DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Jarry <rjarry@redhat.com>
To: dev@dpdk.org, Dariusz Sosnowski <dsosnowski@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Bing Zhao <bingz@nvidia.com>, Ori Kam <orika@nvidia.com>,
	Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>
Subject: [PATCH dpdk] net/mlx5: add option to reduce Tx datapath compilation time
Date: Tue, 21 Apr 2026 23:23:55 +0200	[thread overview]
Message-ID: <20260421212356.573976-1-rjarry@redhat.com> (raw)

The mlx5 Tx datapath compiles 42 variants of the burst function, each
a specialization of mlx5_tx_burst_tmpl() with a different combination
of offload flags. The compiler must instantiate and optimize the entire
3800+ line template for every variant, which dominates build time for
all the code base.

When MLX5_MINIMAL_TX is defined, only 11 variants are compiled instead
of 42. Two new "full without inline" superset variants (full_noi and
full_noi_empw) are introduced to satisfy the selection algorithm
constraint that the INLINE bit must match exactly between request and
variant. The remaining 9 variants are existing ones that already cover
all reachable combinations of the EMPW, MPW, INLINE and TXPP flags.

The selection function is unchanged. At runtime, it picks the best
matching variant from whatever is available. With the minimal set, each
selected variant may include a few unnecessary offload checks compared
to the precisely-tailored original, which has negligible impact on
performance since modern branch predictors handle static never-taken
branches well.

Compilation times (MM:SS) measured on Intel Core Ultra 7 165U with GCC
16.0.1:

FILE              BUILD          BEFORE   AFTER   DELTA
================= ============== ======== ======= ===============
mlx5_tx_mpw.c     debug          00:31    00:22   -00:09 (-29.0%)
mlx5_tx_txpp.c                   00:39    00:25   -00:14 (-35.9%)
mlx5_tx_empw.c                   01:11    00:19   -00:52 (-73.2%)
mlx5_tx_nompw.c                  01:13    00:16   -00:57 (-78.1%)
----------------- -------------- -------- ------- ---------------
mlx5_tx_mpw.c     debug+asan     03:15    02:45   -00:30 (-15.4%)
mlx5_tx_txpp.c                  *06:28*   03:13   -03:15 (-50.3%)
mlx5_tx_empw.c                  *12:07*   01:55   -10:12 (-84.2%)
mlx5_tx_nompw.c                 *12:54*   01:45   -11:09 (-86.4%)
----------------- -------------- -------- ------- ---------------
mlx5_tx_mpw.c     release        00:12    00:09   -00:03 (-25.0%)
mlx5_tx_txpp.c                   00:31    00:24   -00:07 (-22.6%)
mlx5_tx_empw.c                   00:32    00:18   -00:14 (-43.8%)
mlx5_tx_nompw.c                  00:34    00:16   -00:18 (-52.9%)
----------------- -------------- -------- ------- ---------------
mlx5_tx_mpw.c     release+asan   00:25    00:23   -00:02 (-8.0%)
mlx5_tx_empw.c                   01:24    00:42   -00:42 (-50.0%)
mlx5_tx_txpp.c                   01:32    00:59   -00:33 (-35.9%)
mlx5_tx_nompw.c                  01:38    00:37   -01:01 (-62.2%)

To enable, pass -DMLX5_MINIMAL_TX via c_args:

  meson setup build -Dc_args='-DMLX5_MINIMAL_TX'

Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
 drivers/net/mlx5/mlx5_tx.c       | 23 +++++++++++++++++++++++
 drivers/net/mlx5/mlx5_tx.h       | 12 ++++++++++++
 drivers/net/mlx5/mlx5_tx_empw.c  | 10 ++++++++++
 drivers/net/mlx5/mlx5_tx_mpw.c   |  2 ++
 drivers/net/mlx5/mlx5_tx_nompw.c |  9 +++++++++
 drivers/net/mlx5/mlx5_tx_txpp.c  |  2 ++
 6 files changed, 58 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_tx.c b/drivers/net/mlx5/mlx5_tx.c
index 94644bc3b9e2..a395577bb7e6 100644
--- a/drivers/net/mlx5/mlx5_tx.c
+++ b/drivers/net/mlx5/mlx5_tx.c
@@ -294,6 +294,14 @@ MLX5_TXOFF_INFO(full_empw,
 		MLX5_TXOFF_CONFIG_INLINE | MLX5_TXOFF_CONFIG_VLAN |
 		MLX5_TXOFF_CONFIG_METADATA | MLX5_TXOFF_CONFIG_EMPW)
 
