[v2] net/i40e: fix vf runtime queues rss config

Message ID 1565282473-35661-1-git-send-email-xiao.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v2] net/i40e: fix vf runtime queues rss config |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-Compile-Testing success Compile Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Xiao Zhang Aug. 8, 2019, 4:41 p.m. UTC
  I40evf queue can not work properly with kernel pf driver. Eg. when
configure 8 queues pair, only 4 queues can receive packets, and half
packets will be lost if using 2 queues pair.
This issue is caused by misconfiguration of look up table, use aq command
to setup the lut to make it work properly.

Fixes: cea7a51c1750 ("i40evf: support RSS")
Cc: stable@dpdk.org

Signed-off-by: Xiao Zhang <xiao.zhang@intel.com>
---
v2 change for loop format to avoid build patch issue.
---
 drivers/net/i40e/i40e_ethdev_vf.c | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)
  

Comments

Xing, Beilei Aug. 9, 2019, 2:44 a.m. UTC | #1
> -----Original Message-----
> From: Zhang, Xiao
> Sent: Friday, August 9, 2019 12:41 AM
> To: dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> Zhang, Xiao <xiao.zhang@intel.com>; stable@dpdk.org
> Subject: [v2] net/i40e: fix vf runtime queues rss config
> 
> I40evf queue can not work properly with kernel pf driver. Eg. when configure
> 8 queues pair, only 4 queues can receive packets, and half packets will be lost
> if using 2 queues pair.
> This issue is caused by misconfiguration of look up table, use aq command to
> setup the lut to make it work properly.
> 
> Fixes: cea7a51c1750 ("i40evf: support RSS")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Xiao Zhang <xiao.zhang@intel.com>
> ---
> v2 change for loop format to avoid build patch issue.
> ---
>  drivers/net/i40e/i40e_ethdev_vf.c | 36 +++++++++++++++++++++++++++++---
> ----
>  1 file changed, 29 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
> b/drivers/net/i40e/i40e_ethdev_vf.c
> index 308fb98..2d3cf3e 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -2574,6 +2574,26 @@ i40evf_hw_rss_hash_set(struct i40e_vf *vf, struct
> rte_eth_rss_conf *rss_conf)
>  	if (ret)
>  		return ret;
> 
> +	if (vf->flags & I40E_FLAG_RSS_AQ_CAPABLE) {
> +		uint8_t *lut;
> +		uint32_t rss_lut_size = (I40E_VFQF_HLUT1_MAX_INDEX + 1) *
> 4;
> +		uint32_t i;
> +		lut = rte_zmalloc("i40e_rss_lut", rss_lut_size, 0);
> +		if (!lut) {
> +			PMD_DRV_LOG(ERR, "No memory can be allocated");
> +			return -ENOMEM;
> +		}
> +
> +		for (i = 0; i < rss_lut_size; i++)
> +			lut[i] = i % vf->num_queue_pairs;
> +
> +		ret = i40evf_set_rss_lut(&vf->vsi, lut,
> +					 rss_lut_size);
> +		rte_free(lut);
> +		if (ret)
> +			return ret;
> +	}
> +

Why not moving the LUT configuration to the following i40evf_config_rss function?

