[dpdk-dev,v9] net/i40e: determine number of queues per VF during run time

Message ID 1514301894-58374-1-git-send-email-wei.dai@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Helin Zhang
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Wei Dai Dec. 26, 2017, 3:24 p.m. UTC
  Without this patch, the number of queues per i40e  VF is defined as 4
by CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4 in config/common_base.
It is fixed value determined in building time and can't be changed
during run time.
With this patch, the number of queues per i40e VF can be determinated
during run time. For example, if the PCI address of an i40e PF is
aaaa:bb.cc, with the EAL parameter -w aaaa:bb.cc,queue-num-per-vf=8 ,
the number of queues per VF created from this PF is 8.
If there is no "queue-num-per-vf" setting in EAL parameters, it is 4
by default as before. And if the value after the "queue-num-per-vf"
is invalid, it is set as 4 forcibly. The valid values include 1, 2, 4,
8, 16 .

Signed-off-by: Wei Dai <wei.dai@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
v9:
    v9 = v8+v7, is a complete version for maintainer's convenience.
v8:
    As v7 patch has been accepted into dpdk-next-net-intel, this patch
    is based on v7 patch.
    add description in i40e document
    fix the last member of valid_keys[] for rte_kvargs_parse( )
    add RTE_PMD_REGISTER_PARAM_STRING for this feature
v7:
    use the macro instead of natural number
    correct git log message as the EAL parameter is only valid for PF
v6:
    fix a small bug when detecting end character of strtoul
v5:
    fix git log message and WARNING of coding stype
v4:
    use rte_kvargs instead of pervious parsing function;
    use malloc/free instead of rte_zmalloc/rte_free.
v3:
    fix WARNING of coding style issues from checkpatch@dpdk.org
v2:
    fix WARNING of coding style issues from checkpatch@dpdk.org
---
 config/common_base             |  1 -
 doc/guides/nics/i40e.rst       | 12 ++++---
 drivers/net/i40e/i40e_ethdev.c | 75 +++++++++++++++++++++++++++++++++++++++---
 3 files changed, 78 insertions(+), 10 deletions(-)
  

Comments

Zhang, Helin Jan. 8, 2018, 6 a.m. UTC | #1
> -----Original Message-----
> From: Dai, Wei
> Sent: Tuesday, December 26, 2017 11:25 PM
> To: Wu, Jingjing; Xing, Beilei; Zhang, Helin
> Cc: dev@dpdk.org; Dai, Wei
> Subject: [PATCH v9] net/i40e: determine number of queues per VF during run
> time
> 
> Without this patch, the number of queues per i40e  VF is defined as 4 by
> CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4 in config/common_base.
> It is fixed value determined in building time and can't be changed during run
> time.
> With this patch, the number of queues per i40e VF can be determinated during
> run time. For example, if the PCI address of an i40e PF is aaaa:bb.cc, with the
> EAL parameter -w aaaa:bb.cc,queue-num-per-vf=8 , the number of queues per
> VF created from this PF is 8.
> If there is no "queue-num-per-vf" setting in EAL parameters, it is 4 by default as
> before. And if the value after the "queue-num-per-vf"
> is invalid, it is set as 4 forcibly. The valid values include 1, 2, 4, 8, 16 .
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> ---
> v9:
>     v9 = v8+v7, is a complete version for maintainer's convenience.
> v8:
>     As v7 patch has been accepted into dpdk-next-net-intel, this patch
>     is based on v7 patch.
>     add description in i40e document
>     fix the last member of valid_keys[] for rte_kvargs_parse( )
>     add RTE_PMD_REGISTER_PARAM_STRING for this feature
> v7:
>     use the macro instead of natural number
>     correct git log message as the EAL parameter is only valid for PF
> v6:
>     fix a small bug when detecting end character of strtoul
> v5:
>     fix git log message and WARNING of coding stype
> v4:
>     use rte_kvargs instead of pervious parsing function;
>     use malloc/free instead of rte_zmalloc/rte_free.
> v3:
>     fix WARNING of coding style issues from checkpatch@dpdk.org
> v2:
>     fix WARNING of coding style issues from checkpatch@dpdk.org
> ---
>  config/common_base             |  1 -
>  doc/guides/nics/i40e.rst       | 12 ++++---
>  drivers/net/i40e/i40e_ethdev.c | 75
> +++++++++++++++++++++++++++++++++++++++---
>  3 files changed, 78 insertions(+), 10 deletions(-)

