Skip to content

Commit

Permalink
net/intel: extract common Rx vector criteria
Browse files Browse the repository at this point in the history
While some drivers have specific criteria for when a vector driver can
be enabled on the Rx path, there are a number of basic criteria which
apply across all drivers. Centralize those in the intel/common folder,
and then update drivers to use the common conditional checks. This adds
some additional restrictions to some drivers like ixgbe, where those
conditions were necessary but never checked.

Signed-off-by: Bruce Richardson <[email protected]>
Acked-by: Praveen Shetty <[email protected]>
  • Loading branch information
bruce-richardson committed Jan 28, 2025
1 parent 61dcf27 commit 9eb6058
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 55 deletions.
20 changes: 20 additions & 0 deletions drivers/net/intel/common/rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <stdint.h>
#include <unistd.h>
#include <rte_mbuf.h>
#include <rte_ethdev.h>

#define CI_RX_BURST 32

Expand Down Expand Up @@ -89,4 +90,23 @@ ci_rxq_mbuf_initializer(uint16_t port_id)
return mb_def.rearm_data[0];
}

/* basic checks for a vector-driver capable queue.
* Individual drivers may have other further tests beyond this.
*/
static inline bool
ci_rxq_vec_capable(uint16_t nb_desc, uint16_t rx_free_thresh, uint64_t offloads)
{
if (!rte_is_power_of_2(nb_desc) ||
rx_free_thresh < CI_RX_BURST ||
(nb_desc % rx_free_thresh) != 0)
return false;

/* no driver supports timestamping or buffer split on vector path */
if ((offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) ||
(offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT))
return false;

return true;
}

#endif /* _COMMON_INTEL_RX_H_ */
35 changes: 7 additions & 28 deletions drivers/net/intel/i40e/i40e_rxtx_vec_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ i40e_rx_vec_dev_conf_condition_check_default(struct rte_eth_dev *dev)
struct i40e_adapter *ad =
I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
struct i40e_rx_queue *rxq;
uint16_t desc, i;
bool first_queue;

/* no QinQ support */
if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)
Expand All @@ -132,31 +129,13 @@ i40e_rx_vec_dev_conf_condition_check_default(struct rte_eth_dev *dev)
* Vector mode is allowed only when number of Rx queue
* descriptor is power of 2.
*/
if (!dev->data->dev_started) {
first_queue = true;
for (i = 0; i < dev->data->nb_rx_queues; i++) {
rxq = dev->data->rx_queues[i];
if (!rxq)
continue;
desc = rxq->nb_rx_desc;
if (first_queue)
ad->rx_vec_allowed =
rte_is_power_of_2(desc);
else
ad->rx_vec_allowed =
ad->rx_vec_allowed ?
rte_is_power_of_2(desc) :
ad->rx_vec_allowed;
first_queue = false;
}
} else {
/* Only check the first queue's descriptor number */
for (i = 0; i < dev->data->nb_rx_queues; i++) {
rxq = dev->data->rx_queues[i];
if (!rxq)
continue;
desc = rxq->nb_rx_desc;
ad->rx_vec_allowed = rte_is_power_of_2(desc);
ad->rx_vec_allowed = true;
for (uint16_t i = 0; i < dev->data->nb_rx_queues; i++) {
struct i40e_rx_queue *rxq = dev->data->rx_queues[i];
if (!rxq)
continue;
if (!ci_rxq_vec_capable(rxq->nb_rx_desc, rxq->rx_free_thresh, rxq->offloads)) {
ad->rx_vec_allowed = false;
break;
}
}
Expand Down
15 changes: 1 addition & 14 deletions drivers/net/intel/iavf/iavf_rxtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,6 @@ check_tx_thresh(uint16_t nb_desc, uint16_t tx_rs_thresh,
return 0;
}

static inline bool
check_rx_vec_allow(struct iavf_rx_queue *rxq)
{
if (rxq->rx_free_thresh >= IAVF_VPMD_RX_MAX_BURST &&
rxq->nb_rx_desc % rxq->rx_free_thresh == 0) {
PMD_INIT_LOG(DEBUG, "Vector Rx can be enabled on this rxq.");
return true;
}

PMD_INIT_LOG(DEBUG, "Vector Rx cannot be enabled on this rxq.");
return false;
}

static inline bool
check_tx_vec_allow(struct ci_tx_queue *txq)
{
Expand Down Expand Up @@ -722,7 +709,7 @@ iavf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
ad->rx_bulk_alloc_allowed = false;
}

if (check_rx_vec_allow(rxq) == false)
if (!ci_rxq_vec_capable(rxq->nb_rx_desc, rxq->rx_free_thresh, rxq->offloads))
ad->rx_vec_allowed = false;

#if defined RTE_ARCH_X86 || defined RTE_ARCH_ARM
Expand Down
1 change: 1 addition & 0 deletions drivers/net/intel/iavf/iavf_rxtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef _IAVF_RXTX_H_
#define _IAVF_RXTX_H_

#include "../common/rx.h"
#include "../common/tx.h"

/* In QLEN must be whole number of 32 descriptors. */
Expand Down
14 changes: 1 addition & 13 deletions drivers/net/intel/ice/ice_rxtx_vec_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,12 @@ ice_rx_vec_queue_default(struct ice_rx_queue *rxq)
if (!rxq)
return -1;

if (!rte_is_power_of_2(rxq->nb_rx_desc))
return -1;

if (rxq->rx_free_thresh < ICE_VPMD_RX_BURST)
return -1;

if (rxq->nb_rx_desc % rxq->rx_free_thresh)
if (!ci_rxq_vec_capable(rxq->nb_rx_desc, rxq->rx_free_thresh, rxq->offloads))
return -1;

if (rxq->proto_xtr != PROTO_XTR_NONE)
return -1;

if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
return -1;

if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)
return -1;

if (rxq->offloads & ICE_RX_VECTOR_OFFLOAD)
return ICE_VECTOR_OFFLOAD_PATH;

Expand Down
7 changes: 7 additions & 0 deletions drivers/net/intel/ixgbe/ixgbe_rxtx_vec_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ ixgbe_rx_vec_dev_conf_condition_check_default(struct rte_eth_dev *dev)
if (fconf->mode != RTE_FDIR_MODE_NONE)
return -1;

for (uint16_t i = 0; i < dev->data->nb_rx_queues; i++) {
struct ixgbe_rx_queue *rxq = dev->data->rx_queues[i];
if (!rxq)
continue;
if (!ci_rxq_vec_capable(rxq->nb_rx_desc, rxq->rx_free_thresh, rxq->offloads))
return -1;
}
return 0;
#else
RTE_SET_USED(dev);
Expand Down

0 comments on commit 9eb6058

Please sign in to comment.