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 DCC4AA0575; Thu, 11 Mar 2021 14:14:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C49D722A456; Thu, 11 Mar 2021 14:14:04 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by mails.dpdk.org (Postfix) with ESMTP id EBD2D40689 for ; Thu, 11 Mar 2021 14:14:02 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@nvidia.com) with SMTP; 11 Mar 2021 15:13:59 +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 12BDDkZ3023953; Thu, 11 Mar 2021 15:13:59 +0200 From: Xueming Li To: Andrew Rybchenko , Ferruh Yigit Cc: dev@dpdk.org, Viacheslav Ovsiienko , xuemingl@nvidia.com, Asaf Penso , Ajit Khaparde , Somnath Kotur , John Daley , Hyong Youb Kim , Beilei Xing , Jeff Guo , Qiming Yang , Qi Zhang , Haiyue Wang , Matan Azrad , Shahaf Shuler , Jiawen Wu , Jian Wang , Thomas Monjalon Date: Thu, 11 Mar 2021 13:13:24 +0000 Message-Id: <1615468416-10115-2-git-send-email-xuemingl@nvidia.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615468416-10115-1-git-send-email-xuemingl@nvidia.com> References: <1615468416-10115-1-git-send-email-xuemingl@nvidia.com> In-Reply-To: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> References: <1608303356-13089-2-git-send-email-xuemingl@nvidia.com> Subject: [dpdk-dev] [PATCH v9 01/10] ethdev: introduce representor type 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" To support more representor type, this patch introduces representor type enum. The enum is subject to be extended to support new representor in patches upcoming. For each devarg structure, only one type supported. Signed-off-by: Xueming Li Acked-by: Viacheslav Ovsiienko Acked-by: Thomas Monjalon Acked-by: Ajit Khaparde Acked-by: Andrew Rybchenko Acked-by: Hyong Youb Kim --- drivers/net/bnxt/bnxt_ethdev.c | 7 +++++++ drivers/net/enic/enic_ethdev.c | 6 ++++++ drivers/net/i40e/i40e_ethdev.c | 7 +++++++ drivers/net/ice/ice_dcf_ethdev.c | 2 ++ drivers/net/ixgbe/ixgbe_ethdev.c | 7 +++++++ drivers/net/mlx5/linux/mlx5_os.c | 11 +++++++++++ drivers/net/txgbe/txgbe_ethdev.c | 2 ++ lib/librte_ethdev/ethdev_driver.h | 7 ++++++- lib/librte_ethdev/ethdev_private.c | 5 +++++ lib/librte_ethdev/rte_ethdev.h | 8 ++++++++ 10 files changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 9824cdb6d8..55110ee984 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -5646,6 +5646,13 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, int i, ret = 0; struct rte_kvargs *kvlist = NULL; + if (eth_da->type == RTE_ETH_REPRESENTOR_NONE) + return 0; + if (eth_da->type != RTE_ETH_REPRESENTOR_VF) { + PMD_DRV_LOG(ERR, "unsupported representor type %d\n", + eth_da->type); + return -ENOTSUP; + } num_rep = eth_da->nb_representor_ports; if (num_rep > BNXT_MAX_VF_REPS) { PMD_DRV_LOG(ERR, "nb_representor_ports = %d > %d MAX VF REPS\n", diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index b3f441c8f7..def669f411 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -1312,6 +1312,12 @@ static int eth_enic_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, if (retval) return retval; } + if (eth_da.nb_representor_ports > 0 && + eth_da.type != RTE_ETH_REPRESENTOR_VF) { + ENICPMD_LOG(ERR, "unsupported representor type: %s\n", + pci_dev->device.devargs->args); + return -ENOTSUP; + } retval = rte_eth_dev_create(&pci_dev->device, pci_dev->device.name, sizeof(struct enic), eth_dev_pci_specific_init, pci_dev, diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index d7cd049891..9b86bcdc69 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -639,6 +639,13 @@ eth_i40e_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, return retval; } + if (eth_da.nb_representor_ports > 0 && + eth_da.type != RTE_ETH_REPRESENTOR_VF) { + PMD_DRV_LOG(ERR, "unsupported representor type: %s\n", + pci_dev->device.devargs->args); + return -ENOTSUP; + } + retval = rte_eth_dev_create(&pci_dev->device, pci_dev->device.name, sizeof(struct i40e_adapter), eth_dev_pci_specific_init, pci_dev, diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index e0772295e9..194f57d7b7 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -1089,6 +1089,8 @@ eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv, ice_dcf_dev_init); if (ret || !eth_da.nb_representor_ports) return ret; + if (eth_da.type != RTE_ETH_REPRESENTOR_VF) + return -ENOTSUP; dcf_ethdev = rte_eth_dev_allocated(pci_dev->device.name); if (dcf_ethdev == NULL) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 761a0f26bb..8a9a21e7c2 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -1718,6 +1718,13 @@ eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, } else memset(ð_da, 0, sizeof(eth_da)); + if (eth_da.nb_representor_ports > 0 && + eth_da.type != RTE_ETH_REPRESENTOR_VF) { + PMD_DRV_LOG(ERR, "unsupported representor type: %s\n", + pci_dev->device.devargs->args); + return -ENOTSUP; + } + retval = rte_eth_dev_create(&pci_dev->device, pci_dev->device.name, sizeof(struct ixgbe_adapter), eth_dev_pci_specific_init, pci_dev, diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 81eb2e4b05..92fa178b46 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -751,6 +751,17 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, strerror(rte_errno)); return NULL; } + if (eth_da.type == RTE_ETH_REPRESENTOR_NONE) { + /* Representor not specified. */ + rte_errno = EBUSY; + return NULL; + } + if (eth_da.type != RTE_ETH_REPRESENTOR_VF) { + rte_errno = ENOTSUP; + DRV_LOG(ERR, "unsupported representor type: %s", + dpdk_dev->devargs->args); + return NULL; + } for (i = 0; i < eth_da.nb_representor_ports; ++i) if (eth_da.representor_ports[i] == (uint16_t)switch_info->port_name) diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index 90137d0ceb..a869b06339 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -882,6 +882,8 @@ eth_txgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, if (retval || eth_da.nb_representor_ports < 1) return retval; + if (eth_da.type != RTE_ETH_REPRESENTOR_VF) + return -ENOTSUP; pf_ethdev = rte_eth_dev_allocated(pci_dev->device.name); if (pf_ethdev == NULL) diff --git a/lib/librte_ethdev/ethdev_driver.h b/lib/librte_ethdev/ethdev_driver.h index 57fdedaa1a..d68b8401e7 100644 --- a/lib/librte_ethdev/ethdev_driver.h +++ b/lib/librte_ethdev/ethdev_driver.h @@ -1216,7 +1216,11 @@ __rte_internal int rte_eth_switch_domain_free(uint16_t domain_id); -/** Generic Ethernet device arguments */ +/** + * Generic Ethernet device arguments + * + * One type of representor each structure. + */ struct rte_eth_devargs { uint16_t ports[RTE_MAX_ETHPORTS]; /** port/s number to enable on a multi-port single function */ @@ -1226,6 +1230,7 @@ struct rte_eth_devargs { /** representor port/s identifier to enable on device */ uint16_t nb_representor_ports; /** number of ports in representor port field */ + enum rte_eth_representor_type type; /* type of representor */ }; /** diff --git a/lib/librte_ethdev/ethdev_private.c b/lib/librte_ethdev/ethdev_private.c index 5960c75cc5..2d51e3857a 100644 --- a/lib/librte_ethdev/ethdev_private.c +++ b/lib/librte_ethdev/ethdev_private.c @@ -111,11 +111,16 @@ rte_eth_devargs_process_range(char *str, uint16_t *list, uint16_t *len_list, return 0; } +/* + * representor format: + * #: range or single number of VF representor + */ int rte_eth_devargs_parse_representor_ports(char *str, void *data) { struct rte_eth_devargs *eth_da = data; + eth_da->type = RTE_ETH_REPRESENTOR_VF; return rte_eth_devargs_process_range(str, eth_da->representor_ports, ð_da->nb_representor_ports, RTE_MAX_ETHPORTS); } diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 059a061072..1f378958ca 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1506,6 +1506,14 @@ struct rte_eth_rxseg_capa { * Ethernet device information */ +/** + * Ethernet device representor port type. + */ +enum rte_eth_representor_type { + RTE_ETH_REPRESENTOR_NONE, /**< not a representor. */ + RTE_ETH_REPRESENTOR_VF, /**< representor of Virtual Function. */ +}; + /** * A structure used to retrieve the contextual information of * an Ethernet device, such as the controlling driver of the -- 2.25.1