BTW, I think release notes should be updated for your modifications.
  
Ferruh Yigit Jan. 8, 2018, 1:23 p.m. UTC | #2
On 12/26/2017 3:24 PM, Wei Dai wrote:
> Without this patch, the number of queues per i40e  VF is defined as 4
> by CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4 in config/common_base.
> It is fixed value determined in building time and can't be changed
> during run time.
> With this patch, the number of queues per i40e VF can be determinated
> during run time. For example, if the PCI address of an i40e PF is
> aaaa:bb.cc, with the EAL parameter -w aaaa:bb.cc,queue-num-per-vf=8 ,
> the number of queues per VF created from this PF is 8.
> If there is no "queue-num-per-vf" setting in EAL parameters, it is 4
> by default as before. And if the value after the "queue-num-per-vf"
> is invalid, it is set as 4 forcibly. The valid values include 1, 2, 4,
> 8, 16 .
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> ---
> v9:
>     v9 = v8+v7, is a complete version for maintainer's convenience.
> v8:
>     As v7 patch has been accepted into dpdk-next-net-intel, this patch
>     is based on v7 patch.
>     add description in i40e document
>     fix the last member of valid_keys[] for rte_kvargs_parse( )
>     add RTE_PMD_REGISTER_PARAM_STRING for this feature
> v7:
>     use the macro instead of natural number
>     correct git log message as the EAL parameter is only valid for PF
> v6:
>     fix a small bug when detecting end character of strtoul
> v5:
>     fix git log message and WARNING of coding stype
> v4:
>     use rte_kvargs instead of pervious parsing function;
>     use malloc/free instead of rte_zmalloc/rte_free.
> v3:
>     fix WARNING of coding style issues from checkpatch@dpdk.org
> v2:
>     fix WARNING of coding style issues from checkpatch@dpdk.org
> ---
>  config/common_base             |  1 -
>  doc/guides/nics/i40e.rst       | 12 ++++---
>  drivers/net/i40e/i40e_ethdev.c | 75 +++++++++++++++++++++++++++++++++++++++---
>  3 files changed, 78 insertions(+), 10 deletions(-)
> 
> diff --git a/config/common_base b/config/common_base
> index e74febe..4e20389 100644
> --- a/config/common_base
> +++ b/config/common_base
> @@ -208,7 +208,6 @@ CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=y
>  CONFIG_RTE_LIBRTE_I40E_INC_VECTOR=y
>  CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=n
>  CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_PF=64
> -CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4
>  CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4
>  # interval up to 8160 us, aligned to 2 (or default value)
>  CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
> diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
> index cd46874..abb20da 100644
> --- a/doc/guides/nics/i40e.rst
> +++ b/doc/guides/nics/i40e.rst
> @@ -115,10 +115,6 @@ Please note that enabling debugging options may affect system performance.
>  
>    Number of queues reserved for PF.
>  
> -- ``CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF`` (default ``4``)
> -
> -  Number of queues reserved for each SR-IOV VF.
> -
>  - ``CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM`` (default ``4``)
>  

Hi Wei,

What do you think creating a section for "Runtime config options" in same level
for "Config File Options" and explain new "queue-num-per-vf" option there?

Thanks,
ferruh
  
Wei Dai Jan. 9, 2018, 9:09 a.m. UTC | #3
Thanks to Helin and Ferruh,
I will submit v10 patch following your guide.

