ethdev: introduce representor type
authorXueming Li <xuemingl@nvidia.com>
Thu, 11 Mar 2021 13:13:24 +0000 (13:13 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Mar 2021 19:15:29 +0000 (20:15 +0100)
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 <xuemingl@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Hyong Youb Kim <hyonkim@cisco.com>
doc/guides/rel_notes/release_21_05.rst
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/enic/enic_ethdev.c
drivers/net/i40e/i40e_ethdev.c
drivers/net/ice/ice_dcf_ethdev.c
drivers/net/ixgbe/ixgbe_ethdev.c
drivers/net/mlx5/linux/mlx5_os.c
drivers/net/txgbe/txgbe_ethdev.c
lib/librte_ethdev/ethdev_driver.h
lib/librte_ethdev/ethdev_private.c
lib/librte_ethdev/rte_ethdev.h

index f262d48e82fd72c8c22523eceae9b1875ff23f5c..1d9ac0a2faa4d2fb8d3751cc409a2b9f28416893 100644 (file)
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Enhanced ethdev representor syntax.**
+
+  * Introduced representor type of VF.
+
 * **Updated Broadcom bnxt driver.**
 
   * Updated HWRM structures to 1.10.2.15 version.
index 6cc6af0a66c6b2f0384a058447b6d42cb7ee5d8a..f1dd40591fb4ac5c07af4d1feac88152f4906506 100644 (file)
@@ -5862,6 +5862,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",
index b3f441c8f71cd8e6eee4a33e12913c98fd8a083c..def669f41142ffd7236c9d245d3aea7f0dd47fb0 100644 (file)
@@ -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,
index d7cd049891696531a8a84ef36049855b287f8770..9b86bcdc698400d9acfd228b51b66074ba542df3 100644 (file)
@@ -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,
index e0772295e91688874ae25d5dd2ba95851ee53a39..194f57d7b7198e811b3ddaf6d8f969d91d2df35b 100644 (file)
@@ -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)
index 761a0f26bb96995b6b65063abb7d4da650283779..8a9a21e7c25b5bf68d5c5a9bbe52d3af6f50c30c 100644 (file)
@@ -1718,6 +1718,13 @@ eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
        } else
                memset(&eth_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,
index 81eb2e4b0591c7283b0d41f8e4a9179999e11281..92fa178b4688a92d753603355051c03eb3434c78 100644 (file)
@@ -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)
index 1ab8d2cdedc7b2ee6d624a41d8cb8cad276611e3..5509e5f35510969d223acf5b029fbafd21e4d270 100644 (file)
@@ -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)
index 57fdedaa1a605da897e2c9dfa130a7a0774858e2..d68b8401e7d4dbfdc2d8dcbc58dc4d8a54f02dcc 100644 (file)
@@ -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 */
 };
 
 /**
index 5960c75cc58fc3455ef0a56ada1ac9b5395bc28d..2d51e3857a22de960f6071c885c76431e838e90c 100644 (file)
@@ -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,
                &eth_da->nb_representor_ports, RTE_MAX_ETHPORTS);
 }
index 059a0610720027992e89a135124ab3a8c80999c1..1f378958caae9003660bb894a277e62da72fdc50 100644 (file)
@@ -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