DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/ice: remove bulk alloc compile option
@ 2020-03-04 11:40 Qi Zhang
  2020-03-06  8:46 ` Ye Xiaolong
  0 siblings, 1 reply; 5+ messages in thread
From: Qi Zhang @ 2020-03-04 11:40 UTC (permalink / raw)
  To: beilei.xing, xiaolong.ye; +Cc: dev, Qi Zhang, stable

Remove CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC with below
consideration:

1. a default Rx path can always be selected by setting a proper
   rx_free_thresh value at runtime, see
   ice_check_rx_burst_bulk_alloc_preconditions.

2. its not a big deal to always reserve more space for desc ring.
   "ring_size = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);"

3. Fixes a potential invalid memory access in ice_reset_rx_queue.
   if CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC is turned on while
   ice_check_rx_burst_bulk_alloc_preconditions return fail.
   below code will have problem.

   for (i = 0; i < ICE_RX_MAX_BURST; ++i)
   	rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;

Fixes: 50370662b727 ("net/ice: support device and queue ops")
Cc: stable@dpdk.org

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 config/common_base         |  1 -
 doc/guides/nics/ice.rst    |  4 ---
 drivers/net/ice/ice_rxtx.c | 64 ++++++++++------------------------------------
 3 files changed, 13 insertions(+), 56 deletions(-)

diff --git a/config/common_base b/config/common_base
index 7ca2f28b1..c31175f9d 100644
--- a/config/common_base
+++ b/config/common_base
@@ -337,7 +337,6 @@ CONFIG_RTE_LIBRTE_ICE_PMD=y
 CONFIG_RTE_LIBRTE_ICE_DEBUG_RX=n
 CONFIG_RTE_LIBRTE_ICE_DEBUG_TX=n
 CONFIG_RTE_LIBRTE_ICE_DEBUG_TX_FREE=n
-CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC=y
 CONFIG_RTE_LIBRTE_ICE_16BYTE_RX_DESC=n
 
 # Compile burst-oriented IAVF PMD driver
diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
index cde3fd620..8af32dabf 100644
--- a/doc/guides/nics/ice.rst
+++ b/doc/guides/nics/ice.rst
@@ -54,10 +54,6 @@ Please note that enabling debugging options may affect system performance.
 
   Toggle display of generic debugging messages.
 
-- ``CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC`` (default ``y``)
-
-  Toggle bulk allocation for RX.
-
 - ``CONFIG_RTE_LIBRTE_ICE_16BYTE_RX_DESC`` (default ``n``)
 
   Toggle to use a 16-byte RX descriptor, by default the RX descriptor is 32 byte.
diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 60c411bfa..c7e5fc484 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -236,17 +236,15 @@ _ice_rx_queue_release_mbufs(struct ice_rx_queue *rxq)
 			rxq->sw_ring[i].mbuf = NULL;
 		}
 	}
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
-		if (rxq->rx_nb_avail == 0)
-			return;
-		for (i = 0; i < rxq->rx_nb_avail; i++) {
-			struct rte_mbuf *mbuf;
-
-			mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
-			rte_pktmbuf_free_seg(mbuf);
-		}
-		rxq->rx_nb_avail = 0;
-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
+	if (rxq->rx_nb_avail == 0)
+		return;
+	for (i = 0; i < rxq->rx_nb_avail; i++) {
+		struct rte_mbuf *mbuf;
+
+		mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
+		rte_pktmbuf_free_seg(mbuf);
+	}
+	rxq->rx_nb_avail = 0;
 }
 
 static void
@@ -309,16 +307,10 @@ ice_switch_rx_queue(struct ice_hw *hw, uint16_t q_idx, bool on)
 }
 
 static inline int
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 ice_check_rx_burst_bulk_alloc_preconditions(struct ice_rx_queue *rxq)
-#else
-ice_check_rx_burst_bulk_alloc_preconditions
-	(__rte_unused struct ice_rx_queue *rxq)
-#endif
 {
 	int ret = 0;
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 	if (!(rxq->rx_free_thresh >= ICE_RX_MAX_BURST)) {
 		PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
 			     "rxq->rx_free_thresh=%d, "
@@ -338,9 +330,6 @@ ice_check_rx_burst_bulk_alloc_preconditions
 			     rxq->nb_rx_desc, rxq->rx_free_thresh);
 		ret = -EINVAL;
 	}
-#else
-	ret = -EINVAL;
-#endif
 
 	return ret;
 }
@@ -357,17 +346,11 @@ ice_reset_rx_queue(struct ice_rx_queue *rxq)
 		return;
 	}
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
-	if (ice_check_rx_burst_bulk_alloc_preconditions(rxq) == 0)
-		len = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);
-	else
-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
-		len = rxq->nb_rx_desc;
+	len = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);
 
 	for (i = 0; i < len * sizeof(union ice_rx_flex_desc); i++)
 		((volatile char *)rxq->rx_ring)[i] = 0;
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 	memset(&rxq->fake_mbuf, 0x0, sizeof(rxq->fake_mbuf));
 	for (i = 0; i < ICE_RX_MAX_BURST; ++i)
 		rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;
@@ -375,7 +358,6 @@ ice_reset_rx_queue(struct ice_rx_queue *rxq)
 	rxq->rx_nb_avail = 0;
 	rxq->rx_next_avail = 0;
 	rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
 
 	rxq->rx_tail = 0;
 	rxq->nb_rx_hold = 0;
@@ -926,13 +908,11 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
 	/* Allocate the maximun number of RX ring hardware descriptor. */
 	len = ICE_MAX_RING_DESC;
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 	/**
 	 * Allocating a little more memory because vectorized/bulk_alloc Rx
 	 * functions doesn't check boundaries each time.
 	 */
 	len += ICE_RX_MAX_BURST;
-#endif
 
 	/* Allocate the maximum number of RX ring hardware descriptor. */
 	ring_size = sizeof(union ice_rx_flex_desc) * len;
@@ -952,11 +932,8 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
 	rxq->rx_ring_dma = rz->iova;
 	rxq->rx_ring = rz->addr;
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
+	/* always reserve more for bulk alloc */
 	len = (uint16_t)(nb_desc + ICE_RX_MAX_BURST);
-#else
-	len = nb_desc;
-#endif
 
 	/* Allocate the software ring. */
 	rxq->sw_ring = rte_zmalloc_socket(NULL,
@@ -977,17 +954,14 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
 	use_def_burst_func = ice_check_rx_burst_bulk_alloc_preconditions(rxq);
 
 	if (!use_def_burst_func) {
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 		PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
 			     "satisfied. Rx Burst Bulk Alloc function will be "
 			     "used on port=%d, queue=%d.",
 			     rxq->port_id, rxq->queue_id);
-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
 	} else {
 		PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
-			     "not satisfied, Scattered Rx is requested, "
-			     "or RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC is "
-			     "not enabled on port=%d, queue=%d.",
+			     "not satisfied, Scattered Rx is requested. "
+			     "on port=%d, queue=%d.",
 			     rxq->port_id, rxq->queue_id);
 		ad->rx_bulk_alloc_allowed = false;
 	}
@@ -1399,7 +1373,6 @@ ice_rxd_to_pkt_fields(struct rte_mbuf *mb,
 #endif
 }
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 #define ICE_LOOK_AHEAD 8
 #if (ICE_LOOK_AHEAD != 8)
 #error "PMD ICE: ICE_LOOK_AHEAD must be 8\n"
@@ -1620,15 +1593,6 @@ ice_recv_pkts_bulk_alloc(void *rx_queue,
 
 	return nb_rx;
 }
-#else
-static uint16_t
-ice_recv_pkts_bulk_alloc(void __rte_unused *rx_queue,
-			 struct rte_mbuf __rte_unused **rx_pkts,
-			 uint16_t __rte_unused nb_pkts)
-{
-	return 0;
-}
-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
 
 static uint16_t
 ice_recv_scattered_pkts(void *rx_queue,
@@ -1872,9 +1836,7 @@ ice_dev_supported_ptypes_get(struct rte_eth_dev *dev)
 		ptypes = ptypes_os;
 
 	if (dev->rx_pkt_burst == ice_recv_pkts ||
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 	    dev->rx_pkt_burst == ice_recv_pkts_bulk_alloc ||
-#endif
 	    dev->rx_pkt_burst == ice_recv_scattered_pkts)
 		return ptypes;
 
-- 
2.13.6


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

* Re: [dpdk-dev] [PATCH] net/ice: remove bulk alloc compile option
  2020-03-04 11:40 [dpdk-dev] [PATCH] net/ice: remove bulk alloc compile option Qi Zhang
@ 2020-03-06  8:46 ` Ye Xiaolong
  2020-03-06 23:29   ` Zhang, Qi Z
  2020-03-08  4:13   ` Ye Xiaolong
  0 siblings, 2 replies; 5+ messages in thread
