* [PATCH 1/3] common/sfc_efx/base: update MCDI headers
2026-08-11 17:49 [PATCH 0/3] common/sfc_efx/base: add VADAPTER statistics for Medford4 Ivan Malov
@ 2026-08-11 17:49 ` Ivan Malov
2026-08-11 17:49 ` [PATCH 2/3] common/sfc_efx/base: add support for VADAPTER statistics IDs Ivan Malov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ivan Malov @ 2026-08-11 17:49 UTC (permalink / raw)
To: dev
Cc: Andy Moreton, Viacheslav Galaktionov, Roman Zhukov,
Pieter Jansen van Vuuren, Stephen Hemminger, Andrew Rybchenko
Selectively import MCDI changes from the in-house libefx repository
to meet the needs of the feature support patches that will follow.
Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
---
drivers/common/sfc_efx/base/efx_regs_mcdi.h | 313 +++++++++++++++++++-
1 file changed, 306 insertions(+), 7 deletions(-)
diff --git a/drivers/common/sfc_efx/base/efx_regs_mcdi.h b/drivers/common/sfc_efx/base/efx_regs_mcdi.h
index 259af6a0df..69d17aa255 100644
--- a/drivers/common/sfc_efx/base/efx_regs_mcdi.h
+++ b/drivers/common/sfc_efx/base/efx_regs_mcdi.h
@@ -6952,7 +6952,7 @@
#define MC_CMD_LINK_STATE_MSGSET 0x6c
#undef MC_CMD_0x6c_PRIVILEGE_CTG
-#define MC_CMD_0x6c_PRIVILEGE_CTG SRIOV_CTG_LINK
+#define MC_CMD_0x6c_PRIVILEGE_CTG SRIOV_CTG_GENERAL
/* MC_CMD_LINK_STATE_IN msgrequest */
#define MC_CMD_LINK_STATE_IN_LEN 4
@@ -12323,13 +12323,15 @@
/***********************************/
/* MC_CMD_MAC_CTRL
- * Set MAC configuration. Return code: 0, EINVAL, ENOTSUP
+ * Set MAC configuration. Requires LINK privilege. The only exception is when
+ * the only request is MTU change and the new MTU <= the current setting. In
+ * such case we do nothing and return 0. Return code: 0, EINVAL, ENOTSUP
*/
#define MC_CMD_MAC_CTRL 0x1df
#define MC_CMD_MAC_CTRL_MSGSET 0x1df
#undef MC_CMD_0x1df_PRIVILEGE_CTG
-#define MC_CMD_0x1df_PRIVILEGE_CTG SRIOV_CTG_LINK
+#define MC_CMD_0x1df_PRIVILEGE_CTG SRIOV_CTG_GENERAL
/* MC_CMD_MAC_CTRL_IN msgrequest */
#define MC_CMD_MAC_CTRL_IN_LEN 32
@@ -12454,7 +12456,7 @@
#define MC_CMD_MAC_STATE_MSGSET 0x1e0
#undef MC_CMD_0x1e0_PRIVILEGE_CTG
-#define MC_CMD_0x1e0_PRIVILEGE_CTG SRIOV_CTG_LINK
+#define MC_CMD_0x1e0_PRIVILEGE_CTG SRIOV_CTG_GENERAL
/* MC_CMD_MAC_STATE_IN msgrequest */
#define MC_CMD_MAC_STATE_IN_LEN 4
@@ -12609,6 +12611,16 @@
#define MC_CMD_STAT_ID_MAC 0x2
/* enum: Network port PHY statistics. */
#define MC_CMD_STAT_ID_PHY 0x3
+/* enum: Network port packet memory (PM) statistics. */
+#define MC_CMD_STAT_ID_PM 0x4
+/* enum: Network port RXDP statistics. */
+#define MC_CMD_STAT_ID_RXDP 0x5
+/* enum: Low Latency datapath statistics. */
+#define MC_CMD_STAT_ID_LL 0x6
+/* enum: Fast Classifier statistics. */
+#define MC_CMD_STAT_ID_FC 0x7
+/* enum: Vadapter statistics. */
+#define MC_CMD_STAT_ID_VADAPTER 0x8
#define MC_CMD_STAT_ID_SOURCE_ID_LBN 0
#define MC_CMD_STAT_ID_SOURCE_ID_WIDTH 16
#define MC_CMD_STAT_ID_MARKER_STAT_ID_OFST 2
@@ -12620,7 +12632,7 @@
*/
#define MC_CMD_STAT_ID_GENERATION_START 0x1
/* enum: This value is used to mark the end of a generation of statistics for
- * DMA synchronizaion. Always the last entry in the DMA buffer and set to the
+ * DMA synchronization. Always the last entry in the DMA buffer and set to the
* same value as GENERATION_START. The host driver must compare the
* GENERATION_START and GENERATION_END values to verify that the DMA buffer is
* consistent upon copying the the DMA buffer. If they do not match, it means
@@ -12769,6 +12781,207 @@
#define MC_CMD_STAT_ID_FEC_CORRECTED_SYMBOLS_LANE3 0x6
#define MC_CMD_STAT_ID_PHY_STAT_ID_LBN 16
#define MC_CMD_STAT_ID_PHY_STAT_ID_WIDTH 16
+/* Include packet memory (PM) stats. */
+#define MC_CMD_STAT_ID_PM_STAT_ID_OFST 2
+#define MC_CMD_STAT_ID_PM_STAT_ID_LEN 2
+/* enum property: index */
+/* enum: PM discard_vfifo_full counter. */
+#define MC_CMD_STAT_ID_PM_DISCARD_VFIFO_FULL 0x1
+/* enum: PM discard_qbb counter. */
+#define MC_CMD_STAT_ID_PM_DISCARD_QBB 0x2
+/* enum: PM discard_mapping counter. */
+#define MC_CMD_STAT_ID_PM_DISCARD_MAPPING 0x3
+#define MC_CMD_STAT_ID_PM_STAT_ID_LBN 16
+#define MC_CMD_STAT_ID_PM_STAT_ID_WIDTH 16
+/* Include RXDP stats. */
+#define MC_CMD_STAT_ID_RXDP_STAT_ID_OFST 2
+#define MC_CMD_STAT_ID_RXDP_STAT_ID_LEN 2
+/* enum property: index */
+/* enum: RXDP counter: Number of packets dropped due to the queue being
+ * disabled.
+ */
+#define MC_CMD_STAT_ID_RXDP_Q_DISABLED_PKTS 0x1
+/* enum: RXDP counter: Number of packets dropped by the DICPU. */
+#define MC_CMD_STAT_ID_RXDP_DI_DROPPED_PKTS 0x2
+/* enum: RXDP counter: Number of non-host packets. */
+#define MC_CMD_STAT_ID_RXDP_STREAMING_PKTS 0x3
+/* enum: RXDP counter: Number of times an hlb descriptor fetch was performed.
+ */
+#define MC_CMD_STAT_ID_RXDP_HLB_FETCH_CONDITIONS 0x4
+/* enum: RXDP counter: Number of times the DPCPU waited for an existing
+ * descriptor fetch.
+ */
+#define MC_CMD_STAT_ID_RXDP_HLB_WAIT_CONDITIONS 0x5
+/* enum: RXDP counter: Number of packets truncated because scattering was
+ * disabled.
+ */
+#define MC_CMD_STAT_ID_RXDP_SCATTER_DISABLED_TRUNC 0x6
+/* enum: RXDP counter: Number of times the RXDP head of line blocked waiting
+ * for descriptors. Will be zero unless RXDP_HLB_IDLE capability is set.
+ */
+#define MC_CMD_STAT_ID_RXDP_HLB_IDLE 0x7
+/* enum: RXDP counter: Number of times the RXDP timed out while head of line
+ * blocking. Will be zero unless RXDP_HLB_IDLE capability is set.
+ */
+#define MC_CMD_STAT_ID_RXDP_HLB_TIMEOUT 0x8
+#define MC_CMD_STAT_ID_RXDP_STAT_ID_LBN 16
+#define MC_CMD_STAT_ID_RXDP_STAT_ID_WIDTH 16
+/* Include Low Latency datapath stats */
+#define MC_CMD_STAT_ID_LL_STAT_ID_OFST 2
+#define MC_CMD_STAT_ID_LL_STAT_ID_LEN 2
+/* enum property: index */
+/* enum: BIU Host CTPIO Write Byte Count, x3_ctpio_xfr_if vld & rdy & wr_req &
+ * sot & CTPIO_WINDOW_ADDR, increment by bcnt.
+ */
+#define MC_CMD_STAT_ID_LL_CTPIO_WIN_BYTES 0x1
+/* enum: CTPIO TX Warm Packet Count, internal warm flag drop count per port. */
+#define MC_CMD_STAT_ID_LL_CTPIO_WIN_WARM_PKTS 0x2
+/* enum: CTPIO TX Warm Packet Byte Count, internal warm flag byte drop count
+ * per port.
+ */
+#define MC_CMD_STAT_ID_LL_CTPIO_WIN_WARM_BYTES 0x3
+/* enum: ETH_TX valid & ready. */
+#define MC_CMD_STAT_ID_LL_ETH_TX_ACTIVE 0x4
+/* enum: ETH_TX !ready. */
+#define MC_CMD_STAT_ID_LL_ETH_TX_PAUSE 0x5
+/* enum: ETH_TX valid & ready & last. */
+#define MC_CMD_STAT_ID_LL_ETH_TX_PKTS 0x6
+/* enum: ETH_TX valid & ready & last, count bytes. */
+#define MC_CMD_STAT_ID_LL_ETH_TX_BYTES 0x7
+/* enum: ETH_TX valid & ready & last & bad. */
+#define MC_CMD_STAT_ID_LL_ETH_TX_CTUR_PKTS 0x8
+/* enum: ETH_TX valid & ready & last & bad, count bytes. */
+#define MC_CMD_STAT_ID_LL_ETH_TX_CTUR_BYTES 0x9
+/* enum: ETH_RX_RSP valid. */
+#define MC_CMD_STAT_ID_LL_ETH_TX_RSP 0xa
+/* enum: TX Events Coalesed. */
+#define MC_CMD_STAT_ID_LL_INI_REQ_TXEV_COAL 0xb
+/* enum: biu_ini_dma_req & biu_ini_grant & txev data for the port. */
+#define MC_CMD_STAT_ID_LL_INI_REQ_TXEV_PKTS 0xc
+/* enum: biu_ini_dma_req & biu_ini_grant & txev data for the port, increment by
+ * biu_ini_len.
+ */
+#define MC_CMD_STAT_ID_LL_INI_REQ_TXEV_BYTES 0xd
+/* enum: ETH_RX valid & ready. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_ACTIVE 0xe
+/* enum: ETH_RX !ready. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_PAUSE 0xf
+/* enum: ETH_RX valid & ready & last. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_PKTS 0x10
+/* enum: ETH_RX valid & ready & last & bad. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_BAD_PKTS 0x11
+/* enum: ETH_RX valid & ready & last, count bytes. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_BYTES 0x12
+/* enum: ETH_RX packets dropped because RX for port traffic not enabled. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_EN_DROPPED_PKTS 0x13
+/* enum: ETH_RX bytes dropped because RX for port traffic not enabled. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_EN_DROPPED_BYTES 0x14
+/* enum: ETH_RX packets dropped because RX Buffer full. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_FULL_DROPPED_PKTS 0x15
+/* enum: ETH_RX bytes dropped because RX Buffer full. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_FULL_DROPPED_BYTES 0x16
+/* enum: ETH_RX packets dropped because RX Queue not enabled. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_QEN_DROPPED_PKTS 0x17
+/* enum: ETH_RX bytes dropped because RX Queue not enabled. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_QEN_DROPPED_BYTES 0x18
+/* enum: ETH_RX packets dropped because RX Queue descriptor not available. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_NODSC_DROPPED_PKTS 0x19
+/* enum: ETH_RX bytes dropped because RX Queue descriptor not available. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_NODSC_DROPPED_BYTES 0x1a
+/* enum: biu_ini_dma_req & biu_ini_grant & rxpkt data for the port. */
+#define MC_CMD_STAT_ID_LL_INI_REQ_RXPKT_PKTS 0x1b
+/* enum: biu_ini_dma_req & biu_ini_grant & rxpkt data for the port, increment
+ * by biu_ini_len.
+ */
+#define MC_CMD_STAT_ID_LL_INI_REQ_RXPKT_BYTES 0x1c
+/* enum: biu_ini_dma_req & biu_ini_grant & rxmeta data for the port. */
+#define MC_CMD_STAT_ID_LL_INI_REQ_RXMETA 0x1d
+/* enum: RX Events Coalesed. */
+#define MC_CMD_STAT_ID_LL_INI_REQ_RXEV_COAL 0x1e
+/* enum: biu_ini_dma_req & biu_ini_grant & rxev data for the port. */
+#define MC_CMD_STAT_ID_LL_INI_REQ_RXEV_PKTS 0x1f
+/* enum: biu_ini_dma_req & biu_ini_grant & rxev data for the port, increment by
+ * biu_ini_len.
+ */
+#define MC_CMD_STAT_ID_LL_INI_REQ_RXEV_BYTES 0x20
+/* enum: ETH_RX bytes dropped because packet was truncated by LL. */
+#define MC_CMD_STAT_ID_LL_ETH_RX_TRUNC_DROPPED_BYTES 0x21
+/* enum: CTPIO TX Drain Packet Count, internal drain drop count per port, TX
+ * packet is dropped.
+ */
+#define MC_CMD_STAT_ID_LL_CTPIO_WIN_DRAIN_PKTS 0x22
+/* enum: CTPIO TX Drain Packet Byte Count, internal drain byte drop count per
+ * port, TX packet is dropped.
+ */
+#define MC_CMD_STAT_ID_LL_CTPIO_WIN_DRAIN_BYTES 0x23
+/* enum: cycle count when backpressure high from EV Send block to TX. */
+#define MC_CMD_STAT_ID_LL_TX_EV_BACKPRESSURE 0x24
+/* enum: cycle count when backpressure high from EV Send block to RX. */
+#define MC_CMD_STAT_ID_LL_RX_EV_BACKPRESSURE 0x25
+#define MC_CMD_STAT_ID_LL_STAT_ID_LBN 16
+#define MC_CMD_STAT_ID_LL_STAT_ID_WIDTH 16
+/* Fast Classifier stats */
+#define MC_CMD_STAT_ID_FC_STAT_ID_OFST 2
+#define MC_CMD_STAT_ID_FC_STAT_ID_LEN 2
+/* enum property: index */
+/* enum: Number of detected ECC errors in the fast classifier result memory.
+ * This is a global stat and will only be reported for port 0.
+ */
+#define MC_CMD_STAT_ID_FC_ECC_ERRORS 0x1
+/* enum: A non-zero number here indicates that an unknown number of additional
+ * single-bit errors have occurred in addition to those reported under
+ * FC_ECC_ERRORS. This is a global stat and will only be reported for port 0.
+ */
+#define MC_CMD_STAT_ID_FC_ECC_OVERFLOW 0x2
+/* enum: Number of corrected errors in the fast classifier TCAM lookup data,
+ * i.e. filter key/mask. This is a global stat and will only be reported for
+ * port 0.
+ */
+#define MC_CMD_STAT_ID_FC_TCAM_ERRORS 0x3
+#define MC_CMD_STAT_ID_FC_STAT_ID_LBN 16
+#define MC_CMD_STAT_ID_FC_STAT_ID_WIDTH 16
+/* Vadapter stats for SR-IOV */
+#define MC_CMD_STAT_ID_VADAPTER_STAT_ID_OFST 2
+#define MC_CMD_STAT_ID_VADAPTER_STAT_ID_LEN 2
+/* enum property: index */
+/* enum: Unicast packets received for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_RX_UNICAST_PACKETS 0x1
+/* enum: Unicast bytes received for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_RX_UNICAST_BYTES 0x2
+/* enum: Multicast packets received for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_RX_MULTICAST_PACKETS 0x3
+/* enum: Multicast bytes received for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_RX_MULTICAST_BYTES 0x4
+/* enum: Broadcast packets received for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_RX_BROADCAST_PACKETS 0x5
+/* enum: Broadcast bytes received for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_RX_BROADCAST_BYTES 0x6
+/* enum: Total number of packets received with bad CRC for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_RX_BAD_PACKETS 0x7
+/* enum: Total number of bytes received with bad CRC for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_RX_BAD_BYTES 0x8
+/* enum: Packets received with overflow for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_RX_OVERFLOW 0x9
+/* enum: Unicast packets transmitted for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_TX_UNICAST_PACKETS 0xa
+/* enum: Unicast bytes transmitted for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_TX_UNICAST_BYTES 0xb
+/* enum: Multicast packets transmitted for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_TX_MULTICAST_PACKETS 0xc
+/* enum: Multicast bytes transmitted for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_TX_MULTICAST_BYTES 0xd
+/* enum: Broadcast packets transmitted for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_TX_BROADCAST_PACKETS 0xe
+/* enum: Broadcast bytes transmitted for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_TX_BROADCAST_BYTES 0xf
+/* enum: Packets transmitted with bad FCS for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_TX_BAD_PACKETS 0x10
+/* enum: Bytes transmitted with bad FCS for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_TX_BAD_BYTES 0x11
+/* enum: Packets transmitted with overflow for vadapter. */
+#define MC_CMD_STAT_ID_VADAPTER_TX_OVERFLOW 0x12
+#define MC_CMD_STAT_ID_VADAPTER_STAT_ID_LBN 16
+#define MC_CMD_STAT_ID_VADAPTER_STAT_ID_WIDTH 16
/* MC_CMD_STAT_DESC structuredef: Structure describing the layout and size of
* the stats DMA buffer descriptor.
@@ -12796,6 +13009,26 @@
#define MC_CMD_STAT_DESC_STAT_ID_PHY_STAT_ID_LEN 2
#define MC_CMD_STAT_DESC_STAT_ID_PHY_STAT_ID_LBN 16
#define MC_CMD_STAT_DESC_STAT_ID_PHY_STAT_ID_WIDTH 16
+#define MC_CMD_STAT_DESC_STAT_ID_PM_STAT_ID_OFST 2
+#define MC_CMD_STAT_DESC_STAT_ID_PM_STAT_ID_LEN 2
+#define MC_CMD_STAT_DESC_STAT_ID_PM_STAT_ID_LBN 16
+#define MC_CMD_STAT_DESC_STAT_ID_PM_STAT_ID_WIDTH 16
+#define MC_CMD_STAT_DESC_STAT_ID_RXDP_STAT_ID_OFST 2
+#define MC_CMD_STAT_DESC_STAT_ID_RXDP_STAT_ID_LEN 2
+#define MC_CMD_STAT_DESC_STAT_ID_RXDP_STAT_ID_LBN 16
+#define MC_CMD_STAT_DESC_STAT_ID_RXDP_STAT_ID_WIDTH 16
+#define MC_CMD_STAT_DESC_STAT_ID_LL_STAT_ID_OFST 2
+#define MC_CMD_STAT_DESC_STAT_ID_LL_STAT_ID_LEN 2
+#define MC_CMD_STAT_DESC_STAT_ID_LL_STAT_ID_LBN 16
+#define MC_CMD_STAT_DESC_STAT_ID_LL_STAT_ID_WIDTH 16
+#define MC_CMD_STAT_DESC_STAT_ID_FC_STAT_ID_OFST 2
+#define MC_CMD_STAT_DESC_STAT_ID_FC_STAT_ID_LEN 2
+#define MC_CMD_STAT_DESC_STAT_ID_FC_STAT_ID_LBN 16
+#define MC_CMD_STAT_DESC_STAT_ID_FC_STAT_ID_WIDTH 16
+#define MC_CMD_STAT_DESC_STAT_ID_VADAPTER_STAT_ID_OFST 2
+#define MC_CMD_STAT_DESC_STAT_ID_VADAPTER_STAT_ID_LEN 2
+#define MC_CMD_STAT_DESC_STAT_ID_VADAPTER_STAT_ID_LBN 16
+#define MC_CMD_STAT_DESC_STAT_ID_VADAPTER_STAT_ID_WIDTH 16
/* Index of the statistic in the DMA buffer. */
#define MC_CMD_STAT_DESC_STAT_INDEX_OFST 4
#define MC_CMD_STAT_DESC_STAT_INDEX_LEN 2
@@ -13247,7 +13480,11 @@
/* MC_CMD_GET_FIXED_PORT_PROPERTIES_OUT msgresponse */
#define MC_CMD_GET_FIXED_PORT_PROPERTIES_OUT_LEN 36
-/* Supported capabilities of the port in its current configuration. */
+/* Supported capabilities of the port in its current configuration. NOTE: The
+ * FEC_REQ field is to be ignored for FIXED_PORT_PROPERTIES, as it is a
+ * property that depends on the link configuration. The FEC_MASK field should
+ * be used to query for the fixed FEC modes supported by a port.
+ */
#define MC_CMD_GET_FIXED_PORT_PROPERTIES_OUT_ABILITIES_OFST 0
#define MC_CMD_GET_FIXED_PORT_PROPERTIES_OUT_ABILITIES_LEN 25
/* See structuredef: MC_CMD_ETH_AN_FIELDS */
@@ -13288,7 +13525,11 @@
/* MC_CMD_GET_FIXED_PORT_PROPERTIES_OUT_V2 msgresponse */
#define MC_CMD_GET_FIXED_PORT_PROPERTIES_OUT_V2_LEN 48
-/* Supported capabilities of the port in its current configuration. */
+/* Supported capabilities of the port in its current configuration. NOTE: The
+ * FEC_REQ field is to be ignored for FIXED_PORT_PROPERTIES, as it is a
+ * property that depends on the link configuration. The FEC_MASK field should
+ * be used to query for the fixed FEC modes supported by a port.
+ */
#define MC_CMD_GET_FIXED_PORT_PROPERTIES_OUT_V2_ABILITIES_OFST 0
#define MC_CMD_GET_FIXED_PORT_PROPERTIES_OUT_V2_ABILITIES_LEN 25
/* Number of lanes supported by the port in its current configuration. */
@@ -14253,6 +14494,64 @@
#define MC_CMD_GET_NETPORT_STATISTICS_IN_DMA_LEN_OFST 16
#define MC_CMD_GET_NETPORT_STATISTICS_IN_DMA_LEN_LEN 4
+/* MC_CMD_GET_NETPORT_STATISTICS_V2_IN msgrequest */
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_LEN 24
+/* Handle of port to get MAC statistics for. */
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PORT_HANDLE_OFST 0
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PORT_HANDLE_LEN 4
+/* Contains options for querying the MAC statistics. */
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_CMD_OFST 4
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_CMD_LEN 4
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_OFST 4
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_LBN 0
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_WIDTH 1
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_CLEAR_OFST 4
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_CLEAR_LBN 1
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_CLEAR_WIDTH 1
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIODIC_CHANGE_OFST 4
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIODIC_CHANGE_LBN 2
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIODIC_CHANGE_WIDTH 1
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIODIC_ENABLE_OFST 4
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIODIC_ENABLE_LBN 3
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIODIC_ENABLE_WIDTH 1
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIODIC_NOEVENT_OFST 4
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIODIC_NOEVENT_LBN 4
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIODIC_NOEVENT_WIDTH 1
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIOD_MS_OFST 4
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIOD_MS_LBN 15
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PERIOD_MS_WIDTH 17
+/* Specifies the physical address of the DMA buffer to use for statistics
+ * transfer. This field must contain a valid address under either of these
+ * conditions: 1. DMA flag is set (immediate DMA requested) 2. Both
+ * PERIODIC_CHANGE and PERIODIC_ENABLE are set (periodic DMA configured)
+ */
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_ADDR_OFST 8
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_ADDR_LEN 8
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_ADDR_LO_OFST 8
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_ADDR_LO_LEN 4
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_ADDR_LO_LBN 64
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_ADDR_LO_WIDTH 32
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_ADDR_HI_OFST 12
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_ADDR_HI_LEN 4
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_ADDR_HI_LBN 96
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_ADDR_HI_WIDTH 32
+/* Specifies the length of the DMA buffer in bytes for statistics transfer. The
+ * buffer size must be at least DMA_BUFFER_SIZE bytes (as returned by
+ * MC_CMD_MAC_STATISTICS_DESCRIPTOR). Providing an insufficient buffer size
+ * will result in an EINVAL error. This field must contain a valid length under
+ * either of these conditions: 1. DMA flag is set (immediate DMA requested) 2.
+ * Both PERIODIC_CHANGE and PERIODIC_ENABLE are set (periodic DMA configured)
+ */
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_LEN_OFST 16
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_DMA_LEN_LEN 4
+/* Port ID mapping to an EVB port, used for reporting vadapter stats. If this
+ * value is not provided or invalid, and vadapter stats are supported by the
+ * NIC then the vadapter values will be reported as 0s to maintain a consistent
+ * statistics descriptor layout.
+ */
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PORT_ID_OFST 20
+#define MC_CMD_GET_NETPORT_STATISTICS_V2_IN_PORT_ID_LEN 4
+
/* MC_CMD_GET_NETPORT_STATISTICS_OUT msgresponse */
#define MC_CMD_GET_NETPORT_STATISTICS_OUT_LENMIN 0
#define MC_CMD_GET_NETPORT_STATISTICS_OUT_LENMAX 248
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/3] common/sfc_efx/base: add support for VADAPTER statistics IDs
2026-08-11 17:49 [PATCH 0/3] common/sfc_efx/base: add VADAPTER statistics for Medford4 Ivan Malov
2026-08-11 17:49 ` [PATCH 1/3] common/sfc_efx/base: update MCDI headers Ivan Malov
@ 2026-08-11 17:49 ` Ivan Malov
2026-08-11 17:49 ` [PATCH 3/3] common/sfc_efx/base: switch netport stats to use EVB port ID Ivan Malov
2026-08-11 20:31 ` [PATCH 0/3] common/sfc_efx/base: add VADAPTER statistics for Medford4 Stephen Hemminger
3 siblings, 0 replies; 5+ messages in thread
From: Ivan Malov @ 2026-08-11 17:49 UTC (permalink / raw)
To: dev
Cc: Andy Moreton, Viacheslav Galaktionov, Roman Zhukov,
Pieter Jansen van Vuuren, Stephen Hemminger, Andrew Rybchenko
From: Andy Moreton <andy.moreton@amd.com>
Add netport VADAPTER statistics IDs for use with VFs.
Signed-off-by: Andy Moreton <andy.moreton@amd.com>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
---
drivers/common/sfc_efx/base/efx_np.c | 45 ++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/common/sfc_efx/base/efx_np.c b/drivers/common/sfc_efx/base/efx_np.c
index a8396535bf..816affce2d 100644
--- a/drivers/common/sfc_efx/base/efx_np.c
+++ b/drivers/common/sfc_efx/base/efx_np.c
@@ -705,6 +705,51 @@ static const efx_np_stat_t efx_np_mac_stat_map[] = {
#undef EFX_NP_STAT_MAC
+#define EFX_NP_STAT_VADAPTER(_hw, _sw) \
+ [EFX_MAC_##_sw] = { \
+ .ens_hw_id = EFX_NP_HW_STAT_ID(VADAPTER, _hw), \
+ .ens_valid = B_TRUE, \
+ }
+
+ EFX_NP_STAT_VADAPTER(VADAPTER_RX_UNICAST_PACKETS,
+ VADAPTER_RX_UNICAST_PACKETS),
+ EFX_NP_STAT_VADAPTER(VADAPTER_RX_UNICAST_BYTES,
+ VADAPTER_RX_UNICAST_BYTES),
+ EFX_NP_STAT_VADAPTER(VADAPTER_RX_MULTICAST_PACKETS,
+ VADAPTER_RX_MULTICAST_PACKETS),
+ EFX_NP_STAT_VADAPTER(VADAPTER_RX_MULTICAST_BYTES,
+ VADAPTER_RX_MULTICAST_BYTES),
+ EFX_NP_STAT_VADAPTER(VADAPTER_RX_BROADCAST_PACKETS,
+ VADAPTER_RX_BROADCAST_PACKETS),
+ EFX_NP_STAT_VADAPTER(VADAPTER_RX_BROADCAST_BYTES,
+ VADAPTER_RX_BROADCAST_BYTES),
+ EFX_NP_STAT_VADAPTER(VADAPTER_RX_BAD_PACKETS,
+ VADAPTER_RX_BAD_PACKETS),
+ EFX_NP_STAT_VADAPTER(VADAPTER_RX_BAD_BYTES,
+ VADAPTER_RX_BAD_BYTES),
+ EFX_NP_STAT_VADAPTER(VADAPTER_RX_OVERFLOW,
+ VADAPTER_RX_OVERFLOW),
+ EFX_NP_STAT_VADAPTER(VADAPTER_TX_UNICAST_PACKETS,
+ VADAPTER_TX_UNICAST_PACKETS),
+ EFX_NP_STAT_VADAPTER(VADAPTER_TX_UNICAST_BYTES,
+ VADAPTER_TX_UNICAST_BYTES),
+ EFX_NP_STAT_VADAPTER(VADAPTER_TX_MULTICAST_PACKETS,
+ VADAPTER_TX_MULTICAST_PACKETS),
+ EFX_NP_STAT_VADAPTER(VADAPTER_TX_MULTICAST_BYTES,
+ VADAPTER_TX_MULTICAST_BYTES),
+ EFX_NP_STAT_VADAPTER(VADAPTER_TX_BROADCAST_PACKETS,
+ VADAPTER_TX_BROADCAST_PACKETS),
+ EFX_NP_STAT_VADAPTER(VADAPTER_TX_BROADCAST_BYTES,
+ VADAPTER_TX_BROADCAST_BYTES),
+ EFX_NP_STAT_VADAPTER(VADAPTER_TX_BAD_PACKETS,
+ VADAPTER_TX_BAD_PACKETS),
+ EFX_NP_STAT_VADAPTER(VADAPTER_TX_BAD_BYTES,
+ VADAPTER_TX_BAD_BYTES),
+ EFX_NP_STAT_VADAPTER(VADAPTER_TX_OVERFLOW,
+ VADAPTER_TX_OVERFLOW),
+
+#undef EFX_NP_STAT_VADAPTER
+
#define EFX_NP_STAT_PHY(_hw, _sw) \
[EFX_MAC_##_sw] = { \
.ens_hw_id = EFX_NP_HW_STAT_ID(PHY, _hw), \
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 3/3] common/sfc_efx/base: switch netport stats to use EVB port ID
2026-08-11 17:49 [PATCH 0/3] common/sfc_efx/base: add VADAPTER statistics for Medford4 Ivan Malov
2026-08-11 17:49 ` [PATCH 1/3] common/sfc_efx/base: update MCDI headers Ivan Malov
2026-08-11 17:49 ` [PATCH 2/3] common/sfc_efx/base: add support for VADAPTER statistics IDs Ivan Malov
@ 2026-08-11 17:49 ` Ivan Malov
2026-08-11 20:31 ` [PATCH 0/3] common/sfc_efx/base: add VADAPTER statistics for Medford4 Stephen Hemminger
3 siblings, 0 replies; 5+ messages in thread
From: Ivan Malov @ 2026-08-11 17:49 UTC (permalink / raw)
To: dev
Cc: Andy Moreton, Viacheslav Galaktionov, Roman Zhukov,
Pieter Jansen van Vuuren, Stephen Hemminger, Andrew Rybchenko
From: Andy Moreton <andy.moreton@amd.com>
Support for VADAPTER stats requires passing the EVB port handle.
Use GET_NETPORT_STATISTICS_V2 to do that.
Also for clarity adjust the argument order for efx_np_mac_stats
to match the legacy efx_mcdi_mac_stats.
Signed-off-by: Andy Moreton <andy.moreton@amd.com>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
---
drivers/common/sfc_efx/base/efx_impl.h | 3 ++-
drivers/common/sfc_efx/base/efx_mcdi.c | 2 +-
drivers/common/sfc_efx/base/efx_np.c | 15 ++++++++++++---
drivers/common/sfc_efx/base/medford4_mac.c | 12 +++++++-----
4 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index c91fbbb61b..6dc7ca870d 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -1988,8 +1988,9 @@ extern __checkReturn efx_rc_t
efx_np_mac_stats(
__in efx_nic_t *enp,
__in efx_np_handle_t nph,
- __in efx_stats_action_t action,
+ __in uint32_t vport_id,
__in_opt const efsys_mem_t *esmp,
+ __in efx_stats_action_t action,
__in uint16_t period_ms);
#endif /* EFSYS_OPT_MAC_STATS */
diff --git a/drivers/common/sfc_efx/base/efx_mcdi.c b/drivers/common/sfc_efx/base/efx_mcdi.c
index 8f14f38cdc..f8306460fa 100644
--- a/drivers/common/sfc_efx/base/efx_mcdi.c
+++ b/drivers/common/sfc_efx/base/efx_mcdi.c
@@ -2250,7 +2250,7 @@ efx_mcdi_mac_stats_clear(
if (efx_np_supported(enp) != B_FALSE) {
rc = efx_np_mac_stats(enp, epp->ep_np_handle,
- EFX_STATS_CLEAR, NULL, 0);
+ enp->en_vport_id, NULL, EFX_STATS_CLEAR, 0);
} else {
rc = efx_mcdi_mac_stats(enp, enp->en_vport_id, NULL,
EFX_STATS_CLEAR, 0);
diff --git a/drivers/common/sfc_efx/base/efx_np.c b/drivers/common/sfc_efx/base/efx_np.c
index 816affce2d..5f5ec86647 100644
--- a/drivers/common/sfc_efx/base/efx_np.c
+++ b/drivers/common/sfc_efx/base/efx_np.c
@@ -1603,12 +1603,13 @@ efx_np_mac_ctrl(
efx_np_mac_stats(
__in efx_nic_t *enp,
__in efx_np_handle_t nph,
- __in efx_stats_action_t action,
+ __in uint32_t vport_id,
__in_opt const efsys_mem_t *esmp,
+ __in efx_stats_action_t action,
__in uint16_t period_ms)
{
EFX_MCDI_DECLARE_BUF(payload,
- MC_CMD_GET_NETPORT_STATISTICS_IN_LEN,
+ MC_CMD_GET_NETPORT_STATISTICS_V2_IN_LEN,
MC_CMD_GET_NETPORT_STATISTICS_OUT_LENMIN);
boolean_t enable = (action == EFX_STATS_ENABLE_NOEVENTS);
boolean_t events = (action == EFX_STATS_ENABLE_EVENTS);
@@ -1619,7 +1620,7 @@ efx_np_mac_stats(
efx_rc_t rc;
req.emr_out_length = MC_CMD_GET_NETPORT_STATISTICS_OUT_LENMIN;
- req.emr_in_length = MC_CMD_GET_NETPORT_STATISTICS_IN_LEN;
+ req.emr_in_length = MC_CMD_GET_NETPORT_STATISTICS_V2_IN_LEN;
req.emr_cmd = MC_CMD_GET_NETPORT_STATISTICS;
req.emr_out_buf = payload;
req.emr_in_buf = payload;
@@ -1661,6 +1662,14 @@ efx_np_mac_stats(
MCDI_IN_SET_DWORD(req, GET_NETPORT_STATISTICS_IN_DMA_LEN, sz);
}
+ /*
+ * NOTE: Do not use EVB_PORT_ID_ASSIGNED when disabling periodic stats,
+ * as this may fail (and leave periodic DMA enabled) if the
+ * vadapter has already been deleted.
+ */
+ MCDI_IN_SET_DWORD(req, GET_NETPORT_STATISTICS_V2_IN_PORT_ID,
+ (disable ? EVB_PORT_ID_NULL : vport_id));
+
efx_mcdi_execute(enp, &req);
if (req.emr_rc != 0) {
diff --git a/drivers/common/sfc_efx/base/medford4_mac.c b/drivers/common/sfc_efx/base/medford4_mac.c
index 8ef84c69c6..b6000cf6b9 100644
--- a/drivers/common/sfc_efx/base/medford4_mac.c
+++ b/drivers/common/sfc_efx/base/medford4_mac.c
@@ -172,8 +172,8 @@ medford4_mac_stats_upload(
efx_port_t *epp = &(enp->en_port);
efx_rc_t rc;
- rc = efx_np_mac_stats(enp,
- epp->ep_np_handle, EFX_STATS_UPLOAD, esmp, 0);
+ rc = efx_np_mac_stats(enp, epp->ep_np_handle, enp->en_vport_id,
+ esmp, EFX_STATS_UPLOAD, 0);
if (rc != 0)
goto fail1;
@@ -196,13 +196,15 @@ medford4_mac_stats_periodic(
if (period_ms == 0) {
rc = efx_np_mac_stats(enp, epp->ep_np_handle,
- EFX_STATS_DISABLE, NULL, 0);
+ enp->en_vport_id, NULL, EFX_STATS_DISABLE, 0);
} else if (events != B_FALSE) {
rc = efx_np_mac_stats(enp, epp->ep_np_handle,
- EFX_STATS_ENABLE_EVENTS, esmp, period_ms);
+ enp->en_vport_id, esmp, EFX_STATS_ENABLE_EVENTS,
+ period_ms);
} else {
rc = efx_np_mac_stats(enp, epp->ep_np_handle,
- EFX_STATS_ENABLE_NOEVENTS, esmp, period_ms);
+ enp->en_vport_id, esmp, EFX_STATS_ENABLE_NOEVENTS,
+ period_ms);
}
if (rc != 0)
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 0/3] common/sfc_efx/base: add VADAPTER statistics for Medford4
2026-08-11 17:49 [PATCH 0/3] common/sfc_efx/base: add VADAPTER statistics for Medford4 Ivan Malov
` (2 preceding siblings ...)
2026-08-11 17:49 ` [PATCH 3/3] common/sfc_efx/base: switch netport stats to use EVB port ID Ivan Malov
@ 2026-08-11 20:31 ` Stephen Hemminger
3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2026-08-11 20:31 UTC (permalink / raw)
To: Ivan Malov
Cc: dev, Andy Moreton, Viacheslav Galaktionov, Roman Zhukov,
Pieter Jansen van Vuuren, Andrew Rybchenko
On Tue, 11 Aug 2026 21:49:46 +0400
Ivan Malov <ivan.malov@arknetworks.am> wrote:
> This series adds support for per-VF (VADAPTER) MAC
> statistics on Medford4 in the libefx base layer.
>
> The first patch selectively updates the MCDI headers, adding
> new definitions needed by the subsequent patches.
>
> The second patch introduces netport VADAPTER statistics IDs,
> which identify the per-VF counter set returned by the NIC.
>
> The third patch switches the netport statistics call to use
> GET_NETPORT_STATISTICS_V2, passing the EVB port handle so
> that the correct per-VF counters are retrieved.
>
> Andy Moreton (2):
> common/sfc_efx/base: add support for VADAPTER statistics IDs
> common/sfc_efx/base: switch netport stats to use EVB port ID
>
> Ivan Malov (1):
> common/sfc_efx/base: update MCDI headers
>
> drivers/common/sfc_efx/base/efx_impl.h | 3 +-
> drivers/common/sfc_efx/base/efx_mcdi.c | 2 +-
> drivers/common/sfc_efx/base/efx_np.c | 60 +++-
> drivers/common/sfc_efx/base/efx_regs_mcdi.h | 313 +++++++++++++++++++-
> drivers/common/sfc_efx/base/medford4_mac.c | 12 +-
> 5 files changed, 373 insertions(+), 17 deletions(-)
>
Detailed AI review had info level comments only.
Reviewed the series against upstream (applied cleanly with git am).
Patch 1 is generated MCDI header import, no review comments.
Patch 2/3 verification notes:
- All five efx_np_mac_stats() call sites are updated for the new
argument order (efx_mcdi.c:2251, medford4_mac.c:175/198/201/205).
The parameter count changed from 5 to 6, so a missed caller would
be a compile error rather than a silent type-compatible swap.
- EFX_MCDI_DECLARE_BUF() was correctly bumped to V2_IN_LEN alongside
emr_in_length, so the new PORT_ID write at offset 20 is in bounds.
- MC_CMD_GET_NETPORT_STATISTICS_V2_IN is a strict superset of V1:
PORT_HANDLE/CMD/DMA_ADDR/DMA_LEN are at identical offsets, only
PORT_ID at 20 is new.
- The new VADAPTER entries in efx_np_mac_stat_map[] land before the
FEC entries in efx_mac_stat_t, so the array size is unchanged, and
the map is only consulted to translate descriptors the FW actually
reports, so the addition is inert on FW without vadapter stats.
efx_mac.c already has the matching name strings, and
medford4_mac_stats_get_mask() derives the mask from the LUT, so the
counters surface automatically.
Info
Patch 2:
- EFX_NP_HW_STAT_ID() shifts the index by
MC_CMD_STAT_ID_MAC_STAT_ID_LBN regardless of the source argument.
This is correct today only because MAC/PHY/VADAPTER_STAT_ID_LBN are
all 16. Using MC_CMD_STAT_ID_##_src##_STAT_ID_LBN would make the
macro self-consistent. Pre-existing (the PHY variant has the same
shape), so no need to fix here unless you are touching it anyway.
Patch 3:
- The request mixes V1 and V2 field names: PORT_HANDLE, CMD,
DMA_ADDR_LO/HI and DMA_LEN still use the
GET_NETPORT_STATISTICS_IN_* names while the length and PORT_ID use
GET_NETPORT_STATISTICS_V2_IN_*. The offsets are identical so this
is functionally correct, but naming all fields V2 would make it
obvious at a glance which msgrequest is being sent.
- The V2 request length is now used unconditionally, with no
capability check or V1 fallback. If any shipping Medford4 firmware
implements only the 20-byte GET_NETPORT_STATISTICS_IN msgrequest,
it will reject the 24-byte request and MAC stats break entirely,
not just the vadapter counters. Is V2 guaranteed present in every
FW build that advertises netport support? efx_np_mac_ctrl() already
makes the same unconditional assumption with MAC_CTRL_IN_V2, so I
suspect the answer is yes and there is a documented FW baseline --
worth a line in the commit message either way.
^ permalink raw reply [flat|nested] 5+ messages in thread