+#ifdef MLX5_MINIMAL_TX
+MLX5_TXOFF_INFO(full_noi_empw,
+		MLX5_TXOFF_CONFIG_MULTI | MLX5_TXOFF_CONFIG_TSO |
+		MLX5_TXOFF_CONFIG_SWP | MLX5_TXOFF_CONFIG_CSUM |
+		MLX5_TXOFF_CONFIG_VLAN | MLX5_TXOFF_CONFIG_METADATA |
+		MLX5_TXOFF_CONFIG_EMPW)
+#else
+
 MLX5_TXOFF_INFO(none_empw,
 		MLX5_TXOFF_CONFIG_NONE | MLX5_TXOFF_CONFIG_EMPW)
 
@@ -355,6 +363,8 @@ MLX5_TXOFF_INFO(iv_empw,
 		MLX5_TXOFF_CONFIG_INLINE | MLX5_TXOFF_CONFIG_VLAN |
 		MLX5_TXOFF_CONFIG_METADATA | MLX5_TXOFF_CONFIG_EMPW)
 
+#endif /* !MLX5_MINIMAL_TX */
+
 MLX5_TXOFF_INFO(full_ts_nompw,
 		MLX5_TXOFF_CONFIG_FULL | MLX5_TXOFF_CONFIG_TXPP)
 
@@ -374,6 +384,7 @@ MLX5_TXOFF_INFO(full_ts_noi,
 		MLX5_TXOFF_CONFIG_VLAN | MLX5_TXOFF_CONFIG_METADATA |
 		MLX5_TXOFF_CONFIG_TXPP | MLX5_TXOFF_CONFIG_EMPW)
 
+#ifndef MLX5_MINIMAL_TX
 MLX5_TXOFF_INFO(none_ts,
 		MLX5_TXOFF_CONFIG_NONE | MLX5_TXOFF_CONFIG_TXPP |
 		MLX5_TXOFF_CONFIG_EMPW)
@@ -392,6 +403,7 @@ MLX5_TXOFF_INFO(mtiv_ts,
 		MLX5_TXOFF_CONFIG_INLINE | MLX5_TXOFF_CONFIG_VLAN |
 		MLX5_TXOFF_CONFIG_METADATA | MLX5_TXOFF_CONFIG_TXPP |
 		MLX5_TXOFF_CONFIG_EMPW)
+#endif
 
 MLX5_TXOFF_INFO(full,
 		MLX5_TXOFF_CONFIG_MULTI | MLX5_TXOFF_CONFIG_TSO |
@@ -399,6 +411,13 @@ MLX5_TXOFF_INFO(full,
 		MLX5_TXOFF_CONFIG_INLINE | MLX5_TXOFF_CONFIG_VLAN |
 		MLX5_TXOFF_CONFIG_METADATA)
 
+#ifdef MLX5_MINIMAL_TX
+MLX5_TXOFF_INFO(full_noi,
+		MLX5_TXOFF_CONFIG_MULTI | MLX5_TXOFF_CONFIG_TSO |
+		MLX5_TXOFF_CONFIG_SWP | MLX5_TXOFF_CONFIG_CSUM |
+		MLX5_TXOFF_CONFIG_VLAN | MLX5_TXOFF_CONFIG_METADATA)
+#else
+
 MLX5_TXOFF_INFO(none,
 		MLX5_TXOFF_CONFIG_NONE)
 
@@ -460,6 +479,8 @@ MLX5_TXOFF_INFO(iv,
 		MLX5_TXOFF_CONFIG_INLINE | MLX5_TXOFF_CONFIG_VLAN |
 		MLX5_TXOFF_CONFIG_METADATA)
 
+#endif /* !MLX5_MINIMAL_TX */
+
 MLX5_TXOFF_INFO(none_mpw,
 		MLX5_TXOFF_CONFIG_NONE | MLX5_TXOFF_CONFIG_EMPW |
 		MLX5_TXOFF_CONFIG_MPW)
@@ -473,9 +494,11 @@ MLX5_TXOFF_INFO(mc_mpw,
 		MLX5_TXOFF_CONFIG_MULTI | MLX5_TXOFF_CONFIG_CSUM |
 		MLX5_TXOFF_CONFIG_EMPW | MLX5_TXOFF_CONFIG_MPW)
 
+#ifndef MLX5_MINIMAL_TX
 MLX5_TXOFF_INFO(i_mpw,
 		MLX5_TXOFF_CONFIG_INLINE | MLX5_TXOFF_CONFIG_EMPW |
 		MLX5_TXOFF_CONFIG_MPW)
+#endif
 };
 
 /**
diff --git a/drivers/net/mlx5/mlx5_tx.h b/drivers/net/mlx5/mlx5_tx.h
index 016dba0b03c6..db55355abdd9 100644
--- a/drivers/net/mlx5/mlx5_tx.h
+++ b/drivers/net/mlx5/mlx5_tx.h
@@ -244,6 +244,9 @@ int mlx5_tx_burst_mode_get(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 /* mlx5_tx_empw.c */
 
 MLX5_TXOFF_PRE_DECL(full_empw);