From: Ye Xiaolong @ 2020-03-06  8:46 UTC (permalink / raw)
  To: Qi Zhang; +Cc: beilei.xing, dev, stable

Hi, Qi

Thanks for the cleanup.

On 03/04, Qi Zhang wrote:
>Remove CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC with below
>consideration:
>
>1. a default Rx path can always be selected by setting a proper
>   rx_free_thresh value at runtime, see
>   ice_check_rx_burst_bulk_alloc_preconditions.
>
>2. its not a big deal to always reserve more space for desc ring.
>   "ring_size = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);"
>
>3. Fixes a potential invalid memory access in ice_reset_rx_queue.
>   if CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC is turned on while
>   ice_check_rx_burst_bulk_alloc_preconditions return fail.
>   below code will have problem.
>
>   for (i = 0; i < ICE_RX_MAX_BURST; ++i)
>   	rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;
>
>Fixes: 50370662b727 ("net/ice: support device and queue ops")
>Cc: stable@dpdk.org
>
>Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
>---
> config/common_base         |  1 -
> doc/guides/nics/ice.rst    |  4 ---
> drivers/net/ice/ice_rxtx.c | 64 ++++++++++------------------------------------
> 3 files changed, 13 insertions(+), 56 deletions(-)
>
>diff --git a/config/common_base b/config/common_base
>index 7ca2f28b1..c31175f9d 100644
>--- a/config/common_base
>+++ b/config/common_base
>@@ -337,7 +337,6 @@ CONFIG_RTE_LIBRTE_ICE_PMD=y
> CONFIG_RTE_LIBRTE_ICE_DEBUG_RX=n
> CONFIG_RTE_LIBRTE_ICE_DEBUG_TX=n
> CONFIG_RTE_LIBRTE_ICE_DEBUG_TX_FREE=n
>-CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC=y
> CONFIG_RTE_LIBRTE_ICE_16BYTE_RX_DESC=n
> 
> # Compile burst-oriented IAVF PMD driver
>diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
>index cde3fd620..8af32dabf 100644
>--- a/doc/guides/nics/ice.rst
>+++ b/doc/guides/nics/ice.rst
>@@ -54,10 +54,6 @@ Please note that enabling debugging options may affect system performance.
> 
>   Toggle display of generic debugging messages.
> 
>-- ``CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC`` (default ``y``)
>-
>-  Toggle bulk allocation for RX.
>-
> - ``CONFIG_RTE_LIBRTE_ICE_16BYTE_RX_DESC`` (default ``n``)
> 
>   Toggle to use a 16-byte RX descriptor, by default the RX descriptor is 32 byte.
>diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
>index 60c411bfa..c7e5fc484 100644
>--- a/drivers/net/ice/ice_rxtx.c
>+++ b/drivers/net/ice/ice_rxtx.c
>@@ -236,17 +236,15 @@ _ice_rx_queue_release_mbufs(struct ice_rx_queue *rxq)
> 			rxq->sw_ring[i].mbuf = NULL;
> 		}
> 	}
>-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
>-		if (rxq->rx_nb_avail == 0)
>-			return;
>-		for (i = 0; i < rxq->rx_nb_avail; i++) {
>-			struct rte_mbuf *mbuf;
>-
>-			mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
>-			rte_pktmbuf_free_seg(mbuf);
>-		}
>-		rxq->rx_nb_avail = 0;
>-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
>+	if (rxq->rx_nb_avail == 0)
>+		return;
>+	for (i = 0; i < rxq->rx_nb_avail; i++) {
>+		struct rte_mbuf *mbuf;
>+
>+		mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
>+		rte_pktmbuf_free_seg(mbuf);
>+	}

