From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AA7DDA034F; Fri, 8 Oct 2021 12:05:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D905E410EB; Fri, 8 Oct 2021 12:05:56 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2072.outbound.protection.outlook.com [40.107.92.72]) by mails.dpdk.org (Postfix) with ESMTP id 5C408410E7 for ; Fri, 8 Oct 2021 12:05:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m4dzFtzv1+/03hHXXlAf2W6mHnWrIXT1O69qCrQaUzHJr4jqMvUEysoAfmnyVzK527c8DxQiNj9yryDhZWZrOTj2hx/OcNpzbGs9u6qyWPXuaAJ4fYGiuXR50RbOzfwk2kLhR1wTJ5RaJipDwFO8MWS8RPxY22C84KFzwwqfzV6nEGyb3gEZNczi4pA+o5jsTxLUC/AGHe8nHyms5eUOHT/wG3kCI968Gk9xTbhKfZJrAoDXYYw0VZ+zLxqhjz3bLe7cpC/qqZ0RfvW1KTeoiolrHGdSBBMcwB0gMXZHyA62HkdGvB6Tlpve/ko8qzELidtbO8RoL0QnYz9A3C9oog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l+TrV91p+XM7gIQz0flvbT/rk2TcwhrF1JNsaCaFEoc=; b=YUh22Q6jdE+pHwW6DfAQZdVRrhB0F+GtcalobWhGwXLWyNDssLj+EeFQiZ9ofceTwxrpV/Jea4fromEV8YYj8tIYGW+prUNdJ2BrRv7xxi4VLD4O9yS1RJCcM6bUaH04hr/zfDMYJiJepemBpSikgDvz1+buR1Q+dO4804Y6C59nqFOgWoxq3e0/chlcwcSBef385mZ/A18ivbvi+ApQZ1tn2meouRtFG1VObAYzQ1Rdj3b7jSqfMjnlnApK9OGT2ttJdu990YJoyiyw6QQj1BHek6P96iqZbTN8j3ggPqNJJaBLeNIrSc3DS3cPDjq4MNLBXUkYCB6OV/UpeaLMsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l+TrV91p+XM7gIQz0flvbT/rk2TcwhrF1JNsaCaFEoc=; b=c/oteaqUQJB767wJVZ+HkNET7fHtjazeR+x2Igt6MxJl+zKvo7TVq8hb2mEg06w8HWDa/jv39/ZUCj9DyYa0AoPOCEFI+9HdMK+VYyBsGdkkXZ8aoQn5kycUfm6TmbGyx9PFcCzeeQ/9Of5BCnaiXqRNYlisf3UFOXJNE/kVC7B9bVAiSw7gvPQn5Au3xFhb8sTnPqzMXX264e1vVThxwIQ1WZFqUTOfJg0+ND+1Lvaw8dJ3lrs/3eG2zmkHca9Lh/UNKjM7s19rGuoa2R4b22K1Uk2dKP9egJsBCMflWSsVdxMuuzE9ipnyiKsokNYRXF/dUEf+Ng1XQ4FXh7+ORg== Received: from MW4PR03CA0327.namprd03.prod.outlook.com (2603:10b6:303:dd::32) by DM6PR12MB3050.namprd12.prod.outlook.com (2603:10b6:5:11a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.22; Fri, 8 Oct 2021 10:05:50 +0000 Received: from CO1NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dd:cafe::a0) by MW4PR03CA0327.outlook.office365.com (2603:10b6:303:dd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Fri, 8 Oct 2021 10:05:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT017.mail.protection.outlook.com (10.13.175.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4587.18 via Frontend Transport; Fri, 8 Oct 2021 10:05:50 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 8 Oct 2021 10:05:45 +0000 From: Rongwei Liu To: , , , CC: , Date: Fri, 8 Oct 2021 13:05:29 +0300 Message-ID: <20211008100529.2423738-3-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211008100529.2423738-1-rongweil@nvidia.com> References: <2308701.4c83qqXp4g@thomas> <20211008100529.2423738-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0c5453ca-4d2b-42af-1ce7-08d98a433508 X-MS-TrafficTypeDiagnostic: DM6PR12MB3050: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1013; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0jvQ9k2xcRUITqhhz9wk2ZNcIpvOHdVc0eqLWbdEzr8x5PjKrsA1F3zaausKeTlgLAEQLvV0FQtrACjKo4+rCblyAB4kwi2FL31BjJJM1RpL25+bi2y9XNdxH/n3xLVtqv9uDE9LIG/Z11H+tMg/J+rnYYDeIlvJTQl61CzmizoNKL3OHENLXsoMqCgWg1B3FOqRFjCN4WKn44s2o67aLpVJ3ecHCR+SWKEMqQgKsjHu9DvAPRA7DDSeo4aHFZyMF2RQ4yKYdre17rxSPCnWDiBGPKxGiVsjNAkhQZodGatmkUEeHY3KFcNJUvDrgvcgzviefog+AXJi98WPldglj1Bd9HWof8QE0dXv8tG8+L2TUktrjUv9f8UY1o0j83pm9R0yBBkXQe/RPiCKVsCzNYj8RaQlGr+fXKkp6edQC1Tjw5mJXPwp5daIEwmOs98cHl23w+Z/q1CQM/zOph2Jrd0vG8FxXgw96zqmoIg/FZnRVH509FR9oFAOYh6jgeXHpI5vnTgOXIdgCIvLXSNyfItvvCchO/s3NsgxfAW6ZAsYCroDXPL26cy65nCc5o/qDABMTqTdFkbRHuG3CSUW5aJqGBhcvFlBeFNtAcN2E5fNK2ZJzXRkguLQXh/bVrOAknvDOdkfqsTNgdmTSEynpp+i+NPOjnlrTuGs0Oa1qJH/udfednCVWpFnshyZkjvRSe2x18TAzyM1+LBr/SJH5Q== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(7696005)(36906005)(54906003)(110136005)(316002)(36860700001)(8676002)(55016002)(6666004)(508600001)(26005)(8936002)(70206006)(86362001)(36756003)(16526019)(186003)(1076003)(70586007)(82310400003)(4326008)(6286002)(5660300002)(2906002)(426003)(336012)(83380400001)(47076005)(107886003)(2616005)(356005)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2021 10:05:50.5702 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c5453ca-4d2b-42af-1ce7-08d98a433508 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3050 Subject: [dpdk-dev] [PATCH v3 2/2] net/mlx5: support socket direct mode bonding X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In socket direct mode, it's possible to bind any two (maybe four in future) PCIe devices with IDs like xxxx:xx:xx.x and yyyy:yy:yy.y. Bonding member interfaces are unnecessary to have the same PCIe domain/bus/device ID anymore, Kernel driver uses "system_image_guid" to identify if devices can be bound together or not. Sysfs "phys_switch_id" is used to get "system_image_guid" of each network interface. OFED 5.4+ is required to support "phys_switch_id". Centos 8.1 needs to enable switch_dev mode first Signed-off-by: Rongwei Liu Acked-by: Viacheslav Ovsiienko --- doc/guides/rel_notes/release_21_11.rst | 4 +++ drivers/net/mlx5/linux/mlx5_os.c | 43 ++++++++++++++++++++------ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index dfc2cbdeed..54a7bd230f 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -106,6 +106,10 @@ New Features * Added DES-CBC, AES-XCBC-MAC, AES-CMAC and non-HMAC algo support. * Added PDCP short MAC-I support. +* **Updated Mellanox mlx5 driver.** + + * Added socket direct mode bonding support which needs OFED 5.4+. + * **Updated NXP dpaa2_sec crypto PMD.** * Added PDCP short MAC-I support. diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 3746057673..1d57b934fc 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -2008,6 +2008,8 @@ mlx5_device_bond_pci_match(const struct ibv_device *ibv_dev, FILE *bond_file = NULL, *file; int pf = -1; int ret; + uint8_t cur_guid[32] = {0}; + uint8_t guid[32] = {0}; /* * Try to get master device name. If something goes @@ -2022,6 +2024,8 @@ mlx5_device_bond_pci_match(const struct ibv_device *ibv_dev, np = mlx5_nl_portnum(nl_rdma, ibv_dev->name); if (!np) return -1; + if (mlx5_get_device_guid(pci_dev, cur_guid, sizeof(cur_guid)) < 0) + return -1; /* * The Master device might not be on the predefined * port (not on port index 1, it is not garanted), @@ -2050,6 +2054,7 @@ mlx5_device_bond_pci_match(const struct ibv_device *ibv_dev, char tmp_str[IF_NAMESIZE + 32]; struct rte_pci_addr pci_addr; struct mlx5_switch_info info; + int ret; /* Process slave interface names in the loop. */ snprintf(tmp_str, sizeof(tmp_str), @@ -2080,15 +2085,6 @@ mlx5_device_bond_pci_match(const struct ibv_device *ibv_dev, tmp_str); break; } - /* Match PCI address, allows BDF0+pfx or BDFx+pfx. */ - if (pci_dev->domain == pci_addr.domain && - pci_dev->bus == pci_addr.bus && - pci_dev->devid == pci_addr.devid && - ((pci_dev->function == 0 && - pci_dev->function + owner == pci_addr.function) || - (pci_dev->function == owner && - pci_addr.function == owner))) - pf = info.port_name; /* Get ifindex. */ snprintf(tmp_str, sizeof(tmp_str), "/sys/class/net/%s/ifindex", ifname); @@ -2105,6 +2101,30 @@ mlx5_device_bond_pci_match(const struct ibv_device *ibv_dev, bond_info->ports[info.port_name].pci_addr = pci_addr; bond_info->ports[info.port_name].ifindex = ifindex; bond_info->n_port++; + /* + * Under socket direct mode, bonding will use + * system_image_guid as identification. + * After OFED 5.4, guid is readable (ret >= 0) under sysfs. + * All bonding members should have the same guid even if driver + * is using PCIe BDF. + */ + ret = mlx5_get_device_guid(&pci_addr, guid, sizeof(guid)); + if (ret < 0) + break; + else if (ret > 0) { + if (!memcmp(guid, cur_guid, sizeof(guid)) && + owner == info.port_name && + (owner != 0 || (owner == 0 && + !rte_pci_addr_cmp(pci_dev, &pci_addr)))) + pf = info.port_name; + } else if (pci_dev->domain == pci_addr.domain && + pci_dev->bus == pci_addr.bus && + pci_dev->devid == pci_addr.devid && + ((pci_dev->function == 0 && + pci_dev->function + owner == pci_addr.function) || + (pci_dev->function == owner && + pci_addr.function == owner))) + pf = info.port_name; } if (pf >= 0) { /* Get bond interface info */ @@ -2117,6 +2137,11 @@ mlx5_device_bond_pci_match(const struct ibv_device *ibv_dev, DRV_LOG(INFO, "PF device %u, bond device %u(%s)", ifindex, bond_info->ifindex, bond_info->ifname); } + if (owner == 0 && pf != 0) { + DRV_LOG(INFO, "PCIe instance %04x:%02x:%02x.%x isn't bonding owner", + pci_dev->domain, pci_dev->bus, pci_dev->devid, + pci_dev->function); + } return pf; } -- 2.27.0