vmxnet3: set carrier state properly on probe
Subsystems (3)
PATCH 1/1 vmxnet3: set carrier state properly on probe
vmxnet3 fails to set netif_carrier_off on probe, meaning that when an interface is opened the __LINK_STATE_NOCARRIER bit is already cleared, and so /sys/class/net/<ifname>/operstate remains in the unknown state. Correct this by setting netif_carrier_off on probe, like other drivers do.
Also, while we're at it, lets remove the netif_carrier_ok checks from the link_state_update function, as that check is atomically contained within the netif_carrier_[on|off] functions anyway
Tested successfully by myself
--- drivers/net/vmxnet3/vmxnet3_drv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/vmxnet3/vmxnet3_drv.c +3 -4
@@ -150,8 +150,7 @@ vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool affectTxQueue)if (ret &1 ) {/* Link is up. */ netdev_info (adapter->netdev,"NIC Link is Up %d Mbps\n" , adapter->link_speed); -if (!netif_carrier_ok (adapter->netdev)) -netif_carrier_on (adapter->netdev); +netif_carrier_on (adapter->netdev);if (affectTxQueue) {for (i =0 ; i < adapter->num_tx_queues; i++)
@@ -160,8 +159,7 @@ vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool affectTxQueue) } }else {netdev_info (adapter->netdev,"NIC Link is Down\n" ); -if (netif_carrier_ok (adapter->netdev)) -netif_carrier_off (adapter->netdev); +netif_carrier_off (adapter->netdev);if (affectTxQueue) {for (i =0 ; i < adapter->num_tx_queues; i++)
@@ -3067,6 +3065,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, goto err_register; } +netif_carrier_off (netdev);vmxnet3_check_link (adapter, false);return 0 ;
Signature · 1 line
1.7.11.7
Quoted 22 lines · Neil Horman
vmxnet3 fails to set
netif_carrier_offon probe, meaning that when an interface is opened the__LINK_STATE_NOCARRIERbit is already cleared, and so /sys/class/net/<ifname>/operstate remains in the unknown state. Correct this by settingnetif_carrier_offon probe, like other drivers do.Also, while we're at it, lets remove the
netif_carrier_okchecks from thelink_state_updatefunction, as that check is atomically contained within the netif_carrier_[on|off] functions anywayTested successfully by myself
Signed-off-by Neil Horman <[email protected]>CC "David S. Miller" <[email protected]>CC "VMware, Inc." <[email protected]>--- drivers/net/vmxnet3/vmxnet3_drv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/net/vmxnet3/vmxnet3_drv.c +0
-0
[...]
drivers/net/vmxnet3/vmxnet3_drv.c vmxnet3_probe_device(struct pci_dev *pdev, · line 3071
Quoted 8 lines
drivers/net/vmxnet3/vmxnet3_drv.c +1
-0@@ -3067,6 +3065,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, goto err_register; } +netif_carrier_off (netdev);vmxnet3_check_link (adapter, false);return 0 ;
You should do this before calling register_netdev(), otherwise the link state change can race with vmxnet3_open().
Ben.
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 34 lines · Ben Hutchings
Quoted 24 lines · Neil Horman
vmxnet3 fails to set
netif_carrier_offon probe, meaning that when an interface is opened the__LINK_STATE_NOCARRIERbit is already cleared, and so /sys/class/net/<ifname>/operstate remains in the unknown state. Correct this by settingnetif_carrier_offon probe, like other drivers do.Also, while we're at it, lets remove the
netif_carrier_okchecks from thelink_state_updatefunction, as that check is atomically contained within the netif_carrier_[on|off] functions anywayTested successfully by myself
Signed-off-by Neil Horman <[email protected]>CC "David S. Miller" <[email protected]>CC "VMware, Inc." <[email protected]>---
drivers/net/vmxnet3/vmxnet3_drv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/net/vmxnet3/vmxnet3_drv.cindex b1c90f8..66c26a9 100644drivers/net/vmxnet3/vmxnet3_drv.c +0
-0[...]
Quoted 6 lines
drivers/net/vmxnet3/vmxnet3_drv.c +0
-0@@ -3067,6 +3065,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, goto err_register; }
Quoted 7 lines
drivers/net/vmxnet3/vmxnet3_drv.c vmxnet3_probe_device(struct pci_dev *pdev, · line 3070
Quoted 4 lines
drivers/net/vmxnet3/vmxnet3_drv.c +1
-0+netif_carrier_off (netdev);drivers/net/vmxnet3/vmxnet3_drv.c +0
-0vmxnet3_check_link (adapter, false);return 0 ;You should do this before calling
register_netdev(), otherwise the link state change can race withvmxnet3_open().
Hmm, is it safe to do before the network device is registered? The rest of the drivers (e1000, tg3, etc) seem to be doing netif_carrier_off() in open() rather than probe() and then do link checks.
Thanks,
Dmitry
Quoted 43 lines · Dmitry Torokhov
Quoted 34 lines · Ben Hutchings
Quoted 24 lines · Neil Horman
vmxnet3 fails to set
netif_carrier_offon probe, meaning that when an interface is opened the__LINK_STATE_NOCARRIERbit is already cleared, and so /sys/class/net/<ifname>/operstate remains in the unknown state. Correct this by settingnetif_carrier_offon probe, like other drivers do.Also, while we're at it, lets remove the
netif_carrier_okchecks from thelink_state_updatefunction, as that check is atomically contained within the netif_carrier_[on|off] functions anywayTested successfully by myself
Signed-off-by Neil Horman <[email protected]>CC "David S. Miller" <[email protected]>CC "VMware, Inc." <[email protected]>---
drivers/net/vmxnet3/vmxnet3_drv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/net/vmxnet3/vmxnet3_drv.cindex b1c90f8..66c26a9 100644drivers/net/vmxnet3/vmxnet3_drv.c +0
-0[...]
Quoted 6 lines
drivers/net/vmxnet3/vmxnet3_drv.c +0
-0@@ -3067,6 +3065,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, goto err_register; }Quoted 7 lines
drivers/net/vmxnet3/vmxnet3_drv.c vmxnet3_probe_device(struct pci_dev *pdev, · line 3070
Quoted 4 lines
drivers/net/vmxnet3/vmxnet3_drv.c +1
-0+netif_carrier_off (netdev);drivers/net/vmxnet3/vmxnet3_drv.c +0
-0vmxnet3_check_link (adapter, false);return 0 ;You should do this before calling
register_netdev(), otherwise the link state change can race withvmxnet3_open().
Quoted 4 lines
Hmm, is it safe to do before the network device is registered? The rest of the drivers (e1000, tg3, etc) seem to be doing
netif_carrier_off()inopen()rather thanprobe()and then do link checks.
It appears to be safe to me, at least for the netif_carrier_off case, as theres a check to effecitvely just set the NOCARRIER bit if the device is in UNREGISTERED state.
Neil
Quoted 4 lines
Thanks,
Dmitry
Quoted 44 lines · Neil Horman
Quoted 43 lines · Dmitry Torokhov
Quoted 41 lines · Ben Hutchings
Quoted 24 lines · Neil Horman
vmxnet3 fails to set
netif_carrier_offon probe, meaning that when an interface is opened the__LINK_STATE_NOCARRIERbit is already cleared, and so /sys/class/net/<ifname>/operstate remains in the unknown state. Correct this by settingnetif_carrier_offon probe, like other drivers do.Also, while we're at it, lets remove the
netif_carrier_okchecks from thelink_state_updatefunction, as that check is atomically contained within the netif_carrier_[on|off] functions anywayTested successfully by myself
Signed-off-by Neil Horman <[email protected]>CC "David S. Miller" <[email protected]>CC "VMware, Inc." <[email protected]>---
drivers/net/vmxnet3/vmxnet3_drv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/net/vmxnet3/vmxnet3_drv.cindex b1c90f8..66c26a9 100644drivers/net/vmxnet3/vmxnet3_drv.c +0
-0[...]
drivers/net/vmxnet3/vmxnet3_drv.c vmxnet3_probe_device(struct pci_dev *pdev, · line 3070
Quoted 10 lines
drivers/net/vmxnet3/vmxnet3_drv.c +1
-0@@ -3067,6 +3065,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, goto err_register; } +netif_carrier_off (netdev);drivers/net/vmxnet3/vmxnet3_drv.c +0
-0vmxnet3_check_link (adapter, false);return 0 ;You should do this before calling
register_netdev(), otherwise the link state change can race withvmxnet3_open().
Quoted 7 lines
Quoted 4 lines
Hmm, is it safe to do before the network device is registered? The rest of the drivers (e1000, tg3, etc) seem to be doing
netif_carrier_off()inopen()rather thanprobe()and then do link checks.It appears to be safe to me, at least for the
netif_carrier_offcase, as theres a check to effecitvely just set the NOCARRIER bit if the device is in UNREGISTERED state.
Right, I made this work properly a little while ago (commit 8f4cccbbd92f). Previous best practice was to call netif_carrier_off() after registration, but userland could still see the wrong operstate because linkwatch updates it asynchronously.
Ben.
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 56 lines · Ben Hutchings
Quoted 55 lines · Neil Horman
Quoted 53 lines · Dmitry Torokhov
Quoted 40 lines · Ben Hutchings
Quoted 30 lines · Neil Horman
vmxnet3 fails to set
netif_carrier_offon probe, meaning that when an
interface is opened the__LINK_STATE_NOCARRIERbit is already cleared,
and so /sys/class/net/<ifname>/operstate remains in the unknown state.
Correct this by settingnetif_carrier_offon probe, like other drivers
do.Also, while we're at it, lets remove the
netif_carrier_okchecks from thelink_state_updatefunction, as that check is atomically contained within
the netif_carrier_[on|off] functions anywayTested successfully by myself
Signed-off-by Neil Horman <[email protected]>CC "David S. Miller" <[email protected]>CC "VMware, Inc." <[email protected]>---
drivers/net/vmxnet3/vmxnet3_drv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/net/vmxnet3/vmxnet3_drv.cindex b1c90f8..66c26a9 100644drivers/net/vmxnet3/vmxnet3_drv.c +0
-0[...]
Quoted 6 lines
drivers/net/vmxnet3/vmxnet3_drv.c +0
-0@@ -3067,6 +3065,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, goto err_register; }Quoted 8 lines
drivers/net/vmxnet3/vmxnet3_drv.c vmxnet3_probe_device(struct pci_dev *pdev, · line 3070
Quoted 4 lines
drivers/net/vmxnet3/vmxnet3_drv.c +1
-0+netif_carrier_off (netdev);drivers/net/vmxnet3/vmxnet3_drv.c +0
-0vmxnet3_check_link (adapter, false);return 0 ;You should do this before calling
register_netdev(), otherwise the link
state change can race withvmxnet3_open().Hmm, is it safe to do before the network device is registered? The rest of the drivers (e1000, tg3, etc) seem to be doing
netif_carrier_off()inopen()rather thanprobe()and then do link checks.
Quoted 8 lines
Quoted 3 lines
It appears to be safe to me, at least for the
netif_carrier_offcase, as theres a check to effecitvely just set the NOCARRIER bit if the device is in UNREGISTERED state.Right, I made this work properly a little while ago (commit
8f4cccbbd92f). Previous best practice was to callnetif_carrier_off()after registration, but userland could still see the wrong operstate because linkwatch updates it asynchronously.
Ah, OK I see. Thank you for the explanation.
Thanks,
Dmitry
PATCH v2 1/1 vmxnet3: set carrier state properly on probe
In reply to Neil Hormanvmxnet3 fails to set netif_carrier_off on probe, meaning that when an interface is opened the __LINK_STATE_NOCARRIER bit is already cleared, and so /sys/class/net/<ifname>/operstate remains in the unknown state. Correct this by setting netif_carrier_off on probe, like other drivers do.
Also, while we're at it, lets remove the netif_carrier_ok checks from the link_state_update function, as that check is atomically contained within the netif_carrier_[on|off] functions anyway
Tested successfully by myself
---
Change notes:
v2) Moved netif_carrier_off above register_netdev to prevent race with dev_open as per Ben H.
--- drivers/net/vmxnet3/vmxnet3_drv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/vmxnet3/vmxnet3_drv.c +3 -4
@@ -150,8 +150,7 @@ vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool affectTxQueue)if (ret &1 ) {/* Link is up. */ netdev_info (adapter->netdev,"NIC Link is Up %d Mbps\n" , adapter->link_speed); -if (!netif_carrier_ok (adapter->netdev)) -netif_carrier_on (adapter->netdev); +netif_carrier_on (adapter->netdev);if (affectTxQueue) {for (i =0 ; i < adapter->num_tx_queues; i++)
@@ -160,8 +159,7 @@ vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool affectTxQueue) } }else {netdev_info (adapter->netdev,"NIC Link is Down\n" ); -if (netif_carrier_ok (adapter->netdev)) -netif_carrier_off (adapter->netdev); +netif_carrier_off (adapter->netdev);if (affectTxQueue) {for (i =0 ; i < adapter->num_tx_queues; i++)
@@ -3060,6 +3058,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,netif_set_real_num_tx_queues (adapter->netdev, adapter->num_tx_queues);netif_set_real_num_rx_queues (adapter->netdev, adapter->num_rx_queues); +netif_carrier_off (netdev); err =register_netdev (netdev);if (err) {
Signature · 1 line
1.7.11.7
Quoted 9 lines · Neil Horman
vmxnet3 fails to set
netif_carrier_offon probe, meaning that when an interface is opened the__LINK_STATE_NOCARRIERbit is already cleared, and so /sys/class/net/<ifname>/operstate remains in the unknown state. Correct this by settingnetif_carrier_offon probe, like other drivers do.Also, while we're at it, lets remove the
netif_carrier_okchecks from thelink_state_updatefunction, as that check is atomically contained within the netif_carrier_[on|off] functions anyway
Quoted 5 lines
Tested successfully by myself
Signed-off-by Neil Horman <[email protected]>CC "David S. Miller" <[email protected]>CC "VMware, Inc." <[email protected]>
Quoted 43 lines
CC Ben Hutchings <[email protected]>---
Change notes:v2) Moved
netif_carrier_offaboveregister_netdevto prevent race withdev_openas per Ben H.--- drivers/net/vmxnet3/vmxnet3_drv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/net/vmxnet3/vmxnet3_drv.cindex b1c90f8..ffb97b2 100644drivers/net/vmxnet3/vmxnet3_drv.c +0
-0@@ -150,8 +150,7 @@ vmxnet3_check_link(struct vmxnet3_adapter *adapter, boolaffectTxQueue) if (ret & 1) { /* Link is up. */
drivers/net/vmxnet3/vmxnet3_drv.c +3
-4netdev_info (adapter->netdev,"NIC Link is Up %d Mbps\n" , adapter->link_speed); -if (!netif_carrier_ok (adapter->netdev)) -netif_carrier_on (adapter->netdev); +netif_carrier_on (adapter->netdev);if (affectTxQueue) {for (i =0 ; i < adapter->num_tx_queues; i++)@@ -160,8 +159,7 @@ vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool affectTxQueue) } }else {netdev_info (adapter->netdev,"NIC Link is Down\n" ); -if (netif_carrier_ok (adapter->netdev)) -netif_carrier_off (adapter->netdev); +netif_carrier_off (adapter->netdev);if (affectTxQueue) {for (i =0 ; i < adapter->num_tx_queues; i++)@@ -3060,6 +3058,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,netif_set_real_num_tx_queues (adapter->netdev, adapter->num_tx_queues);netif_set_real_num_rx_queues (adapter->netdev, adapter->num_rx_queues); +netif_carrier_off (netdev); err =register_netdev (netdev);if (err) {
David Miller
maintainerFrom: Neil Horman <[email protected]>
Date: Tue, 29 Jan 2013 13:36:51 -0500
Quoted 5 lines
vmxnet3 fails to set
netif_carrier_offon probe, meaning that when an interface is opened the__LINK_STATE_NOCARRIERbit is already cleared, and so /sys/class/net/<ifname>/operstate remains in the unknown state. Correct this by settingnetif_carrier_offon probe, like other drivers do.
Quoted 7 lines
Also, while we're at it, lets remove the
netif_carrier_okchecks from thelink_state_updatefunction, as that check is atomically contained within the netif_carrier_[on|off] functions anywayTested successfully by myself
Signed-off-by Neil Horman <[email protected]>
This doesn't apply to the current 'net' tree. Please respin.
Quoted 12 lines · David Miller
From: Neil Horman <[email protected]>
Date: Tue, 29 Jan 2013 13:36:51 -0500Quoted 9 lines
vmxnet3 fails to set
netif_carrier_offon probe, meaning that when an interface is opened the__LINK_STATE_NOCARRIERbit is already cleared, and so /sys/class/net/<ifname>/operstate remains in the unknown state. Correct this by settingnetif_carrier_offon probe, like other drivers do.Also, while we're at it, lets remove the
netif_carrier_okchecks from thelink_state_updatefunction, as that check is atomically contained within the netif_carrier_[on|off] functions anyway
Quoted 5 lines
Quoted 3 lines
Tested successfully by myself
Signed-off-by Neil Horman <[email protected]>This doesn't apply to the current 'net' tree. Please respin.
I based it off net-next. I'll respin for net
Neil
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 1/1 vmxnet3: set carrier state properly on probe
In reply to David Millervmxnet3 fails to set netif_carrier_off on probe, meaning that when an interface is opened the __LINK_STATE_NOCARRIER bit is already cleared, and so /sys/class/net/<ifname>/operstate remains in the unknown state. Correct this by setting netif_carrier_off on probe, like other drivers do.
Also, while we're at it, lets remove the netif_carrier_ok checks from the link_state_update function, as that check is atomically contained within the netif_carrier_[on|off] functions anyway
Tested successfully by myself
---
Change notes:
v2) Moved netif_carrier_off above register_netdev to prevent race with dev_open as per Ben H.
v3) Respin for net tree
--- drivers/net/vmxnet3/vmxnet3_drv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/vmxnet3/vmxnet3_drv.c +3 -4
@@ -154,8 +154,7 @@ vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool affectTxQueue)if (ret &1 ) {/* Link is up. */ printk (KERN_INFO "%s: NIC Link is Up %d Mbps\n" , adapter->netdev->name, adapter->link_speed); -if (!netif_carrier_ok (adapter->netdev)) -netif_carrier_on (adapter->netdev); +netif_carrier_on (adapter->netdev);if (affectTxQueue) {for (i =0 ; i < adapter->num_tx_queues; i++)
@@ -165,8 +164,7 @@ vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool affectTxQueue) }else {printk (KERN_INFO "%s: NIC Link is Down\n" , adapter->netdev->name); -if (netif_carrier_ok (adapter->netdev)) -netif_carrier_off (adapter->netdev); +netif_carrier_off (adapter->netdev);if (affectTxQueue) {for (i =0 ; i < adapter->num_tx_queues; i++)
@@ -3061,6 +3059,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,netif_set_real_num_tx_queues (adapter->netdev, adapter->num_tx_queues);netif_set_real_num_rx_queues (adapter->netdev, adapter->num_rx_queues); +netif_carrier_off (netdev); err =register_netdev (netdev);if (err) {
Signature · 1 line
1.7.11.7
From: Neil Horman <[email protected]>
Date: Tue, 29 Jan 2013 16:15:45 -0500
Quoted 5 lines
vmxnet3 fails to set
netif_carrier_offon probe, meaning that when an interface is opened the__LINK_STATE_NOCARRIERbit is already cleared, and so /sys/class/net/<ifname>/operstate remains in the unknown state. Correct this by settingnetif_carrier_offon probe, like other drivers do.
Quoted 7 lines
Also, while we're at it, lets remove the
netif_carrier_okchecks from thelink_state_updatefunction, as that check is atomically contained within the netif_carrier_[on|off] functions anywayTested successfully by myself
Signed-off-by Neil Horman <[email protected]>
Applied, thanks Neil.