How about just

	for (i = 0; i < rxq->rx_nb_avail; i++)
		rte_pktmbuf_free_seg(rxq->rx_stage[rxq->rx_next_avail + i]);

[snip]

For the rest,

Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>

And can this cleanup be applied to i40e as well? I think it's good to have 
less configurations generally.

Thanks,
Xiaolong

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

* Re: [dpdk-dev] [PATCH] net/ice: remove bulk alloc compile option
  2020-03-06  8:46 ` Ye Xiaolong
@ 2020-03-06 23:29   ` Zhang, Qi Z
  2020-03-08  4:13   ` Ye Xiaolong
  1 sibling, 0 replies; 5+ messages in thread
From: Zhang, Qi Z @ 2020-03-06 23:29 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: Xing, Beilei, dev, stable



> -----Original Message-----
> From: Ye, Xiaolong <xiaolong.ye@intel.com>
> Sent: Friday, March 6, 2020 4:46 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: Xing, Beilei <beilei.xing@intel.com>; dev@dpdk.org; stable@dpdk.org
> Subject: Re: [PATCH] net/ice: remove bulk alloc compile option
> 
> Hi, Qi
> 
> Thanks for the cleanup.
> 
> On 03/04, Qi Zhang wrote:
> >Remove CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC with below
> >consideration:
> >
> >1. a default Rx path can always be selected by setting a proper
> >   rx_free_thresh value at runtime, see
> >   ice_check_rx_burst_bulk_alloc_preconditions.
> >
> >2. its not a big deal to always reserve more space for desc ring.
> >   "ring_size = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);"
> >
> >3. Fixes a potential invalid memory access in ice_reset_rx_queue.
> >   if CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC is turned on while
> >   ice_check_rx_burst_bulk_alloc_preconditions return fail.
> >   below code will have problem.
> >
> >   for (i = 0; i < ICE_RX_MAX_BURST; ++i)
> >   	rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;
> >
> >Fixes: 50370662b727 ("net/ice: support device and queue ops")
> >Cc: stable@dpdk.org
> >
> >Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> >---
> > config/common_base         |  1 -
> > doc/guides/nics/ice.rst    |  4 ---
> > drivers/net/ice/ice_rxtx.c | 64
> >++++++++++------------------------------------
> > 3 files changed, 13 insertions(+), 56 deletions(-)
> >
> >diff --git a/config/common_base b/config/common_base index
> >7ca2f28b1..c31175f9d 100644
> >--- a/config/common_base
> >+++ b/config/common_base
> >@@ -337,7 +337,6 @@ CONFIG_RTE_LIBRTE_ICE_PMD=y
> >CONFIG_RTE_LIBRTE_ICE_DEBUG_RX=n
> CONFIG_RTE_LIBRTE_ICE_DEBUG_TX=n
> >CONFIG_RTE_LIBRTE_ICE_DEBUG_TX_FREE=n
> >-CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC=y
> > CONFIG_RTE_LIBRTE_ICE_16BYTE_RX_DESC=n
> >
> > # Compile burst-oriented IAVF PMD driver diff --git
> >a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst index
> >cde3fd620..8af32dabf 100644
> >--- a/doc/guides/nics/ice.rst
> >+++ b/doc/guides/nics/ice.rst
> >@@ -54,10 +54,6 @@ Please note that enabling debugging options may
> affect system performance.
> >
> >   Toggle display of generic debugging messages.
> >
> >-- ``CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC`` (default ``y``)
> >-
> >-  Toggle bulk allocation for RX.
> >-
> > - ``CONFIG_RTE_LIBRTE_ICE_16BYTE_RX_DESC`` (default ``n``)
> >
> >   Toggle to use a 16-byte RX descriptor, by default the RX descriptor is 32
> byte.
> >diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
> >index 60c411bfa..c7e5fc484 100644
> >--- a/drivers/net/ice/ice_rxtx.c
> >+++ b/drivers/net/ice/ice_rxtx.c
> >@@ -236,17 +236,15 @@ _ice_rx_queue_release_mbufs(struct
> ice_rx_queue *rxq)
> > 			rxq->sw_ring[i].mbuf = NULL;
> > 		}
> > 	}
> >-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
> >-		if (rxq->rx_nb_avail == 0)
> >-			return;
> >-		for (i = 0; i < rxq->rx_nb_avail; i++) {
> >-			struct rte_mbuf *mbuf;
> >-
> >-			mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
> >-			rte_pktmbuf_free_seg(mbuf);
> >-		}
> >-		rxq->rx_nb_avail = 0;
> >-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
> >+	if (rxq->rx_nb_avail == 0)
> >+		return;
> >+	for (i = 0; i < rxq->rx_nb_avail; i++) {
> >+		struct rte_mbuf *mbuf;
> >+
> >+		mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
> >+		rte_pktmbuf_free_seg(mbuf);
> >+	}
> 
> How about just
> 
> 	for (i = 0; i < rxq->rx_nb_avail; i++)
> 		rte_pktmbuf_free_seg(rxq->rx_stage[rxq->rx_next_avail + i]);

I just remove the compile option and keep the code unchanged, but no objection for your suggestion. 

> 
> [snip]
> 
> For the rest,
> 
> Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
> 
> And can this cleanup be applied to i40e as well? I think it's good to have less
> configurations generally.

I40e should be similar with a little bit complexity, I will take chance to cleanup later.

Thanks
Qi

> 
> Thanks,
> Xiaolong

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

* Re: [dpdk-dev] [PATCH] net/ice: remove bulk alloc compile option
  2020-03-06  8:46 ` Ye Xiaolong
  2020-03-06 23:29   ` Zhang, Qi Z
@ 2020-03-08  4:13   ` Ye Xiaolong
  1 sibling, 0 replies; 5+ messages in thread
