bnxt_en: Support force speed using the new HWRM fields
authorMichael Chan <michael.chan@broadcom.com>
Fri, 1 Dec 2023 22:39:22 +0000 (14:39 -0800)
committerJakub Kicinski <kuba@kernel.org>
Mon, 4 Dec 2023 23:12:48 +0000 (15:12 -0800)
Modify bnxt_force_link_speed() to support the new speeds stored in
link_info->support_speeds2, including the new 400G speed.

Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20231201223924.26955-14-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

index 7bc0bddbb1268a62bba3d7fc391ef4a97a4114e0..0a7dd48f1da892f85f0a7122eaab3b30bb4bed9b 100644 (file)
@@ -2128,6 +2128,7 @@ bnxt_force_link_speed(struct net_device *dev, u32 ethtool_speed, u32 lanes)
        struct bnxt *bp = netdev_priv(dev);
        struct bnxt_link_info *link_info = &bp->link_info;
        u16 support_pam4_spds = link_info->support_pam4_speeds;
+       u16 support_spds2 = link_info->support_speeds2;
        u16 support_spds = link_info->support_speeds;
        u8 sig_mode = BNXT_SIG_MODE_NRZ;
        u32 lanes_needed = 1;
@@ -2139,7 +2140,8 @@ bnxt_force_link_speed(struct net_device *dev, u32 ethtool_speed, u32 lanes)
                        fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_100MB;
                break;
        case SPEED_1000:
-               if (support_spds & BNXT_LINK_SPEED_MSK_1GB)
+               if ((support_spds & BNXT_LINK_SPEED_MSK_1GB) ||
+                   (support_spds2 & BNXT_LINK_SPEEDS2_MSK_1GB))
                        fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_1GB;
                break;
        case SPEED_2500:
@@ -2147,7 +2149,8 @@ bnxt_force_link_speed(struct net_device *dev, u32 ethtool_speed, u32 lanes)
                        fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_2_5GB;
                break;
        case SPEED_10000:
-               if (support_spds & BNXT_LINK_SPEED_MSK_10GB)
+               if ((support_spds & BNXT_LINK_SPEED_MSK_10GB) ||
+                   (support_spds2 & BNXT_LINK_SPEEDS2_MSK_10GB))
                        fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_10GB;
                break;
        case SPEED_20000:
@@ -2157,26 +2160,34 @@ bnxt_force_link_speed(struct net_device *dev, u32 ethtool_speed, u32 lanes)
                }
                break;
        case SPEED_25000:
-               if (support_spds & BNXT_LINK_SPEED_MSK_25GB)
+               if ((support_spds & BNXT_LINK_SPEED_MSK_25GB) ||
+                   (support_spds2 & BNXT_LINK_SPEEDS2_MSK_25GB))
                        fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_25GB;
                break;
        case SPEED_40000:
-               if (support_spds & BNXT_LINK_SPEED_MSK_40GB) {
+               if ((support_spds & BNXT_LINK_SPEED_MSK_40GB) ||
+                   (support_spds2 & BNXT_LINK_SPEEDS2_MSK_40GB)) {
                        fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_40GB;
                        lanes_needed = 4;
                }
                break;
        case SPEED_50000:
-               if ((support_spds & BNXT_LINK_SPEED_MSK_50GB) && lanes != 1) {
+               if (((support_spds & BNXT_LINK_SPEED_MSK_50GB) ||
+                    (support_spds2 & BNXT_LINK_SPEEDS2_MSK_50GB)) &&
+                   lanes != 1) {
                        fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_50GB;
                        lanes_needed = 2;
                } else if (support_pam4_spds & BNXT_LINK_PAM4_SPEED_MSK_50GB) {
                        fw_speed = PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_50GB;
                        sig_mode = BNXT_SIG_MODE_PAM4;
+               } else if (support_spds2 & BNXT_LINK_SPEEDS2_MSK_50GB_PAM4) {
+                       fw_speed = BNXT_LINK_SPEED_50GB_PAM4;
+                       sig_mode = BNXT_SIG_MODE_PAM4;
                }
                break;
        case SPEED_100000:
-               if ((support_spds & BNXT_LINK_SPEED_MSK_100GB) &&
+               if (((support_spds & BNXT_LINK_SPEED_MSK_100GB) ||
+                    (support_spds2 & BNXT_LINK_SPEEDS2_MSK_100GB)) &&
                    lanes != 2 && lanes != 1) {
                        fw_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_100GB;
                        lanes_needed = 4;
@@ -2184,6 +2195,14 @@ bnxt_force_link_speed(struct net_device *dev, u32 ethtool_speed, u32 lanes)
                        fw_speed = PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_100GB;
                        sig_mode = BNXT_SIG_MODE_PAM4;
                        lanes_needed = 2;
+               } else if ((support_spds2 & BNXT_LINK_SPEEDS2_MSK_100GB_PAM4) &&
+                          lanes != 1) {
+                       fw_speed = BNXT_LINK_SPEED_100GB_PAM4;
+                       sig_mode = BNXT_SIG_MODE_PAM4;
+                       lanes_needed = 2;
+               } else if (support_spds2 & BNXT_LINK_SPEEDS2_MSK_100GB_PAM4_112) {
+                       fw_speed = BNXT_LINK_SPEED_100GB_PAM4_112;
+                       sig_mode = BNXT_SIG_MODE_PAM4_112;
                }
                break;
        case SPEED_200000:
@@ -2191,6 +2210,27 @@ bnxt_force_link_speed(struct net_device *dev, u32 ethtool_speed, u32 lanes)
                        fw_speed = PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_200GB;
                        sig_mode = BNXT_SIG_MODE_PAM4;
                        lanes_needed = 4;
+               } else if ((support_spds2 & BNXT_LINK_SPEEDS2_MSK_200GB_PAM4) &&
+                          lanes != 2) {
+                       fw_speed = BNXT_LINK_SPEED_200GB_PAM4;
+                       sig_mode = BNXT_SIG_MODE_PAM4;
+                       lanes_needed = 4;
+               } else if (support_spds2 & BNXT_LINK_SPEEDS2_MSK_200GB_PAM4_112) {
+                       fw_speed = BNXT_LINK_SPEED_200GB_PAM4_112;
+                       sig_mode = BNXT_SIG_MODE_PAM4_112;
+                       lanes_needed = 2;
+               }
+               break;
+       case SPEED_400000:
+               if ((support_spds2 & BNXT_LINK_SPEEDS2_MSK_400GB_PAM4) &&
+                   lanes != 4) {
+                       fw_speed = BNXT_LINK_SPEED_400GB_PAM4;
+                       sig_mode = BNXT_SIG_MODE_PAM4;
+                       lanes_needed = 8;
+               } else if (support_spds2 & BNXT_LINK_SPEEDS2_MSK_400GB_PAM4_112) {
+                       fw_speed = BNXT_LINK_SPEED_400GB_PAM4_112;
+                       sig_mode = BNXT_SIG_MODE_PAM4_112;
+                       lanes_needed = 4;
                }
                break;
        }