* [PATCH net] net: txgbe: fix module identification
@ 2026-06-02 2:54 Jiawen Wu
2026-06-02 13:14 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: Jiawen Wu @ 2026-06-02 2:54 UTC (permalink / raw)
To: netdev
Cc: Mengyuan Lou, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Russell King, Simon Horman,
Jiawen Wu
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.
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>
---
.../net/ethernet/wangxun/txgbe/txgbe_aml.c | 22 +++++++++----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
index da1d3976ed33..e0beba075e76 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
@@ -203,6 +203,7 @@ static int txgbe_sfp_to_linkmodes(struct wx *wx, struct txgbe_sff_id *id)
DECLARE_PHY_INTERFACE_MASK(interfaces);
struct txgbe *txgbe = wx->priv;
+ phy_interface_zero(interfaces);
if (id->cable_tech & TXGBE_SFF_DA_PASSIVE_CABLE) {
txgbe->link_port = PORT_DA;
phylink_set(modes, Autoneg);
@@ -270,6 +271,7 @@ static int txgbe_qsfp_to_linkmodes(struct wx *wx, struct txgbe_sff_id *id)
DECLARE_PHY_INTERFACE_MASK(interfaces);
struct txgbe *txgbe = wx->priv;
+ phy_interface_zero(interfaces);
if (id->transceiver_type & TXGBE_SFF_ETHERNET_40G_CR4) {
txgbe->link_port = PORT_DA;
phylink_set(modes, Autoneg);
@@ -331,7 +333,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;
@@ -353,18 +355,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 -EINVAL;
- }
-
- 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] 3+ messages in thread* Re: [PATCH net] net: txgbe: fix module identification
2026-06-02 2:54 [PATCH net] net: txgbe: fix module identification Jiawen Wu
@ 2026-06-02 13:14 ` Andrew Lunn
2026-06-03 3:19 ` Jiawen Wu
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2026-06-02 13:14 UTC (permalink / raw)
To: Jiawen Wu
Cc: netdev, Mengyuan Lou, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Russell King, Simon Horman
On Tue, Jun 02, 2026 at 10:54:43AM +0800, Jiawen Wu 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.
>
> 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.
This seems like multiple fixes. Please break the patch up.
The current DECLARE_PHY_INTERFACE_MASK() is not great. It is mostly
used by phylink in structures which get allocated and zeroed. But here
you have it as a stack variable. Maybe we want a new variant which
includes = {} ?
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread* RE: [PATCH net] net: txgbe: fix module identification
2026-06-02 13:14 ` Andrew Lunn
@ 2026-06-03 3:19 ` Jiawen Wu
0 siblings, 0 replies; 3+ messages in thread
From: Jiawen Wu @ 2026-06-03 3:19 UTC (permalink / raw)
To: 'Andrew Lunn'
Cc: netdev, 'Mengyuan Lou', 'Andrew Lunn',
'David S. Miller', 'Eric Dumazet',
'Jakub Kicinski', 'Paolo Abeni',
'Russell King', 'Simon Horman', netdev,
'Mengyuan Lou', 'Andrew Lunn',
'David S. Miller', 'Eric Dumazet',
'Jakub Kicinski', 'Paolo Abeni',
'Russell King', 'Simon Horman'
On Tue, Jun 2, 2026 9:15 PM, Andrew Lunn wrote:
> On Tue, Jun 02, 2026 at 10:54:43AM +0800, Jiawen Wu 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.
> >
> > 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.
>
> This seems like multiple fixes. Please break the patch up.
OK.
> The current DECLARE_PHY_INTERFACE_MASK() is not great. It is mostly
> used by phylink in structures which get allocated and zeroed. But here
> you have it as a stack variable. Maybe we want a new variant which
> includes = {} ?
I'll change it to:
unsigned long interfaces[PHY_INTERFACE_MODE_MAX] = {};
If PHYLINK could optimize DECLARE_PHY_INTERFACE_MASK(), it would be better.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-03 3:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-02 2:54 [PATCH net] net: txgbe: fix module identification Jiawen Wu
2026-06-02 13:14 ` Andrew Lunn
2026-06-03 3:19 ` Jiawen Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox