net/cxgbe: separate VF only devargs
authorRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Fri, 27 Sep 2019 20:30:08 +0000 (02:00 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:57 +0000 (15:00 +0200)
Rework devargs parsing logic to separate VF only args.

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
doc/guides/nics/cxgbe.rst
drivers/net/cxgbe/base/adapter.h
drivers/net/cxgbe/cxgbe.h
drivers/net/cxgbe/cxgbe_ethdev.c
drivers/net/cxgbe/cxgbe_main.c
drivers/net/cxgbe/cxgbevf_ethdev.c

index fc74b57..f94b837 100644 (file)
@@ -118,12 +118,18 @@ be passed as part of EAL arguments. For example,
 
    testpmd -w 02:00.4,keep_ovlan=1 -- -i
 
+Common Runtime Options
+^^^^^^^^^^^^^^^^^^^^^^
+
 - ``keep_ovlan`` (default **0**)
 
   Toggle behavior to keep/strip outer VLAN in Q-in-Q packets. If
   enabled, the outer VLAN tag is preserved in Q-in-Q packets. Otherwise,
   the outer VLAN tag is stripped in Q-in-Q packets.
 
+CXGBE VF Only Runtime Options
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
 - ``force_link_up`` (default **0**)
 
   When set to 1, CXGBEVF PMD always forces link as up for all VFs on
index 2dfdb2d..fcc84e4 100644 (file)
@@ -299,6 +299,11 @@ struct mbox_entry {
 
 TAILQ_HEAD(mbox_list, mbox_entry);
 
+struct adapter_devargs {
+       bool keep_ovlan;
+       bool force_link_up;
+};
+
 struct adapter {
        struct rte_pci_device *pdev;       /* associated rte pci device */
        struct rte_eth_dev *eth_dev;       /* first port's rte eth device */
@@ -331,6 +336,8 @@ struct adapter {
        struct mpstcam_table *mpstcam;
 
        struct tid_info tids;     /* Info used to access TID related tables */
+
+       struct adapter_devargs devargs;
 };
 
 /**
index 3f97fa5..3a50502 100644 (file)
                           DEV_RX_OFFLOAD_SCATTER)
 
 
-#define CXGBE_DEVARG_KEEP_OVLAN "keep_ovlan"
-#define CXGBE_DEVARG_FORCE_LINK_UP "force_link_up"
+/* Common PF and VF devargs */
+#define CXGBE_DEVARG_CMN_KEEP_OVLAN "keep_ovlan"
+
+/* VF only devargs */
+#define CXGBE_DEVARG_VF_FORCE_LINK_UP "force_link_up"
 
 bool cxgbe_force_linkup(struct adapter *adap);
 int cxgbe_probe(struct adapter *adapter);
@@ -76,7 +79,7 @@ int cxgbe_setup_rss(struct port_info *pi);
 void cxgbe_enable_rx_queues(struct port_info *pi);
 void cxgbe_print_port_info(struct adapter *adap);
 void cxgbe_print_adapter_info(struct adapter *adap);
-int cxgbe_get_devargs(struct rte_devargs *devargs, const char *key);
+void cxgbe_process_devargs(struct adapter *adap);
 void cxgbe_configure_max_ethqsets(struct adapter *adapter);
 
 #endif /* _CXGBE_H_ */
index 13df45b..2a2875f 100644 (file)
@@ -1190,6 +1190,8 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev)
        adapter->eth_dev = eth_dev;
        pi->adapter = adapter;
 
+       cxgbe_process_devargs(adapter);
+
        err = cxgbe_probe(adapter);
        if (err) {
                dev_err(adapter, "%s: cxgbe probe failed with err %d\n",
@@ -1237,8 +1239,7 @@ RTE_PMD_REGISTER_PCI(net_cxgbe, rte_cxgbe_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_cxgbe, cxgb4_pci_tbl);
 RTE_PMD_REGISTER_KMOD_DEP(net_cxgbe, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_cxgbe,
-                             CXGBE_DEVARG_KEEP_OVLAN "=<0|1> "
-                             CXGBE_DEVARG_FORCE_LINK_UP "=<0|1> ");
+                             CXGBE_DEVARG_CMN_KEEP_OVLAN "=<0|1> ");
 
 RTE_INIT(cxgbe_init_log)
 {
index c3e6b95..6a6137f 100644 (file)
@@ -669,19 +669,25 @@ void cxgbe_print_port_info(struct adapter *adap)
        }
 }
 
-static int
-check_devargs_handler(__rte_unused const char *key, const char *value,
-                     __rte_unused void *opaque)
+static int check_devargs_handler(const char *key, const char *value, void *p)
 {
-       if (strcmp(value, "1"))
-               return -1;
+       if (!strncmp(key, CXGBE_DEVARG_CMN_KEEP_OVLAN, strlen(key)) ||
+           !strncmp(key, CXGBE_DEVARG_VF_FORCE_LINK_UP, strlen(key))) {
+               if (!strncmp(value, "1", 1)) {
+                       bool *dst_val = (bool *)p;
+
+                       *dst_val = true;
+               }
+       }
 
        return 0;
 }
 
-int cxgbe_get_devargs(struct rte_devargs *devargs, const char *key)
+static int cxgbe_get_devargs(struct rte_devargs *devargs, const char *key,
+                            void *p)
 {
        struct rte_kvargs *kvlist;
+       int ret = 0;
 
        if (!devargs)
                return 0;
@@ -690,24 +696,44 @@ int cxgbe_get_devargs(struct rte_devargs *devargs, const char *key)
        if (!kvlist)
                return 0;
 
-       if (!rte_kvargs_count(kvlist, key)) {
-               rte_kvargs_free(kvlist);
-               return 0;
-       }
+       if (!rte_kvargs_count(kvlist, key))
+               goto out;
 
-       if (rte_kvargs_process(kvlist, key,
-                              check_devargs_handler, NULL) < 0) {
-               rte_kvargs_free(kvlist);
-               return 0;
-       }
+       ret = rte_kvargs_process(kvlist, key, check_devargs_handler, p);
+
+out:
        rte_kvargs_free(kvlist);
 
-       return 1;
+       return ret;
+}
+
+static void cxgbe_get_devargs_int(struct adapter *adap, int *dst,
+                                 const char *key, int default_value)
+{
+       struct rte_pci_device *pdev = adap->pdev;
+       int ret, devarg_value = default_value;
+
+       *dst = default_value;
+       if (!pdev)
+               return;
+
+       ret = cxgbe_get_devargs(pdev->device.devargs, key, &devarg_value);
+       if (ret)
+               return;
+
+       *dst = devarg_value;
+}
+
+void cxgbe_process_devargs(struct adapter *adap)
+{
+       cxgbe_get_devargs_int(adap, &adap->devargs.keep_ovlan,
+                             CXGBE_DEVARG_CMN_KEEP_OVLAN, 0);
+       cxgbe_get_devargs_int(adap, &adap->devargs.force_link_up,
+                             CXGBE_DEVARG_VF_FORCE_LINK_UP, 0);
 }
 
 static void configure_vlan_types(struct adapter *adapter)
 {
-       struct rte_pci_device *pdev = adapter->pdev;
        int i;
 
        for_each_port(adapter, i) {
@@ -742,9 +768,8 @@ static void configure_vlan_types(struct adapter *adapter)
                                 F_OVLAN_EN2 | F_IVLAN_EN);
        }
 
-       if (cxgbe_get_devargs(pdev->device.devargs, CXGBE_DEVARG_KEEP_OVLAN))
-               t4_tp_wr_bits_indirect(adapter, A_TP_INGRESS_CONFIG,
-                                      V_RM_OVLAN(1), V_RM_OVLAN(0));
+       t4_tp_wr_bits_indirect(adapter, A_TP_INGRESS_CONFIG, V_RM_OVLAN(1),
+                              V_RM_OVLAN(!adapter->devargs.keep_ovlan));
 }
 
 static void configure_pcie_ext_tag(struct adapter *adapter)
@@ -1323,14 +1348,10 @@ void t4_os_portmod_changed(const struct adapter *adap, int port_id)
 
 bool cxgbe_force_linkup(struct adapter *adap)
 {
-       struct rte_pci_device *pdev = adap->pdev;
-
        if (is_pf4(adap))
-               return false;   /* force_linkup not required for pf driver*/
-       if (!cxgbe_get_devargs(pdev->device.devargs,
-                              CXGBE_DEVARG_FORCE_LINK_UP))
-               return false;
-       return true;
+               return false;   /* force_linkup not required for pf driver */
+
+       return adap->devargs.force_link_up;
 }
 
 /**
index 60e96aa..cc0938b 100644 (file)
@@ -162,6 +162,9 @@ static int eth_cxgbevf_dev_init(struct rte_eth_dev *eth_dev)
        adapter->pdev = pci_dev;
        adapter->eth_dev = eth_dev;
        pi->adapter = adapter;
+
+       cxgbe_process_devargs(adapter);
+
        err = cxgbevf_probe(adapter);
        if (err) {
                dev_err(adapter, "%s: cxgbevf probe failed with err %d\n",
@@ -208,3 +211,6 @@ static struct rte_pci_driver rte_cxgbevf_pmd = {
 RTE_PMD_REGISTER_PCI(net_cxgbevf, rte_cxgbevf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_cxgbevf, cxgb4vf_pci_tbl);
 RTE_PMD_REGISTER_KMOD_DEP(net_cxgbevf, "* igb_uio | vfio-pci");
+RTE_PMD_REGISTER_PARAM_STRING(net_cxgbevf,
+                             CXGBE_DEVARG_CMN_KEEP_OVLAN "=<0|1> "
+                             CXGBE_DEVARG_VF_FORCE_LINK_UP "=<0|1> ");