> -----Original Message-----
> From: Zhang, Helin
> Sent: Monday, January 8, 2018 2:01 PM
> To: Dai, Wei <wei.dai@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>;
> Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v9] net/i40e: determine number of queues per VF during
> run time
> 
> 
> 
> > -----Original Message-----
> > From: Dai, Wei
> > Sent: Tuesday, December 26, 2017 11:25 PM
> > To: Wu, Jingjing; Xing, Beilei; Zhang, Helin
> > Cc: dev@dpdk.org; Dai, Wei
> > Subject: [PATCH v9] net/i40e: determine number of queues per VF during
> > run time
> >
> > Without this patch, the number of queues per i40e  VF is defined as 4
> > by
> > CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4 in
> config/common_base.
> > It is fixed value determined in building time and can't be changed
> > during run time.
> > With this patch, the number of queues per i40e VF can be determinated
> > during run time. For example, if the PCI address of an i40e PF is
> > aaaa:bb.cc, with the EAL parameter -w aaaa:bb.cc,queue-num-per-vf=8 ,
> > the number of queues per VF created from this PF is 8.
> > If there is no "queue-num-per-vf" setting in EAL parameters, it is 4
> > by default as before. And if the value after the "queue-num-per-vf"
> > is invalid, it is set as 4 forcibly. The valid values include 1, 2, 4, 8, 16 .
> >
> > Signed-off-by: Wei Dai <wei.dai@intel.com>
> > Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> > ---
> > v9:
> >     v9 = v8+v7, is a complete version for maintainer's convenience.
> > v8:
> >     As v7 patch has been accepted into dpdk-next-net-intel, this patch
> >     is based on v7 patch.
> >     add description in i40e document
> >     fix the last member of valid_keys[] for rte_kvargs_parse( )
> >     add RTE_PMD_REGISTER_PARAM_STRING for this feature
> > v7:
> >     use the macro instead of natural number
> >     correct git log message as the EAL parameter is only valid for PF
> > v6:
> >     fix a small bug when detecting end character of strtoul
> > v5:
> >     fix git log message and WARNING of coding stype
> > v4:
> >     use rte_kvargs instead of pervious parsing function;
> >     use malloc/free instead of rte_zmalloc/rte_free.
> > v3:
> >     fix WARNING of coding style issues from checkpatch@dpdk.org
> > v2:
> >     fix WARNING of coding style issues from checkpatch@dpdk.org
> > ---
> >  config/common_base             |  1 -
> >  doc/guides/nics/i40e.rst       | 12 ++++---
> >  drivers/net/i40e/i40e_ethdev.c | 75
> > +++++++++++++++++++++++++++++++++++++++---
> >  3 files changed, 78 insertions(+), 10 deletions(-)
> 
> BTW, I think release notes should be updated for your modifications.
  

Patch

diff --git a/config/common_base b/config/common_base
index e74febe..4e20389 100644
--- a/config/common_base
+++ b/config/common_base
@@ -208,7 +208,6 @@  CONFIG_RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC=y
 CONFIG_RTE_LIBRTE_I40E_INC_VECTOR=y
 CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=n
 CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_PF=64
-CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF=4
 CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4
 # interval up to 8160 us, aligned to 2 (or default value)
 CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index cd46874..abb20da 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -115,10 +115,6 @@  Please note that enabling debugging options may affect system performance.
 
   Number of queues reserved for PF.
 
-- ``CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF`` (default ``4``)
-
-  Number of queues reserved for each SR-IOV VF.
-
 - ``CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM`` (default ``4``)
 
   Number of queues reserved for each VMDQ Pool.
@@ -374,6 +370,14 @@  configuration passed on the EAL command line.
 The floating VEB functionality requires a NIC firmware version of 5.0
 or greater.
 
+Number of Queues per VF
+~~~~~~~~~~~~~~~~~~~~~~~
+
+The number of queue per VF is determined by its host PF. If the PCI address of
+an i40e PF is aaaa:bb.cc, the number of queues per VF can be configured with
+EAL parameter like -w aaaa:bb.cc,queue-num-per-vf=n. The value n can be 1, 2, 4,
+8 or 16. If no such parameter is configured, the number of queues per VF is 4
+by default.
 
 Limitations or Known issues
 ---------------------------
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 811cc9f..24dae37 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3971,6 +3971,69 @@  i40e_get_cap(struct i40e_hw *hw)
 	return ret;
 }
 
