ice: Fix "Unknown bps" during link events
Subsystems (3)
PATCH v2 1/1 ice: Fix "Unknown bps" during link events
From: Jakub Kaminski <[email protected]>
The driver may display "NIC Link is up Unknown bps" messages during link state changes. This occurs when link status and link speed are read from different points in time.
The driver processes link events by receiving an asynchronous ARQ event from firmware containing link_up and link_speed values, then performing a synchronous AQ query via ice_update_link_info() which overwrites the phy.link_info structure, and finally calling ice_link_event() with a link_speed parameter while ice_print_link_msg() read link_speed from phy.link_info directly.
ice_print_link_msg() always read link_speed from the phy.link_info structure. This caused link status from the ARQ event to be combined with link_speed from the later AQ query, mixing information from two different points in time. When firmware state changed between these moments, inconsistent messages like "Link is up Unknown bps" appeared.
Add a link_speed parameter to ice_print_link_msg() to ensure link status and speed are always taken from the same source and point in time.
---
v2:
Remove conditional assignement of local var link_up only during UP events. Cache state of both link_up and link_speed for every event.
---
--- drivers/net/ethernet/intel/ice/ice.h | 2 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 +- drivers/net/ethernet/intel/ice/ice_main.c | 17 ++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -1
@@ -1006,7 +1006,7 @@ int ice_get_rss_key(struct ice_vsi *vsi, u8 *seed);int ice_set_rss_hfunc (struct ice_vsi *vsi,u8 hfunc);void ice_fill_rss_lut (u8 *lut,u16 rss_table_size,u16 rss_size);int ice_schedule_reset (struct ice_pf *pf,enum ice_reset_req reset); -void ice_print_link_msg (struct ice_vsi *vsi,bool isup); +void ice_print_link_msg (struct ice_vsi *vsi,bool isup,u16 link_speed);int ice_plug_aux_dev (struct ice_pf *pf);void ice_unplug_aux_dev (struct ice_pf *pf);void ice_rdma_finalize_setup (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_ethtool.c +1 -1
@@ -2814,7 +2814,7 @@ ice_set_link_ksettings(struct net_device *netdev,/* Tell the OS link is going down, the link will go * back up when fw says it is ready asynchronously */ -ice_print_link_msg (np->vsi, false); +ice_print_link_msg (np->vsi, false,0 );netif_carrier_off (netdev);netif_tx_stop_all_queues (netdev); }
drivers/net/ethernet/intel/ice/ice_main.c +8 -9
@@ -835,8 +835,9 @@ static void ice_print_topo_conflict(struct ice_vsi *vsi)* ice_print_link_msg - print link up or down message * @vsi: the VSI whose link status is being queried * @isup: boolean for if the link is now up or down +* @link_speed: current link speed value to display */ -void ice_print_link_msg (struct ice_vsi *vsi,bool isup) +void ice_print_link_msg (struct ice_vsi *vsi,bool isup,u16 link_speed) {struct ice_aqc_get_phy_caps_data *caps;const char *an_advertised;
@@ -860,7 +861,7 @@ void ice_print_link_msg(struct ice_vsi *vsi, bool isup)return ; } -switch (vsi->port_info->phy.link_info.link_speed) { +switch (link_speed) {case ICE_AQ_LINK_SPEED_200GB : speed ="200 G" ;break ;
@@ -1190,11 +1191,8 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up,ice_check_link_cfg_err (pf, pi->phy.link_info.link_cfg_err); -/* Check if the link state is up after updating link info, and treat -* this event as an UP event since the link is actually UP now. -*/ -if (phy_info->link_info.link_info &ICE_AQ_LINK_UP ) - link_up = true; + link_up = phy_info->link_info.link_info &ICE_AQ_LINK_UP ; + link_speed = phy_info->link_info.link_speed; vsi =ice_get_main_vsi (pf);if (!vsi || !vsi->port_info)
@@ -1224,7 +1222,7 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up,ice_set_dflt_mib (pf); }ice_vsi_link_event (vsi, link_up); -ice_print_link_msg (vsi, link_up); +ice_print_link_msg (vsi, link_up, link_speed);ice_vc_notify_link_state (pf);
@@ -6922,7 +6920,8 @@ static int ice_up_complete(struct ice_vsi *vsi) (vsi->port_info->phy.link_info.link_info & ICE_AQ_LINK_UP) && ((vsi->netdev && (vsi->type == ICE_VSI_PF || vsi->type == ICE_VSI_SF)))) { -ice_print_link_msg (vsi, true); +ice_print_link_msg (vsi, true, + vsi->port_info->phy.link_info.link_speed);netif_tx_start_all_queues (vsi->netdev);netif_carrier_on (vsi->netdev);ice_ptp_link_change (pf, true);
Signature · 1 line
2.50.1
Quoted 19 lines · Lukasz Czapnik
From: Jakub Kaminski <[email protected]>
The driver may display "NIC Link is up Unknown bps" messages during link state changes. This occurs when link status and link speed are read from different points in time.
The driver processes link events by receiving an asynchronous ARQ event from firmware containing
link_upandlink_speedvalues, then performing a synchronous AQ query viaice_update_link_info()which overwrites the phy.link_info structure, and finally callingice_link_event()with alink_speedparameter whileice_print_link_msg()readlink_speedfrom phy.link_info directly.
ice_print_link_msg()always readlink_speedfrom the phy.link_info structure. This caused link status from the ARQ event to be combined withlink_speedfrom the later AQ query, mixing information from two different points in time. When firmware state changed between these moments, inconsistent messages like "Link is up Unknown bps" appeared.
Quoted 4 lines
Add a
link_speedparameter toice_print_link_msg()to ensure link status and speed are always taken from the same source and point in time.
Hi Lukasz,
Probably this can be addressed when the patch applied. But I'll point out that git am will truncate the patch description at this point due to the immediately following scissors ("---").
IOW, Fixes and the other tags should probably appear exactly here. With the v2 information left below the scissors.
Quoted 5 lines
---
v2:
Remove conditional assignement of local varlink_uponly during UP events. Cache state of bothlink_upandlink_speedfor every event.
Thanks for the update.
Quoted 7 lines
---
Fixes c2a23e00613b ("ice: Refactor link event flow")Signed-off-by Jakub Kaminski <[email protected]>Signed-off-by Lukasz Czapnik <[email protected]>Reviewed-by Aleksandr Loktionov <[email protected]>Reviewed-by Tomasz Lichwala <[email protected]>
...
Tony Nguyen
maintainerQuoted 1 line · Lukasz Czapnik
From: Jakub Kaminski <[email protected]>
...
drivers/net/ethernet/intel/ice/ice_main.c ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up, · line 1195
Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_main.c +2
-5@@ -1190,11 +1191,8 @@ ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up,ice_check_link_cfg_err (pf, pi->phy.link_info.link_cfg_err); -/* Check if the link state is up after updating link info, and treat -* this event as an UP event since the link is actually UP now. -*/ -if (phy_info->link_info.link_info &ICE_AQ_LINK_UP ) - link_up = true; + link_up = phy_info->link_info.link_info &ICE_AQ_LINK_UP ; + link_speed = phy_info->link_info.link_speed;
Sashiko says:
Does this unconditionally overwrite the ARQ-provided link_up and link_speed arguments with the cached AQ state?
If the synchronous AQ query (ice_update_link_info()) called earlier in ice_link_event() fails, for example due to an AQ timeout, the phy_info->link_info structure is not updated.
By unconditionally reading from this potentially stale structure, link_up and link_speed are guaranteed to match old_link and old_link_speed. This would cause the following early return block to trigger erroneously:
drivers/net/ethernet/intel/ice/ice_main.c:ice_link_event() {
...
if (link_up == old_link && link_speed == old_link_speed)
return 0;
...
}Could this silently drop a valid hardware link state change, leaving the OS and the hardware out of sync and causing network hangs?
Tony says:
I think the right/wrong combination could cause this to occur. I, also, think there's an issue with accounting for the link event and updated link info that could get lost if it changes.
Thanks,
Tony
Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_main.c +0
-0vsi =ice_get_main_vsi (pf);if (!vsi || !vsi->port_info)