From: Rahul Lakkireddy Date: Fri, 27 Sep 2019 20:30:08 +0000 (+0530) Subject: net/cxgbe: separate VF only devargs X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=dd7c9f12762e69eb4fdce16c1b01547a67a8ab2c;p=dpdk.git net/cxgbe: separate VF only devargs Rework devargs parsing logic to separate VF only args. Signed-off-by: Rahul Lakkireddy --- diff --git a/doc/guides/nics/cxgbe.rst b/doc/guides/nics/cxgbe.rst index fc74b571c5..f94b8371e0 100644 --- a/doc/guides/nics/cxgbe.rst +++ b/doc/guides/nics/cxgbe.rst @@ -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 diff --git a/drivers/net/cxgbe/base/adapter.h b/drivers/net/cxgbe/base/adapter.h index 2dfdb2df8a..fcc84e4e9f 100644 --- a/drivers/net/cxgbe/base/adapter.h +++ b/drivers/net/cxgbe/base/adapter.h @@ -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; }; /** diff --git a/drivers/net/cxgbe/cxgbe.h b/drivers/net/cxgbe/cxgbe.h index 3f97fa58b2..3a50502b7e 100644 --- a/drivers/net/cxgbe/cxgbe.h +++ b/drivers/net/cxgbe/cxgbe.h @@ -50,8 +50,11 @@ 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_ */ diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 13df45b2d9..2a2875f89b 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -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) { diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c index c3e6b9557f..6a6137f06a 100644 --- a/drivers/net/cxgbe/cxgbe_main.c +++ b/drivers/net/cxgbe/cxgbe_main.c @@ -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; } /** diff --git a/drivers/net/cxgbe/cxgbevf_ethdev.c b/drivers/net/cxgbe/cxgbevf_ethdev.c index 60e96aa4e4..cc0938b430 100644 --- a/drivers/net/cxgbe/cxgbevf_ethdev.c +++ b/drivers/net/cxgbe/cxgbevf_ethdev.c @@ -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> ");