[PATCH v5 12/14] net/enetc4: update VF link status to bitmask encoding

Gagandeep Singh g.singh at nxp.com
Mon Aug 10 12:48:13 CEST 2026


The PF-to-VF link status notification code was previously a two-value
enum (UP=0x0, DOWN=0x1). Change this to a bitmask so future bits can
carry additional state alongside the link up/down indication:

  ENETC_LINK_DOWN  BIT(0)  -- set when link is down

Link up is now encoded as the DOWN bit being clear, which keeps the
wire value for link-down identical (0x1) and ensures backward
compatibility with older kernel PFs.

Changes:
- enetc.h: replace enum link_status with a #define bitmask;
  drop ENETC_LINK_UP (no longer a named constant).
- enetc4_vf.c enetc4_process_psi_msg(): replace switch/case on
  ENETC_LINK_UP/DOWN with bitmask decode.
- enetc4_vf.c enetc4_vf_link_update(): same bitmask decode.

Signed-off-by: Gagandeep Singh <g.singh at nxp.com>
---
 doc/guides/rel_notes/release_26_11.rst |  1 +
 drivers/net/enetc/enetc.h              |  8 ++++----
 drivers/net/enetc/enetc4_vf.c          | 27 +++++++-------------------
 3 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 190d77ecee..47090068d0 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -73,6 +73,7 @@ New Features
   * Added stats reset for the ENETC4 VF using a software snapshot/delta approach.
   * Added per-queue MSI-X Rx interrupt support for the ENETC4 VF.
   * Added SI-based port VLAN insertion (Tx) and removal (Rx) for ENETC4 PF and VF.
+  * Updated ENETC4 VF link status reporting to use bitmask encoding.
 
 Removed Items
 -------------
diff --git a/drivers/net/enetc/enetc.h b/drivers/net/enetc/enetc.h
index 6cabef000e..d4d39737ec 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -235,10 +235,10 @@ enum vlan_status {
 	ENETC_VLAN_NO_RESOURCE = 0x3
 };
 
-enum link_status {
-	ENETC_LINK_UP = 0x0,
-	ENETC_LINK_DOWN = 0x1
-};
+/* Link status bitmask in PF-to-VF mailbox notification.
+ * Link up is encoded as the DOWN bit being clear.
+ */
+#define ENETC_LINK_DOWN  (1u << 0)
 
 enum speed {
 	ENETC_SPEED_UNKNOWN = 0x0,
diff --git a/drivers/net/enetc/enetc4_vf.c b/drivers/net/enetc/enetc4_vf.c
index 9b03d91ca4..3bdd032dba 100644
--- a/drivers/net/enetc/enetc4_vf.c
+++ b/drivers/net/enetc/enetc4_vf.c
@@ -510,8 +510,10 @@ enetc4_process_psi_msg(struct rte_eth_dev *eth_dev, struct enetc_hw *enetc_hw)
 	enetc4_msg_get_psi_msg(enetc_hw, msg);
 
 	if (msg->class_id == ENETC_CLASS_ID_LINK_STATUS) {
-		switch (msg->status) {
-		case ENETC_LINK_UP:
+		if (msg->status & ENETC_LINK_DOWN) {
+			ENETC_PMD_DEBUG("Link is down");
+			link.link_status = RTE_ETH_LINK_DOWN;
+		} else {
 			ENETC_PMD_DEBUG("Link is up");
 			link.link_status = RTE_ETH_LINK_UP;
 			/* Re-query speed from PF so the cached value reflects
@@ -528,14 +530,6 @@ enetc4_process_psi_msg(struct rte_eth_dev *eth_dev, struct enetc_hw *enetc_hw)
 			} else {
 				ENETC_PMD_WARN("Failed to alloc msg for speed query");
 			}
-			break;
-		case ENETC_LINK_DOWN:
-			ENETC_PMD_DEBUG("Link is down");
-			link.link_status = RTE_ETH_LINK_DOWN;
-			break;
-		default:
-			ENETC_PMD_ERR("Unknown link status 0x%x", msg->status);
-			break;
 		}
 		ret = rte_eth_linkstatus_set(eth_dev, &link);
 		if (!ret)
@@ -1208,17 +1202,10 @@ enetc4_vf_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused
 	}
 
 	if (reply_msg->class_id == ENETC_CLASS_ID_LINK_STATUS) {
-		switch (reply_msg->status) {
-		case ENETC_LINK_UP:
-			link.link_status = RTE_ETH_LINK_UP;
-			break;
-		case ENETC_LINK_DOWN:
+		if (reply_msg->status & ENETC_LINK_DOWN)
 			link.link_status = RTE_ETH_LINK_DOWN;
-			break;
-		default:
-			ENETC_PMD_ERR("Unknown link status");
-			break;
-		}
+		else
+			link.link_status = RTE_ETH_LINK_UP;
 	} else {
 		ENETC_PMD_ERR("Wrong reply message");
 		return -1;
-- 
2.25.1



More information about the dev mailing list