From: Ye Xiaolong @ 2020-03-08  4:13 UTC (permalink / raw)
  To: Qi Zhang; +Cc: beilei.xing, dev, stable

On 03/06, Ye Xiaolong wrote:
>Hi, Qi
>
>Thanks for the cleanup.
>
>On 03/04, Qi Zhang wrote:
>>Remove CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC with below
>>consideration:
>>
>>1. a default Rx path can always be selected by setting a proper
>>   rx_free_thresh value at runtime, see
>>   ice_check_rx_burst_bulk_alloc_preconditions.
>>
>>2. its not a big deal to always reserve more space for desc ring.
>>   "ring_size = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);"
>>
>>3. Fixes a potential invalid memory access in ice_reset_rx_queue.
>>   if CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC is turned on while
>>   ice_check_rx_burst_bulk_alloc_preconditions return fail.
>>   below code will have problem.
>>
>>   for (i = 0; i < ICE_RX_MAX_BURST; ++i)
>>   	rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;
>>
>>Fixes: 50370662b727 ("net/ice: support device and queue ops")
>>Cc: stable@dpdk.org
>>
>>Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
>>---
>> config/common_base         |  1 -
>> doc/guides/nics/ice.rst    |  4 ---
>> drivers/net/ice/ice_rxtx.c | 64 ++++++++++------------------------------------
>> 3 files changed, 13 insertions(+), 56 deletions(-)
>>
>>diff --git a/config/common_base b/config/common_base
>>index 7ca2f28b1..c31175f9d 100644
>>--- a/config/common_base
>>+++ b/config/common_base
>>@@ -337,7 +337,6 @@ CONFIG_RTE_LIBRTE_ICE_PMD=y
>> CONFIG_RTE_LIBRTE_ICE_DEBUG_RX=n
>> CONFIG_RTE_LIBRTE_ICE_DEBUG_TX=n
>> CONFIG_RTE_LIBRTE_ICE_DEBUG_TX_FREE=n
>>-CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC=y
>> CONFIG_RTE_LIBRTE_ICE_16BYTE_RX_DESC=n
>> 
>> # Compile burst-oriented IAVF PMD driver
>>diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
>>index cde3fd620..8af32dabf 100644
>>--- a/doc/guides/nics/ice.rst
>>+++ b/doc/guides/nics/ice.rst
>>@@ -54,10 +54,6 @@ Please note that enabling debugging options may affect system performance.
>> 
>>   Toggle display of generic debugging messages.
>> 
>>-- ``CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC`` (default ``y``)
>>-
>>-  Toggle bulk allocation for RX.
>>-
>> - ``CONFIG_RTE_LIBRTE_ICE_16BYTE_RX_DESC`` (default ``n``)
>> 
>>   Toggle to use a 16-byte RX descriptor, by default the RX descriptor is 32 byte.
>>diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
>>index 60c411bfa..c7e5fc484 100644
>>--- a/drivers/net/ice/ice_rxtx.c
>>+++ b/drivers/net/ice/ice_rxtx.c
>>@@ -236,17 +236,15 @@ _ice_rx_queue_release_mbufs(struct ice_rx_queue *rxq)
>> 			rxq->sw_ring[i].mbuf = NULL;
>> 		}
>> 	}
>>-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
>>-		if (rxq->rx_nb_avail == 0)
>>-			return;
>>-		for (i = 0; i < rxq->rx_nb_avail; i++) {
>>-			struct rte_mbuf *mbuf;
>>-
>>-			mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
>>-			rte_pktmbuf_free_seg(mbuf);
>>-		}
>>-		rxq->rx_nb_avail = 0;
>>-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
>>+	if (rxq->rx_nb_avail == 0)
>>+		return;
>>+	for (i = 0; i < rxq->rx_nb_avail; i++) {
>>+		struct rte_mbuf *mbuf;
>>+
>>+		mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
>>+		rte_pktmbuf_free_seg(mbuf);
>>+	}
>
>How about just
>
>	for (i = 0; i < rxq->rx_nb_avail; i++)
>		rte_pktmbuf_free_seg(rxq->rx_stage[rxq->rx_next_avail + i]);
>
>[snip]
>
>For the rest,
>
>Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
>
>And can this cleanup be applied to i40e as well? I think it's good to have 
>less configurations generally.
>
>Thanks,
>Xiaolong

