net: lan743x: cleanup netdev-based logging
Subsystems (3)
v2 cover net: lan743x: cleanup netdev-based logging
This series improves netdev-based logging in the lan743x driver by addressing the issue where several log entries at boot include the warning "(unnamed net_device) (uninitialized)".
The first patch introduces a "message level" module parameter and uses netif_msg_init(), allowing msg_enable to be configured at load time.
The second patch ensures that netdev-based logging is only used after netdev registration has completed successfully.
v2:
- Added patch 1
- Changed target repo from "net" to "net-next"
David Thompson (2):
net: lan743x: add "message level" module parameter
net: lan743x: avoid netdev-based logging before netdev registration
drivers/net/ethernet/microchip/lan743x_main.c | 87 ++++++++++++------- 1 file changed, 57 insertions(+), 30 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 net: lan743x: add "message level" module parameter
The lan743x driver currently hardcodes the initial value of the msg_enable parameter during probe(), and uses this value for netdev message logging. Instead, the driver should provide a "message level" module parameter to allow users to configure the logging level at load time.
---
v2:
- new patch added in v2
--- drivers/net/ethernet/microchip/lan743x_main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +12 -3
@@ -28,6 +28,17 @@#define RFE_RD_FIFO_TH_3_DWORDS 0x3 +#define LAN743X_DEF_MSG_ENABLE \ + (NETIF_MSG_DRV | \ + NETIF_MSG_PROBE | \ + NETIF_MSG_LINK | \ + NETIF_MSG_IFUP | \ + NETIF_MSG_IFDOWN | \ + NETIF_MSG_TX_QUEUED) +static int lan743x_msg_enable =-1 ; +module_param (lan743x_msg_enable, int,0 ); +MODULE_PARM_DESC (lan743x_msg_enable,"Debug message level" ); +static bool pci11x1x_is_a0 (struct lan743x_adapter *adapter) {u32 dev_rev = adapter->csr.id_rev &ID_REV_CHIP_REV_MASK_ ;
@@ -3661,9 +3672,7 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,pci_set_drvdata (pdev, netdev); adapter =netdev_priv (netdev); adapter->netdev = netdev; - adapter->msg_enable =NETIF_MSG_DRV |NETIF_MSG_PROBE | -NETIF_MSG_LINK |NETIF_MSG_IFUP | -NETIF_MSG_IFDOWN |NETIF_MSG_TX_QUEUED ; + adapter->msg_enable =netif_msg_init (lan743x_msg_enable,LAN743X_DEF_MSG_ENABLE ); netdev->max_mtu =LAN743X_MAX_FRAME_SIZE ;of_get_mac_address (pdev->dev.of_node, adapter->mac_address);
Signature · 1 line
2.43.0
Re: [PATCH net-next v2 1/2] net: lan743x: add "message level" module parameter
Quoted 22 lines · David Thompson
The lan743x driver currently hardcodes the initial value of the
msg_enableparameter duringprobe(), and uses this value for netdev message logging. Instead, the driver should provide a "message level" module parameter to allow users to configure the logging level at load time.Signed-off-by David Thompson <[email protected]>---
v2:
- new patch added in v2--- drivers/net/ethernet/microchip/lan743x_main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/net/ethernet/microchip/lan743x_main.c +1
-0@@ -28,6 +28,17 @@#define RFE_RD_FIFO_TH_3_DWORDS 0x3 +#define LAN743X_DEF_MSG_ENABLE \
drivers/net/ethernet/microchip/lan743x_main.c line 41
Quoted 10 lines
drivers/net/ethernet/microchip/lan743x_main.c +10
-0+ (NETIF_MSG_DRV | \ +NETIF_MSG_PROBE | \ +NETIF_MSG_LINK | \ +NETIF_MSG_IFUP | \ +NETIF_MSG_IFDOWN | \ + NETIF_MSG_TX_QUEUED) +static int lan743x_msg_enable =-1 ; +module_param (lan743x_msg_enable, int,0 ); +MODULE_PARM_DESC (lan743x_msg_enable,"Debug message level" ); +
I guess many drivers have msg_enable parameters already so this isn't "new", but the netdev maintainers have frowned on adding any module parameters for years.
You could handle this by just always using the dynamic debug capability instead of the netdev msg_enable infrastructure, but the driver does already use this infrastructure heavily, so I guess it makes sense to expose it and allow changing the settings during early init prior to when the netdevice is available to userspace..
Since this is a relatively common module parameter and not something "new" or trying to do anything other than aid in debugging I suppose this is likely acceptable.
Thanks,
Jake
Quoted 14 lines
drivers/net/ethernet/microchip/lan743x_main.c +1
-3static bool pci11x1x_is_a0 (struct lan743x_adapter *adapter) {u32 dev_rev = adapter->csr.id_rev &ID_REV_CHIP_REV_MASK_ ;@@ -3661,9 +3672,7 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,pci_set_drvdata (pdev, netdev); adapter =netdev_priv (netdev); adapter->netdev = netdev; - adapter->msg_enable =NETIF_MSG_DRV |NETIF_MSG_PROBE | -NETIF_MSG_LINK |NETIF_MSG_IFUP | -NETIF_MSG_IFDOWN |NETIF_MSG_TX_QUEUED ; + adapter->msg_enable =netif_msg_init (lan743x_msg_enable,LAN743X_DEF_MSG_ENABLE ); netdev->max_mtu =LAN743X_MAX_FRAME_SIZE ;of_get_mac_address (pdev->dev.of_node, adapter->mac_address);
RE: [PATCH net-next v2 1/2] net: lan743x: add "message level" module parameter
Quoted 37 lines
-----Original Message-----
From: Jacob Keller <[email protected]>
Sent: Wednesday, May 27, 2026 4:36 PM
To: David Thompson <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH net-next v2 1/2] net: lan743x: add "message level" module parameterQuoted 2 lines · David Thompson
The lan743x driver currently hardcodes the initial value of the
msg_enableparameter duringprobe(), and uses this value for netdevmessage logging.
Quoted 20 lines
Instead, the driver should provide a "message level" module parameter to allow users to configure the logging level at load time.
Signed-off-by David Thompson <[email protected]>---
v2:
- new patch added in v2--- drivers/net/ethernet/microchip/lan743x_main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/net/ethernet/microchip/lan743x_main.c +0
-0@@ -28,6 +28,17 @@#define RFE_RD_FIFO_TH_3_DWORDS 0x3
Quoted 16 lines
drivers/net/ethernet/microchip/lan743x_main.c line 41
Quoted 11 lines
drivers/net/ethernet/microchip/lan743x_main.c +11
-0+#define LAN743X_DEF_MSG_ENABLE \ + (NETIF_MSG_DRV | \ + NETIF_MSG_PROBE | \ + NETIF_MSG_LINK | \ + NETIF_MSG_IFUP | \ + NETIF_MSG_IFDOWN | \ + NETIF_MSG_TX_QUEUED) +static int lan743x_msg_enable =-1 ; +module_param (lan743x_msg_enable, int,0 ); +MODULE_PARM_DESC (lan743x_msg_enable,"Debug message level" ); +I guess many drivers have
msg_enableparameters already so this isn't "new", but the netdev maintainers have frowned on adding any module parameters for years.
This patch has received two bits of negative feedback:
1) It causes a CI test failure:
netdev/deprecated_api fail Found: 'module_param' was: 0 now: 1
2) Also, Jakub Kicinski asked me to not pursue this type of change
So, this patch will be retracted from the patch series.
I will create a v3 patch for net-next to address all feedback.
- Dave
PATCH v2 2/2 net: lan743x: avoid netdev-based logging before netdev registration
In reply to David ThompsonThis patch updates the lan743x driver to prevent the use of netdev-based logging APIs (such as netdev_dbg) before the network device has been successfully registered. Using netdev-based logging prior to registration results in log messages referencing "(unnamed net_device) (uninitialized)", which can be confusing and less informative.
The driver must use netif_msg_ APIs and device-based logging (e.g. dev_dbg) until netdev registration is complete. This ensures log entries are associated with the correct device context and improves log clarity. After registration, netdev-based logging APIs can be used safely.
---
v2:
- Changed target repo from "net" to "net-next"
- Removed "Fixes" tag
--- drivers/net/ethernet/microchip/lan743x_main.c | 72 ++++++++++++------- 1 file changed, 45 insertions(+), 27 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +45 -27
@@ -119,9 +119,10 @@ static int lan743x_pci_init(struct lan743x_adapter *adapter,if (ret) goto return_error; -netif_info (adapter, probe, adapter->netdev, -"PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n" , - pdev->vendor, pdev->device); +if (netif_msg_probe (adapter)) +pci_info (pdev, +"PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n" , + pdev->vendor, pdev->device); bars =pci_select_bars (pdev,IORESOURCE_MEM );if (!test_bit (0 , &bars)) goto disable_device;
@@ -203,10 +204,11 @@ static int lan743x_csr_init(struct lan743x_adapter *adapter) csr->id_rev =lan743x_csr_read (adapter,ID_REV ); csr->fpga_rev =lan743x_csr_read (adapter,FPGA_REV ); -netif_info (adapter, probe, adapter->netdev, -"ID_REV = 0x%08X, FPGA_REV = %d.%d\n" , - csr->id_rev,FPGA_REV_GET_MAJOR_ (csr->fpga_rev), -FPGA_REV_GET_MINOR_ (csr->fpga_rev)); +if (netif_msg_probe (adapter)) +dev_info (&adapter->pdev->dev, +"ID_REV = 0x%08X, FPGA_REV = %d.%d\n" , + csr->id_rev,FPGA_REV_GET_MAJOR_ (csr->fpga_rev), +FPGA_REV_GET_MINOR_ (csr->fpga_rev));if (!ID_REV_IS_VALID_CHIP_ID_ (csr->id_rev))return -ENODEV ;
@@ -964,8 +966,9 @@ int lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr)u32 val;if (mmd >31 ) { -netif_err (adapter, probe, adapter->netdev, -"%s mmd should <= 31\n" , __func__); +if (netif_msg_probe (adapter)) +dev_err (&adapter->pdev->dev, +"%s mmd should <= 31\n" , __func__);return -EINVAL ; }
@@ -994,8 +997,9 @@ static int lan743x_sgmii_write(struct lan743x_adapter *adapter,int ret;if (mmd >31 ) { -netif_err (adapter, probe, adapter->netdev, -"%s mmd should <= 31\n" , __func__); +if (netif_msg_probe (adapter)) +dev_err (&adapter->pdev->dev, +"%s mmd should <= 31\n" , __func__);return -EINVAL ; }mutex_lock (&adapter->sgmii_rw_lock);
@@ -1226,8 +1230,14 @@ static void lan743x_mac_set_address(struct lan743x_adapter *adapter,lan743x_csr_write (adapter,MAC_RX_ADDRH , addr_hi);ether_addr_copy (adapter->mac_address, addr); -netif_info (adapter, drv, adapter->netdev, -"MAC address set to %pM\n" , addr); +if (netif_msg_drv (adapter)) { +if (adapter->netdev->reg_state ==NETREG_REGISTERED ) +netdev_info (adapter->netdev, +"MAC address set to %pM\n" , addr); +else +dev_info (&adapter->pdev->dev, +"MAC address set to %pM\n" , addr); + } }static int lan743x_mac_init (struct lan743x_adapter *adapter)
@@ -1381,8 +1391,9 @@ static void lan743x_phy_interface_select(struct lan743x_adapter *adapter)else adapter->phy_interface =PHY_INTERFACE_MODE_RGMII ; -netif_dbg (adapter, drv, adapter->netdev, -"selected phy interface: 0x%X\n" , adapter->phy_interface); +if (netif_msg_drv (adapter)) +dev_dbg (&adapter->pdev->dev, +"selected phy interface: 0x%X\n" , adapter->phy_interface); }static void lan743x_rfe_open (struct lan743x_adapter *adapter)
@@ -3179,7 +3190,7 @@ static int lan743x_phylink_create(struct lan743x_adapter *adapter) } adapter->phylink = pl; -netdev_dbg (netdev,"lan743x phylink created" ); +dev_dbg (&adapter->pdev->dev,"lan743x phylink created" );return 0 ; }
@@ -3592,30 +3603,36 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter) adapter->mdiobus->priv = (void *)adapter;if (adapter->is_pci11x1x) {if (adapter->is_sgmii_en) { -netif_dbg (adapter, drv, adapter->netdev, -"SGMII operation\n" ); +if (netif_msg_drv (adapter)) +dev_dbg (&adapter->pdev->dev, +"SGMII operation\n" ); adapter->mdiobus->read = lan743x_mdiobus_read_c22; adapter->mdiobus->write = lan743x_mdiobus_write_c22; adapter->mdiobus->read_c45 = lan743x_mdiobus_read_c45; adapter->mdiobus->write_c45 = lan743x_mdiobus_write_c45; adapter->mdiobus->name ="lan743x-mdiobus-c45" ; -netif_dbg (adapter, drv, adapter->netdev, -"lan743x-mdiobus-c45\n" ); +if (netif_msg_drv (adapter)) +dev_dbg (&adapter->pdev->dev, +"lan743x-mdiobus-c45\n" ); }else { -netif_dbg (adapter, drv, adapter->netdev, -"RGMII operation\n" ); +if (netif_msg_drv (adapter)) +dev_dbg (&adapter->pdev->dev, +"RGMII operation\n" );// Only C22 support when RGMII I/F adapter->mdiobus->read = lan743x_mdiobus_read_c22; adapter->mdiobus->write = lan743x_mdiobus_write_c22; adapter->mdiobus->name ="lan743x-mdiobus" ; -netif_dbg (adapter, drv, adapter->netdev, -"lan743x-mdiobus\n" ); +if (netif_msg_drv (adapter)) +dev_dbg (&adapter->pdev->dev, +"lan743x-mdiobus\n" ); } }else { adapter->mdiobus->read = lan743x_mdiobus_read_c22; adapter->mdiobus->write = lan743x_mdiobus_write_c22; adapter->mdiobus->name ="lan743x-mdiobus" ; -netif_dbg (adapter, drv, adapter->netdev,"lan743x-mdiobus\n" ); +if (netif_msg_drv (adapter)) +dev_dbg (&adapter->pdev->dev, +"lan743x-mdiobus\n" ); } snprintf(adapter->mdiobus->id, MII_BUS_ID_SIZE,
@@ -3705,8 +3722,9 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev, ret =lan743x_phylink_create (adapter);if (ret <0 ) { -netif_err (adapter, probe, netdev, -"failed to setup phylink (%d)\n" , ret); +if (netif_msg_probe (adapter)) +dev_err (&pdev->dev, +"failed to setup phylink (%d)\n" , ret); goto cleanup_mdiobus; }
Signature · 1 line
2.43.0
Re: [PATCH net-next v2 2/2] net: lan743x: avoid netdev-based logging before netdev registration
Quoted 25 lines · David Thompson
This patch updates the lan743x driver to prevent the use of netdev-based logging APIs (such as
netdev_dbg) before the network device has been successfully registered. Using netdev-based logging prior to registration results in log messages referencing "(unnamednet_device) (uninitialized)", which can be confusing and less informative.The driver must use
netif_msg_APIs and device-based logging (e.g.dev_dbg) until netdev registration is complete. This ensures log entries are associated with the correct device context and improves log clarity. After registration, netdev-based logging APIs can be used safely.Signed-off-by David Thompson <[email protected]>---
v2:
- Changed target repo from "net" to "net-next"
- Removed "Fixes" tag--- drivers/net/ethernet/microchip/lan743x_main.c | 72 ++++++++++++------- 1 file changed, 45 insertions(+), 27 deletions(-)drivers/net/ethernet/microchip/lan743x_main.c +0
-0
drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_pci_init(struct lan743x_adapter *adapter, · line 125
Quoted 10 lines
drivers/net/ethernet/microchip/lan743x_main.c +4
-3@@ -119,9 +119,10 @@ static int lan743x_pci_init(struct lan743x_adapter *adapter,if (ret) goto return_error; -netif_info (adapter, probe, adapter->netdev, -"PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n" , - pdev->vendor, pdev->device); +if (netif_msg_probe (adapter)) +pci_info (pdev, +"PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n" , + pdev->vendor, pdev->device);
Do you really need to check netif_msg here? I guess it keeps the log from being cluttered based on the message levels enabled. I would probably just do dev_dbg() for all of these and let users use dynamic debugging to enable/disable precisely which messages they want instead of the message_enable bits.
Also, sometimes you use pci_info and other times you use dev_info. Why not be consistent?
RE: [PATCH net-next v2 2/2] net: lan743x: avoid netdev-based logging before netdev registration
Quoted 59 lines
-----Original Message-----
From: Jacob Keller <[email protected]>
Sent: Wednesday, May 27, 2026 4:32 PM
To: David Thompson <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH net-next v2 2/2] net: lan743x: avoid netdev-based logging before netdev registrationdrivers/net/ethernet/microchip/lan743x_main.c static int lan743x_pci_init(struct lan743x_adapter
Quoted 27 lines · David Thompson
This patch updates the lan743x driver to prevent the use of netdev-based logging APIs (such as
netdev_dbg) before the network device has been successfully registered. Using netdev-based logging prior to registration results in log messages referencing "(unnamednet_device) (uninitialized)", which can be confusing and less informative.The driver must use
netif_msg_APIs and device-based logging (e.g.dev_dbg) until netdev registration is complete. This ensures log entries are associated with the correct device context and improves log clarity. After registration, netdev-based logging APIs can be used safely.Signed-off-by David Thompson <[email protected]>---
v2:
- Changed target repo from "net" to "net-next"
- Removed "Fixes" tag--- drivers/net/ethernet/microchip/lan743x_main.c | 72 ++++++++++++------- 1 file changed, 45 insertions(+), 27 deletions(-)drivers/net/ethernet/microchip/lan743x_main.c +0
-0@@ -119,9 +119,10 @@ static int lan743x_pci_init(struct lan743x_adapter*adapter,
drivers/net/ethernet/microchip/lan743x_main.c static int lan743x_pci_init(struct lan743x_adapter *adapter, · line 125
Quoted 10 lines
drivers/net/ethernet/microchip/lan743x_main.c +4
-3if (ret) goto return_error; -netif_info (adapter, probe, adapter->netdev, -"PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n" , - pdev->vendor, pdev->device); +if (netif_msg_probe (adapter)) +pci_info (pdev, +"PCI: Vendor ID = 0x%04X, Device ID = 0x%04X\n" , + pdev->vendor, pdev->device);Do you really need to check
netif_msghere? I guess it keeps the log from being cluttered based on the message levels enabled. I would probably just dodev_dbg()for all of these and let users use dynamic debugging to enable/disable precisely which messages they want instead of themessage_enablebits.
Quoted 2 lines
Also, sometimes you use
pci_infoand other times you usedev_info. Why not be consistent?
Thanks for the reply Jacob.
I will update the code to use dev_dbg(), which can be controlled via dynamic debugging.
- Dave