dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Ciara Loftus <ciara.loftus@intel.com>
To: dev@dpdk.org
Cc: Ciara Loftus <ciara.loftus@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH v2 01/10] net/intel: introduce infrastructure for Tx path selection
Date: Fri, 12 Dec 2025 10:33:14 +0000	[thread overview]
Message-ID: <20251212103323.1481307-2-ciara.loftus@intel.com> (raw)
In-Reply-To: <20251212103323.1481307-1-ciara.loftus@intel.com>

The code for determining which Tx path to select during initialisation
has become complicated in many intel drivers due to the amount of
different paths and features available within each path. This commit
aims to simplify and genericize the path selection logic.

The following information about each Tx burst function is stored and
used by the new common function to select the appropriate Tx path:
- Tx Offloads
- SIMD bitwidth
- "Simple" Tx

The implementation is based off the Rx path selection infrastructure
introduced in a previous commit.

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
v2:
* Change req_features to pointer instead of passing by value
* Change num_paths from int to size_t
* Change i from int to unsigned int and define it inside the for
statement.
* Remove ci_tx_path_features_extra substructure
* Add simple tx feature in this patch rather in a later patch when it
is first used by a driver.
---
 drivers/net/intel/common/tx.h | 77 +++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/drivers/net/intel/common/tx.h b/drivers/net/intel/common/tx.h
index 5af64a4cfe..04d9aa8473 100644
--- a/drivers/net/intel/common/tx.h
+++ b/drivers/net/intel/common/tx.h
@@ -8,6 +8,7 @@
 #include <stdint.h>
 #include <rte_mbuf.h>
 #include <rte_ethdev.h>
+#include <rte_vect.h>
 
 /* forward declaration of the common intel (ci) queue structure */
 struct ci_tx_queue;
@@ -117,6 +118,19 @@ struct ci_tx_queue {
 	};
 };
 
+struct ci_tx_path_features {
+	uint32_t tx_offloads;
+	enum rte_vect_max_simd simd_width;
+	bool simple_tx;
+};
+
+struct ci_tx_path_info {
+	eth_tx_burst_t pkt_burst;
+	const char *info;
+	struct ci_tx_path_features features;
+	eth_tx_prep_t pkt_prep;
+};
+
 static __rte_always_inline void
 ci_tx_backlog_entry(struct ci_tx_entry *txep, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
@@ -262,4 +276,67 @@ ci_txq_release_all_mbufs(struct ci_tx_queue *txq, bool use_ctx)
 	memset(txq->sw_ring_vec, 0, sizeof(txq->sw_ring_vec[0]) * nb_desc);
 }
 
+/**
+ * Select the best matching Tx path based on features
+ *
+ * @param req_features
+ *   The requested features for the Tx path
+ * @param infos
+ *   Array of information about the available Tx paths
+ * @param num_paths
+ *   Number of available paths in the infos array
+ * @param default_path
+ *   Index of the default path to use if no suitable path is found
+ *
+ * @return
+ *   The packet burst function index that best matches the requested features,
+ *   or default_path if no suitable path is found
+ */
+static inline int
+ci_tx_path_select(const struct ci_tx_path_features *req_features,
+			const struct ci_tx_path_info *infos,
+			size_t num_paths,
+			int default_path)
+{
+	int idx = default_path;
+	const struct ci_tx_path_features *chosen_path_features = NULL;
+
+	for (unsigned int i = 0; i < num_paths; i++) {
+		const struct ci_tx_path_features *path_features = &infos[i].features;
+
+		/* Do not use a simple tx path if not requested. */
+		if (path_features->simple_tx && !req_features->simple_tx)
+			continue;
+
+		/* Ensure the path supports the requested TX offloads. */
+		if ((path_features->tx_offloads & req_features->tx_offloads) !=
+				req_features->tx_offloads)
+			continue;
+
+		/* Ensure the path's SIMD width is compatible with the requested width. */
+		if (path_features->simd_width > req_features->simd_width)
+			continue;
+
+		/* Do not select the path if it is less suitable than the chosen path. */
+		if (chosen_path_features != NULL) {
+			/* Do not select paths with lower SIMD width than the chosen path. */
+			if (path_features->simd_width < chosen_path_features->simd_width)
+				continue;
+			/* Do not select paths with more offloads enabled than the chosen path if
+			 * the SIMD widths are the same.
+			 */
+			if (path_features->simd_width == chosen_path_features->simd_width &&
+					rte_popcount32(path_features->tx_offloads) >
+					rte_popcount32(chosen_path_features->tx_offloads))
+				continue;
+		}
+
+		/* Finally, select the path since it has met all the requirements. */
+		idx = i;
+		chosen_path_features = &infos[idx].features;
+	}
+
+	return idx;
+}
+
 #endif /* _COMMON_INTEL_TX_H_ */
