ixgbe: add fiber tranceiver plug/unplug notifier
Subsystems (3)
PATCH v3 1/1 ixgbe: add fiber tranceiver plug/unplug notifier
Hi, all
The changes are as below:
V3:
1.move the 2 variables from ixgbe_hw struct to ixgbe_adapter struct;
V2:
1. Replace IXGBE_IDENTIFIER with IXGBE_ESDP;
2. Replace plug interrupt with poll;
3. Indicate the NICs that does not support to plug/unplug tranceiver as plugged;
Hi, Don
Thanks for your reply. I will try to explain your concerns.
1. The ixgbe_sfp_detection_subtask function is driven by our master service task which isn't always running and doesn't always run at the same frequency.
Sure. If we open the nic, the ixgbe_sfp_detection_subtask function will be run. The command "ip link set eth0 up" can open the nic. In this patch, the time precision is not the first. We can accept several seconds delay. So it is not important that the ixgbe_sfp_detection_subtask function can not run at the same frequency.
2. - Insertion/removal while the device is down.
I made tests about this. When the device is down, there is no any interrupt and the ixgbe_sfp_detection_subtask function will not be run after the fiber tranceiver is plugged/unplugged.
3. - Initial query when the driver is loaded.
When the driver is loaded, the initial query will be sent. And the NETDEV_FIBER_TRANCEIVER_UNPLUG notifier will be sent if the fiber tranceiver is absent. Or else, the NETDEV_FIBER_TRANCEIVER_PLUG notifier will be sent. To 82598EB NIC that does not support plug/unplug fiber tranceiver, the notifier NETDEV_FIBER_TRANCEIVER_PLUG is sent.
4. - Some modules aren't supported I'm not sure how you would want to there, still report the insertion to the stack, ignore it?
Sure. From my tests, I think 82598EB does not support plug/unplug. And we treat the tranceiver as plugged in 82598EB. When the driver is loaded, the notifier NETDEV_FIBER_TRANCEIVER_PLUG is sent. And the status of the fiber tranceiver will not be changed in 82598EB
5. - I've also recently added a crosstalk fix that your patch would not take in to consideration.
Thanks a lot. I read your patch carefully. I do not think this patch is related with yours since this patch is only to check the absence of fiber tranceiver. It will not change anything.
If I am wrong, please correct me.
BTW, your patch provides a better method to detect the absence of fiber tranceiver. Thanks.
6. Some receive interrupts while others have to poll.
I know. Maybe some NICs do not support interrupts. So poll is used to check the absence of fiber tranceiver. Soon I will send a new patch.
The patch will be sent soon.
Any reply is appreciated.
Zhu Yanjun
PATCH v2 1/1 ixgbe: add fiber tranceiver plug/unplug notifier
From: Zhu Yanjun <[email protected]>
When the fiber tranceiver is plugged/unplugged, a netdev notifier is sent. The userspace tools or kernel can receive this notifier.
--- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 2 ++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 24 +++++++++++++++++++++++- include/linux/netdevice.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +2 -0
@@ -806,6 +806,8 @@ struct ixgbe_adapter {u32 rss_key[IXGBE_RSS_KEY_SIZE /sizeof (u32)];bool need_crosstalk_fix; +s32 last_tranceiver_status; +unsigned long tranceiver_polltime; };static inline u8 ixgbe_max_rss_indices (struct ixgbe_adapter *adapter)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +23 -1
@@ -5635,6 +5635,8 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter) hw->revision_id = pdev->revision; hw->subsystem_vendor_id = pdev->subsystem_vendor; hw->subsystem_device_id = pdev->subsystem_device; + adapter->last_tranceiver_status =IXGBE_NOT_IMPLEMENTED ; + adapter->tranceiver_polltime =0 ;/* Set common capability flags and settings */ rss =min_t (int,ixgbe_max_rss_indices (adapter),num_online_cpus ());
@@ -7067,7 +7069,27 @@ static void ixgbe_watchdog_subtask(struct ixgbe_adapter *adapter)static void ixgbe_sfp_detection_subtask (struct ixgbe_adapter *adapter) {struct ixgbe_hw *hw = &adapter->hw; -s32 err; +s32 err, status; + +if ((hw->mac.ops.get_media_type (hw) == ixgbe_media_type_fiber) && +time_after (jiffies, adapter->tranceiver_polltime)) { + status =IXGBE_READ_REG (hw,IXGBE_ESDP ) &IXGBE_ESDP_SDP2 ; +if (status != adapter->last_tranceiver_status) { +unsigned long val; + +if (!status) { + hw->phy.sfp_type = ixgbe_sfp_type_not_present; + val =NETDEV_FIBER_TRANCEIVER_UNPLUG ; + }else { + val =NETDEV_FIBER_TRANCEIVER_PLUG ; + } +rtnl_lock (); +call_netdevice_notifiers (val, adapter->netdev); +rtnl_unlock (); + } + adapter->last_tranceiver_status = status; + adapter->tranceiver_polltime = jiffies +3 *HZ ; + }/* If crosstalk fix enabled verify the SFP+ cage is full */ if (adapter->need_crosstalk_fix) {
include/linux/netdevice.h +2 -0
@@ -2253,6 +2253,8 @@ struct netdev_lag_lower_state_info {#define NETDEV_CHANGELOWERSTATE 0x001B#define NETDEV_OFFLOAD_PUSH_VXLAN 0x001C#define NETDEV_OFFLOAD_PUSH_GENEVE 0x001D +#define NETDEV_FIBER_TRANCEIVER_PLUG 0x001E +#define NETDEV_FIBER_TRANCEIVER_UNPLUG 0x001Fint register_netdevice_notifier (struct notifier_block *nb);int unregister_netdevice_notifier (struct notifier_block *nb);
Signature · 1 line
1.7.9.5