From patchwork Tue Nov 17 11:01:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 84266 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7AC4FA04DB; Tue, 17 Nov 2020 12:01:50 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A8038C8B6; Tue, 17 Nov 2020 12:01:44 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 8BD4DC8B0 for ; Tue, 17 Nov 2020 12:01:43 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 17 Nov 2020 13:01:40 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0AHB1eCq019539; Tue, 17 Nov 2020 13:01:40 +0200 From: Xueming Li To: Matan Azrad , Viacheslav Ovsiienko Cc: dev@dpdk.org, xuemingl@nvidia.com, Asaf Penso Date: Tue, 17 Nov 2020 11:01:38 +0000 Message-Id: <1605610898-6671-1-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: set representor device to first PF in bonding mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" When the representor device was set to PF1 in bonding mode, iterating device iterator that looking for representors by bonding device failed to match PF0 pci address with PF1 address. So detaching PF bonding device only detached all representors on PF0. This patch registers all representors of PF1 with PF0 as PCI device. Signed-off-by: Xueming Li Reviewed-by: Slava Ovsiienko --- drivers/net/mlx5/linux/mlx5_os.c | 20 ++++++++++++++++++-- drivers/net/mlx5/mlx5.c | 1 + drivers/net/mlx5/mlx5.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index ce25108b90..4b7fff4eff 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -757,7 +757,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, rte_errno = ENOMEM; return NULL; } - eth_dev->device = dpdk_dev; + priv = eth_dev->data->dev_private; + if (priv->sh->bond_dev != UINT16_MAX) + /* For bonding port, use primary PCI device. */ + eth_dev->device = + rte_eth_devices[priv->sh->bond_dev].device; + else + eth_dev->device = dpdk_dev; eth_dev->dev_ops = &mlx5_os_dev_sec_ops; eth_dev->rx_descriptor_status = mlx5_rx_descriptor_status; eth_dev->tx_descriptor_status = mlx5_tx_descriptor_status; @@ -1373,7 +1379,17 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, eth_dev->data->dev_private = priv; priv->dev_data = eth_dev->data; eth_dev->data->mac_addrs = priv->mac; - eth_dev->device = dpdk_dev; + if (spawn->pf_bond < 0) { + eth_dev->device = dpdk_dev; + } else { + /* Use primary bond PCI as device. */ + if (sh->bond_dev == UINT16_MAX) { + sh->bond_dev = eth_dev->data->port_id; + eth_dev->device = dpdk_dev; + } else { + eth_dev->device = rte_eth_devices[sh->bond_dev].device; + } + } eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; /* Configure the first MAC address by default. */ if (mlx5_get_mac(eth_dev, &mac.addr_bytes)) { diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 31011c3a72..ede5fd44ab 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -915,6 +915,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, goto error; } sh->refcnt = 1; + sh->bond_dev = UINT16_MAX; sh->max_port = spawn->max_port; strncpy(sh->ibdev_name, mlx5_os_get_ctx_device_name(sh->ctx), sizeof(sh->ibdev_name) - 1); diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 0155f5ca23..b0c3a2286d 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -705,6 +705,7 @@ struct mlx5_flex_parser_profiles { struct mlx5_dev_ctx_shared { LIST_ENTRY(mlx5_dev_ctx_shared) next; uint32_t refcnt; + uint16_t bond_dev; /* Bond primary device id. */ uint32_t devx:1; /* Opened with DV. */ uint32_t flow_hit_aso_en:1; /* Flow Hit ASO is supported. */ uint32_t eqn; /* Event Queue number. */