-- 
2.43.0


  reply	other threads:[~2025-12-12 10:33 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-09 11:26 [PATCH 00/13] net/intel: tx path selection simplification Ciara Loftus
2025-12-09 11:26 ` [PATCH 01/13] net/intel: introduce infrastructure for Tx path selection Ciara Loftus
2025-12-11 10:25   ` Bruce Richardson
2025-12-09 11:26 ` [PATCH 02/13] net/ice: use same Tx path across processes Ciara Loftus
2025-12-11 11:39   ` Bruce Richardson
2025-12-12 10:39     ` Loftus, Ciara
2025-12-09 11:26 ` [PATCH 03/13] net/ice: use common Tx path selection infrastructure Ciara Loftus
2025-12-11 11:56   ` Bruce Richardson
2025-12-11 12:02     ` Bruce Richardson
2025-12-09 11:26 ` [PATCH 04/13] net/iavf: use same Tx path across processes Ciara Loftus
2025-12-09 11:26 ` [PATCH 05/13] net/iavf: use common Tx path selection infrastructure Ciara Loftus
2025-12-09 11:26 ` [PATCH 06/13] net/i40e: use same Tx path across processes Ciara Loftus
2025-12-09 11:26 ` [PATCH 07/13] net/i40e: use common Tx path selection infrastructure Ciara Loftus
2025-12-09 11:26 ` [PATCH 08/13] net/idpf: " Ciara Loftus
2025-12-09 11:26 ` [PATCH 09/13] net/cpfl: " Ciara Loftus
2025-12-09 11:26 ` [PATCH 10/13] docs: fix TSO and checksum offload feature status in ice doc Ciara Loftus
2025-12-11 11:58   ` Bruce Richardson
2025-12-09 11:26 ` [PATCH 11/13] docs: fix TSO feature status in iavf driver documentation Ciara Loftus
2025-12-11 11:58   ` Bruce Richardson
2025-12-09 11:26 ` [PATCH 12/13] docs: fix inline crypto feature status in iavf driver doc Ciara Loftus
2025-12-11 11:59   ` Bruce Richardson
2025-12-09 11:26 ` [PATCH 13/13] docs: fix TSO feature status in i40e driver documentation Ciara Loftus
2025-12-11 11:59   ` Bruce Richardson
2025-12-12 10:33 ` [PATCH v2 00/10] net/intel: tx path selection simplification Ciara Loftus
2025-12-12 10:33   ` Ciara Loftus [this message]
2025-12-12 10:33   ` [PATCH v2 02/10] net/ice: use common Tx path selection infrastructure Ciara Loftus
2025-12-12 10:33   ` [PATCH v2 03/10] net/iavf: " Ciara Loftus
2025-12-12 10:33   ` [PATCH v2 04/10] net/i40e: " Ciara Loftus
2025-12-12 10:33   ` [PATCH v2 05/10] net/idpf: " Ciara Loftus
2025-12-12 10:33   ` [PATCH v2 06/10] net/cpfl: " Ciara Loftus
2025-12-12 10:33   ` [PATCH v2 07/10] docs: fix TSO and checksum offload feature status in ice doc Ciara Loftus
2025-12-12 10:33   ` [PATCH v2 08/10] docs: fix TSO feature status in iavf driver documentation Ciara Loftus
2025-12-12 10:33   ` [PATCH v2 09/10] docs: fix inline crypto feature status in iavf driver doc Ciara Loftus
2025-12-12 10:33   ` [PATCH v2 10/10] docs: fix TSO feature status in i40e driver documentation Ciara Loftus
2025-12-12 11:06   ` [PATCH v3 00/10] net/intel: tx path selection simplification Ciara Loftus
2025-12-12 11:06     ` [PATCH v3 01/10] net/intel: introduce infrastructure for Tx path selection Ciara Loftus
2025-12-12 11:06     ` [PATCH v3 02/10] net/ice: use common Tx path selection infrastructure Ciara Loftus
2025-12-12 13:40       ` Bruce Richardson
2025-12-12 11:06     ` [PATCH v3 03/10] net/iavf: " Ciara Loftus
2025-12-12 14:09       ` Bruce Richardson
2025-12-12 11:06     ` [PATCH v3 04/10] net/i40e: " Ciara Loftus
2025-12-12 14:53       ` Bruce Richardson
2025-12-12 11:06     ` [PATCH v3 05/10] net/idpf: " Ciara Loftus
2025-12-12 15:26       ` Bruce Richardson
2025-12-12 11:06     ` [PATCH v3 06/10] net/cpfl: " Ciara Loftus
2025-12-12 15:30       ` Bruce Richardson
2025-12-12 11:06     ` [PATCH v3 07/10] docs: fix TSO and checksum offload feature status in ice doc Ciara Loftus
2025-12-12 11:06     ` [PATCH v3 08/10] docs: fix TSO feature status in iavf driver documentation Ciara Loftus
2025-12-12 11:06     ` [PATCH v3 09/10] docs: fix inline crypto feature status in iavf driver doc Ciara Loftus
2025-12-12 11:06     ` [PATCH v3 10/10] docs: fix TSO feature status in i40e driver documentation Ciara Loftus
2025-12-12 15:48     ` [PATCH v3 00/10] net/intel: tx path selection simplification Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251212103323.1481307-2-ciara.loftus@intel.com \
    --to=ciara.loftus@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).