net/ice: refine queue start stop

Message ID 20240105133705.360750-1-qi.z.zhang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series net/ice: refine queue start stop |

Checks

Context Check Description
ci/loongarch-compilation success Compilation OK
ci/checkpatch success coding style OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Qi Zhang Jan. 5, 2024, 1:37 p.m. UTC
  Not necessary to return fail when starting or stopping a queue
if the queue was already at required state.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/ice_rxtx.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
  

Comments

Wenjun Wu Jan. 5, 2024, 6:02 a.m. UTC | #1
> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zhang@intel.com>
> Sent: Friday, January 5, 2024 9:37 PM
> To: Yang, Qiming <qiming.yang@intel.com>; Wu, Wenjun1
> <wenjun1.wu@intel.com>
> Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: [PATCH] net/ice: refine queue start stop
> 
> Not necessary to return fail when starting or stopping a queue if the queue
> was already at required state.
> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
>  drivers/net/ice/ice_rxtx.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index
> 73e47ae92d..3286bb08fe 100644
> --- a/drivers/net/ice/ice_rxtx.c
> +++ b/drivers/net/ice/ice_rxtx.c
> @@ -673,6 +673,10 @@ ice_rx_queue_start(struct rte_eth_dev *dev,
> uint16_t rx_queue_id)
>  		return -EINVAL;
>  	}
> 
> +	if (dev->data->rx_queue_state[rx_queue_id] ==
> +		RTE_ETH_QUEUE_STATE_STARTED)
> +		return 0;
> +
>  	if (dev->data->dev_conf.rxmode.offloads &
> RTE_ETH_RX_OFFLOAD_TIMESTAMP)
>  		rxq->ts_enable = true;
>  	err = ice_program_hw_rx_queue(rxq);
> @@ -717,6 +721,10 @@ ice_rx_queue_stop(struct rte_eth_dev *dev,
> uint16_t rx_queue_id)
>  	if (rx_queue_id < dev->data->nb_rx_queues) {
>  		rxq = dev->data->rx_queues[rx_queue_id];
> 
> +		if (dev->data->rx_queue_state[rx_queue_id] ==
> +			RTE_ETH_QUEUE_STATE_STOPPED)
> +			return 0;
> +
>  		err = ice_switch_rx_queue(hw, rxq->reg_idx, false);
>  		if (err) {
>  			PMD_DRV_LOG(ERR, "Failed to switch RX queue %u
> off", @@ -758,6 +766,10 @@ ice_tx_queue_start(struct rte_eth_dev *dev,
> uint16_t tx_queue_id)
>  		return -EINVAL;
>  	}
> 
> +	if (dev->data->tx_queue_state[tx_queue_id] ==
> +		RTE_ETH_QUEUE_STATE_STARTED)
> +		return 0;
> +
>  	buf_len = ice_struct_size(txq_elem, txqs, 1);
>  	txq_elem = ice_malloc(hw, buf_len);
>  	if (!txq_elem)
> @@ -1066,6 +1078,10 @@ ice_tx_queue_stop(struct rte_eth_dev *dev,
> uint16_t tx_queue_id)
>  		return -EINVAL;
>  	}
> 
> +	if (dev->data->tx_queue_state[tx_queue_id] ==
> +		RTE_ETH_QUEUE_STATE_STOPPED)
> +		return 0;
> +
>  	q_ids[0] = txq->reg_idx;
>  	q_teids[0] = txq->q_teid;
> 
> --
> 2.31.1

Acked-by: Wenjun Wu <wenjun1.wu@intel.com>
  