+#define RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF	4
+#define QUEUE_NUM_PER_VF_ARG			"queue-num-per-vf"
+RTE_PMD_REGISTER_PARAM_STRING(net_i40e,	QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16");
+
+static int i40e_pf_parse_vf_queue_number_handler(const char *key,
+		const char *value,
+		void *opaque)
+{
+	struct i40e_pf *pf;
+	unsigned long num;
+	char *end;
+
+	pf = (struct i40e_pf *)opaque;
+	RTE_SET_USED(key);
+
+	errno = 0;
+	num = strtoul(value, &end, 0);
+	if (errno != 0 || end == value || *end != 0) {
+		PMD_DRV_LOG(WARNING, "Wrong VF queue number = %s, Now it is "
+			    "kept the value = %hu", value, pf->vf_nb_qp_max);
+		return -(EINVAL);
+	}
+
+	if (num <= I40E_MAX_QP_NUM_PER_VF && rte_is_power_of_2(num))
+		pf->vf_nb_qp_max = (uint16_t)num;
+	else
+		/* here return 0 to make next valid same argument work */
+		PMD_DRV_LOG(WARNING, "Wrong VF queue number = %lu, it must be "
+			    "power of 2 and equal or less than 16 !, Now it is "
+			    "kept the value = %hu", num, pf->vf_nb_qp_max);
+
+	return 0;
+}
+
+static int i40e_pf_config_vf_rxq_number(struct rte_eth_dev *dev)
+{
+	static const char * const valid_keys[] = {QUEUE_NUM_PER_VF_ARG, NULL};
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct rte_kvargs *kvlist;
+
+	/* set default queue number per VF as 4 */
+	pf->vf_nb_qp_max = RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF;
+
+	if (dev->device->devargs == NULL)
+		return 0;
+
+	kvlist = rte_kvargs_parse(dev->device->devargs->args, valid_keys);
+	if (kvlist == NULL)
+		return -(EINVAL);
+
+	if (rte_kvargs_count(kvlist, QUEUE_NUM_PER_VF_ARG) > 1)
+		PMD_DRV_LOG(WARNING, "More than one argument \"%s\" and only "
+			    "the first invalid or last valid one is used !",
+			    QUEUE_NUM_PER_VF_ARG);
+
+	rte_kvargs_process(kvlist, QUEUE_NUM_PER_VF_ARG,
+			   i40e_pf_parse_vf_queue_number_handler, pf);
+
+	rte_kvargs_free(kvlist);
+
+	return 0;
+}
+
 static int
 i40e_pf_parameter_init(struct rte_eth_dev *dev)
 {
@@ -3983,6 +4046,9 @@  i40e_pf_parameter_init(struct rte_eth_dev *dev)
 		PMD_INIT_LOG(ERR, "HW configuration doesn't support SRIOV");
 		return -EINVAL;
 	}
+
+	i40e_pf_config_vf_rxq_number(dev);
+
 	/* Add the parameter init for LFC */
 	pf->fc_conf.pause_time = I40E_DEFAULT_PAUSE_TIME;
 	pf->fc_conf.high_water[I40E_MAX_TRAFFIC_CLASS] = I40E_DEFAULT_HIGH_WATER;
@@ -3992,7 +4058,6 @@  i40e_pf_parameter_init(struct rte_eth_dev *dev)
 	pf->max_num_vsi = hw->func_caps.num_vsis;
 	pf->lan_nb_qp_max = RTE_LIBRTE_I40E_QUEUE_NUM_PER_PF;
 	pf->vmdq_nb_qp_max = RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM;
-	pf->vf_nb_qp_max = RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF;
 
 	/* FDir queue/VSI allocation */
 	pf->fdir_qp_offset = 0;
@@ -4022,7 +4087,7 @@  i40e_pf_parameter_init(struct rte_eth_dev *dev)
 	pf->vf_qp_offset = pf->lan_qp_offset + pf->lan_nb_qps;
 	if (hw->func_caps.sr_iov_1_1 && pci_dev->max_vfs) {
 		pf->flags |= I40E_FLAG_SRIOV;
-		pf->vf_nb_qps = RTE_LIBRTE_I40E_QUEUE_NUM_PER_VF;
+		pf->vf_nb_qps = pf->vf_nb_qp_max;
 		pf->vf_num = pci_dev->max_vfs;
 		PMD_DRV_LOG(DEBUG,
 			"%u VF VSIs, %u queues per VF VSI, in total %u queues",
@@ -5315,15 +5380,15 @@  i40e_dev_init_vlan(struct rte_eth_dev *dev)
 	int mask = 0;
 
 	/* Apply vlan offload setting */
-	mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK;
+	mask = ETH_VLAN_STRIP_MASK |
+	       ETH_VLAN_FILTER_MASK |
+	       ETH_VLAN_EXTEND_MASK;
 	ret = i40e_vlan_offload_set(dev, mask);
 	if (ret) {
 		PMD_DRV_LOG(INFO, "Failed to update vlan offload");
 		return ret;
 	}
 
-	/* Apply double-vlan setting, not implemented yet */
-
 	/* Apply pvid setting */
 	ret = i40e_vlan_pvid_set(dev, data->dev_conf.txmode.pvid,
 				data->dev_conf.txmode.hw_vlan_insert_pvid);