git: 6288beb31e0c - stable/14 - if_bnxt: Fix media speed update issue in "ifconfig -m" during PHY hot plug

From: Warner Losh <imp_at_FreeBSD.org>
Date: Mon, 03 Jun 2024 19:24:48 UTC
The branch stable/14 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=6288beb31e0c1bb516ace7b7eeafa412a6642444

commit 6288beb31e0c1bb516ace7b7eeafa412a6642444
Author:     Chandrakanth Patil <chandrakanth.patil@broadcom.com>
AuthorDate: 2024-03-06 13:13:07 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-06-03 19:23:12 +0000

    if_bnxt: Fix media speed update issue in "ifconfig -m" during PHY hot plug
    
    Currently, if a media type (e.g., DAC) is hot-plugged out and another type
    (e.g., optical cable) is hot-plugged in, the new speed is not reflected in
    ifconfig. This occurs when the driver fails to update speeds with unchanged
    tx and rx flow control.
    
    To fix, a phy_type check ensures update of phy speeds upon detecting the new
    phy.
    
    Reviewed by:            imp
    Approved by:            imp
    Differential revision:  https://reviews.freebsd.org/D42951
    
    (cherry picked from commit 7cbffbfcd9a5185be61bec65790674159bb7c0a8)
---
 sys/dev/bnxt/bnxt.h    | 1 +
 sys/dev/bnxt/if_bnxt.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/sys/dev/bnxt/bnxt.h b/sys/dev/bnxt/bnxt.h
index 2b5c16e263d7..4484c8db5430 100644
--- a/sys/dev/bnxt/bnxt.h
+++ b/sys/dev/bnxt/bnxt.h
@@ -298,6 +298,7 @@ struct bnxt_link_info {
 	uint8_t		last_link_up;
 	uint8_t		duplex;
 	uint8_t		last_duplex;
+	uint8_t		last_phy_type;
 	struct bnxt_flow_ctrl   flow_ctrl;
 	struct bnxt_flow_ctrl   last_flow_ctrl;
 	uint8_t		duplex_setting;
diff --git a/sys/dev/bnxt/if_bnxt.c b/sys/dev/bnxt/if_bnxt.c
index 70d699d4b419..8dc151121311 100644
--- a/sys/dev/bnxt/if_bnxt.c
+++ b/sys/dev/bnxt/if_bnxt.c
@@ -3072,6 +3072,7 @@ bnxt_report_link(struct bnxt_softc *softc)
 		if (!link_info->link_up)
 			return;
 		if ((link_info->duplex == link_info->last_duplex) &&
+		    (link_info->phy_type == link_info->last_phy_type) &&
                     (!(BNXT_IS_FLOW_CTRL_CHANGED(link_info))))
 			return;
 	}
@@ -3102,6 +3103,7 @@ bnxt_report_link(struct bnxt_softc *softc)
 
 	link_info->last_link_up = link_info->link_up;
 	link_info->last_duplex = link_info->duplex;
+	link_info->last_phy_type = link_info->phy_type;
 	link_info->last_flow_ctrl.tx = link_info->flow_ctrl.tx;
 	link_info->last_flow_ctrl.rx = link_info->flow_ctrl.rx;
 	link_info->last_flow_ctrl.autoneg = link_info->flow_ctrl.autoneg;