Qi Zhang Jan. 5, 2024, 12:49 p.m. UTC | #2
> -----Original Message-----
> From: Wu, Wenjun1 <wenjun1.wu@intel.com>
> Sent: Friday, January 5, 2024 2:03 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH] net/ice: refine queue start stop
> 
> > -----Original Message-----
> > From: Zhang, Qi Z <qi.z.zhang@intel.com>
> > Sent: Friday, January 5, 2024 9:37 PM
> > To: Yang, Qiming <qiming.yang@intel.com>; Wu, Wenjun1
> > <wenjun1.wu@intel.com>
> > Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>
> > Subject: [PATCH] net/ice: refine queue start stop
> >
> > Not necessary to return fail when starting or stopping a queue if the
> > queue was already at required state.
> >
> > Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> > ---
> >  drivers/net/ice/ice_rxtx.c | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> >
> > diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
> > index 73e47ae92d..3286bb08fe 100644
> > --- a/drivers/net/ice/ice_rxtx.c
> > +++ b/drivers/net/ice/ice_rxtx.c
> > @@ -673,6 +673,10 @@ ice_rx_queue_start(struct rte_eth_dev *dev,
> > uint16_t rx_queue_id)
> >  		return -EINVAL;
> >  	}
> >
> > +	if (dev->data->rx_queue_state[rx_queue_id] ==
> > +		RTE_ETH_QUEUE_STATE_STARTED)
> > +		return 0;
> > +
> >  	if (dev->data->dev_conf.rxmode.offloads &
> > RTE_ETH_RX_OFFLOAD_TIMESTAMP)
> >  		rxq->ts_enable = true;
> >  	err = ice_program_hw_rx_queue(rxq);
> > @@ -717,6 +721,10 @@ ice_rx_queue_stop(struct rte_eth_dev *dev,
> > uint16_t rx_queue_id)
> >  	if (rx_queue_id < dev->data->nb_rx_queues) {
> >  		rxq = dev->data->rx_queues[rx_queue_id];
> >
> > +		if (dev->data->rx_queue_state[rx_queue_id] ==
> > +			RTE_ETH_QUEUE_STATE_STOPPED)
> > +			return 0;
> > +
> >  		err = ice_switch_rx_queue(hw, rxq->reg_idx, false);
> >  		if (err) {
> >  			PMD_DRV_LOG(ERR, "Failed to switch RX queue %u
> off", @@ -758,6
> > +766,10 @@ ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t
> > tx_queue_id)
> >  		return -EINVAL;
> >  	}
> >
> > +	if (dev->data->tx_queue_state[tx_queue_id] ==
> > +		RTE_ETH_QUEUE_STATE_STARTED)
> > +		return 0;
> > +
> >  	buf_len = ice_struct_size(txq_elem, txqs, 1);
> >  	txq_elem = ice_malloc(hw, buf_len);
> >  	if (!txq_elem)
> > @@ -1066,6 +1078,10 @@ ice_tx_queue_stop(struct rte_eth_dev *dev,
> > uint16_t tx_queue_id)
> >  		return -EINVAL;
> >  	}
> >
> > +	if (dev->data->tx_queue_state[tx_queue_id] ==
> > +		RTE_ETH_QUEUE_STATE_STOPPED)
> > +		return 0;
> > +
> >  	q_ids[0] = txq->reg_idx;
> >  	q_teids[0] = txq->q_teid;
> >
> > --
> > 2.31.1
> 
> Acked-by: Wenjun Wu <wenjun1.wu@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
  

Patch

diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 73e47ae92d..3286bb08fe 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -673,6 +673,10 @@  ice_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		return -EINVAL;
 	}
 
+	if (dev->data->rx_queue_state[rx_queue_id] ==
+		RTE_ETH_QUEUE_STATE_STARTED)
+		return 0;
+
 	if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
 		rxq->ts_enable = true;
 	err = ice_program_hw_rx_queue(rxq);
@@ -717,6 +721,10 @@  ice_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	if (rx_queue_id < dev->data->nb_rx_queues) {
 		rxq = dev->data->rx_queues[rx_queue_id];
 
+		if (dev->data->rx_queue_state[rx_queue_id] ==
+			RTE_ETH_QUEUE_STATE_STOPPED)
+			return 0;
+
 		err = ice_switch_rx_queue(hw, rxq->reg_idx, false);
 		if (err) {
 			PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
@@ -758,6 +766,10 @@  ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		return -EINVAL;
 	}
 
+	if (dev->data->tx_queue_state[tx_queue_id] ==
+		RTE_ETH_QUEUE_STATE_STARTED)
+		return 0;
+
 	buf_len = ice_struct_size(txq_elem, txqs, 1);
 	txq_elem = ice_malloc(hw, buf_len);
 	if (!txq_elem)
@@ -1066,6 +1078,10 @@  ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		return -EINVAL;
 	}
 
+	if (dev->data->tx_queue_state[tx_queue_id] ==
+		RTE_ETH_QUEUE_STATE_STOPPED)
+		return 0;
+
 	q_ids[0] = txq->reg_idx;
 	q_teids[0] = txq->q_teid;