On 2/9/2026 5:45 PM, Bruce Richardson wrote:
Since i40e and ice have the same checksum offload logic, merge their
functions into one. Future rework should enable this to be used by more
drivers also.
Signed-off-by: Bruce Richardson <[email protected]>
---
drivers/net/intel/common/tx_scalar.h | 58 +++++++++++++++++++++++++++
drivers/net/intel/i40e/i40e_rxtx.c | 52 +-----------------------
drivers/net/intel/i40e/i40e_rxtx.h | 1 +
drivers/net/intel/ice/ice_rxtx.c | 60 +---------------------------
drivers/net/intel/ice/ice_rxtx.h | 1 +
5 files changed, 62 insertions(+), 110 deletions(-)
diff --git a/drivers/net/intel/common/tx_scalar.h
b/drivers/net/intel/common/tx_scalar.h
index 573f5136a9..cf0dcb4b2c 100644
--- a/drivers/net/intel/common/tx_scalar.h
+++ b/drivers/net/intel/common/tx_scalar.h
@@ -59,6 +59,64 @@ ci_tx_xmit_cleanup(struct ci_tx_queue *txq)
return 0;
}
+/* Common checksum enable function for Intel drivers (ice, i40e, etc.) */
+static inline void
+ci_txd_enable_checksum(uint64_t ol_flags,
+ uint32_t *td_cmd,
+ uint32_t *td_offset,
+ union ci_tx_offload tx_offload)
+{
+ /* Enable L3 checksum offloads */
+ if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
+ *td_cmd |= CI_TX_DESC_CMD_IIPT_IPV4_CSUM;
+ *td_offset |= (tx_offload.l3_len >> 2) <<
+ CI_TX_DESC_LEN_IPLEN_S;
+ } else if (ol_flags & RTE_MBUF_F_TX_IPV4) {
+ *td_cmd |= CI_TX_DESC_CMD_IIPT_IPV4;
+ *td_offset |= (tx_offload.l3_len >> 2) <<
+ CI_TX_DESC_LEN_IPLEN_S;
+ } else if (ol_flags & RTE_MBUF_F_TX_IPV6) {
+ *td_cmd |= CI_TX_DESC_CMD_IIPT_IPV6;
+ *td_offset |= (tx_offload.l3_len >> 2) <<
+ CI_TX_DESC_LEN_IPLEN_S;
+ }
+
+ if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
+ *td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_TCP;
+ *td_offset |= (tx_offload.l4_len >> 2) <<
+ CI_TX_DESC_LEN_L4_LEN_S;
+ return;
+ }
+
+ if (ol_flags & RTE_MBUF_F_TX_UDP_SEG) {
+ *td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_UDP;
+ *td_offset |= (tx_offload.l4_len >> 2) <<
+ CI_TX_DESC_LEN_L4_LEN_S;
+ return;
+ }
+
+ /* Enable L4 checksum offloads */
+ switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {
+ case RTE_MBUF_F_TX_TCP_CKSUM:
+ *td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_TCP;
+ *td_offset |= (sizeof(struct rte_tcp_hdr) >> 2) <<
+ CI_TX_DESC_LEN_L4_LEN_S;
+ break;
+ case RTE_MBUF_F_TX_SCTP_CKSUM:
+ *td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_SCTP;
+ *td_offset |= (sizeof(struct rte_sctp_hdr) >> 2) <<
+ CI_TX_DESC_LEN_L4_LEN_S;
+ break;
+ case RTE_MBUF_F_TX_UDP_CKSUM:
+ *td_cmd |= CI_TX_DESC_CMD_L4T_EOFT_UDP;
+ *td_offset |= (sizeof(struct rte_udp_hdr) >> 2) <<
+ CI_TX_DESC_LEN_L4_LEN_S;
+ break;
+ default:
+ break;
+ }
Nitpick: some of the indentation here is inconststent. Perhaps enabling
whitespace view in your editor would help, if you haven't done so?
(the inconsistency was already present in the ice function but that
doesn't mean we have to copy it!)
Otherwise,
Acked-by: Anatoly Burakov <[email protected]>
--
Thanks,
Anatoly