[PATCH net-next v3] net: wangxun: use cached NCSI and WOL capability flags
From: Jiawen Wu <jiawenwu@trustnetic.com>
Date: 2026-09-16 06:34:46
Subsystem:
networking drivers, the rest, wangxun ethernet driver · Maintainers:
Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds, Jiawen Wu, Mengyuan Lou
wx_disable_rx() and txgbe_disable_device() open-code the same subsystem
device ID tests to decide whether the MAC receiver and transmitter have
to stay enabled for out-of-band management:
(subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP ||
(subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP
ngbe_init_type_code() already decodes the subsystem device ID into
wx->ncsi_enabled and wx->wol_hw_supported. Do the same in
txgbe_init_type_code() and let both call sites test the cached flags, so
that each driver decides the capability once while probing instead of
having shared code re-derive it from raw IDs.
This is not equivalent for ngbe, and that is intentional.
wx->ncsi_enabled has never been read since it was added by commit
02338c484ab6 ("net: ngbe: Initialize sw info and register netdev"), and
it is wider than the inline test:
wx->ncsi_enabled = (ncsi_mask == WX_NCSI_SUP ||
type_mask == NGBE_SUBID_OCP_CARD) ? 1 : 0;
OCP mezzanine cards are NCSI capable by design, so the NCSI semantics do
apply to them, and they need the MAC receiver to keep running for
out-of-band management. The inline test does not cover the OCP card
type, so on such a card that does not have the NCSI bit set the receiver
was turned off on every path reaching wx_disable_rx(), i.e.
ngbe_disable_device() on ifdown, wx_stop_adapter() from ngbe_reset_hw()
and wx_configure_rx(), and management traffic was dropped. Reading
ncsi_enabled keeps the receiver enabled on these cards.
No Fixes: tag is added on purpose. The broken behaviour goes back to the
initial ngbe support in v6.2, and wx_disable_rx() has since been moved
into libwx and reworked several times, so this does not cherry-pick into
stable kernels in any useful form.
For txgbe both flags are newly initialized, but wol_hw_supported is only
consumed by txgbe_disable_device() there - txgbe does not implement the
WoL ethtool ops - so txgbe behaviour is unchanged.
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
v3:
- Rewritting commit message.
v2: https://lore.kernel.org/all/F76F75E3FFF42A39+20260908025416.42250-1-jiawenwu@trustnetic.com (local)
- Remove single-use locals.
- Describe the behavior change on ngbe OCP cards.
v1: https://lore.kernel.org/all/95D34449BA183C54+20260901070238.78509-1-jiawenwu@trustnetic.com (local)
---
drivers/net/ethernet/wangxun/libwx/wx_hw.c | 3 +--
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 6 ++++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_hw.c b/drivers/net/ethernet/wangxun/libwx/wx_hw.c
index 111aadf79208..2490c4dd548f 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_hw.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_hw.c@@ -1313,8 +1313,7 @@ void wx_disable_rx(struct wx *wx) rxctrl &= ~WX_RDB_PB_CTL_RXEN; wr32(wx, WX_RDB_PB_CTL, rxctrl); - if (!(((wx->subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP) || - ((wx->subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP))) { + if (!(wx->ncsi_enabled || wx->wol_hw_supported)) { /* disable mac receiver */ wr32m(wx, WX_MAC_RX_CFG, WX_MAC_RX_CFG_RE, 0);
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
index eb91c4f28ecd..0ecbd1c0e553 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c@@ -267,8 +267,7 @@ static void txgbe_disable_device(struct wx *wx) wx_set_all_vfs(wx); } - if (!(((wx->subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP) || - ((wx->subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP))) { + if (!(wx->ncsi_enabled || wx->wol_hw_supported)) { /* disable mac transmiter */ wr32m(wx, WX_MAC_TX_CFG, WX_MAC_TX_CFG_TE, 0); }
@@ -381,6 +380,9 @@ static void txgbe_init_type_code(struct wx *wx) wx->media_type = wx_media_unknown; break; } + + wx->wol_hw_supported = ((wx->subsystem_device_id & WX_WOL_MASK) == WX_WOL_SUP); + wx->ncsi_enabled = ((wx->subsystem_device_id & WX_NCSI_MASK) == WX_NCSI_SUP); } /**
--
2.51.0