The branch main has been updated by ssaxena:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=770e7ba3ebe87ba7ffc872c87de72707757b4e25

commit 770e7ba3ebe87ba7ffc872c87de72707757b4e25
Author:     Chandrakanth Patil <chandrakanth.pa...@broadcom.com>
AuthorDate: 2024-03-06 13:23:04 +0000
Commit:     Sumit Saxena <ssax...@freebsd.org>
CommitDate: 2024-03-07 19:26:34 +0000

    if_bnxt: Set 1G/10G baseT force speed as auto speeds
    
    The firmware lacks support for manually setting 1G and 10G baseT speeds.
    However, the driver can enable auto speed masks to achieve automatic 
configuration
    at these speeds.
    
    Reviewed by:            imp
    Approved by:            imp
    Differential revision:  https://reviews.freebsd.org/D42960
---
 sys/dev/bnxt/bnxt.h      |  1 +
 sys/dev/bnxt/bnxt_hwrm.c | 16 ++++++++++++++--
 sys/dev/bnxt/if_bnxt.c   | 11 ++++++++---
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/sys/dev/bnxt/bnxt.h b/sys/dev/bnxt/bnxt.h
index 204284d45428..0547bae91e09 100644
--- a/sys/dev/bnxt/bnxt.h
+++ b/sys/dev/bnxt/bnxt.h
@@ -843,5 +843,6 @@ struct bnxt_softc *bnxt_find_dev(uint32_t domain, uint32_t 
bus, uint32_t dev_fn,
 int bnxt_read_sfp_module_eeprom_info(struct bnxt_softc *bp, uint16_t i2c_addr,
     uint16_t page_number, uint8_t bank, bool bank_sel_en, uint16_t start_addr,
     uint16_t data_length, uint8_t *buf);
+uint8_t get_phy_type(struct bnxt_softc *softc);
 
 #endif /* _BNXT_H */
diff --git a/sys/dev/bnxt/bnxt_hwrm.c b/sys/dev/bnxt/bnxt_hwrm.c
index 481d45350488..37238b857ef5 100644
--- a/sys/dev/bnxt/bnxt_hwrm.c
+++ b/sys/dev/bnxt/bnxt_hwrm.c
@@ -862,8 +862,20 @@ bnxt_hwrm_set_link_common(struct bnxt_softc *softc,
        uint16_t fw_link_speed = softc->link_info.req_link_speed;
 
        if (autoneg & BNXT_AUTONEG_SPEED) {
-               req->auto_mode |=
-                   HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ALL_SPEEDS;
+               uint8_t phy_type = get_phy_type(softc);
+
+               if (phy_type == HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASET ||
+                   phy_type == HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET ||
+                   phy_type == HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE) {
+
+                       req->auto_mode |= 
htole32(HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_SPEED_MASK);
+                       if (link_info->advertising) {
+                               req->enables |= 
htole32(HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_LINK_SPEED_MASK);
+                               req->auto_link_speed_mask = 
htole16(link_info->advertising);
+                       }
+               } else {
+                       req->auto_mode |= 
HWRM_PORT_PHY_CFG_INPUT_AUTO_MODE_ALL_SPEEDS;
+               }
 
                req->enables |=
                    htole32(HWRM_PORT_PHY_CFG_INPUT_ENABLES_AUTO_MODE);
diff --git a/sys/dev/bnxt/if_bnxt.c b/sys/dev/bnxt/if_bnxt.c
index 4abd8b425444..9fd76301d6b3 100644
--- a/sys/dev/bnxt/if_bnxt.c
+++ b/sys/dev/bnxt/if_bnxt.c
@@ -219,7 +219,6 @@ static void bnxt_mark_cpr_invalid(struct bnxt_cp_ring *cpr);
 static void bnxt_def_cp_task(void *context);
 static void bnxt_handle_async_event(struct bnxt_softc *softc,
     struct cmpl_base *cmpl);
-static uint8_t get_phy_type(struct bnxt_softc *softc);
 static uint64_t bnxt_get_baudrate(struct bnxt_link_info *link);
 static void bnxt_get_wol_settings(struct bnxt_softc *softc);
 static int bnxt_wol_config(if_ctx_t ctx);
@@ -2144,7 +2143,6 @@ bnxt_media_change(if_ctx_t ctx)
                    HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_100MB;
                break;
        case IFM_1000_KX:
-       case IFM_1000_T:
        case IFM_1000_SGMII:
        case IFM_1000_CX:
        case IFM_1000_SX:
@@ -2163,7 +2161,6 @@ bnxt_media_change(if_ctx_t ctx)
        case IFM_10G_KR:
        case IFM_10G_LR:
        case IFM_10G_SR:
-       case IFM_10G_T:
                softc->link_info.autoneg &= ~BNXT_AUTONEG_SPEED;
                softc->link_info.req_link_speed =
                    HWRM_PORT_PHY_CFG_INPUT_FORCE_LINK_SPEED_10GB;
@@ -2240,6 +2237,14 @@ bnxt_media_change(if_ctx_t ctx)
                softc->link_info.req_signal_mode =
                        HWRM_PORT_PHY_QCFG_OUTPUT_SIGNAL_MODE_PAM4;
                break;
+       case IFM_1000_T:
+               softc->link_info.advertising = 
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_1GB;
+               softc->link_info.autoneg |= BNXT_AUTONEG_SPEED;
+               break;
+       case IFM_10G_T:
+               softc->link_info.advertising = 
HWRM_PORT_PHY_CFG_INPUT_AUTO_LINK_SPEED_MASK_10GB;
+               softc->link_info.autoneg |= BNXT_AUTONEG_SPEED;
+               break;
        default:
                device_printf(softc->dev,
                    "Unsupported media type!  Using auto\n");

Reply via email to