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 <[email protected]>
---
 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 e6d96b2a50..5323f4fea3 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -71,6 +71,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 72e43572f7..40bad56341 100644
--- a/drivers/net/enetc/enetc.h
+++ b/drivers/net/enetc/enetc.h
@@ -236,10 +236,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 fc5ea4d609..1b93835dd7 100644
--- a/drivers/net/enetc/enetc4_vf.c
+++ b/drivers/net/enetc/enetc4_vf.c
@@ -480,8 +480,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
@@ -498,14 +500,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)
@@ -1180,17 +1174,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

Reply via email to