+#ifdef MLX5_MINIMAL_TX
+MLX5_TXOFF_PRE_DECL(full_noi_empw);
+#else
 MLX5_TXOFF_PRE_DECL(none_empw);
 MLX5_TXOFF_PRE_DECL(md_empw);
 MLX5_TXOFF_PRE_DECL(mt_empw);
@@ -258,10 +261,14 @@ MLX5_TXOFF_PRE_DECL(sciv_empw);
 MLX5_TXOFF_PRE_DECL(i_empw);
 MLX5_TXOFF_PRE_DECL(v_empw);
 MLX5_TXOFF_PRE_DECL(iv_empw);
+#endif
 
 /* mlx5_tx_nompw.c */
 
 MLX5_TXOFF_PRE_DECL(full);
+#ifdef MLX5_MINIMAL_TX
+MLX5_TXOFF_PRE_DECL(full_noi);
+#else
 MLX5_TXOFF_PRE_DECL(none);
 MLX5_TXOFF_PRE_DECL(md);
 MLX5_TXOFF_PRE_DECL(mt);
@@ -276,6 +283,7 @@ MLX5_TXOFF_PRE_DECL(sciv);
 MLX5_TXOFF_PRE_DECL(i);
 MLX5_TXOFF_PRE_DECL(v);
 MLX5_TXOFF_PRE_DECL(iv);
+#endif
 
 /* mlx5_tx_txpp.c */
 
@@ -283,17 +291,21 @@ MLX5_TXOFF_PRE_DECL(full_ts_nompw);
 MLX5_TXOFF_PRE_DECL(full_ts_nompwi);
 MLX5_TXOFF_PRE_DECL(full_ts);
 MLX5_TXOFF_PRE_DECL(full_ts_noi);
+#ifndef MLX5_MINIMAL_TX
 MLX5_TXOFF_PRE_DECL(none_ts);
 MLX5_TXOFF_PRE_DECL(mdi_ts);
 MLX5_TXOFF_PRE_DECL(mti_ts);
 MLX5_TXOFF_PRE_DECL(mtiv_ts);
+#endif
 
 /* mlx5_tx_mpw.c */
 
 MLX5_TXOFF_PRE_DECL(none_mpw);
 MLX5_TXOFF_PRE_DECL(mci_mpw);
 MLX5_TXOFF_PRE_DECL(mc_mpw);
+#ifndef MLX5_MINIMAL_TX
 MLX5_TXOFF_PRE_DECL(i_mpw);
+#endif
 
 static __rte_always_inline struct mlx5_uar_data *
 mlx5_tx_bfreg(struct mlx5_txq_data *txq)
diff --git a/drivers/net/mlx5/mlx5_tx_empw.c b/drivers/net/mlx5/mlx5_tx_empw.c
index 81c2dc451b14..4cb9965956c5 100644
--- a/drivers/net/mlx5/mlx5_tx_empw.c
+++ b/drivers/net/mlx5/mlx5_tx_empw.c
@@ -9,6 +9,14 @@
 MLX5_TXOFF_DECL(full_empw,
 		MLX5_TXOFF_CONFIG_FULL | MLX5_TXOFF_CONFIG_EMPW)
 
+#ifdef MLX5_MINIMAL_TX
+MLX5_TXOFF_DECL(full_noi_empw,
+		MLX5_TXOFF_CONFIG_MULTI | MLX5_TXOFF_CONFIG_TSO |
+		MLX5_TXOFF_CONFIG_SWP | MLX5_TXOFF_CONFIG_CSUM |
+		MLX5_TXOFF_CONFIG_VLAN | MLX5_TXOFF_CONFIG_METADATA |
+		MLX5_TXOFF_CONFIG_EMPW)
+#else
+
 MLX5_TXOFF_DECL(none_empw,
 		MLX5_TXOFF_CONFIG_NONE | MLX5_TXOFF_CONFIG_EMPW)
 
