* [PATCH net v3 1/3] net: txgbe: initialize module info buffer
2026-06-08 7:08 [PATCH net v3 0/3] net: txgbe: fix module identification Jiawen Wu
@ 2026-06-08 7:08 ` Jiawen Wu
2026-06-08 7:08 ` [PATCH net v3 2/3] net: txgbe: distinguish module types by checking identifier Jiawen Wu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Jiawen Wu @ 2026-06-08 7:08 UTC (permalink / raw)
To: netdev
Cc: Mengyuan Lou, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Larysa Zaremba,
Fabio Baltieri, Jiawen Wu
The module info buffer should be initialized to 0 before the firmware
returns information. Otherwise, there is a risk that the buffer field
not filled by the firmware is random value.
Fixes: 343929799ace ("net: txgbe: Support to handle GPIO IRQs for AML devices")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
index f0514251d4f3..a7e81f9e1be1 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
@@ -335,7 +335,7 @@ static int txgbe_qsfp_to_linkmodes(struct wx *wx, struct txgbe_sff_id *id)
int txgbe_identify_module(struct wx *wx)
{
- struct txgbe_hic_get_module_info buffer;
+ struct txgbe_hic_get_module_info buffer = { 0 };
struct txgbe_sff_id *id;
int err = 0;
u32 mod_abs;
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net v3 2/3] net: txgbe: distinguish module types by checking identifier
2026-06-08 7:08 [PATCH net v3 0/3] net: txgbe: fix module identification Jiawen Wu
2026-06-08 7:08 ` [PATCH net v3 1/3] net: txgbe: initialize module info buffer Jiawen Wu
@ 2026-06-08 7:08 ` Jiawen Wu
2026-06-08 7:08 ` [PATCH net v3 3/3] net: txgbe: initialize PHY interface to 0 Jiawen Wu
2026-06-11 9:10 ` [PATCH net v3 0/3] net: txgbe: fix module identification patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Jiawen Wu @ 2026-06-08 7:08 UTC (permalink / raw)
To: netdev
Cc: Mengyuan Lou, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Larysa Zaremba,
Fabio Baltieri, Jiawen Wu
Rework txgbe_identify_module() to validate module identifiers through
explicit type checks instead of relying on transceiver_type heuristics.
When using the SFP module, transceiver_type could be a random value,
because it was read from an invalid register.
Fixes: 57d39faed4c9 ("net: txgbe: improve functions of AML 40G devices")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
index a7e81f9e1be1..bdac654a2364 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
@@ -357,18 +357,16 @@ int txgbe_identify_module(struct wx *wx)
}
id = &buffer.id;
- if (id->identifier != TXGBE_SFF_IDENTIFIER_SFP &&
- id->identifier != TXGBE_SFF_IDENTIFIER_QSFP &&
- id->identifier != TXGBE_SFF_IDENTIFIER_QSFP_PLUS &&
- id->identifier != TXGBE_SFF_IDENTIFIER_QSFP28) {
- wx_err(wx, "Invalid module\n");
- return -ENODEV;
- }
-
- if (id->transceiver_type == 0xFF)
+ if (id->identifier == TXGBE_SFF_IDENTIFIER_SFP)
return txgbe_sfp_to_linkmodes(wx, id);
- return txgbe_qsfp_to_linkmodes(wx, id);
+ if (id->identifier == TXGBE_SFF_IDENTIFIER_QSFP ||
+ id->identifier == TXGBE_SFF_IDENTIFIER_QSFP_PLUS ||
+ id->identifier == TXGBE_SFF_IDENTIFIER_QSFP28)
+ return txgbe_qsfp_to_linkmodes(wx, id);
+
+ wx_err(wx, "Invalid module\n");
+ return -EINVAL;
}
void txgbe_setup_link(struct wx *wx)
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net v3 3/3] net: txgbe: initialize PHY interface to 0
2026-06-08 7:08 [PATCH net v3 0/3] net: txgbe: fix module identification Jiawen Wu
2026-06-08 7:08 ` [PATCH net v3 1/3] net: txgbe: initialize module info buffer Jiawen Wu
2026-06-08 7:08 ` [PATCH net v3 2/3] net: txgbe: distinguish module types by checking identifier Jiawen Wu
@ 2026-06-08 7:08 ` Jiawen Wu
2026-06-11 9:10 ` [PATCH net v3 0/3] net: txgbe: fix module identification patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Jiawen Wu @ 2026-06-08 7:08 UTC (permalink / raw)
To: netdev
Cc: Mengyuan Lou, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Larysa Zaremba,
Fabio Baltieri, Jiawen Wu
DECLARE_PHY_INTERFACE_MASK() does not guarantee zeroed contents. Add a
new macro DECLARE_PHY_INTERFACE_MASK_ZERO(), make the stack variable to
be zeroed before setting supported interfaces.
Fixes: 57d39faed4c9 ("net: txgbe: improve functions of AML 40G devices")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c | 4 ++--
drivers/net/ethernet/wangxun/txgbe/txgbe_type.h | 3 +++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
index bdac654a2364..8fc32df8e49a 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
@@ -204,7 +204,7 @@ int txgbe_set_phy_link(struct wx *wx)
static int txgbe_sfp_to_linkmodes(struct wx *wx, struct txgbe_sff_id *id)
{
__ETHTOOL_DECLARE_LINK_MODE_MASK(modes) = { 0, };
- DECLARE_PHY_INTERFACE_MASK(interfaces);
+ DECLARE_PHY_INTERFACE_MASK_ZERO(interfaces);
struct txgbe *txgbe = wx->priv;
if (id->cable_tech & TXGBE_SFF_DA_PASSIVE_CABLE) {
@@ -271,7 +271,7 @@ static int txgbe_sfp_to_linkmodes(struct wx *wx, struct txgbe_sff_id *id)
static int txgbe_qsfp_to_linkmodes(struct wx *wx, struct txgbe_sff_id *id)
{
__ETHTOOL_DECLARE_LINK_MODE_MASK(modes) = { 0, };
- DECLARE_PHY_INTERFACE_MASK(interfaces);
+ DECLARE_PHY_INTERFACE_MASK_ZERO(interfaces);
struct txgbe *txgbe = wx->priv;
if (id->transceiver_type & TXGBE_SFF_ETHERNET_40G_CR4) {
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
index 6b05f32b4a01..877234e3fdc2 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
@@ -315,6 +315,9 @@ void txgbe_up(struct wx *wx);
int txgbe_setup_tc(struct net_device *dev, u8 tc);
void txgbe_do_reset(struct net_device *netdev);
+#define DECLARE_PHY_INTERFACE_MASK_ZERO(name) \
+ unsigned long name[PHY_INTERFACE_MODE_MAX] = { 0, }
+
#define TXGBE_LINK_SPEED_UNKNOWN 0
#define TXGBE_LINK_SPEED_10GB_FULL 4
#define TXGBE_LINK_SPEED_25GB_FULL 0x10
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net v3 0/3] net: txgbe: fix module identification
2026-06-08 7:08 [PATCH net v3 0/3] net: txgbe: fix module identification Jiawen Wu
` (2 preceding siblings ...)
2026-06-08 7:08 ` [PATCH net v3 3/3] net: txgbe: initialize PHY interface to 0 Jiawen Wu
@ 2026-06-11 9:10 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-11 9:10 UTC (permalink / raw)
To: Jiawen Wu
Cc: netdev, mengyuanlou, andrew+netdev, davem, edumazet, kuba, pabeni,
horms, larysa.zaremba, fabio.baltieri
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Mon, 8 Jun 2026 15:08:39 +0800 you wrote:
> For AML devices, there are some issues where the wrong module
> indentified then configure PHY failed.
>
> The module info buffers should be initialized to 0 before the firmware
> returns information. And DECLARE_PHY_INTERFACE_MASK() does not guarantee
> zeroed contents, so explicitly clear the temporary interface masks before
> setting supported interfaces.
>
> [...]
Here is the summary with links:
- [net,v3,1/3] net: txgbe: initialize module info buffer
https://git.kernel.org/netdev/net/c/0487cfca4651
- [net,v3,2/3] net: txgbe: distinguish module types by checking identifier
https://git.kernel.org/netdev/net/c/f2df54ddbfb0
- [net,v3,3/3] net: txgbe: initialize PHY interface to 0
https://git.kernel.org/netdev/net/c/47f848aac4e7
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread