From 820a3f4acbcd266b9f46fe127fa3846cecb4d93d Mon Sep 17 00:00:00 2001
From: liujie-answer <liujie5@linkdatatechnology.com>
Date: Sat, 29 Aug 2026 06:35:00 +0000
Subject: [PATCH 148/153] net/sxe2: add Rx buffer split support
Program split type and header length for supported packet types.
Signed-off-by: liujie-answer <liujie5@linkdatatechnology.com>
drivers/net/sxe2/sxe2_cmd_chnl.c | 115 +++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
@@ -193,6 +193,110 @@ int32_t sxe2_drv_vsi_del(struct sxe2_adapter *adapter, struct sxe2_vsi *vsi)
#define SXE2_RXQ_CTXT_CFG_BUF_LEN_ALIGN (1 << 7)
#define SXE2_RX_HDR_SIZE 256
+static int32_t sxe2_rxq_buf_split_fill(struct sxe2_rx_queue *rxq,
+ struct sxe2_drv_rxq_ctxt *ctxt)
+{
+ uint32_t proto_hdr;
+ int32_t ret = 0;
+
+ if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
+ ctxt->hdr_len = 0;
+ ctxt->split_type_mask = 0;
+ goto l_end;
+ }
+
+ proto_hdr = rxq->rx_seg[0].proto_hdr;
+ if (proto_hdr == RTE_PTYPE_UNKNOWN) {
+ PMD_LOG_ERR(RX, "Buffer split protocol must be configured");
+ ret = -EINVAL;
+ goto l_end;
+ }
+
+ switch (proto_hdr & RTE_PTYPE_L4_MASK) {
+ case RTE_PTYPE_L4_TCP:
+ ctxt->split_type_mask = SXE2_PTYPE_L4_TCP;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ case RTE_PTYPE_L4_UDP:
+ ctxt->split_type_mask = SXE2_PTYPE_L4_UDP;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ case RTE_PTYPE_L4_SCTP:
+ ctxt->split_type_mask = SXE2_PTYPE_L4_SCTP;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ default:
+ break;
+ }
+
+ switch (proto_hdr & RTE_PTYPE_L3_MASK) {
+ case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
+ ctxt->split_type_mask = SXE2_PTYPE_L3_IPV4;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
+ ctxt->split_type_mask = SXE2_PTYPE_L3_IPV6;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ default:
+ break;
+ }
+
+ if ((proto_hdr & RTE_PTYPE_L2_MASK) == RTE_PTYPE_L2_ETHER) {
+ ctxt->split_type_mask = SXE2_PTYPE_L2_ETHER;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ }
+
+ switch (proto_hdr & RTE_PTYPE_INNER_L4_MASK) {
+ case RTE_PTYPE_INNER_L4_TCP:
+ ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_TCP;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ case RTE_PTYPE_INNER_L4_UDP:
+ ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_UDP;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ case RTE_PTYPE_INNER_L4_SCTP:
+ ctxt->split_type_mask = SXE2_PTYPE_INNER_L4_SCTP;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ default:
+ break;
+ }
+
+ switch (proto_hdr & RTE_PTYPE_INNER_L3_MASK) {
+ case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
+ ctxt->split_type_mask = SXE2_PTYPE_INNER_L3_IPV4;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
+ ctxt->split_type_mask = SXE2_PTYPE_INNER_L3_IPV6;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ default:
+ break;
+ }
+
+ if ((proto_hdr & RTE_PTYPE_INNER_L2_MASK) == RTE_PTYPE_INNER_L2_ETHER) {
+ ctxt->split_type_mask = SXE2_PTYPE_INNER_L2_ETHER;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ }
+
+ if ((proto_hdr & RTE_PTYPE_TUNNEL_MASK) == RTE_PTYPE_TUNNEL_GRENAT) {
+ ctxt->split_type_mask = SXE2_PTYPE_TUNNEL_GRENAT;
+ ctxt->hdr_len = SXE2_RX_HDR_SIZE;
+ goto l_end;
+ }
+
+ PMD_LOG_ERR(RX, "Buffer split protocol is not supported");
+ ret = -EINVAL;
+
+l_end:
+ return ret;
+}
+
static int32_t sxe2_rxq_ctxt_cfg_fill(struct sxe2_rx_queue *rxq,
struct sxe2_drv_rxq_cfg_req *req, uint16_t rxq_cnt)
{
@@ -226,7 +330,18 @@ static int32_t sxe2_rxq_ctxt_cfg_fill(struct sxe2_rx_queue *rxq,
else
ctxt->keep_crc_en = 0;
+ if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
+ ret = sxe2_rxq_buf_split_fill(rxq, ctxt);
+ if (ret)
+ goto l_end;
+ ctxt->split_en = 1;
+ } else {
+ ctxt->split_en = 0;
+ }
+
ctxt->desc_size = sizeof(union sxe2_rx_desc);
+
+l_end:
return ret;
}
--
2.43.0