@@ -69,3 +77,5 @@ MLX5_TXOFF_DECL(v_empw,
 MLX5_TXOFF_DECL(iv_empw,
 		MLX5_TXOFF_CONFIG_INLINE | MLX5_TXOFF_CONFIG_VLAN |
 		MLX5_TXOFF_CONFIG_METADATA | MLX5_TXOFF_CONFIG_EMPW)
+
+#endif /* !MLX5_MINIMAL_TX */
diff --git a/drivers/net/mlx5/mlx5_tx_mpw.c b/drivers/net/mlx5/mlx5_tx_mpw.c
index bd7d5d2e533f..15061cde5bb1 100644
--- a/drivers/net/mlx5/mlx5_tx_mpw.c
+++ b/drivers/net/mlx5/mlx5_tx_mpw.c
@@ -29,6 +29,8 @@ MLX5_TXOFF_DECL(mc_mpw,
 		MLX5_TXOFF_CONFIG_MULTI | MLX5_TXOFF_CONFIG_CSUM |
 		MLX5_TXOFF_CONFIG_EMPW | MLX5_TXOFF_CONFIG_MPW)
 
+#ifndef MLX5_MINIMAL_TX
 MLX5_TXOFF_DECL(i_mpw,
 		MLX5_TXOFF_CONFIG_INLINE | MLX5_TXOFF_CONFIG_EMPW |
 		MLX5_TXOFF_CONFIG_MPW)
+#endif
diff --git a/drivers/net/mlx5/mlx5_tx_nompw.c b/drivers/net/mlx5/mlx5_tx_nompw.c
index ad23aab5d37b..a4d9ac8c576a 100644
--- a/drivers/net/mlx5/mlx5_tx_nompw.c
+++ b/drivers/net/mlx5/mlx5_tx_nompw.c
@@ -9,6 +9,13 @@
 MLX5_TXOFF_DECL(full,
 		MLX5_TXOFF_CONFIG_FULL)
 
+#ifdef MLX5_MINIMAL_TX
+MLX5_TXOFF_DECL(full_noi,
+		MLX5_TXOFF_CONFIG_MULTI | MLX5_TXOFF_CONFIG_TSO |
+		MLX5_TXOFF_CONFIG_SWP | MLX5_TXOFF_CONFIG_CSUM |
+		MLX5_TXOFF_CONFIG_VLAN | MLX5_TXOFF_CONFIG_METADATA)
+#else
+
 MLX5_TXOFF_DECL(none,
 		MLX5_TXOFF_CONFIG_NONE)
 
@@ -69,3 +76,5 @@ MLX5_TXOFF_DECL(v,
 MLX5_TXOFF_DECL(iv,
 		MLX5_TXOFF_CONFIG_INLINE | MLX5_TXOFF_CONFIG_VLAN |
 		MLX5_TXOFF_CONFIG_METADATA)
+
+#endif /* !MLX5_MINIMAL_TX */
diff --git a/drivers/net/mlx5/mlx5_tx_txpp.c b/drivers/net/mlx5/mlx5_tx_txpp.c
index 4d2a4c65f752..3e48a2bbe23c 100644
--- a/drivers/net/mlx5/mlx5_tx_txpp.c
+++ b/drivers/net/mlx5/mlx5_tx_txpp.c
@@ -25,6 +25,7 @@ MLX5_TXOFF_DECL(full_ts_noi,
 		MLX5_TXOFF_CONFIG_VLAN | MLX5_TXOFF_CONFIG_METADATA |
 		MLX5_TXOFF_CONFIG_TXPP | MLX5_TXOFF_CONFIG_EMPW)
 
+#ifndef MLX5_MINIMAL_TX
 MLX5_TXOFF_DECL(none_ts,
 		MLX5_TXOFF_CONFIG_NONE | MLX5_TXOFF_CONFIG_TXPP |
 		MLX5_TXOFF_CONFIG_EMPW)
@@ -43,3 +44,4 @@ MLX5_TXOFF_DECL(mtiv_ts,
 		MLX5_TXOFF_CONFIG_INLINE | MLX5_TXOFF_CONFIG_VLAN |
 		MLX5_TXOFF_CONFIG_METADATA | MLX5_TXOFF_CONFIG_TXPP |
 		MLX5_TXOFF_CONFIG_EMPW)
+#endif /* !MLX5_MINIMAL_TX */
-- 
2.53.0


             reply	other threads:[~2026-04-21 21:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21 21:23 Robin Jarry [this message]
2026-04-21 21:56 ` [PATCH dpdk] net/mlx5: add option to reduce Tx datapath compilation time Stephen Hemminger
2026-04-22  7:27 ` Bruce Richardson
2026-04-28 15:59   ` Robin Jarry

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=20260421212356.573976-1-rjarry@redhat.com \
    --to=rjarry@redhat.com \
    --cc=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    /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