Applied to dpdk-next-net-intel with above change, Thanks.

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

* [dpdk-dev] [PATCH] net/ice: remove bulk alloc compile option
@ 2020-03-04 11:39 Qi Zhang
  0 siblings, 0 replies; 5+ messages in thread
From: Qi Zhang @ 2020-03-04 11:39 UTC (permalink / raw)
  To: beilei.xing, xiaolong.ye; +Cc: dev, Qi Zhang, stable

Remove CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC with below
consideration:

1. a default Rx path can always be selected by setting a proper
   rx_free_thresh value at runtime, see
   ice_check_rx_burst_bulk_alloc_preconditions.

2. its not a big deal to always reserve more space for desc ring.
   "ring_size = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);"

3. Fixes a potential invalid memory access in ice_reset_rx_queue.
   if CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC is turned on while
   ice_check_rx_burst_bulk_alloc_preconditions return fail.
   below code will have problem.

   for (i = 0; i < ICE_RX_MAX_BURST; ++i)
   	rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;

Fixes: 50370662b727 ("net/ice: support device and queue ops")
Cc: stable@dpdk.org

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 config/common_base         |  1 -
 drivers/net/ice/ice_rxtx.c | 64 ++++++++++------------------------------------
 2 files changed, 13 insertions(+), 52 deletions(-)