>  	hena = i40e_config_hena(vf->adapter, rss_conf->rss_hf);
>  	i40e_write_rx_ctl(hw, I40E_VFQF_HENA(0), (uint32_t)hena);
>  	i40e_write_rx_ctl(hw, I40E_VFQF_HENA(1), (uint32_t)(hena >> 32));
> @@ -2607,13 +2627,15 @@ i40evf_config_rss(struct i40e_vf *vf)
>  	}
> 
>  	num = RTE_MIN(vf->dev_data->nb_rx_queues,
> I40E_MAX_QP_NUM_PER_VF);
> -	/* Fill out the look up table */
> -	for (i = 0, j = 0; i < nb_q; i++, j++) {
> -		if (j >= num)
> -			j = 0;
> -		lut = (lut << 8) | j;
> -		if ((i & 3) == 3)
> -			I40E_WRITE_REG(hw, I40E_VFQF_HLUT(i >> 2), lut);
> +	if (!(vf->flags & I40E_FLAG_RSS_AQ_CAPABLE)) {
> +		/* Fill out the look up table */
> +		for (i = 0, j = 0; i < nb_q; i++, j++) {
> +			if (j >= num)
> +				j = 0;
> +			lut = (lut << 8) | j;
> +			if ((i & 3) == 3)
> +				I40E_WRITE_REG(hw, I40E_VFQF_HLUT(i >>
> 2), lut);
> +		}
>  	}
> 
>  	rss_conf = vf->dev_data->dev_conf.rx_adv_conf.rss_conf;
> --
> 2.7.4
  
Xiao Zhang Aug. 9, 2019, 3:25 a.m. UTC | #2
> -----Original Message-----
> From: Xing, Beilei
> Sent: Friday, August 9, 2019 10:44 AM
> To: Zhang, Xiao <xiao.zhang@intel.com>; dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; stable@dpdk.org
> Subject: RE: [v2] net/i40e: fix vf runtime queues rss config
> 
> 
> > -----Original Message-----
> > From: Zhang, Xiao
> > Sent: Friday, August 9, 2019 12:41 AM
> > To: dev@dpdk.org
> > Cc: Xing, Beilei <beilei.xing@intel.com>; Zhang, Qi Z
> > <qi.z.zhang@intel.com>; Zhang, Xiao <xiao.zhang@intel.com>;
> > stable@dpdk.org
> > Subject: [v2] net/i40e: fix vf runtime queues rss config
> >
> > I40evf queue can not work properly with kernel pf driver. Eg. when
> > configure
> > 8 queues pair, only 4 queues can receive packets, and half packets
> > will be lost if using 2 queues pair.
> > This issue is caused by misconfiguration of look up table, use aq
> > command to setup the lut to make it work properly.
> >
> > Fixes: cea7a51c1750 ("i40evf: support RSS")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Xiao Zhang <xiao.zhang@intel.com>
> > ---
> > v2 change for loop format to avoid build patch issue.
> > ---
> >  drivers/net/i40e/i40e_ethdev_vf.c | 36
> > +++++++++++++++++++++++++++++---
> > ----
> >  1 file changed, 29 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
> > b/drivers/net/i40e/i40e_ethdev_vf.c
> > index 308fb98..2d3cf3e 100644
> > --- a/drivers/net/i40e/i40e_ethdev_vf.c
> > +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> > @@ -2574,6 +2574,26 @@ i40evf_hw_rss_hash_set(struct i40e_vf *vf,
> > struct rte_eth_rss_conf *rss_conf)
> >  	if (ret)
> >  		return ret;
> >
> > +	if (vf->flags & I40E_FLAG_RSS_AQ_CAPABLE) {
> > +		uint8_t *lut;
> > +		uint32_t rss_lut_size = (I40E_VFQF_HLUT1_MAX_INDEX + 1) *
> > 4;
> > +		uint32_t i;
> > +		lut = rte_zmalloc("i40e_rss_lut", rss_lut_size, 0);
> > +		if (!lut) {
> > +			PMD_DRV_LOG(ERR, "No memory can be allocated");
> > +			return -ENOMEM;
> > +		}
> > +
> > +		for (i = 0; i < rss_lut_size; i++)
> > +			lut[i] = i % vf->num_queue_pairs;
> > +
> > +		ret = i40evf_set_rss_lut(&vf->vsi, lut,
> > +					 rss_lut_size);
> > +		rte_free(lut);
> > +		if (ret)
> > +			return ret;
> > +	}
> > +
> 
> Why not moving the LUT configuration to the following i40evf_config_rss
> function?

Yes, it's better to move the above code to i40evf_config_rss since the lagecy 
LUT configuration is also there. It will be more clear.

Thanks,
Xiao
> 
> >  	hena = i40e_config_hena(vf->adapter, rss_conf->rss_hf);
> >  	i40e_write_rx_ctl(hw, I40E_VFQF_HENA(0), (uint32_t)hena);
> >  	i40e_write_rx_ctl(hw, I40E_VFQF_HENA(1), (uint32_t)(hena >> 32));
> @@
> > -2607,13 +2627,15 @@ i40evf_config_rss(struct i40e_vf *vf)
> >  	}
> >
> >  	num = RTE_MIN(vf->dev_data->nb_rx_queues,
> > I40E_MAX_QP_NUM_PER_VF);
> > -	/* Fill out the look up table */
> > -	for (i = 0, j = 0; i < nb_q; i++, j++) {
> > -		if (j >= num)
> > -			j = 0;
> > -		lut = (lut << 8) | j;
> > -		if ((i & 3) == 3)
> > -			I40E_WRITE_REG(hw, I40E_VFQF_HLUT(i >> 2), lut);
> > +	if (!(vf->flags & I40E_FLAG_RSS_AQ_CAPABLE)) {
> > +		/* Fill out the look up table */
> > +		for (i = 0, j = 0; i < nb_q; i++, j++) {
> > +			if (j >= num)
> > +				j = 0;
> > +			lut = (lut << 8) | j;
> > +			if ((i & 3) == 3)
> > +				I40E_WRITE_REG(hw, I40E_VFQF_HLUT(i >>
> > 2), lut);
> > +		}
> >  	}
> >
> >  	rss_conf = vf->dev_data->dev_conf.rx_adv_conf.rss_conf;
> > --
> > 2.7.4
  

Patch

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 308fb98..2d3cf3e 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -2574,6 +2574,26 @@  i40evf_hw_rss_hash_set(struct i40e_vf *vf, struct rte_eth_rss_conf *rss_conf)
 	if (ret)
 		return ret;
 
+	if (vf->flags & I40E_FLAG_RSS_AQ_CAPABLE) {
+		uint8_t *lut;
+		uint32_t rss_lut_size = (I40E_VFQF_HLUT1_MAX_INDEX + 1) * 4;
+		uint32_t i;
+		lut = rte_zmalloc("i40e_rss_lut", rss_lut_size, 0);
+		if (!lut) {
+			PMD_DRV_LOG(ERR, "No memory can be allocated");
+			return -ENOMEM;
+		}
+
+		for (i = 0; i < rss_lut_size; i++)
+			lut[i] = i % vf->num_queue_pairs;
+
+		ret = i40evf_set_rss_lut(&vf->vsi, lut,
+					 rss_lut_size);
+		rte_free(lut);
+		if (ret)
+			return ret;
+	}
+
 	hena = i40e_config_hena(vf->adapter, rss_conf->rss_hf);
 	i40e_write_rx_ctl(hw, I40E_VFQF_HENA(0), (uint32_t)hena);
 	i40e_write_rx_ctl(hw, I40E_VFQF_HENA(1), (uint32_t)(hena >> 32));
@@ -2607,13 +2627,15 @@  i40evf_config_rss(struct i40e_vf *vf)
 	}
 
 	num = RTE_MIN(vf->dev_data->nb_rx_queues, I40E_MAX_QP_NUM_PER_VF);
-	/* Fill out the look up table */
-	for (i = 0, j = 0; i < nb_q; i++, j++) {
-		if (j >= num)
-			j = 0;
-		lut = (lut << 8) | j;
-		if ((i & 3) == 3)
-			I40E_WRITE_REG(hw, I40E_VFQF_HLUT(i >> 2), lut);
+	if (!(vf->flags & I40E_FLAG_RSS_AQ_CAPABLE)) {
+		/* Fill out the look up table */
+		for (i = 0, j = 0; i < nb_q; i++, j++) {
+			if (j >= num)
+				j = 0;
+			lut = (lut << 8) | j;
+			if ((i & 3) == 3)
+				I40E_WRITE_REG(hw, I40E_VFQF_HLUT(i >> 2), lut);
+		}
 	}
 
 	rss_conf = vf->dev_data->dev_conf.rx_adv_conf.rss_conf;