git: 7cbffbfcd9a5 - main - if_bnxt: Fix media speed update issue in "ifconfig -m" during PHY hot plug

From: Sumit Saxena <ssaxena_at_FreeBSD.org>
Date: Thu, 07 Mar 2024 18:55:29 UTC
The branch main has been updated by ssaxena:

URL: https://cgit.FreeBSD.org/src/commit/?id=7cbffbfcd9a5185be61bec65790674159bb7c0a8

commit 7cbffbfcd9a5185be61bec65790674159bb7c0a8
Author:     Chandrakanth Patil <chandrakanth.patil@broadcom.com>
AuthorDate: 2024-03-06 13:13:07 +0000
Commit:     Sumit Saxena <ssaxena@FreeBSD.org>
CommitDate: 2024-03-07 18:42:39 +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
---
 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 e3d82214a8a8..8439504af49a 100644
--- a/sys/dev/bnxt/if_bnxt.c
+++ b/sys/dev/bnxt/if_bnxt.c
@@ -3071,6 +3071,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;
 	}
@@ -3101,6 +3102,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;