diff --git a/config/common_base b/config/common_base
index 7ca2f28b1..c31175f9d 100644
--- a/config/common_base
+++ b/config/common_base
@@ -337,7 +337,6 @@ CONFIG_RTE_LIBRTE_ICE_PMD=y
 CONFIG_RTE_LIBRTE_ICE_DEBUG_RX=n
 CONFIG_RTE_LIBRTE_ICE_DEBUG_TX=n
 CONFIG_RTE_LIBRTE_ICE_DEBUG_TX_FREE=n
-CONFIG_RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC=y
 CONFIG_RTE_LIBRTE_ICE_16BYTE_RX_DESC=n
 
 # Compile burst-oriented IAVF PMD driver
diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 60c411bfa..c7e5fc484 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -236,17 +236,15 @@ _ice_rx_queue_release_mbufs(struct ice_rx_queue *rxq)
 			rxq->sw_ring[i].mbuf = NULL;
 		}
 	}
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
-		if (rxq->rx_nb_avail == 0)
-			return;
-		for (i = 0; i < rxq->rx_nb_avail; i++) {
-			struct rte_mbuf *mbuf;
-
-			mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
-			rte_pktmbuf_free_seg(mbuf);
-		}
-		rxq->rx_nb_avail = 0;
-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
+	if (rxq->rx_nb_avail == 0)
+		return;
+	for (i = 0; i < rxq->rx_nb_avail; i++) {
+		struct rte_mbuf *mbuf;
+
+		mbuf = rxq->rx_stage[rxq->rx_next_avail + i];
+		rte_pktmbuf_free_seg(mbuf);
+	}
+	rxq->rx_nb_avail = 0;
 }
 
 static void
