DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v9 00/30] net/hinic3: add PMD features and fixes
@ 2026-11-25 17:03 Jiacheng Ye
  2026-11-25 17:03 ` [PATCH v9 01/30] net/hinic3: fix SP230 VF PCI device ID Jiacheng Ye
                   ` (30 more replies)
  0 siblings, 31 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:03 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

This series fixes offload capability advertisement, cmdq/compact CQE
configuration, and a handful of driver defects, and adds NIC
type identification, FEC, CIR drop statistics, VF LAG/link state, COS
mask/map, mbox recording, RSS hash configuration, compact CQE Rx/Tx
paths, TSO segment expansion, Tx burst mode reporting, queue statistics,
pseudo-header checksum, per-tile cmdq ops, SP560 NIC support, and device
kvargs tunables.

This version supersedes v8. v8 was applied to next-net; please drop it
and use v9 instead.

Changes in v9:
- 0005: split the wildcard IPv4 and ICMP/UDP fixes out of the flow rule
  parsing refactor (0021), so they can be reviewed and backported on
  their own: eth / ipv4 / udp is accepted as a wildcard, and
  eth / ipv4 / icmp no longer needs an explicit ipv4 proto 1 to match
  ICMP, because the ICMP item is translated into the IPv4 protocol key.
  Masks that select fields the TCAM cannot match are rejected with
  -EINVAL instead of being silently ignored: the ICMP type, code,
  checksum, identifier or sequence number, and the UDP length or
  checksum.
- 0009/0010: split the per-queue start/stop fix into two commits. The
  first one (return success when there is no TCAM rule) fixes
  commit efa3b9b36fc7 ("net/hinic3: add flow control and filters"), the
  uninitialized return of which is still present in 25.11, and
  commit b247199927a1 ("net/hinic3: fix return value of FDIR enabling"),
  which added the -EINVAL in main; it carries Cc: stable for 25.11. The
  second one (gate RQ enable on HTN FDIR) fixes
  commit b20dc78b286a ("net/hinic3: support Compact CQE in Rx"), which
  is not in 25.11. This series has 30 patches, so from 0009 onward the
  v8 number is two lower.
- 0012: if the Rx queue count does not fit in the MSI-X vector table,
  keep the old polling behaviour on SP230 instead of failing dev_start;
  only fail when the application explicitly requested Rx interrupts.
- 0013: drop the stale QinQ entries from features/hinic3.ini and the
  Features list in hinic3.rst, since the PMD does not advertise QinQ.
- 0015: return -EIO, not -EINVAL, when the FEC get/set mailbox command
  does not reach the firmware, and keep -EINVAL for a firmware status
  error or an empty response, like the other mailbox commands in the
  file. Also return -EINVAL for NOT_SET (0) instead of mapping it to
  AUTO, as it has no DPDK equivalent.
- 0018: keep the cached PF link state when the firmware link query fails.
  hinic3_link_update() used to store the synthesized LINK_DOWN into
  hwdev->link_status, which hinic3_vf_link_status() ANDs with the vport
  state, so on a VF a failed query made the port report DOWN, and
  dev_set_link_up() read that stale DOWN, until the next successful query
  or PF link event. The current call still reports DOWN, but the cache is
  only updated when the query succeeds.
- 0019: select the cmdq ops by the NIC_F_HTN_CMDQ capability bit rather
  than by a NIC-type table, like every other per-tile selection in the
  driver. The bit agrees with the removed table: the SP230 reports HTN,
  the SP620 reports STN.
- 0021: reject a Geneve mask that selects the reserved bits (rsvd1), like
  the other Geneve fields the TCAM cannot match, instead of ignoring it
  and letting the rule match every Geneve packet.
- 0022: report the speed actually applied, in Mbps, instead of the table
  index in the invalid-speed warning.
- 0024: allocate the ptype table with rte_zmalloc_socket() on the device
  socket, like the other per-port allocations, instead of rte_zmalloc().
  Also drop the commit message paragraph about the inner IPv4 fragment,
  ICMP and ESP ptype branches: the table is new in this patch, so there
  is nothing to drop.
- 0026: correct the copy pool comment: one copied TSO packet pins up to
  227 mbufs, so the pool can still run out at a queue depth of 256, not
  only above it.
- 0027: in hinic3.rst, describe the Tx WQE task format selection, in
  place of the compact CQE paragraph that the Tx burst split added. That
  paragraph duplicates the existing compact CQE description.
- Beyond the items above, v9 also cleans up code consistency and
  documentation across the series: unified error handling and log
  wording, and corrections to stale or duplicated text in the driver
  documentation.

Changes in v8:
- 0009: fold the v7 "add NIC type identification" patch into the
  pseudo-header checksum fix that follows it, which is the only user of
  the new HINIC3_IS_SP230_NIC() helper, and name the NIC type in that
  commit's subject as well. The merged commit carries the Cc: stable tag.
  The series is 28 patches from here on and the later numbering is one
  lower than in v7. The shared-mbuf rejection covers only the writes the
  software performs: TCP/UDP checksum, TSO and outer UDP checksum; the
  SCTP checksum is computed by the hardware and writes nothing back.
- 0006: drop the rte_atomic_thread_fence(); the cleared index is only
  consumed when the ring is re-armed and the RQ context is sent to the
  device at start, so no explicit barrier is required.
- 0007: drop the dead null check on the secondary process path.
- 0010: reject a queue count that does not fit in the MSI-X vector table,
  on both the intr_conf.rxq and the SP230 RQ-context paths, and document
  the new -EINVAL.
- 0014: stop printing the unused mbox slots in the debug dump.
- 0016: restore admin_down when dev_set_link_up() fails, as
  dev_set_link_down() already does.
- 0019: spell out in the commit message that the TCAM does not support
  VLAN matching, so the vlan_flag mask/value pairs were meaningless and are
  removed, and a rule now hits tagged and untagged packets alike.
- 0021/0022: turn the Runtime Configuration section into a definition
  list, with the compact-CQE switch documented in the compact CQE patch.
- 0022: when an application asks for the separate Rx mode on a NIC that
  reports the SW compact CQE bit, clear that bit as well, so the Rx
  burst, the RQ context, the CEQ attributes and the vport flag agree.
  The HW compact CQE bit is never cleared, and nothing is cleared when
  the compact mode is requested.
- 0022: clear the compact CQE info before each packet, so the LRO, VLAN
  and data-offset fields of a previous 16-byte CQE cannot leak into the
  next packet.
- 0024: reword the copy pool comment: the 256 mbufs per queue cap is
  deliberate, and a burst stops at the packet that cannot be copied.
- 0025: rename the Tx compact-task helpers from *_compact_cqe to
  *_compact_task, report "compact task" in the burst mode string, drop
  the dead !sq_wqe branch, and document that the scalar path no longer
  sets TCPUDP_CS.

Changes in v7:
- 0008: treat a missing FDIR rule as a successful no-op instead of
  returning -EINVAL, and gate the RQ enable command on NIC_F_HTN_FDIR so
  the HTN-only command is not sent to STN devices.
- 0011: when the application does not request Rx interrupts
  (intr_conf.rxq == 0), name the queue vector in the SP230 RQ context and
  leave that vector disabled, so no interrupt is reported while Rx keeps
  polling the descriptor ring. No event fds, intr_vec or MSI-X attribute
  commands are used on this path. Backends without per-vector support
  (igb_uio, uio_pci_generic) keep the previous behaviour and are left
  untouched.
- 0012: move the Fixes: tags back to the trailer block.
- 0016: use the 12-character commit hash in Fixes:.
- 0017: set admin_down before disabling the vport, and clear it again if
  the disable fails, so a link-up event cannot re-enable the vport in
  between. dev_start() also skips enabling the vport while admin_down is
  set.
- 0019: derive the cached per-queue RSS enablement from rss_state and
  rss_type.val, refresh it from hinic3_rss_hash_update(), and access it
  with relaxed atomics, because the control path writes it while the Rx
  data path reads it. Include rte_stdatomic.h explicitly instead of
  relying on another header to pull it in.
- 0022: treat a device argument list that is present but empty as no
  arguments instead of parsing a NULL string.
- 0023: use the existing rx_free_mbuf_bytes counter in the new htn Rx
  path instead of a non-existent field name.
- 0024: record the expected queue depth only after the queue has been set
  up successfully, so a failed setup does not leave a depth behind that
  the next attempt has to match, and check every configured queue at the
  top of dev_start(), before the Rx interrupt setup dereferences them.
- 0026: stop the Tx burst at the first packet that cannot be enqueued and
  keep that mbuf owned by the application, so the returned count stays a
  consumed prefix as rte_eth_tx_burst() requires. The per-burst packet
  counter that was only ever equal to the loop index is gone, so the
  statistics use the returned count directly.

The series builds with -Dwerror=true.

Jiacheng Ye (30):
  net/hinic3: fix SP230 VF PCI device ID
  net/hinic3: fix double removal in ethertype flow destroy
  net/hinic3: fix TCAM index leak on ethertype flow set
  net/hinic3: fix VXLAN VNI spec and mask write
  net/hinic3: fix wildcard IPv4, ICMP and UDP flow items
  net/hinic3: fix vport enable null dereference
  net/hinic3: clear stale Rx hardware CI on queue reset
  net/hinic3: attach ethdev and set ops in secondary process
  net/hinic3: return success when no FDIR rule to update
  net/hinic3: gate RQ enable on HTN FDIR
  net/hinic3: fix pseudo-header checksum and identify NIC type
  net/hinic3: add SP230 Rx queue interrupt handling
  net/hinic3: fix offload and cmdq/compact CQE config
  net/hinic3: add vport statistics and VF LAG support
  net/hinic3: add FEC mode get/set and capability support
  net/hinic3: add mbox message recording and debug dump
  net/hinic3: add COS mask and COS map support
  net/hinic3: add VF link state and promiscuous support
  net/hinic3: convert cmdq ops to static global variables
  net/hinic3: update RSS hash type configuration
  net/hinic3: refactor flow rule parsing
  net/hinic3: add SP560 NIC type identification and handling
  net/hinic3: add device kvargs parameters support
  net/hinic3: add compact CQE Rx path and ptype table
  net/hinic3: ensure queue depth and state consistency
  net/hinic3: expand TSO from 127 to 255 segments
  net/hinic3: split Tx burst function for compact task support
  net/hinic3: add SP230 VF software statistics
  net/hinic3: add Tx burst mode get
  net/hinic3: expose Tx queue copied-mbuf statistics

 .mailmap                                      |    1 +
 doc/guides/nics/features/hinic3.ini           |    5 +-
 doc/guides/nics/hinic3.rst                    |   45 +-
 doc/guides/rel_notes/release_26_11.rst        |   19 +
 drivers/net/hinic3/base/hinic3_cmd.h          |    2 +
 drivers/net/hinic3/base/hinic3_csr.h          |    6 +-
 drivers/net/hinic3/base/hinic3_eqs.c          |   64 +-
 drivers/net/hinic3/base/hinic3_eqs.h          |    9 +-
 drivers/net/hinic3/base/hinic3_hw_cfg.c       |    2 +
 drivers/net/hinic3/base/hinic3_hw_cfg.h       |    8 +-
 drivers/net/hinic3/base/hinic3_hw_comm.c      |    9 +-
 drivers/net/hinic3/base/hinic3_hwdev.h        |    3 +-
 drivers/net/hinic3/base/hinic3_hwif.c         |    4 +-
 drivers/net/hinic3/base/hinic3_mbox.c         |   45 +
 drivers/net/hinic3/base/hinic3_mbox.h         |   19 +
 drivers/net/hinic3/base/hinic3_nic_cfg.c      |  203 +++-
 drivers/net/hinic3/base/hinic3_nic_cfg.h      |  105 +-
 drivers/net/hinic3/base/hinic3_nic_event.c    |   72 +-
 drivers/net/hinic3/hinic3_ethdev.c            | 1017 ++++++++++++++--
 drivers/net/hinic3/hinic3_ethdev.h            |   58 +-
 drivers/net/hinic3/hinic3_fdir.c              |   53 +-
 drivers/net/hinic3/hinic3_fdir.h              |    8 +-
 drivers/net/hinic3/hinic3_flow.c              |  633 +++++++---
 drivers/net/hinic3/hinic3_flow.h              |  196 ---
 drivers/net/hinic3/hinic3_nic_io.c            |  157 +--
 drivers/net/hinic3/hinic3_nic_io.h            |   98 ++
 drivers/net/hinic3/hinic3_rx.c                |  672 +++++++++--
 drivers/net/hinic3/hinic3_rx.h                |  214 ++--
 drivers/net/hinic3/hinic3_tx.c                | 1068 +++++++++++++----
 drivers/net/hinic3/hinic3_tx.h                |   63 +-
 .../net/hinic3/htn_adapt/hinic3_htn_cmdq.c    |   65 +-
 .../net/hinic3/htn_adapt/hinic3_htn_cmdq.h    |    6 +-
 .../net/hinic3/stn_adapt/hinic3_stn_cmdq.c    |   76 +-
 .../net/hinic3/stn_adapt/hinic3_stn_cmdq.h    |    6 +-
 34 files changed, 3817 insertions(+), 1194 deletions(-)
 delete mode 100644 drivers/net/hinic3/hinic3_flow.h

-- 
2.33.0


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH v9 01/30] net/hinic3: fix SP230 VF PCI device ID
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
@ 2026-11-25 17:03 ` Jiacheng Ye
  2026-11-25 17:03 ` [PATCH v9 02/30] net/hinic3: fix double removal in ethertype flow destroy Jiacheng Ye
                   ` (29 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:03 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Firmware changed the SP230 VF device ID to 0x022a. Sync the driver
table to avoid probe failure with the old 0x3750 value.

Add the author to .mailmap.

Fixes: 8843a7a6bca5 ("net/hinic3: support new SPx series NIC")

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 .mailmap                             | 1 +
 drivers/net/hinic3/base/hinic3_csr.h | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/.mailmap b/.mailmap
index a0096fb97a..260cfaf7ae 100644
--- a/.mailmap
+++ b/.mailmap
@@ -765,6 +765,7 @@ Jesse Bruni <jesse.bruni@intel.com>
 Jia He <justin.he@arm.com> <jia.he@hxt-semitech.com>
 Jia Jia <physicalmtea@gmail.com>
 Jia Yu <jyu@vmware.com>
+Jiacheng Ye <yejiacheng4@h-partners.com>
 Jian Wang <jianwang@trustnetic.com>
 Jianbo Liu <jianbo.liu@arm.com> <jianbo.liu@linaro.org>
 Jianfeng Tan <jianfeng.tan@intel.com>
diff --git a/drivers/net/hinic3/base/hinic3_csr.h b/drivers/net/hinic3/base/hinic3_csr.h
index eceb34e9fd..7cae2419c0 100644
--- a/drivers/net/hinic3/base/hinic3_csr.h
+++ b/drivers/net/hinic3/base/hinic3_csr.h
@@ -11,7 +11,7 @@
 #define HINIC3_DEV_ID_VF_SP620	0x375F
 
 #define HINIC3_DEV_ID_SP230	0x0229
-#define HINIC3_DEV_ID_VF_SP230	0x3750
+#define HINIC3_DEV_ID_VF_SP230	0x022a
 
 #define HINIC3_DEV_ID_SP920	0x0224
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 02/30] net/hinic3: fix double removal in ethertype flow destroy
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
  2026-11-25 17:03 ` [PATCH v9 01/30] net/hinic3: fix SP230 VF PCI device ID Jiacheng Ye
@ 2026-11-25 17:03 ` Jiacheng Ye
  2026-11-25 17:03 ` [PATCH v9 03/30] net/hinic3: fix TCAM index leak on ethertype flow set Jiacheng Ye
                   ` (28 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:03 UTC (permalink / raw)
  To: dev
  Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger,
	stable

The ethertype destroy path removes the same flow node from
filter_ethertype_list twice, corrupting the tailq and leading to
use-after-free. Drop the redundant removal.

Fixes: efa3b9b36fc7 ("net/hinic3: add flow control and filters")
Cc: stable@dpdk.org

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_flow.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/hinic3/hinic3_flow.c b/drivers/net/hinic3/hinic3_flow.c
index 5c255619e3..453b4369b3 100644
--- a/drivers/net/hinic3/hinic3_flow.c
+++ b/drivers/net/hinic3/hinic3_flow.c
@@ -1332,10 +1332,6 @@ hinic3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
 			&rules->ethertype_filter, false);
 		if (!ret)
 			TAILQ_REMOVE(&nic_dev->filter_ethertype_list, flow, node);
-
-		flow->rule = rules;
-		flow->filter_type = rules->filter_type;
-		TAILQ_REMOVE(&nic_dev->filter_ethertype_list, flow, node);
 		break;
 
 	case RTE_ETH_FILTER_FDIR:
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 03/30] net/hinic3: fix TCAM index leak on ethertype flow set
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
  2026-11-25 17:03 ` [PATCH v9 01/30] net/hinic3: fix SP230 VF PCI device ID Jiacheng Ye
  2026-11-25 17:03 ` [PATCH v9 02/30] net/hinic3: fix double removal in ethertype flow destroy Jiacheng Ye
@ 2026-11-25 17:03 ` Jiacheng Ye
  2026-11-25 17:03 ` [PATCH v9 04/30] net/hinic3: fix VXLAN VNI spec and mask write Jiacheng Ye
                   ` (27 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:03 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

When adding an ethertype filter on an HTN NIC, a TCAM index is allocated
before the firmware command is sent. If the command fails, the index is
never freed, leaking a dynamic TCAM slot and eventually exhausting the
dynamic TCAM pool. Free the index on the error path.

Fixes: b2d4933b80ec ("net/hinic3: support htn FDIR for new SPx series NIC")

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_fdir.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/hinic3/hinic3_fdir.c b/drivers/net/hinic3/hinic3_fdir.c
index 71d50a3d22..95ce7cfe16 100644
--- a/drivers/net/hinic3/hinic3_fdir.c
+++ b/drivers/net/hinic3/hinic3_fdir.c
@@ -1001,6 +1001,9 @@ hinic3_set_fdir_ethertype_filter(void *hwdev, uint8_t pkt_type, void *filter, ui
 		PMD_DRV_LOG(ERR,
 			    "set fdir ethertype rule failed, err: %d, status: 0x%x, out size: 0x%x, func_id %d",
 			    err, ethertype_cmd.head.status, out_size, ethertype_cmd.func_id);
+		if ((hinic3_get_driver_feature(nic_dev) & NIC_F_HTN_FDIR) != 0 && en != 0)
+			hinic3_tcam_index_free(nic_dev, HINIC3_TCAM_GET_INDEX_IN_BLOCK(index),
+				HINIC3_TCAM_GET_DYNAMIC_BLOCK_INDEX(index));
 		return -EIO;
 	}
 	if ((hinic3_get_driver_feature(nic_dev) & NIC_F_HTN_FDIR) != 0) {
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 04/30] net/hinic3: fix VXLAN VNI spec and mask write
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (2 preceding siblings ...)
  2026-11-25 17:03 ` [PATCH v9 03/30] net/hinic3: fix TCAM index leak on ethertype flow set Jiacheng Ye
@ 2026-11-25 17:03 ` Jiacheng Ye
  2026-11-25 17:03 ` [PATCH v9 05/30] net/hinic3: fix wildcard IPv4, ICMP and UDP flow items Jiacheng Ye
                   ` (26 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:03 UTC (permalink / raw)
  To: dev
  Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger,
	stable

The VXLAN parser writes the flow item spec into key_mask and never
populates the mask, so VNI matches against a wrong value. Store the spec
into key_spec and the mask into key_mask.

Fixes: efa3b9b36fc7 ("net/hinic3: add flow control and filters")
Cc: stable@dpdk.org

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_flow.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hinic3/hinic3_flow.c b/drivers/net/hinic3/hinic3_flow.c
index 453b4369b3..1f686d4675 100644
--- a/drivers/net/hinic3/hinic3_flow.c
+++ b/drivers/net/hinic3/hinic3_flow.c
@@ -967,6 +967,7 @@ hinic3_flow_fdir_vxlan(struct rte_flow_error *error,
 {
 	const struct rte_flow_item_vxlan *spec_vxlan, *mask_vxlan;
 	uint32_t vxlan_vni_id = 0;
+	uint32_t vxlan_vni_id_mask = 0;
 
 	spec_vxlan = (const struct rte_flow_item_vxlan *)flow_item->spec;
 	mask_vxlan = (const struct rte_flow_item_vxlan *)flow_item->mask;
@@ -990,8 +991,11 @@ hinic3_flow_fdir_vxlan(struct rte_flow_error *error,
 	}
 
 	memcpy(((uint8_t *)&vxlan_vni_id + 1), spec_vxlan->vni, 3);
-	filter->fdir_filter.key_mask.tunnel.tunnel_id =
+	filter->fdir_filter.key_spec.tunnel.tunnel_id =
 		rte_be_to_cpu_32(vxlan_vni_id);
+	memcpy(((uint8_t *)&vxlan_vni_id_mask + 1), mask_vxlan->vni, 3);
+	filter->fdir_filter.key_mask.tunnel.tunnel_id =
+		rte_be_to_cpu_32(vxlan_vni_id_mask);
 	return 0;
 }
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 05/30] net/hinic3: fix wildcard IPv4, ICMP and UDP flow items
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (3 preceding siblings ...)
  2026-11-25 17:03 ` [PATCH v9 04/30] net/hinic3: fix VXLAN VNI spec and mask write Jiacheng Ye
@ 2026-11-25 17:03 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 06/30] net/hinic3: fix vport enable null dereference Jiacheng Ye
                   ` (25 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:03 UTC (permalink / raw)
  To: dev
  Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger,
	stable

Accept a wildcard IPv4 item, such as eth / ipv4 / udp, that has neither
a spec nor a mask, so the L4 item alone constrains the rule. The fdir
parser required both fields and rejected such a rule with -EINVAL.

The ICMP item was not translated, so an ICMP rule with an IPv4 spec or
mask matched every IPv4 packet that passed the IPv4 fields, and with the
wildcard above it would also match when the IPv4 item is empty.
Translate the ICMP item into the IPv4 protocol key, as the TCP and UDP
items already are, and reject a mask that selects fields the TCAM cannot
match: the ICMP type, code, checksum, identifier or sequence number, and
the UDP length or checksum. The TCP item already rejects its unsupported
fields; the ICMP and UDP items silently ignored them.

Fixes: efa3b9b36fc7 ("net/hinic3: add flow control and filters")
Cc: stable@dpdk.org

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_flow.c | 60 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 58 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hinic3/hinic3_flow.c b/drivers/net/hinic3/hinic3_flow.c
index 1f686d4675..3fbed5497b 100644
--- a/drivers/net/hinic3/hinic3_flow.c
+++ b/drivers/net/hinic3/hinic3_flow.c
@@ -230,6 +230,14 @@ hinic3_flow_fdir_ipv4(const struct rte_flow_item *flow_item,
 
 	mask_ipv4 = (const struct rte_flow_item_ipv4 *)flow_item->mask;
 	spec_ipv4 = (const struct rte_flow_item_ipv4 *)flow_item->spec;
+
+	filter->fdir_filter.ip_type = HINIC3_FDIR_IP_TYPE_IPV4;
+	filter->fdir_filter.tunnel_type = HINIC3_FDIR_TUNNEL_MODE_NORMAL;
+
+	/* A wildcard IPv4 item leaves the L4 item in charge of the rule. */
+	if (!mask_ipv4 && !spec_ipv4)
+		return 0;
+
 	if (!mask_ipv4 || !spec_ipv4) {
 		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
 				   flow_item,
@@ -252,8 +260,6 @@ hinic3_flow_fdir_ipv4(const struct rte_flow_item *flow_item,
 	}
 
 	/* Set the filter information. */
-	filter->fdir_filter.ip_type = HINIC3_FDIR_IP_TYPE_IPV4;
-	filter->fdir_filter.tunnel_type = HINIC3_FDIR_TUNNEL_MODE_NORMAL;
 	filter->fdir_filter.key_mask.ipv4.src_ip =
 		rte_be_to_cpu_32(mask_ipv4->hdr.src_addr);
 	filter->fdir_filter.key_spec.ipv4.src_ip =
@@ -381,3 +387,11 @@ hinic3_flow_fdir_udp(const struct rte_flow_item *flow_item,
 	}
 
+	/* Only support src, dst ports, others should be masked. */
+	if (mask_udp->hdr.dgram_len || mask_udp->hdr.dgram_cksum) {
+		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
+				   flow_item,
+				   "Not supported by fdir filter, udp only support src port, dst port");
+		return -rte_errno;
+	}
+
 	/* Set the filter information. */
@@ -393,6 +407,42 @@ hinic3_flow_fdir_udp(const struct rte_flow_item *flow_item,
 	return 0;
 }
 
+static int
+hinic3_flow_fdir_icmp(const struct rte_flow_item *flow_item,
+		      struct hinic3_filter_t *filter,
+		      struct rte_flow_error *error)
+{
+	const struct rte_flow_item_icmp *spec_icmp, *mask_icmp;
+
+	mask_icmp = (const struct rte_flow_item_icmp *)flow_item->mask;
+	spec_icmp = (const struct rte_flow_item_icmp *)flow_item->spec;
+
+	filter->fdir_filter.key_mask.proto = HINIC3_UINT8_MAX;
+	filter->fdir_filter.key_spec.proto = IPPROTO_ICMP;
+
+	if (!mask_icmp && !spec_icmp)
+		return 0;
+
+	if (!mask_icmp || !spec_icmp) {
+		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
+				   flow_item,
+				   "Invalid fdir filter icmp mask or spec");
+		return -rte_errno;
+	}
+
+	/* Only the protocol number can be matched, others should be masked. */
+	if (mask_icmp->hdr.icmp_type || mask_icmp->hdr.icmp_code ||
+	    mask_icmp->hdr.icmp_cksum || mask_icmp->hdr.icmp_ident ||
+	    mask_icmp->hdr.icmp_seq_nb) {
+		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
+				   flow_item,
+				   "Not supported by fdir filter, icmp only support protocol number");
+		return -rte_errno;
+	}
+
+	return 0;
+}
+
 /**
  * Parse the pattern of network traffic and apply the parsing result to the
  * traffic filter.
@@ -464,6 +514,12 @@ hinic3_flow_parse_fdir_pattern(__rte_unused struct rte_eth_dev *dev,
 				return -rte_errno;
 			break;
 
+		case RTE_FLOW_ITEM_TYPE_ICMP:
+			err = hinic3_flow_fdir_icmp(flow_item, filter, error);
+			if (err)
+				return -rte_errno;
+			break;
+
 		default:
 			break;
 		}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 06/30] net/hinic3: fix vport enable null dereference
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (4 preceding siblings ...)
  2026-11-25 17:03 ` [PATCH v9 05/30] net/hinic3: fix wildcard IPv4, ICMP and UDP flow items Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 07/30] net/hinic3: clear stale Rx hardware CI on queue reset Jiacheng Ye
                   ` (24 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

hinic3_set_vport_enable() dereferences hwdev->dev_handle in the
declaration block, before checking hwdev. Move the dereference below the
hwdev check so a NULL hwdev returns an error instead of crashing during
early PF initialization.

Fixes: 9204b6b7bb1a ("net/hinic3: split new/old command queue operations")

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/base/hinic3_nic_cfg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.c b/drivers/net/hinic3/base/hinic3_nic_cfg.c
index 5387626b98..1520f88a1b 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.c
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.c
@@ -443,12 +443,13 @@ int
 hinic3_set_vport_enable(struct hinic3_hwdev *hwdev, bool enable)
 {
 	struct hinic3_vport_state en_state;
-	struct hinic3_nic_dev *nic_dev = hwdev->dev_handle;
+	struct hinic3_nic_dev *nic_dev;
 	uint16_t out_size = sizeof(en_state);
 	int err;
 
 	if (!hwdev)
 		return -EINVAL;
+	nic_dev = hwdev->dev_handle;
 
 	memset(&en_state, 0, sizeof(en_state));
 	en_state.func_id = hinic3_global_func_id(hwdev);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 07/30] net/hinic3: clear stale Rx hardware CI on queue reset
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (5 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 06/30] net/hinic3: fix vport enable null dereference Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 08/30] net/hinic3: attach ethdev and set ops in secondary process Jiacheng Ye
                   ` (23 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

In compact CQE mode the driver relies on the hardware CI written back by
the NIC to decide whether a completion is pending. The hardware does not
clear that write-back memory on reset, so after a port stop/start the
stale value left by the previous session makes the driver take the whole
ring as completed and report q_depth packets that were never received
when the next packet arrives.

Clear the CI write-back memory in hinic3_reset_rx_queue() so the ring is
re-armed with a fresh CI.

Fixes: c1537bf6c033 ("net/hinic3: support Compact CQE in init")

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_ethdev.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index eb5ddd9de6..d9821d1c9f 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -884,6 +884,14 @@ hinic3_reset_rx_queue(struct rte_eth_dev *dev)
 		rxq->prod_idx = 0;
 		rxq->delta = rxq->q_depth;
 		rxq->next_to_update = 0;
+
+		/*
+		 * Hardware does not clear the CI write-back memory on reset, so
+		 * the stale hw_ci must be cleared as well, otherwise the driver
+		 * may treat queued mbufs as completed after restart.
+		 */
+		if (rxq->rq_ci != NULL)
+			memset(rxq->rq_ci, 0, sizeof(*rxq->rq_ci));
 	}
 }
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 08/30] net/hinic3: attach ethdev and set ops in secondary process
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (6 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 07/30] net/hinic3: clear stale Rx hardware CI on queue reset Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 09/30] net/hinic3: return success when no FDIR rule to update Jiacheng Ye
                   ` (22 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev
  Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger,
	stable

The secondary process probe path returns early without attaching the
already-created ethdev or assigning its dev_ops, leaving the device
unusable in secondary processes. Attach the ethdev and set the matching
PF/VF ops.

Fixes: 468368457681 ("net/hinic3: add device initialization")
Cc: stable@dpdk.org

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_ethdev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index d9821d1c9f..aaae6f4364 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -2135,6 +2135,9 @@ hinic3_dev_close(struct rte_eth_dev *eth_dev)
 		HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
 	int ret;
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
 	if (hinic3_test_and_set_bit(HINIC3_DEV_CLOSE, &nic_dev->dev_status)) {
 		PMD_DRV_LOG(WARNING, "Device %s already closed",
 			    nic_dev->dev_name);
@@ -3408,6 +3411,13 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 		PMD_DRV_LOG(INFO, "Initialize %s in secondary process",
 			    eth_dev->data->name);
 
+		nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
+
+		if (HINIC3_FUNC_TYPE(nic_dev->hwdev) == TYPE_VF)
+			eth_dev->dev_ops = &hinic3_pmd_vf_ops;
+		else
+			eth_dev->dev_ops = &hinic3_pmd_ops;
+
 		return 0;
 	}
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 09/30] net/hinic3: return success when no FDIR rule to update
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (7 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 08/30] net/hinic3: attach ethdev and set ops in secondary process Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 10/30] net/hinic3: gate RQ enable on HTN FDIR Jiacheng Ye
                   ` (21 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev
  Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger,
	stable

hinic3_enable_rxq_fdir_filter() fails when the queue has no TCAM rule.
rx_queue_start() and rx_queue_stop() propagate this error as fatal, so
such a queue cannot be started or stopped. There is nothing to update in
that case; return success.

The no-rule path originally returned an uninitialized value; then
commit b247199927a1 ("net/hinic3: fix return value of FDIR enabling")
set it to -EINVAL, which still makes the callers fail.

Fixes: efa3b9b36fc7 ("net/hinic3: add flow control and filters")
Fixes: b247199927a1 ("net/hinic3: fix return value of FDIR enabling")
Cc: stable@dpdk.org
Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_fdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hinic3/hinic3_fdir.c b/drivers/net/hinic3/hinic3_fdir.c
index 95ce7cfe16..f3a570b358 100644
--- a/drivers/net/hinic3/hinic3_fdir.c
+++ b/drivers/net/hinic3/hinic3_fdir.c
@@ -1278,7 +1278,7 @@ hinic3_enable_rxq_fdir_filter(struct rte_eth_dev *dev, uint32_t queue_id, uint32
 	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 	struct hinic3_tcam_filter *it;
 	struct hinic3_tcam_cfg_rule fdir_tcam_rule;
-	int ret = -EINVAL;
+	int ret = 0;
 	uint32_t queue_res;
 	uint16_t index;
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 10/30] net/hinic3: gate RQ enable on HTN FDIR
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (8 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 09/30] net/hinic3: return success when no FDIR rule to update Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 11/30] net/hinic3: fix pseudo-header checksum and identify NIC type Jiacheng Ye
                   ` (20 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

hinic3_start_rq() checks NIC_F_FDIR, but hinic3_set_rq_enable() sends
the HTN-only SET_RQ_ENABLE command. An STN device rejects that command.
Use NIC_F_HTN_FDIR, as the stop path already does.

Fixes: b20dc78b286a ("net/hinic3: support Compact CQE in Rx")
Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hinic3/hinic3_rx.c b/drivers/net/hinic3/hinic3_rx.c
index ed753ba4ec..90681ce15c 100644
--- a/drivers/net/hinic3/hinic3_rx.c
+++ b/drivers/net/hinic3/hinic3_rx.c
@@ -784,7 +784,7 @@ hinic3_start_rq(struct rte_eth_dev *eth_dev, struct hinic3_rxq *rxq)
 	hinic3_add_rq_to_rx_queue_list(nic_dev, rxq->q_id);
 
 	if (nic_dev->rss_state == HINIC3_RSS_ENABLE) {
-		if ((hinic3_get_driver_feature(nic_dev) & NIC_F_FDIR) != 0)
+		if ((hinic3_get_driver_feature(nic_dev) & NIC_F_HTN_FDIR) != 0)
 			err = hinic3_set_rq_enable(nic_dev, rxq->q_id, true);
 		if (err) {
 			PMD_DRV_LOG(ERR, "Flush rq failed, eth_dev:%s, queue_idx:%d",
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 11/30] net/hinic3: fix pseudo-header checksum and identify NIC type
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (9 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 10/30] net/hinic3: gate RQ enable on HTN FDIR Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 12/30] net/hinic3: add SP230 Rx queue interrupt handling Jiacheng Ye
                   ` (19 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev
  Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger,
	stable

SP620 expects the driver to precompute the L4 pseudo-header checksum for
TCP/UDP checksum and TSO offload; without it the hardware writes a wrong
checksum. Compute the inner and outer pseudo-header checksums in the Tx
prepare callback, with the L4 protocol derived from the offload flags.

The checksum is written back into the packet headers, so reject a shared
or indirect mbuf only when the offload modifies the packet: TCP/UDP
checksum, TSO and outer UDP checksum. The SCTP checksum is computed by
the hardware and writes nothing back. Reject a packet whose headers do
not fit in the first segment.

The SP230 derives the inner checksums and TSO headers in hardware and must
not have them written back, so the prepare step needs to know the NIC
model. Identify it from the PCI device ID at initialization and keep it in
the NIC private data, and run the software pseudo-header writes only for
the other models.

Fixes: 7608f0367d5a ("net/hinic3: add basic ethdev operations")
Cc: stable@dpdk.org

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_ethdev.c |  18 +++
 drivers/net/hinic3/hinic3_ethdev.h |  11 ++
 drivers/net/hinic3/hinic3_tx.c     | 220 ++++++++++++++++++++++++++---
 drivers/net/hinic3/hinic3_tx.h     |   1 +
 4 files changed, 234 insertions(+), 16 deletions(-)

diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index aaae6f4364..e74dfa22da 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -482,6 +482,22 @@ hinic3_init_default_cos(struct hinic3_nic_dev *nic_dev)
 	return 0;
 }
 
+static enum nic_type
+hinic3_get_nic_type(struct rte_pci_device *pci_dev)
+{
+	switch (pci_dev->id.device_id) {
+	case HINIC3_DEV_ID_SP620:
+	case HINIC3_DEV_ID_VF_SP620:
+	case HINIC3_DEV_ID_SP920: /* SP920 is the DPU card of SP620. */
+		return NIC_SP620;
+	case HINIC3_DEV_ID_SP230:
+	case HINIC3_DEV_ID_VF_SP230:
+		return NIC_SP230;
+	default:
+		return NIC_UNKNOWN;
+	}
+}
+
 /**
  * Initialize Class of Service (CoS). For PF devices, it also sync the link
  * status with the physical port.
@@ -3423,6 +3439,7 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 
 	nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
 	memset(nic_dev, 0, sizeof(*nic_dev));
+	nic_dev->nic_type = hinic3_get_nic_type(pci_dev);
 	snprintf(nic_dev->dev_name, sizeof(nic_dev->dev_name),
 		"dbdf-%.4x:%.2x:%.2x.%x", pci_dev->addr.domain,
 		pci_dev->addr.bus, pci_dev->addr.devid,
@@ -3646,6 +3663,7 @@ hinic3_dev_init(struct rte_eth_dev *eth_dev)
 
 	eth_dev->rx_pkt_burst = hinic3_recv_pkts;
 	eth_dev->tx_pkt_burst = hinic3_xmit_pkts;
+	eth_dev->tx_pkt_prepare = hinic3_prep_pkts;
 
 	return hinic3_func_init(eth_dev);
 }
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index 9061e2b217..8bbab2ad53 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -41,6 +41,7 @@
 #define HINIC3_PKT_TX_OUTER_IP_CKSUM	RTE_MBUF_F_TX_OUTER_IP_CKSUM
 #define HINIC3_PKT_TX_OUTER_UDP_CKSUM	RTE_MBUF_F_TX_OUTER_UDP_CKSUM
 #define HINIC3_PKT_TX_OUTER_IPV6	RTE_MBUF_F_TX_OUTER_IPV6
+#define HINIC3_PKT_TX_OUTER_IPV4	RTE_MBUF_F_TX_OUTER_IPV4
 #define HINIC3_PKT_RX_LRO		RTE_MBUF_F_RX_LRO
 #define HINIC3_PKT_TX_L4_NO_CKSUM	RTE_MBUF_F_TX_L4_NO_CKSUM
 
@@ -106,6 +107,12 @@ enum nic_feature_cap {
 TAILQ_HEAD(hinic3_ethertype_filter_list, rte_flow);
 TAILQ_HEAD(hinic3_fdir_rule_filter_list, rte_flow);
 
+enum nic_type {
+	NIC_SP620 = 0,
+	NIC_SP230 = 1,
+	NIC_UNKNOWN = 2,
+};
+
 struct hinic3_nic_dev {
 	struct hinic3_hwdev *hwdev; /**< Hardware device. */
 	struct hinic3_txq **txqs;
@@ -152,9 +159,13 @@ struct hinic3_nic_dev {
 	struct hinic3_nic_cmdq_ops *cmdq_ops;
 	struct hinic3_nic_rx_ops *rx_ops;
 	struct hinic3_nic_tx_ops *tx_ops;
+	enum nic_type nic_type; /**< NIC type. */
 
 };
 
+#define HINIC3_IS_SP620_NIC(nic_dev) ((nic_dev)->nic_type == NIC_SP620)
+#define HINIC3_IS_SP230_NIC(nic_dev) ((nic_dev)->nic_type == NIC_SP230)
+
 extern const struct rte_flow_ops hinic3_flow_ops;
 
 /**
diff --git a/drivers/net/hinic3/hinic3_tx.c b/drivers/net/hinic3/hinic3_tx.c
index 6b2bffb14e..0555fd3393 100644
--- a/drivers/net/hinic3/hinic3_tx.c
+++ b/drivers/net/hinic3/hinic3_tx.c
@@ -285,6 +285,28 @@ hinic3_tx_done_cleanup(void *txq, uint32_t free_cnt)
 	return hinic3_xmit_mbuf_cleanup(tx_queue, try_free_cnt);
 }
 
+static uint16_t
+hinic3_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint16_t l3_len,
+		       uint8_t proto, uint64_t ol_flags)
+{
+	uint32_t sum;
+	rte_be32_t l4_len;
+	rte_be32_t l4_proto;
+
+	l4_proto = rte_cpu_to_be_32(proto);
+	if (ol_flags & HINIC3_PKT_TX_TCP_SEG)
+		l4_len = 0;
+	else
+		l4_len = rte_cpu_to_be_16(rte_be_to_cpu_16(ipv6_hdr->payload_len) -
+					  l3_len + sizeof(*ipv6_hdr));
+
+	sum = __rte_raw_cksum(ipv6_hdr->src_addr.a,
+			      sizeof(ipv6_hdr->src_addr.a) + sizeof(ipv6_hdr->dst_addr.a), 0);
+	sum = __rte_raw_cksum(&l4_len, sizeof(l4_len), sum);
+	sum = __rte_raw_cksum(&l4_proto, sizeof(l4_proto), sum);
+
+	return __rte_raw_cksum_reduce(sum);
+}
 /**
  * Prepare the data packet to be sent and calculate the internal L3 offset.
  *
@@ -297,19 +319,111 @@ hinic3_tx_done_cleanup(void *txq, uint32_t free_cnt)
  * @return
  * 0 as success, -EINVAL as failure.
  */
-static int
-hinic3_tx_offload_pkt_prepare(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *mbuf,
-			      uint16_t *inner_l3_offset)
+static inline uint16_t
+hinic3_calculate_l4_cksum(struct rte_mbuf *mbuf, uint16_t inner_l3_offset,
+			  uint16_t l3_len, uint8_t l4_proto)
+{
+	struct rte_ipv4_hdr *ipv4_hdr;
+	struct rte_ipv6_hdr *ipv6_hdr;
+	uint64_t ol_flags = mbuf->ol_flags;
+
+	if (ol_flags & HINIC3_PKT_TX_IPV4) {
+		ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *,
+						   inner_l3_offset);
+
+		if (ol_flags & HINIC3_PKT_TX_IP_CKSUM)
+			ipv4_hdr->hdr_checksum = 0;
+
+		return rte_ipv4_phdr_cksum(ipv4_hdr, ol_flags);
+	}
+
+	ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv6_hdr *,
+					   inner_l3_offset);
+
+	return hinic3_ipv6_phdr_cksum(ipv6_hdr, l3_len, l4_proto, ol_flags);
+}
+
+static inline void hinic3_calculate_outer_udp_checksum(struct rte_mbuf *mbuf,
+						       uint16_t outer_l3_offset)
+{
+	struct rte_ipv4_hdr *ipv4_hdr;
+	struct rte_ipv6_hdr *ipv6_hdr;
+	struct rte_udp_hdr *udp_hdr;
+	uint64_t ol_flags = mbuf->ol_flags;
+
+	if (ol_flags & HINIC3_PKT_TX_OUTER_IPV4) {
+		ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *, outer_l3_offset);
+		if (ol_flags & HINIC3_PKT_TX_OUTER_IP_CKSUM)
+			ipv4_hdr->hdr_checksum = 0;
+		udp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr + mbuf->outer_l3_len);
+		udp_hdr->dgram_cksum = rte_ipv4_phdr_cksum(ipv4_hdr, ol_flags);
+	} else if (ol_flags & HINIC3_PKT_TX_OUTER_IPV6) {
+		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv6_hdr *, outer_l3_offset);
+		udp_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_udp_hdr *,
+						  (outer_l3_offset + mbuf->outer_l3_len));
+		udp_hdr->dgram_cksum = hinic3_ipv6_phdr_cksum(ipv6_hdr, mbuf->outer_l3_len,
+							      IPPROTO_UDP, ol_flags);
+	}
+}
+
+static inline void hinic3_calculate_outer_phdr_checksum(struct rte_mbuf *mbuf,
+							uint16_t outer_l3_offset)
+{
+	uint64_t ol_flags = mbuf->ol_flags;
+
+	if (ol_flags & HINIC3_PKT_TX_OUTER_UDP_CKSUM)
+		hinic3_calculate_outer_udp_checksum(mbuf, outer_l3_offset);
+}
+
+static inline void hinic3_calculate_phdr_checksum(struct rte_mbuf *mbuf,
+						  uint16_t inner_l3_offset)
 {
 	uint64_t ol_flags = mbuf->ol_flags;
+	struct rte_tcp_hdr *tcp_hdr;
+	struct rte_udp_hdr *udp_hdr;
+	uint16_t l3_len = mbuf->l3_len;
+	uint16_t l4_offset;
+
+	l4_offset = inner_l3_offset + l3_len;
+
+	switch (ol_flags & HINIC3_PKT_TX_L4_MASK) {
+	case HINIC3_PKT_TX_UDP_CKSUM:
+		udp_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_udp_hdr *, l4_offset);
+		udp_hdr->dgram_cksum = hinic3_calculate_l4_cksum(mbuf, inner_l3_offset,
+								 l3_len, IPPROTO_UDP);
+		break;
+	case HINIC3_PKT_TX_TCP_CKSUM:
+		tcp_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_tcp_hdr *, l4_offset);
+		tcp_hdr->cksum = hinic3_calculate_l4_cksum(mbuf, inner_l3_offset,
+							   l3_len, IPPROTO_TCP);
+		break;
+	case HINIC3_PKT_TX_SCTP_CKSUM:
+		/* Sctp csum no need to calculate pseudo-header */
+		break;
+	default:
+		if (ol_flags & HINIC3_PKT_TX_TCP_SEG) {
+			tcp_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_tcp_hdr *, l4_offset);
+			tcp_hdr->cksum = hinic3_calculate_l4_cksum(mbuf, inner_l3_offset,
+								   l3_len, IPPROTO_TCP);
+		}
+		break;
+	}
+}
 
-	if ((ol_flags & HINIC3_PKT_TX_TUNNEL_MASK)) {
-		if (!(((ol_flags & HINIC3_PKT_TX_TUNNEL_VXLAN) &&
-				HINIC3_SUPPORT_VXLAN_OFFLOAD(nic_dev)) ||
-		      ((ol_flags & HINIC3_PKT_TX_TUNNEL_GENEVE) &&
-				HINIC3_SUPPORT_GENEVE_OFFLOAD(nic_dev)) ||
-		      ((ol_flags & HINIC3_PKT_TX_TUNNEL_IPIP) &&
-				HINIC3_SUPPORT_IPXIP_OFFLOAD(nic_dev))))
+static int
+hinic3_get_inner_l3_offset(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *mbuf,
+			   uint16_t *inner_l3_offset)
+{
+	uint64_t ol_flags = mbuf->ol_flags;
+	uint64_t tunnel_type = ol_flags & HINIC3_PKT_TX_TUNNEL_MASK;
+
+	if (tunnel_type) {
+		if (!((tunnel_type == HINIC3_PKT_TX_TUNNEL_VXLAN &&
+		       HINIC3_SUPPORT_VXLAN_OFFLOAD(nic_dev)) ||
+		      (tunnel_type == HINIC3_PKT_TX_TUNNEL_GENEVE &&
+		       HINIC3_SUPPORT_GENEVE_OFFLOAD(nic_dev)) ||
+		      (tunnel_type == HINIC3_PKT_TX_TUNNEL_IPIP &&
+		       HINIC3_SUPPORT_IPXIP_OFFLOAD(nic_dev))))
 			return -EINVAL;
 	}
 
@@ -318,13 +432,28 @@ hinic3_tx_offload_pkt_prepare(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *m
 		return -EINVAL;
 #endif
 	/* Support tunnel. */
-	if ((ol_flags & HINIC3_PKT_TX_TUNNEL_MASK)) {
-		if ((ol_flags & HINIC3_PKT_TX_OUTER_IP_CKSUM) ||
-		    (ol_flags & HINIC3_PKT_TX_OUTER_IPV6) ||
-		    (ol_flags & HINIC3_PKT_TX_TCP_SEG)) {
+	if (tunnel_type) {
+		/*
+		 * For IPv6-in-IPv6 packets, ol_flags cannot be used to determine
+		 * whether the delivered port offload value contains UDP and IP
+		 * hardware offload flags, so it is impossible to determine how
+		 * l2_len is populated. Here, the property that l2_len is 0 for
+		 * IP-in-IP is used to distinguish population modes. If
+		 * mbuf->l2_len == 0, the upper layer has enabled UDP and IP
+		 * hardware offload flags; the inner L3 offset is then
+		 * outer_l2_len + outer_l3_len.
+		 */
+		if (tunnel_type == HINIC3_PKT_TX_TUNNEL_IPIP) {
+			if (mbuf->l2_len == 0)
+				*inner_l3_offset = mbuf->outer_l2_len + mbuf->outer_l3_len;
+			else
+				*inner_l3_offset = mbuf->l2_len;
+		} else if ((ol_flags & HINIC3_PKT_TX_OUTER_IP_CKSUM) ||
+			   (ol_flags & HINIC3_PKT_TX_OUTER_UDP_CKSUM) ||
+			   (ol_flags & HINIC3_PKT_TX_TCP_SEG)) {
 			/*
 			 * For this senmatic, l2_len of mbuf means
-			 * len(out_udp + vxlan + in_eth).
+			 * len(out_udp + vxlan/geneve + in_eth).
 			 */
 			*inner_l3_offset = mbuf->l2_len + mbuf->outer_l2_len +
 					   mbuf->outer_l3_len;
@@ -343,6 +472,65 @@ hinic3_tx_offload_pkt_prepare(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *m
 	return 0;
 }
 
+
+uint16_t
+hinic3_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+{
+	struct hinic3_txq *txq = tx_queue;
+	struct hinic3_nic_dev *nic_dev = txq->nic_dev;
+	struct rte_mbuf *mbuf;
+	uint16_t inner_l3_offset;
+	int ret;
+	int i;
+
+	for (i = 0; i != nb_pkts; i++) {
+		mbuf = tx_pkts[i];
+
+		if (!(mbuf->ol_flags & HINIC3_TX_OFFLOAD_MASK))
+			continue;
+
+		ret = hinic3_get_inner_l3_offset(nic_dev, mbuf, &inner_l3_offset);
+		if (unlikely(ret)) {
+			rte_errno = -ret;
+			return i;
+		}
+
+		if (!HINIC3_IS_SP230_NIC(nic_dev)) {
+			/*
+			 * The pseudo-header checksum is written back into the
+			 * packet's L3/L4 header, which would corrupt data still
+			 * referenced by another consumer for a shared or indirect
+			 * mbuf, so fail those packets instead. Only TCP/UDP
+			 * checksum, TSO and outer UDP checksum write into the
+			 * packet; the SCTP checksum is left to the hardware.
+			 */
+			if (unlikely((mbuf->ol_flags &
+				      (HINIC3_PKT_TX_TCP_CKSUM |
+				       HINIC3_PKT_TX_UDP_CKSUM |
+				       HINIC3_PKT_TX_TCP_SEG |
+				       HINIC3_PKT_TX_OUTER_UDP_CKSUM)) &&
+				     (rte_mbuf_refcnt_read(mbuf) > 1 ||
+				      RTE_MBUF_CLONED(mbuf)))) {
+				rte_errno = EINVAL;
+				return i;
+			}
+
+			/* The headers must be contiguous in the first segment. */
+			if (unlikely(rte_pktmbuf_data_len(mbuf) <
+				     inner_l3_offset + mbuf->l3_len + mbuf->l4_len)) {
+				rte_errno = ENOTSUP;
+				return i;
+			}
+
+			/* Process the outer and inner pseudo-header checksums. */
+			hinic3_calculate_outer_phdr_checksum(mbuf, mbuf->outer_l2_len);
+			hinic3_calculate_phdr_checksum(mbuf, inner_l3_offset);
+		}
+	}
+
+	return i;
+}
+
 void
 hinic3_tx_set_normal_task_offload(struct hinic3_wqe_info *wqe_info,
 				  struct hinic3_sq_wqe_combo *wqe_combo)
@@ -622,7 +810,7 @@ hinic3_get_tx_offload(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *mbuf,
 	}
 
 	wqe_info->offload = 1;
-	err = hinic3_tx_offload_pkt_prepare(nic_dev, mbuf, &inner_l3_offset);
+	err = hinic3_get_inner_l3_offset(nic_dev, mbuf, &inner_l3_offset);
 	if (err)
 		return err;
 
diff --git a/drivers/net/hinic3/hinic3_tx.h b/drivers/net/hinic3/hinic3_tx.h
index e0ed9908ad..3b1580dd3a 100644
--- a/drivers/net/hinic3/hinic3_tx.h
+++ b/drivers/net/hinic3/hinic3_tx.h
@@ -394,6 +394,7 @@ void hinic3_flush_txqs(struct hinic3_nic_dev *nic_dev);
 void hinic3_free_txq_mbufs(struct hinic3_txq *txq);
 void hinic3_free_all_txq_mbufs(struct hinic3_nic_dev *nic_dev);
 uint16_t hinic3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
+uint16_t hinic3_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
 int hinic3_stop_sq(struct hinic3_txq *txq);
 int hinic3_start_all_sqs(struct rte_eth_dev *eth_dev);
 int hinic3_tx_done_cleanup(void *txq, uint32_t free_cnt);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 12/30] net/hinic3: add SP230 Rx queue interrupt handling
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (10 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 11/30] net/hinic3: fix pseudo-header checksum and identify NIC type Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 13/30] net/hinic3: fix offload and cmdq/compact CQE config Jiacheng Ye
                   ` (18 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

SP230 raises the aggregated Rx interrupt even when the application does
not request queue interrupts, and nothing acknowledges it. The HTN tile
has no microcode to mask it and its RQ context has no invalid-INTR
encoding, unlike the STN tile used by SP560.

The INTR field is a plain vector index, so 0 selects the AEQ vector and
every Rx queue raises there. With per-queue MSI-X vectors available,
program the queue vector and leave it disabled: Rx keeps polling and no
interrupt is delivered. hinic3_dev_rx_queue_intr_enable() returns 0 for
SP230 without touching the hardware, so an application that needs Rx
interrupts must set intr_conf.rxq at configure time.

If the queue count does not fit in the MSI-X vector table, fall back to
the old behaviour: leave dp_intr_en at 0 and keep polling, with a
warning. Only fail the configuration when the application explicitly
requested Rx interrupts.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_ethdev.c | 88 +++++++++++++++++++++++++++++---
 1 file changed, 82 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index e74dfa22da..432278a0f2 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -1503,6 +1503,9 @@ hinic3_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
 	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 	uint16_t msix_intr;
 
+	if (HINIC3_IS_SP230_NIC(nic_dev) && !dev->data->dev_conf.intr_conf.rxq)
+		return 0;
+
 	if (!rte_intr_dp_is_en(intr_handle) || !intr_handle->intr_vec)
 		return 0;
 
@@ -1765,11 +1768,8 @@ hinic3_init_rxq_msix_attr(void *hwdev, uint16_t msix_index)
 	info.resend_timer_cfg = HINIC3_TXRX_MSIX_RESEND_TIMER_CFG;
 	info.msix_index = msix_index;
 	err = hinic3_set_interrupt_cfg(hwdev, info);
-	if (err) {
-		PMD_DRV_LOG(ERR, "Set msix attr failed, msix_index %d",
-			    msix_index);
+	if (err)
 		return -EFAULT;
-	}
 
 	return 0;
 }
@@ -1786,6 +1786,47 @@ hinic3_deinit_rxq_intr(struct rte_eth_dev *dev)
 	}
 }
 
+/**
+ * Check that the Rx queue vectors fit in the device MSI-X vector table.
+ *
+ * @param[in] dev
+ * Pointer to ethernet device structure.
+ * @param[in] nb_rx_queues
+ * Number of Rx queues to be given a vector.
+ * @param[in] required
+ * Whether the vectors are required (application requested Rx interrupts).
+ *
+ * @return
+ * 0 if the configuration fits, -EINVAL otherwise.
+ */
+static int
+hinic3_check_rxq_intr_vec(struct rte_eth_dev *dev, uint32_t nb_rx_queues,
+			  bool required)
+{
+	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+	uint16_t num_irqs = HINIC3_HWIF_NUM_IRQS(nic_dev->hwdev->hwif);
+	uint32_t last_vec;
+
+	if (nb_rx_queues == 0)
+		return 0;
+
+	last_vec = (uint32_t)HINIC3_RX_VEC_START + nb_rx_queues - 1;
+	if (last_vec >= (uint32_t)num_irqs) {
+		if (required)
+			PMD_DRV_LOG(ERR,
+				    "Not enough MSI-X vectors for %u Rx queues, need %u vectors, have %u",
+				    nb_rx_queues, last_vec + 1, num_irqs);
+		else
+			PMD_DRV_LOG(WARNING,
+				    "Not enough MSI-X vectors for %u Rx queues, need %u vectors, have %u; "
+				    "Rx queue interrupts stay disabled",
+				    nb_rx_queues, last_vec + 1, num_irqs);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /**
  * Initialize RX queue interrupts by enabling MSI-X, allocate interrupt vectors,
  * and configure interrupt attributes for each RX queue.
@@ -1798,6 +1839,14 @@ hinic3_deinit_rxq_intr(struct rte_eth_dev *dev)
  * - -ENOTSUP if MSI-X interrupts are not supported.
  * - Error code if enabling event file descriptors fails.
  * - -ENOMEM if allocating interrupt vectors fails.
+ * - -EINVAL if Rx interrupts are requested and the Rx queues do not
+ *   fit in the MSI-X vector table. When Rx interrupts are not
+ *   requested, a vector-table overflow is not fatal: the function
+ *   logs a warning and keeps Rx queue interrupts disabled.
+ *
+ * On SP230 with per-queue MSI-X vectors, when the application does not
+ * request Rx interrupts, the queue vector is named in each RQ context but
+ * never enabled, and no interrupt resources are allocated.
  */
 static int
 hinic3_init_rxq_intr(struct rte_eth_dev *dev)
@@ -1810,8 +1859,28 @@ hinic3_init_rxq_intr(struct rte_eth_dev *dev)
 
 	intr_handle = dev->intr_handle;
 	nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
-	if (!dev->data->dev_conf.intr_conf.rxq)
+
+	if (!dev->data->dev_conf.intr_conf.rxq) {
+		/*
+		 * SP230 raises the Rx MSI-X vector even without Rx interrupts.
+		 * Name a valid vector in the RQ context; the vector is never
+		 * enabled, so no interrupt is reported.
+		 */
+		if (!HINIC3_IS_SP230_NIC(nic_dev) ||
+		    !rte_intr_cap_multiple(intr_handle))
+			return 0;
+
+		if (hinic3_check_rxq_intr_vec(dev, dev->data->nb_rx_queues, false))
+			return 0;
+
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rxq = dev->data->rx_queues[i];
+			rxq->dp_intr_en = 1;
+			rxq->msix_entry_idx = (uint16_t)(i + HINIC3_RX_VEC_START);
+		}
+
 		return 0;
+	}
 
 	if (!rte_intr_cap_multiple(intr_handle)) {
 		PMD_DRV_LOG(ERR, "Rx queue interrupts require MSI-X interrupts (vfio-pci driver)");
@@ -1819,6 +1888,10 @@ hinic3_init_rxq_intr(struct rte_eth_dev *dev)
 	}
 
 	nb_rx_queues = dev->data->nb_rx_queues;
+	err = hinic3_check_rxq_intr_vec(dev, nb_rx_queues, true);
+	if (err)
+		return err;
+
 	err = rte_intr_efd_enable(intr_handle, nb_rx_queues);
 	if (err) {
 		PMD_DRV_LOG(ERR,
@@ -1829,8 +1902,8 @@ hinic3_init_rxq_intr(struct rte_eth_dev *dev)
 	intr_handle->intr_vec =
 		rte_zmalloc("hinic_intr_vec", nb_rx_queues * sizeof(int), 0);
 	if (intr_handle->intr_vec == NULL) {
-		PMD_DRV_LOG(ERR, "Failed to allocate intr_vec");
 		rte_intr_efd_disable(intr_handle);
+		PMD_DRV_LOG(ERR, "Failed to allocate intr_vec");
 		return -ENOMEM;
 	}
 	intr_handle->vec_list_size = nb_rx_queues;
@@ -1845,6 +1918,9 @@ hinic3_init_rxq_intr(struct rte_eth_dev *dev)
 		err = hinic3_init_rxq_msix_attr(nic_dev->hwdev,
 						rxq->msix_entry_idx);
 		if (err) {
+			PMD_DRV_LOG(ERR,
+				    "Set msix attr failed, msix_index %d",
+				    rxq->msix_entry_idx);
 			hinic3_deinit_rxq_intr(dev);
 			return err;
 		}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 13/30] net/hinic3: fix offload and cmdq/compact CQE config
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (11 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 12/30] net/hinic3: add SP230 Rx queue interrupt handling Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 14/30] net/hinic3: add vport statistics and VF LAG support Jiacheng Ye
                   ` (17 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Some offload capabilities are reported based on the wrong conditions:
VXLAN TNL TSO is never advertised, GENEVE/IPIP TSO is gated by the HTN
cmdq flag instead of those features' own flags, and outer UDP checksum
offload is not advertised although the Tx path handles it. The cmdq
mode/depth are also set in the wrong helper and the compact CQE flag is
not written to firmware at vport enable.

Advertise the missing offloads, gate tunnel TSO by the correct flags, set
cmdq mode/depth in hinic3_set_cmdq_depth(), and forward the compact CQE
flag.

The stale QinQ entries are dropped from features/hinic3.ini and the
Features list in hinic3.rst since the PMD does not advertise those
offloads.

Fixes: aa31be38544e ("net/hinic3: enhance command queue for new SPx series NIC")
Fixes: c1537bf6c033 ("net/hinic3: support Compact CQE in init")
Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/nics/features/hinic3.ini      | 1 -
 doc/guides/nics/hinic3.rst               | 2 +-
 drivers/net/hinic3/base/hinic3_hw_comm.c | 9 +++++----
 drivers/net/hinic3/base/hinic3_nic_cfg.c | 1 +
 drivers/net/hinic3/hinic3_ethdev.c       | 7 +++++--
 drivers/net/hinic3/hinic3_ethdev.h       | 1 -
 6 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/doc/guides/nics/features/hinic3.ini b/doc/guides/nics/features/hinic3.ini
index 6cdd240a82..3405a837bf 100644
--- a/doc/guides/nics/features/hinic3.ini
+++ b/doc/guides/nics/features/hinic3.ini
@@ -25,7 +25,6 @@ VLAN filter          = Y
 Flow control         = Y
 CRC offload          = Y
 VLAN offload         = Y
-QinQ offload         = P
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Inner L3 checksum    = P
diff --git a/doc/guides/nics/hinic3.rst b/doc/guides/nics/hinic3.rst
index d07e8605c0..68e67fbcff 100644
--- a/doc/guides/nics/hinic3.rst
+++ b/doc/guides/nics/hinic3.rst
@@ -16,7 +16,7 @@ Features
 - Receiver Side Scaling (RSS)
 - Flow filtering
 - Checksum offload
-- VLAN/QinQ stripping and inserting
+- VLAN stripping and inserting
 - TSO offload
 - Promiscuous mode
 - Port hardware statistics
diff --git a/drivers/net/hinic3/base/hinic3_hw_comm.c b/drivers/net/hinic3/base/hinic3_hw_comm.c
index 6541bc0428..2749faeba1 100644
--- a/drivers/net/hinic3/base/hinic3_hw_comm.c
+++ b/drivers/net/hinic3/base/hinic3_hw_comm.c
@@ -276,10 +276,6 @@ hinic3_set_root_ctxt(struct hinic3_hwdev *hwdev, uint32_t rq_depth,
 	root_ctxt.rq_depth = (uint16_t)rte_log2_u32(rq_depth);
 	root_ctxt.rx_buf_sz = get_hw_rx_buf_size(hwdev, rx_buf_sz);
 	root_ctxt.sq_depth = (uint16_t)rte_log2_u32(sq_depth);
-	root_ctxt.cmdq_mode = hwdev->cmdqs->cmdq_mode;
-
-	if (hwdev->cmdqs->cmdq_mode == HINIC3_ENHANCE_CMDQ)
-		root_ctxt.cmdq_depth--;
 
 	err = hinic3_msg_to_mgmt_sync(hwdev, HINIC3_MOD_COMM,
 				      HINIC3_MGMT_CMD_SET_VAT,
@@ -334,6 +330,11 @@ hinic3_set_cmdq_depth(struct hinic3_hwdev *hwdev, uint16_t cmdq_depth)
 	root_ctxt.set_cmdq_depth = 1;
 	root_ctxt.cmdq_depth = (uint8_t)rte_log2_u32(cmdq_depth);
 
+	root_ctxt.cmdq_mode = hwdev->cmdqs->cmdq_mode;
+
+	if (root_ctxt.cmdq_mode == HINIC3_ENHANCE_CMDQ)
+		root_ctxt.cmdq_depth--;
+
 	err = hinic3_msg_to_mgmt_sync(hwdev, HINIC3_MOD_COMM,
 				      HINIC3_MGMT_CMD_SET_VAT,
 				      &root_ctxt, sizeof(root_ctxt),
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.c b/drivers/net/hinic3/base/hinic3_nic_cfg.c
index 1520f88a1b..fb9b6d4d19 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.c
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.c
@@ -455,6 +455,7 @@ hinic3_set_vport_enable(struct hinic3_hwdev *hwdev, bool enable)
 	en_state.func_id = hinic3_global_func_id(hwdev);
 	en_state.state = enable ? 1 : 0;
 	en_state.num_qps = nic_dev->num_rqs;
+	en_state.rx_compact_wqe_en = HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev);
 
 	err = hinic3_msg_to_mgmt_sync(hwdev, HINIC3_MOD_L2NIC,
 				      HINIC3_NIC_CMD_SET_VPORT_ENABLE,
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 432278a0f2..5e8c143696 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -672,6 +672,8 @@ hinic3_dev_tnl_tso_support(struct rte_eth_dev_info *info, struct hinic3_nic_dev
 		info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO;
 	if (HINIC3_SUPPORT_IPXIP_OFFLOAD(nic_dev))
 		info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO;
+	if (HINIC3_SUPPORT_VXLAN_OFFLOAD(nic_dev))
+		info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO;
 }
 
 /**
@@ -713,9 +715,10 @@ hinic3_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
 		RTE_ETH_TX_OFFLOAD_UDP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
 		RTE_ETH_TX_OFFLOAD_SCTP_CKSUM |
 		RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+		RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM |
 		RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
-	if (nic_dev->feature_cap & NIC_F_HTN_CMDQ)
-		hinic3_dev_tnl_tso_support(info, nic_dev);
+
+	hinic3_dev_tnl_tso_support(info, nic_dev);
 
 	info->hash_key_size = HINIC3_RSS_KEY_SIZE;
 	info->reta_size = HINIC3_RSS_INDIR_SIZE;
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index 8bbab2ad53..f4d8c16640 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -24,7 +24,6 @@
 #define HINIC3_PKT_TX_TCP_CKSUM		RTE_MBUF_F_TX_TCP_CKSUM
 #define HINIC3_PKT_TX_IP_CKSUM		RTE_MBUF_F_TX_IP_CKSUM
 #define HINIC3_PKT_TX_VLAN_PKT		RTE_MBUF_F_TX_VLAN
-#define HINIC3_PKT_TX_QINQ_PKT		RTE_MBUF_F_TX_QINQ
 #define HINIC3_PKT_TX_L4_MASK		RTE_MBUF_F_TX_L4_MASK
 #define HINIC3_PKT_TX_SCTP_CKSUM	RTE_MBUF_F_TX_SCTP_CKSUM
 #define HINIC3_PKT_TX_IPV6		RTE_MBUF_F_TX_IPV6
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 14/30] net/hinic3: add vport statistics and VF LAG support
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (12 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 13/30] net/hinic3: fix offload and cmdq/compact CQE config Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 15/30] net/hinic3: add FEC mode get/set and capability support Jiacheng Ye
                   ` (16 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Expose the CIR drop counter and the firmware rx_mtu_err_vport and
rx_out_of_buffer counters through the per-port extended statistics, and
select the queue COS from the VF LAG bitmap when a VF runs on an
aggregated link.

For an even queue of a VF that is in the LAG group, the driver flips the
COS so the queue egresses through the peer port; other queues keep the
default COS.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/rel_notes/release_26_11.rst   |  5 ++
 drivers/net/hinic3/base/hinic3_cmd.h     |  2 +
 drivers/net/hinic3/base/hinic3_nic_cfg.c | 62 +++++++++++++++++++
 drivers/net/hinic3/base/hinic3_nic_cfg.h | 45 +++++++++++++-
 drivers/net/hinic3/hinic3_ethdev.c       | 76 +++++++++++++++++++++++-
 drivers/net/hinic3/hinic3_ethdev.h       |  3 +
 6 files changed, 190 insertions(+), 3 deletions(-)

diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 10ab2355ae..b0fb72ad59 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -128,6 +128,11 @@ New Features
   * Advertised ``RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP`` capability,
     as flow rules were already kept across device restart.
 
+* **Updated Huawei hinic3 ethernet driver.**
+
+  * Added vport statistics, including CIR drop, and VF link
+    aggregation (LAG) support.
+
 * **Updated Intel iavf driver.**
 
   * Runtime Rx/Tx queue setup is now automatically disabled
diff --git a/drivers/net/hinic3/base/hinic3_cmd.h b/drivers/net/hinic3/base/hinic3_cmd.h
index f2d5d47522..ecce94690e 100644
--- a/drivers/net/hinic3/base/hinic3_cmd.h
+++ b/drivers/net/hinic3/base/hinic3_cmd.h
@@ -94,6 +94,8 @@ enum hinic3_nic_cmd {
 	/* PORT CFG */
 	HINIC3_NIC_CMD_CFG_PAUSE_INFO			= 101,
 	HINIC3_NIC_CMD_VF_COS				= 104,
+	HINIC3_NIC_CMD_GET_CIR_DROP			= 115,
+	HINIC3_NIC_CMD_CFG_VF_LAG			= 243,
 };
 
 /* COMM commands between driver to MPU. */
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.c b/drivers/net/hinic3/base/hinic3_nic_cfg.c
index fb9b6d4d19..853ca0a41b 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.c
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.c
@@ -601,6 +601,33 @@ hinic3_get_pause_info(struct hinic3_hwdev *hwdev, struct nic_pause_config *nic_p
 	return hinic3_cfg_hw_pause(hwdev, HINIC3_CMD_OP_GET, nic_pause);
 }
 
+int
+hinic3_get_cir_drop(void *hwdev, struct hinic3_cir_drop *stats)
+{
+	struct hinic3_port_stats_info stats_info = { 0 };
+	struct hinic3_cmd_get_dp_info_resp vport_stats = { 0 };
+	uint16_t out_size = sizeof(vport_stats);
+	int err;
+
+	if (!hwdev || !stats)
+		return -EINVAL;
+
+	stats_info.func_id = hinic3_global_func_id(hwdev);
+	err = hinic3_msg_to_mgmt_sync(hwdev, HINIC3_MOD_L2NIC,
+				      HINIC3_NIC_CMD_GET_CIR_DROP,
+				      &stats_info, sizeof(stats_info),
+				      &vport_stats, &out_size);
+	if (err || !out_size || vport_stats.msg_head.status) {
+		PMD_DRV_LOG(ERR, "Get port stats failed, err: %d, status: 0x%x, out size: 0x%x",
+			    err, vport_stats.msg_head.status, out_size);
+		return -EIO;
+	}
+
+	memcpy(stats, vport_stats.value, sizeof(*stats));
+
+	return 0;
+}
+
 int
 hinic3_get_vport_stats(struct hinic3_hwdev *hwdev, struct hinic3_vport_stats *stats)
 {
@@ -1725,3 +1752,38 @@ hinic3_set_link_status_follow(struct hinic3_hwdev *hwdev,
 
 	return follow.head.status;
 }
+
+bool
+hinic3_cmd_vf_lag(void *hwdev, uint16_t func_id, uint8_t opcode)
+{
+	struct hinic3_vf_lag_cmd vf_lag_info = { 0 };
+	uint16_t out_size = sizeof(struct hinic3_vf_lag_cmd);
+	int err;
+
+	if (!hwdev || func_id >= MAX_FUNCTION_NUM)
+		return false;
+	vf_lag_info.func_id = func_id;
+	vf_lag_info.opcode = opcode;
+	vf_lag_info.en_flag = 0;
+
+	err = hinic3_msg_to_mgmt_sync(hwdev, HINIC3_MOD_L2NIC,
+				      HINIC3_NIC_CMD_CFG_VF_LAG,
+				      &vf_lag_info, sizeof(vf_lag_info),
+				      &vf_lag_info, &out_size);
+	if (vf_lag_info.msg_head.status == HINIC3_MGMT_CMD_UNSUPPORTED)
+		return false;
+
+	if (err || vf_lag_info.msg_head.status || !out_size) {
+		PMD_DRV_LOG(ERR,
+			    "Get vf_lag failed, err: %d, status: 0x%x, out size: 0x%x",
+			    err, vf_lag_info.msg_head.status, out_size);
+		return false;
+	}
+
+	if (opcode == HINIC3_CMD_OPCODE_GET) {
+		return !!(vf_lag_info.vf_lag_bitmap.vf_bit_map[func_id / VF_LAG_VF_NUM_PER_GROUP] &
+			  RTE_BIT32(func_id % VF_LAG_VF_NUM_PER_GROUP));
+	}
+
+	return false;
+}
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.h b/drivers/net/hinic3/base/hinic3_nic_cfg.h
index 6d3eb433bd..6fb56fff4f 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.h
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.h
@@ -17,6 +17,7 @@
 #define HINIC3_DCB_UP_MAX		0x8
 
 #define HINIC3_MAX_NUM_RQ		256
+#define MAX_FUNCTION_NUM		4096
 
 #define HINIC3_MAX_MTU_SIZE		9600
 #define HINIC3_MIN_MTU_SIZE		256
@@ -371,6 +372,18 @@ struct hinic3_port_stats_info {
 	uint16_t rsvd1;
 };
 
+#define HINIC3_CMD_MAX_DP_DATA_NUM 50
+struct hinic3_cir_drop {
+	uint64_t rx_discard_phy;
+};
+
+struct hinic3_cmd_get_dp_info_resp {
+	struct mgmt_msg_head msg_head;
+	uint16_t length;
+	uint16_t rsvd;
+	uint64_t value[HINIC3_CMD_MAX_DP_DATA_NUM];
+};
+
 struct hinic3_vport_stats {
 	uint64_t tx_unicast_pkts_vport;
 	uint64_t tx_unicast_bytes_vport;
@@ -390,6 +403,8 @@ struct hinic3_vport_stats {
 	uint64_t rx_discard_vport;
 	uint64_t tx_err_vport;
 	uint64_t rx_err_vport;
+	uint64_t rx_mtu_err_vport;
+	uint64_t rx_out_of_buffer; /* fw: rx_nowqe */
 };
 
 struct hinic3_cmd_vport_stats {
@@ -398,7 +413,7 @@ struct hinic3_cmd_vport_stats {
 	uint32_t stats_size;
 	uint32_t rsvd1;
 	struct hinic3_vport_stats stats;
-	uint64_t rsvd2[6];
+	uint64_t rsvd2[4];
 };
 
 struct hinic3_phy_port_stats {
@@ -1540,4 +1555,32 @@ int hinic3_set_feature_to_hw(struct hinic3_hwdev *hwdev, uint64_t *s_feature, ui
 
 int hinic3_set_link_status_follow(struct hinic3_hwdev *hwdev,
 				  enum hinic3_link_follow_status status);
+
+/* VF LAG definitions */
+#define VF_LAG_VF_NUM_GROUP_NUM 128
+#define VF_LAG_VF_NUM_PER_GROUP 32
+#define HINIC3_CMD_OPCODE_SET 0
+#define HINIC3_CMD_OPCODE_GET 1
+
+typedef struct hinic3_vf_lag_bitmap_s {
+	uint32_t vf_bit_map[VF_LAG_VF_NUM_GROUP_NUM];
+} hinic3_vf_lag_bitmap;
+
+struct hinic3_vf_lag_cmd {
+	struct mgmt_msg_head msg_head;
+
+	uint16_t func_id;
+	uint8_t opcode; /* 0 -> set, 1 -> get */
+	uint8_t en_flag; /* 0 -> disable, 1 -> enable  */
+	uint8_t bond_active_num;
+	uint8_t bond_active_bitmap;
+	uint8_t mac_sync_flag;
+	uint8_t rsvd;
+	hinic3_vf_lag_bitmap vf_lag_bitmap;
+};
+
+int hinic3_get_cir_drop(void *hwdev, struct hinic3_cir_drop *stats);
+
+bool hinic3_cmd_vf_lag(void *hwdev, uint16_t func_id, uint8_t opcode);
+
 #endif /* _HINIC3_NIC_CFG_H_ */
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 5e8c143696..96c3eb4931 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -80,12 +80,25 @@ struct hinic3_xstats_name_off {
 	uint32_t offset;
 };
 
+#define HINIC3_CIR_DROP_STAT(_stat_item)                                   \
+	{                                                                  \
+		.name = #_stat_item,                                       \
+		.offset = offsetof(struct hinic3_cir_drop, _stat_item),    \
+	}
+
 #define HINIC3_FUNC_STAT(_stat_item)                                       \
 	{                                                                  \
 		.name = #_stat_item,                                       \
 		.offset = offsetof(struct hinic3_vport_stats, _stat_item), \
 	}
 
+
+static struct hinic3_xstats_name_off hinic3_cir_drop_stats_strings[] = {
+	HINIC3_CIR_DROP_STAT(rx_discard_phy),
+};
+
+#define HINIC3_CIR_DROP_XSTATS_NUM  RTE_DIM(hinic3_cir_drop_stats_strings)
+
 static const struct hinic3_xstats_name_off hinic3_vport_stats_strings[] = {
 	HINIC3_FUNC_STAT(tx_unicast_pkts_vport),
 	HINIC3_FUNC_STAT(tx_unicast_bytes_vport),
@@ -105,6 +118,8 @@ static const struct hinic3_xstats_name_off hinic3_vport_stats_strings[] = {
 	HINIC3_FUNC_STAT(rx_discard_vport),
 	HINIC3_FUNC_STAT(tx_err_vport),
 	HINIC3_FUNC_STAT(rx_err_vport),
+	HINIC3_FUNC_STAT(rx_mtu_err_vport),
+	HINIC3_FUNC_STAT(rx_out_of_buffer),
 };
 
 #define HINIC3_VPORT_XSTATS_NUM RTE_DIM(hinic3_vport_stats_strings)
@@ -284,12 +299,16 @@ static const struct hinic3_xstats_name_off hinic3_txq_stats_strings[] = {
 static uint32_t
 hinic3_xstats_calc_num(struct hinic3_nic_dev *nic_dev)
 {
+	uint32_t cir_drop_num = HINIC3_IS_SP620_NIC(nic_dev) ?
+				HINIC3_CIR_DROP_XSTATS_NUM : 0;
+
 	if (HINIC3_IS_VF(nic_dev->hwdev)) {
-		return (HINIC3_VPORT_XSTATS_NUM +
+		return (HINIC3_VPORT_XSTATS_NUM + cir_drop_num +
 			HINIC3_RXQ_XSTATS_NUM * nic_dev->num_rqs +
 			HINIC3_TXQ_XSTATS_NUM * nic_dev->num_sqs);
 	} else {
 		return (HINIC3_VPORT_XSTATS_NUM + HINIC3_PHYPORT_XSTATS_NUM +
+			cir_drop_num +
 			HINIC3_RXQ_XSTATS_NUM * nic_dev->num_rqs +
 			HINIC3_TXQ_XSTATS_NUM * nic_dev->num_sqs);
 	}
@@ -1269,7 +1288,14 @@ hinic3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 	txq->wqebb_size = (uint16_t)RTE_BIT32(txq->wqebb_shift);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->owner = 1;
-	txq->cos = nic_dev->default_cos;
+
+	if (!ODD_NUMBER_QUEUE_ID(qid) &&
+		hinic3_cmd_vf_lag(nic_dev->hwdev, hinic3_global_func_id(nic_dev->hwdev),
+				  HINIC3_CMD_OPCODE_GET))
+		txq->cos = SELECT_OTHER_COS_ID(nic_dev->default_cos);
+	else
+		txq->cos = nic_dev->default_cos;
+
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 	txq->tx_wqe_compact_task = HINIC3_SUPPORT_TX_WQE_COMPACT_TASK(nic_dev);
 
@@ -2947,6 +2973,38 @@ hinic3_dev_stats_reset(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static uint16_t
+get_port_cir_drop(struct hinic3_nic_dev *nic_dev,
+		  struct rte_eth_xstat *xstats, uint32_t base)
+{
+	struct hinic3_cir_drop port_stats;
+	uint16_t i;
+	int err;
+
+	memset(&port_stats, 0, sizeof(port_stats));
+
+	err = hinic3_get_cir_drop(nic_dev->hwdev, &port_stats);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to get CPB cir drops from fw.");
+
+		for (i = 0; i < RTE_DIM(hinic3_cir_drop_stats_strings); i++) {
+			xstats[i].value = 0;
+			xstats[i].id = base + i;
+		}
+
+		return RTE_DIM(hinic3_cir_drop_stats_strings);
+	}
+
+	for (i = 0; i < RTE_DIM(hinic3_cir_drop_stats_strings); i++) {
+		memcpy(&xstats[i].value,
+		       (const char *)&port_stats + hinic3_cir_drop_stats_strings[i].offset,
+		       sizeof(uint64_t));
+		xstats[i].id = base + i;
+	}
+
+	return RTE_DIM(hinic3_cir_drop_stats_strings);
+}
+
 /**
  * Get device extended statistics.
  *
@@ -3035,6 +3093,10 @@ hinic3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
 		count++;
 	}
 
+	/* Get stats from cir drop stats structure */
+	if (HINIC3_IS_SP620_NIC(nic_dev))
+		count += get_port_cir_drop(nic_dev, &xstats[count], count);
+
 	if (HINIC3_IS_VF(nic_dev->hwdev))
 		return count;
 
@@ -3135,6 +3197,16 @@ hinic3_dev_xstats_get_names(struct rte_eth_dev *dev,
 		count++;
 	}
 
+	/* Get cir drop stats name. */
+	if (HINIC3_IS_SP620_NIC(nic_dev)) {
+		for (i = 0; i < HINIC3_CIR_DROP_XSTATS_NUM; i++) {
+			strlcpy(xstats_names[count].name,
+				hinic3_cir_drop_stats_strings[i].name,
+				sizeof(xstats_names[count].name));
+			count++;
+		}
+	}
+
 	if (HINIC3_IS_VF(nic_dev->hwdev))
 		return count;
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index f4d8c16640..c3384e5fd0 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -162,6 +162,9 @@ struct hinic3_nic_dev {
 
 };
 
+#define SELECT_OTHER_COS_ID(cos_id) ((cos_id) ^ 4)
+#define ODD_NUMBER_QUEUE_ID(q_id) ((q_id) & 1)
+
 #define HINIC3_IS_SP620_NIC(nic_dev) ((nic_dev)->nic_type == NIC_SP620)
 #define HINIC3_IS_SP230_NIC(nic_dev) ((nic_dev)->nic_type == NIC_SP230)
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 15/30] net/hinic3: add FEC mode get/set and capability support
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (13 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 14/30] net/hinic3: add vport statistics and VF LAG support Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 16/30] net/hinic3: add mbox message recording and debug dump Jiacheng Ye
                   ` (15 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Add the FEC get/set/capability callbacks and convert the FEC values
between the firmware and DPDK representations.

The firmware reports the advertised FEC mode as an enum and the
supported modes as a bitmap; map both to the DPDK masks. NOT_SET (0)
has no DPDK equivalent, so fec_get returns -EINVAL for it. AUTO cannot
be set through the PMD: it is masked out of the capabilities, and fec_set
accepts only NOFEC, BASER, RS or LLRS.

Reject unknown values and empty masks. Return
HINIC3_FEC_CAPA_NUM_PER_SPEED as the required count when the caller's
array is too small.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/nics/features/hinic3.ini      |   1 +
 doc/guides/nics/hinic3.rst               |   1 +
 doc/guides/rel_notes/release_26_11.rst   |   1 +
 drivers/net/hinic3/base/hinic3_nic_cfg.c | 126 +++++++++++++++++++++
 drivers/net/hinic3/base/hinic3_nic_cfg.h |  32 ++++++
 drivers/net/hinic3/hinic3_ethdev.c       |  129 ++++++++++++++++++++++++++++++
 6 files changed, 290 insertions(+)

diff --git a/doc/guides/nics/features/hinic3.ini b/doc/guides/nics/features/hinic3.ini
index 3405a837bf..dc4a92fc41 100644
--- a/doc/guides/nics/features/hinic3.ini
+++ b/doc/guides/nics/features/hinic3.ini
@@ -25,6 +25,7 @@ VLAN filter          = Y
 Flow control         = Y
 CRC offload          = Y
 VLAN offload         = Y
+FEC                  = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Inner L3 checksum    = P
diff --git a/doc/guides/nics/hinic3.rst b/doc/guides/nics/hinic3.rst
index 68e67fbcff..4afa322bc3 100644
--- a/doc/guides/nics/hinic3.rst
+++ b/doc/guides/nics/hinic3.rst
@@ -23,6 +23,7 @@ Features
 - Jumbo frames
 - Link state information
 - Link flow control
+- FEC
 - Scattered and gather for TX and RX
 - Allmulticast mode
 - MTU update
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index b0fb72ad59..d03f12e743 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -132,6 +132,7 @@ New Features
 
   * Added vport statistics, including CIR drop, and VF link
     aggregation (LAG) support.
+  * Added FEC mode get and set support.
 
 * **Updated Intel iavf driver.**
 
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.c b/drivers/net/hinic3/base/hinic3_nic_cfg.c
index 853ca0a41b..b6717f2990 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.c
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.c
@@ -1753,6 +1753,132 @@ hinic3_set_link_status_follow(struct hinic3_hwdev *hwdev,
 	return follow.head.status;
 }
 
+static void
+hinic3_fec_param_convert(uint32_t opcode, uint8_t in_fec_param, uint8_t *out_fec_param)
+{
+	uint8_t fec_value_table_length;
+	uint8_t i;
+
+	struct hinic3_fec_param_value_map fec_value_table[] = {
+		{HINIC3_PORT_FEC_RSFEC, RTE_BIT32(HINIC3_PORT_FEC_RSFEC),
+		 RTE_ETH_FEC_MODE_CAPA_MASK(RS)},
+		{HINIC3_PORT_FEC_BASEFEC, RTE_BIT32(HINIC3_PORT_FEC_BASEFEC),
+		 RTE_ETH_FEC_MODE_CAPA_MASK(BASER)},
+		{HINIC3_PORT_FEC_NOFEC, RTE_BIT32(HINIC3_PORT_FEC_NOFEC),
+		 RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC)},
+		{HINIC3_PORT_FEC_LLRSFEC, RTE_BIT32(HINIC3_PORT_FEC_LLRSFEC),
+		 RTE_ETH_FEC_MODE_CAPA_MASK(LLRS)}
+	};
+
+	*out_fec_param = 0;
+	fec_value_table_length =
+		(uint8_t)(sizeof(fec_value_table) / sizeof(struct hinic3_fec_param_value_map));
+
+	if (opcode == HINIC3_FEC_MODE_OPCODE_SET) {
+		for (i = 0; i < fec_value_table_length; i++) {
+			if ((in_fec_param & fec_value_table[i].ethtool_fec_value) != 0)
+				*out_fec_param = fec_value_table[i].fec_offset;
+		}
+	}
+
+	if (opcode == HINIC3_FEC_MODE_OPCODE_GET) {
+		for (i = 0; i < fec_value_table_length; i++) {
+			if ((in_fec_param & fec_value_table[i].hinic3_fec_value) != 0)
+				*out_fec_param |= fec_value_table[i].ethtool_fec_value;
+		}
+	}
+}
+
+int
+hinic3_set_fec_mode(struct hinic3_hwdev *hwdev, uint8_t fecparam)
+{
+	struct mag_cmd_cfg_fec_mode fec_msg = { 0 };
+	uint16_t out_size = sizeof(fec_msg);
+	uint8_t advertised_fec = 0;
+	int err;
+
+	if (!hwdev)
+		return -EINVAL;
+
+	hinic3_fec_param_convert(HINIC3_FEC_MODE_OPCODE_SET, fecparam, &advertised_fec);
+	fec_msg.opcode = HINIC3_FEC_MODE_OPCODE_SET;
+	fec_msg.port_id = hinic3_physical_port_id(hwdev);
+	fec_msg.advertised_fec = advertised_fec;
+
+	err = hinic3_msg_to_mgmt_sync(hwdev, HINIC3_MOD_HILINK,
+				      MAG_CMD_CFG_FEC_MODE,
+				      &fec_msg, sizeof(fec_msg),
+				      &fec_msg, &out_size);
+
+	if (err || !out_size || fec_msg.head.status) {
+		PMD_DRV_LOG(ERR, "Failed to set fec mode, err: %d, status: 0x%x, out size: 0x%x",
+			    err, fec_msg.head.status, out_size);
+		if (err != 0)
+			return -EIO;
+		return -EINVAL;
+	}
+
+	PMD_DRV_LOG(INFO, "Set fec mode success, active fec capa mode: %d", fecparam);
+	return 0;
+}
+
+int
+hinic3_get_fec_mode(struct hinic3_hwdev *hwdev, uint8_t *advertised_fec,
+		    uint8_t *supported_fec)
+{
+	struct mag_cmd_cfg_fec_mode fec_msg = { 0 };
+	uint16_t out_size = sizeof(fec_msg);
+	int err;
+
+	if (!hwdev)
+		return -EINVAL;
+
+	if (advertised_fec != NULL)
+		*advertised_fec = 0;
+
+	if (supported_fec != NULL)
+		*supported_fec = 0;
+
+	fec_msg.opcode = HINIC3_FEC_MODE_OPCODE_GET;
+	fec_msg.port_id = hinic3_physical_port_id(hwdev);
+
+	err = hinic3_msg_to_mgmt_sync(hwdev, HINIC3_MOD_HILINK,
+				      MAG_CMD_CFG_FEC_MODE,
+				      &fec_msg, sizeof(fec_msg),
+				      &fec_msg, &out_size);
+
+	if (err || !out_size || fec_msg.head.status) {
+		PMD_DRV_LOG(ERR, "Failed to get fec mode, err: %d, status: 0x%x, out size: 0x%x",
+			    err, fec_msg.head.status, out_size);
+		if (err != 0)
+			return -EIO;
+		return -EINVAL;
+	}
+
+	/*
+	 * Reject out-of-range values instead of turning them into an invalid
+	 * DPDK mode mask. advertised_fec is an enum, supported_fec is a bitmap
+	 * of the same values.
+	 */
+	if ((advertised_fec != NULL &&
+	     fec_msg.advertised_fec > HINIC3_PORT_FEC_LLRSFEC) ||
+	    (supported_fec != NULL &&
+	     (fec_msg.supported_fec & ~((1U << (HINIC3_PORT_FEC_LLRSFEC + 1)) - 1)) != 0))
+		return -EINVAL;
+
+	if (advertised_fec != NULL)
+		hinic3_fec_param_convert(HINIC3_FEC_MODE_OPCODE_GET,
+					RTE_BIT32(fec_msg.advertised_fec),
+					advertised_fec);
+
+	if (supported_fec != NULL)
+		hinic3_fec_param_convert(HINIC3_FEC_MODE_OPCODE_GET,
+					fec_msg.supported_fec,
+					supported_fec);
+
+	return 0;
+}
+
 bool
 hinic3_cmd_vf_lag(void *hwdev, uint16_t func_id, uint8_t opcode)
 {
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.h b/drivers/net/hinic3/base/hinic3_nic_cfg.h
index 6fb56fff4f..9458a576c4 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.h
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.h
@@ -967,6 +967,33 @@ int hinic3_msg_to_mgmt_sync(struct hinic3_hwdev *hwdev, enum hinic3_mod_type mod
 
 int hinic3_set_ci_table(struct hinic3_hwdev *hwdev, struct hinic3_sq_attr *attr);
 
+enum hinic3_fec_mode_opcode {
+	HINIC3_FEC_MODE_OPCODE_GET = 0,
+	HINIC3_FEC_MODE_OPCODE_SET = 1,
+};
+
+struct mag_cmd_cfg_fec_mode {
+	struct mgmt_msg_head head;
+	uint8_t port_id;
+	uint8_t opcode;
+	uint8_t advertised_fec;
+	uint8_t supported_fec;
+};
+
+enum hinic3_cmd_port_fec {
+	HINIC3_PORT_FEC_NOT_SET = 0,
+	HINIC3_PORT_FEC_RSFEC = 1,
+	HINIC3_PORT_FEC_BASEFEC = 2,
+	HINIC3_PORT_FEC_NOFEC = 3,
+	HINIC3_PORT_FEC_LLRSFEC = 4,
+};
+
+struct hinic3_fec_param_value_map {
+	uint8_t fec_offset;
+	uint8_t hinic3_fec_value;
+	uint8_t ethtool_fec_value;
+};
+
 /**
  * Update MAC address to hardware.
  *
@@ -1583,4 +1610,9 @@ int hinic3_get_cir_drop(void *hwdev, struct hinic3_cir_drop *stats);
 
 bool hinic3_cmd_vf_lag(void *hwdev, uint16_t func_id, uint8_t opcode);
 
+int hinic3_set_fec_mode(struct hinic3_hwdev *hwdev, uint8_t fecparam);
+
+int hinic3_get_fec_mode(struct hinic3_hwdev *hwdev, uint8_t *advertised_fec,
+			uint8_t *supported_fec);
+
 #endif /* _HINIC3_NIC_CFG_H_ */
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 96c3eb4931..ef0ac1fdcd 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -3440,6 +3440,132 @@ hinic3_dev_filter_ctrl(struct rte_eth_dev *dev, const struct rte_flow_ops **arg)
 	return 0;
 }
 
+static const uint32_t HINIC3_FEC_CAPA_NUM_PER_SPEED = 1;
+
+static const uint32_t hinic3_speed_capa[] = {
+	RTE_ETH_SPEED_NUM_NONE, RTE_ETH_SPEED_NUM_10M,
+	RTE_ETH_SPEED_NUM_100M, RTE_ETH_SPEED_NUM_1G,
+	RTE_ETH_SPEED_NUM_10G, RTE_ETH_SPEED_NUM_25G,
+	RTE_ETH_SPEED_NUM_40G, RTE_ETH_SPEED_NUM_50G,
+	RTE_ETH_SPEED_NUM_100G, RTE_ETH_SPEED_NUM_200G,
+	RTE_ETH_SPEED_NUM_400G, RTE_ETH_SPEED_NUM_800G
+};
+
+static bool
+hinic3_fec_param_valid(uint32_t fec_param)
+{
+	if (fec_param == RTE_ETH_FEC_MODE_CAPA_MASK(LLRS) ||
+	    fec_param == RTE_ETH_FEC_MODE_CAPA_MASK(RS) ||
+	    fec_param == RTE_ETH_FEC_MODE_CAPA_MASK(BASER) ||
+	    fec_param == RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC)) {
+		return true;
+	}
+
+	return false;
+}
+
+static int
+hinic3_fec_set(struct rte_eth_dev *dev, uint32_t fec_capa)
+{
+	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+	int err;
+
+	if (!hinic3_fec_param_valid(fec_capa)) {
+		if (fec_capa & RTE_ETH_FEC_MODE_CAPA_MASK(AUTO))
+			PMD_DRV_LOG(ERR,
+				    "Unsupported fec param 0x%x, AUTO is configured by the hinicadm5 firmware tool.",
+				    fec_capa);
+		else
+			PMD_DRV_LOG(ERR, "Unsupported fec param 0x%x.", fec_capa);
+		return -EINVAL;
+	}
+
+	err = hinic3_set_fec_mode(nic_dev->hwdev, (uint8_t)fec_capa);
+	if (err) {
+		/*
+		 * A forced FEC mode can only be configured after
+		 * auto-negotiation is disabled with the hinicadm5 firmware tool.
+		 * While auto-negotiation is on, the firmware rejects the SET
+		 * request (management status 0x10), and the PMD has no way to
+		 * toggle it. The firmware also reports the negotiated mode on
+		 * GET, so the AUTO state cannot be detected before the attempt.
+		 */
+		PMD_DRV_LOG(ERR, "Failed to set fec param 0x%x, err %d.",
+			    fec_capa, err);
+		return err;
+	}
+
+	return 0;
+}
+
+static int
+hinic3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa)
+{
+	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+	uint8_t advertised_fec = 0;
+	int err;
+
+	err = hinic3_get_fec_mode(nic_dev->hwdev, &advertised_fec, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Get fec param failed: %d.", err);
+		return err;
+	}
+
+	if (advertised_fec == 0) {
+		PMD_DRV_LOG(ERR, "Firmware reported an unknown FEC mode (NOT_SET).");
+		return -EINVAL;
+	}
+
+	*fec_capa = (uint32_t)advertised_fec;
+
+	return 0;
+}
+
+static int
+hinic3_fec_capability_get(struct rte_eth_dev *dev,
+			  struct rte_eth_fec_capa *speed_fec_capa,
+			  unsigned int num)
+{
+	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+	struct nic_port_info port_info = { 0 };
+	uint8_t supported_fec = 0;
+	int err;
+
+	if (speed_fec_capa == NULL)
+		return HINIC3_FEC_CAPA_NUM_PER_SPEED;
+
+	if (num < HINIC3_FEC_CAPA_NUM_PER_SPEED) {
+		PMD_DRV_LOG(ERR, "Not enough array size(%u) to store FEC capabilities, should not be less than %u.",
+			    num, HINIC3_FEC_CAPA_NUM_PER_SPEED);
+		return HINIC3_FEC_CAPA_NUM_PER_SPEED;
+	}
+
+	err = hinic3_get_fec_mode(nic_dev->hwdev, NULL, &supported_fec);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to get fec capability, err: %d.", err);
+		return err;
+	}
+
+	err = hinic3_get_port_info(nic_dev->hwdev, &port_info);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to get port info, err: %d.", err);
+		return err;
+	}
+
+	if (port_info.speed >= RTE_DIM(hinic3_speed_capa))
+		return -EINVAL;
+
+	speed_fec_capa->speed = hinic3_speed_capa[port_info.speed];
+	/* AUTO is managed by the hinicadm5 firmware tool and cannot be set through the PMD. */
+	speed_fec_capa->capa = (uint32_t)supported_fec &
+			       ~RTE_ETH_FEC_MODE_CAPA_MASK(AUTO);
+
+	if (speed_fec_capa->capa == 0)
+		return -ENOTSUP;
+
+	return HINIC3_FEC_CAPA_NUM_PER_SPEED;
+}
+
 static const struct eth_dev_ops hinic3_pmd_ops = {
 	.dev_configure                 = hinic3_dev_configure,
 	.dev_infos_get                 = hinic3_dev_infos_get,
@@ -3486,6 +3617,9 @@ static const struct eth_dev_ops hinic3_pmd_ops = {
 	.mac_addr_add                  = hinic3_mac_addr_add,
 	.set_mc_addr_list              = hinic3_set_mc_addr_list,
 	.flow_ops_get                  = hinic3_dev_filter_ctrl,
+	.fec_get_capability            = hinic3_fec_capability_get,
+	.fec_get                       = hinic3_fec_get,
+	.fec_set                       = hinic3_fec_set,
 };
 
 static const struct eth_dev_ops hinic3_pmd_vf_ops = {
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 16/30] net/hinic3: add mbox message recording and debug dump
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (14 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 15/30] net/hinic3: add FEC mode get/set and capability support Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 17/30] net/hinic3: add COS mask and COS map support Jiacheng Ye
                   ` (14 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Provide recorded mbox send/receive history and a dump of it together with
the AEQ state so mailbox timeouts and response mismatches can be diagnosed.

eth_dev_priv_dump is also registered for secondary processes, where
hwdev->pci_dev is not valid. Pass the rte_pci_device obtained from the
ethdev down to the dump instead of reading it from hwdev.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/rel_notes/release_26_11.rst |  1 +
 drivers/net/hinic3/base/hinic3_eqs.c   | 64 ++++++++++++++++++++++++--
 drivers/net/hinic3/base/hinic3_eqs.h   |  9 +++-
 drivers/net/hinic3/base/hinic3_mbox.c  | 45 ++++++++++++++++++
 drivers/net/hinic3/base/hinic3_mbox.h  | 19 ++++++++
 drivers/net/hinic3/hinic3_ethdev.c     | 29 ++++++++++++
 6 files changed, 161 insertions(+), 6 deletions(-)

diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index d03f12e743..e0d042f681 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -133,6 +133,7 @@ New Features
   * Added vport statistics, including CIR drop, and VF link
     aggregation (LAG) support.
   * Added FEC mode get and set support.
+  * Added mailbox message counter reporting through the device private dump API.
 
 * **Updated Intel iavf driver.**
 
diff --git a/drivers/net/hinic3/base/hinic3_eqs.c b/drivers/net/hinic3/base/hinic3_eqs.c
index 1fc78adc85..f86188b5f5 100644
--- a/drivers/net/hinic3/base/hinic3_eqs.c
+++ b/drivers/net/hinic3/base/hinic3_eqs.c
@@ -553,7 +553,7 @@ hinic3_aeqs_free(struct hinic3_hwdev *hwdev)
 }
 
 void
-hinic3_dump_aeq_info(struct hinic3_hwdev *hwdev)
+hinic3_dump_aeq_info(struct hinic3_hwdev *hwdev, FILE *file)
 {
 	struct hinic3_aeq_elem *aeqe_pos = NULL;
 	struct hinic3_eq *eq = NULL;
@@ -580,10 +580,64 @@ hinic3_dump_aeq_info(struct hinic3_hwdev *hwdev)
 		addr = HINIC3_CSR_AEQ_PROD_IDX_ADDR;
 		pi = hinic3_hwif_read_reg(hwdev->hwif, addr);
 		aeqe_pos = GET_AEQ_ELEM(eq, eq->cons_idx);
-		PMD_DRV_LOG(ERR,
-			    "Aeq id: %d, idx: %u, ctrl0: 0x%08x, wrap: %d, pi: 0x%x, ci: 0x%08x, desc: 0x%x",
-			    q_id, idx, ctrl0, eq->wrapped, pi, ci,
-			    rte_be_to_cpu_32(aeqe_pos->desc));
+		fprintf(file, "Aeq id: %d, idx: %u, ctrl0: 0x%08x, wrap: %d, pi: 0x%x, ci: 0x%08x, desc: 0x%x\n",
+				q_id, idx, ctrl0, eq->wrapped, pi, ci,
+				rte_be_to_cpu_32(aeqe_pos->desc));
+	}
+}
+
+void
+hinic3_dump_aeq_mbox_info(struct hinic3_hwdev *hwdev,
+			  struct rte_pci_device *pci_dev, FILE *file)
+{
+	struct save_mbox_info *save_mbox = NULL;
+	struct hinic3_eq *aeq = NULL;
+	struct hinic3_aeq_elem *aeqe_pos = NULL;
+	uint32_t i, pos;
+	uint8_t src, size, wrapped, seq_id, seg_len, msg_id, mod;
+	uint8_t data[HINIC3_AEQE_DATA_SIZE];
+	uint16_t src_func_idx, cmd;
+	uint32_t aeqe_desc;
+	uint64_t mbox_header;
+	enum hinic3_aeq_type event;
+
+	save_mbox = hwdev->func_to_func->save_mbox;
+	aeq = &hwdev->aeqs->aeq[HINIC3_MBOX_RSP_MSG_AEQ];
+
+	fprintf(file, "Sending the latest mbox messages:\n");
+	for (i = 0; i < save_mbox->count; i++) {
+		pos = (save_mbox->start + i) % HINIC3_MBOX_SAVE_NUM;
+		fprintf(file, "send_msg_id: %u, cmd: %u, mod: %u\n",
+			save_mbox->send_info[pos].send_msg_id, save_mbox->send_info[pos].cmd,
+			save_mbox->send_info[pos].mod);
+	}
+
+	fprintf(file, "dump aeqe info:\n");
+	fprintf(file, "port: %u, eq cid: %u, func id: %u, bus: %u, devid: %u, wrapped: %u\n",
+		hwdev->port_id, aeq->cons_idx, pci_dev->addr.function, pci_dev->addr.bus,
+		pci_dev->addr.devid, aeq->wrapped);
+	for (i = 0; i < aeq->eq_len; i++) {
+		/* Parsing the data field. */
+		aeqe_pos = GET_AEQ_ELEM(aeq, i);
+		aeqe_desc = rte_be_to_cpu_32(aeqe_pos->desc);
+		memcpy(data, aeqe_pos->aeqe_data, HINIC3_AEQE_DATA_SIZE);
+		hinic3_be32_to_cpu(data, HINIC3_AEQE_DATA_SIZE);
+		memcpy(&mbox_header, data, sizeof(mbox_header));
+		seq_id = HINIC3_MSG_HEADER_GET(mbox_header, SEQID);
+		seg_len = HINIC3_MSG_HEADER_GET(mbox_header, SEG_LEN);
+		src_func_idx = HINIC3_MSG_HEADER_GET(mbox_header, SRC_GLB_FUNC_IDX);
+		msg_id = HINIC3_MSG_HEADER_GET(mbox_header, MSG_ID);
+		mod = HINIC3_MSG_HEADER_GET(mbox_header, MODULE);
+		cmd = HINIC3_MSG_HEADER_GET(mbox_header, CMD);
+		/* Parsing the desc field. */
+		event = EQ_ELEM_DESC_GET(aeqe_desc, TYPE);
+		src = EQ_ELEM_DESC_GET(aeqe_desc, SRC);
+		size = EQ_ELEM_DESC_GET(aeqe_desc, SIZE);
+		wrapped = EQ_ELEM_DESC_GET(aeqe_desc, WRAPPED);
+
+		fprintf(file, "index: %d, msg_id: %u, mod: %u, cmd: %u, seq_id: %u, seg_len: %u, src_func_idx: %u, event: %u, src: %u, size: %u, wrapped: %u\n",
+			i, msg_id, mod, cmd, seq_id, seg_len, src_func_idx,
+			event, src, size, wrapped);
 	}
 }
 
diff --git a/drivers/net/hinic3/base/hinic3_eqs.h b/drivers/net/hinic3/base/hinic3_eqs.h
index 365c9cbf39..4c1b03da11 100644
--- a/drivers/net/hinic3/base/hinic3_eqs.h
+++ b/drivers/net/hinic3/base/hinic3_eqs.h
@@ -5,6 +5,10 @@
 #ifndef _HINIC3_EQS_H_
 #define _HINIC3_EQS_H_
 
+#include <stdio.h>
+
+struct rte_pci_device;
+
 #define HINIC3_MAX_AEQS	    4
 #define HINIC3_MIN_AEQS	    2
 #define HINIC3_EQ_MAX_PAGES 4
@@ -83,7 +87,10 @@ int hinic3_aeqs_init(struct hinic3_hwdev *hwdev);
 
 void hinic3_aeqs_free(struct hinic3_hwdev *hwdev);
 
-void hinic3_dump_aeq_info(struct hinic3_hwdev *hwdev);
+void hinic3_dump_aeq_info(struct hinic3_hwdev *hwdev, FILE *file);
+
+void hinic3_dump_aeq_mbox_info(struct hinic3_hwdev *hwdev,
+			       struct rte_pci_device *pci_dev, FILE *file);
 
 int hinic3_aeq_poll_msg(struct hinic3_eq *eq, uint32_t timeout, void *param);
 
diff --git a/drivers/net/hinic3/base/hinic3_mbox.c b/drivers/net/hinic3/base/hinic3_mbox.c
index c4ca2ed7ba..6d0d4cce2b 100644
--- a/drivers/net/hinic3/base/hinic3_mbox.c
+++ b/drivers/net/hinic3/base/hinic3_mbox.c
@@ -711,6 +711,27 @@ send_tlp_mbox_seg(struct hinic3_mbox *func_to_func, uint64_t header, uint16_t ds
 	return 0;
 }
 
+static void hinic3_record_mbox_info(struct hinic3_mbox *func_to_func,
+				    enum hinic3_mod_type mod, uint16_t cmd,
+				    uint8_t msg_id)
+{
+	struct mbox_send_info send_mbox;
+
+	send_mbox.cmd = cmd;
+	send_mbox.mod = mod;
+	send_mbox.send_msg_id = msg_id;
+
+	uint8_t pos = (func_to_func->save_mbox->start + func_to_func->save_mbox->count) %
+		      HINIC3_MBOX_SAVE_NUM;
+	func_to_func->save_mbox->send_info[pos] = send_mbox;
+
+	if (func_to_func->save_mbox->count < HINIC3_MBOX_SAVE_NUM)
+		func_to_func->save_mbox->count++;
+	else
+		func_to_func->save_mbox->start = (func_to_func->save_mbox->start + 1) %
+						 HINIC3_MBOX_SAVE_NUM;
+}
+
 static int
 send_mbox_to_func(struct hinic3_mbox *func_to_func, enum hinic3_mod_type mod,
 		struct hinic3_handler_info *handler_info, struct mbox_msg_info *msg_info)
@@ -724,6 +745,9 @@ send_mbox_to_func(struct hinic3_mbox *func_to_func, enum hinic3_mod_type mod,
 
 	rsp_aeq_id = HINIC3_MBOX_RSP_MSG_AEQ;
 
+	hinic3_record_mbox_info(func_to_func, mod, handler_info->cmd,
+				msg_info->msg_id);
+
 	/* Set the header message. */
 	header = HINIC3_MSG_HEADER_SET(handler_info->in_size, MSG_LEN) |
 		 HINIC3_MSG_HEADER_SET(mod, MODULE) |
@@ -782,6 +806,9 @@ send_tlp_mbox_to_func(struct hinic3_mbox *func_to_func, enum hinic3_mod_type mod
 
 	rsp_aeq_id = HINIC3_MBOX_RSP_MSG_AEQ;
 
+	hinic3_record_mbox_info(func_to_func, mod, handler_info->cmd,
+				msg_info->msg_id);
+
 	/* Set the header message. */
 	header = HINIC3_MSG_HEADER_SET(MBOX_TLP_HEADER_SZ, MSG_LEN) |
 		 HINIC3_MSG_HEADER_SET(MBOX_TLP_HEADER_SZ, SEG_LEN) |
@@ -873,6 +900,7 @@ hinic3_mbox_to_func(struct hinic3_mbox *func_to_func, enum hinic3_mod_type mod,
 		goto send_err;
 	}
 
+	func_to_func->mbox_send_cnt++;
 	/* Wait for the response message. */
 	time = timeout ? timeout : HINIC3_MBOX_COMP_TIME;
 	aeq = &func_to_func->hwdev->aeqs->aeq[HINIC3_MBOX_RSP_MSG_AEQ];
@@ -884,6 +912,7 @@ hinic3_mbox_to_func(struct hinic3_mbox *func_to_func, enum hinic3_mod_type mod,
 		goto send_err;
 	}
 
+	func_to_func->mbox_ack_cnt++;
 	/* Check whether mod and command of the rsp message match the sent message. */
 	if (mod != mbox_for_resp->mod || handler_info->cmd != mbox_for_resp->cmd) {
 		PMD_DRV_LOG(ERR,
@@ -917,6 +946,8 @@ hinic3_mbox_to_func(struct hinic3_mbox *func_to_func, enum hinic3_mod_type mod,
 		*handler_info->out_size = mbox_for_resp->mbox_len;
 	}
 send_err:
+	if (err != 0)
+		func_to_func->mbox_error = true;
 	return err;
 }
 
@@ -1129,6 +1160,16 @@ hinic3_func_to_func_init(struct hinic3_hwdev *hwdev)
 
 	hwdev->func_to_func = func_to_func;
 	func_to_func->hwdev = hwdev;
+
+	struct save_mbox_info *save_mbox = rte_zmalloc("save_mbox_info",
+						      sizeof(struct save_mbox_info), 0);
+	if (!save_mbox) {
+		err = -ENOMEM;
+		goto alloc_save_mbox_err;
+	}
+
+	func_to_func->save_mbox = save_mbox;
+
 	rte_spinlock_init(&func_to_func->mbox_lock);
 
 	/* Alloc the memory required by the mailbox. */
@@ -1170,6 +1211,9 @@ hinic3_func_to_func_init(struct hinic3_hwdev *hwdev)
 	free_mbox_info(func_to_func->mbox_send);
 
 alloc_mbox_for_send_err:
+	rte_free(save_mbox);
+alloc_save_mbox_err:
+	hwdev->func_to_func = NULL;
 	rte_free(func_to_func);
 
 	return err;
@@ -1184,5 +1228,6 @@ hinic3_func_to_func_free(struct hinic3_hwdev *hwdev)
 	free_mbox_tlp_buffer(func_to_func);
 	free_mbox_info(func_to_func->mbox_resp);
 	free_mbox_info(func_to_func->mbox_send);
+	rte_free(func_to_func->save_mbox);
 	rte_free(func_to_func);
 }
diff --git a/drivers/net/hinic3/base/hinic3_mbox.h b/drivers/net/hinic3/base/hinic3_mbox.h
index df6de062e2..8797c19697 100644
--- a/drivers/net/hinic3/base/hinic3_mbox.h
+++ b/drivers/net/hinic3/base/hinic3_mbox.h
@@ -15,6 +15,8 @@
 
 #define HINIC3_MAX_PF_FUNCS 32
 
+#define HINIC3_MBOX_SAVE_NUM          20
+
 /* Message header define. */
 #define HINIC3_MSG_HEADER_SRC_GLB_FUNC_IDX_SHIFT 0
 #define HINIC3_MSG_HEADER_STATUS_SHIFT		 13
@@ -150,8 +152,21 @@ enum hinic3_mbox_cb_state {
 	HINIC3_PPF_TO_PF_MBOX_CB_RUNNING
 };
 
+struct mbox_send_info {
+	uint16_t cmd;
+	enum hinic3_mod_type mod;
+	uint8_t send_msg_id;
+};
+
+struct save_mbox_info {
+	struct mbox_send_info send_info[HINIC3_MBOX_SAVE_NUM];
+	uint8_t start;
+	uint8_t count;
+};
+
 struct hinic3_mbox {
 	struct hinic3_hwdev *hwdev;
+	struct save_mbox_info *save_mbox;
 
 	struct hinic3_send_mbox send_mbox;
 
@@ -163,6 +178,10 @@ struct hinic3_mbox {
 	enum mbox_event_state event_flag;
 	/* Lock for mbox event flag. */
 	rte_spinlock_t mbox_lock;
+
+	uint64_t mbox_send_cnt;
+	uint64_t mbox_ack_cnt;
+	bool mbox_error;
 };
 
 int hinic3_mbox_func_aeqe_handler(struct hinic3_hwdev *hwdev, uint8_t *header,
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index ef0ac1fdcd..4f337791fc 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -10,6 +10,7 @@
 #include "base/hinic3_eqs.h"
 #include "base/hinic3_cmdq.h"
 #include "base/hinic3_hwdev.h"
+#include "base/hinic3_mbox.h"
 #include "base/hinic3_hwif.h"
 #include "base/hinic3_hw_cfg.h"
 #include "base/hinic3_hw_comm.h"
@@ -3571,6 +3572,32 @@ hinic3_fec_capability_get(struct rte_eth_dev *dev,
 	return HINIC3_FEC_CAPA_NUM_PER_SPEED;
 }
 
+static int
+hinic3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
+{
+	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+	struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
+	struct hinic3_hwdev *hwdev;
+
+	if (file == NULL)
+		return -EINVAL;
+
+	hwdev = nic_dev->hwdev;
+	if (hwdev == NULL || hwdev->func_to_func == NULL)
+		return 0;
+
+	fprintf(file, "mbox_send_cnt: %" PRIu64 "\n",
+		hwdev->func_to_func->mbox_send_cnt);
+	fprintf(file, "mbox_ack_cnt: %" PRIu64 "\n",
+		hwdev->func_to_func->mbox_ack_cnt);
+
+	hinic3_dump_aeq_info(hwdev, file);
+	if (hwdev->func_to_func->mbox_error)
+		hinic3_dump_aeq_mbox_info(hwdev, pci_dev, file);
+
+	return 0;
+}
+
 static const struct eth_dev_ops hinic3_pmd_ops = {
 	.dev_configure                 = hinic3_dev_configure,
 	.dev_infos_get                 = hinic3_dev_infos_get,
@@ -3620,6 +3647,7 @@ static const struct eth_dev_ops hinic3_pmd_ops = {
 	.fec_get_capability            = hinic3_fec_capability_get,
 	.fec_get                       = hinic3_fec_get,
 	.fec_set                       = hinic3_fec_set,
+	.eth_dev_priv_dump             = hinic3_eth_dev_priv_dump,
 };
 
 static const struct eth_dev_ops hinic3_pmd_vf_ops = {
@@ -3664,6 +3692,7 @@ static const struct eth_dev_ops hinic3_pmd_vf_ops = {
 	.mac_addr_add                  = hinic3_mac_addr_add,
 	.set_mc_addr_list              = hinic3_set_mc_addr_list,
 	.flow_ops_get                  = hinic3_dev_filter_ctrl,
+	.eth_dev_priv_dump             = hinic3_eth_dev_priv_dump,
 };
 
 static void hinic3_nic_tx_rx_ops_init(struct hinic3_nic_dev *nic_dev)
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 17/30] net/hinic3: add COS mask and COS map support
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (15 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 16/30] net/hinic3: add mbox message recording and debug dump Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 18/30] net/hinic3: add VF link state and promiscuous support Jiacheng Ye
                   ` (13 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Apply the firmware COS mask/map when setting up Tx queues so the configured
COS value selects the intended queue.

The VF default COS limit HINIC3_COS_NUM_MAX_HTN (4) only applies to the
HTN tile used by SP230, where the firmware cos_mask can select four
non-contiguous COS values for the NIC and cos_map[] maps every other COS
to default_cos. SP620 and SP560 assign all eight COS to the NIC, so drop
the clamp there.

Fixes: 9204b6b7bb1a ("net/hinic3: split new/old command queue operations")

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/rel_notes/release_26_11.rst   |  1 +
 drivers/net/hinic3/base/hinic3_hw_cfg.c  |  2 +
 drivers/net/hinic3/base/hinic3_hw_cfg.h  |  8 +++-
 drivers/net/hinic3/base/hinic3_nic_cfg.c |  2 +-
 drivers/net/hinic3/base/hinic3_nic_cfg.h |  1 -
 drivers/net/hinic3/hinic3_ethdev.c       | 59 +++++++++++++++++++++---
 drivers/net/hinic3/hinic3_ethdev.h       |  2 +
 7 files changed, 64 insertions(+), 11 deletions(-)

diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index e0d042f681..4ccc9ad5a7 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -133,6 +133,7 @@ New Features
   * Added vport statistics, including CIR drop, and VF link
     aggregation (LAG) support.
   * Added FEC mode get and set support.
+  * Added Class of Service (COS) mask and map support.
   * Added mailbox message counter reporting through the device private dump API.
 
 * **Updated Intel iavf driver.**
diff --git a/drivers/net/hinic3/base/hinic3_hw_cfg.c b/drivers/net/hinic3/base/hinic3_hw_cfg.c
index 8899f98515..e7971509d5 100644
--- a/drivers/net/hinic3/base/hinic3_hw_cfg.c
+++ b/drivers/net/hinic3/base/hinic3_hw_cfg.c
@@ -22,6 +22,8 @@ parse_pub_res_cap(struct service_cap *cap,
 	cap->chip_svc_type = cap->svc_type;
 
 	cap->cos_valid_bitmap = dev_cap->valid_cos_bitmap;
+	cap->cos_mask_mode = dev_cap->cos_mask_mode;
+	cap->cos_mask_bitmap = dev_cap->cos_mask_bitmap;
 	cap->flexq_en = dev_cap->flexq_en;
 
 	cap->host_total_function = dev_cap->host_total_func;
diff --git a/drivers/net/hinic3/base/hinic3_hw_cfg.h b/drivers/net/hinic3/base/hinic3_hw_cfg.h
index 46a9c9bf4b..62af1daa25 100644
--- a/drivers/net/hinic3/base/hinic3_hw_cfg.h
+++ b/drivers/net/hinic3/base/hinic3_hw_cfg.h
@@ -40,6 +40,8 @@ struct service_cap {
 
 	uint8_t flexq_en;
 	uint8_t cos_valid_bitmap;
+	uint8_t cos_mask_mode;
+	uint8_t cos_mask_bitmap;
 	uint16_t max_vf; /**< Max VF number that PF supported. */
 
 	struct nic_service_cap nic_cap; /**< NIC capability. */
@@ -80,9 +82,11 @@ struct hinic3_cfg_cmd_dev_cap {
 	uint8_t flexq_en;
 	uint8_t valid_cos_bitmap;
 	/* Reserved for func_valid_cos_bitmap. */
-	uint16_t rsvd_cos;
+	uint16_t rsvd_valid_cos[2];
+	uint8_t cos_mask_mode;
+	uint8_t cos_mask_bitmap;
 
-	uint32_t rsvd[11];
+	uint32_t rsvd[10];
 
 	/* l2nic */
 	uint16_t nic_max_sq_id;
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.c b/drivers/net/hinic3/base/hinic3_nic_cfg.c
index b6717f2990..531ac0ecf9 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.c
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.c
@@ -1492,7 +1492,7 @@ hinic3_vf_get_default_cos(struct hinic3_hwdev *hwdev, uint8_t *cos_id)
 		return -EIO;
 	}
 
-	*cos_id = vf_dcb.state.default_cos % HINIC3_COS_NUM_MAX_HTN;
+	*cos_id = vf_dcb.state.default_cos;
 
 	return 0;
 }
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.h b/drivers/net/hinic3/base/hinic3_nic_cfg.h
index 9458a576c4..b5d7ce07a1 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.h
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.h
@@ -23,7 +23,6 @@
 #define HINIC3_MIN_MTU_SIZE		256
 
 #define HINIC3_COS_NUM_MAX		8
-#define HINIC3_COS_NUM_MAX_HTN		4
 
 #define HINIC3_VLAN_TAG_SIZE	4
 #define HINIC3_ETH_OVERHEAD \
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 4f337791fc..325764dee4 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -76,6 +76,9 @@ enum hinic3_rx_mod {
 #define HINIC3_DEFAULT_RX_MODE \
 	(HINIC3_RX_MODE_UC | HINIC3_RX_MODE_MC | HINIC3_RX_MODE_BC)
 
+#define HINIC3_DEFAULT_COS_MASK		0x7
+#define HINIC3_DEFAULT_COS_MASK_BITMAP	0xff
+
 struct hinic3_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	uint32_t offset;
@@ -451,10 +454,8 @@ hinic3_deinit_mac_addr(struct rte_eth_dev *eth_dev)
 static int
 hinic3_pf_get_default_cos(struct hinic3_hwdev *hwdev, uint8_t *cos_id)
 {
-	struct hinic3_nic_dev *nic_dev = hwdev->dev_handle;
 	uint8_t default_cos = 0;
 	uint8_t valid_cos_bitmap;
-	uint8_t cos_num_max;
 	uint8_t i;
 
 	valid_cos_bitmap = hwdev->cfg_mgmt->svc_cap.cos_valid_bitmap;
@@ -463,10 +464,7 @@ hinic3_pf_get_default_cos(struct hinic3_hwdev *hwdev, uint8_t *cos_id)
 		return -EFAULT;
 	}
 
-	cos_num_max = nic_dev->feature_cap & NIC_F_HTN_CMDQ ?
-		      HINIC3_COS_NUM_MAX_HTN : HINIC3_COS_NUM_MAX;
-
-	for (i = 0; i < cos_num_max; i++) {
+	for (i = 0; i < HINIC3_COS_NUM_MAX; i++) {
 		if (valid_cos_bitmap & RTE_BIT32(i))
 			/* Find max cos id as default cos. */
 			default_cos = i;
@@ -477,12 +475,53 @@ hinic3_pf_get_default_cos(struct hinic3_hwdev *hwdev, uint8_t *cos_id)
 	return 0;
 }
 
+static void
+hinic3_get_cos_mask(struct hinic3_hwdev *hwdev, uint8_t *cos_mask)
+{
+	uint8_t cos_mask_mode;
+
+	cos_mask_mode = hwdev->cfg_mgmt->svc_cap.cos_mask_mode;
+	if (!cos_mask_mode) {
+		*cos_mask = HINIC3_DEFAULT_COS_MASK; /* default: 8 COS*/
+		PMD_DRV_LOG(INFO,
+			"cos mask not provided by firmware, use default 0x%x",
+			HINIC3_DEFAULT_COS_MASK);
+		return;
+	}
+
+	*cos_mask = cos_mask_mode;
+}
+
+static void
+hinic3_get_cos_mask_bitmap(struct hinic3_nic_dev *nic_dev)
+{
+	int i;
+	uint8_t default_cos = 0;
+	uint8_t cos_mask_bitmap = nic_dev->hwdev->cfg_mgmt->svc_cap.cos_mask_bitmap == 0
+			? HINIC3_DEFAULT_COS_MASK_BITMAP
+			: nic_dev->hwdev->cfg_mgmt->svc_cap.cos_mask_bitmap;
+
+	PMD_DRV_LOG(INFO, "cos_mask_bitmap: 0x%x", cos_mask_bitmap);
+	for (i = HINIC3_COS_NUM_MAX - 1; i >= 0; i--) {
+		if (cos_mask_bitmap & RTE_BIT32(i)) {
+			default_cos = i;
+			break;
+		}
+	}
+
+	for (i = 0; i < HINIC3_COS_NUM_MAX; i++)
+		nic_dev->cos_map[i] = ((RTE_BIT32(i) & cos_mask_bitmap) == 0) ? default_cos : i;
+}
+
 static int
 hinic3_init_default_cos(struct hinic3_nic_dev *nic_dev)
 {
+	uint8_t cos_mask = 0;
 	uint8_t cos_id = 0;
 	int err;
 
+	hinic3_get_cos_mask(nic_dev->hwdev, &cos_mask);
+
 	if (!HINIC3_IS_VF(nic_dev->hwdev)) {
 		err = hinic3_pf_get_default_cos(nic_dev->hwdev, &cos_id);
 		if (err) {
@@ -497,8 +536,9 @@ hinic3_init_default_cos(struct hinic3_nic_dev *nic_dev)
 		}
 	}
 
+	nic_dev->cos_mask = cos_mask;
 	nic_dev->default_cos = cos_id;
-	PMD_DRV_LOG(DEBUG, "Default cos %d", nic_dev->default_cos);
+	PMD_DRV_LOG(DEBUG, "Default cos %d, cos mask %d", nic_dev->default_cos, nic_dev->cos_mask);
 	return 0;
 }
 
@@ -533,6 +573,7 @@ hinic3_set_default_hw_feature(struct hinic3_nic_dev *nic_dev)
 {
 	int err;
 
+	hinic3_get_cos_mask_bitmap(nic_dev);
 	err = hinic3_init_default_cos(nic_dev);
 	if (err)
 		return err;
@@ -1297,6 +1338,10 @@ hinic3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 	else
 		txq->cos = nic_dev->default_cos;
 
+	if (HINIC3_IS_SP230_NIC(nic_dev))
+		txq->cos = nic_dev->cos_map[txq->cos &
+			(HINIC3_COS_NUM_MAX - 1) & nic_dev->cos_mask];
+
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
 	txq->tx_wqe_compact_task = HINIC3_SUPPORT_TX_WQE_COMPACT_TASK(nic_dev);
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index c3384e5fd0..935b7719ca 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -133,6 +133,7 @@ struct hinic3_nic_dev {
 	uint8_t rx_queue_list[HINIC3_MAX_QUEUE_NUM];
 	rte_spinlock_t queue_list_lock;
 
+	uint32_t cos_mask;
 	uint32_t default_cos;
 	uint32_t rx_csum_en;
 
@@ -155,6 +156,7 @@ struct hinic3_nic_dev {
 	struct hinic3_tcam_info tcam;
 	struct hinic3_ethertype_filter_list filter_ethertype_list;
 	struct hinic3_fdir_rule_filter_list filter_fdir_rule_list;
+	uint8_t cos_map[HINIC3_COS_NUM_MAX];
 	struct hinic3_nic_cmdq_ops *cmdq_ops;
 	struct hinic3_nic_rx_ops *rx_ops;
 	struct hinic3_nic_tx_ops *tx_ops;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 18/30] net/hinic3: add VF link state and promiscuous support
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (16 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 17/30] net/hinic3: add COS mask and COS map support Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 19/30] net/hinic3: convert cmdq ops to static global variables Jiacheng Ye
                   ` (12 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

VF link state followed the PF, so a VF could not be brought down while
the PF stayed up. Track vf_valid_status and combine it with the physical
link when computing the VF link status.

Keep a separate admin_down flag, set only by dev_set_link_up/down, and
check it in hinic3_set_vport_state(), dev_start() and the VF link status
so a PF link-up event cannot re-enable a vport the application brought
down.

Register the promiscuous callback in the VF ethdev_ops.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/rel_notes/release_26_11.rst     |  1 +
 drivers/net/hinic3/base/hinic3_hwdev.h     |  3 +-
 drivers/net/hinic3/base/hinic3_nic_cfg.c   |  2 +
 drivers/net/hinic3/base/hinic3_nic_event.c |  9 ++-
 drivers/net/hinic3/hinic3_ethdev.c         | 71 +++++++++++++++++++---
 drivers/net/hinic3/hinic3_ethdev.h         |  2 +
 6 files changed, 78 insertions(+), 10 deletions(-)

diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 4ccc9ad5a7..13c62f71ac 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -134,6 +134,7 @@ New Features
     aggregation (LAG) support.
   * Added FEC mode get and set support.
   * Added Class of Service (COS) mask and map support.
+  * Added VF link up/down and promiscuous mode support.
   * Added mailbox message counter reporting through the device private dump API.
 
 * **Updated Intel iavf driver.**
diff --git a/drivers/net/hinic3/base/hinic3_hwdev.h b/drivers/net/hinic3/base/hinic3_hwdev.h
index c6661aa1a6..87ca18e571 100644
--- a/drivers/net/hinic3/base/hinic3_hwdev.h
+++ b/drivers/net/hinic3/base/hinic3_hwdev.h
@@ -157,7 +157,8 @@ struct hinic3_hwdev {
 	char mgmt_ver[MGMT_VERSION_MAX_LEN];
 
 	uint16_t max_vfs;
-	uint16_t link_status;
+	uint8_t link_status;
+	uint8_t vf_valid_status; /* vport_enable: 1, vport_disable: 0 */
 	uint64_t features[HINIC3_MAX_FEATURE_QWORD];
 };
 
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.c b/drivers/net/hinic3/base/hinic3_nic_cfg.c
index 531ac0ecf9..f65b071258 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.c
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.c
@@ -468,6 +468,8 @@ hinic3_set_vport_enable(struct hinic3_hwdev *hwdev, bool enable)
 		return -EIO;
 	}
 
+	hwdev->vf_valid_status = enable;
+
 	return 0;
 }
 
diff --git a/drivers/net/hinic3/base/hinic3_nic_event.c b/drivers/net/hinic3/base/hinic3_nic_event.c
index 981a5f5083..0fe7b54981 100644
--- a/drivers/net/hinic3/base/hinic3_nic_event.c
+++ b/drivers/net/hinic3/base/hinic3_nic_event.c
@@ -82,7 +82,8 @@ hinic3_set_vport_state(struct hinic3_hwdev *hwdev,
 	nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(hwdev->eth_dev);
 
 	if (link_state->state) {
-		if (hinic3_get_bit(HINIC3_DEV_START, &nic_dev->dev_status))
+		if (hinic3_get_bit(HINIC3_DEV_START, &nic_dev->dev_status) &&
+		    !nic_dev->admin_down)
 			err = hinic3_set_vport_enable(hwdev, true);
 	} else {
 		err = hinic3_set_vport_enable(hwdev, false);
@@ -111,6 +112,12 @@ link_status_event_handler(struct hinic3_hwdev *hwdev, struct hinic3_handler_info
 
 	/* Link event reported only after set vport enable. */
 	hinic3_get_link_port_info(hwdev, link_status->state, &link);
+
+	if (HINIC3_IS_VF(hwdev)) {
+		hwdev->link_status = link.link_status;
+		link.link_status = hwdev->link_status & hwdev->vf_valid_status;
+	}
+
 	err = rte_eth_linkstatus_set(hwdev->eth_dev, &link);
 	if (!err && hwdev->eth_dev->data->dev_conf.intr_conf.lsc != 0)
 		rte_eth_dev_callback_process(hwdev->eth_dev,
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 325764dee4..5c10bd3c47 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -821,6 +821,26 @@ hinic3_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
 	return 0;
 }
 
+/**
+ * Get the VF link status reported to the application.
+ *
+ * @param[in] nic_dev
+ * Pointer to the hinic3 NIC device.
+ *
+ * @return
+ * Link status of the VF, RTE_ETH_LINK_UP or RTE_ETH_LINK_DOWN.
+ */
+static uint8_t
+hinic3_vf_link_status(struct hinic3_nic_dev *nic_dev)
+{
+	struct hinic3_hwdev *hwdev = nic_dev->hwdev;
+
+	if (nic_dev->admin_down)
+		return RTE_ETH_LINK_DOWN;
+
+	return hwdev->link_status & hwdev->vf_valid_status;
+}
+
 /**
  * Set ethernet device link state up.
  *
@@ -834,8 +854,11 @@ static int
 hinic3_dev_set_link_up(struct rte_eth_dev *dev)
 {
 	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+	struct rte_eth_link link = { 0 };
 	int err;
 
+	nic_dev->admin_down = 0;
+
 	/*
 	 * Vport enable will set function valid in mpu.
 	 * So dev start status need to be checked before vport enable.
@@ -845,6 +868,7 @@ hinic3_dev_set_link_up(struct rte_eth_dev *dev)
 		if (err) {
 			PMD_DRV_LOG(ERR, "Enable vport failed, dev_name: %s",
 				    nic_dev->dev_name);
+			nic_dev->admin_down = 1;
 			return err;
 		}
 	}
@@ -855,9 +879,17 @@ hinic3_dev_set_link_up(struct rte_eth_dev *dev)
 		PMD_DRV_LOG(ERR,
 			    "Set MAC link up failed, dev_name: %s, port_id: %d",
 			    nic_dev->dev_name, dev->data->port_id);
+		nic_dev->admin_down = 1;
 		return err;
 	}
 
+	if (HINIC3_IS_VF(nic_dev->hwdev)) {
+		link = dev->data->dev_link;
+		link.link_status = hinic3_vf_link_status(nic_dev);
+
+		(void)rte_eth_linkstatus_set(dev, &link);
+	}
+
 	return 0;
 }
 
@@ -874,10 +906,14 @@ static int
 hinic3_dev_set_link_down(struct rte_eth_dev *dev)
 {
 	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+	struct rte_eth_link link = { 0 };
 	int err;
 
+	nic_dev->admin_down = 1;
+
 	err = hinic3_set_vport_enable(nic_dev->hwdev, false);
 	if (err) {
+		nic_dev->admin_down = 0;
 		PMD_DRV_LOG(ERR, "Disable vport failed, dev_name: %s",
 			    nic_dev->dev_name);
 		return err;
@@ -887,11 +923,18 @@ hinic3_dev_set_link_down(struct rte_eth_dev *dev)
 	err = hinic3_set_port_enable(nic_dev->hwdev, false);
 	if (err) {
 		PMD_DRV_LOG(ERR,
-			"Set MAC link down failed, dev_name: %s, port_id: %d",
-			nic_dev->dev_name, dev->data->port_id);
+			    "Set MAC link down failed, dev_name: %s, port_id: %d",
+			    nic_dev->dev_name, dev->data->port_id);
 		return err;
 	}
 
+	if (HINIC3_IS_VF(nic_dev->hwdev)) {
+		link = dev->data->dev_link;
+		link.link_status = hinic3_vf_link_status(nic_dev);
+
+		(void)rte_eth_linkstatus_set(dev, &link);
+	}
+
 	return 0;
 }
 
@@ -939,6 +982,13 @@ hinic3_link_update(struct rte_eth_dev *dev, int wait_to_complete)
 	} while (rep_cnt--);
 
 out:
+	if (HINIC3_IS_VF(nic_dev->hwdev)) {
+		if (ret == 0)
+			nic_dev->hwdev->link_status = link.link_status;
+		link.link_status = (ret == 0) ?
+			hinic3_vf_link_status(nic_dev) : RTE_ETH_LINK_DOWN;
+	}
+
 	return rte_eth_linkstatus_set(dev, &link);
 }
 
@@ -2125,12 +2175,13 @@ hinic3_dev_start(struct rte_eth_dev *eth_dev)
 
 	hinic3_start_all_sqs(eth_dev);
 
-	/* Open virtual port and ready to start packet receiving. */
-	err = hinic3_set_vport_enable(nic_dev->hwdev, true);
-	if (err) {
-		PMD_DRV_LOG(ERR, "Enable vport failed, dev_name: %s",
-			    eth_dev->data->name);
-		goto en_vport_fail;
+	if (!nic_dev->admin_down) {
+		err = hinic3_set_vport_enable(nic_dev->hwdev, true);
+		if (err) {
+			PMD_DRV_LOG(ERR, "Enable vport failed, dev_name: %s",
+				    eth_dev->data->name);
+			goto en_vport_fail;
+		}
 	}
 
 	/* Open physical port and start packet receiving. */
@@ -3699,6 +3750,8 @@ static const struct eth_dev_ops hinic3_pmd_vf_ops = {
 	.dev_configure                 = hinic3_dev_configure,
 	.dev_infos_get                 = hinic3_dev_infos_get,
 	.fw_version_get                = hinic3_fw_version_get,
+	.dev_set_link_up               = hinic3_dev_set_link_up,
+	.dev_set_link_down             = hinic3_dev_set_link_down,
 	.rx_queue_setup                = hinic3_rx_queue_setup,
 	.tx_queue_setup                = hinic3_tx_queue_setup,
 	.rx_queue_intr_enable          = hinic3_dev_rx_queue_intr_enable,
@@ -3720,6 +3773,8 @@ static const struct eth_dev_ops hinic3_pmd_vf_ops = {
 	.vlan_offload_set              = hinic3_vlan_offload_set,
 	.allmulticast_enable           = hinic3_dev_allmulticast_enable,
 	.allmulticast_disable          = hinic3_dev_allmulticast_disable,
+	.promiscuous_enable            = hinic3_dev_promiscuous_enable,
+	.promiscuous_disable           = hinic3_dev_promiscuous_disable,
 	.rss_hash_update               = hinic3_rss_hash_update,
 	.rss_hash_conf_get             = hinic3_rss_conf_get,
 	.reta_update                   = hinic3_rss_reta_update,
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index 935b7719ca..a078120794 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -141,6 +141,8 @@ struct hinic3_nic_dev {
 
 	RTE_ATOMIC(uint64_t)dev_status;
 
+	uint8_t admin_down; /**< Link down requested by dev_set_link_down(). */
+
 	uint8_t pause_set; /**< Flag of PAUSE frame setting. */
 	struct nic_pause_config nic_pause;
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 19/30] net/hinic3: convert cmdq ops to static global variables
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (17 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 18/30] net/hinic3: add VF link state and promiscuous support Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 20/30] net/hinic3: update RSS hash type configuration Jiacheng Ye
                   ` (11 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Replace the per-device dynamically allocated cmdq_ops with static global
instances (hinic3_htn_cmdq_ops and hinic3_stn_cmdq_ops), selected by the
NIC_F_HTN_CMDQ capability bit.

The old code allocated the block with rte_zmalloc() and then overwrote the
pointer with the static ops, leaking the allocation and passing a static
pointer to rte_free() on the error path. Nothing is allocated per device
now.

Fixes: 9204b6b7bb1a ("net/hinic3: split new/old command queue operations")
Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/base/hinic3_nic_cfg.c      |  7 ++--
 drivers/net/hinic3/hinic3_ethdev.c            | 34 ++++++++++---------
 drivers/net/hinic3/hinic3_ethdev.h            |  1 -
 drivers/net/hinic3/hinic3_nic_io.c            | 11 +++---
 drivers/net/hinic3/hinic3_nic_io.h            | 11 ++++++
 .../net/hinic3/htn_adapt/hinic3_htn_cmdq.c    | 21 +++++-------
 .../net/hinic3/htn_adapt/hinic3_htn_cmdq.h    |  6 ++--
 .../net/hinic3/stn_adapt/hinic3_stn_cmdq.c    | 23 +++++--------
 .../net/hinic3/stn_adapt/hinic3_stn_cmdq.h    |  6 ++--
 9 files changed, 62 insertions(+), 58 deletions(-)

diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.c b/drivers/net/hinic3/base/hinic3_nic_cfg.c
index f65b071258..c44ac1b083 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.c
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.c
@@ -1212,7 +1212,7 @@ hinic3_rss_get_indir_tbl(struct hinic3_hwdev *hwdev, uint32_t *indir_table)
 	cmd_buf->size = sizeof(struct nic_rss_indirect_tbl);
 	nic_dev = (struct hinic3_nic_dev *)hwdev->dev_handle;
 
-	cmd = nic_dev->cmdq_ops->prepare_cmd_buf_get_rss_indir_table(nic_dev, cmd_buf);
+	cmd = hinic3_cmdq_get_ops(nic_dev)->prepare_cmd_buf_get_rss_indir_table(nic_dev, cmd_buf);
 	err = hinic3_cmdq_detail_resp(hwdev, HINIC3_MOD_L2NIC, cmd, cmd_buf, cmd_buf, 0);
 	if (err) {
 		PMD_DRV_LOG(ERR, "Get rss indir table failed");
@@ -1220,7 +1220,7 @@ hinic3_rss_get_indir_tbl(struct hinic3_hwdev *hwdev, uint32_t *indir_table)
 		return err;
 	}
 
-	nic_dev->cmdq_ops->cmd_buf_to_rss_indir_table(cmd_buf, indir_table);
+	hinic3_cmdq_get_ops(nic_dev)->cmd_buf_to_rss_indir_table(cmd_buf, indir_table);
 
 	hinic3_free_cmd_buf(cmd_buf);
 	return 0;
@@ -1245,7 +1245,8 @@ hinic3_rss_set_indir_tbl(struct hinic3_hwdev *hwdev, const uint32_t *indir_table
 	}
 
 	nic_dev = (struct hinic3_nic_dev *)hwdev->dev_handle;
-	cmd = nic_dev->cmdq_ops->prepare_cmd_buf_set_rss_indir_table(nic_dev, indir_table, cmd_buf);
+	cmd = hinic3_cmdq_get_ops(nic_dev)->prepare_cmd_buf_set_rss_indir_table(nic_dev,
+		indir_table, cmd_buf);
 	err = hinic3_cmdq_direct_resp(hwdev, HINIC3_MOD_L2NIC, cmd, cmd_buf, &out_param, 0);
 	if (err || out_param != 0) {
 		PMD_DRV_LOG(ERR, "Set rss indir table failed");
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 5c10bd3c47..714533ea52 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -558,6 +558,24 @@ hinic3_get_nic_type(struct rte_pci_device *pci_dev)
 	}
 }
 
+/**
+ * Get cmdq ops for the given NIC device.
+ *
+ * @param[in] nic_dev
+ * Pointer to NIC device structure.
+ *
+ * @return
+ * Pointer to cmdq ops structure.
+ */
+const struct hinic3_nic_cmdq_ops *
+hinic3_cmdq_get_ops(struct hinic3_nic_dev *nic_dev)
+{
+	if ((hinic3_get_driver_feature(nic_dev) & NIC_F_HTN_CMDQ) != 0)
+		return &hinic3_htn_cmdq_ops;
+
+	return &hinic3_stn_cmdq_ops;
+}
+
 /**
  * Initialize Class of Service (CoS). For PF devices, it also sync the link
  * status with the physical port.
@@ -3868,13 +3886,6 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 		goto alloc_eth_addr_fail;
 	}
 
-	nic_dev->cmdq_ops = rte_zmalloc("cmdq_ops", sizeof(struct hinic3_nic_cmdq_ops), 0);
-	if (!nic_dev->cmdq_ops) {
-		PMD_DRV_LOG(ERR, "Allocate cmdq_ops memory failed");
-		err = -ENOMEM;
-		goto alloc_cmdq_ops_fail;
-	}
-
 	nic_dev->rx_ops = rte_zmalloc("rx_ops", sizeof(struct hinic3_nic_rx_ops), 0);
 	if (!nic_dev->rx_ops) {
 		PMD_DRV_LOG(ERR, "Allocate rx_ops memory failed");
@@ -3942,11 +3953,6 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 		goto get_cap_fail;
 	}
 
-	if (!(nic_dev->feature_cap & NIC_F_HTN_CMDQ))
-		nic_dev->cmdq_ops = hinic3_nic_cmdq_get_stn_ops();
-	else
-		nic_dev->cmdq_ops = hinic3_nic_cmdq_get_htn_ops();
-
 	hinic3_nic_tx_rx_ops_init(nic_dev);
 
 	err = hinic3_init_sw_rxtxqs(nic_dev);
@@ -4045,10 +4051,6 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 	nic_dev->rx_ops = NULL;
 
 alloc_rx_ops_fail:
-	rte_free(nic_dev->cmdq_ops);
-	nic_dev->cmdq_ops = NULL;
-
-alloc_cmdq_ops_fail:
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index a078120794..84f9b2db0e 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -159,7 +159,6 @@ struct hinic3_nic_dev {
 	struct hinic3_ethertype_filter_list filter_ethertype_list;
 	struct hinic3_fdir_rule_filter_list filter_fdir_rule_list;
 	uint8_t cos_map[HINIC3_COS_NUM_MAX];
-	struct hinic3_nic_cmdq_ops *cmdq_ops;
 	struct hinic3_nic_rx_ops *rx_ops;
 	struct hinic3_nic_tx_ops *tx_ops;
 	enum nic_type nic_type; /**< NIC type. */
diff --git a/drivers/net/hinic3/hinic3_nic_io.c b/drivers/net/hinic3/hinic3_nic_io.c
index 9203dcce40..361586868e 100644
--- a/drivers/net/hinic3/hinic3_nic_io.c
+++ b/drivers/net/hinic3/hinic3_nic_io.c
@@ -391,8 +391,8 @@ init_sq_ctxts(struct hinic3_nic_dev *nic_dev)
 		max_ctxts = (nic_dev->num_sqs - q_id) > HINIC3_Q_CTXT_MAX
 				    ? HINIC3_Q_CTXT_MAX
 				    : (nic_dev->num_sqs - q_id);
-		cmd = nic_dev->cmdq_ops->prepare_cmd_buf_qp_context_multi_store(nic_dev, cmd_buf,
-			HINIC3_QP_CTXT_TYPE_SQ, q_id, max_ctxts);
+		cmd = hinic3_cmdq_get_ops(nic_dev)->prepare_cmd_buf_qp_context_multi_store(nic_dev,
+			cmd_buf, HINIC3_QP_CTXT_TYPE_SQ, q_id, max_ctxts);
 		rte_atomic_thread_fence(rte_memory_order_seq_cst);
 		err = hinic3_cmdq_direct_resp(nic_dev->hwdev, HINIC3_MOD_L2NIC,
 					      cmd, cmd_buf, &out_param, 0);
@@ -443,8 +443,8 @@ init_rq_ctxts(struct hinic3_nic_dev *nic_dev)
 		max_ctxts = (nic_dev->num_rqs - q_id) > HINIC3_Q_CTXT_MAX
 				    ? HINIC3_Q_CTXT_MAX
 				    : (nic_dev->num_rqs - q_id);
-		cmd = nic_dev->cmdq_ops->prepare_cmd_buf_qp_context_multi_store(nic_dev, cmd_buf,
-			HINIC3_QP_CTXT_TYPE_RQ, q_id, max_ctxts);
+		cmd = hinic3_cmdq_get_ops(nic_dev)->prepare_cmd_buf_qp_context_multi_store(nic_dev,
+			cmd_buf, HINIC3_QP_CTXT_TYPE_RQ, q_id, max_ctxts);
 		rte_atomic_thread_fence(rte_memory_order_seq_cst);
 		err = hinic3_cmdq_direct_resp(nic_dev->hwdev, HINIC3_MOD_L2NIC,
 					      cmd, cmd_buf, &out_param, 0);
@@ -491,7 +491,8 @@ clean_queue_offload_ctxt(struct hinic3_nic_dev *nic_dev,
 		return -ENOMEM;
 	}
 
-	cmd = nic_dev->cmdq_ops->prepare_cmd_buf_clean_tso_lro_space(nic_dev, cmd_buf, ctxt_type);
+	cmd = hinic3_cmdq_get_ops(nic_dev)->prepare_cmd_buf_clean_tso_lro_space(nic_dev,
+		cmd_buf, ctxt_type);
 
 	/* Send a command to hardware to clean up queue offload context. */
 	err = hinic3_cmdq_direct_resp(nic_dev->hwdev, HINIC3_MOD_L2NIC,
diff --git a/drivers/net/hinic3/hinic3_nic_io.h b/drivers/net/hinic3/hinic3_nic_io.h
index e1741d1156..d7ec81f2e6 100644
--- a/drivers/net/hinic3/hinic3_nic_io.h
+++ b/drivers/net/hinic3/hinic3_nic_io.h
@@ -79,6 +79,17 @@ struct hinic3_nic_cmdq_ops {
 	cmd_buf_to_rss_indir_table_t			cmd_buf_to_rss_indir_table;
 };
 
+/**
+ * Get cmdq ops for the given NIC device.
+ *
+ * @param[in] nic_dev
+ * Pointer to NIC device structure.
+ *
+ * @return
+ * Pointer to cmdq ops structure.
+ */
+const struct hinic3_nic_cmdq_ops *hinic3_cmdq_get_ops(struct hinic3_nic_dev *nic_dev);
+
 /* Doorbell info. */
 struct hinic3_db {
 	uint32_t db_info;
diff --git a/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.c b/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.c
index 634dfe7239..607fe2d0fe 100644
--- a/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.c
+++ b/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.c
@@ -152,16 +152,11 @@ static void cmd_buf_to_rss_indir_table(const struct hinic3_cmd_buf *cmd_buf, uin
 		indir_table[i] = *(indir_tbl + i);
 }
 
-struct hinic3_nic_cmdq_ops *hinic3_nic_cmdq_get_htn_ops(void)
-{
-	static struct hinic3_nic_cmdq_ops cmdq_ops = {
-		.prepare_cmd_buf_clean_tso_lro_space =    prepare_cmd_buf_clean_tso_lro_space,
-		.prepare_cmd_buf_qp_context_multi_store = prepare_cmd_buf_qp_context_multi_store,
-		.prepare_cmd_buf_modify_svlan =           prepare_cmd_buf_modify_svlan,
-		.prepare_cmd_buf_set_rss_indir_table =    prepare_cmd_buf_set_rss_indir_table,
-		.prepare_cmd_buf_get_rss_indir_table =    prepare_cmd_buf_get_rss_indir_table,
-		.cmd_buf_to_rss_indir_table =             cmd_buf_to_rss_indir_table,
-	};
-
-	return &cmdq_ops;
-}
+const struct hinic3_nic_cmdq_ops hinic3_htn_cmdq_ops = {
+	.prepare_cmd_buf_clean_tso_lro_space =    prepare_cmd_buf_clean_tso_lro_space,
+	.prepare_cmd_buf_qp_context_multi_store = prepare_cmd_buf_qp_context_multi_store,
+	.prepare_cmd_buf_modify_svlan =           prepare_cmd_buf_modify_svlan,
+	.prepare_cmd_buf_set_rss_indir_table =    prepare_cmd_buf_set_rss_indir_table,
+	.prepare_cmd_buf_get_rss_indir_table =    prepare_cmd_buf_get_rss_indir_table,
+	.cmd_buf_to_rss_indir_table =             cmd_buf_to_rss_indir_table,
+};
diff --git a/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.h b/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.h
index 73f4922734..158cbc5f8e 100644
--- a/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.h
+++ b/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.h
@@ -53,11 +53,11 @@ struct hinic3_htn_vlan_ctx {
 };
 
 /**
- * Get cmdq ops hardware tile NIC(htn) supported.
+ * Cmdq ops hardware tile NIC(htn) supported.
  *
  * @return
- * Pointer to ops.
+ * Ops.
  */
-struct hinic3_nic_cmdq_ops *hinic3_nic_cmdq_get_htn_ops(void);
+extern const struct hinic3_nic_cmdq_ops hinic3_htn_cmdq_ops;
 
 #endif /* _HINIC3_HTN_CMDQ_H_ */
diff --git a/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.c b/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.c
index f41f060d17..23adbc79f4 100644
--- a/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.c
+++ b/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.c
@@ -108,7 +108,7 @@ static uint8_t prepare_cmd_buf_set_rss_indir_table(struct hinic3_nic_dev *nic_de
 
 	for (i = 0; i < HINIC3_RSS_INDIR_SIZE; i++)
 		indir_tbl->entry[i] = (uint16_t)(*(indir_table + i));
-	size = sizeof(indir_tbl->entry) / 4;
+	size = (size_t)sizeof(indir_tbl->entry) / sizeof(uint32_t);
 	temp = (uint32_t *)indir_tbl->entry;
 	for (i = 0; i < size; i++) {
 		rte_atomic_thread_fence(rte_memory_order_seq_cst);
@@ -136,16 +136,11 @@ static void cmd_buf_to_rss_indir_table(const struct hinic3_cmd_buf *cmd_buf, uin
 		indir_table[i] = *(indir_tbl + i);
 }
 
-struct hinic3_nic_cmdq_ops *hinic3_nic_cmdq_get_stn_ops(void)
-{
-	static struct hinic3_nic_cmdq_ops cmdq_ops = {
-		.prepare_cmd_buf_clean_tso_lro_space =    prepare_cmd_buf_clean_tso_lro_space,
-		.prepare_cmd_buf_qp_context_multi_store = prepare_cmd_buf_qp_context_multi_store,
-		.prepare_cmd_buf_modify_svlan =           prepare_cmd_buf_modify_svlan,
-		.prepare_cmd_buf_set_rss_indir_table =    prepare_cmd_buf_set_rss_indir_table,
-		.prepare_cmd_buf_get_rss_indir_table =    prepare_cmd_buf_get_rss_indir_table,
-		.cmd_buf_to_rss_indir_table =             cmd_buf_to_rss_indir_table,
-	};
-
-	return &cmdq_ops;
-}
+const struct hinic3_nic_cmdq_ops hinic3_stn_cmdq_ops = {
+	.prepare_cmd_buf_clean_tso_lro_space =    prepare_cmd_buf_clean_tso_lro_space,
+	.prepare_cmd_buf_qp_context_multi_store = prepare_cmd_buf_qp_context_multi_store,
+	.prepare_cmd_buf_modify_svlan =           prepare_cmd_buf_modify_svlan,
+	.prepare_cmd_buf_set_rss_indir_table =    prepare_cmd_buf_set_rss_indir_table,
+	.prepare_cmd_buf_get_rss_indir_table =    prepare_cmd_buf_get_rss_indir_table,
+	.cmd_buf_to_rss_indir_table =             cmd_buf_to_rss_indir_table,
+};
diff --git a/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.h b/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.h
index f1720c29c7..ab1c73a977 100644
--- a/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.h
+++ b/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.h
@@ -36,11 +36,11 @@ struct hinic3_stn_vlan_ctx {
 };
 
 /**
- * Get cmdq ops software tile NIC(stn) supported.
+ * Cmdq ops software tile NIC(stn) supported.
  *
  * @return
- * Pointer to ops.
+ * Ops.
  */
-struct hinic3_nic_cmdq_ops *hinic3_nic_cmdq_get_stn_ops(void);
+extern const struct hinic3_nic_cmdq_ops hinic3_stn_cmdq_ops;
 
 #endif /* _HINIC3_STN_CMDQ_H_ */
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 20/30] net/hinic3: update RSS hash type configuration
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (18 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 19/30] net/hinic3: convert cmdq ops to static global variables Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 21/30] net/hinic3: refactor flow rule parsing Jiacheng Ye
                   ` (10 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

The aggregated compact CQE does not expose a readable RSS hash flags
field. To keep the behavior consistent with the normal CQE path, derive
the mbuf RSS flags from the software configured rss_hf instead.

Cache the RSS enablement in struct hinic3_rxq, refresh it when a runtime
RSS update changes rss_type, and clear rss_type when RSS is disabled so a
reconfigure without RSS after stop does not use a stale hash setting for
RTE_MBUF_F_RX_RSS_HASH. The flag is written by the control path and read
by the Rx path, so use relaxed atomics.

ipv6_ext and tcp_ipv6_ext are supported on all tiles, so set them from
rss_hf rather than gating them on the HTN cmdq flag.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/rel_notes/release_26_11.rst   |  1 +
 drivers/net/hinic3/base/hinic3_nic_cfg.h | 21 +++++++----
 drivers/net/hinic3/hinic3_ethdev.c       | 27 +++++++------
 drivers/net/hinic3/hinic3_ethdev.h       |  2 +
 drivers/net/hinic3/hinic3_rx.c           | 48 +++++++++++++++++++-----
 drivers/net/hinic3/hinic3_rx.h           |  9 +++++
 6 files changed, 77 insertions(+), 31 deletions(-)

diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 13c62f71ac..7bcb6a9d43 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -135,6 +135,7 @@ New Features
   * Added FEC mode get and set support.
   * Added Class of Service (COS) mask and map support.
   * Added VF link up/down and promiscuous mode support.
+  * Updated RSS hash type configuration.
   * Added mailbox message counter reporting through the device private dump API.
 
 * **Updated Intel iavf driver.**
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.h b/drivers/net/hinic3/base/hinic3_nic_cfg.h
index b5d7ce07a1..8c48f6d8a9 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.h
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.h
@@ -72,14 +72,19 @@
 	HINIC3_SUPPORT_FEATURE(dev, IPXIP_OFFLOAD)
 
 struct hinic3_rss_type {
-	uint8_t tcp_ipv6_ext;
-	uint8_t ipv6_ext;
-	uint8_t tcp_ipv6;
-	uint8_t ipv6;
-	uint8_t tcp_ipv4;
-	uint8_t ipv4;
-	uint8_t udp_ipv6;
-	uint8_t udp_ipv4;
+	union {
+		struct {
+			uint8_t tcp_ipv6_ext;
+			uint8_t ipv6_ext;
+			uint8_t tcp_ipv6;
+			uint8_t ipv6;
+			uint8_t tcp_ipv4;
+			uint8_t ipv4;
+			uint8_t udp_ipv6;
+			uint8_t udp_ipv4;
+		};
+		uint64_t val;
+	};
 };
 
 enum hinic3_rss_hash_type {
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 714533ea52..2ffebddf3a 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -1032,6 +1032,8 @@ hinic3_reset_rx_queue(struct rte_eth_dev *dev)
 		rxq->prod_idx = 0;
 		rxq->delta = rxq->q_depth;
 		rxq->next_to_update = 0;
+		rte_atomic_store_explicit(&rxq->rss_en, 0,
+					  rte_memory_order_relaxed);
 
 		/*
 		 * Hardware does not clear the CI write-back memory on reset, so
@@ -1816,6 +1818,7 @@ hinic3_remove_rxtx_configure(struct rte_eth_dev *dev)
 		hinic3_rss_cfg(nic_dev->hwdev, HINIC3_RSS_DISABLE, 0, prio_tc);
 		hinic3_rss_template_free(nic_dev->hwdev);
 		nic_dev->rss_state = HINIC3_RSS_DISABLE;
+		nic_dev->rss_type.val = 0;
 	}
 }
 
@@ -2785,20 +2788,18 @@ hinic3_rss_hash_update(struct rte_eth_dev *dev,
 	rss_type.tcp_ipv6 = (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_TCP) ? 1 : 0;
 	rss_type.udp_ipv4 = (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_UDP) ? 1 : 0;
 	rss_type.udp_ipv6 = (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_UDP) ? 1 : 0;
-
-	if (nic_dev->feature_cap & NIC_F_HTN_CMDQ) {
-		rss_type.ipv6_ext = (rss_hf & RTE_ETH_RSS_IPV6_EX) ? 1 : 0;
-		rss_type.tcp_ipv6_ext = (rss_hf & RTE_ETH_RSS_IPV6_TCP_EX) ? 1 : 0;
-	} else {
-		rss_type.ipv6_ext = 0;
-		rss_type.tcp_ipv6_ext = 0;
-	}
+	rss_type.ipv6_ext = (rss_hf & RTE_ETH_RSS_IPV6_EX) ? 1 : 0;
+	rss_type.tcp_ipv6_ext = (rss_hf & RTE_ETH_RSS_IPV6_TCP_EX) ? 1 : 0;
 
 	err = hinic3_set_rss_type(nic_dev->hwdev, rss_type);
-	if (err)
+	if (err) {
 		PMD_DRV_LOG(ERR, "Set RSS type failed");
+		return err;
+	}
 
-	return err;
+	nic_dev->rss_type = rss_type;
+	hinic3_rxq_rss_en_update(dev);
+	return 0;
 }
 
 /**
@@ -2853,10 +2854,8 @@ hinic3_rss_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf)
 	rss_conf->rss_hf |= rss_type.tcp_ipv6 ? RTE_ETH_RSS_NONFRAG_IPV6_TCP : 0;
 	rss_conf->rss_hf |= rss_type.udp_ipv4 ? RTE_ETH_RSS_NONFRAG_IPV4_UDP : 0;
 	rss_conf->rss_hf |= rss_type.udp_ipv6 ? RTE_ETH_RSS_NONFRAG_IPV6_UDP : 0;
-	if (nic_dev->feature_cap & NIC_F_HTN_CMDQ) {
-		rss_conf->rss_hf |= rss_type.ipv6_ext ? RTE_ETH_RSS_IPV6_EX : 0;
-		rss_conf->rss_hf |= rss_type.tcp_ipv6_ext ? RTE_ETH_RSS_IPV6_TCP_EX : 0;
-	}
+	rss_conf->rss_hf |= rss_type.ipv6_ext ? RTE_ETH_RSS_IPV6_EX : 0;
+	rss_conf->rss_hf |= rss_type.tcp_ipv6_ext ? RTE_ETH_RSS_IPV6_TCP_EX : 0;
 
 	return 0;
 }
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index 84f9b2db0e..13c9c69e7f 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -9,6 +9,7 @@
 #include <rte_ethdev_core.h>
 
 #include "hinic3_fdir.h"
+#include "base/hinic3_nic_cfg.h"
 
 #define HINIC3_PMD_DRV_VERSION "B106"
 
@@ -130,6 +131,7 @@ struct hinic3_nic_dev {
 	uint16_t num_rss; /**< Number of RSS queues. */
 
 	uint32_t rx_mode;
+	struct hinic3_rss_type rss_type;
 	uint8_t rx_queue_list[HINIC3_MAX_QUEUE_NUM];
 	rte_spinlock_t queue_list_lock;
 
diff --git a/drivers/net/hinic3/hinic3_rx.c b/drivers/net/hinic3/hinic3_rx.c
index 90681ce15c..74dfddac9d 100644
--- a/drivers/net/hinic3/hinic3_rx.c
+++ b/drivers/net/hinic3/hinic3_rx.c
@@ -437,17 +437,15 @@ hinic3_init_rss_type(struct hinic3_nic_dev *nic_dev,
 	rss_type.tcp_ipv6 = (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_TCP) ? 1 : 0;
 	rss_type.udp_ipv4 = (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_UDP) ? 1 : 0;
 	rss_type.udp_ipv6 = (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_UDP) ? 1 : 0;
-
-	if (nic_dev->feature_cap & NIC_F_HTN_CMDQ) {
-		rss_type.ipv6_ext = (rss_hf & RTE_ETH_RSS_IPV6_EX) ? 1 : 0;
-		rss_type.tcp_ipv6_ext = (rss_hf & RTE_ETH_RSS_IPV6_TCP_EX) ? 1 : 0;
-	} else {
-		rss_type.ipv6_ext = 0;
-		rss_type.tcp_ipv6_ext = 0;
-	}
+	rss_type.ipv6_ext = (rss_hf & RTE_ETH_RSS_IPV6_EX) ? 1 : 0;
+	rss_type.tcp_ipv6_ext = (rss_hf & RTE_ETH_RSS_IPV6_TCP_EX) ? 1 : 0;
 
 	err = hinic3_set_rss_type(nic_dev->hwdev, rss_type);
-	return err;
+	if (err)
+		return err;
+
+	nic_dev->rss_type = rss_type;
+	return 0;
 }
 
 int
@@ -502,6 +500,8 @@ hinic3_update_rss_config(struct rte_eth_dev *dev,
 	return 0;
 
 init_rss_fail:
+	nic_dev->rss_type.val = 0;
+
 	if (hinic3_rss_template_free(nic_dev->hwdev))
 		PMD_DRV_LOG(WARNING, "Free rss template failed");
 
@@ -701,6 +701,8 @@ hinic3_stop_rq(struct rte_eth_dev *eth_dev, struct hinic3_rxq *rxq)
 	uint32_t head_ci, head_done;
 	int err;
 
+	rte_atomic_store_explicit(&rxq->rss_en, 0, rte_memory_order_relaxed);
+
 	/* Disable rxq intr. */
 	hinic3_dev_rx_queue_intr_disable(eth_dev, rxq->q_id);
 
@@ -779,6 +781,11 @@ hinic3_start_rq(struct rte_eth_dev *eth_dev, struct hinic3_rxq *rxq)
 	struct hinic3_nic_dev *nic_dev = rxq->nic_dev;
 	int err = 0;
 
+	rte_atomic_store_explicit(&rxq->rss_en,
+				  (nic_dev->rss_state == HINIC3_RSS_ENABLE) &&
+				  (nic_dev->rss_type.val != 0),
+				  rte_memory_order_relaxed);
+
 	/* Lock dev queue switch.  */
 	rte_spinlock_lock(&nic_dev->queue_list_lock);
 	hinic3_add_rq_to_rx_queue_list(nic_dev, rxq->q_id);
@@ -921,6 +928,23 @@ hinic3_recv_jumbo_pkt(struct hinic3_rxq *rxq, struct rte_mbuf *head_mbuf,
 	}
 }
 
+void
+hinic3_rxq_rss_en_update(struct rte_eth_dev *eth_dev)
+{
+	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
+	uint8_t rss_en = (nic_dev->rss_state == HINIC3_RSS_ENABLE) &&
+			 (nic_dev->rss_type.val != 0);
+	uint16_t i;
+
+	for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
+		struct hinic3_rxq *rxq = eth_dev->data->rx_queues[i];
+
+		if (rxq != NULL)
+			rte_atomic_store_explicit(&rxq->rss_en, rss_en,
+						  rte_memory_order_relaxed);
+	}
+}
+
 int
 hinic3_start_all_rqs(struct rte_eth_dev *eth_dev)
 {
@@ -933,6 +957,10 @@ hinic3_start_all_rqs(struct rte_eth_dev *eth_dev)
 
 	for (i = 0; i < nic_dev->num_rqs; i++) {
 		rxq = eth_dev->data->rx_queues[i];
+		rte_atomic_store_explicit(&rxq->rss_en,
+					  (nic_dev->rss_state == HINIC3_RSS_ENABLE) &&
+					  (nic_dev->rss_type.val != 0),
+					  rte_memory_order_relaxed);
 		hinic3_add_rq_to_rx_queue_list(nic_dev, rxq->q_id);
 		err = hinic3_rearm_rxq_mbuf(rxq);
 		if (err) {
@@ -1056,6 +1084,8 @@ hinic3_rx_get_compact_cqe_info(struct hinic3_rxq *rxq, volatile struct hinic3_rq
 	cqe_info->pkt_len = HINIC3_RQ_COMPACT_CQE_STATUS_GET(dw0, PKT_LEN);
 	cqe_info->ts_flag = HINIC3_RQ_COMPACT_CQE_STATUS_GET(dw0, TS_FLAG);
 	cqe_info->ptype = HINIC3_RQ_COMPACT_CQE_STATUS_GET(dw0, PTYPE);
+	cqe_info->rss_type = rte_atomic_load_explicit(&rxq->rss_en,
+						      rte_memory_order_relaxed);
 	cqe_info->rss_hash_value = dw1;
 
 	if (cqe_info->cqe_len == HINIC3_RQ_COMPACT_CQE_16BYTE) {
diff --git a/drivers/net/hinic3/hinic3_rx.h b/drivers/net/hinic3/hinic3_rx.h
index 129c2b4a59..59a198c070 100644
--- a/drivers/net/hinic3/hinic3_rx.h
+++ b/drivers/net/hinic3/hinic3_rx.h
@@ -5,6 +5,8 @@
 #ifndef _HINIC3_RX_H_
 #define _HINIC3_RX_H_
 
+#include <rte_stdatomic.h>
+
 #define RQ_CQE_OFFOLAD_TYPE_PTYPE_OFFLOAD_SHIFT	0
 #define RQ_CQE_OFFOLAD_TYPE_VLAN_EN_SHIFT	21
 #define RQ_CQE_OFFOLAD_TYPE_RSS_TYPE_SHIFT	24
@@ -358,6 +360,12 @@ struct __rte_cache_aligned hinic3_rxq {
 	rte_iova_t cqe_start_paddr;
 	void *cqe_start_vaddr;
 	uint8_t dp_intr_en;
+	/**
+	 * RSS was enabled when this queue was started. Written by the
+	 * control path and read by the Rx data path, so it is accessed with
+	 * relaxed atomics.
+	 */
+	RTE_ATOMIC(uint8_t)rss_en;
 	uint16_t msix_entry_idx;
 
 	bool rx_deferred_start; /* don't start this queue in dev start */
@@ -421,6 +429,7 @@ void hinic3_init_rx_queue_list(struct hinic3_nic_dev *nic_dev);
 void hinic3_remove_rq_from_rx_queue_list(struct hinic3_nic_dev *nic_dev,
 					 uint16_t queue_id);
 int hinic3_start_all_rqs(struct rte_eth_dev *eth_dev);
+void hinic3_rxq_rss_en_update(struct rte_eth_dev *eth_dev);
 
 #ifdef HINIC3_XSTAT_RXBUF_INFO
 void hinic3_get_stats(struct hinic3_rxq *rxq);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 21/30] net/hinic3: refactor flow rule parsing
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (19 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 20/30] net/hinic3: update RSS hash type configuration Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 22/30] net/hinic3: add SP560 NIC type identification and handling Jiacheng Ye
                   ` (9 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

The flow rule parser was based on a fixed hardcoded pattern table that was
hard to extend. Replace it with a protocol-graph classifier and add
IP-in-IP, Geneve and VXLAN-GPE tunnel patterns.

The STN dynamic TCAM limit is raised from 1024 to 2048,
RTE_ETHER_TYPE_CNM and RTE_ETHER_TYPE_ECP are accepted, and rules with
multiple actions are rejected.

The TCAM does not support VLAN matching, so the vlan_flag mask/value pairs
in the key were meaningless and are removed. A rule now matches both tagged
and untagged packets.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/nics/features/hinic3.ini    |   2 +
 doc/guides/rel_notes/release_26_11.rst |   2 +
 drivers/net/hinic3/hinic3_fdir.c       |  48 +--
 drivers/net/hinic3/hinic3_fdir.h       |   8 +-
 drivers/net/hinic3/hinic3_flow.c       | 575 ++++++++++++++++++-------
 drivers/net/hinic3/hinic3_flow.h       | 196 ---------
 6 files changed, 451 insertions(+), 380 deletions(-)
 delete mode 100644 drivers/net/hinic3/hinic3_flow.h

diff --git a/doc/guides/nics/features/hinic3.ini b/doc/guides/nics/features/hinic3.ini
index dc4a92fc41..81c3e85410 100644
--- a/doc/guides/nics/features/hinic3.ini
+++ b/doc/guides/nics/features/hinic3.ini
@@ -42,12 +42,14 @@ ARMv8                = Y
 [rte_flow items]
 any                  = Y
 eth                  = P
+geneve               = Y
 icmp                 = Y
 ipv4                 = Y
 ipv6                 = Y
 tcp                  = Y
 udp                  = Y
 vxlan                = Y
+vxlan_gpe            = P
 
 [rte_flow actions]
 queue                = Y
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 7bcb6a9d43..cc2e9d83c5 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -136,6 +136,8 @@ New Features
   * Added Class of Service (COS) mask and map support.
   * Added VF link up/down and promiscuous mode support.
   * Updated RSS hash type configuration.
+  * Added Geneve and VXLAN-GPE flow items, and raised the dynamic TCAM
+    limit to 2048 entries on the STN tile.
   * Added mailbox message counter reporting through the device private dump API.
 
 * **Updated Intel iavf driver.**
diff --git a/drivers/net/hinic3/hinic3_fdir.c b/drivers/net/hinic3/hinic3_fdir.c
index f3a570b358..ef8bed6d39 100644
--- a/drivers/net/hinic3/hinic3_fdir.c
+++ b/drivers/net/hinic3/hinic3_fdir.c
@@ -77,8 +77,6 @@ hinic3_fdir_tcam_ipv4_init(struct hinic3_fdir_filter *rule,
 	/* Fill type of ip. */
 	tcam_key->key_mask.ip_type = HINIC3_UINT1_MAX;
 	tcam_key->key_info.ip_type = HINIC3_FDIR_IP_TYPE_IPV4;
-	tcam_key->key_mask.vlan_flag = HINIC3_UINT1_MAX;
-	tcam_key->key_info.vlan_flag = 0;
 
 	/* Fill src IPv4. */
 	tcam_key->key_mask.sipv4_h =
@@ -101,8 +99,9 @@ hinic3_fdir_tcam_ipv4_init(struct hinic3_fdir_filter *rule,
 		HINIC3_32_LOWER_16_BITS(rule->key_spec.ipv4.dst_ip);
 }
 
-static void hinic3_fdir_ipv6_tcam_key_init_sip(struct hinic3_fdir_filter *rule,
-					       struct hinic3_tcam_key *tcam_key)
+static inline void
+hinic3_fdir_ipv6_tcam_key_init_sip(struct hinic3_fdir_filter *rule,
+				   struct hinic3_tcam_key *tcam_key)
 {
 	tcam_key->key_mask_ipv6.sipv6_key0 =
 		HINIC3_32_UPPER_16_BITS(rule->key_mask.ipv6.src_ip[0]);
@@ -138,8 +137,9 @@ static void hinic3_fdir_ipv6_tcam_key_init_sip(struct hinic3_fdir_filter *rule,
 		HINIC3_32_LOWER_16_BITS(rule->key_spec.ipv6.src_ip[0x3]);
 }
 
-static void hinic3_fdir_ipv6_tcam_key_init_dip(struct hinic3_fdir_filter *rule,
-					       struct hinic3_tcam_key *tcam_key)
+static inline void
+hinic3_fdir_ipv6_tcam_key_init_dip(struct hinic3_fdir_filter *rule,
+				   struct hinic3_tcam_key *tcam_key)
 {
 	tcam_key->key_mask_ipv6.dipv6_key0 =
 		HINIC3_32_UPPER_16_BITS(rule->key_mask.ipv6.dst_ip[0]);
@@ -175,8 +175,9 @@ static void hinic3_fdir_ipv6_tcam_key_init_dip(struct hinic3_fdir_filter *rule,
 		HINIC3_32_LOWER_16_BITS(rule->key_spec.ipv6.dst_ip[0x3]);
 }
 
-static void hinic3_fdir_ipv6_tcam_key_init(struct hinic3_fdir_filter *rule,
-					   struct hinic3_tcam_key *tcam_key)
+static void
+hinic3_fdir_ipv6_tcam_key_init(struct hinic3_fdir_filter *rule,
+			       struct hinic3_tcam_key *tcam_key)
 {
 	hinic3_fdir_ipv6_tcam_key_init_sip(rule, tcam_key);
 	hinic3_fdir_ipv6_tcam_key_init_dip(rule, tcam_key);
@@ -189,8 +190,6 @@ hinic3_fdir_tcam_ipv6_init(struct hinic3_fdir_filter *rule,
 	/* Fill type of ip. */
 	tcam_key->key_mask_ipv6.ip_type = HINIC3_UINT1_MAX;
 	tcam_key->key_info_ipv6.ip_type = HINIC3_FDIR_IP_TYPE_IPV6;
-	tcam_key->key_mask_ipv6.vlan_flag = HINIC3_UINT1_MAX;
-	tcam_key->key_info_ipv6.vlan_flag = 0;
 
 	hinic3_fdir_ipv6_tcam_key_init(rule, tcam_key);
 }
@@ -224,9 +223,6 @@ hinic3_fdir_tcam_notunnel_init(struct rte_eth_dev *dev,
 
 	tcam_key->key_mask.function_id = HINIC3_UINT15_MAX;
 
-	tcam_key->key_mask.vlan_flag = 1;
-	tcam_key->key_info.vlan_flag = 0;
-
 	tcam_key->key_info.function_id = hinic3_global_func_id(nic_dev->hwdev) &
 					 HINIC3_UINT15_MAX;
 
@@ -240,15 +236,11 @@ hinic3_fdir_tcam_notunnel_init(struct rte_eth_dev *dev,
 }
 
 static void
-hinic3_fdir_tcam_vxlan_ipv4_init(struct hinic3_fdir_filter *rule,
+hinic3_fdir_tcam_vxlan_geneve_ipv4_init(struct hinic3_fdir_filter *rule,
 				 struct hinic3_tcam_key *tcam_key)
 {
-	/* Fill type of ip. */
 	tcam_key->key_mask.ip_type = HINIC3_UINT1_MAX;
 	tcam_key->key_info.ip_type = HINIC3_FDIR_IP_TYPE_IPV4;
-	tcam_key->key_mask.vlan_flag = HINIC3_UINT1_MAX;
-	tcam_key->key_info.vlan_flag = 0;
-
 	/* Fill src ipv4. */
 	tcam_key->key_mask.sipv4_h =
 		HINIC3_32_UPPER_16_BITS(rule->key_mask.inner_ipv4.src_ip);
@@ -271,14 +263,12 @@ hinic3_fdir_tcam_vxlan_ipv4_init(struct hinic3_fdir_filter *rule,
 }
 
 static void
-hinic3_fdir_tcam_vxlan_ipv6_init(struct hinic3_fdir_filter *rule,
+hinic3_fdir_tcam_vxlan_geneve_ipv6_init(struct hinic3_fdir_filter *rule,
 				 struct hinic3_tcam_key *tcam_key)
 {
 	/* Fill type of ip. */
 	tcam_key->key_mask_vxlan_ipv6.ip_type = HINIC3_UINT1_MAX;
 	tcam_key->key_info_vxlan_ipv6.ip_type = HINIC3_FDIR_IP_TYPE_IPV6;
-	tcam_key->key_mask_vxlan_ipv6.vlan_flag = HINIC3_UINT1_MAX;
-	tcam_key->key_info_vxlan_ipv6.vlan_flag = 0;
 
 	/* Use inner dst ipv6 to fill the dst ipv6 of tcam_key. */
 	tcam_key->key_mask_vxlan_ipv6.dipv6_key0 =
@@ -331,9 +321,6 @@ hinic3_fdir_tcam_ipv6_vxlan_init(struct rte_eth_dev *dev,
 	tcam_key->key_mask_ipv6.outer_ip_type = HINIC3_UINT1_MAX;
 	tcam_key->key_info_ipv6.outer_ip_type = HINIC3_FDIR_IP_TYPE_IPV6;
 
-	tcam_key->key_mask_ipv6.vlan_flag = HINIC3_UINT1_MAX;
-	tcam_key->key_info_ipv6.vlan_flag = 0;
-
 	tcam_key->key_mask_ipv6.function_id = HINIC3_UINT15_MAX;
 	tcam_key->key_info_ipv6.function_id =
 		hinic3_global_func_id(nic_dev->hwdev) & HINIC3_UINT15_MAX;
@@ -359,7 +346,7 @@ hinic3_fdir_tcam_ipv6_vxlan_init(struct rte_eth_dev *dev,
  * Pointer to the TCAM key.
  */
 static void
-hinic3_fdir_tcam_vxlan_init(struct rte_eth_dev *dev,
+hinic3_fdir_tcam_vxlan_geneve_init(struct rte_eth_dev *dev,
 			    struct hinic3_fdir_filter *rule,
 			    struct hinic3_tcam_key *tcam_key)
 {
@@ -409,17 +396,15 @@ hinic3_fdir_tcam_vxlan_init(struct rte_eth_dev *dev,
 	tcam_key->key_mask.tunnel_type = HINIC3_UINT4_MAX;
 	tcam_key->key_info.tunnel_type = rule->tunnel_type;
 
-	tcam_key->key_mask.vlan_flag = 1;
 	tcam_key->key_mask.function_id = HINIC3_UINT15_MAX;
-	tcam_key->key_info.vlan_flag = 0;
 	tcam_key->key_info.function_id = hinic3_global_func_id(nic_dev->hwdev) &
 					 HINIC3_UINT15_MAX;
 
 	if (rule->ip_type == HINIC3_FDIR_IP_TYPE_IPV4)
-		hinic3_fdir_tcam_vxlan_ipv4_init(rule, tcam_key);
+		hinic3_fdir_tcam_vxlan_geneve_ipv4_init(rule, tcam_key);
 
 	else if (rule->ip_type == HINIC3_FDIR_IP_TYPE_IPV6)
-		hinic3_fdir_tcam_vxlan_ipv6_init(rule, tcam_key);
+		hinic3_fdir_tcam_vxlan_geneve_ipv6_init(rule, tcam_key);
 }
 
 static void
@@ -432,7 +417,7 @@ hinic3_fdir_tcam_info_init(struct rte_eth_dev *dev,
 	if (rule->tunnel_type == HINIC3_FDIR_TUNNEL_MODE_NORMAL)
 		hinic3_fdir_tcam_notunnel_init(dev, rule, tcam_key);
 	else
-		hinic3_fdir_tcam_vxlan_init(dev, rule, tcam_key);
+		hinic3_fdir_tcam_vxlan_geneve_init(dev, rule, tcam_key);
 
 	/* Set the queue index. */
 	fdir_tcam_rule->data.qid = rule->rq_index;
@@ -841,7 +826,7 @@ hinic3_dynamic_lookup_tcam_filter(struct hinic3_nic_dev *nic_dev,
 	 * capacity of dynamic TCAM blocks.
 	 */
 	if (rule_nums >= block_cnt * HINIC3_TCAM_DYNAMIC_BLOCK_SIZE) {
-		if (block_cnt >= (HINIC3_TCAM_DYNAMIC_MAX_FILTERS /
+		if (block_cnt >= (HINIC3_TCAM_DYNAMIC_MAX_FILTERS(nic_dev) /
 				  HINIC3_TCAM_DYNAMIC_BLOCK_SIZE)) {
 			PMD_DRV_LOG(ERR,
 				"Dynamic tcam block is full, alloc failed!");
@@ -1597,6 +1582,7 @@ hinic3_flow_add_del_ethertype_filter(struct rte_eth_dev *dev,
 	/* Get dev private info. */
 	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 	int ret;
+
 	/* Add or remove an Ethernet type filter rule. */
 	ret = hinic3_flow_add_del_ethertype_filter_rule(dev, ethertype_filter, add);
 
diff --git a/drivers/net/hinic3/hinic3_fdir.h b/drivers/net/hinic3/hinic3_fdir.h
index 277d89d4fd..05bd9c515b 100644
--- a/drivers/net/hinic3/hinic3_fdir.h
+++ b/drivers/net/hinic3/hinic3_fdir.h
@@ -8,8 +8,13 @@
 #define HINIC3_FLOW_MAX_PATTERN_NUM 16
 
 #define HINIC3_TCAM_DYNAMIC_BLOCK_SIZE 16
+#define HINIC3_TCAM_DYNAMIC_MAX_FILTERS(nic_dev)         \
+		(HINIC3_IS_SP230_NIC(nic_dev)            \
+		? HINIC3_TCAM_DYNAMIC_MAX_FILTERS_HTN    \
+		: HINIC3_TCAM_DYNAMIC_MAX_FILTERS_STN)
 
-#define HINIC3_TCAM_DYNAMIC_MAX_FILTERS 1024
+#define HINIC3_TCAM_DYNAMIC_MAX_FILTERS_STN 2048
+#define HINIC3_TCAM_DYNAMIC_MAX_FILTERS_HTN 1024
 
 #define HINIC3_PKT_TCAM_DYNAMIC_INDEX_START(block_index) \
 	(HINIC3_TCAM_DYNAMIC_BLOCK_SIZE * (block_index))
@@ -96,6 +101,7 @@ enum hinic3_fdir_tunnel_mode {
 	HINIC3_FDIR_TUNNEL_MODE_GENEVE = 5,
 	HINIC3_FDIR_TUNNEL_MODE_NSH    = 6,
 	HINIC3_FDIR_TUNNEL_MODE_IPIP   = 7,
+	HINIC3_FDIR_TUNNEL_MODE_MAX    = 8,
 };
 
 enum hinic3_fdir_ip_type {
diff --git a/drivers/net/hinic3/hinic3_flow.c b/drivers/net/hinic3/hinic3_flow.c
index 3fbed5497b..daa158d994 100644
--- a/drivers/net/hinic3/hinic3_flow.c
+++ b/drivers/net/hinic3/hinic3_flow.c
@@ -8,7 +8,6 @@
 #include "base/hinic3_hwdev.h"
 #include "base/hinic3_nic_cfg.h"
 #include "hinic3_ethdev.h"
-#include "hinic3_flow.h"
 
 #define HINIC3_UINT8_MAX 0xff
 
@@ -19,12 +18,6 @@ typedef int (*hinic3_parse_filter_t)(struct rte_eth_dev *dev,
 				     struct rte_flow_error *error,
 				     struct hinic3_filter_t *filter);
 
-/* Indicate valid filter mode . */
-struct hinic3_valid_pattern {
-	enum rte_flow_item_type *items;
-	hinic3_parse_filter_t parse_filter;
-};
-
 static int hinic3_flow_parse_fdir_filter(struct rte_eth_dev *dev,
 					 const struct rte_flow_attr *attr,
 					 const struct rte_flow_item pattern[],
@@ -39,65 +32,12 @@ static int hinic3_flow_parse_ethertype_filter(struct rte_eth_dev *dev,
 					      struct rte_flow_error *error,
 					      struct hinic3_filter_t *filter);
 
-static int hinic3_flow_parse_fdir_vxlan_filter(struct rte_eth_dev *dev,
-					       const struct rte_flow_attr *attr,
-					       const struct rte_flow_item pattern[],
-					       const struct rte_flow_action actions[],
-					       struct rte_flow_error *error,
-					       struct hinic3_filter_t *filter);
-
-/*
- * Define a supported pattern array, including the matching patterns of
- * various network protocols and corresponding parsing functions.
- */
-static const struct hinic3_valid_pattern hinic3_supported_patterns[] = {
-	/* Support ethertype. */
-	{pattern_ethertype, hinic3_flow_parse_ethertype_filter},
-	/* Support ipv4 but not tunnel, and any field can be masked. */
-	{pattern_ipv4, hinic3_flow_parse_fdir_filter},
-	{pattern_ipv4_any, hinic3_flow_parse_fdir_filter},
-	/* Support ipv4 + l4 but not tunnel, and any field can be masked. */
-	{pattern_ipv4_udp, hinic3_flow_parse_fdir_filter},
-	{pattern_ipv4_tcp, hinic3_flow_parse_fdir_filter},
-	/* Support ipv4 + icmp not tunnel, and any field can be masked. */
-	{pattern_ipv4_icmp, hinic3_flow_parse_fdir_filter},
-
-	/* Support ipv4 + l4 but not tunnel, and any field can be masked. */
-	{pattern_ethertype_udp, hinic3_flow_parse_fdir_filter},
-	{pattern_ethertype_tcp, hinic3_flow_parse_fdir_filter},
-
-	/* Support ipv4 + vxlan + any, and any field can be masked. */
-	{pattern_ipv4_vxlan, hinic3_flow_parse_fdir_vxlan_filter},
-	/* Support ipv4 + vxlan + ipv4, and any field can be masked. */
-	{pattern_ipv4_vxlan_ipv4, hinic3_flow_parse_fdir_vxlan_filter},
-	/* Support ipv4 + vxlan + ipv4 + l4, and any field can be masked. */
-	{pattern_ipv4_vxlan_ipv4_tcp, hinic3_flow_parse_fdir_vxlan_filter},
-	{pattern_ipv4_vxlan_ipv4_udp, hinic3_flow_parse_fdir_vxlan_filter},
-	/* Support ipv4 + vxlan + ipv6, and any field can be masked. */
-	{pattern_ipv4_vxlan_ipv6, hinic3_flow_parse_fdir_vxlan_filter},
-	/* Support ipv4 + vxlan + ipv6 + l4, and any field can be masked. */
-	{pattern_ipv4_vxlan_ipv6_tcp, hinic3_flow_parse_fdir_vxlan_filter},
-	{pattern_ipv4_vxlan_ipv6_udp, hinic3_flow_parse_fdir_vxlan_filter},
-	/* Support ipv4 + vxlan + l4, and any field can be masked. */
-	{pattern_ipv4_vxlan_tcp, hinic3_flow_parse_fdir_vxlan_filter},
-	{pattern_ipv4_vxlan_udp, hinic3_flow_parse_fdir_vxlan_filter},
-	{pattern_ipv4_vxlan_any, hinic3_flow_parse_fdir_vxlan_filter},
-
-	/* Support ipv6 but not tunnel, and any field can be masked. */
-	{pattern_ipv6, hinic3_flow_parse_fdir_filter},
-	/* Support ipv6 + l4 but not tunnel, and any field can be masked. */
-	{pattern_ipv6_udp, hinic3_flow_parse_fdir_filter},
-	{pattern_ipv6_tcp, hinic3_flow_parse_fdir_filter},
-
-	/* Support ipv6 + vxlan + any, and any field can be masked. */
-	{pattern_ipv6_vxlan, hinic3_flow_parse_fdir_vxlan_filter},
-	{pattern_ipv6_vxlan_any, hinic3_flow_parse_fdir_vxlan_filter},
-
-	/* Support ipv6 + vxlan + l4, and any field can be masked. */
-	{pattern_ipv6_vxlan_tcp, hinic3_flow_parse_fdir_vxlan_filter},
-	{pattern_ipv6_vxlan_udp, hinic3_flow_parse_fdir_vxlan_filter},
-
-};
+static int hinic3_flow_parse_fdir_vxlan_geneve_filter(struct rte_eth_dev *dev,
+						      const struct rte_flow_attr *attr,
+						      const struct rte_flow_item pattern[],
+						      const struct rte_flow_action actions[],
+						      struct rte_flow_error *error,
+						      struct hinic3_filter_t *filter);
 
 static inline void
 net_addr_to_host(uint32_t *dst, const uint32_t *src, size_t len)
@@ -107,30 +47,248 @@ net_addr_to_host(uint32_t *dst, const uint32_t *src, size_t len)
 		dst[i] = rte_be_to_cpu_32(src[i]);
 }
 
-static bool
-hinic3_match_pattern(enum rte_flow_item_type *item_array,
-		     const struct rte_flow_item *pattern)
-{
-	const struct rte_flow_item *item = pattern;
+/* IPINIP and GPE are split out due to chip support differences. */
+enum hinic3_flow_filter_kind {
+	HINIC3_FLOW_KIND_ETHERTYPE,	/* [ETH]. */
+	HINIC3_FLOW_KIND_NON_TUNNEL,	/* single L3/L4 or ethertype L4. */
+	HINIC3_FLOW_KIND_VXLAN_GENEVE,	/* vxlan/geneve. */
+	HINIC3_FLOW_KIND_GPE,		/* vxlan-gpe. */
+	HINIC3_FLOW_KIND_IPINIP,	/* ip-in-ip. */
+	HINIC3_FLOW_KIND_INVALID,
+};
 
-	/* skip the first void item. */
+/*
+ * The pattern is parsed as a small protocol graph. Every supported pattern
+ * starts with ETH and then follows one of the supported encapsulation paths
+ * (plain L3/L4, tunneled, or ip-in-ip). VOID items are transparent.
+ */
+
+/* Peek at the next non-VOID item type. */
+static enum rte_flow_item_type
+hinic3_flow_next(const struct rte_flow_item *item)
+{
 	while (item->type == RTE_FLOW_ITEM_TYPE_VOID)
 		item++;
 
-	/* Find no void item. */
-	while (((*item_array == item->type) &&
-		(*item_array != RTE_FLOW_ITEM_TYPE_END)) ||
-	       (item->type == RTE_FLOW_ITEM_TYPE_VOID)) {
-		if (item->type == RTE_FLOW_ITEM_TYPE_VOID) {
-			item++;
-		} else {
-			item_array++;
-			item++;
+	return item->type;
+}
+
+/* Consume the next non-VOID item when it matches @p type. */
+static bool
+hinic3_flow_take(const struct rte_flow_item **item,
+		 enum rte_flow_item_type type)
+{
+	while ((*item)->type == RTE_FLOW_ITEM_TYPE_VOID)
+		(*item)++;
+
+	if ((*item)->type != type)
+		return false;
+
+	(*item)++;
+	return true;
+}
+
+/* Return true when only the END item remains. */
+static bool
+hinic3_flow_at_end(const struct rte_flow_item *item)
+{
+	return hinic3_flow_next(item) == RTE_FLOW_ITEM_TYPE_END;
+}
+
+/* Finish a branch, which is valid only when END is reached. */
+static enum hinic3_flow_filter_kind
+hinic3_flow_finish(const struct rte_flow_item *item,
+		   enum hinic3_flow_filter_kind kind)
+{
+	return hinic3_flow_at_end(item) ? kind : HINIC3_FLOW_KIND_INVALID;
+}
+
+/* Classify an inner L3 (IPv4/IPv6) with an optional L4, returning @p kind. */
+static enum hinic3_flow_filter_kind
+hinic3_flow_classify_inner(const struct rte_flow_item **item,
+			   enum hinic3_flow_filter_kind kind,
+			   enum rte_flow_item_type outer_ip)
+{
+	enum rte_flow_item_type next = hinic3_flow_next(*item);
+
+	if (next != RTE_FLOW_ITEM_TYPE_IPV4 &&
+	    next != RTE_FLOW_ITEM_TYPE_IPV6)
+		return HINIC3_FLOW_KIND_INVALID;
+
+	/*
+	 * An outer IPv6 plus any inner L3 does not fit in the TCAM, so only
+	 * an IPv4 outer (or no outer at all) may carry an inner L3.
+	 */
+	if (outer_ip == RTE_FLOW_ITEM_TYPE_IPV6)
+		return HINIC3_FLOW_KIND_INVALID;
+
+	hinic3_flow_take(item, next);
+
+	switch (hinic3_flow_next(*item)) {
+	case RTE_FLOW_ITEM_TYPE_END:
+		return kind;
+	case RTE_FLOW_ITEM_TYPE_TCP:
+	case RTE_FLOW_ITEM_TYPE_UDP:
+		hinic3_flow_take(item, hinic3_flow_next(*item));
+		return hinic3_flow_finish(*item, kind);
+	default:
+		return HINIC3_FLOW_KIND_INVALID;
+	}
+}
+
+/* Consume a tunnel header and classify the payload that follows it. */
+static enum hinic3_flow_filter_kind
+hinic3_flow_classify_tunnel(const struct rte_flow_item **item,
+			    enum rte_flow_item_type tunnel_type,
+			    enum rte_flow_item_type outer_ip)
+{
+	enum hinic3_flow_filter_kind kind =
+		tunnel_type == RTE_FLOW_ITEM_TYPE_VXLAN_GPE ?
+			HINIC3_FLOW_KIND_GPE : HINIC3_FLOW_KIND_VXLAN_GENEVE;
+	enum rte_flow_item_type next;
+
+	if (!hinic3_flow_take(item, tunnel_type))
+		return HINIC3_FLOW_KIND_INVALID;
+
+	next = hinic3_flow_next(*item);
+
+	/* A bare tunnel with nothing after the header is valid. */
+	if (next == RTE_FLOW_ITEM_TYPE_END)
+		return kind;
+
+	/* GPE: an optional inner ETH (which may be terminal), then an L3(+L4). */
+	if (tunnel_type == RTE_FLOW_ITEM_TYPE_VXLAN_GPE) {
+		if (next == RTE_FLOW_ITEM_TYPE_ETH) {
+			hinic3_flow_take(item, RTE_FLOW_ITEM_TYPE_ETH);
+			if (hinic3_flow_at_end(*item))
+				return kind;
+		}
+		return hinic3_flow_classify_inner(item, kind, outer_ip);
+	}
+
+	/* vxlan/geneve: a bare L4/ANY, or an inner L3(+L4). */
+	switch (next) {
+	case RTE_FLOW_ITEM_TYPE_TCP:
+	case RTE_FLOW_ITEM_TYPE_UDP:
+	case RTE_FLOW_ITEM_TYPE_ANY:
+		hinic3_flow_take(item, next);
+		return hinic3_flow_finish(*item, kind);
+	case RTE_FLOW_ITEM_TYPE_ETH:
+	case RTE_FLOW_ITEM_TYPE_IPV4:
+	case RTE_FLOW_ITEM_TYPE_IPV6:
+		if (next == RTE_FLOW_ITEM_TYPE_ETH) {
+			hinic3_flow_take(item, RTE_FLOW_ITEM_TYPE_ETH);
+			break;
+		}
+		/* Geneve accepts a bare inner L3; vxlan requires the inner ETH. */
+		if (tunnel_type != RTE_FLOW_ITEM_TYPE_GENEVE)
+			return HINIC3_FLOW_KIND_INVALID;
+		break;
+	default:
+		return HINIC3_FLOW_KIND_INVALID;
+	}
+
+	return hinic3_flow_classify_inner(item, kind, outer_ip);
+}
+
+/* Classify the payload that follows the outer L3. */
+static enum hinic3_flow_filter_kind
+hinic3_flow_classify_ip(const struct rte_flow_item **item,
+			enum rte_flow_item_type ip_type)
+{
+	enum rte_flow_item_type next = hinic3_flow_next(*item);
+
+	switch (next) {
+	case RTE_FLOW_ITEM_TYPE_END:
+		return HINIC3_FLOW_KIND_NON_TUNNEL;
+	case RTE_FLOW_ITEM_TYPE_TCP:
+		hinic3_flow_take(item, RTE_FLOW_ITEM_TYPE_TCP);
+		return hinic3_flow_finish(*item, HINIC3_FLOW_KIND_NON_TUNNEL);
+	case RTE_FLOW_ITEM_TYPE_UDP:
+		hinic3_flow_take(item, RTE_FLOW_ITEM_TYPE_UDP);
+		next = hinic3_flow_next(*item);
+		switch (next) {
+		case RTE_FLOW_ITEM_TYPE_END:
+			return HINIC3_FLOW_KIND_NON_TUNNEL;
+		case RTE_FLOW_ITEM_TYPE_VXLAN:
+		case RTE_FLOW_ITEM_TYPE_GENEVE:
+		case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
+			return hinic3_flow_classify_tunnel(item, next, ip_type);
+		default:
+			return HINIC3_FLOW_KIND_INVALID;
+		}
+	case RTE_FLOW_ITEM_TYPE_ICMP:
+	case RTE_FLOW_ITEM_TYPE_ANY:
+		/* ICMP and ANY are valid only right after an IPv4 outer. */
+		if (ip_type != RTE_FLOW_ITEM_TYPE_IPV4)
+			return HINIC3_FLOW_KIND_INVALID;
+		hinic3_flow_take(item, next);
+		return hinic3_flow_finish(*item, HINIC3_FLOW_KIND_NON_TUNNEL);
+	case RTE_FLOW_ITEM_TYPE_IPV4:
+	case RTE_FLOW_ITEM_TYPE_IPV6:
+		/*
+		 * Ip-in-ip: a second L3 with an optional L4 (or ANY). An outer
+		 * IPv6 plus an inner L3 does not fit in the TCAM.
+		 */
+		if (ip_type == RTE_FLOW_ITEM_TYPE_IPV6)
+			return HINIC3_FLOW_KIND_INVALID;
+		hinic3_flow_take(item, next);
+		switch (hinic3_flow_next(*item)) {
+		case RTE_FLOW_ITEM_TYPE_END:
+			return HINIC3_FLOW_KIND_IPINIP;
+		case RTE_FLOW_ITEM_TYPE_TCP:
+		case RTE_FLOW_ITEM_TYPE_UDP:
+		case RTE_FLOW_ITEM_TYPE_ANY:
+			hinic3_flow_take(item, hinic3_flow_next(*item));
+			return hinic3_flow_finish(*item, HINIC3_FLOW_KIND_IPINIP);
+		default:
+			return HINIC3_FLOW_KIND_INVALID;
 		}
+	default:
+		return HINIC3_FLOW_KIND_INVALID;
 	}
+}
 
-	return (*item_array == RTE_FLOW_ITEM_TYPE_END &&
-		item->type == RTE_FLOW_ITEM_TYPE_END);
+/* Classify a pattern into one of the supported filter kinds. */
+static enum hinic3_flow_filter_kind
+hinic3_flow_classify(const struct rte_flow_item *pattern)
+{
+	const struct rte_flow_item *item = pattern;
+	enum rte_flow_item_type next;
+
+	if (!hinic3_flow_take(&item, RTE_FLOW_ITEM_TYPE_ETH))
+		return HINIC3_FLOW_KIND_INVALID;
+
+	switch (hinic3_flow_next(item)) {
+	case RTE_FLOW_ITEM_TYPE_END:
+		return HINIC3_FLOW_KIND_ETHERTYPE;
+	case RTE_FLOW_ITEM_TYPE_TCP:
+		hinic3_flow_take(&item, RTE_FLOW_ITEM_TYPE_TCP);
+		return hinic3_flow_finish(item, HINIC3_FLOW_KIND_NON_TUNNEL);
+	case RTE_FLOW_ITEM_TYPE_UDP:
+		hinic3_flow_take(&item, RTE_FLOW_ITEM_TYPE_UDP);
+		next = hinic3_flow_next(item);
+		switch (next) {
+		case RTE_FLOW_ITEM_TYPE_END:
+			return HINIC3_FLOW_KIND_NON_TUNNEL;
+		case RTE_FLOW_ITEM_TYPE_VXLAN:
+		case RTE_FLOW_ITEM_TYPE_GENEVE:
+		case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
+			/* No outer IP: pass END so classify_inner allows it. */
+			return hinic3_flow_classify_tunnel(&item, next,
+							    RTE_FLOW_ITEM_TYPE_END);
+		default:
+			return HINIC3_FLOW_KIND_INVALID;
+		}
+	case RTE_FLOW_ITEM_TYPE_IPV4:
+		hinic3_flow_take(&item, RTE_FLOW_ITEM_TYPE_IPV4);
+		return hinic3_flow_classify_ip(&item, RTE_FLOW_ITEM_TYPE_IPV4);
+	case RTE_FLOW_ITEM_TYPE_IPV6:
+		hinic3_flow_take(&item, RTE_FLOW_ITEM_TYPE_IPV6);
+		return hinic3_flow_classify_ip(&item, RTE_FLOW_ITEM_TYPE_IPV6);
+	default:
+		return HINIC3_FLOW_KIND_INVALID;
+	}
 }
 
 /**
@@ -142,20 +300,27 @@ hinic3_match_pattern(enum rte_flow_item_type *item_array,
  * Matched resolution filter. If no resolution filter is found, return NULL.
  */
 static hinic3_parse_filter_t
-hinic3_find_parse_filter_func(const struct rte_flow_item *pattern)
+hinic3_find_parse_filter_func(struct rte_eth_dev *dev,
+			      const struct rte_flow_item *pattern)
 {
-	hinic3_parse_filter_t parse_filter = NULL;
-	uint8_t i;
-	/* Traverse all supported patterns. */
-	for (i = 0; i < RTE_DIM(hinic3_supported_patterns); i++) {
-		if (hinic3_match_pattern(hinic3_supported_patterns[i].items, pattern)) {
-			parse_filter =
-				hinic3_supported_patterns[i].parse_filter;
-			break;
-		}
-	}
+	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
-	return parse_filter;
+	switch (hinic3_flow_classify(pattern)) {
+	case HINIC3_FLOW_KIND_ETHERTYPE:
+		return hinic3_flow_parse_ethertype_filter;
+	case HINIC3_FLOW_KIND_NON_TUNNEL:
+		return hinic3_flow_parse_fdir_filter;
+	case HINIC3_FLOW_KIND_VXLAN_GENEVE:
+		return hinic3_flow_parse_fdir_vxlan_geneve_filter;
+	case HINIC3_FLOW_KIND_GPE:
+		return HINIC3_IS_SP620_NIC(nic_dev) ?
+		hinic3_flow_parse_fdir_vxlan_geneve_filter : NULL;
+	case HINIC3_FLOW_KIND_IPINIP:
+		return HINIC3_IS_SP620_NIC(nic_dev) ? NULL :
+		hinic3_flow_parse_fdir_vxlan_geneve_filter;
+	default:
+		return NULL;
+	}
 }
 
 /**
@@ -182,12 +347,36 @@ hinic3_flow_parse_action(struct rte_eth_dev *dev,
 	const struct rte_flow_action_queue *act_q;
 	const struct rte_flow_action *act = actions;
 
-	/* skip the first void item. */
-	while (act->type == RTE_FLOW_ACTION_TYPE_VOID)
-		act++;
+	/* Only one non-VOID action before END is supported. */
+	const struct rte_flow_action *last_act = NULL;
+	for (act = actions; act->type != RTE_FLOW_ACTION_TYPE_END; act++) {
+		if (act->type == RTE_FLOW_ACTION_TYPE_VOID)
+			continue;
+		if (last_act != NULL) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ACTION, act,
+					   "Multiple actions not supported.");
+			return -rte_errno;
+		}
+		last_act = act;
+	}
+	if (last_act == NULL) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_ACTION, actions,
+				   "No valid action.");
+		return -rte_errno;
+	}
+
+	act = last_act;
 
 	switch (act->type) {
 	case RTE_FLOW_ACTION_TYPE_QUEUE:
+		if (act->conf == NULL) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ACTION,
+					   act, "Invalid action queue config.");
+			return -rte_errno;
+		}
 		act_q = (const struct rte_flow_action_queue *)act->conf;
 		filter->fdir_filter.rq_index = act_q->index;
 		if (filter->fdir_filter.rq_index >= dev->data->nb_rx_queues) {
@@ -234,7 +423,7 @@ hinic3_flow_fdir_ipv4(const struct rte_flow_item *flow_item,
 	filter->fdir_filter.ip_type = HINIC3_FDIR_IP_TYPE_IPV4;
 	filter->fdir_filter.tunnel_type = HINIC3_FDIR_TUNNEL_MODE_NORMAL;
 
-	/* A wildcard IPv4 item leaves the L4 item in charge of the rule. */
+	/* When both L3 mask and spec are empty, return 0, then proceed to evaluate L4. */
 	if (!mask_ipv4 && !spec_ipv4)
 		return 0;
 
@@ -259,7 +448,6 @@ hinic3_flow_fdir_ipv4(const struct rte_flow_item *flow_item,
 		return -rte_errno;
 	}
 
-	/* Set the filter information. */
 	filter->fdir_filter.key_mask.ipv4.src_ip =
 		rte_be_to_cpu_32(mask_ipv4->hdr.src_addr);
 	filter->fdir_filter.key_spec.ipv4.src_ip =
@@ -283,6 +471,14 @@ hinic3_flow_fdir_ipv6(const struct rte_flow_item *flow_item,
 
 	mask_ipv6 = (const struct rte_flow_item_ipv6 *)flow_item->mask;
 	spec_ipv6 = (const struct rte_flow_item_ipv6 *)flow_item->spec;
+
+	filter->fdir_filter.ip_type = HINIC3_FDIR_IP_TYPE_IPV6;
+	filter->fdir_filter.tunnel_type = HINIC3_FDIR_TUNNEL_MODE_NORMAL;
+
+	/* When both L3 mask and spec are empty, return 0, then proceed to evaluate L4. */
+	if (!mask_ipv6 && !spec_ipv6)
+		return 0;
+
 	if (!mask_ipv6 || !spec_ipv6) {
 		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
 				   flow_item,
@@ -299,9 +495,6 @@ hinic3_flow_fdir_ipv6(const struct rte_flow_item *flow_item,
 		return -rte_errno;
 	}
 
-	/* Set the filter information. */
-	filter->fdir_filter.ip_type = HINIC3_FDIR_IP_TYPE_IPV6;
-	filter->fdir_filter.tunnel_type = HINIC3_FDIR_TUNNEL_MODE_NORMAL;
 	net_addr_to_host(filter->fdir_filter.key_mask.ipv6.src_ip,
 			 (const uint32_t *)mask_ipv6->hdr.src_addr.a, 4);
 	net_addr_to_host(filter->fdir_filter.key_spec.ipv6.src_ip,
@@ -687,6 +880,12 @@ hinic3_flow_parse_ethertype_pattern(__rte_unused struct rte_eth_dev *dev,
 			case RTE_ETHER_TYPE_LLDP:
 				break;
 
+			case RTE_ETHER_TYPE_CNM:
+				break;
+
+			case RTE_ETHER_TYPE_ECP:
+				break;
+
 			default:
 				rte_flow_error_set(error, EINVAL,
 						   RTE_FLOW_ERROR_TYPE_ITEM,
@@ -734,14 +933,15 @@ static int
 hinic3_flow_fdir_tunnel_ipv4(struct rte_flow_error *error,
 			     struct hinic3_filter_t *filter,
 			     const struct rte_flow_item *flow_item,
-			     enum hinic3_fdir_tunnel_mode tunnel_mode)
+			     enum hinic3_fdir_tunnel_mode *tunnel_mode)
 {
 	const struct rte_flow_item_ipv4 *spec_ipv4, *mask_ipv4;
 	mask_ipv4 = (const struct rte_flow_item_ipv4 *)flow_item->mask;
 	spec_ipv4 = (const struct rte_flow_item_ipv4 *)flow_item->spec;
 
-	if (tunnel_mode == HINIC3_FDIR_TUNNEL_MODE_NORMAL) {
+	if (*tunnel_mode == HINIC3_FDIR_TUNNEL_MODE_MAX) {
 		filter->fdir_filter.outer_ip_type = HINIC3_FDIR_IP_TYPE_IPV4;
+		*tunnel_mode = HINIC3_FDIR_TUNNEL_MODE_NORMAL;
 
 		if (!mask_ipv4 && !spec_ipv4)
 			return 0;
@@ -750,7 +950,7 @@ hinic3_flow_fdir_tunnel_ipv4(struct rte_flow_error *error,
 			rte_flow_error_set(error, EINVAL,
 					   RTE_FLOW_ERROR_TYPE_ITEM,
 					   flow_item,
-					   "Invalid fdir filter, vxlan outer ipv4 mask or spec");
+					   "Invalid fdir filter, vxlan/geneve outer ipv4 mask or spec");
 			return -rte_errno;
 		}
 
@@ -766,7 +966,7 @@ hinic3_flow_fdir_tunnel_ipv4(struct rte_flow_error *error,
 		    mask_ipv4->hdr.next_proto_id ||
 		    mask_ipv4->hdr.hdr_checksum) {
 			rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, flow_item,
-				"Not supported by fdir filter, vxlan outer ipv4 only support src ip, dst ip");
+				"Not supported by fdir filter, vxlan/geneve outer ipv4 only support src ip,dst ip");
 			return -rte_errno;
 		}
 
@@ -781,6 +981,10 @@ hinic3_flow_fdir_tunnel_ipv4(struct rte_flow_error *error,
 			rte_be_to_cpu_32(spec_ipv4->hdr.dst_addr);
 	} else {
 		filter->fdir_filter.ip_type = HINIC3_FDIR_IP_TYPE_IPV4;
+		if (*tunnel_mode == HINIC3_FDIR_TUNNEL_MODE_NORMAL) {
+			*tunnel_mode = HINIC3_FDIR_TUNNEL_MODE_IPIP;
+			filter->fdir_filter.tunnel_type = *tunnel_mode;
+		}
 
 		if (!mask_ipv4 && !spec_ipv4)
 			return 0;
@@ -789,7 +993,7 @@ hinic3_flow_fdir_tunnel_ipv4(struct rte_flow_error *error,
 			rte_flow_error_set(error, EINVAL,
 					   RTE_FLOW_ERROR_TYPE_ITEM,
 					   flow_item,
-					   "Invalid fdir filter, vxlan inner ipv4 mask or spec");
+					   "Invalid fdir filter, vxlan/geneve inner ipv4 mask or spec");
 			return -rte_errno;
 		}
 
@@ -806,7 +1010,7 @@ hinic3_flow_fdir_tunnel_ipv4(struct rte_flow_error *error,
 			rte_flow_error_set(error, EINVAL,
 					   RTE_FLOW_ERROR_TYPE_ITEM,
 					   flow_item,
-					   "Not supported by fdir filter, vxlan inner ipv4 only support src ip, dst ip, proto");
+					   "Not supported by fdir filter, vxlan/geneve inner ipv4 only support src ip,dst ip, proto");
 			return -rte_errno;
 		}
 
@@ -831,15 +1035,16 @@ static int
 hinic3_flow_fdir_tunnel_ipv6(struct rte_flow_error *error,
 			     struct hinic3_filter_t *filter,
 			     const struct rte_flow_item *flow_item,
-			     enum hinic3_fdir_tunnel_mode tunnel_mode)
+			     enum hinic3_fdir_tunnel_mode *tunnel_mode)
 {
 	const struct rte_flow_item_ipv6 *spec_ipv6, *mask_ipv6;
 
 	mask_ipv6 = (const struct rte_flow_item_ipv6 *)flow_item->mask;
 	spec_ipv6 = (const struct rte_flow_item_ipv6 *)flow_item->spec;
 
-	if (tunnel_mode == HINIC3_FDIR_TUNNEL_MODE_NORMAL) {
+	if (*tunnel_mode == HINIC3_FDIR_TUNNEL_MODE_MAX) {
 		filter->fdir_filter.outer_ip_type = HINIC3_FDIR_IP_TYPE_IPV6;
+		*tunnel_mode = HINIC3_FDIR_TUNNEL_MODE_NORMAL;
 
 		if (!mask_ipv6 && !spec_ipv6)
 			return 0;
@@ -870,7 +1075,10 @@ hinic3_flow_fdir_tunnel_ipv6(struct rte_flow_error *error,
 				 (const uint32_t *)spec_ipv6->hdr.dst_addr.a, 4);
 	} else {
 		filter->fdir_filter.ip_type = HINIC3_FDIR_IP_TYPE_IPV6;
-
+		if (*tunnel_mode == HINIC3_FDIR_TUNNEL_MODE_NORMAL) {
+			*tunnel_mode = HINIC3_FDIR_TUNNEL_MODE_IPIP;
+			filter->fdir_filter.tunnel_type = *tunnel_mode;
+		}
 		if (!mask_ipv6 && !spec_ipv6)
 			return 0;
 
@@ -917,7 +1125,7 @@ hinic3_flow_fdir_tunnel_tcp(struct rte_flow_error *error,
 	if (tunnel_mode == HINIC3_FDIR_TUNNEL_MODE_NORMAL) {
 		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
 				   flow_item,
-				   "Not supported by fdir filter, vxlan only support inner tcp");
+				   "Not supported by fdir filter, vxlan/geneve only support inner tcp");
 		return -rte_errno;
 	}
 
@@ -942,7 +1150,7 @@ hinic3_flow_fdir_tunnel_tcp(struct rte_flow_error *error,
 	    mask_tcp->hdr.tcp_urp) {
 		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
 				   flow_item,
-				   "Not supported by fdir filter, vxlan inner tcp only support src port,dst port");
+				   "Not supported by fdir filter, vxlan/geneve inner tcp only support src port,dst port");
 		return -rte_errno;
 	}
 
@@ -969,7 +1177,8 @@ hinic3_flow_fdir_tunnel_udp(struct rte_flow_error *error,
 	mask_udp = (const struct rte_flow_item_udp *)flow_item->mask;
 	spec_udp = (const struct rte_flow_item_udp *)flow_item->spec;
 
-	if (tunnel_mode == HINIC3_FDIR_TUNNEL_MODE_NORMAL) {
+	if (tunnel_mode == HINIC3_FDIR_TUNNEL_MODE_MAX ||
+	    tunnel_mode == HINIC3_FDIR_TUNNEL_MODE_NORMAL) {
 		/*
 		 * UDP is used to describe protocol,
 		 * spec and mask should be NULL.
@@ -990,7 +1199,7 @@ hinic3_flow_fdir_tunnel_udp(struct rte_flow_error *error,
 			rte_flow_error_set(error, EINVAL,
 					   RTE_FLOW_ERROR_TYPE_ITEM,
 					   flow_item,
-					   "Invalid fdir filter vxlan inner udp mask or spec");
+					   "Invalid fdir filter vxlan/geneve inner udp mask or spec");
 			return -rte_errno;
 		}
 
@@ -1008,57 +1217,119 @@ hinic3_flow_fdir_tunnel_udp(struct rte_flow_error *error,
 	return 0;
 }
 
+static inline enum hinic3_fdir_tunnel_mode
+hinic3_flow_tunnel_mode(enum rte_flow_item_type type)
+{
+	switch (type) {
+	case RTE_FLOW_ITEM_TYPE_GENEVE:
+		return HINIC3_FDIR_TUNNEL_MODE_GENEVE;
+	case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
+		return HINIC3_FDIR_TUNNEL_MODE_GPE;
+	default:
+		return HINIC3_FDIR_TUNNEL_MODE_VXLAN;
+	}
+}
+
 static int
-hinic3_flow_fdir_vxlan(struct rte_flow_error *error,
-		       struct hinic3_filter_t *filter,
-		       const struct rte_flow_item *flow_item)
+hinic3_flow_fdir_vxlan_geneve(struct rte_flow_error	  *error,
+			      struct hinic3_filter_t	  *filter,
+			      enum hinic3_fdir_tunnel_mode tunnel_mode,
+			      const struct rte_flow_item  *flow_item)
 {
-	const struct rte_flow_item_vxlan *spec_vxlan, *mask_vxlan;
+	const uint8_t *vni;
+	const uint8_t *vni_mask;
 	uint32_t vxlan_vni_id = 0;
 	uint32_t vxlan_vni_id_mask = 0;
 
-	spec_vxlan = (const struct rte_flow_item_vxlan *)flow_item->spec;
-	mask_vxlan = (const struct rte_flow_item_vxlan *)flow_item->mask;
+	filter->fdir_filter.tunnel_type = tunnel_mode;
 
-	filter->fdir_filter.tunnel_type = HINIC3_FDIR_TUNNEL_MODE_VXLAN;
-
-	if (!spec_vxlan && !mask_vxlan) {
+	if (!flow_item->spec && !flow_item->mask)
 		return 0;
-	} else if (filter->fdir_filter.outer_ip_type == HINIC3_FDIR_IP_TYPE_IPV6) {
+
+	if (filter->fdir_filter.outer_ip_type == HINIC3_FDIR_IP_TYPE_IPV6) {
 		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
 				   flow_item,
-				   "Invalid fdir filter vxlan mask or spec, ipv6 vxlan, don't support vni");
+				   "Invalid fdir filter vxlan/geneve mask or spec, ipv6 vxlan/geneve, don't support vni");
 		return -rte_errno;
 	}
 
-	if (!spec_vxlan || !mask_vxlan) {
+	if (!flow_item->spec || !flow_item->mask) {
 		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
 				   flow_item,
-				   "Invalid fdir filter vxlan mask or spec");
+				   "Invalid fdir filter vxlan/geneve mask or spec");
 		return -rte_errno;
 	}
 
-	memcpy(((uint8_t *)&vxlan_vni_id + 1), spec_vxlan->vni, 3);
+	switch (tunnel_mode) {
+	case HINIC3_FDIR_TUNNEL_MODE_GENEVE: {
+		const struct rte_flow_item_geneve *spec =
+			(const struct rte_flow_item_geneve *)flow_item->spec;
+		const struct rte_flow_item_geneve *mask =
+			(const struct rte_flow_item_geneve *)flow_item->mask;
+
+		/* Only VNI is matched; the other header fields are not. */
+		if (mask->ver_opt_len_o_c_rsvd0 || mask->protocol ||
+		    mask->rsvd1)
+			goto unsupported;
+		vni = spec->vni;
+		vni_mask = mask->vni;
+		break;
+	}
+	case HINIC3_FDIR_TUNNEL_MODE_GPE: {
+		const struct rte_flow_item_vxlan_gpe *spec =
+			(const struct rte_flow_item_vxlan_gpe *)flow_item->spec;
+		const struct rte_flow_item_vxlan_gpe *mask =
+			(const struct rte_flow_item_vxlan_gpe *)flow_item->mask;
+
+		/* Only VNI is matched; flags, reserved bits and protocol are not. */
+		if (mask->flags || mask->rsvd0[0] || mask->rsvd0[1] ||
+		    mask->protocol || mask->rsvd1)
+			goto unsupported;
+		vni = spec->vni;
+		vni_mask = mask->vni;
+		break;
+	}
+	default:
+		vni = ((const struct rte_flow_item_vxlan *)flow_item->spec)->vni;
+		vni_mask =
+			((const struct rte_flow_item_vxlan *)flow_item->mask)->vni;
+		break;
+	}
+
+	memcpy(((uint8_t *)&vxlan_vni_id + 1), vni, 3);
 	filter->fdir_filter.key_spec.tunnel.tunnel_id =
 		rte_be_to_cpu_32(vxlan_vni_id);
-	memcpy(((uint8_t *)&vxlan_vni_id_mask + 1), mask_vxlan->vni, 3);
+	memcpy(((uint8_t *)&vxlan_vni_id_mask + 1), vni_mask, 3);
 	filter->fdir_filter.key_mask.tunnel.tunnel_id =
 		rte_be_to_cpu_32(vxlan_vni_id_mask);
 	return 0;
+
+unsupported:
+	rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, flow_item,
+			   "Not supported by fdir filter, only vni is supported");
+	return -rte_errno;
 }
 
 static int
-hinic3_flow_parse_fdir_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
-				     const struct rte_flow_item *pattern,
-				     struct rte_flow_error *error,
-				     struct hinic3_filter_t *filter)
+hinic3_flow_parse_fdir_vxlan_geneve_pattern(__rte_unused struct rte_eth_dev *dev,
+					    const struct rte_flow_item *pattern,
+					    struct rte_flow_error *error,
+					    struct hinic3_filter_t *filter)
 {
 	const struct rte_flow_item *flow_item = pattern;
-	enum hinic3_fdir_tunnel_mode tunnel_mode =
-		HINIC3_FDIR_TUNNEL_MODE_NORMAL;
+	/* Pass tunnel_mode by pointer so the inner L3 parser can promote it
+	 * to IPIP when a second IPv4/IPv6 header is recognized.
+	 */
+	enum hinic3_fdir_tunnel_mode tunnel_mode = HINIC3_FDIR_TUNNEL_MODE_MAX;
 	enum rte_flow_item_type type;
 	int err;
 
+	if (pattern == NULL) {
+		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, NULL,
+				   "Invalid pattern");
+		return -rte_errno;
+	}
+
 	/* Inner and outer ip type, set it to any by default */
 	filter->fdir_filter.ip_type = HINIC3_FDIR_IP_TYPE_ANY;
 	filter->fdir_filter.outer_ip_type = HINIC3_FDIR_IP_TYPE_ANY;
@@ -1086,14 +1357,14 @@ hinic3_flow_parse_fdir_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 
 		case RTE_FLOW_ITEM_TYPE_IPV4:
 			err = hinic3_flow_fdir_tunnel_ipv4(error,
-				filter, flow_item, tunnel_mode);
+				filter, flow_item, &tunnel_mode);
 			if (err)
 				return -rte_errno;
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			err = hinic3_flow_fdir_tunnel_ipv6(error,
-				filter, flow_item, tunnel_mode);
+				filter, flow_item, &tunnel_mode);
 			if (err)
 				return -rte_errno;
 			break;
@@ -1113,10 +1384,12 @@ hinic3_flow_parse_fdir_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
 			break;
 
 		case RTE_FLOW_ITEM_TYPE_VXLAN:
-			err = hinic3_flow_fdir_vxlan(error, filter, flow_item);
+		case RTE_FLOW_ITEM_TYPE_GENEVE:
+		case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
+			tunnel_mode = hinic3_flow_tunnel_mode(type);
+			err = hinic3_flow_fdir_vxlan_geneve(error, filter, tunnel_mode, flow_item);
 			if (err)
 				return -rte_errno;
-			tunnel_mode = HINIC3_FDIR_TUNNEL_MODE_VXLAN;
 			break;
 
 		default:
@@ -1147,16 +1420,16 @@ hinic3_flow_parse_fdir_vxlan_pattern(__rte_unused struct rte_eth_dev *dev,
  * 0 on success, non-zero on failure.
  */
 static int
-hinic3_flow_parse_fdir_vxlan_filter(struct rte_eth_dev *dev,
-				    const struct rte_flow_attr *attr,
-				    const struct rte_flow_item pattern[],
-				    const struct rte_flow_action actions[],
-				    struct rte_flow_error *error,
-				    struct hinic3_filter_t *filter)
+hinic3_flow_parse_fdir_vxlan_geneve_filter(struct rte_eth_dev *dev,
+					   const struct rte_flow_attr *attr,
+					   const struct rte_flow_item pattern[],
+					   const struct rte_flow_action actions[],
+					   struct rte_flow_error *error,
+					   struct hinic3_filter_t *filter)
 {
 	int ret;
 
-	ret = hinic3_flow_parse_fdir_vxlan_pattern(dev, pattern, error, filter);
+	ret = hinic3_flow_parse_fdir_vxlan_geneve_pattern(dev, pattern, error, filter);
 	if (ret)
 		return ret;
 
@@ -1201,6 +1474,7 @@ hinic3_flow_parse(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 	hinic3_parse_filter_t parse_filter;
 	uint32_t pattern_num = 0;
 	int ret = 0;
+
 	/* Check whether the parameter is valid. */
 	if (!pattern || !actions || !attr) {
 		rte_flow_error_set(error, EINVAL,
@@ -1222,7 +1496,7 @@ hinic3_flow_parse(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 	 * The corresponding filter is returned. If the filter is not found,
 	 * NULL is returned.
 	 */
-	parse_filter = hinic3_find_parse_filter_func(pattern);
+	parse_filter = hinic3_find_parse_filter_func(dev, pattern);
 	if (!parse_filter) {
 		rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
 				   pattern, "Unsupported pattern");
@@ -1351,9 +1625,7 @@ hinic3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 				   NULL, "Unsupported filter type.");
 		goto free_flow;
 	}
-
 	return flow;
-
 free_flow:
 	rte_free(flow);
 	rte_free(filter_rules);
@@ -1515,7 +1787,6 @@ hinic3_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 	return ret;
 }
 
-/* Structure for managing flow table operations. */
 const struct rte_flow_ops hinic3_flow_ops = {
 	.validate = hinic3_flow_validate,
 	.create = hinic3_flow_create,
diff --git a/drivers/net/hinic3/hinic3_flow.h b/drivers/net/hinic3/hinic3_flow.h
deleted file mode 100644
index c4b38e44e7..0000000000
--- a/drivers/net/hinic3/hinic3_flow.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2025 Huawei Technologies Co., Ltd
- */
-
-#ifndef _HINIC3_FLOW_H_
-#define _HINIC3_FLOW_H_
-
-#include <rte_flow.h>
-
-/* Indicate the type of the IPv4 ICPM matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_icmp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH,
-	RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_ICMP,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 any protocol matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_any[] = {
-	RTE_FLOW_ITEM_TYPE_ETH,
-	RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_ANY,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the Ether matching pattern. */
-static enum rte_flow_item_type pattern_ethertype[] = {
-	RTE_FLOW_ITEM_TYPE_ETH,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the TCP matching pattern. */
-static enum rte_flow_item_type pattern_ethertype_tcp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH,
-	RTE_FLOW_ITEM_TYPE_TCP,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the UDP matching pattern. */
-static enum rte_flow_item_type pattern_ethertype_udp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH,
-	RTE_FLOW_ITEM_TYPE_UDP,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 vxlan matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_vxlan[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 vxlan any protocol matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_vxlan_any[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_ANY, RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 vxlan TCP matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_vxlan_tcp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_TCP, RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 vxlan UDP matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_vxlan_udp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 vxlan IPv4 matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_vxlan_ipv4[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 vxlan IPv4 TCP matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_vxlan_ipv4_tcp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_TCP, RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 vxlan IPv4 UDP matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_vxlan_ipv4_udp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 vxlan IPv6 matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_vxlan_ipv6[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV6,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 vxlan IPv6 TCP matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_vxlan_ipv6_tcp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV6,
-	RTE_FLOW_ITEM_TYPE_TCP, RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 vxlan IPv6 UDP matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_vxlan_ipv6_udp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV6,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 matching pattern. */
-static enum rte_flow_item_type pattern_ipv4[] = {
-	RTE_FLOW_ITEM_TYPE_ETH,
-	RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 UDP matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_udp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH,
-	RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_UDP,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv4 TCP matching pattern. */
-static enum rte_flow_item_type pattern_ipv4_tcp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH,
-	RTE_FLOW_ITEM_TYPE_IPV4,
-	RTE_FLOW_ITEM_TYPE_TCP,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv6 matching pattern. */
-static enum rte_flow_item_type pattern_ipv6[] = {
-	RTE_FLOW_ITEM_TYPE_ETH,
-	RTE_FLOW_ITEM_TYPE_IPV6,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv6 UDP matching pattern. */
-static enum rte_flow_item_type pattern_ipv6_udp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH,
-	RTE_FLOW_ITEM_TYPE_IPV6,
-	RTE_FLOW_ITEM_TYPE_UDP,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv6 TCP matching pattern. */
-static enum rte_flow_item_type pattern_ipv6_tcp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH,
-	RTE_FLOW_ITEM_TYPE_IPV6,
-	RTE_FLOW_ITEM_TYPE_TCP,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv6 TCP matching pattern. */
-static enum rte_flow_item_type pattern_ipv6_vxlan[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV6,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv6 VXLAN any protocol matching pattern. */
-static enum rte_flow_item_type pattern_ipv6_vxlan_any[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV6,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_ANY, RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv6 VXLAN TCP matching pattern. */
-static enum rte_flow_item_type pattern_ipv6_vxlan_tcp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV6,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_TCP, RTE_FLOW_ITEM_TYPE_END,
-};
-
-/* Indicate the type of the IPv6 VXLAN UDP matching pattern. */
-static enum rte_flow_item_type pattern_ipv6_vxlan_udp[] = {
-	RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_IPV6,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_VXLAN,
-	RTE_FLOW_ITEM_TYPE_UDP, RTE_FLOW_ITEM_TYPE_END,
-};
-
-#endif /**< _HINIC3_FLOW_H_ */
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 22/30] net/hinic3: add SP560 NIC type identification and handling
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (20 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 21/30] net/hinic3: refactor flow rule parsing Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 23/30] net/hinic3: add device kvargs parameters support Jiacheng Ye
                   ` (8 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Identify the new SP560 NIC through its PCI device ID and select NIC-type
specific operations. Extend the link speed reporting to 400G/800G and
enable the software compact CQE feature for the SP560.

Split prefetch, packet-drop and CEQ context setup into per-tile cmdq ops,
so the SP560 stn tile configures its own prefetch and coalescing
parameters, distinct from the htn tile used by the SP230. The htn ops set
the SP230 queue context to the values recommended for that tile.

The SW compact CQE path keeps Rx interrupts usable: when it is active, the
RQ CEQ EN bit enables the compact CEQ context instead of masking
interrupts, and interrupt delivery is controlled by the vector number in
the INTR field. The NIC therefore keeps advertising Rx interrupt support.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/nics/hinic3.rst                    |   2 +-
 doc/guides/rel_notes/release_26_11.rst        |   1 +
 drivers/net/hinic3/base/hinic3_csr.h          |   4 +
 drivers/net/hinic3/base/hinic3_hwif.c         |   4 +-
 drivers/net/hinic3/base/hinic3_nic_cfg.c      |   3 +-
 drivers/net/hinic3/base/hinic3_nic_cfg.h      |   6 +
 drivers/net/hinic3/base/hinic3_nic_event.c    |  63 ++++++++-
 drivers/net/hinic3/hinic3_ethdev.c            |  19 ++-
 drivers/net/hinic3/hinic3_ethdev.h            |   6 +-
 drivers/net/hinic3/hinic3_nic_io.c            | 132 ++++--------------
 drivers/net/hinic3/hinic3_nic_io.h            |  87 ++++++++++++
 drivers/net/hinic3/hinic3_rx.c                |  19 +++
 .../net/hinic3/htn_adapt/hinic3_htn_cmdq.c    |  48 +++++++
 .../net/hinic3/stn_adapt/hinic3_stn_cmdq.c    |  57 ++++++++
 14 files changed, 332 insertions(+), 119 deletions(-)

diff --git a/doc/guides/nics/hinic3.rst b/doc/guides/nics/hinic3.rst
index 4afa322bc3..f3123175fe 100644
--- a/doc/guides/nics/hinic3.rst
+++ b/doc/guides/nics/hinic3.rst
@@ -5,7 +5,7 @@ HINIC3 Poll Mode Driver
 =======================
 
 The hinic3 PMD (**librte_net_hinic3**) provides poll mode driver support
-for 25Gbps/100Gbps/200Gbps Huawei SPx series Network Adapters.
+for 25Gbps/100Gbps/200Gbps/400Gbps Huawei SP230, SP560 and SP620 series Network Adapters.
 
 
 Features
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index cc2e9d83c5..225e1aadf2 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -139,6 +139,7 @@ New Features
   * Added Geneve and VXLAN-GPE flow items, and raised the dynamic TCAM
     limit to 2048 entries on the STN tile.
   * Added mailbox message counter reporting through the device private dump API.
+  * Added support for the SP560 NIC.
 
 * **Updated Intel iavf driver.**
 
diff --git a/drivers/net/hinic3/base/hinic3_csr.h b/drivers/net/hinic3/base/hinic3_csr.h
index 7cae2419c0..82f20e2ea7 100644
--- a/drivers/net/hinic3/base/hinic3_csr.h
+++ b/drivers/net/hinic3/base/hinic3_csr.h
@@ -15,6 +15,10 @@
 
 #define HINIC3_DEV_ID_SP920	0x0224
 
+#define HINIC3_DEV_ID_SP560		0x0230
+#define HINIC3_DEV_ID_VF_SP560		0x0231
+#define HINIC3_DEV_ID_HYPER_VF_SP560	0x0232
+
 /*
  * Bit30/bit31 for bar index flag.
  * 00: bar0
diff --git a/drivers/net/hinic3/base/hinic3_hwif.c b/drivers/net/hinic3/base/hinic3_hwif.c
index c82b223fa0..af1dddabf4 100644
--- a/drivers/net/hinic3/base/hinic3_hwif.c
+++ b/drivers/net/hinic3/base/hinic3_hwif.c
@@ -141,7 +141,9 @@
 static inline bool hinic3_is_vf_dev(const struct rte_pci_device *pdev)
 {
 	return pdev->id.device_id == HINIC3_DEV_ID_VF_SP620 ||
-	       pdev->id.device_id == HINIC3_DEV_ID_VF_SP230;
+	       pdev->id.device_id == HINIC3_DEV_ID_VF_SP230 ||
+	       pdev->id.device_id == HINIC3_DEV_ID_VF_SP560 ||
+	       pdev->id.device_id == HINIC3_DEV_ID_HYPER_VF_SP560;
 }
 
 uint32_t
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.c b/drivers/net/hinic3/base/hinic3_nic_cfg.c
index c44ac1b083..f211b31eda 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.c
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.c
@@ -455,7 +455,8 @@ hinic3_set_vport_enable(struct hinic3_hwdev *hwdev, bool enable)
 	en_state.func_id = hinic3_global_func_id(hwdev);
 	en_state.state = enable ? 1 : 0;
 	en_state.num_qps = nic_dev->num_rqs;
-	en_state.rx_compact_wqe_en = HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev);
+	en_state.rx_compact_wqe_en = HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev) ||
+				     HINIC3_SUPPORT_RX_SW_COMPACT_CQE(nic_dev);
 
 	err = hinic3_msg_to_mgmt_sync(hwdev, HINIC3_MOD_L2NIC,
 				      HINIC3_NIC_CMD_SET_VPORT_ENABLE,
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.h b/drivers/net/hinic3/base/hinic3_nic_cfg.h
index 8c48f6d8a9..d7e7adf7be 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.h
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.h
@@ -62,6 +62,8 @@
 	((hinic3_get_driver_feature(dev) & NIC_F_##feature) != 0)
 #define HINIC3_SUPPORT_RX_HW_COMPACT_CQE(dev) \
 	HINIC3_SUPPORT_FEATURE(dev, RX_HW_COMPACT_CQE)
+#define HINIC3_SUPPORT_RX_SW_COMPACT_CQE(dev) \
+	HINIC3_SUPPORT_FEATURE(dev, RX_SW_COMPACT_CQE)
 #define HINIC3_SUPPORT_TX_WQE_COMPACT_TASK(dev) \
 	HINIC3_SUPPORT_FEATURE(dev, TX_WQE_COMPACT_TASK)
 #define HINIC3_SUPPORT_VXLAN_OFFLOAD(dev) \
@@ -126,6 +128,8 @@ enum nic_speed_level {
 	LINK_SPEED_50GB,
 	LINK_SPEED_100GB,
 	LINK_SPEED_200GB,
+	LINK_SPEED_400GB,
+	LINK_SPEED_800GB,
 	LINK_SPEED_LEVELS,
 };
 
@@ -180,6 +184,8 @@ enum mag_cmd_port_speed {
 	PORT_SPEED_50GB    = 7,
 	PORT_SPEED_100GB   = 8,
 	PORT_SPEED_200GB   = 9,
+	PORT_SPEED_400GB   = 10,
+	PORT_SPEED_800GB   = 11,
 	PORT_SPEED_UNKNOWN
 };
 
diff --git a/drivers/net/hinic3/base/hinic3_nic_event.c b/drivers/net/hinic3/base/hinic3_nic_event.c
index 0fe7b54981..16e4218969 100644
--- a/drivers/net/hinic3/base/hinic3_nic_event.c
+++ b/drivers/net/hinic3/base/hinic3_nic_event.c
@@ -15,6 +15,7 @@ static const char *g_hw_to_char_fec[HILINK_FEC_MAX_TYPE] = {
 static const char *g_hw_to_speed_info[PORT_SPEED_UNKNOWN] = {
 	"not set", "10MB", "100MB", "1GB",   "10GB",
 	"25GB",	   "40GB", "50GB",  "100GB", "200GB",
+	"400GB",   "800GB",
 };
 static const char *g_hw_to_an_state_info[PORT_CFG_AN_OFF + 1] = {
 	"not set", "on", "off",
@@ -25,6 +26,37 @@ struct port_type_table {
 	const char *port_type_name;
 };
 
+/*
+ * Hardware cable speed modes.
+ *
+ * The firmware reports the cable speed mode as a uint8_t value. Speeds whose raw
+ * Gbps value cannot be represented in 8 bits (notably 400G and 800G) are
+ * therefore encoded with indirection codes instead, and must be translated
+ * back to their real speeds through speed_mode_map[] below.
+ */
+enum {
+	HW_CABLE_SPEED_MODE_200G = 200,
+	HW_CABLE_SPEED_MODE_400G = 201,
+	HW_CABLE_SPEED_MODE_800G = 202,
+};
+
+/* Real cable speeds in Gbps, as exposed to the upper layer. */
+enum {
+	REAL_CABLE_SPEED_400G    = 400,
+	REAL_CABLE_SPEED_800G    = 800,
+};
+
+/* Mapping between a cable speed mode (uint8_t) and its real speed in Gbps. */
+struct speed_mode_map_entry {
+	uint8_t speed_mode;
+	uint32_t real_speed;
+};
+
+static const struct speed_mode_map_entry speed_mode_map[] = {
+	{HW_CABLE_SPEED_MODE_400G, REAL_CABLE_SPEED_400G},
+	{HW_CABLE_SPEED_MODE_800G, REAL_CABLE_SPEED_800G},
+};
+
 void
 hinic3_get_link_port_info(struct hinic3_hwdev *hwdev, uint8_t link_state,
 	      struct rte_eth_link *link)
@@ -35,6 +67,7 @@ hinic3_get_link_port_info(struct hinic3_hwdev *hwdev, uint8_t link_state,
 		RTE_ETH_SPEED_NUM_10G,	RTE_ETH_SPEED_NUM_25G,
 		RTE_ETH_SPEED_NUM_40G,	RTE_ETH_SPEED_NUM_50G,
 		RTE_ETH_SPEED_NUM_100G, RTE_ETH_SPEED_NUM_200G,
+		RTE_ETH_SPEED_NUM_400G, RTE_ETH_SPEED_NUM_800G
 	};
 	struct nic_port_info port_info = {0};
 	int err;
@@ -53,6 +86,14 @@ hinic3_get_link_port_info(struct hinic3_hwdev *hwdev, uint8_t link_state,
 			link->link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
 			link->link_autoneg = RTE_ETH_LINK_FIXED;
 		} else {
+			if (port_info.speed >= LINK_SPEED_LEVELS) {
+				PMD_DRV_LOG(WARNING,
+					"Invalid port speed %u reported by firmware, "
+					"reset to %u Mbps",
+					port_info.speed,
+					port_speed[port_info.speed % LINK_SPEED_LEVELS]);
+			}
+
 			link->link_speed =
 				port_speed[port_info.speed % LINK_SPEED_LEVELS];
 			link->link_duplex = port_info.duplex;
@@ -176,6 +217,22 @@ get_port_temperature_power(struct mag_cmd_event_port_info *info, char *str)
 	return 0;
 }
 
+static uint32_t
+get_real_cable_speed(uint8_t speed)
+{
+	uint32_t i;
+
+	if (speed <= HW_CABLE_SPEED_MODE_200G)
+		return speed;
+	for (i = 0; i < RTE_DIM(speed_mode_map); i++) {
+		if (speed_mode_map[i].speed_mode == speed)
+			return speed_mode_map[i].real_speed;
+	}
+
+	PMD_DRV_LOG(ERR, "unsupported cable speed mode: 0x%x", speed);
+	return speed;
+}
+
 static void
 print_cable_info(struct mag_cmd_event_port_info *port_info)
 {
@@ -201,9 +258,9 @@ print_cable_info(struct mag_cmd_event_port_info *port_info)
 	memcpy(vendor, port_info->vendor_name,
 	       sizeof(port_info->vendor_name));
 	snprintf(str, CAP_INFO_MAX_LEN - 1,
-		     "Vendor: %s, %s, length: %um, max_speed: %uGbps",
-		     vendor, port_type, port_info->cable_length,
-		     port_info->max_speed);
+	     "Vendor: %s, %s, length: %um, max_speed: %uGbps",
+	     vendor, port_type, port_info->cable_length,
+	     get_real_cable_speed(port_info->max_speed));
 
 	if (port_info->port_type == LINK_PORT_OPTICAL_MM ||
 	    port_info->port_type == LINK_PORT_AOC) {
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 2ffebddf3a..efa54c2ae4 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -553,6 +553,10 @@ hinic3_get_nic_type(struct rte_pci_device *pci_dev)
 	case HINIC3_DEV_ID_SP230:
 	case HINIC3_DEV_ID_VF_SP230:
 		return NIC_SP230;
+	case HINIC3_DEV_ID_SP560:
+	case HINIC3_DEV_ID_VF_SP560:
+	case HINIC3_DEV_ID_HYPER_VF_SP560:
+		return NIC_SP560;
 	default:
 		return NIC_UNKNOWN;
 	}
@@ -1189,7 +1193,8 @@ hinic3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 	}
 
 	/* If NIC support compact CQE, use compact wqe as default. */
-	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev)) {
+	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev) ||
+	    HINIC3_SUPPORT_RX_SW_COMPACT_CQE(nic_dev)) {
 		rxq->wqe_type = HINIC3_COMPACT_RQ_WQE;
 	} else {
 		if (buf_size >= HINIC3_RX_BUF_SIZE_4K &&
@@ -1249,7 +1254,8 @@ hinic3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 		goto alloc_rx_info_fail;
 	}
 
-	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev)) {
+	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev) ||
+	    HINIC3_SUPPORT_RX_SW_COMPACT_CQE(nic_dev)) {
 		ci_mz = hinic3_dma_zone_reserve(dev, "hinic3_ci_mz", qid,
 						sizeof(*rxq->rq_ci),
 						RTE_CACHE_LINE_SIZE, (int)socket_id);
@@ -1488,7 +1494,8 @@ hinic3_rx_queue_release(struct rte_eth_dev *dev, uint16_t queue_id)
 
 	hinic3_free_rxq_mbufs(rxq);
 
-	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev))
+	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev) ||
+	    HINIC3_SUPPORT_RX_SW_COMPACT_CQE(nic_dev))
 		hinic3_memzone_free(rxq->ci_mz);
 	else
 		hinic3_memzone_free(rxq->cqe_mz);
@@ -3819,7 +3826,8 @@ static void hinic3_nic_tx_rx_ops_init(struct hinic3_nic_dev *nic_dev)
 	else
 		nic_dev->tx_ops->nic_tx_set_wqe_offload = hinic3_tx_set_normal_task_offload;
 
-	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev)) {
+	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev) ||
+	    HINIC3_SUPPORT_RX_SW_COMPACT_CQE(nic_dev)) {
 		nic_dev->rx_ops->nic_rx_get_cqe_info = hinic3_rx_get_compact_cqe_info;
 		nic_dev->rx_ops->nic_rx_cqe_done = hinic3_rx_integrated_cqe_done;
 		nic_dev->rx_ops->nic_rx_poll_rq_empty = hinic3_poll_integrated_cqe_rq_empty;
@@ -4104,6 +4112,9 @@ static const struct rte_pci_id pci_id_hinic3_map[] = {
 	{RTE_PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, HINIC3_DEV_ID_VF_SP230)},
 
 	{RTE_PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, HINIC3_DEV_ID_SP920)},
+	{RTE_PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, HINIC3_DEV_ID_SP560)},
+	{RTE_PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, HINIC3_DEV_ID_VF_SP560)},
+	{RTE_PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, HINIC3_DEV_ID_HYPER_VF_SP560)},
 
 	{.vendor_id = 0},
 };
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index 13c9c69e7f..e4f1a5b51c 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -102,7 +102,7 @@ enum nic_feature_cap {
 
 };
 
-#define DEFAULT_DRV_FEATURE		0x3FC3FFF
+#define DEFAULT_DRV_FEATURE		0x0BFC3FFF
 
 TAILQ_HEAD(hinic3_ethertype_filter_list, rte_flow);
 TAILQ_HEAD(hinic3_fdir_rule_filter_list, rte_flow);
@@ -110,7 +110,8 @@ TAILQ_HEAD(hinic3_fdir_rule_filter_list, rte_flow);
 enum nic_type {
 	NIC_SP620 = 0,
 	NIC_SP230 = 1,
-	NIC_UNKNOWN = 2,
+	NIC_SP560 = 2,
+	NIC_UNKNOWN = 3,
 };
 
 struct hinic3_nic_dev {
@@ -172,6 +173,7 @@ struct hinic3_nic_dev {
 
 #define HINIC3_IS_SP620_NIC(nic_dev) ((nic_dev)->nic_type == NIC_SP620)
 #define HINIC3_IS_SP230_NIC(nic_dev) ((nic_dev)->nic_type == NIC_SP230)
+#define HINIC3_IS_SP560_NIC(nic_dev) ((nic_dev)->nic_type == NIC_SP560)
 
 extern const struct rte_flow_ops hinic3_flow_ops;
 
diff --git a/drivers/net/hinic3/hinic3_nic_io.c b/drivers/net/hinic3/hinic3_nic_io.c
index 361586868e..d4c53645c4 100644
--- a/drivers/net/hinic3/hinic3_nic_io.c
+++ b/drivers/net/hinic3/hinic3_nic_io.c
@@ -13,12 +13,6 @@
 
 #define HINIC3_DEAULT_TX_CI_PENDING_LIMIT	3
 #define HINIC3_DEAULT_TX_CI_COALESCING_TIME	16
-#define HINIC3_DEAULT_DROP_THD_ON		0xFFFF
-#define HINIC3_DEAULT_DROP_THD_OFF		0
-
-#define WQ_PREFETCH_MAX				6
-#define WQ_PREFETCH_MIN				1
-#define WQ_PREFETCH_THRESHOLD			256
 
 #define CI_IDX_HIGH_SHIFH			12
 
@@ -53,16 +47,6 @@
 	(((val) & SQ_CTXT_WQ_PAGE_##member##_MASK)	\
 	 << SQ_CTXT_WQ_PAGE_##member##_SHIFT)
 
-#define SQ_CTXT_PKT_DROP_THD_ON_SHIFT		0
-#define SQ_CTXT_PKT_DROP_THD_OFF_SHIFT		16
-
-#define SQ_CTXT_PKT_DROP_THD_ON_MASK		0xFFFFU
-#define SQ_CTXT_PKT_DROP_THD_OFF_MASK		0xFFFFU
-
-#define SQ_CTXT_PKT_DROP_THD_SET(val, member)		\
-	(((val) & SQ_CTXT_PKT_DROP_##member##_MASK)	\
-	 << SQ_CTXT_PKT_DROP_##member##_SHIFT)
-
 #define SQ_CTXT_GLOBAL_SQ_ID_SHIFT		0
 
 #define SQ_CTXT_GLOBAL_SQ_ID_MASK		0x1FFFU
@@ -84,30 +68,6 @@
 	(((val) & SQ_CTXT_VLAN_##member##_MASK)		\
 	 << SQ_CTXT_VLAN_##member##_SHIFT)
 
-#define SQ_CTXT_PREF_CACHE_THRESHOLD_SHIFT	0
-#define SQ_CTXT_PREF_CACHE_MAX_SHIFT		14
-#define SQ_CTXT_PREF_CACHE_MIN_SHIFT		25
-
-#define SQ_CTXT_PREF_CACHE_THRESHOLD_MASK	0x3FFFU
-#define SQ_CTXT_PREF_CACHE_MAX_MASK		0x7FFU
-#define SQ_CTXT_PREF_CACHE_MIN_MASK		0x7FU
-
-#define SQ_CTXT_PREF_CI_HI_SHIFT		0
-#define SQ_CTXT_PREF_OWNER_SHIFT		4
-
-#define SQ_CTXT_PREF_CI_HI_MASK			0xFU
-#define SQ_CTXT_PREF_OWNER_MASK			0x1U
-
-#define SQ_CTXT_PREF_WQ_PFN_HI_SHIFT		0
-#define SQ_CTXT_PREF_CI_LOW_SHIFT		20
-
-#define SQ_CTXT_PREF_WQ_PFN_HI_MASK		0xFFFFFU
-#define SQ_CTXT_PREF_CI_LOW_MASK		0xFFFU
-
-#define SQ_CTXT_PREF_SET(val, member)			\
-	(((val) & SQ_CTXT_PREF_##member##_MASK)		\
-	 << SQ_CTXT_PREF_##member##_SHIFT)
-
 #define SQ_CTXT_WQ_BLOCK_PFN_HI_SHIFT		0
 
 #define SQ_CTXT_WQ_BLOCK_PFN_HI_MASK		0x7FFFFFU
@@ -125,18 +85,6 @@
 #define RQ_CTXT_CI_PI_SET(val, member)			\
 	(((val) & RQ_CTXT_##member##_MASK) << RQ_CTXT_##member##_SHIFT)
 
-#define RQ_CTXT_CEQ_ATTR_INTR_SHIFT		21
-#define RQ_CTXT_CEQ_ATTR_INTR_ARM_SHIFT		30
-#define RQ_CTXT_CEQ_ATTR_EN_SHIFT		31
-
-#define RQ_CTXT_CEQ_ATTR_INTR_MASK		0x3FFU
-#define RQ_CTXT_CEQ_ATTR_INTR_ARM_MASK		0x1U
-#define RQ_CTXT_CEQ_ATTR_EN_MASK		0x1U
-
-#define RQ_CTXT_CEQ_ATTR_SET(val, member)		\
-	(((val) & RQ_CTXT_CEQ_ATTR_##member##_MASK)	\
-	 << RQ_CTXT_CEQ_ATTR_##member##_SHIFT)
-
 #define RQ_CTXT_WQ_PAGE_HI_PFN_SHIFT		0
 #define RQ_CTXT_WQ_PAGE_WQE_TYPE_SHIFT		28
 #define RQ_CTXT_WQ_PAGE_OWNER_SHIFT		31
@@ -149,37 +97,6 @@
 	(((val) & RQ_CTXT_WQ_PAGE_##member##_MASK)	\
 	 << RQ_CTXT_WQ_PAGE_##member##_SHIFT)
 
-#define RQ_CTXT_CQE_LEN_SHIFT			28
-
-#define RQ_CTXT_CQE_LEN_MASK			0x3U
-
-#define RQ_CTXT_CQE_LEN_SET(val, member)		\
-	(((val) & RQ_CTXT_##member##_MASK) << RQ_CTXT_##member##_SHIFT)
-
-#define RQ_CTXT_PREF_CACHE_THRESHOLD_SHIFT	0
-#define RQ_CTXT_PREF_CACHE_MAX_SHIFT		14
-#define RQ_CTXT_PREF_CACHE_MIN_SHIFT		25
-
-#define RQ_CTXT_PREF_CACHE_THRESHOLD_MASK	0x3FFFU
-#define RQ_CTXT_PREF_CACHE_MAX_MASK		0x7FFU
-#define RQ_CTXT_PREF_CACHE_MIN_MASK		0x7FU
-
-#define RQ_CTXT_PREF_CI_HI_SHIFT		0
-#define RQ_CTXT_PREF_OWNER_SHIFT		4
-
-#define RQ_CTXT_PREF_CI_HI_MASK			0xFU
-#define RQ_CTXT_PREF_OWNER_MASK			0x1U
-
-#define RQ_CTXT_PREF_WQ_PFN_HI_SHIFT		0
-#define RQ_CTXT_PREF_CI_LOW_SHIFT		20
-
-#define RQ_CTXT_PREF_WQ_PFN_HI_MASK		0xFFFFFU
-#define RQ_CTXT_PREF_CI_LOW_MASK		0xFFFU
-
-#define RQ_CTXT_PREF_SET(val, member)			\
-	(((val) & RQ_CTXT_PREF_##member##_MASK)		\
-	 << RQ_CTXT_PREF_##member##_SHIFT)
-
 #define RQ_CTXT_WQ_BLOCK_PFN_HI_SHIFT		0
 
 #define RQ_CTXT_WQ_BLOCK_PFN_HI_MASK		0x7FFFFFU
@@ -206,6 +123,10 @@ hinic3_sq_prepare_ctxt(struct hinic3_txq *sq, uint16_t sq_id,
 	uint32_t wq_page_pfn_hi, wq_page_pfn_lo, wq_block_pfn_hi, wq_block_pfn_lo;
 	uint16_t pi_start, ci_start;
 
+	memset(sq_ctxt, 0, sizeof(*sq_ctxt));
+
+	hinic3_cmdq_get_ops(sq->nic_dev)->prepare_sq_ctxt_drop_and_prefetch(sq_ctxt);
+
 	ci_start = sq->cons_idx & sq->q_mask;
 	pi_start = sq->prod_idx & sq->q_mask;
 
@@ -232,10 +153,6 @@ hinic3_sq_prepare_ctxt(struct hinic3_txq *sq, uint16_t sq_id,
 
 	sq_ctxt->wq_pfn_lo = wq_page_pfn_lo;
 
-	sq_ctxt->pkt_drop_thd =
-		SQ_CTXT_PKT_DROP_THD_SET(HINIC3_DEAULT_DROP_THD_ON, THD_ON) |
-		SQ_CTXT_PKT_DROP_THD_SET(HINIC3_DEAULT_DROP_THD_OFF, THD_OFF);
-
 	sq_ctxt->global_sq_id =
 		SQ_CTXT_GLOBAL_QUEUE_ID_SET(sq_id, GLOBAL_SQ_ID);
 
@@ -245,11 +162,6 @@ hinic3_sq_prepare_ctxt(struct hinic3_txq *sq, uint16_t sq_id,
 
 	sq_ctxt->rsvd0 = 0;
 
-	sq_ctxt->pref_cache =
-		SQ_CTXT_PREF_SET(WQ_PREFETCH_MIN, CACHE_MIN) |
-		SQ_CTXT_PREF_SET(WQ_PREFETCH_MAX, CACHE_MAX) |
-		SQ_CTXT_PREF_SET(WQ_PREFETCH_THRESHOLD, CACHE_THRESHOLD);
-
 	sq_ctxt->pref_ci_owner =
 		SQ_CTXT_PREF_SET(CI_HIGN_IDX(ci_start), CI_HI) |
 		SQ_CTXT_PREF_SET(1, OWNER);
@@ -278,6 +190,9 @@ hinic3_rq_prepare_ctxt(struct hinic3_rxq *rq, struct hinic3_rq_ctxt *rq_ctxt)
 	uint16_t pi_start, ci_start;
 	uint16_t wqe_type = rq->wqe_type;
 	uint8_t intr_disable;
+	bool support_rq_sw_compact_cqe = false;
+
+	memset(rq_ctxt, 0, sizeof(*rq_ctxt));
 
 	/* RQ depth is in unit of 8 Bytes. */
 	ci_start = (uint16_t)((rq->cons_idx & rq->q_mask) << wqe_type);
@@ -292,38 +207,47 @@ hinic3_rq_prepare_ctxt(struct hinic3_rxq *rq, struct hinic3_rq_ctxt *rq_ctxt)
 
 	/* Use 0-level CLA. */
 	wq_block_pfn = WQ_BLOCK_PFN(wq_page_addr);
+
 	wq_block_pfn_hi = upper_32_bits(wq_block_pfn);
 	wq_block_pfn_lo = lower_32_bits(wq_block_pfn);
 
 	rq_ctxt->ci_pi = RQ_CTXT_CI_PI_SET(ci_start, CI_IDX) |
 			 RQ_CTXT_CI_PI_SET(pi_start, PI_IDX);
 
-	/* RQ doesn't need ceq, msix_entry_idx set 1, but mask not enable. */
+	/* RQ doesn't need ceq, msix_entry_idx set 1, but mask not enable */
 	intr_disable = rq->dp_intr_en ? 0 : 1;
-	rq_ctxt->ceq_attr = RQ_CTXT_CEQ_ATTR_SET(intr_disable, EN) |
-			    RQ_CTXT_CEQ_ATTR_SET(0, INTR_ARM) |
-			    RQ_CTXT_CEQ_ATTR_SET(rq->msix_entry_idx, INTR);
+	support_rq_sw_compact_cqe = HINIC3_SUPPORT_RX_SW_COMPACT_CQE(rq->nic_dev);
+	hinic3_cmdq_get_ops(rq->nic_dev)->prepare_rq_ctxt_ceq_and_prefetch(rq_ctxt,
+		wqe_type, rq->msix_entry_idx, support_rq_sw_compact_cqe, intr_disable);
 
-	/* Use 32Byte WQE with SGE for CQE in default. */
+	/* Use 32Byte WQE with SGE for CQE in default */
 	rq_ctxt->wq_pfn_hi_type_owner =
 		RQ_CTXT_WQ_PAGE_SET(wq_page_pfn_hi, HI_PFN) |
 		RQ_CTXT_WQ_PAGE_SET(1, OWNER);
+	rq_ctxt->pi_paddr_hi = upper_32_bits(rq->pi_dma_addr);
+	rq_ctxt->pi_paddr_lo = lower_32_bits(rq->pi_dma_addr);
 
 	switch (wqe_type) {
 	case HINIC3_EXTEND_RQ_WQE:
-		/* Use 32Byte WQE with SGE for CQE. */
+		/* Use 32Byte WQE with SGE for CQE */
 		rq_ctxt->wq_pfn_hi_type_owner |=
 			RQ_CTXT_WQ_PAGE_SET(0, WQE_TYPE);
 		break;
 	case HINIC3_NORMAL_RQ_WQE:
-		/* Use 16Byte WQE with 32Bytes SGE for CQE. */
+		/* Use 16Byte WQE with 32Bytes SGE for CQE */
 		rq_ctxt->wq_pfn_hi_type_owner |=
 			RQ_CTXT_WQ_PAGE_SET(2, WQE_TYPE);
 		rq_ctxt->cqe_sge_len = RQ_CTXT_CQE_LEN_SET(1, CQE_LEN);
 		break;
 	case HINIC3_COMPACT_RQ_WQE:
-		/* Use 8Byte WQE without SGE for CQE. */
+		/* Use 8Byte WQE without SGE for CQE */
 		rq_ctxt->wq_pfn_hi_type_owner |= RQ_CTXT_WQ_PAGE_SET(3, WQE_TYPE);
+		if (HINIC3_SUPPORT_RX_SW_COMPACT_CQE(rq->nic_dev)) {
+			rq_ctxt->cqe_sge_len |=
+				RQ_CTXT_CQE_LEN_SET(RQ_CQE_AGGREGATE_NUM, MAX_COUNT);
+			rq_ctxt->pi_paddr_hi = upper_32_bits(rq->rq_ci_paddr >> RQ_CI_ADDR_SHIFT);
+			rq_ctxt->pi_paddr_lo = lower_32_bits(rq->rq_ci_paddr >> RQ_CI_ADDR_SHIFT);
+		}
 		break;
 	default:
 		PMD_DRV_LOG(INFO, "Invalid rq wqe type: %u", wqe_type);
@@ -331,11 +255,6 @@ hinic3_rq_prepare_ctxt(struct hinic3_rxq *rq, struct hinic3_rq_ctxt *rq_ctxt)
 
 	rq_ctxt->wq_pfn_lo = wq_page_pfn_lo;
 
-	rq_ctxt->pref_cache =
-		RQ_CTXT_PREF_SET(WQ_PREFETCH_MIN, CACHE_MIN) |
-		RQ_CTXT_PREF_SET(WQ_PREFETCH_MAX, CACHE_MAX) |
-		RQ_CTXT_PREF_SET(WQ_PREFETCH_THRESHOLD, CACHE_THRESHOLD);
-
 	rq_ctxt->pref_ci_owner =
 		RQ_CTXT_PREF_SET(CI_HIGN_IDX(ci_start), CI_HI) |
 		RQ_CTXT_PREF_SET(1, OWNER);
@@ -346,8 +265,7 @@ hinic3_rq_prepare_ctxt(struct hinic3_rxq *rq, struct hinic3_rq_ctxt *rq_ctxt)
 
 	rq_ctxt->pref_wq_pfn_lo = wq_page_pfn_lo;
 
-	rq_ctxt->pi_paddr_hi = upper_32_bits(rq->pi_dma_addr);
-	rq_ctxt->pi_paddr_lo = lower_32_bits(rq->pi_dma_addr);
+
 
 	rq_ctxt->wq_block_pfn_hi =
 		RQ_CTXT_WQ_BLOCK_SET(wq_block_pfn_hi, PFN_HI);
diff --git a/drivers/net/hinic3/hinic3_nic_io.h b/drivers/net/hinic3/hinic3_nic_io.h
index d7ec81f2e6..3b99c9ba68 100644
--- a/drivers/net/hinic3/hinic3_nic_io.h
+++ b/drivers/net/hinic3/hinic3_nic_io.h
@@ -28,6 +28,81 @@
 
 #define HINIC3_Q_CTXT_MAX ((uint16_t)(((HINIC3_CMDQ_BUF_SIZE - 8) - RTE_PKTMBUF_HEADROOM) / 64))
 
+#define RQ_CTXT_PREF_CACHE_THRESHOLD_SHIFT	0
+#define RQ_CTXT_PREF_CACHE_MAX_SHIFT		14
+#define RQ_CTXT_PREF_CACHE_MIN_SHIFT		25
+
+#define RQ_CTXT_PREF_CACHE_THRESHOLD_MASK	0x3FFFU
+#define RQ_CTXT_PREF_CACHE_MAX_MASK		0x7FFU
+#define RQ_CTXT_PREF_CACHE_MIN_MASK		0x7FU
+
+#define RQ_CTXT_PREF_CI_HI_SHIFT		0
+#define RQ_CTXT_PREF_OWNER_SHIFT		4
+
+#define RQ_CTXT_PREF_CI_HI_MASK			0xFU
+#define RQ_CTXT_PREF_OWNER_MASK			0x1U
+
+#define RQ_CTXT_PREF_WQ_PFN_HI_SHIFT		0
+#define RQ_CTXT_PREF_CI_LOW_SHIFT		20
+
+#define RQ_CTXT_PREF_WQ_PFN_HI_MASK		0xFFFFFU
+#define RQ_CTXT_PREF_CI_LOW_MASK		0xFFFU
+
+#define RQ_CTXT_PREF_SET(val, member)		(((val) & \
+						RQ_CTXT_PREF_##member##_MASK) << \
+						RQ_CTXT_PREF_##member##_SHIFT)
+
+#define RQ_CTXT_CEQ_ATTR_SET(val, member)	(((val) & \
+						RQ_CTXT_CEQ_ATTR_##member##_MASK) \
+						<< RQ_CTXT_CEQ_ATTR_##member##_SHIFT)
+
+#define RQ_CTXT_CQE_LEN_SHIFT			28
+#define RQ_CTXT_MAX_COUNT_SHIFT			18
+
+#define RQ_CTXT_CQE_LEN_MASK			0x3U
+#define RQ_CTXT_MAX_COUNT_MASK			0x3FFU
+#define RQ_CTXT_CQE_LEN_SET(val, member)	(((val) & \
+						RQ_CTXT_##member##_MASK) << \
+						RQ_CTXT_##member##_SHIFT)
+
+#define SQ_CI_ADDR_SHIFT	2
+#define RQ_CI_ADDR_SHIFT	4
+#define RQ_CQE_AGGREGATE_NUM		768
+
+#define SQ_CTXT_PREF_CACHE_THRESHOLD_SHIFT	0
+#define SQ_CTXT_PREF_CACHE_MAX_SHIFT		14
+#define SQ_CTXT_PREF_CACHE_MIN_SHIFT		25
+
+#define SQ_CTXT_PREF_CACHE_THRESHOLD_MASK	0x3FFFU
+#define SQ_CTXT_PREF_CACHE_MAX_MASK		0x7FFU
+#define SQ_CTXT_PREF_CACHE_MIN_MASK		0x7FU
+
+#define SQ_CTXT_PREF_CI_HI_SHIFT		0
+#define SQ_CTXT_PREF_OWNER_SHIFT		4
+
+#define SQ_CTXT_PREF_CI_HI_MASK			0xFU
+#define SQ_CTXT_PREF_OWNER_MASK			0x1U
+
+#define SQ_CTXT_PREF_WQ_PFN_HI_SHIFT		0
+#define SQ_CTXT_PREF_CI_LOW_SHIFT		20
+
+#define SQ_CTXT_PREF_WQ_PFN_HI_MASK		0xFFFFFU
+#define SQ_CTXT_PREF_CI_LOW_MASK		0xFFFU
+
+#define SQ_CTXT_PREF_SET(val, member)		(((val) & \
+						SQ_CTXT_PREF_##member##_MASK) \
+						<< SQ_CTXT_PREF_##member##_SHIFT)
+
+#define SQ_CTXT_PKT_DROP_THD_ON_SHIFT		0
+#define SQ_CTXT_PKT_DROP_THD_OFF_SHIFT		16
+
+#define SQ_CTXT_PKT_DROP_THD_ON_MASK		0xFFFFU
+#define SQ_CTXT_PKT_DROP_THD_OFF_MASK		0xFFFFU
+
+#define SQ_CTXT_PKT_DROP_THD_SET(val, member)	(((val) & \
+						SQ_CTXT_PKT_DROP_##member##_MASK) \
+						<< SQ_CTXT_PKT_DROP_##member##_SHIFT)
+
 enum hinic3_rq_wqe_type {
 	HINIC3_COMPACT_RQ_WQE,
 	HINIC3_NORMAL_RQ_WQE,
@@ -69,6 +144,16 @@ typedef uint8_t  (*prepare_cmd_buf_get_rss_indir_table_t)(struct hinic3_nic_dev
 /* Configure RSS indir table */
 typedef void     (*cmd_buf_to_rss_indir_table_t)(const struct hinic3_cmd_buf *cmd_buf,
 						 uint32_t *indir_table);
+struct hinic3_rq_ctxt;
+struct hinic3_sq_ctxt;
+
+typedef void	 (*prepare_rq_ctxt_ceq_and_prefetch_t)(struct hinic3_rq_ctxt *rq_ctxt,
+						       uint16_t wqe_type,
+						       uint16_t msix_entry_idx,
+						       bool support_rq_sw_compact_cqe,
+						       uint8_t intr_disable);
+
+typedef void	 (*prepare_sq_ctxt_drop_and_prefetch_t)(struct hinic3_sq_ctxt *sq_ctxt);
 
 struct hinic3_nic_cmdq_ops {
 	prepare_cmd_buf_clean_tso_lro_space_t		prepare_cmd_buf_clean_tso_lro_space;
@@ -77,6 +162,8 @@ struct hinic3_nic_cmdq_ops {
 	prepare_cmd_buf_set_rss_indir_table_t		prepare_cmd_buf_set_rss_indir_table;
 	prepare_cmd_buf_get_rss_indir_table_t		prepare_cmd_buf_get_rss_indir_table;
 	cmd_buf_to_rss_indir_table_t			cmd_buf_to_rss_indir_table;
+	prepare_rq_ctxt_ceq_and_prefetch_t		prepare_rq_ctxt_ceq_and_prefetch;
+	prepare_sq_ctxt_drop_and_prefetch_t		prepare_sq_ctxt_drop_and_prefetch;
 };
 
 /**
diff --git a/drivers/net/hinic3/hinic3_rx.c b/drivers/net/hinic3/hinic3_rx.c
index 74dfddac9d..eef4ab5a30 100644
--- a/drivers/net/hinic3/hinic3_rx.c
+++ b/drivers/net/hinic3/hinic3_rx.c
@@ -639,6 +639,25 @@ hinic3_poll_integrated_cqe_rq_empty(struct hinic3_rxq *rxq)
 	rq_ci.dw1.value = hinic3_hw_cpu32(val);
 	hw_ci = rq_ci.dw1.bs.hw_ci;
 
+	if (HINIC3_IS_SP560_NIC(rxq->nic_dev)) {
+		uint16_t sw_pi = hinic3_get_rq_local_pi(rxq);
+		uint64_t end;
+
+		end = cycles + msecs_to_cycles(HINIC3_FLUSH_QUEUE_TIMEOUT);
+		do {
+			val = rte_read32(&rxq->rq_ci->dw1.value);
+			rq_ci.dw1.value = hinic3_hw_cpu32(val);
+			hw_ci = rq_ci.dw1.bs.hw_ci;
+			if (sw_pi == hw_ci)
+				break;
+
+			rte_delay_us(1);
+		} while (time_before(cycles, end));
+
+		if (sw_pi != hw_ci)
+			return -EFAULT;
+	}
+
 	while (sw_ci != hw_ci) {
 		rx_info = &rxq->rx_info[sw_ci];
 		rte_pktmbuf_free(rx_info->mbuf);
diff --git a/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.c b/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.c
index 607fe2d0fe..abf6644f35 100644
--- a/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.c
+++ b/drivers/net/hinic3/htn_adapt/hinic3_htn_cmdq.c
@@ -8,6 +8,27 @@
 #include "hinic3_hwif.h"
 #include "hinic3_htn_cmdq.h"
 
+#define HINIC3_DEFAULT_DROP_THD_OFF	0xFFFF
+#define HINIC3_DEFAULT_DROP_THD_ON	0xFFFF
+
+#define SQ_PREFETCH_MAX			5
+#define SQ_PREFETCH_MIN			4
+#define SQ_PREFETCH_THRESHOLD		48
+
+#define RQ_PREFETCH_MAX			4
+#define RQ_PREFETCH_MIN			2
+#define RQ_PREFETCH_THRESHOLD		32
+
+#define RQ_PFH_TH			7
+
+#define RQ_CTXT_CEQ_ATTR_PFH_TH_SHIFT	0
+#define RQ_CTXT_CEQ_ATTR_INTR_SHIFT	21
+#define RQ_CTXT_CEQ_ATTR_EN_SHIFT	31
+
+#define RQ_CTXT_CEQ_ATTR_PFH_TH_MASK	0x1FU
+#define RQ_CTXT_CEQ_ATTR_EN_MASK	0x1U
+#define RQ_CTXT_CEQ_ATTR_INTR_MASK	0x3FFU
+
 #define HTN_SQ_CTXT_SIZE(num_sqs)	((uint16_t)(sizeof(struct hinic3_htn_qp_ctxt_header) \
 						    + (num_sqs) * sizeof(struct hinic3_sq_ctxt)))
 #define HTN_RQ_CTXT_SIZE(num_rqs)	((uint16_t)(sizeof(struct hinic3_htn_qp_ctxt_header) \
@@ -152,6 +173,31 @@ static void cmd_buf_to_rss_indir_table(const struct hinic3_cmd_buf *cmd_buf, uin
 		indir_table[i] = *(indir_tbl + i);
 }
 
+static void
+prepare_sq_ctxt_drop_and_prefetch(struct hinic3_sq_ctxt *sq_ctxt)
+{
+	sq_ctxt->pkt_drop_thd = SQ_CTXT_PKT_DROP_THD_SET(HINIC3_DEFAULT_DROP_THD_ON, THD_ON) |
+				SQ_CTXT_PKT_DROP_THD_SET(HINIC3_DEFAULT_DROP_THD_OFF, THD_OFF);
+
+	sq_ctxt->pref_cache = SQ_CTXT_PREF_SET(SQ_PREFETCH_MIN, CACHE_MIN) |
+			      SQ_CTXT_PREF_SET(SQ_PREFETCH_MAX, CACHE_MAX) |
+			      SQ_CTXT_PREF_SET(SQ_PREFETCH_THRESHOLD, CACHE_THRESHOLD);
+}
+
+static void
+prepare_rq_ctxt_ceq_and_prefetch(struct hinic3_rq_ctxt *rq_ctxt, uint16_t wqe_type __rte_unused,
+	uint16_t msix_entry_idx, bool support_rq_sw_compact_cqe __rte_unused,
+	uint8_t intr_disable)
+{
+	rq_ctxt->ceq_attr = RQ_CTXT_CEQ_ATTR_SET(intr_disable, EN) |
+			    RQ_CTXT_CEQ_ATTR_SET(RQ_PFH_TH, PFH_TH) |
+			    RQ_CTXT_CEQ_ATTR_SET(msix_entry_idx, INTR);
+
+	rq_ctxt->pref_cache = RQ_CTXT_PREF_SET(RQ_PREFETCH_MIN, CACHE_MIN) |
+			      RQ_CTXT_PREF_SET(RQ_PREFETCH_MAX, CACHE_MAX) |
+			      RQ_CTXT_PREF_SET(RQ_PREFETCH_THRESHOLD, CACHE_THRESHOLD);
+}
+
 const struct hinic3_nic_cmdq_ops hinic3_htn_cmdq_ops = {
 	.prepare_cmd_buf_clean_tso_lro_space =    prepare_cmd_buf_clean_tso_lro_space,
 	.prepare_cmd_buf_qp_context_multi_store = prepare_cmd_buf_qp_context_multi_store,
@@ -159,4 +205,6 @@ const struct hinic3_nic_cmdq_ops hinic3_htn_cmdq_ops = {
 	.prepare_cmd_buf_set_rss_indir_table =    prepare_cmd_buf_set_rss_indir_table,
 	.prepare_cmd_buf_get_rss_indir_table =    prepare_cmd_buf_get_rss_indir_table,
 	.cmd_buf_to_rss_indir_table =             cmd_buf_to_rss_indir_table,
+	.prepare_sq_ctxt_drop_and_prefetch =      prepare_sq_ctxt_drop_and_prefetch,
+	.prepare_rq_ctxt_ceq_and_prefetch =       prepare_rq_ctxt_ceq_and_prefetch,
 };
diff --git a/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.c b/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.c
index 23adbc79f4..be23f991f1 100644
--- a/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.c
+++ b/drivers/net/hinic3/stn_adapt/hinic3_stn_cmdq.c
@@ -8,6 +8,24 @@
 #include "hinic3_hwif.h"
 #include "hinic3_stn_cmdq.h"
 
+#define HINIC3_DEFAULT_DROP_THD_ON			0xFFFF
+#define HINIC3_DEFAULT_DROP_THD_OFF			0
+#define WQ_PREFETCH_MAX					6
+#define WQ_PREFETCH_MIN					1
+#define WQ_PREFETCH_THRESHOLD				256
+
+#define RQ_CTXT_CEQ_ATTR_CI_WR_SHIFT			0
+#define RQ_CTXT_CEQ_ATTR_INTR_SHIFT			21
+#define RQ_CTXT_CEQ_ATTR_INTR_ARM_SHIFT			30
+#define RQ_CTXT_CEQ_ATTR_EN_SHIFT			31
+
+#define RQ_CTXT_CEQ_ATTR_CI_WR_MASK			0x1U
+#define RQ_CTXT_CEQ_ATTR_INTR_MASK			0x3FFU
+#define RQ_CTXT_CEQ_ATTR_INTR_ARM_MASK			0x1U
+#define RQ_CTXT_CEQ_ATTR_EN_MASK			0x1U
+/* Indicate ucode that this is an interrupt in the DPDK scenario. */
+#define RQ_CTXT_INVALID_INTR_NUM			0x1FFU
+
 #define STN_SQ_CTXT_SIZE(num_sqs)	((uint16_t)(sizeof(struct hinic3_stn_qp_ctxt_header) \
 						    + (num_sqs) * sizeof(struct hinic3_sq_ctxt)))
 #define STN_RQ_CTXT_SIZE(num_rqs)	((uint16_t)(sizeof(struct hinic3_stn_qp_ctxt_header) \
@@ -136,6 +154,43 @@ static void cmd_buf_to_rss_indir_table(const struct hinic3_cmd_buf *cmd_buf, uin
 		indir_table[i] = *(indir_tbl + i);
 }
 
+static void
+prepare_sq_ctxt_drop_and_prefetch(struct hinic3_sq_ctxt *sq_ctxt)
+{
+	sq_ctxt->pkt_drop_thd = SQ_CTXT_PKT_DROP_THD_SET(HINIC3_DEFAULT_DROP_THD_ON, THD_ON) |
+				SQ_CTXT_PKT_DROP_THD_SET(HINIC3_DEFAULT_DROP_THD_OFF, THD_OFF);
+
+	sq_ctxt->pref_cache = SQ_CTXT_PREF_SET(WQ_PREFETCH_MIN, CACHE_MIN) |
+			      SQ_CTXT_PREF_SET(WQ_PREFETCH_MAX, CACHE_MAX) |
+			      SQ_CTXT_PREF_SET(WQ_PREFETCH_THRESHOLD, CACHE_THRESHOLD);
+}
+
+static void
+prepare_rq_ctxt_ceq_and_prefetch(struct hinic3_rq_ctxt *rq_ctxt, uint16_t wqe_type,
+	uint16_t msix_entry_idx, bool support_rq_sw_compact_cqe, uint8_t intr_disable)
+{
+	uint16_t ceq_intr = intr_disable ? RQ_CTXT_INVALID_INTR_NUM : msix_entry_idx;
+
+	rq_ctxt->ceq_attr = RQ_CTXT_CEQ_ATTR_SET(intr_disable, EN) |
+			    RQ_CTXT_CEQ_ATTR_SET(0, INTR_ARM) |
+			    RQ_CTXT_CEQ_ATTR_SET(ceq_intr, INTR);
+	if (wqe_type == HINIC3_COMPACT_RQ_WQE && support_rq_sw_compact_cqe) {
+		/*
+		 * With the SW compact CQE, EN enables the CEQ context and must
+		 * be set for the attributes below to take effect; it does not
+		 * mask Rx interrupts. Interrupt delivery is controlled by the
+		 * INTR field above, where RQ_CTXT_INVALID_INTR_NUM keeps the
+		 * queue silent while a valid vector enables the interrupt.
+		 */
+		rq_ctxt->ceq_attr |= RQ_CTXT_CEQ_ATTR_SET(1, EN);
+		rq_ctxt->ceq_attr |= RQ_CTXT_CEQ_ATTR_SET(1, CI_WR);
+		rq_ctxt->ceq_attr |= RQ_CTXT_CEQ_ATTR_SET(1, INTR_ARM);
+	}
+	rq_ctxt->pref_cache = RQ_CTXT_PREF_SET(WQ_PREFETCH_MIN, CACHE_MIN) |
+			      RQ_CTXT_PREF_SET(WQ_PREFETCH_MAX, CACHE_MAX) |
+			      RQ_CTXT_PREF_SET(WQ_PREFETCH_THRESHOLD, CACHE_THRESHOLD);
+}
+
 const struct hinic3_nic_cmdq_ops hinic3_stn_cmdq_ops = {
 	.prepare_cmd_buf_clean_tso_lro_space =    prepare_cmd_buf_clean_tso_lro_space,
 	.prepare_cmd_buf_qp_context_multi_store = prepare_cmd_buf_qp_context_multi_store,
@@ -143,4 +198,6 @@ const struct hinic3_nic_cmdq_ops hinic3_stn_cmdq_ops = {
 	.prepare_cmd_buf_set_rss_indir_table =    prepare_cmd_buf_set_rss_indir_table,
 	.prepare_cmd_buf_get_rss_indir_table =    prepare_cmd_buf_get_rss_indir_table,
 	.cmd_buf_to_rss_indir_table =             cmd_buf_to_rss_indir_table,
+	.prepare_sq_ctxt_drop_and_prefetch =      prepare_sq_ctxt_drop_and_prefetch,
+	.prepare_rq_ctxt_ceq_and_prefetch =       prepare_rq_ctxt_ceq_and_prefetch,
 };
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 23/30] net/hinic3: add device kvargs parameters support
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (21 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 22/30] net/hinic3: add SP560 NIC type identification and handling Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 24/30] net/hinic3: add compact CQE Rx path and ptype table Jiacheng Ye
                   ` (7 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Expose TX completion coalescing (tx_pending_limit, tx_coalescing_time) and
RX CQE coalescing (rx_cqe_coalesce_num, rx_cqe_timer_loop) through device
kvargs, so they can be set per deployment without rebuilding the driver,
and written into the hardware context.

Adjust the coalescing defaults to 2/2 for TX and 7/5 for RX CQE, down
from 3/16 and 63/15, to reduce latency while keeping the packet rate.

The two RX CQE coalescing parameters only take effect with HW compact
CQE; they are ignored with SW compact and split CQE.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/nics/hinic3.rst             |  24 +++++
 doc/guides/rel_notes/release_26_11.rst |   1 +
 drivers/net/hinic3/hinic3_ethdev.c     | 125 ++++++++++++++++++++++++-
 drivers/net/hinic3/hinic3_ethdev.h     |  17 ++++
 drivers/net/hinic3/hinic3_nic_io.c     |  14 +--
 5 files changed, 170 insertions(+), 11 deletions(-)

diff --git a/doc/guides/nics/hinic3.rst b/doc/guides/nics/hinic3.rst
index f3123175fe..2274441dcf 100644
--- a/doc/guides/nics/hinic3.rst
+++ b/doc/guides/nics/hinic3.rst
@@ -49,6 +49,30 @@ Driver compilation and testing
 Refer to the document :doc:`build_and_test` for details.
 
 
+Runtime Configuration
+---------------------
+
+The driver can be configured at initialization via EAL device parameters.
+The following parameters are supported:
+
+``tx_pending_limit`` (default ``2``)
+   Tx completion coalescing pending limit, in units of 8
+   packets.
+
+``tx_coalescing_time`` (default ``2``)
+   Tx completion coalescing time, in microseconds.
+
+``rx_cqe_coalesce_num`` (default ``7``)
+   Rx CQE coalescing count, in units of 8 packets.
+
+``rx_cqe_timer_loop`` (default ``5``)
+   Rx CQE coalescing timer, in microseconds.
+
+The two RX CQE coalescing parameters above apply only to the HW
+compact CQE mode; they are ignored with the SW compact and split
+CQE modes.
+
+
 Limitations or Known issues
 ---------------------------
 
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 225e1aadf2..e46a28fe8d 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -140,6 +140,7 @@ New Features
     limit to 2048 entries on the STN tile.
   * Added mailbox message counter reporting through the device private dump API.
   * Added support for the SP560 NIC.
+  * Added device parameters for runtime configuration.
 
 * **Updated Intel iavf driver.**
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index efa54c2ae4..765fa061ba 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -4067,10 +4067,107 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 	return err;
 }
 
+static int
+hinic3_nic_common_args_check_handler(const char *key, const char *val, void *opaque)
+{
+	struct hinic3_nic_common_dev_config *config = opaque;
+	char *end;
+	signed long tmp;
+
+	if (val == NULL || *val == '\0') {
+		PMD_DRV_LOG(ERR, "Key %s is missing value.", key);
+		return -EINVAL;
+	}
+
+	errno = 0;
+	tmp = strtol(val, &end, 10);
+	if (errno != 0 || *end != '\0' || tmp < 0) {
+		PMD_DRV_LOG(ERR, "%s: \"%s\" is an invalid integer.", key, val);
+		return -EINVAL;
+	}
+
+	if (strcmp(key, "tx_pending_limit") == 0) {
+		if (tmp > UINT8_MAX)
+			goto out_of_range;
+		config->tx_pending_limit = tmp;
+	} else if (strcmp(key, "tx_coalescing_time") == 0) {
+		if (tmp > UINT8_MAX)
+			goto out_of_range;
+		config->tx_coalescing_time = tmp;
+	} else if (strcmp(key, "rx_cqe_coalesce_num") == 0) {
+		if (tmp > UINT8_MAX)
+			goto out_of_range;
+		config->rx_cqe_coalesce_num = tmp;
+	} else if (strcmp(key, "rx_cqe_timer_loop") == 0) {
+		if (tmp > UINT8_MAX)
+			goto out_of_range;
+		config->rx_cqe_timer_loop = tmp;
+	} else {
+		PMD_DRV_LOG(ERR, "Unknown parameter: %s", key);
+		return -EINVAL;
+	}
+
+	return 0;
+
+out_of_range:
+	PMD_DRV_LOG(ERR, "%s: value exceeds the maximum allowed value.", key);
+	return -EINVAL;
+}
+
+static const char *const hinic3_nic_common_valid_args[] = {
+	"tx_pending_limit",
+	"tx_coalescing_time",
+	"rx_cqe_coalesce_num",
+	"rx_cqe_timer_loop",
+	NULL
+};
+
+static int
+hinic3_nic_common_config_get(struct rte_pci_device *pci_dev,
+			     struct hinic3_nic_common_dev_config *config)
+{
+	int ret = 0;
+	struct rte_kvargs *kvlist;
+	struct rte_device *eal_dev = &pci_dev->device;
+
+	/* Set private param defaults. */
+	config->tx_pending_limit = HINIC3_DEFAULT_TX_CI_PENDING_LIMIT;
+	config->tx_coalescing_time = HINIC3_DEFAULT_TX_CI_COALESCING_TIME;
+	config->rx_cqe_coalesce_num = HINIC3_RX_CQE_COALESCE_NUM;
+	config->rx_cqe_timer_loop = HINIC3_RX_CQE_TIMER_LOOP;
+
+	if (eal_dev->devargs == NULL || eal_dev->devargs->args == NULL)
+		return 0;
+
+	kvlist = rte_kvargs_parse(eal_dev->devargs->args,
+				  hinic3_nic_common_valid_args);
+	if (kvlist == NULL) {
+		PMD_DRV_LOG(ERR, "nic private parameter err, the format must be '-a dev,[key]=[value]'.");
+		return -EINVAL;
+	}
+
+	ret = rte_kvargs_process(kvlist, NULL, hinic3_nic_common_args_check_handler, config);
+	if (ret < 0)
+		ret = -EINVAL;
+
+	rte_kvargs_free(kvlist);
+
+	PMD_DRV_LOG(INFO, "tx_pending_limit:%upkt, tx_coalescing_time:%uus, "
+		"rx_cqe_coalesce_num:%upkt, rx_cqe_timer_loop:%uus.",
+		config->tx_pending_limit * HINIC3_COALESCING_UNIT_PKTS,
+		config->tx_coalescing_time,
+		config->rx_cqe_coalesce_num * HINIC3_COALESCING_UNIT_PKTS,
+		config->rx_cqe_timer_loop);
+	return ret;
+}
+
 static int
 hinic3_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
+	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
+	struct hinic3_nic_common_dev_config config;
+	int err = 0;
 
 	pci_dev = RTE_CLASS_TO_BUS_DEVICE(eth_dev, *pci_dev);
 
@@ -4083,11 +4180,32 @@ hinic3_dev_init(struct rte_eth_dev *eth_dev)
 	PMD_DRV_LOG(DEBUG, "Network Interface pmd driver version: %s",
 		    HINIC3_PMD_DRV_VERSION);
 
+	/*
+	 * Parse device arguments before allocating any resources so that an
+	 * invalid argument fails the probe without leaking memory. Secondary
+	 * processes re-use the primary's configuration and must not re-parse
+	 * devargs or overwrite the primary's settings.
+	 */
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		err = hinic3_nic_common_config_get(pci_dev, &config);
+		if (err < 0) {
+			PMD_DRV_LOG(ERR, "Failed to get nic device arguments.");
+			return err;
+		}
+	}
+
+	err = hinic3_func_init(eth_dev);
+	if (err)
+		return err;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+		nic_dev->config = config;
+
 	eth_dev->rx_pkt_burst = hinic3_recv_pkts;
 	eth_dev->tx_pkt_burst = hinic3_xmit_pkts;
 	eth_dev->tx_pkt_prepare = hinic3_prep_pkts;
 
-	return hinic3_func_init(eth_dev);
+	return 0;
 }
 
 static int
@@ -4142,6 +4260,11 @@ static struct rte_pci_driver rte_hinic3_pmd = {
 
 RTE_PMD_REGISTER_PCI(net_hinic3, rte_hinic3_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_hinic3, pci_id_hinic3_map);
+RTE_PMD_REGISTER_PARAM_STRING(net_hinic3,
+	"tx_pending_limit=<int> "
+	"tx_coalescing_time=<int> "
+	"rx_cqe_coalesce_num=<int> "
+	"rx_cqe_timer_loop=<int>");
 
 RTE_INIT(hinic3_init_log)
 {
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index e4f1a5b51c..f8d146f3bc 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -6,6 +6,8 @@
 #define _HINIC3_ETHDEV_H_
 
 #include <rte_ethdev.h>
+#include <rte_kvargs.h>
+#include <rte_devargs.h>
 #include <rte_ethdev_core.h>
 
 #include "hinic3_fdir.h"
@@ -60,6 +62,12 @@
 #define HINIC3_VFTA_SIZE		(4096 / HINIC3_UINT32_BIT_SIZE)
 #define HINIC3_MAX_QUEUE_NUM		256
 
+#define HINIC3_DEFAULT_TX_CI_PENDING_LIMIT	2
+#define HINIC3_DEFAULT_TX_CI_COALESCING_TIME	2
+#define HINIC3_RX_CQE_TIMER_LOOP		5
+#define HINIC3_RX_CQE_COALESCE_NUM		7
+#define HINIC3_COALESCING_UNIT_PKTS		8 /**< Coalescing unit: 8 packets. */
+
 #define HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev) \
 	((struct hinic3_nic_dev *)(dev)->data->dev_private)
 
@@ -107,6 +115,14 @@ enum nic_feature_cap {
 TAILQ_HEAD(hinic3_ethertype_filter_list, rte_flow);
 TAILQ_HEAD(hinic3_fdir_rule_filter_list, rte_flow);
 
+struct hinic3_nic_common_dev_config {
+	unsigned int tx_pending_limit; /**< TX CI coalescing parameter pending_limit. */
+	unsigned int tx_coalescing_time; /**< TX CI coalescing parameter coalescing_time. */
+	unsigned int rx_cqe_compact_en; /**< cqe mode, 0 -- separate cqe, 1 -- compact cqe. */
+	unsigned int rx_cqe_coalesce_num; /**< RX CQE parameter coalesce_num. */
+	unsigned int rx_cqe_timer_loop; /**< RX CQE parameter time_loop. */
+};
+
 enum nic_type {
 	NIC_SP620 = 0,
 	NIC_SP230 = 1,
@@ -148,6 +164,7 @@ struct hinic3_nic_dev {
 
 	uint8_t pause_set; /**< Flag of PAUSE frame setting. */
 	struct nic_pause_config nic_pause;
+	struct hinic3_nic_common_dev_config config;
 
 	struct rte_ether_addr default_addr;
 	struct rte_ether_addr *mc_list;
diff --git a/drivers/net/hinic3/hinic3_nic_io.c b/drivers/net/hinic3/hinic3_nic_io.c
index d4c53645c4..c66748da2a 100644
--- a/drivers/net/hinic3/hinic3_nic_io.c
+++ b/drivers/net/hinic3/hinic3_nic_io.c
@@ -11,9 +11,6 @@
 #include "hinic3_rx.h"
 #include "hinic3_tx.h"
 
-#define HINIC3_DEAULT_TX_CI_PENDING_LIMIT	3
-#define HINIC3_DEAULT_TX_CI_COALESCING_TIME	16
-
 #define CI_IDX_HIGH_SHIFH			12
 
 #define CI_HIGN_IDX(val) ((val) >> CI_IDX_HIGH_SHIFH)
@@ -456,9 +453,6 @@ hinic3_get_func_rx_buf_size(struct hinic3_nic_dev *nic_dev)
 	nic_dev->rx_buff_len = buf_size;
 }
 
-#define HINIC3_RX_CQE_TIMER_LOOP		15
-#define HINIC3_RX_CQE_COALESCE_NUM		63
-
 int
 hinic3_init_rq_cqe_ctxts(struct hinic3_nic_dev *nic_dev)
 {
@@ -487,8 +481,8 @@ hinic3_init_rq_cqe_ctxts(struct hinic3_nic_dev *nic_dev)
 			rq_ci_paddr = rxq->rq_ci_paddr >> CQE_CTX_CI_ADDR_SHIFT;
 			cqe_ctx.ci_addr_hi = upper_32_bits(rq_ci_paddr);
 			cqe_ctx.ci_addr_lo = lower_32_bits(rq_ci_paddr);
-			cqe_ctx.threshold_cqe_num = HINIC3_RX_CQE_COALESCE_NUM;
-			cqe_ctx.timer_loop = HINIC3_RX_CQE_TIMER_LOOP;
+			cqe_ctx.threshold_cqe_num = nic_dev->config.rx_cqe_coalesce_num;
+			cqe_ctx.timer_loop = nic_dev->config.rx_cqe_timer_loop;
 		} else {
 			cqe_ctx.threshold_cqe_num = 0;
 			cqe_ctx.timer_loop = 0;
@@ -562,8 +556,8 @@ hinic3_init_qp_ctxts(struct hinic3_nic_dev *nic_dev)
 	/* Configure CI tables for each SQ. */
 	for (q_id = 0; q_id < nic_dev->num_sqs; q_id++) {
 		sq_attr.ci_dma_base = nic_dev->txqs[q_id]->ci_dma_base >> 0x2;
-		sq_attr.pending_limit = HINIC3_DEAULT_TX_CI_PENDING_LIMIT;
-		sq_attr.coalescing_time = HINIC3_DEAULT_TX_CI_COALESCING_TIME;
+		sq_attr.pending_limit = nic_dev->config.tx_pending_limit;
+		sq_attr.coalescing_time = nic_dev->config.tx_coalescing_time;
 		sq_attr.intr_en = 0;
 		sq_attr.intr_idx = 0; /**< Tx doesn't need interrupt. */
 		sq_attr.l2nic_sqn = q_id;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 24/30] net/hinic3: add compact CQE Rx path and ptype table
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (22 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 23/30] net/hinic3: add device kvargs parameters support Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 25/30] net/hinic3: ensure queue depth and state consistency Jiacheng Ye
                   ` (6 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Add a precomputed ptype table and split the Rx burst into
hinic3_recv_pkts() for separate CQE and hinic3_recv_pkts_compact_cqe() for
compact CQE. Add the rx_cqe_compact_en device parameter to choose between
the two formats; it is honoured only on NICs that report the SW compact
CQE capability (SP560). SP230 always uses HW compact CQE and SP620 always
uses separate CQE.

The same value drives the compact RQ WQE, the firmware vport flag and the
Rx burst.

Compact CQE reports one L3/L4 checksum error value and cannot distinguish
an inner from an outer failure, so keep the checksum result unknown and
only count the error in stats. The merged mapping applies only to compact
RQ WQE; in separate WQE format the same field is a bitmap where bit 0
means an IPv4 header checksum error.

Selecting separate mode also clears the SW compact CQE capability so the
RQ context, CQ attributes and vport flag stay consistent.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/nics/hinic3.rst               |   6 +
 doc/guides/rel_notes/release_26_11.rst   |   1 +
 drivers/net/hinic3/base/hinic3_nic_cfg.c |   3 +-
 drivers/net/hinic3/hinic3_ethdev.c       | 127 +++--
 drivers/net/hinic3/hinic3_ethdev.h       |   8 +-
 drivers/net/hinic3/hinic3_rx.c           | 615 +++++++++++++++++++----
 drivers/net/hinic3/hinic3_rx.h           | 205 ++++----
 7 files changed, 719 insertions(+), 246 deletions(-)

diff --git a/doc/guides/nics/hinic3.rst b/doc/guides/nics/hinic3.rst
index 2274441dcf..25d86f0e48 100644
--- a/doc/guides/nics/hinic3.rst
+++ b/doc/guides/nics/hinic3.rst
@@ -62,6 +62,12 @@ The following parameters are supported:
 ``tx_coalescing_time`` (default ``2``)
    Tx completion coalescing time, in microseconds.
 
+``rx_cqe_compact_en`` (default ``1``)
+   Enable (``1``) or disable (``0``) compact CQE mode. The SP230 reports the
+   HW compact CQE feature bit and always uses the compact Rx mode; the SP560
+   reports the SW compact CQE feature bit and follows this setting; the SP620
+   reports neither.
+
 ``rx_cqe_coalesce_num`` (default ``7``)
    Rx CQE coalescing count, in units of 8 packets.
 
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index e46a28fe8d..d8dc492b83 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -141,6 +141,7 @@ New Features
   * Added mailbox message counter reporting through the device private dump API.
   * Added support for the SP560 NIC.
   * Added device parameters for runtime configuration.
+  * Added a compact CQE receive data path.
 
 * **Updated Intel iavf driver.**
 
diff --git a/drivers/net/hinic3/base/hinic3_nic_cfg.c b/drivers/net/hinic3/base/hinic3_nic_cfg.c
index f211b31eda..ea0c564252 100644
--- a/drivers/net/hinic3/base/hinic3_nic_cfg.c
+++ b/drivers/net/hinic3/base/hinic3_nic_cfg.c
@@ -455,8 +455,7 @@ hinic3_set_vport_enable(struct hinic3_hwdev *hwdev, bool enable)
 	en_state.func_id = hinic3_global_func_id(hwdev);
 	en_state.state = enable ? 1 : 0;
 	en_state.num_qps = nic_dev->num_rqs;
-	en_state.rx_compact_wqe_en = HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev) ||
-				     HINIC3_SUPPORT_RX_SW_COMPACT_CQE(nic_dev);
+	en_state.rx_compact_wqe_en = nic_dev->config.rx_cqe_compact_en;
 
 	err = hinic3_msg_to_mgmt_sync(hwdev, HINIC3_MOD_L2NIC,
 				      HINIC3_NIC_CMD_SET_VPORT_ENABLE,
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 765fa061ba..706f3b871b 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -1193,8 +1193,7 @@ hinic3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 	}
 
 	/* If NIC support compact CQE, use compact wqe as default. */
-	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev) ||
-	    HINIC3_SUPPORT_RX_SW_COMPACT_CQE(nic_dev)) {
+	if (nic_dev->config.rx_cqe_compact_en) {
 		rxq->wqe_type = HINIC3_COMPACT_RQ_WQE;
 	} else {
 		if (buf_size >= HINIC3_RX_BUF_SIZE_4K &&
@@ -1254,8 +1253,7 @@ hinic3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 		goto alloc_rx_info_fail;
 	}
 
-	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev) ||
-	    HINIC3_SUPPORT_RX_SW_COMPACT_CQE(nic_dev)) {
+	if (nic_dev->config.rx_cqe_compact_en) {
 		ci_mz = hinic3_dma_zone_reserve(dev, "hinic3_ci_mz", qid,
 						sizeof(*rxq->rq_ci),
 						RTE_CACHE_LINE_SIZE, (int)socket_id);
@@ -1494,8 +1492,7 @@ hinic3_rx_queue_release(struct rte_eth_dev *dev, uint16_t queue_id)
 
 	hinic3_free_rxq_mbufs(rxq);
 
-	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev) ||
-	    HINIC3_SUPPORT_RX_SW_COMPACT_CQE(nic_dev))
+	if (nic_dev->config.rx_cqe_compact_en)
 		hinic3_memzone_free(rxq->ci_mz);
 	else
 		hinic3_memzone_free(rxq->cqe_mz);
@@ -2362,6 +2359,8 @@ hinic3_dev_release(struct rte_eth_dev *eth_dev)
 
 	rte_free(nic_dev->hwdev);
 	nic_dev->hwdev = NULL;
+	rte_free(nic_dev->ptype_tbl);
+	nic_dev->ptype_tbl = NULL;
 }
 
 /**
@@ -3342,6 +3341,40 @@ hinic3_dev_xstats_get_names(struct rte_eth_dev *dev,
 	return count;
 }
 
+static const uint32_t *
+hinic3_dev_supported_ptypes_get(__rte_unused struct rte_eth_dev *dev, size_t *no_of_elements)
+{
+	static const uint32_t ptypes[] = {
+		RTE_PTYPE_L2_ETHER,
+		RTE_PTYPE_L2_ETHER_FCOE,
+		RTE_PTYPE_L2_ETHER_NSH,
+		RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_L4_TCP,
+		RTE_PTYPE_L4_UDP,
+		RTE_PTYPE_L4_SCTP,
+		RTE_PTYPE_L4_NONFRAG,
+		RTE_PTYPE_L4_FRAG,
+		RTE_PTYPE_L4_ICMP,
+		RTE_PTYPE_L4_IGMP,
+		RTE_PTYPE_L4_ESP,
+		RTE_PTYPE_TUNNEL_IP,
+		RTE_PTYPE_TUNNEL_GRE,
+		RTE_PTYPE_TUNNEL_VXLAN,
+		RTE_PTYPE_TUNNEL_VXLAN_GPE,
+		RTE_PTYPE_TUNNEL_GENEVE,
+		RTE_PTYPE_INNER_L2_ETHER,
+		RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
+		RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
+		RTE_PTYPE_INNER_L4_TCP,
+		RTE_PTYPE_INNER_L4_UDP,
+		RTE_PTYPE_INNER_L4_SCTP,
+		RTE_PTYPE_INNER_L4_NONFRAG,
+	};
+	*no_of_elements = RTE_DIM(ptypes);
+	return ptypes;
+}
+
 static void
 hinic3_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
 		    struct rte_eth_rxq_info *qinfo)
@@ -3721,6 +3754,7 @@ hinic3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
 static const struct eth_dev_ops hinic3_pmd_ops = {
 	.dev_configure                 = hinic3_dev_configure,
 	.dev_infos_get                 = hinic3_dev_infos_get,
+	.dev_supported_ptypes_get      = hinic3_dev_supported_ptypes_get,
 	.fw_version_get                = hinic3_fw_version_get,
 	.dev_set_link_up               = hinic3_dev_set_link_up,
 	.dev_set_link_down             = hinic3_dev_set_link_down,
@@ -3773,6 +3807,7 @@ static const struct eth_dev_ops hinic3_pmd_ops = {
 static const struct eth_dev_ops hinic3_pmd_vf_ops = {
 	.dev_configure                 = hinic3_dev_configure,
 	.dev_infos_get                 = hinic3_dev_infos_get,
+	.dev_supported_ptypes_get      = hinic3_dev_supported_ptypes_get,
 	.fw_version_get                = hinic3_fw_version_get,
 	.dev_set_link_up               = hinic3_dev_set_link_up,
 	.dev_set_link_down             = hinic3_dev_set_link_down,
@@ -3825,17 +3860,6 @@ static void hinic3_nic_tx_rx_ops_init(struct hinic3_nic_dev *nic_dev)
 		nic_dev->tx_ops->nic_tx_set_wqe_offload = hinic3_tx_set_compact_task_offload;
 	else
 		nic_dev->tx_ops->nic_tx_set_wqe_offload = hinic3_tx_set_normal_task_offload;
-
-	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev) ||
-	    HINIC3_SUPPORT_RX_SW_COMPACT_CQE(nic_dev)) {
-		nic_dev->rx_ops->nic_rx_get_cqe_info = hinic3_rx_get_compact_cqe_info;
-		nic_dev->rx_ops->nic_rx_cqe_done = hinic3_rx_integrated_cqe_done;
-		nic_dev->rx_ops->nic_rx_poll_rq_empty = hinic3_poll_integrated_cqe_rq_empty;
-	} else {
-		nic_dev->rx_ops->nic_rx_get_cqe_info = hinic3_rx_get_cqe_info;
-		nic_dev->rx_ops->nic_rx_cqe_done = hinic3_rx_separate_cqe_done;
-		nic_dev->rx_ops->nic_rx_poll_rq_empty = hinic3_poll_rq_empty;
-	}
 }
 
 /**
@@ -3893,13 +3917,6 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 		goto alloc_eth_addr_fail;
 	}
 
-	nic_dev->rx_ops = rte_zmalloc("rx_ops", sizeof(struct hinic3_nic_rx_ops), 0);
-	if (!nic_dev->rx_ops) {
-		PMD_DRV_LOG(ERR, "Allocate rx_ops memory failed");
-		err = -ENOMEM;
-		goto alloc_rx_ops_fail;
-	}
-
 	nic_dev->tx_ops = rte_zmalloc("tx_ops", sizeof(struct hinic3_nic_tx_ops), 0);
 	if (!nic_dev->tx_ops) {
 		PMD_DRV_LOG(ERR, "Allocate tx_ops memory failed");
@@ -4001,6 +4018,7 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 			    eth_dev->data->name);
 		goto enable_intr_fail;
 	}
+
 	tcam_info = &nic_dev->tcam;
 	memset(tcam_info, 0, sizeof(struct hinic3_tcam_info));
 	TAILQ_INIT(&tcam_info->tcam_list);
@@ -4054,10 +4072,6 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 	nic_dev->tx_ops = NULL;
 
 alloc_tx_ops_fail:
-	rte_free(nic_dev->rx_ops);
-	nic_dev->rx_ops = NULL;
-
-alloc_rx_ops_fail:
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 
@@ -4094,6 +4108,8 @@ hinic3_nic_common_args_check_handler(const char *key, const char *val, void *opa
 		if (tmp > UINT8_MAX)
 			goto out_of_range;
 		config->tx_coalescing_time = tmp;
+	} else if (strcmp(key, "rx_cqe_compact_en") == 0) {
+		config->rx_cqe_compact_en = !!tmp;
 	} else if (strcmp(key, "rx_cqe_coalesce_num") == 0) {
 		if (tmp > UINT8_MAX)
 			goto out_of_range;
@@ -4117,6 +4133,7 @@ hinic3_nic_common_args_check_handler(const char *key, const char *val, void *opa
 static const char *const hinic3_nic_common_valid_args[] = {
 	"tx_pending_limit",
 	"tx_coalescing_time",
+	"rx_cqe_compact_en",
 	"rx_cqe_coalesce_num",
 	"rx_cqe_timer_loop",
 	NULL
@@ -4133,6 +4150,7 @@ hinic3_nic_common_config_get(struct rte_pci_device *pci_dev,
 	/* Set private param defaults. */
 	config->tx_pending_limit = HINIC3_DEFAULT_TX_CI_PENDING_LIMIT;
 	config->tx_coalescing_time = HINIC3_DEFAULT_TX_CI_COALESCING_TIME;
+	config->rx_cqe_compact_en = HINIC3_RX_CQE_COMPACT_EN;
 	config->rx_cqe_coalesce_num = HINIC3_RX_CQE_COALESCE_NUM;
 	config->rx_cqe_timer_loop = HINIC3_RX_CQE_TIMER_LOOP;
 
@@ -4161,6 +4179,35 @@ hinic3_nic_common_config_get(struct rte_pci_device *pci_dev,
 	return ret;
 }
 
+static void hinic3_nic_feature_init(struct hinic3_nic_dev *nic_dev)
+{
+	/*
+	 * The SP230 reports the HW compact CQE feature bit
+	 * (NIC_F_RX_HW_COMPACT_CQE, bit 20) and always uses the compact
+	 * Rx mode. The SP560 reports the SW compact CQE feature bit
+	 * (NIC_F_RX_SW_COMPACT_CQE, bit 27) and uses either mode. The
+	 * SP620 reports neither.
+	 */
+	if (HINIC3_SUPPORT_RX_HW_COMPACT_CQE(nic_dev)) {
+		nic_dev->config.rx_cqe_compact_en = HINIC3_RX_CQE_COMPACT_EN;
+	} else if (HINIC3_SUPPORT_RX_SW_COMPACT_CQE(nic_dev)) {
+		if (nic_dev->config.rx_cqe_compact_en == 0) {
+			/*
+			 * Drop the SW capability too, so the RQ context setup
+			 * in hinic3_nic_io.c builds the separate-CQE layout.
+			 */
+			nic_dev->feature_cap &= ~NIC_F_RX_SW_COMPACT_CQE;
+		}
+	} else {
+		nic_dev->config.rx_cqe_compact_en = 0;
+	}
+
+	PMD_DRV_LOG(INFO, "nic rx burst mode is %s.",
+		    nic_dev->config.rx_cqe_compact_en ? "compact" : "separate");
+}
+
+static int hinic3_dev_uninit(struct rte_eth_dev *dev);
+
 static int
 hinic3_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -4198,12 +4245,29 @@ hinic3_dev_init(struct rte_eth_dev *eth_dev)
 	if (err)
 		return err;
 
-	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		nic_dev->config = config;
+		hinic3_nic_feature_init(nic_dev);
+
+		err = hinic3_init_rx_ptype_table(eth_dev);
+		if (err) {
+			PMD_DRV_LOG(ERR, "Failed to create ptype_table.");
+			hinic3_dev_uninit(eth_dev);
+			return err;
+		}
+	}
 
-	eth_dev->rx_pkt_burst = hinic3_recv_pkts;
-	eth_dev->tx_pkt_burst = hinic3_xmit_pkts;
 	eth_dev->tx_pkt_prepare = hinic3_prep_pkts;
+	eth_dev->tx_pkt_burst = hinic3_xmit_pkts;
+
+	/*
+	 * The Rx burst follows the same per-port CQE mode that drives the
+	 * RQ WQE type, the CI/CQE memzone and the ptype table.
+	 */
+	if (nic_dev->config.rx_cqe_compact_en)
+		eth_dev->rx_pkt_burst = hinic3_recv_pkts_compact_cqe;
+	else
+		eth_dev->rx_pkt_burst = hinic3_recv_pkts;
 
 	return 0;
 }
@@ -4263,6 +4327,7 @@ RTE_PMD_REGISTER_PCI_TABLE(net_hinic3, pci_id_hinic3_map);
 RTE_PMD_REGISTER_PARAM_STRING(net_hinic3,
 	"tx_pending_limit=<int> "
 	"tx_coalescing_time=<int> "
+	"rx_cqe_compact_en=<int> "
 	"rx_cqe_coalesce_num=<int> "
 	"rx_cqe_timer_loop=<int>");
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index f8d146f3bc..0763665885 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -64,6 +64,7 @@
 
 #define HINIC3_DEFAULT_TX_CI_PENDING_LIMIT	2
 #define HINIC3_DEFAULT_TX_CI_COALESCING_TIME	2
+#define HINIC3_RX_CQE_COMPACT_EN		1
 #define HINIC3_RX_CQE_TIMER_LOOP		5
 #define HINIC3_RX_CQE_COALESCE_NUM		7
 #define HINIC3_COALESCING_UNIT_PKTS		8 /**< Coalescing unit: 8 packets. */
@@ -115,6 +116,11 @@ enum nic_feature_cap {
 TAILQ_HEAD(hinic3_ethertype_filter_list, rte_flow);
 TAILQ_HEAD(hinic3_fdir_rule_filter_list, rte_flow);
 
+#define HINIC3_PTYPE_NUM 4096
+struct hinic3_ptype_table {
+	alignas(RTE_CACHE_LINE_SIZE) uint32_t ptype[HINIC3_PTYPE_NUM];
+};
+
 struct hinic3_nic_common_dev_config {
 	unsigned int tx_pending_limit; /**< TX CI coalescing parameter pending_limit. */
 	unsigned int tx_coalescing_time; /**< TX CI coalescing parameter coalescing_time. */
@@ -179,7 +185,7 @@ struct hinic3_nic_dev {
 	struct hinic3_ethertype_filter_list filter_ethertype_list;
 	struct hinic3_fdir_rule_filter_list filter_fdir_rule_list;
 	uint8_t cos_map[HINIC3_COS_NUM_MAX];
-	struct hinic3_nic_rx_ops *rx_ops;
+	struct hinic3_ptype_table *ptype_tbl;
 	struct hinic3_nic_tx_ops *tx_ops;
 	enum nic_type nic_type; /**< NIC type. */
 
diff --git a/drivers/net/hinic3/hinic3_rx.c b/drivers/net/hinic3/hinic3_rx.c
index eef4ab5a30..382dac9bfb 100644
--- a/drivers/net/hinic3/hinic3_rx.c
+++ b/drivers/net/hinic3/hinic3_rx.c
@@ -1,16 +1,275 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright(c) 2025 Huawei Technologies Co., Ltd
  */
+#include <rte_ether.h>
+#include <rte_mbuf.h>
 
 #include "base/hinic3_compat.h"
 #include "base/hinic3_hwif.h"
 #include "base/hinic3_hwdev.h"
 #include "base/hinic3_wq.h"
+#include "base/hinic3_mgmt.h"
 #include "base/hinic3_nic_cfg.h"
 #include "hinic3_nic_io.h"
 #include "hinic3_ethdev.h"
+#include "hinic3_tx.h"
 #include "hinic3_rx.h"
 
+#define HINIC3_RX_EMPTY_THRESHOLD 3
+
+static uint32_t
+hinic3_get_l3_ptype(uint32_t ip_type)
+{
+	uint32_t ptype = 0;
+	if (ip_type == IPSU_METADATA_L3_TP_IPV4)
+		ptype |= RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
+	else if (ip_type == IPSU_METADATA_L3_TP_IPV6)
+		ptype |= RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
+	return ptype;
+}
+static uint32_t
+hinic3_get_l4_ptype(uint32_t packet_type)
+{
+	int ptype = 0;
+	switch (packet_type) {
+	case IPSU_PKT_TYPE_NULL:
+		break;
+	case IPSU_PKT_TYPE_TCP:
+		ptype |= RTE_PTYPE_L4_TCP;
+		break;
+	case IPSU_PKT_TYPE_UDP:
+		ptype |= RTE_PTYPE_L4_UDP;
+		break;
+	case IPSU_PKT_TYPE_IPV4_FRAG:
+		ptype |= RTE_PTYPE_L4_FRAG;
+		break;
+	case IPSU_PKT_TYPE_SCTP:
+		ptype |= RTE_PTYPE_L4_SCTP;
+		break;
+	case IPSU_PKT_TYPE_ICMP:
+		ptype |= RTE_PTYPE_L4_ICMP;
+		break;
+	case IPSU_PKT_TYPE_IGMP:
+		ptype |= RTE_PTYPE_L4_IGMP;
+		break;
+	case IPSU_PKT_TYPE_ESP_OVER_IP:
+		ptype |= RTE_PTYPE_L4_ESP;
+		break;
+	default:
+		ptype |= RTE_PTYPE_L4_NONFRAG;
+	}
+	return ptype;
+}
+
+static uint32_t
+hinic3_get_inner_l4_ptype(uint32_t packet_type)
+{
+	int ptype = 0;
+	switch (packet_type) {
+	case IPSU_PKT_TYPE_NULL:
+		break;
+	case IPSU_PKT_TYPE_TCP:
+		ptype |= RTE_PTYPE_INNER_L4_TCP;
+		break;
+	case IPSU_PKT_TYPE_UDP:
+		ptype |= RTE_PTYPE_INNER_L4_UDP;
+		break;
+	case IPSU_PKT_TYPE_SCTP:
+		ptype |= RTE_PTYPE_INNER_L4_SCTP;
+		break;
+	case IPSU_PKT_TYPE_IGMP:
+		ptype |= RTE_PTYPE_INNER_L4_NONFRAG;
+		break;
+	default:
+		ptype |= RTE_PTYPE_INNER_L4_NONFRAG;
+	}
+	return ptype;
+}
+
+/**
+ * Calculate the ptype value of given offload type.
+ *
+ * @param[in] offload_type
+ *   The offload of Packet
+ * @return
+ *   Ptype value
+ */
+static uint32_t
+hinic3_calc_rx_ptype_table(uint32_t offload_type, struct hinic3_nic_dev *nic_dev)
+{
+	uint32_t packet_type, ip_type, enc_l3_type, pkt_fmt;
+	uint32_t ptype = RTE_PTYPE_UNKNOWN;
+
+	packet_type = HINIC3_GET_RX_PKT_TYPE(offload_type);
+	ip_type = HINIC3_GET_RX_IP_TYPE(offload_type);
+	enc_l3_type = HINIC3_GET_RX_ENC_L3_TYPE(offload_type);
+	pkt_fmt = HINIC3_GET_RX_PKT_FORMAT(offload_type);
+
+	switch (pkt_fmt) {
+	case IPSU_METADATA_FMT_NO_ENC:
+		ptype |= RTE_PTYPE_L2_ETHER;
+		ptype |= hinic3_get_l3_ptype(ip_type);
+		ptype |= hinic3_get_l4_ptype(packet_type);
+		break;
+	case IPSU_METADATA_FMT_FC:
+		ptype |= RTE_PTYPE_L2_ETHER_FCOE;
+		break;
+	case IPSU_METADATA_FMT_NSH:
+		ptype |= RTE_PTYPE_L2_ETHER_NSH;
+		break;
+	/* IPinIP */
+	case IPSU_METADATA_FMT_IPIP:
+		ptype |= RTE_PTYPE_L2_ETHER;
+		ptype |= RTE_PTYPE_TUNNEL_IP;
+		if (!(nic_dev->feature_cap & NIC_F_TX_WQE_COMPACT_TASK)) {
+			ptype |= hinic3_get_l3_ptype(ip_type);
+		} else {
+			ptype |= hinic3_get_l3_ptype(enc_l3_type);
+			ptype |= hinic3_get_inner_l4_ptype(packet_type);
+			if (ip_type == IPSU_METADATA_L3_TP_IPV4)
+				ptype |= RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
+			else if (ip_type == IPSU_METADATA_L3_TP_IPV6)
+				ptype |= RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
+		}
+		break;
+	default:
+	/* VXLAN, NVGRE, VXLAN_GPE, GENEVE */
+		ptype |= RTE_PTYPE_L2_ETHER;
+		ptype |= hinic3_get_l3_ptype(enc_l3_type);
+
+		switch (pkt_fmt) {
+		case IPSU_METADATA_FMT_VXLAN:
+			ptype |= RTE_PTYPE_L4_UDP;
+			ptype |= RTE_PTYPE_TUNNEL_VXLAN;
+			ptype |= RTE_PTYPE_INNER_L2_ETHER;
+			break;
+		case IPSU_METADATA_FMT_NVGRE:
+			ptype |= RTE_PTYPE_TUNNEL_GRE;
+			if (!HINIC3_IS_SP560_NIC(nic_dev))
+				return ptype;
+			break;
+		case IPSU_METADATA_FMT_GPE:
+			ptype |= RTE_PTYPE_L4_UDP;
+			ptype |= RTE_PTYPE_TUNNEL_VXLAN_GPE;
+			break;
+		case IPSU_METADATA_FMT_GENEVE:
+			ptype |= RTE_PTYPE_L4_UDP;
+			ptype |= RTE_PTYPE_TUNNEL_GENEVE;
+			ptype |= RTE_PTYPE_INNER_L2_ETHER;
+			break;
+		default:
+			ptype |= RTE_PTYPE_L4_NONFRAG;
+			break;
+		}
+		if (ip_type == IPSU_METADATA_L3_TP_IPV4)
+			ptype |= RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
+		else if (ip_type == IPSU_METADATA_L3_TP_IPV6)
+			ptype |= RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
+		else
+			return ptype;
+		/* shift ptype to inner*/
+		ptype |= hinic3_get_inner_l4_ptype(packet_type);
+	}
+	return ptype;
+}
+
+static uint32_t
+hinic3_calc_rx_ptype_compact_table(uint32_t offload_type)
+{
+	uint32_t packet_type, ip_type, pkt_fmt;
+	uint32_t ptype = RTE_PTYPE_UNKNOWN;
+
+	pkt_fmt = HINIC3_RQ_COMPACT_CQE_STATUS_GET(offload_type << HINIC3_COMPACT_CQE_PTYPE_SHIFT,
+						   PKT_FORMAT);
+	ip_type = HINIC3_RQ_COMPACT_CQE_STATUS_GET(offload_type << HINIC3_COMPACT_CQE_PTYPE_SHIFT,
+						   IP_TYPE);
+	packet_type = HINIC3_RQ_COMPACT_CQE_STATUS_GET(offload_type <<
+							HINIC3_COMPACT_CQE_PTYPE_SHIFT,
+							PKT_TYPE);
+
+	switch (pkt_fmt) {
+	case IPSU_METADATA_FMT_NO_ENC:
+		ptype |= RTE_PTYPE_L2_ETHER;
+		ptype |= hinic3_get_l3_ptype(ip_type);
+		ptype |= hinic3_get_l4_ptype(packet_type);
+		break;
+	case IPSU_METADATA_FMT_FC:
+		ptype |= RTE_PTYPE_L2_ETHER_FCOE;
+		break;
+	case IPSU_METADATA_FMT_NSH:
+		ptype |= RTE_PTYPE_L2_ETHER_NSH;
+		break;
+	default:
+	/* VXLAN, NVGRE, VXLAN_GPE, GENEVE, IPinIP */
+		ptype |= RTE_PTYPE_L2_ETHER;
+
+		switch (pkt_fmt) {
+		case IPSU_METADATA_FMT_VXLAN:
+			ptype |= RTE_PTYPE_L4_UDP;
+			ptype |= RTE_PTYPE_TUNNEL_VXLAN;
+			ptype |= RTE_PTYPE_INNER_L2_ETHER;
+			break;
+		case IPSU_METADATA_FMT_NVGRE:
+			ptype |= RTE_PTYPE_TUNNEL_GRE;
+			return ptype;
+		case IPSU_METADATA_FMT_GENEVE:
+			ptype |= RTE_PTYPE_L4_UDP;
+			ptype |= RTE_PTYPE_TUNNEL_GENEVE;
+			ptype |= RTE_PTYPE_INNER_L2_ETHER;
+			break;
+
+		case IPSU_METADATA_FMT_IPIP:
+			ptype |= RTE_PTYPE_TUNNEL_IP;
+			break;
+		default:
+			ptype |= RTE_PTYPE_L4_NONFRAG;
+			break;
+		}
+		if (ip_type == IPSU_METADATA_L3_TP_IPV4)
+			ptype |= RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
+		else if (ip_type == IPSU_METADATA_L3_TP_IPV6)
+			ptype |= RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
+		else
+			return ptype;
+		/* shift ptype to inner*/
+		ptype |= hinic3_get_inner_l4_ptype(packet_type);
+	}
+	return ptype;
+}
+
+/**
+ * Get receive queue local ci
+ *
+ * @param[in] rxq
+ *   Receive queue
+ * @return
+ *   Receive queue local ci
+ */
+static inline uint16_t hinic3_get_rq_local_ci(struct hinic3_rxq *rxq)
+{
+	return MASKED_QUEUE_IDX(rxq, rxq->cons_idx);
+}
+
+static inline uint16_t hinic3_get_rq_free_wqebb(struct hinic3_rxq *rxq)
+{
+	return rxq->delta - 1;
+}
+
+/**
+ * Update receive queue local ci
+ *
+ * @param[in] rxq
+ *   Receive queue
+ * @param[in] wqe_cnt
+ *   Wqebb counters
+ */
+static inline void hinic3_update_rq_local_ci(struct hinic3_rxq *rxq,
+					     uint16_t wqe_cnt)
+{
+	rxq->cons_idx += wqe_cnt;
+	rxq->delta += wqe_cnt;
+}
+
 /**
  * Get wqe from receive queue.
  *
@@ -62,6 +321,13 @@ hinic3_get_rq_local_pi(struct hinic3_rxq *rxq)
 	return MASKED_QUEUE_IDX(rxq, rxq->prod_idx);
 }
 
+static inline uint16_t hinic3_get_rq_hw_ci(struct hinic3_rxq *rxq)
+{
+	struct hinic3_rq_ci_wb rq_ci;
+	rq_ci.dw1.value = hinic3_hw_cpu32(rte_read32(&rxq->rq_ci->dw1.value));
+	return rq_ci.dw1.bs.hw_ci;
+}
+
 uint16_t
 hinic3_rx_fill_wqe(struct hinic3_rxq *rxq)
 {
@@ -508,6 +774,41 @@ hinic3_update_rss_config(struct rte_eth_dev *dev,
 	return err;
 }
 
+/**
+ * Initialize the receive packet type table
+ * @param[in] dev
+ *   Pointer to ethernet device structure.
+ */
+
+int
+hinic3_init_rx_ptype_table(struct rte_eth_dev *dev)
+{
+	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+	struct hinic3_ptype_table *tbl;
+	int socket_id;
+
+	socket_id = rte_eth_dev_socket_id(dev->data->port_id);
+	tbl = rte_zmalloc_socket("ptype_tbl", sizeof(struct hinic3_ptype_table),
+				 0, socket_id);
+
+	if (tbl == NULL)
+		return -ENOMEM;
+
+	uint32_t *ptype = tbl->ptype;
+	uint32_t i;
+
+	/* The ptype encoding follows the CQE format selected for this port. */
+	if (nic_dev->config.rx_cqe_compact_en) {
+		for (i = 0; i < HINIC3_PTYPE_NUM; i++)
+			ptype[i] = hinic3_calc_rx_ptype_compact_table(i);
+	} else {
+		for (i = 0; i < HINIC3_PTYPE_NUM; i++)
+			ptype[i] = hinic3_calc_rx_ptype_table(i, nic_dev);
+	}
+	nic_dev->ptype_tbl = tbl;
+	return 0;
+}
+
 /**
  * Search given queue array to find position of given id.
  * Return queue pos or queue_count if not found.
@@ -604,7 +905,7 @@ hinic3_rx_queue_release_mbufs(struct hinic3_rxq *rxq)
 	hinic3_update_rq_local_ci(rxq, nr_released);
 }
 
-int
+static int
 hinic3_poll_rq_empty(struct hinic3_rxq *rxq)
 {
 	uint64_t end;
@@ -625,29 +926,21 @@ hinic3_poll_rq_empty(struct hinic3_rxq *rxq)
 	return err;
 }
 
-int
+static int
 hinic3_poll_integrated_cqe_rq_empty(struct hinic3_rxq *rxq)
 {
 	struct hinic3_rx_info *rx_info;
-	struct hinic3_rq_ci_wb rq_ci;
-	uint16_t sw_ci;
-	uint16_t hw_ci;
-	uint32_t val;
+	uint16_t sw_ci, sw_pi, hw_ci;
+	uint64_t end;
 
 	sw_ci = hinic3_get_rq_local_ci(rxq);
-	val = rte_read32(&rxq->rq_ci->dw1.value);
-	rq_ci.dw1.value = hinic3_hw_cpu32(val);
-	hw_ci = rq_ci.dw1.bs.hw_ci;
+	sw_pi = hinic3_get_rq_local_pi(rxq);
+	hw_ci = hinic3_get_rq_hw_ci(rxq);
 
 	if (HINIC3_IS_SP560_NIC(rxq->nic_dev)) {
-		uint16_t sw_pi = hinic3_get_rq_local_pi(rxq);
-		uint64_t end;
-
 		end = cycles + msecs_to_cycles(HINIC3_FLUSH_QUEUE_TIMEOUT);
 		do {
-			val = rte_read32(&rxq->rq_ci->dw1.value);
-			rq_ci.dw1.value = hinic3_hw_cpu32(val);
-			hw_ci = rq_ci.dw1.bs.hw_ci;
+			hw_ci = hinic3_get_rq_hw_ci(rxq);
 			if (sw_pi == hw_ci)
 				break;
 
@@ -671,22 +964,33 @@ hinic3_poll_integrated_cqe_rq_empty(struct hinic3_rxq *rxq)
 	return 0;
 }
 
-void
-hinic3_dump_cqe_status(struct hinic3_rxq *rxq, uint32_t *cqe_done_cnt,
-		       uint32_t *cqe_hole_cnt, uint32_t *head_ci, uint32_t *head_done)
+static void
+hinic3_dump_cqe_status(struct hinic3_rxq *rxq)
 {
-	uint16_t sw_ci;
+	volatile struct hinic3_rq_cqe *rx_cqe;
+	uint16_t sw_ci, sw_pi, hw_ci;
+	uint32_t head_ci, head_done;
 	uint16_t avail_pkts = 0;
 	uint16_t hit_done = 0;
 	uint16_t cqe_hole = 0;
-	RTE_ATOMIC(uint32_t)status;
-	volatile struct hinic3_rq_cqe *rx_cqe;
+	uint32_t status;
+
+	if (rxq->wqe_type == HINIC3_COMPACT_RQ_WQE) {
+		sw_ci = hinic3_get_rq_local_ci(rxq);
+		sw_pi = hinic3_get_rq_local_pi(rxq);
+		hw_ci = hinic3_get_rq_hw_ci(rxq);
+		PMD_DRV_LOG(ERR, "Poll rq empty timeout, eth_dev:%s, queue_idx:%d, mbuf_left:%d, sw_pi:%d, sw_ci:%d, hw_ci:%d",
+			rxq->nic_dev->dev_name, rxq->q_id,
+			rxq->q_depth - hinic3_get_rq_free_wqebb(rxq),
+			sw_pi, sw_ci, hw_ci);
+		return;
+	}
 
 	sw_ci = hinic3_get_rq_local_ci(rxq);
 	rx_cqe = &rxq->rx_cqe[sw_ci];
 	status = rx_cqe->status;
-	*head_done = HINIC3_GET_RX_DONE(status);
-	*head_ci = sw_ci;
+	head_done = HINIC3_GET_RX_DONE(status);
+	head_ci = sw_ci;
 
 	for (sw_ci = 0; sw_ci < rxq->q_depth; sw_ci++) {
 		rx_cqe = &rxq->rx_cqe[sw_ci];
@@ -707,17 +1011,16 @@ hinic3_dump_cqe_status(struct hinic3_rxq *rxq, uint32_t *cqe_done_cnt,
 		hit_done = 1;
 	}
 
-	*cqe_done_cnt = avail_pkts;
-	*cqe_hole_cnt = cqe_hole;
+	PMD_DRV_LOG(ERR, "Poll rq empty timeout, eth_dev:%s, queue_idx:%d, mbuf_left:%d, cqe_done:%d, cqe_hole:%d, cqe[%d].done=%d",
+		rxq->nic_dev->dev_name, rxq->q_id,
+		rxq->q_depth - hinic3_get_rq_free_wqebb(rxq),
+		avail_pkts, cqe_hole, head_ci, head_done);
 }
 
 int
 hinic3_stop_rq(struct rte_eth_dev *eth_dev, struct hinic3_rxq *rxq)
 {
 	struct hinic3_nic_dev *nic_dev = rxq->nic_dev;
-	uint32_t cqe_done_cnt = 0;
-	uint32_t cqe_hole_cnt = 0;
-	uint32_t head_ci, head_done;
 	int err;
 
 	rte_atomic_store_explicit(&rxq->rss_en, 0, rte_memory_order_relaxed);
@@ -766,23 +1069,21 @@ hinic3_stop_rq(struct rte_eth_dev *eth_dev, struct hinic3_rxq *rxq)
 		goto rq_flush_failed;
 	}
 
-	err = nic_dev->rx_ops->nic_rx_poll_rq_empty(rxq);
+	if (nic_dev->config.rx_cqe_compact_en)
+		err = hinic3_poll_integrated_cqe_rq_empty(rxq);
+	else
+		err = hinic3_poll_rq_empty(rxq);
+
 	if (err) {
-		hinic3_dump_cqe_status(rxq, &cqe_done_cnt, &cqe_hole_cnt,
-				       &head_ci, &head_done);
-		PMD_DRV_LOG(ERR, "Poll rq empty timeout");
-		PMD_DRV_LOG(ERR,
-			    "eth_dev:%s, queue_idx:%d, mbuf_left:%d, cqe_done:%d, cqe_hole:%d, cqe[%d].done=%d",
-			    nic_dev->dev_name, rxq->q_id,
-			    rxq->q_depth - hinic3_get_rq_free_wqebb(rxq),
-			    cqe_done_cnt, cqe_hole_cnt, head_ci, head_done);
+		hinic3_dump_cqe_status(rxq);
 		goto poll_rq_failed;
 	}
 
 	return 0;
 
 poll_rq_failed:
-	hinic3_set_rq_enable(nic_dev, rxq->q_id, true);
+	if ((hinic3_get_driver_feature(nic_dev) & NIC_F_HTN_FDIR) != 0)
+		(void)hinic3_set_rq_enable(nic_dev, rxq->q_id, true);
 rq_flush_failed:
 	rte_spinlock_lock(&nic_dev->queue_list_lock);
 set_indir_failed:
@@ -875,6 +1176,17 @@ hinic3_rx_csum(uint16_t csum_err, struct hinic3_rxq *rxq)
 	if (unlikely(csum_err & HINIC3_RX_CSUM_HW_CHECK_NONE))
 		return HINIC3_PKT_RX_IP_CKSUM_UNKNOWN;
 
+	/*
+	 * The compact CQE reports a checksum failure somewhere in the
+	 * inner or the outer header without saying where, so the failing
+	 * layer cannot be blamed: leave both results unknown and only
+	 * account the error.
+	 */
+	if (unlikely(csum_err & HINIC3_RX_CSUM_LAYER_UNKNOWN_ERR)) {
+		rxq->rxq_stats.csum_errors++;
+		return HINIC3_PKT_RX_IP_CKSUM_UNKNOWN;
+	}
+
 	flags = 0;
 
 	/* IP checksum error. */
@@ -1015,38 +1327,14 @@ hinic3_start_all_rqs(struct rte_eth_dev *eth_dev)
 	}
 	return err;
 }
-
-bool
-hinic3_rx_separate_cqe_done(struct hinic3_rxq *rxq, volatile struct hinic3_rq_cqe **rx_cqe)
-{
-	volatile struct hinic3_rq_cqe *cqe = NULL;
-	uint16_t sw_ci;
-	uint32_t status;
-
-	sw_ci = hinic3_get_rq_local_ci(rxq);
-	*rx_cqe = &rxq->rx_cqe[sw_ci];
-	cqe = *rx_cqe;
-
-	status = hinic3_hw_cpu32((uint32_t)(rte_atomic_load_explicit(&cqe->status,
-								     rte_memory_order_acquire)));
-	if (!HINIC3_GET_RX_DONE(status))
-		return false;
-
-	return true;
-}
-
-bool
+static bool
 hinic3_rx_integrated_cqe_done(struct hinic3_rxq *rxq, volatile struct hinic3_rq_cqe **rx_cqe)
 {
-	struct hinic3_rq_ci_wb rq_ci;
 	struct rte_mbuf *rxm = NULL;
 	uint16_t sw_ci, hw_ci;
-	uint32_t val;
 
 	sw_ci = hinic3_get_rq_local_ci(rxq);
-	val = rte_read32(&rxq->rq_ci->dw1.value);
-	rq_ci.dw1.value = hinic3_hw_cpu32(val);
-	hw_ci = rq_ci.dw1.bs.hw_ci;
+	hw_ci = hinic3_get_rq_hw_ci(rxq);
 
 	if (hw_ci == sw_ci)
 		return false;
@@ -1058,28 +1346,7 @@ hinic3_rx_integrated_cqe_done(struct hinic3_rxq *rxq, volatile struct hinic3_rq_
 	return true;
 }
 
-void
-hinic3_rx_get_cqe_info(struct hinic3_rxq *rxq __rte_unused, volatile struct hinic3_rq_cqe *rx_cqe,
-		       struct hinic3_cqe_info *cqe_info)
-{
-	uint32_t dw0 = hinic3_hw_cpu32(rx_cqe->status);
-	uint32_t dw1 = hinic3_hw_cpu32(rx_cqe->vlan_len);
-	uint32_t dw2 = hinic3_hw_cpu32(rx_cqe->offload_type);
-	uint32_t dw3 = hinic3_hw_cpu32(rx_cqe->hash_val);
-
-	cqe_info->lro_num = RQ_CQE_STATUS_GET(dw0, NUM_LRO);
-	cqe_info->csum_err = RQ_CQE_STATUS_GET(dw0, CSUM_ERR);
-
-	cqe_info->pkt_len = RQ_CQE_SGE_GET(dw1, LEN);
-	cqe_info->vlan_tag = RQ_CQE_SGE_GET(dw1, VLAN);
-
-	cqe_info->ptype = HINIC3_GET_RX_PTYPE_OFFLOAD(dw0);
-	cqe_info->vlan_offload = RQ_CQE_OFFOLAD_TYPE_GET(dw2, VLAN_EN);
-	cqe_info->rss_type = RQ_CQE_OFFOLAD_TYPE_GET(dw2, RSS_TYPE);
-	cqe_info->rss_hash_value = dw3;
-}
-
-void
+static void
 hinic3_rx_get_compact_cqe_info(struct hinic3_rxq *rxq, volatile struct hinic3_rq_cqe *rx_cqe,
 			       struct hinic3_cqe_info *cqe_info)
 {
@@ -1106,7 +1373,21 @@ hinic3_rx_get_compact_cqe_info(struct hinic3_rxq *rxq, volatile struct hinic3_rq
 	cqe_info->rss_type = rte_atomic_load_explicit(&rxq->rss_en,
 						      rte_memory_order_relaxed);
 	cqe_info->rss_hash_value = dw1;
-
+	if (rxq->wqe_type == HINIC3_COMPACT_RQ_WQE) {
+		switch (cqe_info->csum_err) {
+		case HINIC3_RX_COMPACT_L3_L4_CSUM_ERROR:
+			cqe_info->csum_err = HINIC3_RX_CSUM_LAYER_UNKNOWN_ERR;
+			break;
+		case HINIC3_RX_COMPACT_CSUM_OTHER_ERROR:
+			cqe_info->csum_err = HINIC3_RX_CSUM_IPSU_OTHER_ERR;
+			break;
+		case HINIC3_RX_COMPACT_HW_BYPASS_ERROR:
+			cqe_info->csum_err = HINIC3_RX_CSUM_HW_CHECK_NONE;
+			break;
+		default:
+			break;
+		}
+	}
 	if (cqe_info->cqe_len == HINIC3_RQ_COMPACT_CQE_16BYTE) {
 		cqe_info->lro_num = HINIC3_RQ_COMPACT_CQE_OFFLOAD_GET(dw2, NUM_LRO);
 		cqe_info->vlan_tag = HINIC3_RQ_COMPACT_CQE_OFFLOAD_GET(dw2, VLAN);
@@ -1117,15 +1398,15 @@ hinic3_rx_get_compact_cqe_info(struct hinic3_rxq *rxq, volatile struct hinic3_rq
 				(cqe_info->cqe_len == HINIC3_RQ_COMPACT_CQE_16BYTE) ? 16 : 8;
 }
 
-#define HINIC3_RX_EMPTY_THRESHOLD 3
 uint16_t
-hinic3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
+hinic3_recv_pkts_compact_cqe(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 {
 	struct hinic3_rxq *rxq = rx_queue;
 	struct hinic3_nic_dev *nic_dev = rxq->nic_dev;
+	const struct hinic3_ptype_table * const ptype_tbl = nic_dev->ptype_tbl;
 	struct hinic3_rx_info *rx_info = NULL;
 	volatile struct hinic3_rq_cqe *rx_cqe = NULL;
-	struct hinic3_cqe_info cqe_info = {0};
+	struct hinic3_cqe_info cqe_info;
 	struct rte_mbuf *rxm = NULL;
 	uint16_t sw_ci, rx_buf_len, pkts = 0;
 	uint32_t pkt_len;
@@ -1142,13 +1423,18 @@ hinic3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 	sw_ci = hinic3_get_rq_local_ci(rxq);
 
 	while (pkts < nb_pkts) {
-		rx_cqe = &rxq->rx_cqe[sw_ci];
-		if (!nic_dev->rx_ops->nic_rx_cqe_done(rxq, &rx_cqe)) {
+		if (!hinic3_rx_integrated_cqe_done(rxq, &rx_cqe)) {
 			rxq->rxq_stats.empty++;
 			break;
 		}
 
-		nic_dev->rx_ops->nic_rx_get_cqe_info(rxq, rx_cqe, &cqe_info);
+		/*
+		 * The getter leaves the fields that do not apply to the
+		 * current CQE format untouched, so clear the whole structure
+		 * to keep the previous packet's LRO/VLAN state out of this one.
+		 */
+		memset(&cqe_info, 0, sizeof(cqe_info));
+		hinic3_rx_get_compact_cqe_info(rxq, rx_cqe, &cqe_info);
 
 		pkt_len = cqe_info.pkt_len;
 		/*
@@ -1194,8 +1480,9 @@ hinic3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		/* 5. Vlan offload. */
 		rxm->ol_flags |= hinic3_rx_vlan(cqe_info.vlan_offload, cqe_info.vlan_tag,
 						&rxm->vlan_tci);
-
-		/* 6. RSS. */
+		/* 6. Packet ptype */
+		rxm->packet_type = ptype_tbl->ptype[cqe_info.ptype];
+		/* 7. RSS. */
 		rxm->ol_flags |= hinic3_rx_rss_hash(cqe_info.rss_type, cqe_info.rss_hash_value,
 						    &rxm->hash.rss);
 		/* 8. LRO. */
@@ -1235,3 +1522,141 @@ hinic3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 
 	return pkts;
 }
+
+uint16_t hinic3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
+{
+	struct hinic3_rxq *rxq = rx_queue;
+	struct hinic3_nic_dev *nic_dev = rxq->nic_dev;
+	struct hinic3_rx_info *rx_info = NULL;
+	volatile struct hinic3_rq_cqe *rx_cqe = NULL;
+	struct rte_mbuf *rxm = NULL;
+	uint16_t sw_ci, rx_buf_len, wqebb_cnt = 0, pkts = 0;
+	uint32_t status, pkt_len, vlan_len, offload_type, pkt_type, lro_num;
+	uint64_t rx_bytes = 0;
+	uint32_t hash_value = 0;
+	const struct hinic3_ptype_table * const ptype_tbl = nic_dev->ptype_tbl;
+
+#ifdef HINIC3_XSTAT_PROF_RX
+	uint64_t t1 = rte_get_tsc_cycles();
+	uint64_t t2;
+#endif
+	if (((rte_get_timer_cycles() - rxq->rxq_stats.tsc) < rxq->wait_time_cycle) &&
+	    rxq->rxq_stats.empty >= HINIC3_RX_EMPTY_THRESHOLD)
+		goto out;
+
+	sw_ci = hinic3_get_rq_local_ci(rxq);
+	rx_buf_len = rxq->buf_len;
+
+	while (pkts < nb_pkts) {
+		rx_cqe = &rxq->rx_cqe[sw_ci];
+		status = hinic3_hw_cpu32((uint32_t)(rte_atomic_load_explicit(&rx_cqe->status,
+								     rte_memory_order_acquire)));
+		if (!HINIC3_GET_RX_DONE(status)) {
+			rxq->rxq_stats.empty++;
+			break;
+		}
+
+		vlan_len = hinic3_hw_cpu32(rx_cqe->vlan_len);
+
+		pkt_len = HINIC3_GET_RX_PKT_LEN(vlan_len);
+
+		rx_info = &rxq->rx_info[sw_ci];
+		rxm = rx_info->mbuf;
+
+		/* 1. Next ci point and prefetch */
+		sw_ci++;
+		sw_ci &= rxq->q_mask;
+
+		/* 2. Prefetch next mbuf first 64B */
+		rte_prefetch0(rxq->rx_info[sw_ci].mbuf);
+
+		/* 3. Jumbo frame process */
+
+		if (likely(pkt_len <= (uint32_t)rx_buf_len)) {
+			rxm->data_len = (uint16_t)pkt_len;
+			rxm->pkt_len = pkt_len;
+			wqebb_cnt++;
+		} else {
+			rxm->data_len = rx_buf_len;
+			rxm->pkt_len = rx_buf_len;
+
+			/* If receive jumbo, updating ci will be done by
+			 * hinic3_recv_jumbo_pkt function.
+			 */
+			hinic3_update_rq_local_ci(rxq, wqebb_cnt + 1);
+			wqebb_cnt = 0;
+			hinic3_recv_jumbo_pkt(rxq, rxm, pkt_len - rx_buf_len);
+			sw_ci = hinic3_get_rq_local_ci(rxq);
+		}
+
+
+		/*
+		 * data_off was already set by rearm to the offset of the DMA
+		 * start address relative to buf (HEADROOM + alignment offset
+		 * when alignment is enabled, HEADROOM when disabled). The packet
+		 * data starts at buf + data_off, so no further adjustment is
+		 * needed.
+		 */
+		rxm->port = rxq->port_id;
+
+		/* 4. Rx checksum offload */
+		rxm->ol_flags |= hinic3_rx_csum(HINIC3_GET_RX_CSUM_ERR(status), rxq);
+
+		/* 5. Vlan offload */
+		offload_type = hinic3_hw_cpu32(rx_cqe->offload_type);
+
+		rxm->ol_flags |= hinic3_rx_vlan(HINIC3_GET_RX_VLAN_OFFLOAD_EN(offload_type),
+						HINIC3_GET_RX_VLAN_TAG(vlan_len),
+						&rxm->vlan_tci);
+
+		/* 6. Packet ptype */
+		pkt_type = HINIC3_GET_RX_PTYPE_OFFLOAD(offload_type);
+		rxm->packet_type = ptype_tbl->ptype[pkt_type];
+
+		/* 7. RSS */
+		hash_value = hinic3_hw_cpu32(rx_cqe->hash_val);
+		rxm->ol_flags |= hinic3_rx_rss_hash(HINIC3_GET_RSS_TYPES(offload_type),
+						    hash_value,
+						    &rxm->hash.rss);
+
+		/* 8. LRO */
+		lro_num = HINIC3_GET_RX_NUM_LRO(status);
+		if (unlikely(lro_num != 0)) {
+			rxm->ol_flags |= HINIC3_PKT_RX_LRO;
+			rxm->tso_segsz = pkt_len / lro_num;
+		}
+
+		rx_cqe->status = 0;
+
+		rx_bytes += pkt_len;
+		rx_pkts[pkts++] = rxm;
+	}
+
+	if (pkts) {
+		/* 9. Update local ci */
+		hinic3_update_rq_local_ci(rxq, wqebb_cnt);
+
+		/* Update packet stats */
+		rxq->rxq_stats.packets += pkts;
+		rxq->rxq_stats.bytes += rx_bytes;
+		rxq->rxq_stats.empty = 0;
+#ifdef HINIC3_XSTAT_MBUF_USE
+		rxq->rxq_stats.rx_free_mbuf_bytes += pkts;
+#endif
+	}
+	rxq->rxq_stats.burst_pkts = pkts;
+	rxq->rxq_stats.tsc = rte_get_timer_cycles();
+out:
+	/* 10. Rearm mbuf to rxq */
+	hinic3_rearm_rxq_mbuf(rxq);
+
+#ifdef HINIC3_XSTAT_PROF_RX
+	/* do profiling stats */
+	t2 = rte_get_tsc_cycles();
+	rxq->rxq_stats.app_tsc = t1 - rxq->prof_rx_end_tsc;
+	rxq->prof_rx_end_tsc = t2;
+	rxq->rxq_stats.pmd_tsc = t2 - t1;
+#endif
+
+	return pkts;
+}
diff --git a/drivers/net/hinic3/hinic3_rx.h b/drivers/net/hinic3/hinic3_rx.h
index 59a198c070..29bf3159aa 100644
--- a/drivers/net/hinic3/hinic3_rx.h
+++ b/drivers/net/hinic3/hinic3_rx.h
@@ -7,11 +7,23 @@
 
 #include <rte_stdatomic.h>
 
+#include "hinic3_wq.h"
+
 #define RQ_CQE_OFFOLAD_TYPE_PTYPE_OFFLOAD_SHIFT	0
+#define RQ_CQE_OFFOLAD_TYPE_PKT_TYPE_SHIFT	0
+#define RQ_CQE_OFFOLAD_TYPE_IP_TYPE_SHIFT	5
+#define RQ_CQE_OFFOLAD_TYPE_ENC_L3_TYPE_SHIFT	7
+#define RQ_CQE_OFFOLAD_TYPE_PKT_FORMAT_SHIFT	8
+#define RQ_CQE_OFFOLAD_TYPE_PKT_UMBCAST_SHIFT	19
 #define RQ_CQE_OFFOLAD_TYPE_VLAN_EN_SHIFT	21
 #define RQ_CQE_OFFOLAD_TYPE_RSS_TYPE_SHIFT	24
 
 #define RQ_CQE_OFFOLAD_TYPE_PTYPE_OFFLOAD_MASK	0xFFFU
+#define RQ_CQE_OFFOLAD_TYPE_PKT_TYPE_MASK	0x1FU
+#define RQ_CQE_OFFOLAD_TYPE_IP_TYPE_MASK	0x3U
+#define RQ_CQE_OFFOLAD_TYPE_ENC_L3_TYPE_MASK	0X1U
+#define RQ_CQE_OFFOLAD_TYPE_PKT_FORMAT_MASK	0xFU
+#define RQ_CQE_OFFOLAD_TYPE_PKT_UMBCAST_MASK	0x3U
 #define RQ_CQE_OFFOLAD_TYPE_VLAN_EN_MASK	0x1U
 #define RQ_CQE_OFFOLAD_TYPE_RSS_TYPE_MASK	0xFFU
 
@@ -27,6 +39,15 @@
 #define HINIC3_GET_RX_PKT_TYPE(offload_type) \
 	RQ_CQE_OFFOLAD_TYPE_GET(offload_type, PKT_TYPE)
 
+#define HINIC3_GET_RX_IP_TYPE(offload_type) \
+	RQ_CQE_OFFOLAD_TYPE_GET(offload_type, IP_TYPE)
+
+#define HINIC3_GET_RX_ENC_L3_TYPE(offload_type) \
+	RQ_CQE_OFFOLAD_TYPE_GET(offload_type, ENC_L3_TYPE)
+
+#define HINIC3_GET_RX_PKT_FORMAT(offload_type) \
+	RQ_CQE_OFFOLAD_TYPE_GET(offload_type, PKT_FORMAT)
+
 #define HINIC3_GET_RX_PKT_UMBCAST(offload_type) \
 	RQ_CQE_OFFOLAD_TYPE_GET(offload_type, PKT_UMBCAST)
 
@@ -144,10 +165,10 @@
 #define RQ_COMPACT_CQE_STATUS_CQE_TYPE_MASK		0x1U
 #define RQ_COMPACT_CQE_STATUS_TS_FLAG_MASK		0x1U
 #define RQ_COMPACT_CQE_STATUS_VLAN_EN_MASK		0x1U
-#define RQ_COMPACT_CQE_STATUS_PKT_FORMAT_MASK	0x7U
+#define RQ_COMPACT_CQE_STATUS_PKT_FORMAT_MASK		0x7U
 #define RQ_COMPACT_CQE_STATUS_IP_TYPE_MASK		0x1U
 #define RQ_COMPACT_CQE_STATUS_CQE_LEN_MASK		0x1U
-#define RQ_COMPACT_CQE_STATUS_PKT_MC_MASK		0x1U
+#define RQ_COMPACT_CQE_STATUS_PKT_MC_MASK		0x3U
 #define RQ_COMPACT_CQE_STATUS_CSUM_ERR_MASK		0x3U
 #define RQ_COMPACT_CQE_STATUS_PKT_TYPE_MASK		0x7U
 #define RQ_COMPACT_CQE_STATUS_PTYPE_MASK		0xFFFU
@@ -183,6 +204,15 @@
 #define HINIC3_RX_CSUM_SCTP_CRC_ERR     RTE_BIT32(6)
 #define HINIC3_RX_CSUM_HW_CHECK_NONE    RTE_BIT32(7)
 #define HINIC3_RX_CSUM_IPSU_OTHER_ERR   RTE_BIT32(8)
+/* Compact CQE: some inner/outer L3 or L4 checksum failed, layer unknown. */
+#define HINIC3_RX_CSUM_LAYER_UNKNOWN_ERR RTE_BIT32(9)
+
+enum hinic3_compact_cqe_csum_err_type {
+	HINIC3_RX_COMPACT_CSUM_NO_ERROR = 0,
+	HINIC3_RX_COMPACT_L3_L4_CSUM_ERROR,
+	HINIC3_RX_COMPACT_CSUM_OTHER_ERROR,
+	HINIC3_RX_COMPACT_HW_BYPASS_ERROR
+};
 
 #define HINIC3_DEFAULT_RX_CSUM_OFFLOAD 0xFFF
 #define HINIC3_CQE_LEN		       32
@@ -202,6 +232,59 @@
 	RTE_ETH_RSS_IPV6_TCP_EX |        \
 	RTE_ETH_RSS_IPV6_UDP_EX)
 
+#define HINIC3_COMPACT_CQE_PTYPE_SHIFT 16
+
+enum IPSU_METADATA_L3_TP_E {
+	IPSU_METADATA_L3_TP_IPV4 = 0u,
+	IPSU_METADATA_L3_TP_IPV6 = 1u,
+};
+
+enum IPSU_PKT_TYPE_L45FINAL_E {
+	IPSU_PKT_TYPE_NULL = 0,
+	IPSU_PKT_TYPE_ROCEV2,
+	IPSU_PKT_TYPE_TCPCOCO,
+	IPSU_PKT_TYPE_TCP,
+	IPSU_PKT_TYPE_UDP,
+	IPSU_PKT_TYPE_ICMP,
+	IPSU_PKT_TYPE_IGMP,
+	IPSU_PKT_TYPE_SCTP,
+	IPSU_PKT_TYPE_DHCP,
+	IPSU_PKT_TYPE_IPV4_FRAG,
+	IPSU_PKT_TYPE_IPV6_MC,
+	IPSU_PKT_TYPE_1588,
+	IPSU_PKT_TYPE_AH_OVER_IP,
+	IPSU_PKT_TYPE_ESP_OVER_IP,
+	IPSU_PKT_TYPE_NATT,
+	IPSU_PKT_TYPE_AH_OVER_VXLAN_GPE,
+	IPSU_PKT_TYPE_ESP_OVER_VXLAN_GPE,
+	IPSU_PKT_TYPE_TSO,
+	IPSU_PKT_TYPE_UFO,
+	IPSU_PKT_TYPE_INT,
+	IPSU_PKT_TYPE_IOAM,
+	IPSU_PKT_TYPE_VXLAN_GPE,
+	IPSU_PKT_TYPE_GENEVE,
+	IPSU_PKT_TYPE_NSH_OVER_GENEVE,
+	IPSU_PKT_TYPE_NSH_OVER_VXLAN_GPE,
+	IPSU_PKT_TYPE_ESP_OVER_GENEVE,
+	IPSU_PKT_TYPE_PPOP_OVER_GENEVE,
+	IPSU_PKT_TYPE_OSPF,
+	IPSU_PKT_TYPE_VRRP,
+	IPSU_PKT_TYPE_BGP,
+	IPSU_PKT_TYPE_GRE,
+	IPSU_ERR_RSVD,
+};
+
+enum IPSU_METADATA_FMT_E {
+	IPSU_METADATA_FMT_NO_ENC	= 0u,
+	IPSU_METADATA_FMT_VXLAN		= 1u,
+	IPSU_METADATA_FMT_NVGRE		= 2u,
+	IPSU_METADATA_FMT_FC		= 3u,
+	IPSU_METADATA_FMT_GPE		= 4u,
+	IPSU_METADATA_FMT_GENEVE	= 5u,
+	IPSU_METADATA_FMT_NSH		= 6u,
+	IPSU_METADATA_FMT_IPIP		= 7U,
+};
+
 struct hinic3_rxq_stats {
 	uint64_t packets;
 	uint64_t bytes;
@@ -315,7 +398,6 @@ struct hinic3_rq_ci_wb {
 	uint32_t rsvd[3];
 };
 
-
 struct __rte_cache_aligned hinic3_rxq {
 	struct hinic3_nic_dev *nic_dev;
 
@@ -378,24 +460,6 @@ struct __rte_cache_aligned hinic3_rxq {
 #endif
 };
 
-/* Rx CQE info get callback function */
-typedef void  (*nic_rx_get_cqe_info_t)(struct hinic3_rxq *rxq,
-				       volatile struct hinic3_rq_cqe *rx_cqe,
-				       struct hinic3_cqe_info *cqe_info);
-
-/* Rx CQE check status callback function */
-typedef bool  (*nic_rx_cqe_done_t)(struct hinic3_rxq *rxq,
-				   volatile struct hinic3_rq_cqe **rx_cqe);
-
-/* Rx CQE empty poll callback function */
-typedef int   (*nic_rx_poll_rq_empty_t)(struct hinic3_rxq *rxq);
-
-struct hinic3_nic_rx_ops {
-	nic_rx_get_cqe_info_t		nic_rx_get_cqe_info;
-	nic_rx_cqe_done_t		nic_rx_cqe_done;
-	nic_rx_poll_rq_empty_t		nic_rx_poll_rq_empty;
-};
-
 uint16_t hinic3_rx_fill_wqe(struct hinic3_rxq *rxq);
 
 uint16_t hinic3_rx_fill_buffers(struct hinic3_rxq *rxq);
@@ -407,16 +471,14 @@ void hinic3_free_all_rxq_mbufs(struct hinic3_nic_dev *nic_dev);
 int hinic3_update_rss_config(struct rte_eth_dev *dev,
 			     struct rte_eth_rss_conf *rss_conf);
 
-int hinic3_poll_integrated_cqe_rq_empty(struct hinic3_rxq *rxq);
-int hinic3_poll_rq_empty(struct hinic3_rxq *rxq);
-
-void hinic3_dump_cqe_status(struct hinic3_rxq *rxq, uint32_t *cqe_done_cnt,
-			    uint32_t *cqe_hole_cnt, uint32_t *head_ci, uint32_t *head_done);
+int hinic3_init_rx_ptype_table(struct rte_eth_dev *dev);
 
 int hinic3_stop_rq(struct rte_eth_dev *eth_dev, struct hinic3_rxq *rxq);
 
 int hinic3_start_rq(struct rte_eth_dev *eth_dev, struct hinic3_rxq *rxq);
 
+uint16_t hinic3_recv_pkts_compact_cqe(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
+
 uint16_t hinic3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
 
 void hinic3_add_rq_to_rx_queue_list(struct hinic3_nic_dev *nic_dev,
@@ -435,95 +497,4 @@ void hinic3_rxq_rss_en_update(struct rte_eth_dev *eth_dev);
 void hinic3_get_stats(struct hinic3_rxq *rxq);
 #endif
 
-/**
- * Get receive queue local ci.
- *
- * @param[in] rxq
- * Pointer to receive queue structure.
- * @return
- * Receive queue local ci.
- */
-static inline uint16_t
-hinic3_get_rq_local_ci(struct hinic3_rxq *rxq)
-{
-	return MASKED_QUEUE_IDX(rxq, rxq->cons_idx);
-}
-
-static inline uint16_t
-hinic3_get_rq_free_wqebb(struct hinic3_rxq *rxq)
-{
-	return rxq->delta - 1;
-}
-
-/**
- * Update receive queue local ci.
- *
- * @param[in] rxq
- * Pointer to receive queue structure.
- * @param[out] wqe_cnt
- * Wqebb counters.
- */
-static inline void
-hinic3_update_rq_local_ci(struct hinic3_rxq *rxq, uint16_t wqe_cnt)
-{
-	rxq->cons_idx += wqe_cnt;
-	rxq->delta += wqe_cnt;
-}
-
-/**
- * Get receive cqe information
- *
- * @param[in] rxq
- *   Receive queue
- * @param[in] rx_cqe
- *   Receive cqe
- * @param[in] cqe_info
- *   Packet information parsed from cqe
- */
-void
-hinic3_rx_get_cqe_info(struct hinic3_rxq *rxq, volatile struct hinic3_rq_cqe *rx_cqe,
-		       struct hinic3_cqe_info *cqe_info);
-
-/**
- * Get receive compact cqe information
- *
- * @param[in] rx_queue
- *   Receive queue
- * @param[in] rx_cqe
- *   Receive compact cqe
- * @param[in] cqe_info
- *   Packet information parsed from cqe
- */
-void
-hinic3_rx_get_compact_cqe_info(struct hinic3_rxq *rxq, volatile struct hinic3_rq_cqe *rx_cqe,
-			       struct hinic3_cqe_info *cqe_info);
-
-/**
- * Check whether pkt is received when CQE is separated
- *
- * @param[in] rxq
- *   Receive queue
- * @param[in] rx_cqe
- *   The CQE written by hw
- * @return
- *   True: Packet is received
- *   False: Packet is not received
- */
-bool
-hinic3_rx_separate_cqe_done(struct hinic3_rxq *rxq, volatile struct hinic3_rq_cqe **rx_cqe);
-
-/**
- * Check whether pkt is received when CQE is integrated
- *
- * @param[in] rxq
- *   Receive queue
- * @param[in] rx_cqe
- *   The CQE written by hw
- * @return
- *   True: Packet is received
- *   False: Packet is not received
- */
-bool
-hinic3_rx_integrated_cqe_done(struct hinic3_rxq *rxq, volatile struct hinic3_rq_cqe **rx_cqe);
-
 #endif /* _HINIC3_RX_H_ */
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 25/30] net/hinic3: ensure queue depth and state consistency
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (23 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 24/30] net/hinic3: add compact CQE Rx path and ptype table Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 26/30] net/hinic3: expand TSO from 127 to 255 segments Jiacheng Ye
                   ` (5 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

The hardware tracks a single queue depth, which the root context takes
from queue 0. A queue configured with a different depth used to be
silently coerced to the first queue's depth; reject it with -EINVAL
instead, since the application sized its mempool for the requested
depth.

Keep the expected depth in the per-port state, reset it in
dev_configure() and dev_stop(), and validate in dev_start() that every
configured queue is present and shares queue 0's depth.

Reset the rx/tx queue states in dev_stop, including the tx queue status
used by the Tx path, so the queue state reflects the stopped device
before the next start.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_ethdev.c | 88 +++++++++++++++++++++++++-----
 drivers/net/hinic3/hinic3_ethdev.h |  5 ++
 2 files changed, 80 insertions(+), 13 deletions(-)

diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 706f3b871b..127a6c42d5 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -318,8 +318,6 @@ hinic3_xstats_calc_num(struct hinic3_nic_dev *nic_dev)
 	}
 }
 
-#define HINIC3_MAX_QUEUE_DEPTH 16384
-#define HINIC3_MIN_QUEUE_DEPTH 128
 #define HINIC3_TXD_ALIGN       1
 #define HINIC3_RXD_ALIGN       1
 
@@ -735,6 +733,8 @@ hinic3_dev_configure(struct rte_eth_dev *dev)
 
 	nic_dev->num_sqs = dev->data->nb_tx_queues;
 	nic_dev->num_rqs = dev->data->nb_rx_queues;
+	nic_dev->rxq_depth = 0;
+	nic_dev->txq_depth = 0;
 
 	nic_dev->mtu_size =
 		(uint16_t)HINIC3_PKTLEN_TO_MTU(HINIC3_MAX_RX_PKT_LEN(dev->data->dev_conf.rxmode));
@@ -1116,16 +1116,8 @@ hinic3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 
 	nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
-	/* Queue depth must be equal to queue 0 */
-	if (qid != 0 && nb_desc != nic_dev->rxqs[0]->q_depth) {
-		PMD_DRV_LOG(WARNING, "rxq%u depth:%u is not equal to queue0 depth:%u.",
-			    qid, nb_desc, nic_dev->rxqs[0]->q_depth);
-		nb_desc = nic_dev->rxqs[0]->q_depth;
-	}
-
 	/* Queue depth must be power of 2, otherwise will be aligned up. */
-	rq_depth = (nb_desc & (nb_desc - 1))
-			? ((uint16_t)(1U << (rte_log2_u32(nb_desc) + 1))) : nb_desc;
+	rq_depth = (uint16_t)rte_align32pow2(nb_desc);
 
 	/*
 	 * Validate number of receive descriptors.
@@ -1142,6 +1134,19 @@ hinic3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 		return -EINVAL;
 	}
 
+	/*
+	 * The hardware tracks a single queue depth. Keep the value chosen by
+	 * the first queue of this configuration and compare against it, so a
+	 * runtime reconfiguration with a different depth is not rejected by
+	 * queues that still hold the previous depth.
+	 */
+	if (nic_dev->rxq_depth != 0 && nic_dev->rxq_depth != rq_depth) {
+		PMD_DRV_LOG(ERR,
+			    "rxq%u depth:%u is not equal to the port depth:%u.",
+			    qid, rq_depth, nic_dev->rxq_depth);
+		return -EINVAL;
+	}
+
 	/*
 	 * The RX descriptor ring will be cleaned after rxq->rx_free_thresh
 	 * descriptors are used or if the number of descriptors required
@@ -1295,6 +1300,7 @@ hinic3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 		}
 	}
 	dev->data->rx_queues[qid] = rxq;
+	nic_dev->rxq_depth = rq_depth;
 
 	return 0;
 
@@ -1351,8 +1357,7 @@ hinic3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 	hwdev = nic_dev->hwdev;
 
 	/* Queue depth must be power of 2, otherwise will be aligned up. */
-	sq_depth = (nb_desc & (nb_desc - 1))
-				? ((uint16_t)(1U << (rte_log2_u32(nb_desc) + 1))) : nb_desc;
+	sq_depth = (uint16_t)rte_align32pow2(nb_desc);
 
 	/*
 	 * Validate number of transmit descriptors.
@@ -1369,6 +1374,19 @@ hinic3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 		return -EINVAL;
 	}
 
+	/*
+	 * The hardware tracks a single queue depth. Keep the value chosen by
+	 * the first queue of this configuration and compare against it, so a
+	 * runtime reconfiguration with a different depth is not rejected by
+	 * queues that still hold the previous depth.
+	 */
+	if (nic_dev->txq_depth != 0 && nic_dev->txq_depth != sq_depth) {
+		PMD_DRV_LOG(ERR,
+			    "txq%u depth:%u is not equal to the port depth:%u.",
+			    qid, sq_depth, nic_dev->txq_depth);
+		return -EINVAL;
+	}
+
 	/*
 	 * The TX descriptor ring will be cleaned after txq->tx_free_thresh
 	 * descriptors are used or if the number of descriptors required
@@ -1466,6 +1484,7 @@ hinic3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 	}
 
 	dev->data->tx_queues[qid] = txq;
+	nic_dev->txq_depth = sq_depth;
 
 	return 0;
 
@@ -2121,6 +2140,33 @@ hinic3_dev_start(struct rte_eth_dev *eth_dev)
 	int err;
 
 	nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
+
+	/*
+	 * The root context carries a single depth per direction, taken from
+	 * queue 0, and a queue setup cannot change the other queues. A partial
+	 * reconfiguration would therefore leave the rings sized differently
+	 * from the root context, so refuse to start unless every configured
+	 * queue is present and shares the depth of queue 0.
+	 */
+	for (i = 0; i < nic_dev->num_rqs; i++) {
+		if (nic_dev->rxqs[i] == NULL ||
+		    nic_dev->rxqs[i]->q_depth != nic_dev->rxqs[0]->q_depth) {
+			PMD_DRV_LOG(ERR,
+				    "rxq%u is missing or has a different depth than rxq0.",
+				    i);
+			return -EINVAL;
+		}
+	}
+	for (i = 0; i < nic_dev->num_sqs; i++) {
+		if (nic_dev->txqs[i] == NULL ||
+		    nic_dev->txqs[i]->q_depth != nic_dev->txqs[0]->q_depth) {
+			PMD_DRV_LOG(ERR,
+				    "txq%u is missing or has a different depth than txq0.",
+				    i);
+			return -EINVAL;
+		}
+	}
+
 	err = hinic3_copy_mempool_init(nic_dev);
 	if (err) {
 		PMD_DRV_LOG(ERR, "Create copy mempool failed, dev_name: %s",
@@ -2271,6 +2317,7 @@ hinic3_dev_stop(struct rte_eth_dev *dev)
 {
 	struct hinic3_nic_dev *nic_dev;
 	struct rte_eth_link link;
+	uint16_t i;
 	int err;
 
 	nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
@@ -2322,6 +2369,21 @@ hinic3_dev_stop(struct rte_eth_dev *dev)
 
 	/* Free mempool. */
 	hinic3_copy_mempool_uninit(nic_dev);
+
+	/* A stopped device starts a new queue configuration. */
+	nic_dev->rxq_depth = 0;
+	nic_dev->txq_depth = 0;
+
+	for (i = 0; i < dev->data->nb_rx_queues; i++)
+		dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
+		struct hinic3_txq *txq = dev->data->tx_queues[i];
+
+		if (txq != NULL)
+			HINIC3_SET_TXQ_STOPPED(txq);
+		dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index 0763665885..eff0bca29e 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -15,6 +15,9 @@
 
 #define HINIC3_PMD_DRV_VERSION "B106"
 
+#define HINIC3_MAX_QUEUE_DEPTH         16384
+#define HINIC3_MIN_QUEUE_DEPTH         128
+
 #define PCI_DEV_TO_INTR_HANDLE(pci_dev) ((pci_dev)->intr_handle)
 
 #define HINIC3_PKT_RX_L4_CKSUM_BAD	RTE_MBUF_F_RX_L4_CKSUM_BAD
@@ -144,6 +147,8 @@ struct hinic3_nic_dev {
 
 	uint16_t num_sqs;
 	uint16_t num_rqs;
+	uint16_t rxq_depth;
+	uint16_t txq_depth;
 	uint16_t max_sqs;
 	uint16_t max_rqs;
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 26/30] net/hinic3: expand TSO from 127 to 255 segments
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (24 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 25/30] net/hinic3: ensure queue depth and state consistency Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 27/30] net/hinic3: split Tx burst function for compact task support Jiacheng Ye
                   ` (4 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Raise the TSO segment limit to 255 so full jumbo frames can be sent, and
rework the SGE copy path to build multiple copy mbufs instead of one. 255
is the number of buffer descriptors a WQE can carry, and also the input
segment count the copy path has to compact.

Raise the non-TSO SGE limit from 32 to 38 to match the non-TSO WQE. The
per-port copy pool is sized from the Tx queue depth, with at most 256
mbufs per queue; the per-segment copy source offset advances across the
copy mbufs so a segment spanning several copy mbufs is not copied from
the start every time.

Reject WQEs with sge_cnt >= q_depth - 1 (the ring reports at most
q_depth - 1 free WQEBBs), advertise the 255-segment limit through the Tx
descriptor limits, and keep nb_segs and pkt_len consistent while building
the copy chain.

Reject packets with tso_segsz == 0 or a value that does not fit the 14-bit
MSS field instead of dividing by zero or using a truncated value to
compute the fragment count.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/nics/hinic3.rst             |   5 +
 doc/guides/rel_notes/release_26_11.rst |   1 +
 drivers/net/hinic3/hinic3_ethdev.c     |  51 +++-
 drivers/net/hinic3/hinic3_ethdev.h     |   1 -
 drivers/net/hinic3/hinic3_tx.c         | 328 ++++++++++++++-----------
 drivers/net/hinic3/hinic3_tx.h         |  15 +-
 6 files changed, 240 insertions(+), 161 deletions(-)

diff --git a/doc/guides/nics/hinic3.rst b/doc/guides/nics/hinic3.rst
index 25d86f0e48..ccc72c0df4 100644
--- a/doc/guides/nics/hinic3.rst
+++ b/doc/guides/nics/hinic3.rst
@@ -82,4 +82,9 @@ CQE modes.
 Limitations or Known issues
 ---------------------------
 
+The number of segments in one Tx packet is also limited by the Tx queue
+depth: a packet whose SGE count would need the whole ring is rejected, so
+a queue of 128 or 256 descriptors can transmit at most 126 or 254 segments
+even though the device reports a segment limit of 255.
+
 x86-32, Windows, and BSD are not supported yet.
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index d8dc492b83..62dc9bfda4 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -142,6 +142,7 @@ New Features
   * Added support for the SP560 NIC.
   * Added device parameters for runtime configuration.
   * Added a compact CQE receive data path.
+  * Extended TCP segmentation offload (TSO) to 255 segments.
 
 * **Updated Intel iavf driver.**
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 127a6c42d5..8020b5c28d 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -331,6 +331,8 @@ static const struct rte_eth_desc_lim hinic3_tx_desc_lim = {
 	.nb_max = HINIC3_MAX_QUEUE_DEPTH,
 	.nb_min = HINIC3_MIN_QUEUE_DEPTH,
 	.nb_align = HINIC3_TXD_ALIGN,
+	.nb_seg_max = HINIC3_TSO_PKT_MAX_SGE,
+	.nb_mtu_seg_max = HINIC3_TSO_PKT_MAX_SGE,
 };
 
 /*
@@ -666,24 +668,46 @@ hinic3_deinit_sw_rxtxqs(struct hinic3_nic_dev *nic_dev)
 static int
 hinic3_copy_mempool_init(struct hinic3_nic_dev *nic_dev)
 {
-	nic_dev->cpy_mpool = rte_mempool_lookup(HINCI3_CPY_MEMPOOL_NAME);
+	char name[RTE_MEMPOOL_NAMESIZE];
+	struct hinic3_txq *txq = nic_dev->txqs[0];
+	unsigned int q_depth = 0;
+	unsigned int depth;
+
+	/*
+	 * Give each port its own copy pool so in-flight copy mbufs from one
+	 * port cannot starve another. A copied packet pins its copy mbufs
+	 * until Tx completion. The per-queue contribution is capped at 256
+	 * mbufs to bound the hugepage memory a port can pin; a single copied
+	 * TSO packet can pin up to HINIC3_TSO_MBUF_NUM_MAX (227) of them, so
+	 * the pool can still run out even at a queue depth of 256. If it
+	 * does, the allocation fails and the burst stops at that packet,
+	 * leaving it to the caller. A minimum size is kept for small queue
+	 * configurations.
+	 */
+	if (txq != NULL)
+		q_depth = txq->q_depth;
+
+	depth = nic_dev->num_sqs * RTE_MIN(q_depth, 256u);
+	if (depth < HINIC3_COPY_MEMPOOL_DEPTH)
+		depth = HINIC3_COPY_MEMPOOL_DEPTH;
+
+	snprintf(name, sizeof(name), "hinic3_cpy_%u",
+		 (unsigned int)nic_dev->hwdev->eth_dev->data->port_id);
+	nic_dev->cpy_mpool = rte_pktmbuf_pool_create(name, depth,
+			HINIC3_COPY_MEMPOOL_CACHE, 0, HINIC3_COPY_MBUF_SIZE,
+			nic_dev->hwdev->pci_dev->device.numa_node);
 	if (nic_dev->cpy_mpool == NULL) {
-		nic_dev->cpy_mpool = rte_pktmbuf_pool_create(HINCI3_CPY_MEMPOOL_NAME,
-			HINIC3_COPY_MEMPOOL_DEPTH, HINIC3_COPY_MEMPOOL_CACHE,
-			0, HINIC3_COPY_MBUF_SIZE, rte_socket_id());
-		if (nic_dev->cpy_mpool == NULL) {
-			PMD_DRV_LOG(ERR,
-				    "Create copy mempool failed, errno: %d, dev_name: %s",
-				    rte_errno, HINCI3_CPY_MEMPOOL_NAME);
-			return -ENOMEM;
-		}
+		PMD_DRV_LOG(ERR,
+			    "Create copy mempool %s failed, errno: %d, dev_name: %s",
+			    name, rte_errno, nic_dev->dev_name);
+		return -ENOMEM;
 	}
 
 	return 0;
 }
 
 /**
- * Clear the reference to the copy memory pool without freeing it.
+ * Free the copy memory pool.
  *
  * @param[in] nic_dev
  * Pointer to NIC device structure.
@@ -691,6 +715,9 @@ hinic3_copy_mempool_init(struct hinic3_nic_dev *nic_dev)
 static void
 hinic3_copy_mempool_uninit(struct hinic3_nic_dev *nic_dev)
 {
+	if (nic_dev->cpy_mpool != NULL)
+		rte_mempool_free(nic_dev->cpy_mpool);
+
 	nic_dev->cpy_mpool = NULL;
 }
 
@@ -1422,6 +1449,8 @@ hinic3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 	txq->wqebb_size = (uint16_t)RTE_BIT32(txq->wqebb_shift);
 	txq->tx_free_thresh = tx_free_thresh;
 	txq->owner = 1;
+	txq->non_tso_max_pkt_len =
+		HINIC3_IS_SP230_NIC(nic_dev) ? HINIC3_MAX_JUMBO_FRAME_SIZE : MAX_SINGLE_SGE_SIZE;
 
 	if (!ODD_NUMBER_QUEUE_ID(qid) &&
 		hinic3_cmd_vf_lag(nic_dev->hwdev, hinic3_global_func_id(nic_dev->hwdev),
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index eff0bca29e..dfa5bf8b8f 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -50,7 +50,6 @@
 #define HINIC3_PKT_RX_LRO		RTE_MBUF_F_RX_LRO
 #define HINIC3_PKT_TX_L4_NO_CKSUM	RTE_MBUF_F_TX_L4_NO_CKSUM
 
-#define HINCI3_CPY_MEMPOOL_NAME "cpy_mempool"
 /* Mbuf pool for copy invalid mbuf segs. */
 #define HINIC3_COPY_MEMPOOL_DEPTH	1024
 #define HINIC3_COPY_MEMPOOL_CACHE	128
diff --git a/drivers/net/hinic3/hinic3_tx.c b/drivers/net/hinic3/hinic3_tx.c
index 0555fd3393..f9ae9df431 100644
--- a/drivers/net/hinic3/hinic3_tx.c
+++ b/drivers/net/hinic3/hinic3_tx.c
@@ -661,122 +661,111 @@ hinic3_set_tx_offload(struct hinic3_nic_dev *nic_dev,
  * true as valid, false as invalid.
  */
 static bool
-hinic3_is_tso_sge_valid(struct rte_mbuf *mbuf, struct hinic3_wqe_info *wqe_info)
+hinic3_is_tso_sge_valid(struct rte_mbuf *mbuf,
+			struct hinic3_wqe_info *wqe_info)
 {
-	uint32_t total_len, limit_len, checked_len, left_len, adjust_mss;
-	uint32_t max_sges, left_sges, first_len;
-	uint32_t payload_len, frag_num;
-	uint32_t i;
-	struct rte_mbuf *mbuf_head, *mbuf_first;
-	struct rte_mbuf *mbuf_pre = mbuf;
+	uint32_t payload_len, frag_num, adjust_mss, limit_len;
+	uint32_t i = 0, window_len = 0, no_copy_total_len = 0;
+	uint8_t copy_mbuf_num;
+	struct rte_mbuf *mbuf_pkt;
 
-	left_sges = mbuf->nb_segs;
-	mbuf_head = mbuf;
-	mbuf_first = mbuf;
+	if (unlikely(mbuf->data_len < wqe_info->payload_offset &&
+		     mbuf->nb_segs > HINIC3_NONTSO_PKT_MAX_SGE))
+		return false;
 
 	/* Calculate the number of message payload frag,
 	 * if it exceeds the hardware limit of 10 bits,
 	 * packet will be discarded.
 	 */
-	payload_len = mbuf_head->pkt_len - wqe_info->payload_offset;
-	frag_num = (payload_len + mbuf_head->tso_segsz - 1) / mbuf_head->tso_segsz;
-	if (frag_num > MAX_TSO_NUM_FRAG) {
-		PMD_DRV_LOG(WARNING, "tso frag num over hw limit, frag_num:0x%x.", frag_num);
+	payload_len = mbuf->pkt_len - wqe_info->payload_offset;
+
+	frag_num = (payload_len + mbuf->tso_segsz - 1) / mbuf->tso_segsz;
+	if (frag_num > MAX_TSO_NUM_FRAG)
 		return false;
-	}
 
-	/* Tso sge number validation. */
-	if (unlikely(left_sges >= HINIC3_NONTSO_PKT_MAX_SGE)) {
-		checked_len = 0;
-		total_len = 0;
-		first_len = 0;
-		adjust_mss = mbuf->tso_segsz >= TX_MSS_MIN ? mbuf->tso_segsz
-							   : TX_MSS_MIN;
-		max_sges = HINIC3_NONTSO_PKT_MAX_SGE - 1;
-		limit_len = adjust_mss + wqe_info->payload_offset;
-
-		for (i = 0; (i < max_sges) && (total_len < limit_len); i++) {
-			total_len += mbuf->data_len;
-			mbuf_pre = mbuf;
-			mbuf = mbuf->next;
-		}
+	/* TSO SGE <= HINIC3_NONTSO_PKT_MAX_SGE: no processing */
+	if (likely(mbuf->nb_segs <= HINIC3_NONTSO_PKT_MAX_SGE))
+		return true;
 
-		/* Each continues 38 mbufs segmust do one check. */
-		while (left_sges >= HINIC3_NONTSO_PKT_MAX_SGE) {
-			if (total_len >= limit_len) {
-				/* Update the limit len. */
-				limit_len = adjust_mss;
-				/* Update checked len. */
-				checked_len += first_len;
-				/* Record the first len. */
-				first_len = mbuf_first->data_len;
-				/* First mbuf move to the next. */
-				mbuf_first = mbuf_first->next;
-				/* Update total len. */
-				total_len -= first_len;
-				left_sges--;
-				i--;
-				for (;
-				     (i < max_sges) && (total_len < limit_len);
-				     i++) {
-					total_len += mbuf->data_len;
-					mbuf_pre = mbuf;
-					mbuf = mbuf->next;
-				}
-			} else {
-				/* Try to copy if not valid. */
-				checked_len += (total_len - mbuf_pre->data_len);
+	adjust_mss = mbuf->tso_segsz >= TX_MSS_MIN ? mbuf->tso_segsz : TX_MSS_MIN;
 
-				left_len = mbuf_head->pkt_len - checked_len;
-				if (left_len > HINIC3_COPY_MBUF_SIZE)
-					return false;
-				wqe_info->sge_cnt = (uint16_t)(mbuf_head->nb_segs +
-							  i - left_sges);
-				wqe_info->cpy_mbuf_cnt = 1;
+	/* TSO SGE > HINIC3_TSO_PKT_MAX_SGE: skip MSS check, directly trigger copy */
+	if (unlikely(mbuf->nb_segs > HINIC3_TSO_PKT_MAX_SGE))
+		goto copy;
 
-				return true;
+	/* Check sum of 38 SGEs < MSS (First segment < header + MSS) */
+	limit_len = adjust_mss + wqe_info->payload_offset;
+	mbuf_pkt = mbuf;
+	while (mbuf_pkt) {
+		window_len += mbuf_pkt->data_len;
+		i++;
+		mbuf_pkt = mbuf_pkt->next;
+
+		if (i > HINIC3_NONTSO_PKT_MAX_SGE)
+			goto copy;
+
+		if (window_len >= limit_len) {
+			if (limit_len == adjust_mss + wqe_info->payload_offset) {
+				window_len -= limit_len;
+				limit_len = adjust_mss;
 			}
-		} /**< End of while. */
+			window_len %= adjust_mss;
+			i = (window_len == 0) ? 0 : 1;
+		}
+	}
+	return true;
+
+copy:
+	mbuf_pkt = mbuf;
+	for (i = 0; i < HINIC3_NON_COPY_SGE_NUM; i++) {
+		no_copy_total_len += mbuf_pkt->data_len;
+		mbuf_pkt = mbuf_pkt->next;
 	}
 
-	wqe_info->sge_cnt = mbuf_head->nb_segs;
+	/* TSO payload must fit in HINIC3_TSO_MBUF_NUM_MAX copy mbufs. */
+	if (unlikely(mbuf->pkt_len - no_copy_total_len >
+		     HINIC3_TSO_MBUF_NUM_MAX * HINIC3_COPY_MBUF_SIZE))
+		return false;
+
+	copy_mbuf_num = (mbuf->pkt_len - no_copy_total_len +
+			 HINIC3_COPY_MBUF_SIZE - 1) / HINIC3_COPY_MBUF_SIZE;
+
+	/* Total SGE = 28 normal SGEs + copy mbufs */
+	wqe_info->sge_cnt = HINIC3_NON_COPY_SGE_NUM + copy_mbuf_num;
+	wqe_info->cpy_mbuf_cnt = copy_mbuf_num;
 
 	return true;
 }
 
 static int
-hinic3_non_tso_pkt_pre_process(struct rte_mbuf *mbuf, struct hinic3_wqe_info *wqe_info)
+hinic3_non_tso_pkt_pre_process(struct rte_mbuf *mbuf, struct hinic3_wqe_info *wqe_info,
+			       uint32_t non_tso_max_pkt_len)
 {
 	struct rte_mbuf *mbuf_pkt = mbuf;
 	uint32_t total_len = 0;
-	uint16_t i;
+	uint16_t i, copy_mbuf_num = 0;
+
+	/* Non-TSO packet length must not exceed non_tso_max_pkt_len. */
+	if (unlikely(mbuf->pkt_len > non_tso_max_pkt_len))
+		return -EINVAL;
 
 	if (likely(HINIC3_NONTSO_SEG_NUM_VALID(mbuf->nb_segs)))
 		return 0;
 
-	/* Non-tso packet length must less than 64KB. */
-	if (unlikely(mbuf->pkt_len > MAX_SINGLE_SGE_SIZE))
-		return -EINVAL;
-
-	/*
-	 * Mbuf number of non-tso packet must less than the sge number
-	 * that nic can support. The excess part will be copied to another
-	 * mbuf.
-	 */
-	for (i = 0; i < (HINIC3_NONTSO_PKT_MAX_SGE - 1); i++) {
+	for (i = 0; i < HINIC3_NON_COPY_SGE_NUM; i++) {
 		total_len += mbuf_pkt->data_len;
 		mbuf_pkt = mbuf_pkt->next;
 	}
 
-	/*
-	 * Max copy mbuf size is 4KB, packet will be dropped directly,
-	 * if total copy length is more than it.
-	 */
-	if ((total_len + HINIC3_COPY_MBUF_SIZE) < mbuf->pkt_len)
+	/* Calculate required mbuf number */
+	copy_mbuf_num = (mbuf->pkt_len - total_len +
+			 HINIC3_COPY_MBUF_SIZE - 1) / HINIC3_COPY_MBUF_SIZE;
+	if (copy_mbuf_num > HINIC3_NONTSO_MBUF_NUM_MAX)
 		return -EINVAL;
 
-	wqe_info->sge_cnt = HINIC3_NONTSO_PKT_MAX_SGE;
-	wqe_info->cpy_mbuf_cnt = 1;
+	/* Total SGE = 28 normal SGEs + copy mbufs */
+	wqe_info->sge_cnt = HINIC3_NON_COPY_SGE_NUM + copy_mbuf_num;
+	wqe_info->cpy_mbuf_cnt = copy_mbuf_num;
 
 	return 0;
 }
@@ -790,12 +779,15 @@ hinic3_non_tso_pkt_pre_process(struct rte_mbuf *mbuf, struct hinic3_wqe_info *wq
  * Point to the mbuf to send.
  * @param[in] wqe_info
  * Point to wqe_info of send queue(SQ).
+ * @param[in] q_depth
+ *  Depth of the send queue, used to reject a WQE that can never fit.
  * @return
  * 0 as success, -EINVAL as failure.
  */
 static int
 hinic3_get_tx_offload(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *mbuf,
-		      struct hinic3_wqe_info *wqe_info)
+		      struct hinic3_wqe_info *wqe_info, uint32_t non_tso_max_pkt_len,
+		      uint16_t q_depth)
 {
 	uint64_t ol_flags = mbuf->ol_flags;
 	uint16_t inner_l3_offset = 0;
@@ -806,28 +798,43 @@ hinic3_get_tx_offload(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *mbuf,
 	/* Check if the packet set available offload flags. */
 	if (!(ol_flags & HINIC3_TX_OFFLOAD_MASK)) {
 		wqe_info->offload = 0;
-		return hinic3_non_tso_pkt_pre_process(mbuf, wqe_info);
-	}
-
-	wqe_info->offload = 1;
-	err = hinic3_get_inner_l3_offset(nic_dev, mbuf, &inner_l3_offset);
-	if (err)
-		return err;
-
-	/* Non-tso mbuf only check sge num. */
-	if (likely(!(mbuf->ol_flags & HINIC3_PKT_TX_TCP_SEG)))
-		return hinic3_non_tso_pkt_pre_process(mbuf, wqe_info);
+		err = hinic3_non_tso_pkt_pre_process(mbuf, wqe_info,
+						     non_tso_max_pkt_len);
+		if (unlikely(err))
+			return err;
+	} else {
+		wqe_info->offload = 1;
+		err = hinic3_get_inner_l3_offset(nic_dev, mbuf, &inner_l3_offset);
+		if (err)
+			return err;
+
+		/* Non-tso mbuf only check sge num. */
+		if (likely(!(mbuf->ol_flags & HINIC3_PKT_TX_TCP_SEG))) {
+			err = hinic3_non_tso_pkt_pre_process(mbuf, wqe_info,
+							     non_tso_max_pkt_len);
+			if (unlikely(err))
+				return err;
+		} else {
+			/* Tso mbuf. */
+			if (unlikely(mbuf->tso_segsz == 0 ||
+				     mbuf->tso_segsz > SQ_CTRL_QUEUE_INFO_MSS_MASK))
+				return -EINVAL;
 
-	/* Tso mbuf. */
-	wqe_info->payload_offset =
-		inner_l3_offset + mbuf->l3_len + mbuf->l4_len;
+			wqe_info->payload_offset =
+				inner_l3_offset + mbuf->l3_len + mbuf->l4_len;
 
-	/* Too many mbuf segs. */
-	if (unlikely(HINIC3_TSO_SEG_NUM_INVALID(mbuf->nb_segs)))
-		return -EINVAL;
+			/* Check whether can cover all tso mbuf segs or not. */
+			if (unlikely(!hinic3_is_tso_sge_valid(mbuf, wqe_info)))
+				return -EINVAL;
+		}
+	}
 
-	/* Check whether can cover all tso mbuf segs or not. */
-	if (unlikely(!hinic3_is_tso_sge_valid(mbuf, wqe_info)))
+	/*
+	 * The WQE needs one WQEBB per SGE plus one for the task section, while
+	 * the ring never reports more than q_depth - 1 free WQEBBs. A packet
+	 * that needs the whole ring would never fit and would stall the queue.
+	 */
+	if (unlikely(wqe_info->sge_cnt >= q_depth - 1))
 		return -EINVAL;
 
 	return 0;
@@ -861,33 +868,70 @@ hinic3_alloc_cpy_mbuf(struct hinic3_nic_dev *nic_dev)
  * The address of the copied mbuf.
  */
 static void *
-hinic3_copy_tx_mbuf(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *mbuf,
-		    uint16_t sge_cnt)
+hinic3_copy_tx_mbuf_multi(struct hinic3_nic_dev *nic_dev,
+			  struct rte_mbuf *mbuf, struct hinic3_wqe_info *wqe_info)
 {
-	struct rte_mbuf *dst_mbuf;
-	uint32_t offset = 0;
-	uint16_t i;
+	uint8_t i;
+	uint32_t remaining_len, dst_mbuf_space, copy_size, copy_offset = 0;
+	uint32_t src_off;
+	struct rte_mbuf *prev_mbuf = NULL;
+	struct rte_mbuf *head_mbuf = NULL;
+	struct rte_mbuf *cur_mbuf;
 
 	if (unlikely(!nic_dev->cpy_mpool))
 		return NULL;
 
-	dst_mbuf = hinic3_alloc_cpy_mbuf(nic_dev);
-	if (unlikely(!dst_mbuf))
-		return NULL;
+	/* Allocate all copy mbufs and build linked list */
+	for (i = 0; i < wqe_info->cpy_mbuf_cnt; i++) {
+		cur_mbuf = hinic3_alloc_cpy_mbuf(nic_dev);
+		if (unlikely(!cur_mbuf))
+			goto err_free;
+
+		cur_mbuf->data_off = 0;
+		cur_mbuf->data_len = 0;
+		cur_mbuf->pkt_len = 0;
+		cur_mbuf->next = NULL;
+
+		if (prev_mbuf == NULL)
+			head_mbuf = cur_mbuf;
+		else
+			prev_mbuf->next = cur_mbuf;
+		prev_mbuf = cur_mbuf;
+		head_mbuf->nb_segs = i + 1;
+	}
 
-	dst_mbuf->data_off = 0;
-	dst_mbuf->data_len = 0;
-	for (i = 0; i < sge_cnt; i++) {
-		memcpy((uint8_t *)dst_mbuf->buf_addr + offset,
-			   (uint8_t *)mbuf->buf_addr + mbuf->data_off,
-			   mbuf->data_len);
-		dst_mbuf->data_len += mbuf->data_len;
-		offset += mbuf->data_len;
+	/* Copy data to mbufs - mbuf already points to first SGE to copy */
+	cur_mbuf = head_mbuf;
+	while (mbuf != NULL) {
+		remaining_len = mbuf->data_len;
+		while (remaining_len > 0 && cur_mbuf != NULL) {
+			dst_mbuf_space = HINIC3_COPY_MBUF_SIZE - copy_offset;
+			copy_size = RTE_MIN(remaining_len, dst_mbuf_space);
+			src_off = mbuf->data_len - remaining_len;
+
+			rte_memcpy((uint8_t *)cur_mbuf->buf_addr + copy_offset,
+				   rte_pktmbuf_mtod_offset(mbuf, uint8_t *, src_off),
+				   copy_size);
+
+			cur_mbuf->data_len += copy_size;
+			head_mbuf->pkt_len += copy_size;
+			copy_offset += copy_size;
+			remaining_len -= copy_size;
+
+			if (copy_offset >= HINIC3_COPY_MBUF_SIZE) {
+				copy_offset = 0;
+				cur_mbuf = cur_mbuf->next;
+			}
+		}
 		mbuf = mbuf->next;
 	}
-	dst_mbuf->pkt_len = dst_mbuf->data_len;
 
-	return dst_mbuf;
+	return head_mbuf;
+
+err_free:
+	/* Free all allocated mbufs on error */
+	hinic3_free_cpy_mbuf(nic_dev, head_mbuf);
+	return NULL;
 }
 
 /**
@@ -913,9 +957,9 @@ hinic3_mbuf_dma_map_sge(struct hinic3_txq *txq, struct rte_mbuf *mbuf,
 	struct hinic3_sq_wqe_desc *wqe_desc = wqe_combo->hdr;
 	struct hinic3_sq_bufdesc *buf_desc = wqe_combo->bds_head;
 	uint16_t nb_segs = wqe_info->sge_cnt - wqe_info->cpy_mbuf_cnt;
-	uint16_t real_segs = mbuf->nb_segs;
 	rte_iova_t dma_addr;
 	uint32_t i;
+	uint8_t mbuf_idx;
 
 	for (i = 0; i < nb_segs; i++) {
 		if (unlikely(mbuf == NULL)) {
@@ -954,40 +998,34 @@ hinic3_mbuf_dma_map_sge(struct hinic3_txq *txq, struct rte_mbuf *mbuf,
 		mbuf = mbuf->next;
 	}
 
-	/* For now: support over 38 sge, copy the last 2 mbuf. */
 	if (unlikely(wqe_info->cpy_mbuf_cnt != 0)) {
 		/*
 		 * Copy invalid mbuf segs to a valid buffer, lost performance.
 		 */
 		txq->txq_stats.cpy_pkts += 1;
-		mbuf = hinic3_copy_tx_mbuf(txq->nic_dev, mbuf,
-					   real_segs - nb_segs);
+		mbuf = hinic3_copy_tx_mbuf_multi(txq->nic_dev, mbuf, wqe_info);
 		if (unlikely(!mbuf))
 			return -EINVAL;
 
 		txq->tx_info[wqe_info->pi].cpy_mbuf = mbuf;
 
-		/* Deal with the last mbuf. */
-		dma_addr = rte_mbuf_data_iova(mbuf);
-		if (unlikely(mbuf->data_len == 0)) {
-			txq->txq_stats.sge_len0++;
-			return -EINVAL;
-		}
-		/*
-		 * Parts of wqe is in sq bottom while parts
-		 * of wqe is in sq head.
-		 */
-		if (i == 0) {
-			wqe_desc->hi_addr =
-				hinic3_hw_be32(upper_32_bits(dma_addr));
-			wqe_desc->lo_addr =
-				hinic3_hw_be32(lower_32_bits(dma_addr));
-			wqe_desc->ctrl_len = mbuf->data_len;
-		} else {
-			if (unlikely(((uint64_t)buf_desc == txq->sq_bot_sge_addr)))
+		/* Set DMA descriptors for all copy mbufs */
+		for (mbuf_idx = 0; mbuf_idx < wqe_info->cpy_mbuf_cnt; mbuf_idx++) {
+			dma_addr = rte_mbuf_data_iova(mbuf);
+			if (unlikely(mbuf->data_len == 0)) {
+				txq->txq_stats.sge_len0++;
+				hinic3_free_cpy_mbuf(txq->nic_dev,
+						     txq->tx_info[wqe_info->pi].cpy_mbuf);
+				txq->tx_info[wqe_info->pi].cpy_mbuf = NULL;
+				return -EINVAL;
+			}
+
+			if (unlikely((uint64_t)buf_desc == txq->sq_bot_sge_addr))
 				buf_desc = (struct hinic3_sq_bufdesc *)txq->sq_head_addr;
 
 			hinic3_set_buf_desc(buf_desc, dma_addr, mbuf->data_len);
+			buf_desc++;
+			mbuf = mbuf->next;
 		}
 	}
 
@@ -1088,7 +1126,9 @@ hinic3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	/* Tx loop routine. */
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
 		mbuf_pkt = *tx_pkts++;
-		if (unlikely(hinic3_get_tx_offload(txq->nic_dev, mbuf_pkt, &wqe_info))) {
+		if (unlikely(hinic3_get_tx_offload(txq->nic_dev, mbuf_pkt, &wqe_info,
+						   txq->non_tso_max_pkt_len,
+						   txq->q_depth))) {
 			txq->txq_stats.offload_errors++;
 			break;
 		}
diff --git a/drivers/net/hinic3/hinic3_tx.h b/drivers/net/hinic3/hinic3_tx.h
index 3b1580dd3a..e5aa0a6f8e 100644
--- a/drivers/net/hinic3/hinic3_tx.h
+++ b/drivers/net/hinic3/hinic3_tx.h
@@ -6,11 +6,17 @@
 #define _HINIC3_TX_H_
 
 #define MAX_SINGLE_SGE_SIZE		 65536
-#define HINIC3_NONTSO_PKT_MAX_SGE	 32 /**< non-tso max sge 32. */
+#define HINIC3_NONTSO_PKT_MAX_SGE	 38 /**< non-tso max sge 38. */
 #define HINIC3_NONTSO_SEG_NUM_VALID(num) ((num) <= HINIC3_NONTSO_PKT_MAX_SGE)
 
-#define HINIC3_TSO_PKT_MAX_SGE		127 /**< tso max sge 127. */
-#define HINIC3_TSO_SEG_NUM_INVALID(num) ((num) > HINIC3_TSO_PKT_MAX_SGE)
+#define HINIC3_TSO_PKT_MAX_SGE		255 /**< tso max sge 255. */
+
+/* Non-copy SGE configuration: 28 SGEs are not copied */
+#define HINIC3_NON_COPY_SGE_NUM	28
+#define HINIC3_NONTSO_MBUF_NUM_MAX \
+	(HINIC3_NONTSO_PKT_MAX_SGE - HINIC3_NON_COPY_SGE_NUM)
+#define HINIC3_TSO_MBUF_NUM_MAX \
+	(HINIC3_TSO_PKT_MAX_SGE - HINIC3_NON_COPY_SGE_NUM)
 
 /* Tx wqe queue info */
 struct hinic3_queue_info {
@@ -57,7 +63,6 @@ struct hinic3_wqe_info {
 	uint16_t pi;
 
 	uint16_t wqebb_cnt;
-	uint16_t rsvd2; /**< Reserved field 2. */
 
 	struct hinic3_queue_info queue_info;
 	struct hinic3_offload_info offload_info;
@@ -375,7 +380,7 @@ struct __rte_cache_aligned hinic3_txq {
 	uint64_t sq_bot_sge_addr;
 	uint32_t cos;
 	uint8_t tx_wqe_compact_task;
-	uint8_t rsvd[3];
+	uint32_t non_tso_max_pkt_len;
 	struct hinic3_txq_stats txq_stats;
 #ifdef HINIC3_XSTAT_PROF_TX
 	uint64_t prof_tx_end_tsc;
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 27/30] net/hinic3: split Tx burst function for compact task support
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (25 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 26/30] net/hinic3: expand TSO from 127 to 255 segments Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 28/30] net/hinic3: add SP230 VF software statistics Jiacheng Ye
                   ` (3 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Split the compact task Tx burst from the scalar path and select it by
NIC_F_TX_WQE_COMPACT_TASK, so the WQE task format follows the firmware
capability rather than the NIC model. SP230 and SP560 use compact task
WQEs; SP620 uses scalar task WQEs.

Splitting the path makes the old indirection redundant: remove
txq->tx_wqe_compact_task, struct hinic3_nic_tx_ops,
hinic3_nic_tx_rx_ops_init() and its per-device allocation, drop the
nic_dev argument from the Tx helpers, split hinic3_set_tx_offload() into
scalar and compact task variants, and fold
hinic3_tx_set_normal_task_offload() into the scalar burst.

The split also stops each burst at the first packet that cannot be
enqueued and uses the returned count for the stats, clears per-packet
offload state, guards the first prefetch, drops the per-packet log, and
clears queue_info for SQ_WQE_COMPACT_TYPE in the scalar burst. Tunnel
packets are accepted by type; the scalar path rejects VXLAN_GPE and IPIP
TSO, the latter with a DEBUG log. Only the scalar path no longer sets
TCPUDP_CS from the tunnel offload flags.

Document the Tx WQE task format selection in hinic3.rst.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/nics/hinic3.rst             |   4 +
 doc/guides/rel_notes/release_26_11.rst |   1 +
 drivers/net/hinic3/hinic3_ethdev.c     |  35 +-
 drivers/net/hinic3/hinic3_ethdev.h     |   1 -
 drivers/net/hinic3/hinic3_tx.c         | 527 +++++++++++++++++++++----
 drivers/net/hinic3/hinic3_tx.h         |  45 +--
 6 files changed, 470 insertions(+), 143 deletions(-)

diff --git a/doc/guides/nics/hinic3.rst b/doc/guides/nics/hinic3.rst
index ccc72c0df4..c74b86b538 100644
--- a/doc/guides/nics/hinic3.rst
+++ b/doc/guides/nics/hinic3.rst
@@ -7,6 +7,10 @@ HINIC3 Poll Mode Driver
 The hinic3 PMD (**librte_net_hinic3**) provides poll mode driver support
 for 25Gbps/100Gbps/200Gbps/400Gbps Huawei SP230, SP560 and SP620 series Network Adapters.
 
+The Tx WQE task format is chosen from the firmware capabilities rather
+than from the NIC model: the SP230 and the SP560 use the compact task
+WQE, while the SP620 uses the scalar task WQE.
+
 
 Features
 --------
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 62dc9bfda4..0513d09d9f 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -143,6 +143,7 @@ New Features
   * Added device parameters for runtime configuration.
   * Added a compact CQE receive data path.
   * Extended TCP segmentation offload (TSO) to 255 segments.
+  * Added a compact task transmit data path.
 
 * **Updated Intel iavf driver.**
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 8020b5c28d..65fd19ee0f 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -1464,7 +1464,6 @@ hinic3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qid, uint16_t nb_desc,
 			(HINIC3_COS_NUM_MAX - 1) & nic_dev->cos_mask];
 
 	txq->tx_deferred_start = tx_conf->tx_deferred_start;
-	txq->tx_wqe_compact_task = HINIC3_SUPPORT_TX_WQE_COMPACT_TASK(nic_dev);
 
 	ci_mz = hinic3_dma_zone_reserve(dev, "hinic3_sq_ci", qid,
 					HINIC3_CI_Q_ADDR_SIZE,
@@ -3945,14 +3944,6 @@ static const struct eth_dev_ops hinic3_pmd_vf_ops = {
 	.eth_dev_priv_dump             = hinic3_eth_dev_priv_dump,
 };
 
-static void hinic3_nic_tx_rx_ops_init(struct hinic3_nic_dev *nic_dev)
-{
-	if (HINIC3_SUPPORT_TX_WQE_COMPACT_TASK(nic_dev))
-		nic_dev->tx_ops->nic_tx_set_wqe_offload = hinic3_tx_set_compact_task_offload;
-	else
-		nic_dev->tx_ops->nic_tx_set_wqe_offload = hinic3_tx_set_normal_task_offload;
-}
-
 /**
  * Initialize the network function, including hardware configuration, memory
  * allocation for data structures, MAC address setup, and interrupt enabling.
@@ -4008,13 +3999,6 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 		goto alloc_eth_addr_fail;
 	}
 
-	nic_dev->tx_ops = rte_zmalloc("tx_ops", sizeof(struct hinic3_nic_tx_ops), 0);
-	if (!nic_dev->tx_ops) {
-		PMD_DRV_LOG(ERR, "Allocate tx_ops memory failed");
-		err = -ENOMEM;
-		goto alloc_tx_ops_fail;
-	}
-
 	nic_dev->mc_list = rte_zmalloc("hinic3_mc",
 		HINIC3_MAX_MC_MAC_ADDRS * sizeof(struct rte_ether_addr), 0);
 	if (!nic_dev->mc_list) {
@@ -4068,8 +4052,6 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 		goto get_cap_fail;
 	}
 
-	hinic3_nic_tx_rx_ops_init(nic_dev);
-
 	err = hinic3_init_sw_rxtxqs(nic_dev);
 	if (err) {
 		PMD_DRV_LOG(ERR, "Init sw rxqs or txqs failed, dev_name: %s",
@@ -4159,10 +4141,6 @@ hinic3_func_init(struct rte_eth_dev *eth_dev)
 	nic_dev->mc_list = NULL;
 
 alloc_mc_list_fail:
-	rte_free(nic_dev->tx_ops);
-	nic_dev->tx_ops = NULL;
-
-alloc_tx_ops_fail:
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;
 
@@ -4349,7 +4327,6 @@ hinic3_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	eth_dev->tx_pkt_prepare = hinic3_prep_pkts;
-	eth_dev->tx_pkt_burst = hinic3_xmit_pkts;
 
 	/*
 	 * The Rx burst follows the same per-port CQE mode that drives the
@@ -4360,6 +4337,18 @@ hinic3_dev_init(struct rte_eth_dev *eth_dev)
 	else
 		eth_dev->rx_pkt_burst = hinic3_recv_pkts;
 
+	/*
+	 * Select the burst from the firmware capability bit rather than the
+	 * NIC model: SP230/SP560 report NIC_F_TX_WQE_COMPACT_TASK and use the
+	 * compact-task burst, SP620 uses the scalar burst. The task-info bit
+	 * layout itself is model-specific (SQ_TASK_INFO0_* for SP620,
+	 * SQ_TASK_INFO_* for SP230/SP560).
+	 */
+	if (HINIC3_SUPPORT_TX_WQE_COMPACT_TASK(nic_dev))
+		eth_dev->tx_pkt_burst = hinic3_xmit_pkts_compact_task;
+	else
+		eth_dev->tx_pkt_burst = hinic3_xmit_pkts;
+
 	return 0;
 }
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.h b/drivers/net/hinic3/hinic3_ethdev.h
index dfa5bf8b8f..4600e37f0b 100644
--- a/drivers/net/hinic3/hinic3_ethdev.h
+++ b/drivers/net/hinic3/hinic3_ethdev.h
@@ -190,7 +190,6 @@ struct hinic3_nic_dev {
 	struct hinic3_fdir_rule_filter_list filter_fdir_rule_list;
 	uint8_t cos_map[HINIC3_COS_NUM_MAX];
 	struct hinic3_ptype_table *ptype_tbl;
-	struct hinic3_nic_tx_ops *tx_ops;
 	enum nic_type nic_type; /**< NIC type. */
 
 };
diff --git a/drivers/net/hinic3/hinic3_tx.c b/drivers/net/hinic3/hinic3_tx.c
index f9ae9df431..3f44814405 100644
--- a/drivers/net/hinic3/hinic3_tx.c
+++ b/drivers/net/hinic3/hinic3_tx.c
@@ -77,6 +77,30 @@ hinic3_get_and_update_sq_owner(struct hinic3_txq *sq, uint16_t curr_pi, uint16_t
 	return owner;
 }
 
+static void *
+hinic3_get_sq_wqe(struct hinic3_txq *sq,
+		  struct hinic3_wqe_info *wqe_info)
+{
+	uint16_t cur_pi = MASKED_QUEUE_IDX(sq, sq->prod_idx);
+	uint32_t end_pi;
+
+	end_pi = cur_pi + wqe_info->wqebb_cnt;
+	sq->prod_idx += wqe_info->wqebb_cnt;
+
+	wqe_info->owner = (uint8_t)(sq->owner);
+	wqe_info->pi = cur_pi;
+	wqe_info->wrapped = 0;
+
+	if (unlikely(end_pi >= sq->q_depth)) {
+		sq->owner = !sq->owner;
+
+		if (likely(end_pi > sq->q_depth))
+			wqe_info->wrapped = (uint8_t)(sq->q_depth - cur_pi);
+	}
+
+	return NIC_WQE_ADDR(sq, cur_pi);
+}
+
 static inline void
 hinic3_put_sq_wqe(struct hinic3_txq *sq, struct hinic3_wqe_info *wqe_info)
 {
@@ -97,9 +121,9 @@ hinic3_put_sq_wqe(struct hinic3_txq *sq, struct hinic3_wqe_info *wqe_info)
  * Point to wqe_info of send queue(SQ).
  */
 static void
-hinic3_set_wqe_combo(struct hinic3_txq *sq,
-		     struct hinic3_sq_wqe_combo *wqe_combo,
-		     struct hinic3_wqe_info *wqe_info)
+hinic3_set_wqe_combo_compact_task(struct hinic3_txq *sq,
+				 struct hinic3_sq_wqe_combo *wqe_combo,
+				 struct hinic3_wqe_info *wqe_info)
 {
 	uint16_t tmp_pi;
 
@@ -124,6 +148,62 @@ hinic3_set_wqe_combo(struct hinic3_txq *sq,
 	wqe_info->owner = hinic3_get_and_update_sq_owner(sq, wqe_info->pi, wqe_info->wqebb_cnt);
 }
 
+/**
+ * Sets the WQE combination information in the transmit queue (SQ).
+ *
+ * @param[in] sq
+ * Point to send queue.
+ * @param[out] wqe_combo
+ * Point to wqe_combo of send queue(SQ).
+ * @param[in] wqe_info
+ * Point to wqe_info of send queue(SQ).
+ */
+static void
+hinic3_set_wqe_combo(struct hinic3_txq *sq,
+		     struct hinic3_sq_wqe_combo *wqe_combo,
+		     struct hinic3_sq_wqe *wqe,
+		     struct hinic3_wqe_info *wqe_info)
+{
+	wqe_combo->hdr = &wqe->compact_wqe.wqe_desc;
+
+	if (wqe_info->offload) {
+		if (wqe_info->wrapped == HINIC3_TX_TASK_WRAPPED) {
+			wqe_combo->task = (struct hinic3_sq_task *)
+				(void *)sq->sq_head_addr;
+			wqe_combo->bds_head = (struct hinic3_sq_bufdesc *)
+				(void *)(sq->sq_head_addr + sq->wqebb_size);
+		} else if (wqe_info->wrapped == HINIC3_TX_BD_DESC_WRAPPED) {
+			wqe_combo->task = &wqe->extend_wqe.task;
+			wqe_combo->bds_head = (struct hinic3_sq_bufdesc *)
+				(void *)(sq->sq_head_addr);
+		} else {
+			wqe_combo->task = &wqe->extend_wqe.task;
+			wqe_combo->bds_head = wqe->extend_wqe.buf_desc;
+		}
+
+		wqe_combo->wqe_type = SQ_WQE_EXTENDED_TYPE;
+		wqe_combo->task_type = SQ_WQE_TASKSECT_16BYTES;
+		return;
+	}
+
+	if (wqe_info->wrapped == HINIC3_TX_TASK_WRAPPED) {
+		wqe_combo->bds_head = (struct hinic3_sq_bufdesc *)
+				(void *)(sq->sq_head_addr);
+	} else {
+		wqe_combo->bds_head =
+			(struct hinic3_sq_bufdesc *)(&wqe->extend_wqe.task);
+	}
+
+	if (wqe_info->wqebb_cnt > 1) {
+		wqe_combo->wqe_type = SQ_WQE_EXTENDED_TYPE;
+		wqe_combo->task_type = SQ_WQE_TASKSECT_4BYTES;
+		/* This section used as vlan insert, needs to clear */
+		wqe_combo->bds_head->rsvd = 0;
+	} else {
+		wqe_combo->wqe_type = SQ_WQE_COMPACT_TYPE;
+	}
+}
+
 int
 hinic3_start_all_sqs(struct rte_eth_dev *eth_dev)
 {
@@ -411,21 +491,17 @@ static inline void hinic3_calculate_phdr_checksum(struct rte_mbuf *mbuf,
 }
 
 static int
-hinic3_get_inner_l3_offset(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *mbuf,
-			   uint16_t *inner_l3_offset)
+hinic3_get_inner_l3_offset(struct rte_mbuf *mbuf, uint16_t *inner_l3_offset)
 {
 	uint64_t ol_flags = mbuf->ol_flags;
 	uint64_t tunnel_type = ol_flags & HINIC3_PKT_TX_TUNNEL_MASK;
 
-	if (tunnel_type) {
-		if (!((tunnel_type == HINIC3_PKT_TX_TUNNEL_VXLAN &&
-		       HINIC3_SUPPORT_VXLAN_OFFLOAD(nic_dev)) ||
-		      (tunnel_type == HINIC3_PKT_TX_TUNNEL_GENEVE &&
-		       HINIC3_SUPPORT_GENEVE_OFFLOAD(nic_dev)) ||
-		      (tunnel_type == HINIC3_PKT_TX_TUNNEL_IPIP &&
-		       HINIC3_SUPPORT_IPXIP_OFFLOAD(nic_dev))))
-			return -EINVAL;
-	}
+	if (tunnel_type &&
+	    tunnel_type != HINIC3_PKT_TX_TUNNEL_VXLAN &&
+	    tunnel_type != HINIC3_PKT_TX_TUNNEL_GENEVE &&
+	    tunnel_type != HINIC3_PKT_TX_TUNNEL_VXLAN_GPE &&
+	    tunnel_type != HINIC3_PKT_TX_TUNNEL_IPIP)
+		return -EINVAL;
 
 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
 	if (rte_validate_tx_offload(mbuf) != 0)
@@ -472,7 +548,6 @@ hinic3_get_inner_l3_offset(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *mbuf
 	return 0;
 }
 
-
 uint16_t
 hinic3_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
@@ -489,7 +564,7 @@ hinic3_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		if (!(mbuf->ol_flags & HINIC3_TX_OFFLOAD_MASK))
 			continue;
 
-		ret = hinic3_get_inner_l3_offset(nic_dev, mbuf, &inner_l3_offset);
+		ret = hinic3_get_inner_l3_offset(mbuf, &inner_l3_offset);
 		if (unlikely(ret)) {
 			rte_errno = -ret;
 			return i;
@@ -531,33 +606,15 @@ hinic3_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	return i;
 }
 
-void
-hinic3_tx_set_normal_task_offload(struct hinic3_wqe_info *wqe_info,
-				  struct hinic3_sq_wqe_combo *wqe_combo)
+static inline void hinic3_set_vlan_tx_offload(struct hinic3_sq_task *task,
+					      uint16_t vlan_tag, uint8_t vlan_type)
 {
-	struct hinic3_sq_task *task = wqe_combo->task;
-	struct hinic3_offload_info *offload_info = &wqe_info->offload_info;
-
-	task->pkt_info0 = 0;
-	task->pkt_info0 |= SQ_TASK_INFO0_SET(offload_info->inner_l4_en, INNER_L4_EN);
-	task->pkt_info0 |= SQ_TASK_INFO0_SET(offload_info->inner_l3_en, INNER_L3_EN);
-	task->pkt_info0 |= SQ_TASK_INFO0_SET(offload_info->encapsulation, TUNNEL_FLAG);
-	task->pkt_info0 |= SQ_TASK_INFO0_SET(offload_info->out_l3_en, OUT_L3_EN);
-	task->pkt_info0 |= SQ_TASK_INFO0_SET(offload_info->out_l4_en, OUT_L4_EN);
-	task->pkt_info0 = hinic3_hw_be32(task->pkt_info0);
-
-	if (wqe_combo->task_type == SQ_WQE_TASKSECT_16BYTES) {
-		task->ip_identify = 0;
-		task->pkt_info2 = 0;
-		task->vlan_offload = 0;
-		task->vlan_offload = SQ_TASK_INFO3_SET(offload_info->vlan_tag, VLAN_TAG) |
-				     SQ_TASK_INFO3_SET(offload_info->vlan_sel, VLAN_TYPE) |
-				     SQ_TASK_INFO3_SET(offload_info->vlan_valid, VLAN_TAG_VALID);
-		task->vlan_offload = hinic3_hw_be32(task->vlan_offload);
-	}
+	task->vlan_offload = SQ_TASK_INFO3_SET(vlan_tag, VLAN_TAG) |
+			     SQ_TASK_INFO3_SET(vlan_type, VLAN_TYPE) |
+			     SQ_TASK_INFO3_SET(1U, VLAN_TAG_VALID);
 }
 
-void
+static void
 hinic3_tx_set_compact_task_offload(struct hinic3_wqe_info *wqe_info,
 				   struct hinic3_sq_wqe_combo *wqe_combo)
 {
@@ -578,10 +635,9 @@ hinic3_tx_set_compact_task_offload(struct hinic3_wqe_info *wqe_info,
 }
 
 static int
-hinic3_set_tx_offload(struct hinic3_nic_dev *nic_dev,
-		      struct rte_mbuf *mbuf,
-		      struct hinic3_sq_wqe_combo *wqe_combo,
-		      struct hinic3_wqe_info *wqe_info)
+hinic3_set_tx_offload_compact_task(struct rte_mbuf *mbuf,
+				  struct hinic3_sq_wqe_combo *wqe_combo,
+				  struct hinic3_wqe_info *wqe_info)
 {
 	uint64_t ol_flags = mbuf->ol_flags;
 	struct hinic3_offload_info *offload_info = &wqe_info->offload_info;
@@ -618,7 +674,7 @@ hinic3_set_tx_offload(struct hinic3_nic_dev *nic_dev,
 		case HINIC3_PKT_TX_L4_NO_CKSUM:
 			break;
 		default:
-			PMD_DRV_LOG(INFO, "not support pkt type");
+			PMD_DRV_LOG(DEBUG, "not support pkt type");
 			return -EINVAL;
 		}
 	}
@@ -630,11 +686,14 @@ hinic3_set_tx_offload(struct hinic3_nic_dev *nic_dev,
 		offload_info->encapsulation = 1;
 		wqe_info->queue_info.udp_dp_en = 1;
 		break;
+	case HINIC3_PKT_TX_TUNNEL_IPIP:
+		offload_info->encapsulation = 1;
+		break;
 	case 0:
 		break;
 
 	default:
-		PMD_DRV_LOG(INFO, "not support tunnel pkt type");
+		PMD_DRV_LOG(DEBUG, "not support tunnel pkt type");
 		return -EINVAL;
 	}
 
@@ -645,11 +704,111 @@ hinic3_set_tx_offload(struct hinic3_nic_dev *nic_dev,
 		offload_info->out_l4_en = 1;
 
 set_tx_wqe_offload:
-	nic_dev->tx_ops->nic_tx_set_wqe_offload(wqe_info, wqe_combo);
+	hinic3_tx_set_compact_task_offload(wqe_info, wqe_combo);
 
 	return 0;
 }
 
+static int
+hinic3_set_tx_offload(struct rte_mbuf *mbuf,
+		      struct hinic3_sq_task *task,
+		      struct hinic3_wqe_info *wqe_info)
+{
+	uint64_t ol_flags = mbuf->ol_flags;
+	uint16_t pld_offset = 0;
+	uint32_t queue_info = 0;
+	uint16_t vlan_tag;
+
+	task->pkt_info0 = 0;
+	task->ip_identify = 0;
+	task->pkt_info2 = 0;
+	task->vlan_offload = 0;
+
+	/* Vlan offload */
+	if (unlikely(ol_flags & HINIC3_PKT_TX_VLAN_PKT)) {
+		vlan_tag = mbuf->vlan_tci;
+		hinic3_set_vlan_tx_offload(task, vlan_tag, HINIC3_TX_TPID0);
+		task->vlan_offload = hinic3_hw_be32(task->vlan_offload);
+	}
+
+	if (!(ol_flags & HINIC3_TX_CKSUM_OFFLOAD_MASK))
+		return 0;
+
+	/* Tso offload */
+	if (ol_flags & HINIC3_PKT_TX_TCP_SEG) {
+		if ((ol_flags & HINIC3_PKT_TX_TUNNEL_MASK) ==
+		    HINIC3_PKT_TX_TUNNEL_VXLAN_GPE)
+			return -EINVAL;
+		if ((ol_flags & HINIC3_PKT_TX_TUNNEL_MASK) ==
+		    HINIC3_PKT_TX_TUNNEL_IPIP) {
+			PMD_DRV_LOG(DEBUG, "IPinIP TSO is not supported on SP620");
+			return -EINVAL;
+		}
+		pld_offset = wqe_info->payload_offset;
+		if ((pld_offset >> 1) > MAX_PAYLOAD_OFFSET)
+			return -EINVAL;
+
+		task->pkt_info0 |= SQ_TASK_INFO0_SET(1U, INNER_L4_EN);
+		task->pkt_info0 |= SQ_TASK_INFO0_SET(1U, INNER_L3_EN);
+
+		queue_info |= SQ_CTRL_QUEUE_INFO_SET(1U, TSO);
+		queue_info |= SQ_CTRL_QUEUE_INFO_SET(pld_offset >> 1, PLDOFF);
+
+		/* Set MSS value */
+		queue_info = SQ_CTRL_QUEUE_INFO_CLEAR(queue_info, MSS);
+		queue_info |= SQ_CTRL_QUEUE_INFO_SET(mbuf->tso_segsz, MSS);
+	} else {
+		if (ol_flags & HINIC3_PKT_TX_IP_CKSUM)
+			task->pkt_info0 |= SQ_TASK_INFO0_SET(1U, INNER_L3_EN);
+
+		switch (ol_flags & HINIC3_PKT_TX_L4_MASK) {
+		case HINIC3_PKT_TX_TCP_CKSUM:
+		case HINIC3_PKT_TX_UDP_CKSUM:
+		case HINIC3_PKT_TX_SCTP_CKSUM:
+			task->pkt_info0 |= SQ_TASK_INFO0_SET(1U, INNER_L4_EN);
+			break;
+		case HINIC3_PKT_TX_L4_NO_CKSUM:
+			break;
+		default:
+			PMD_DRV_LOG(DEBUG, "not support pkt type");
+			return -EINVAL;
+		}
+	}
+
+	/* For vxlan, also can support PKT_TX_TUNNEL_GENEVE/GRE, etc */
+	switch (ol_flags & HINIC3_PKT_TX_TUNNEL_MASK) {
+	case HINIC3_PKT_TX_TUNNEL_VXLAN:
+		task->pkt_info0 |= SQ_TASK_INFO0_SET(1U, TUNNEL_FLAG);
+		break;
+	case HINIC3_PKT_TX_TUNNEL_VXLAN_GPE:
+		task->pkt_info0 |= SQ_TASK_INFO0_SET(1U, TUNNEL_FLAG);
+		break;
+	case HINIC3_PKT_TX_TUNNEL_GENEVE:
+		task->pkt_info0 |= SQ_TASK_INFO0_SET(1U, TUNNEL_FLAG);
+		break;
+	case HINIC3_PKT_TX_TUNNEL_IPIP:
+		task->pkt_info0 |= SQ_TASK_INFO0_SET(1U, TUNNEL_FLAG);
+		break;
+	case 0:
+		break;
+	default:
+		/* For non UDP/GRE tunneling, drop the tunnel packet */
+		PMD_DRV_LOG(DEBUG, "not support tunnel pkt type");
+		return -EINVAL;
+	}
+
+	if (ol_flags & HINIC3_PKT_TX_OUTER_IP_CKSUM)
+		task->pkt_info0 |= SQ_TASK_INFO0_SET(1U, OUT_L3_EN);
+
+	if (ol_flags & HINIC3_PKT_TX_OUTER_UDP_CKSUM)
+		task->pkt_info0 |= SQ_TASK_INFO0_SET(1U, OUT_L4_EN);
+
+	task->pkt_info0 = hinic3_hw_be32(task->pkt_info0);
+	task->pkt_info2 = hinic3_hw_be32(task->pkt_info2);
+	wqe_info->queue_info_sp620 = queue_info;
+	return 0;
+}
+
 /**
  * Check whether the number of segments in the mbuf is valid.
  *
@@ -779,15 +938,16 @@ hinic3_non_tso_pkt_pre_process(struct rte_mbuf *mbuf, struct hinic3_wqe_info *wq
  * Point to the mbuf to send.
  * @param[in] wqe_info
  * Point to wqe_info of send queue(SQ).
+ * @param[in] non_tso_max_pkt_len
+ *  Number of non_tso_max_pkt_len(SP230 is 9600, SP620/SP560 is 64K)
  * @param[in] q_depth
  *  Depth of the send queue, used to reject a WQE that can never fit.
  * @return
  * 0 as success, -EINVAL as failure.
  */
 static int
-hinic3_get_tx_offload(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *mbuf,
-		      struct hinic3_wqe_info *wqe_info, uint32_t non_tso_max_pkt_len,
-		      uint16_t q_depth)
+hinic3_get_tx_offload(struct rte_mbuf *mbuf, struct hinic3_wqe_info *wqe_info,
+		      uint32_t non_tso_max_pkt_len, uint16_t q_depth)
 {
 	uint64_t ol_flags = mbuf->ol_flags;
 	uint16_t inner_l3_offset = 0;
@@ -795,6 +955,13 @@ hinic3_get_tx_offload(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *mbuf,
 
 	wqe_info->sge_cnt = mbuf->nb_segs;
 	wqe_info->cpy_mbuf_cnt = 0;
+	/*
+	 * These are filled in only for the offloads the packet carries.
+	 * Clear them so a previous packet's VLAN/TSO state cannot leak
+	 * into this one.
+	 */
+	wqe_info->queue_info = (struct hinic3_queue_info){ 0 };
+	wqe_info->offload_info = (struct hinic3_offload_info){ 0 };
 	/* Check if the packet set available offload flags. */
 	if (!(ol_flags & HINIC3_TX_OFFLOAD_MASK)) {
 		wqe_info->offload = 0;
@@ -804,7 +971,7 @@ hinic3_get_tx_offload(struct hinic3_nic_dev *nic_dev, struct rte_mbuf *mbuf,
 			return err;
 	} else {
 		wqe_info->offload = 1;
-		err = hinic3_get_inner_l3_offset(nic_dev, mbuf, &inner_l3_offset);
+		err = hinic3_get_inner_l3_offset(mbuf, &inner_l3_offset);
 		if (err)
 			return err;
 
@@ -995,6 +1162,7 @@ hinic3_mbuf_dma_map_sge(struct hinic3_txq *txq, struct rte_mbuf *mbuf,
 			hinic3_set_buf_desc(buf_desc, dma_addr, mbuf->data_len);
 			buf_desc++;
 		}
+
 		mbuf = mbuf->next;
 	}
 
@@ -1042,8 +1210,8 @@ hinic3_mbuf_dma_map_sge(struct hinic3_txq *txq, struct rte_mbuf *mbuf,
  * Point to wqe_info of send queue.
  */
 static void
-hinic3_prepare_sq_ctrl(struct hinic3_sq_wqe_combo *wqe_combo,
-		       struct hinic3_wqe_info *wqe_info)
+hinic3_prepare_sq_ctrl_compact_task(struct hinic3_sq_wqe_combo *wqe_combo,
+				   struct hinic3_wqe_info *wqe_info)
 {
 	struct hinic3_queue_info *queue_info = &wqe_info->queue_info;
 	struct hinic3_sq_wqe_desc *wqe_desc = wqe_combo->hdr;
@@ -1056,7 +1224,7 @@ hinic3_prepare_sq_ctrl(struct hinic3_sq_wqe_combo *wqe_combo,
 	if (wqe_combo->wqe_type == SQ_WQE_EXTENDED_TYPE) {
 		wqe_desc->ctrl_len |= SQ_CTRL_SET(wqe_info->sge_cnt, BUFDESC_NUM) |
 				      SQ_CTRL_SET(wqe_combo->task_type, TASKSECT_LEN) |
-				      SQ_CTRL_SET(SQ_NORMAL_WQE, DATA_FORMAT);
+				      SQ_CTRL_SET(SQ_WQE_SGL, DATA_FORMAT);
 
 		*qsf = SQ_CTRL_QUEUE_INFO_SET(1, UC) |
 		       SQ_CTRL_QUEUE_INFO_SET(queue_info->sctp, SCTP) |
@@ -1077,14 +1245,56 @@ hinic3_prepare_sq_ctrl(struct hinic3_sq_wqe_combo *wqe_combo,
 		*qsf = hinic3_hw_be32(*qsf);
 	} else {
 		wqe_desc->ctrl_len |= SQ_CTRL_COMPACT_QUEUE_INFO_SET(queue_info->sctp, SCTP) |
-				SQ_CTRL_COMPACT_QUEUE_INFO_SET(queue_info->udp_dp_en, UDP_DP_EN) |
-				SQ_CTRL_COMPACT_QUEUE_INFO_SET(queue_info->ufo, UFO) |
-				SQ_CTRL_COMPACT_QUEUE_INFO_SET(queue_info->pkt_type, PKT_TYPE);
+				      SQ_CTRL_COMPACT_QUEUE_INFO_SET(queue_info->udp_dp_en,
+								     UDP_DP_EN) |
+				      SQ_CTRL_COMPACT_QUEUE_INFO_SET(queue_info->ufo, UFO) |
+				      SQ_CTRL_COMPACT_QUEUE_INFO_SET(queue_info->pkt_type,
+								     PKT_TYPE);
 	}
 
 	wqe_desc->ctrl_len = hinic3_hw_be32(wqe_desc->ctrl_len);
 }
 
+/**
+ * Sets and configures fields in the transmit queue control descriptor based on
+ * the WQE type.
+ *
+ * @param[out] wqe_combo
+ * Point to wqe_combo of send queue.
+ * @param[in] wqe_info
+ * Point to wqe_info of send queue.
+ */
+static void
+hinic3_prepare_sq_ctrl(struct hinic3_sq_wqe_combo *wqe_combo,
+		       struct hinic3_wqe_info *wqe_info)
+{
+	struct hinic3_sq_wqe_desc *wqe_desc = wqe_combo->hdr;
+
+	wqe_desc->ctrl_len |= SQ_CTRL_SET(wqe_info->sge_cnt, BUFDESC_NUM) |
+			      SQ_CTRL_SET(wqe_combo->task_type, TASKSECT_LEN) |
+			      SQ_CTRL_SET(SQ_NORMAL_WQE, DATA_FORMAT) |
+			      SQ_CTRL_SET(wqe_combo->wqe_type, EXTENDED) |
+			      SQ_CTRL_SET(wqe_info->owner, OWNER);
+
+	wqe_desc->ctrl_len = hinic3_hw_be32(wqe_desc->ctrl_len);
+
+	wqe_desc->queue_info = wqe_info->queue_info_sp620;
+	wqe_desc->queue_info |= SQ_CTRL_QUEUE_INFO_SET(1U, UC);
+
+	if (!SQ_CTRL_QUEUE_INFO_GET(wqe_desc->queue_info, MSS)) {
+		wqe_desc->queue_info |=
+			SQ_CTRL_QUEUE_INFO_SET(TX_MSS_DEFAULT, MSS);
+	} else if (SQ_CTRL_QUEUE_INFO_GET(wqe_desc->queue_info, MSS) <
+		   TX_MSS_MIN) {
+		/* Mss should not less than 80 */
+		wqe_desc->queue_info =
+			SQ_CTRL_QUEUE_INFO_CLEAR(wqe_desc->queue_info, MSS);
+		wqe_desc->queue_info |= SQ_CTRL_QUEUE_INFO_SET(TX_MSS_MIN, MSS);
+	}
+
+	wqe_desc->queue_info = hinic3_hw_be32(wqe_desc->queue_info);
+}
+
 /**
  * It is responsible for sending data packets.
  *
@@ -1104,6 +1314,7 @@ hinic3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	struct hinic3_tx_info *tx_info = NULL;
 	struct rte_mbuf *mbuf_pkt = NULL;
 	struct hinic3_sq_wqe_combo wqe_combo = {0};
+	struct hinic3_sq_wqe *sq_wqe = NULL;
 	struct hinic3_wqe_info wqe_info = {0};
 	uint32_t offload_err, free_cnt;
 	uint64_t tx_bytes = 0;
@@ -1118,6 +1329,8 @@ hinic3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	if (unlikely(!HINIC3_TXQ_IS_STARTED(txq)))
 		return 0;
 
+	if (nb_pkts)
+		rte_prefetch0(tx_pkts[0]);
 	free_cnt = txq->tx_free_thresh;
 	/* Reclaim tx mbuf before xmit new packets. */
 	if (hinic3_get_sq_free_wqebbs(txq) < txq->tx_free_thresh)
@@ -1125,54 +1338,69 @@ hinic3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 	/* Tx loop routine. */
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
-		mbuf_pkt = *tx_pkts++;
-		if (unlikely(hinic3_get_tx_offload(txq->nic_dev, mbuf_pkt, &wqe_info,
+		mbuf_pkt = tx_pkts[nb_tx];
+		if (nb_tx + 1 < nb_pkts)
+			rte_prefetch0(tx_pkts[nb_tx + 1]);
+		if (unlikely(hinic3_get_tx_offload(mbuf_pkt, &wqe_info,
 						   txq->non_tso_max_pkt_len,
 						   txq->q_depth))) {
 			txq->txq_stats.offload_errors++;
 			break;
 		}
 
-		wqe_info.wqebb_cnt = wqe_info.sge_cnt;
-		if (likely(wqe_info.offload || wqe_info.wqebb_cnt > 1)) {
-			if (txq->tx_wqe_compact_task) {
-				/**
-				 * One more wqebb is needed for compact task under two situations:
-				 * 1. TSO: MSS field is needed, no available space for
-				 *    compact task in compact wqe.
-				 * 2. SGE number > 1: wqe is handlerd as extended wqe by nic.
-				 */
-				if (mbuf_pkt->ol_flags & HINIC3_PKT_TX_TCP_SEG ||
-				    wqe_info.wqebb_cnt > 1)
-					wqe_info.wqebb_cnt++;
-			} else {
-				/* Use extended sq wqe with normal TS */
-				wqe_info.wqebb_cnt++;
-			}
-		}
+		if (!wqe_info.offload)
+			/*
+			 * Use extended sq wqe with small TS, which can include
+			 * multi sges, or compact sq normal wqe, which just
+			 * supports one sge
+			 */
+			wqe_info.wqebb_cnt = wqe_info.sge_cnt;
+		else
+			/* Use extended sq wqe with normal TS */
+			wqe_info.wqebb_cnt = wqe_info.sge_cnt + 1;
 
 		free_wqebb_cnt = hinic3_get_sq_free_wqebbs(txq);
-		if (unlikely(wqe_info.wqebb_cnt > free_wqebb_cnt)) {
-			/* Reclaim again. */
+		if (wqe_info.wqebb_cnt > free_wqebb_cnt) {
+			/*
+			 * Try to reclaim completed Tx WQEs when SQ space is
+			 * insufficient. This gives hardware a chance to free
+			 * descriptors and helps prevent packet drops caused
+			 * by transient SQ congestion.
+			 */
 			hinic3_xmit_mbuf_cleanup(txq, free_cnt);
 			free_wqebb_cnt = hinic3_get_sq_free_wqebbs(txq);
-			if (unlikely(wqe_info.wqebb_cnt > free_wqebb_cnt)) {
+			if (wqe_info.wqebb_cnt > free_wqebb_cnt) {
 				txq->txq_stats.tx_busy += (nb_pkts - nb_tx);
-				break;
+				goto end;
 			}
 		}
 
-		/* Task or bd section maybe wrapped for one wqe. */
-		hinic3_set_wqe_combo(txq, &wqe_combo, &wqe_info);
+		/* Get sq wqe address from wqe_page */
+		sq_wqe = hinic3_get_sq_wqe(txq, &wqe_info);
 
-		/* Fill tx packet offload into qsf and task field. */
-		offload_err = hinic3_set_tx_offload(txq->nic_dev, mbuf_pkt, &wqe_combo, &wqe_info);
+		/* Task or bd section maybe wrapped for one wqe */
+		hinic3_set_wqe_combo(txq, &wqe_combo, sq_wqe, &wqe_info);
+
+		/*
+		 * A compact WQE has no SQ control section and the scalar
+		 * burst does not fill its 4-byte task, so clear queue_info
+		 * once per packet.
+		 */
+		if (wqe_combo.wqe_type == SQ_WQE_COMPACT_TYPE)
+			wqe_combo.hdr->queue_info = 0;
+
+		wqe_info.queue_info_sp620 = 0;
+		/* Fill tx packet offload into qsf and task field */
+		if (wqe_info.offload) {
+			offload_err = hinic3_set_tx_offload(mbuf_pkt,
+							    wqe_combo.task,
+							    &wqe_info);
 			if (unlikely(offload_err)) {
 				hinic3_put_sq_wqe(txq, &wqe_info);
 				txq->txq_stats.offload_errors++;
 				break;
 			}
-
+		}
 		/* Fill sq_wqe buf_desc and bd_desc. */
 		err = hinic3_mbuf_dma_map_sge(txq, mbuf_pkt, &wqe_combo,
 					      &wqe_info);
@@ -1196,7 +1424,7 @@ hinic3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		tx_bytes += mbuf_pkt->pkt_len;
 	}
-
+end:
 	/* Update txq stats. */
 	if (nb_tx) {
 		hinic3_write_db(txq->db_addr, txq->q_id, (int)(txq->cos),
@@ -1271,3 +1499,130 @@ hinic3_flush_txqs(struct hinic3_nic_dev *nic_dev)
 			PMD_DRV_LOG(ERR, "Stop sq%d failed", qid);
 	}
 }
+
+/**
+ * It is responsible for sending data packets.
+ *
+ * @param[in] tx_queue
+ * Point to send queue.
+ * @param[in] tx_pkts
+ * Pointer to the array of data packets to be sent.
+ * @param[in] nb_pkts
+ * Number of sent packets.
+ * @return
+ * Number of actually sent packets.
+ */
+uint16_t
+hinic3_xmit_pkts_compact_task(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+{
+	struct hinic3_txq *txq = tx_queue;
+	struct hinic3_tx_info *tx_info = NULL;
+	struct rte_mbuf *mbuf_pkt = NULL;
+	struct hinic3_sq_wqe_combo wqe_combo = { 0 };
+	struct hinic3_wqe_info wqe_info = { 0 };
+	uint32_t offload_err, free_cnt;
+	uint64_t tx_bytes = 0;
+	uint16_t free_wqebb_cnt, nb_tx;
+	int err;
+
+#ifdef HINIC3_XSTAT_PROF_TX
+	uint64_t t1, t2;
+	t1 = rte_get_tsc_cycles();
+#endif
+
+	if (unlikely(!HINIC3_TXQ_IS_STARTED(txq)))
+		return 0;
+
+	free_cnt = txq->tx_free_thresh;
+	/* Reclaim tx mbuf before xmit new packets. */
+	if (hinic3_get_sq_free_wqebbs(txq) < txq->tx_free_thresh)
+		hinic3_xmit_mbuf_cleanup(txq, free_cnt);
+
+	/* Tx loop routine. */
+	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
+		mbuf_pkt = *tx_pkts++;
+		if (unlikely(hinic3_get_tx_offload(mbuf_pkt, &wqe_info,
+						   txq->non_tso_max_pkt_len,
+						   txq->q_depth))) {
+			txq->txq_stats.offload_errors++;
+			break;
+		}
+
+		wqe_info.wqebb_cnt = wqe_info.sge_cnt;
+		if (likely(wqe_info.offload || wqe_info.wqebb_cnt > 1)) {
+			/**
+			 * One more wqebb is needed for compact task under two situations:
+			 * 1. TSO: MSS field is needed, no available space for
+			 *    compact task in compact wqe.
+			 * 2. SGE number > 1: wqe is handled as extended wqe by nic.
+			 */
+			if (mbuf_pkt->ol_flags & HINIC3_PKT_TX_TCP_SEG ||
+			    wqe_info.wqebb_cnt > 1)
+				wqe_info.wqebb_cnt++;
+		}
+
+		free_wqebb_cnt = hinic3_get_sq_free_wqebbs(txq);
+		if (wqe_info.wqebb_cnt > free_wqebb_cnt) {
+			/* Reclaim again */
+			hinic3_xmit_mbuf_cleanup(txq, free_cnt);
+			free_wqebb_cnt = hinic3_get_sq_free_wqebbs(txq);
+			if (wqe_info.wqebb_cnt > free_wqebb_cnt) {
+				txq->txq_stats.tx_busy += (nb_pkts - nb_tx);
+				goto end;
+			}
+		}
+
+		/* Task or bd section maybe wrapped for one wqe. */
+		hinic3_set_wqe_combo_compact_task(txq, &wqe_combo, &wqe_info);
+
+		/* Fill tx packet offload into qsf and task field. */
+		offload_err = hinic3_set_tx_offload_compact_task(mbuf_pkt, &wqe_combo, &wqe_info);
+		if (unlikely(offload_err)) {
+			hinic3_put_sq_wqe(txq, &wqe_info);
+			txq->txq_stats.offload_errors++;
+			break;
+		}
+
+		/* Fill sq_wqe buf_desc and bd_desc. */
+		err = hinic3_mbuf_dma_map_sge(txq, mbuf_pkt, &wqe_combo, &wqe_info);
+
+		if (err) {
+			hinic3_put_sq_wqe(txq, &wqe_info);
+			txq->txq_stats.offload_errors++;
+			break;
+		}
+
+		/* Record tx info. */
+		tx_info = &txq->tx_info[wqe_info.pi];
+		tx_info->mbuf = mbuf_pkt;
+		tx_info->wqebb_cnt = wqe_info.wqebb_cnt;
+
+		/*
+		 * For wqe compact type, no need to prepare
+		 * sq ctrl info.
+		 */
+		hinic3_prepare_sq_ctrl_compact_task(&wqe_combo, &wqe_info);
+
+		tx_bytes += mbuf_pkt->pkt_len;
+	}
+end:
+	/* Update txq stats. */
+	if (nb_tx) {
+		hinic3_write_db(txq->db_addr, txq->q_id, (int)(txq->cos),
+				SQ_CFLAG_DP,
+				MASKED_QUEUE_IDX(txq, txq->prod_idx));
+		txq->txq_stats.packets += nb_tx;
+		txq->txq_stats.bytes += tx_bytes;
+	}
+	txq->txq_stats.burst_pkts = nb_tx;
+
+#ifdef HINIC3_XSTAT_PROF_TX
+	t2 = rte_get_tsc_cycles();
+	txq->txq_stats.app_tsc = t1 - txq->prof_tx_end_tsc;
+	txq->prof_tx_end_tsc = t2;
+	txq->txq_stats.pmd_tsc = t2 - t1;
+	txq->txq_stats.burst_pkts = nb_tx;
+#endif
+
+	return nb_tx;
+}
diff --git a/drivers/net/hinic3/hinic3_tx.h b/drivers/net/hinic3/hinic3_tx.h
index e5aa0a6f8e..51024e4e99 100644
--- a/drivers/net/hinic3/hinic3_tx.h
+++ b/drivers/net/hinic3/hinic3_tx.h
@@ -55,10 +55,10 @@ struct hinic3_wqe_info {
 	uint16_t sge_cnt;
 
 	uint8_t offload;
-	uint8_t rsvd0; /**< Reserved field 0. */
+	uint8_t wrapped;
 	uint16_t payload_offset;
 
-	uint8_t rsvd1; /**< Reserved field 1. */
+	uint32_t queue_info_sp620; /**< Scalar/SP620 queue-info word. */
 	uint8_t owner;
 	uint16_t pi;
 
@@ -174,6 +174,10 @@ enum sq_wqe_tasksect_len_type {
 #define SQ_CTRL_QUEUE_INFO_PLDOFF_SHIFT	   2
 #define SQ_CTRL_QUEUE_INFO_UFO_SHIFT	   10
 #define SQ_CTRL_QUEUE_INFO_TSO_SHIFT	   11
+/*
+ * Compact task format only: set for VXLAN, VXLAN-GPE and GENEVE.
+ * The scalar/SP620 WQE does not use this bit.
+ */
 #define SQ_CTRL_QUEUE_INFO_TCPUDP_CS_SHIFT 12
 #define SQ_CTRL_QUEUE_INFO_MSS_SHIFT	   13
 #define SQ_CTRL_QUEUE_INFO_SCTP_SHIFT	   27
@@ -228,6 +232,11 @@ enum sq_wqe_tasksect_len_type {
 		    SQ_CTRL_COMPACT_QUEUE_INFO_##member##_SHIFT)))
 
 /* Setting and obtaining task information */
+
+/* SQ_TASK_INFO0_* serves the SP620 scalar WQE from hinic3_xmit_pkts();
+ * SQ_TASK_INFO_* serves the SP230/SP560 compact task WQE from
+ * hinic3_xmit_pkts_compact_task().
+ */
 #define SQ_TASK_INFO0_TUNNEL_FLAG_SHIFT	    19
 #define SQ_TASK_INFO0_ESP_NEXT_PROTO_SHIFT  22
 #define SQ_TASK_INFO0_INNER_L4_EN_SHIFT	    24
@@ -379,7 +388,6 @@ struct __rte_cache_aligned hinic3_txq {
 	uint64_t sq_head_addr;
 	uint64_t sq_bot_sge_addr;
 	uint32_t cos;
-	uint8_t tx_wqe_compact_task;
 	uint32_t non_tso_max_pkt_len;
 	struct hinic3_txq_stats txq_stats;
 #ifdef HINIC3_XSTAT_PROF_TX
@@ -387,42 +395,13 @@ struct __rte_cache_aligned hinic3_txq {
 #endif
 };
 
-/* Tx WQE offload set callback function */
-typedef void  (*nic_tx_set_wqe_offload_t)(struct hinic3_wqe_info *wqe_info,
-					  struct hinic3_sq_wqe_combo *wqe_combo);
-
-struct hinic3_nic_tx_ops {
-	nic_tx_set_wqe_offload_t	nic_tx_set_wqe_offload;
-};
-
 void hinic3_flush_txqs(struct hinic3_nic_dev *nic_dev);
 void hinic3_free_txq_mbufs(struct hinic3_txq *txq);
 void hinic3_free_all_txq_mbufs(struct hinic3_nic_dev *nic_dev);
+uint16_t hinic3_xmit_pkts_compact_task(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
 uint16_t hinic3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
 uint16_t hinic3_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
 int hinic3_stop_sq(struct hinic3_txq *txq);
 int hinic3_start_all_sqs(struct rte_eth_dev *eth_dev);
 int hinic3_tx_done_cleanup(void *txq, uint32_t free_cnt);
-
-/**
- * Set wqe task section
- *
- * @param[in] wqe_info
- * Packet info parsed according to mbuf
- * @param[in] wqe_combo
- * Wqe need to format
- */
-void hinic3_tx_set_normal_task_offload(struct hinic3_wqe_info *wqe_info,
-				       struct hinic3_sq_wqe_combo *wqe_combo);
-
-/**
- * Set compact wqe task section
- *
- * @param[in] wqe_info
- * Packet info parsed according to mbuf
- * @param[in] wqe_combo
- * Wqe need to format
- */
-void hinic3_tx_set_compact_task_offload(struct hinic3_wqe_info *wqe_info,
-					struct hinic3_sq_wqe_combo *wqe_combo);
 #endif /**< _HINIC3_TX_H_ */
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 28/30] net/hinic3: add SP230 VF software statistics
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (26 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 27/30] net/hinic3: split Tx burst function for compact task support Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 29/30] net/hinic3: add Tx burst mode get Jiacheng Ye
                   ` (2 subsequent siblings)
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

For an SP230 VF, aggregate the software queue counters to report
ipackets/ibytes/opackets/obytes. PF ports keep using the firmware vport
statistics.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 drivers/net/hinic3/hinic3_ethdev.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 65fd19ee0f..5c4faef83f 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -3084,13 +3084,16 @@ hinic3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
 	struct hinic3_nic_dev *nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 	struct hinic3_vport_stats vport_stats;
 	uint64_t rx_discards_pmd = 0;
+	bool sw_stats = HINIC3_IS_VF(nic_dev->hwdev) && HINIC3_IS_SP230_NIC(nic_dev);
 	int err;
 
-	err = hinic3_get_vport_stats(nic_dev->hwdev, &vport_stats);
-	if (err) {
-		PMD_DRV_LOG(ERR, "Get vport stats from fw failed, nic_dev: %s",
-			    nic_dev->dev_name);
-		return err;
+	if (!sw_stats) {
+		err = hinic3_get_vport_stats(nic_dev->hwdev, &vport_stats);
+		if (err) {
+			PMD_DRV_LOG(ERR, "Get vport stats from fw failed, nic_dev: %s",
+				    nic_dev->dev_name);
+			return err;
+		}
 	}
 
 	/* Rx queue stats. */
@@ -3111,6 +3114,12 @@ hinic3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
 		stats->ierrors += rxq->rxq_stats.errors;
 		rx_discards_pmd += rxq->rxq_stats.dropped;
 		dev->data->rx_mbuf_alloc_failed += rxq->rxq_stats.rx_nombuf;
+
+		if (sw_stats) {
+			stats->ipackets += rxq->rxq_stats.packets;
+			stats->ibytes += rxq->rxq_stats.bytes;
+			stats->imissed += rxq->rxq_stats.dropped;
+		}
 	}
 
 	/* Tx queue stats. */
@@ -3121,8 +3130,16 @@ hinic3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
 			qstats[i].q_opackets = txq->txq_stats.packets;
 			qstats[i].q_obytes = txq->txq_stats.bytes;
 		}
+
+		if (sw_stats) {
+			stats->opackets += txq->txq_stats.packets;
+			stats->obytes += txq->txq_stats.bytes;
+		}
 	}
 
+	if (sw_stats)
+		return 0;
+
 	/* Vport stats. */
 	stats->oerrors += vport_stats.tx_discard_vport;
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 29/30] net/hinic3: add Tx burst mode get
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (27 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 28/30] net/hinic3: add SP230 VF software statistics Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-25 17:04 ` [PATCH v9 30/30] net/hinic3: expose Tx queue copied-mbuf statistics Jiacheng Ye
  2026-11-27 17:38 ` [PATCH v9 00/30] net/hinic3: add PMD features and fixes Stephen Hemminger
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

Expose the active Tx burst mode and its offloads via the
tx_burst_mode_get callback so applications can query how each queue
sends packets. The string is derived from the Tx burst function actually
installed on the device, so it reports the compact task path only when
that path is really in use, and also lists the enabled offloads.
Advertise the new capability in the feature matrix.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/nics/features/hinic3.ini    |  1 +
 doc/guides/nics/hinic3.rst             |  1 +
 doc/guides/rel_notes/release_26_11.rst |  1 +
 drivers/net/hinic3/hinic3_ethdev.c     |  2 ++
 drivers/net/hinic3/hinic3_tx.c         | 31 ++++++++++++++++++++++++++
 drivers/net/hinic3/hinic3_tx.h         |  2 ++
 6 files changed, 38 insertions(+)

diff --git a/doc/guides/nics/features/hinic3.ini b/doc/guides/nics/features/hinic3.ini
index 81c3e85410..ba30a850e9 100644
--- a/doc/guides/nics/features/hinic3.ini
+++ b/doc/guides/nics/features/hinic3.ini
@@ -9,6 +9,7 @@ Link speed configuration = Y
 Rx interrupt         = Y
 Queue start/stop     = Y
 Runtime queue setup  = Y
+Burst mode info      = Y
 MTU update           = Y
 Scattered Rx         = Y
 TSO                  = Y
diff --git a/doc/guides/nics/hinic3.rst b/doc/guides/nics/hinic3.rst
index c74b86b538..f46670e79f 100644
--- a/doc/guides/nics/hinic3.rst
+++ b/doc/guides/nics/hinic3.rst
@@ -24,6 +24,7 @@ Features
 - TSO offload
 - Promiscuous mode
 - Port hardware statistics
+- Burst mode info
 - Jumbo frames
 - Link state information
 - Link flow control
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 0513d09d9f..04105af387 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -144,6 +144,7 @@ New Features
   * Added a compact CQE receive data path.
   * Extended TCP segmentation offload (TSO) to 255 segments.
   * Added a compact task transmit data path.
+  * Added Tx burst mode reporting.
 
 * **Updated Intel iavf driver.**
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 5c4faef83f..23d28a585c 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -3905,6 +3905,7 @@ static const struct eth_dev_ops hinic3_pmd_ops = {
 	.mac_addr_add                  = hinic3_mac_addr_add,
 	.set_mc_addr_list              = hinic3_set_mc_addr_list,
 	.flow_ops_get                  = hinic3_dev_filter_ctrl,
+	.tx_burst_mode_get             = hinic3_tx_burst_mode_get,
 	.fec_get_capability            = hinic3_fec_capability_get,
 	.fec_get                       = hinic3_fec_get,
 	.fec_set                       = hinic3_fec_set,
@@ -3959,6 +3960,7 @@ static const struct eth_dev_ops hinic3_pmd_vf_ops = {
 	.set_mc_addr_list              = hinic3_set_mc_addr_list,
 	.flow_ops_get                  = hinic3_dev_filter_ctrl,
 	.eth_dev_priv_dump             = hinic3_eth_dev_priv_dump,
+	.tx_burst_mode_get             = hinic3_tx_burst_mode_get,
 };
 
 /**
diff --git a/drivers/net/hinic3/hinic3_tx.c b/drivers/net/hinic3/hinic3_tx.c
index 3f44814405..0bee8a8691 100644
--- a/drivers/net/hinic3/hinic3_tx.c
+++ b/drivers/net/hinic3/hinic3_tx.c
@@ -1500,6 +1500,37 @@ hinic3_flush_txqs(struct hinic3_nic_dev *nic_dev)
 	}
 }
 
+int
+hinic3_tx_burst_mode_get(struct rte_eth_dev *dev,
+			 uint16_t tx_queue_id,
+			 struct rte_eth_burst_mode *mode)
+{
+	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
+	struct hinic3_nic_dev *nic_dev;
+	struct hinic3_txq *txq = NULL;
+
+	nic_dev = HINIC3_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
+	txq = nic_dev->txqs[tx_queue_id];
+	if (!txq)
+		return -EINVAL;
+
+	snprintf(mode->info, sizeof(mode->info),
+		 "%s%s%s%s%s",
+		 dev->tx_pkt_burst == hinic3_xmit_pkts_compact_task ?
+			"compact task" : "scalar",
+		 (tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) ? " + MULTI" : "",
+		 (tx_offloads & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
+				 RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO)) ? " + TSO" : "",
+		 (tx_offloads & (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
+				 RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
+				 RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
+				 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM |
+				 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) ? " + CKSUM" : "",
+		 (tx_offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) ? " + VLAN" : "");
+
+	return 0;
+}
+
 /**
  * It is responsible for sending data packets.
  *
diff --git a/drivers/net/hinic3/hinic3_tx.h b/drivers/net/hinic3/hinic3_tx.h
index 51024e4e99..3a6451f69b 100644
--- a/drivers/net/hinic3/hinic3_tx.h
+++ b/drivers/net/hinic3/hinic3_tx.h
@@ -404,4 +404,6 @@ uint16_t hinic3_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb
 int hinic3_stop_sq(struct hinic3_txq *txq);
 int hinic3_start_all_sqs(struct rte_eth_dev *eth_dev);
 int hinic3_tx_done_cleanup(void *txq, uint32_t free_cnt);
+int hinic3_tx_burst_mode_get(struct rte_eth_dev *dev, uint16_t tx_queue_id,
+			     struct rte_eth_burst_mode *mode);
 #endif /**< _HINIC3_TX_H_ */
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v9 30/30] net/hinic3: expose Tx queue copied-mbuf statistics
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (28 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 29/30] net/hinic3: add Tx burst mode get Jiacheng Ye
@ 2026-11-25 17:04 ` Jiacheng Ye
  2026-11-27 17:38 ` [PATCH v9 00/30] net/hinic3: add PMD features and fixes Stephen Hemminger
  30 siblings, 0 replies; 32+ messages in thread
From: Jiacheng Ye @ 2026-11-25 17:04 UTC (permalink / raw)
  To: dev; +Cc: Feifei Wang, Thomas Monjalon, Anatoly Burakov, Stephen Hemminger

The Tx path copies mbufs when the segment count exceeds the inline
limit, tracking the number of copied packets and the number of segments
too large to inline. Expose these two counters in the per-queue extended
statistics so they are visible to applications.

Signed-off-by: Jiacheng Ye <yejiacheng4@h-partners.com>
---
 doc/guides/rel_notes/release_26_11.rst | 1 +
 drivers/net/hinic3/hinic3_ethdev.c     | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 04105af387..97e37b5f49 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -145,6 +145,7 @@ New Features
   * Extended TCP segmentation offload (TSO) to 255 segments.
   * Added a compact task transmit data path.
   * Added Tx burst mode reporting.
+  * Added Tx queue copied-mbuf statistics.
 
 * **Updated Intel iavf driver.**
 
diff --git a/drivers/net/hinic3/hinic3_ethdev.c b/drivers/net/hinic3/hinic3_ethdev.c
index 23d28a585c..a52f317d51 100644
--- a/drivers/net/hinic3/hinic3_ethdev.c
+++ b/drivers/net/hinic3/hinic3_ethdev.c
@@ -287,6 +287,8 @@ static const struct hinic3_xstats_name_off hinic3_txq_stats_strings[] = {
 	HINIC3_TXQ_STAT(burst_pkts),
 	HINIC3_TXQ_STAT(sge_len0),
 	HINIC3_TXQ_STAT(mbuf_null),
+	HINIC3_TXQ_STAT(cpy_pkts),
+	HINIC3_TXQ_STAT(sge_len_too_large),
 
 #ifdef HINIC3_XSTAT_PROF_TX
 	HINIC3_TXQ_STAT(app_tsc),
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH v9 00/30] net/hinic3: add PMD features and fixes
  2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
                   ` (29 preceding siblings ...)
  2026-11-25 17:04 ` [PATCH v9 30/30] net/hinic3: expose Tx queue copied-mbuf statistics Jiacheng Ye
@ 2026-11-27 17:38 ` Stephen Hemminger
  30 siblings, 0 replies; 32+ messages in thread
From: Stephen Hemminger @ 2026-11-27 17:38 UTC (permalink / raw)
  To: Jiacheng Ye; +Cc: dev, Feifei Wang, Thomas Monjalon, Anatoly Burakov

On Thu, 26 Nov 2026 01:03:54 +0800
Jiacheng Ye <yejiacheng4@h-partners.com> wrote:

> This series fixes offload capability advertisement, cmdq/compact CQE
> configuration, and a handful of driver defects, and adds NIC
> type identification, FEC, CIR drop statistics, VF LAG/link state, COS
> mask/map, mbox recording, RSS hash configuration, compact CQE Rx/Tx
> paths, TSO segment expansion, Tx burst mode reporting, queue statistics,
> pseudo-header checksum, per-tile cmdq ops, SP560 NIC support, and device
> kvargs tunables.
> 
> This version supersedes v8. v8 was applied to next-net; please drop it
> and use v9 instead.


Update the version in next-net.

Minor AI review info noted:

Info
====

[PATCH 15/30] v8 mapped the firmware NOT_SET value to AUTO on GET.
v9 drops that table entry, so hinic3_fec_get() now fails with -EINVAL
whenever the firmware reports NOT_SET:

	if (advertised_fec == 0) {
		PMD_DRV_LOG(ERR, "Firmware reported an unknown FEC mode (NOT_SET).");
		return -EINVAL;
	}

rte_eth_fec_get() can report AUTO, and NOT_SET is a state the
firmware produces, not a corrupt value. If NOT_SET means the mode has
not been forced, return RTE_ETH_FEC_MODE_CAPA_MASK(AUTO) as before
and drop the ERR log. If it can only happen in an error state, say
when in the commit message.

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2026-11-27 17:38 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 17:03 [PATCH v9 00/30] net/hinic3: add PMD features and fixes Jiacheng Ye
2026-11-25 17:03 ` [PATCH v9 01/30] net/hinic3: fix SP230 VF PCI device ID Jiacheng Ye
2026-11-25 17:03 ` [PATCH v9 02/30] net/hinic3: fix double removal in ethertype flow destroy Jiacheng Ye
2026-11-25 17:03 ` [PATCH v9 03/30] net/hinic3: fix TCAM index leak on ethertype flow set Jiacheng Ye
2026-11-25 17:03 ` [PATCH v9 04/30] net/hinic3: fix VXLAN VNI spec and mask write Jiacheng Ye
2026-11-25 17:03 ` [PATCH v9 05/30] net/hinic3: fix wildcard IPv4, ICMP and UDP flow items Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 06/30] net/hinic3: fix vport enable null dereference Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 07/30] net/hinic3: clear stale Rx hardware CI on queue reset Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 08/30] net/hinic3: attach ethdev and set ops in secondary process Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 09/30] net/hinic3: return success when no FDIR rule to update Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 10/30] net/hinic3: gate RQ enable on HTN FDIR Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 11/30] net/hinic3: fix pseudo-header checksum and identify NIC type Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 12/30] net/hinic3: add SP230 Rx queue interrupt handling Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 13/30] net/hinic3: fix offload and cmdq/compact CQE config Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 14/30] net/hinic3: add vport statistics and VF LAG support Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 15/30] net/hinic3: add FEC mode get/set and capability support Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 16/30] net/hinic3: add mbox message recording and debug dump Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 17/30] net/hinic3: add COS mask and COS map support Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 18/30] net/hinic3: add VF link state and promiscuous support Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 19/30] net/hinic3: convert cmdq ops to static global variables Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 20/30] net/hinic3: update RSS hash type configuration Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 21/30] net/hinic3: refactor flow rule parsing Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 22/30] net/hinic3: add SP560 NIC type identification and handling Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 23/30] net/hinic3: add device kvargs parameters support Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 24/30] net/hinic3: add compact CQE Rx path and ptype table Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 25/30] net/hinic3: ensure queue depth and state consistency Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 26/30] net/hinic3: expand TSO from 127 to 255 segments Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 27/30] net/hinic3: split Tx burst function for compact task support Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 28/30] net/hinic3: add SP230 VF software statistics Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 29/30] net/hinic3: add Tx burst mode get Jiacheng Ye
2026-11-25 17:04 ` [PATCH v9 30/30] net/hinic3: expose Tx queue copied-mbuf statistics Jiacheng Ye
2026-11-27 17:38 ` [PATCH v9 00/30] net/hinic3: add PMD features and fixes Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox