patches for DPDK stable branches
 help / color / mirror / Atom feed
* RE: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX descriptor
  2022-05-07  9:34 [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX descriptor Yiding Zhou
@ 2022-05-07  2:09 ` Zhang, Qi Z
  2022-05-07  4:43   ` Zhou, YidingX
  0 siblings, 1 reply; 6+ messages in thread
From: Zhang, Qi Z @ 2022-05-07  2:09 UTC (permalink / raw)
  To: Zhou, YidingX, Wu, Jingjing, Xing, Beilei
  Cc: Yang, Qiming, stable, Yeleswarapu, Ramamani



> -----Original Message-----
> From: Zhou, YidingX <yidingx.zhou@intel.com>
> Sent: Saturday, May 7, 2022 5:34 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; stable@dpdk.org; Yeleswarapu, Ramamani
> <ramamani.yeleswarapu@intel.com>
> Subject: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX
> descriptor
> 
> Some kernel drivers return the capability
> VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC when IAVF_RXDID_COMMS_OVS_1 is
> not supported. This causes PMD to use rx_pkt_burst that handles the Flex
> Receive Descriptor format, but actually configures the RXDID into
> IAVF_RXDID_LEGACY_1, then the fields of rte_mbuf Will be filled with wrong
> values in rx_pkt_burst, which will eventually lead to coredump.
> 
> This patch fixes mismatch between rx_pkt_burst and rx descriptor.
> 
> Fixes: 12b435bf8f2f ("net/iavf: support flex desc metadata extraction")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yiding Zhou <yidingx.zhou@intel.com>
> ---
>  drivers/net/iavf/iavf_rxtx.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index
> 345f6aeebc..69584264de 100644
> --- a/drivers/net/iavf/iavf_rxtx.c
> +++ b/drivers/net/iavf/iavf_rxtx.c
> @@ -2908,6 +2908,18 @@ iavf_set_rx_function(struct rte_eth_dev *dev)
>  	bool use_avx512 = false;
>  	bool use_flex = false;
> 
> +	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
> +		use_flex = true;

No need this check, we can init use_flex as true;

> +
> +	for (i = 0; i < dev->data->nb_rx_queues; i++) {
> +		rxq = dev->data->rx_queues[i];
> +		if (rxq->rxdid <= IAVF_RXDID_LEGACY_1 ||
> +			!(vf->supported_rxdid & BIT(rxq->rxdid))) {

Check if rxq->rxdid is in supported list is not necessary, this has been  guaranteed when we set it.

Also its better to print some warning message here,  if we saw some rxq->rxdid is flex and some rxq->rxdid is legacy as we have to set rx_burst as legacy for all , this is something not be expected by user



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX descriptor
  2022-05-07  2:09 ` Zhang, Qi Z
@ 2022-05-07  4:43   ` Zhou, YidingX
  2022-05-07  7:03     ` Zhang, Qi Z
  0 siblings, 1 reply; 6+ messages in thread
From: Zhou, YidingX @ 2022-05-07  4:43 UTC (permalink / raw)
  To: Zhang, Qi Z, Wu, Jingjing, Xing, Beilei
  Cc: Yang, Qiming, stable, Yeleswarapu, Ramamani



> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zhang@intel.com>
> Sent: Saturday, May 7, 2022 10:09 AM
> To: Zhou, YidingX <yidingx.zhou@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> Cc: Yang, Qiming <qiming.yang@intel.com>; stable@dpdk.org; Yeleswarapu,
> Ramamani <ramamani.yeleswarapu@intel.com>
> Subject: RE: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX
> descriptor
> 
> 
> 
> > -----Original Message-----
> > From: Zhou, YidingX <yidingx.zhou@intel.com>
> > Sent: Saturday, May 7, 2022 5:34 PM
> > To: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>
> > Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> > <qi.z.zhang@intel.com>; stable@dpdk.org; Yeleswarapu, Ramamani
> > <ramamani.yeleswarapu@intel.com>
> > Subject: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX
> > descriptor
> >
> > Some kernel drivers return the capability
> > VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC when
> IAVF_RXDID_COMMS_OVS_1 is not
> > supported. This causes PMD to use rx_pkt_burst that handles the Flex
> > Receive Descriptor format, but actually configures the RXDID into
> > IAVF_RXDID_LEGACY_1, then the fields of rte_mbuf Will be filled with
> > wrong values in rx_pkt_burst, which will eventually lead to coredump.
> >
> > This patch fixes mismatch between rx_pkt_burst and rx descriptor.
> >
> > Fixes: 12b435bf8f2f ("net/iavf: support flex desc metadata
> > extraction")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Yiding Zhou <yidingx.zhou@intel.com>
> > ---
> >  drivers/net/iavf/iavf_rxtx.c | 20 ++++++++++++++------
> >  1 file changed, 14 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/net/iavf/iavf_rxtx.c
> > b/drivers/net/iavf/iavf_rxtx.c index 345f6aeebc..69584264de 100644
> > --- a/drivers/net/iavf/iavf_rxtx.c
> > +++ b/drivers/net/iavf/iavf_rxtx.c
> > @@ -2908,6 +2908,18 @@ iavf_set_rx_function(struct rte_eth_dev *dev)
> > bool use_avx512 = false;  bool use_flex = false;
> >
> > +if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
> > +use_flex = true;
> 
> No need this check, we can init use_flex as true;
> 

I'm not sure if use_flex can be init as true. is it possible that vf->vf_res->vf_cap_flags doesn't contain VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC?

> > +
> > +for (i = 0; i < dev->data->nb_rx_queues; i++) { rxq =
> > +dev->data->rx_queues[i]; if (rxq->rxdid <= IAVF_RXDID_LEGACY_1 ||
> > +!(vf->supported_rxdid & BIT(rxq->rxdid))) {
> 
> Check if rxq->rxdid is in supported list is not necessary, this has been
> guaranteed when we set it.
> 

According to debugging, this is not guaranteed.
rxq->rxdid is set to IAVF_RXDID_COMMS_OVS_1 by default when vf->supported_rxdid == 6 (just contains IAVF_RXDID_LEGACY_1 and IAVF_RXDID_FLEX_NIC).

> Also its better to print some warning message here,  if we saw some rxq-
> >rxdid is flex and some rxq->rxdid is legacy as we have to set rx_burst as
> legacy for all , this is something not be expected by user
> 
> 
Agreed, I will do this in v2. Thanks.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX descriptor
  2022-05-07  4:43   ` Zhou, YidingX
@ 2022-05-07  7:03     ` Zhang, Qi Z
  2022-05-07  7:20       ` Zhou, YidingX
  0 siblings, 1 reply; 6+ messages in thread
From: Zhang, Qi Z @ 2022-05-07  7:03 UTC (permalink / raw)
  To: Zhou, YidingX, Wu, Jingjing, Xing, Beilei
  Cc: Yang, Qiming, stable, Yeleswarapu, Ramamani



> -----Original Message-----
> From: Zhou, YidingX <yidingx.zhou@intel.com>
> Sent: Saturday, May 7, 2022 12:43 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>;
> Xing, Beilei <beilei.xing@intel.com>
> Cc: Yang, Qiming <qiming.yang@intel.com>; stable@dpdk.org; Yeleswarapu,
> Ramamani <ramamani.yeleswarapu@intel.com>
> Subject: RE: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX
> descriptor
> 
> 
> 
> > -----Original Message-----
> > From: Zhang, Qi Z <qi.z.zhang@intel.com>
> > Sent: Saturday, May 7, 2022 10:09 AM
> > To: Zhou, YidingX <yidingx.zhou@intel.com>; Wu, Jingjing
> > <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> > Cc: Yang, Qiming <qiming.yang@intel.com>; stable@dpdk.org;
> > Yeleswarapu, Ramamani <ramamani.yeleswarapu@intel.com>
> > Subject: RE: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and
> > RX descriptor
> >
> >
> >
> > > -----Original Message-----
> > > From: Zhou, YidingX <yidingx.zhou@intel.com>
> > > Sent: Saturday, May 7, 2022 5:34 PM
> > > To: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> > > <beilei.xing@intel.com>
> > > Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> > > <qi.z.zhang@intel.com>; stable@dpdk.org; Yeleswarapu, Ramamani
> > > <ramamani.yeleswarapu@intel.com>
> > > Subject: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX
> > > descriptor
> > >
> > > Some kernel drivers return the capability
> > > VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC when
> > IAVF_RXDID_COMMS_OVS_1 is not
> > > supported. This causes PMD to use rx_pkt_burst that handles the Flex
> > > Receive Descriptor format, but actually configures the RXDID into
> > > IAVF_RXDID_LEGACY_1, then the fields of rte_mbuf Will be filled with
> > > wrong values in rx_pkt_burst, which will eventually lead to coredump.
> > >
> > > This patch fixes mismatch between rx_pkt_burst and rx descriptor.
> > >
> > > Fixes: 12b435bf8f2f ("net/iavf: support flex desc metadata
> > > extraction")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Yiding Zhou <yidingx.zhou@intel.com>
> > > ---
> > >  drivers/net/iavf/iavf_rxtx.c | 20 ++++++++++++++------
> > >  1 file changed, 14 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/net/iavf/iavf_rxtx.c
> > > b/drivers/net/iavf/iavf_rxtx.c index 345f6aeebc..69584264de 100644
> > > --- a/drivers/net/iavf/iavf_rxtx.c
> > > +++ b/drivers/net/iavf/iavf_rxtx.c
> > > @@ -2908,6 +2908,18 @@ iavf_set_rx_function(struct rte_eth_dev *dev)
> > > bool use_avx512 = false;  bool use_flex = false;
> > >
> > > +if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
> > > +use_flex = true;
> >
> > No need this check, we can init use_flex as true;
> >
> 
> I'm not sure if use_flex can be init as true. is it possible that vf->vf_res-
> >vf_cap_flags doesn't contain VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC?

I think the following loop will reset to false if any rxq->rxdid is legacy or any unsupported rxdid happen
Otherwise, it should always be true. 

> 
> > > +
> > > +for (i = 0; i < dev->data->nb_rx_queues; i++) { rxq =
> > > +dev->data->rx_queues[i]; if (rxq->rxdid <= IAVF_RXDID_LEGACY_1 ||
> > > +!(vf->supported_rxdid & BIT(rxq->rxdid))) {
> >
> > Check if rxq->rxdid is in supported list is not necessary, this has
> > been guaranteed when we set it.
> >
> 
> According to debugging, this is not guaranteed.
> rxq->rxdid is set to IAVF_RXDID_COMMS_OVS_1 by default when vf-
> >supported_rxdid == 6 (just contains IAVF_RXDID_LEGACY_1 and
> IAVF_RXDID_FLEX_NIC).

OK, you can keep this.

Btw, please send to dev@dpdk.org not stable@dpdk.org

> 
> > Also its better to print some warning message here,  if we saw some
> > rxq-
> > >rxdid is flex and some rxq->rxdid is legacy as we have to set
> > >rx_burst as
> > legacy for all , this is something not be expected by user
> >
> >
> Agreed, I will do this in v2. Thanks.
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX descriptor
  2022-05-07  7:03     ` Zhang, Qi Z
@ 2022-05-07  7:20       ` Zhou, YidingX
  0 siblings, 0 replies; 6+ messages in thread
From: Zhou, YidingX @ 2022-05-07  7:20 UTC (permalink / raw)
  To: Zhang, Qi Z, Wu, Jingjing, Xing, Beilei
  Cc: Yang, Qiming, stable, Yeleswarapu, Ramamani



> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zhang@intel.com>
> Sent: Saturday, May 7, 2022 3:04 PM
> To: Zhou, YidingX <yidingx.zhou@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> Cc: Yang, Qiming <qiming.yang@intel.com>; stable@dpdk.org; Yeleswarapu,
> Ramamani <ramamani.yeleswarapu@intel.com>
> Subject: RE: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX
> descriptor
> 
> 
> 
> > -----Original Message-----
> > From: Zhou, YidingX <yidingx.zhou@intel.com>
> > Sent: Saturday, May 7, 2022 12:43 PM
> > To: Zhang, Qi Z <qi.z.zhang@intel.com>; Wu, Jingjing
> > <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> > Cc: Yang, Qiming <qiming.yang@intel.com>; stable@dpdk.org;
> > Yeleswarapu, Ramamani <ramamani.yeleswarapu@intel.com>
> > Subject: RE: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and
> > RX descriptor
> >
> >
> >
> > > -----Original Message-----
> > > From: Zhang, Qi Z <qi.z.zhang@intel.com>
> > > Sent: Saturday, May 7, 2022 10:09 AM
> > > To: Zhou, YidingX <yidingx.zhou@intel.com>; Wu, Jingjing
> > > <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> > > Cc: Yang, Qiming <qiming.yang@intel.com>; stable@dpdk.org;
> > > Yeleswarapu, Ramamani <ramamani.yeleswarapu@intel.com>
> > > Subject: RE: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and
> > > RX descriptor
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Zhou, YidingX <yidingx.zhou@intel.com>
> > > > Sent: Saturday, May 7, 2022 5:34 PM
> > > > To: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> > > > <beilei.xing@intel.com>
> > > > Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> > > > <qi.z.zhang@intel.com>; stable@dpdk.org; Yeleswarapu, Ramamani
> > > > <ramamani.yeleswarapu@intel.com>
> > > > Subject: [PATCH] net/iavf: fix mismatch between rx_pkt_burst and
> > > > RX descriptor
> > > >
> > > > Some kernel drivers return the capability
> > > > VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC when
> > > IAVF_RXDID_COMMS_OVS_1 is not
> > > > supported. This causes PMD to use rx_pkt_burst that handles the
> > > > Flex Receive Descriptor format, but actually configures the RXDID
> > > > into IAVF_RXDID_LEGACY_1, then the fields of rte_mbuf Will be
> > > > filled with wrong values in rx_pkt_burst, which will eventually lead to
> coredump.
> > > >
> > > > This patch fixes mismatch between rx_pkt_burst and rx descriptor.
> > > >
> > > > Fixes: 12b435bf8f2f ("net/iavf: support flex desc metadata
> > > > extraction")
> > > > Cc: stable@dpdk.org
> > > >
> > > > Signed-off-by: Yiding Zhou <yidingx.zhou@intel.com>
> > > > ---
> > > >  drivers/net/iavf/iavf_rxtx.c | 20 ++++++++++++++------
> > > >  1 file changed, 14 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/drivers/net/iavf/iavf_rxtx.c
> > > > b/drivers/net/iavf/iavf_rxtx.c index 345f6aeebc..69584264de 100644
> > > > --- a/drivers/net/iavf/iavf_rxtx.c
> > > > +++ b/drivers/net/iavf/iavf_rxtx.c
> > > > @@ -2908,6 +2908,18 @@ iavf_set_rx_function(struct rte_eth_dev
> > > > *dev) bool use_avx512 = false;  bool use_flex = false;
> > > >
> > > > +if (vf->vf_res->vf_cap_flags &
> VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
> > > > +use_flex = true;
> > >
> > > No need this check, we can init use_flex as true;
> > >
> >
> > I'm not sure if use_flex can be init as true. is it possible that
> > vf->vf_res-
> > >vf_cap_flags doesn't contain VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC?
> 
> I think the following loop will reset to false if any rxq->rxdid is legacy or any
> unsupported rxdid happen Otherwise, it should always be true.
> 
> >
> > > > +
> > > > +for (i = 0; i < dev->data->nb_rx_queues; i++) { rxq =
> > > > +dev->data->rx_queues[i]; if (rxq->rxdid <= IAVF_RXDID_LEGACY_1 ||
> > > > +!(vf->supported_rxdid & BIT(rxq->rxdid))) {
> > >
> > > Check if rxq->rxdid is in supported list is not necessary, this has
> > > been guaranteed when we set it.
> > >
> >
> > According to debugging, this is not guaranteed.
> > rxq->rxdid is set to IAVF_RXDID_COMMS_OVS_1 by default when vf-
> > >supported_rxdid == 6 (just contains IAVF_RXDID_LEGACY_1 and
> > IAVF_RXDID_FLEX_NIC).
> 
> OK, you can keep this.
> 
> Btw, please send to dev@dpdk.org not stable@dpdk.org
> 
> >
> > > Also its better to print some warning message here,  if we saw some
> > > rxq-
> > > >rxdid is flex and some rxq->rxdid is legacy as we have to set
> > > >rx_burst as
> > > legacy for all , this is something not be expected by user
> > >
> > >
> > Agreed, I will do this in v2. Thanks.
> >
> 

I will sent v2 soon, thanks. 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX descriptor
@ 2022-05-07  9:34 Yiding Zhou
  2022-05-07  2:09 ` Zhang, Qi Z
  0 siblings, 1 reply; 6+ messages in thread
From: Yiding Zhou @ 2022-05-07  9:34 UTC (permalink / raw)
  To: jingjing.wu, beilei.xing
  Cc: qiming.yang, qi.z.zhang, stable, ramamani.yeleswarapu

Some kernel drivers return the capability VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC
when IAVF_RXDID_COMMS_OVS_1 is not supported. This causes PMD to use
rx_pkt_burst that handles the Flex Receive Descriptor format, but actually
configures the RXDID into IAVF_RXDID_LEGACY_1, then the fields of rte_mbuf
Will be filled with wrong values in rx_pkt_burst, which will eventually
lead to coredump.

This patch fixes mismatch between rx_pkt_burst and rx descriptor.

Fixes: 12b435bf8f2f ("net/iavf: support flex desc metadata extraction")
Cc: stable@dpdk.org

Signed-off-by: Yiding Zhou <yidingx.zhou@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 345f6aeebc..69584264de 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -2908,6 +2908,18 @@ iavf_set_rx_function(struct rte_eth_dev *dev)
 	bool use_avx512 = false;
 	bool use_flex = false;
 
+	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
+		use_flex = true;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		rxq = dev->data->rx_queues[i];
+		if (rxq->rxdid <= IAVF_RXDID_LEGACY_1 ||
+			!(vf->supported_rxdid & BIT(rxq->rxdid))) {
+			use_flex = false;
+			break;
+		}
+	}
+
 	check_ret = iavf_rx_vec_dev_check(dev);
 	if (check_ret >= 0 &&
 	    rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
@@ -2923,10 +2935,6 @@ iavf_set_rx_function(struct rte_eth_dev *dev)
 			use_avx512 = true;
 #endif
 
-		if (vf->vf_res->vf_cap_flags &
-			VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
-			use_flex = true;
-
 		for (i = 0; i < dev->data->nb_rx_queues; i++) {
 			rxq = dev->data->rx_queues[i];
 			(void)iavf_rxq_vec_setup(rxq);
@@ -3030,7 +3038,7 @@ iavf_set_rx_function(struct rte_eth_dev *dev)
 	if (dev->data->scattered_rx) {
 		PMD_DRV_LOG(DEBUG, "Using a Scattered Rx callback (port=%d).",
 			    dev->data->port_id);
-		if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
+		if (use_flex)
 			dev->rx_pkt_burst = iavf_recv_scattered_pkts_flex_rxd;
 		else
 			dev->rx_pkt_burst = iavf_recv_scattered_pkts;
@@ -3041,7 +3049,7 @@ iavf_set_rx_function(struct rte_eth_dev *dev)
 	} else {
 		PMD_DRV_LOG(DEBUG, "Using Basic Rx callback (port=%d).",
 			    dev->data->port_id);
-		if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
+		if (use_flex)
 			dev->rx_pkt_burst = iavf_recv_pkts_flex_rxd;
 		else
 			dev->rx_pkt_burst = iavf_recv_pkts;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX descriptor
@ 2022-05-07  9:36 Yiding Zhou
  0 siblings, 0 replies; 6+ messages in thread
From: Yiding Zhou @ 2022-05-07  9:36 UTC (permalink / raw)
  To: dev, jingjing.wu, beilei.xing
  Cc: qiming.yang, qi.z.zhang, stable, ramamani.yeleswarapu

Some kernel drivers return the capability VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC
when IAVF_RXDID_COMMS_OVS_1 is not supported. This causes PMD to use
rx_pkt_burst that handles the Flex Receive Descriptor format, but actually
configures the RXDID into IAVF_RXDID_LEGACY_1, then the fields of rte_mbuf
Will be filled with wrong values in rx_pkt_burst, which will eventually
lead to coredump.

This patch fixes mismatch between rx_pkt_burst and rx descriptor.

Fixes: 12b435bf8f2f ("net/iavf: support flex desc metadata extraction")
Cc: stable@dpdk.org

Signed-off-by: Yiding Zhou <yidingx.zhou@intel.com>
---
 drivers/net/iavf/iavf_rxtx.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index 345f6aeebc..69584264de 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -2908,6 +2908,18 @@ iavf_set_rx_function(struct rte_eth_dev *dev)
 	bool use_avx512 = false;
 	bool use_flex = false;
 
+	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
+		use_flex = true;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		rxq = dev->data->rx_queues[i];
+		if (rxq->rxdid <= IAVF_RXDID_LEGACY_1 ||
+			!(vf->supported_rxdid & BIT(rxq->rxdid))) {
+			use_flex = false;
+			break;
+		}
+	}
+
 	check_ret = iavf_rx_vec_dev_check(dev);
 	if (check_ret >= 0 &&
 	    rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
@@ -2923,10 +2935,6 @@ iavf_set_rx_function(struct rte_eth_dev *dev)
 			use_avx512 = true;
 #endif
 
-		if (vf->vf_res->vf_cap_flags &
-			VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
-			use_flex = true;
-
 		for (i = 0; i < dev->data->nb_rx_queues; i++) {
 			rxq = dev->data->rx_queues[i];
 			(void)iavf_rxq_vec_setup(rxq);
@@ -3030,7 +3038,7 @@ iavf_set_rx_function(struct rte_eth_dev *dev)
 	if (dev->data->scattered_rx) {
 		PMD_DRV_LOG(DEBUG, "Using a Scattered Rx callback (port=%d).",
 			    dev->data->port_id);
-		if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
+		if (use_flex)
 			dev->rx_pkt_burst = iavf_recv_scattered_pkts_flex_rxd;
 		else
 			dev->rx_pkt_burst = iavf_recv_scattered_pkts;
@@ -3041,7 +3049,7 @@ iavf_set_rx_function(struct rte_eth_dev *dev)
 	} else {
 		PMD_DRV_LOG(DEBUG, "Using Basic Rx callback (port=%d).",
 			    dev->data->port_id);
-		if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC)
+		if (use_flex)
 			dev->rx_pkt_burst = iavf_recv_pkts_flex_rxd;
 		else
 			dev->rx_pkt_burst = iavf_recv_pkts;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-07  7:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-07  9:34 [PATCH] net/iavf: fix mismatch between rx_pkt_burst and RX descriptor Yiding Zhou
2022-05-07  2:09 ` Zhang, Qi Z
2022-05-07  4:43   ` Zhou, YidingX
2022-05-07  7:03     ` Zhang, Qi Z
2022-05-07  7:20       ` Zhou, YidingX
2022-05-07  9:36 Yiding Zhou

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git