@@ -309,16 +307,10 @@ ice_switch_rx_queue(struct ice_hw *hw, uint16_t q_idx, bool on)
 }
 
 static inline int
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 ice_check_rx_burst_bulk_alloc_preconditions(struct ice_rx_queue *rxq)
-#else
-ice_check_rx_burst_bulk_alloc_preconditions
-	(__rte_unused struct ice_rx_queue *rxq)
-#endif
 {
 	int ret = 0;
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 	if (!(rxq->rx_free_thresh >= ICE_RX_MAX_BURST)) {
 		PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
 			     "rxq->rx_free_thresh=%d, "
@@ -338,9 +330,6 @@ ice_check_rx_burst_bulk_alloc_preconditions
 			     rxq->nb_rx_desc, rxq->rx_free_thresh);
 		ret = -EINVAL;
 	}
-#else
-	ret = -EINVAL;
-#endif
 
 	return ret;
 }
@@ -357,17 +346,11 @@ ice_reset_rx_queue(struct ice_rx_queue *rxq)
 		return;
 	}
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
-	if (ice_check_rx_burst_bulk_alloc_preconditions(rxq) == 0)
-		len = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);
-	else
-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
-		len = rxq->nb_rx_desc;
+	len = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);
 
 	for (i = 0; i < len * sizeof(union ice_rx_flex_desc); i++)
 		((volatile char *)rxq->rx_ring)[i] = 0;
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 	memset(&rxq->fake_mbuf, 0x0, sizeof(rxq->fake_mbuf));
 	for (i = 0; i < ICE_RX_MAX_BURST; ++i)
 		rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;
@@ -375,7 +358,6 @@ ice_reset_rx_queue(struct ice_rx_queue *rxq)
 	rxq->rx_nb_avail = 0;
 	rxq->rx_next_avail = 0;
 	rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
 
 	rxq->rx_tail = 0;
 	rxq->nb_rx_hold = 0;
@@ -926,13 +908,11 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
 	/* Allocate the maximun number of RX ring hardware descriptor. */
 	len = ICE_MAX_RING_DESC;
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 	/**
 	 * Allocating a little more memory because vectorized/bulk_alloc Rx
 	 * functions doesn't check boundaries each time.
 	 */
 	len += ICE_RX_MAX_BURST;
-#endif
 
 	/* Allocate the maximum number of RX ring hardware descriptor. */
 	ring_size = sizeof(union ice_rx_flex_desc) * len;
@@ -952,11 +932,8 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
 	rxq->rx_ring_dma = rz->iova;
 	rxq->rx_ring = rz->addr;
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
+	/* always reserve more for bulk alloc */
 	len = (uint16_t)(nb_desc + ICE_RX_MAX_BURST);
-#else
-	len = nb_desc;
-#endif
 
 	/* Allocate the software ring. */
 	rxq->sw_ring = rte_zmalloc_socket(NULL,
@@ -977,17 +954,14 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
 	use_def_burst_func = ice_check_rx_burst_bulk_alloc_preconditions(rxq);
 
 	if (!use_def_burst_func) {
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 		PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
 			     "satisfied. Rx Burst Bulk Alloc function will be "
 			     "used on port=%d, queue=%d.",
 			     rxq->port_id, rxq->queue_id);
-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
 	} else {
 		PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
-			     "not satisfied, Scattered Rx is requested, "
-			     "or RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC is "
-			     "not enabled on port=%d, queue=%d.",
+			     "not satisfied, Scattered Rx is requested. "
+			     "on port=%d, queue=%d.",
 			     rxq->port_id, rxq->queue_id);
 		ad->rx_bulk_alloc_allowed = false;
 	}
@@ -1399,7 +1373,6 @@ ice_rxd_to_pkt_fields(struct rte_mbuf *mb,
 #endif
 }
 
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 #define ICE_LOOK_AHEAD 8
 #if (ICE_LOOK_AHEAD != 8)
 #error "PMD ICE: ICE_LOOK_AHEAD must be 8\n"
@@ -1620,15 +1593,6 @@ ice_recv_pkts_bulk_alloc(void *rx_queue,
 
 	return nb_rx;
 }
-#else
-static uint16_t
-ice_recv_pkts_bulk_alloc(void __rte_unused *rx_queue,
-			 struct rte_mbuf __rte_unused **rx_pkts,
-			 uint16_t __rte_unused nb_pkts)
-{
-	return 0;
-}
-#endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
 
 static uint16_t
 ice_recv_scattered_pkts(void *rx_queue,
@@ -1872,9 +1836,7 @@ ice_dev_supported_ptypes_get(struct rte_eth_dev *dev)
 		ptypes = ptypes_os;
 
 	if (dev->rx_pkt_burst == ice_recv_pkts ||
-#ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
 	    dev->rx_pkt_burst == ice_recv_pkts_bulk_alloc ||
-#endif
 	    dev->rx_pkt_burst == ice_recv_scattered_pkts)
 		return ptypes;
 
-- 
2.13.6


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

end of thread, other threads:[~2020-03-08  4:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04 11:40 [dpdk-dev] [PATCH] net/ice: remove bulk alloc compile option Qi Zhang
2020-03-06  8:46 ` Ye Xiaolong
2020-03-06 23:29   ` Zhang, Qi Z
2020-03-08  4:13   ` Ye Xiaolong
  -- strict thread matches above, loose matches on Subject: below --
2020-03-04 11:39 Qi Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).