]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fbnic: Set correct supported modes and speeds based on FW setting
authorAlexander Duyck <alexanderduyck@fb.com>
Wed, 18 Jun 2025 22:07:55 +0000 (15:07 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 24 Jun 2025 07:31:46 +0000 (09:31 +0200)
The fbnic driver was using the XLGMII link mode to enable phylink, however
that mode wasn't the correct one to use as the NIC doesn't actually use
XLGMII, it is using a combinations of 25G, 50G, and 100G interface modes
and configuring those via pins exposed on the PCS, MAC, and PHY interfaces.
To more accurately reflect that we should drop the uxe of XGMII and XLGMII
and instead use the correct interface types.

Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
Link: https://patch.msgid.link/175028447568.625704.17971496887030109107.stgit@ahduyck-xeon-server.home.arpa
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/meta/fbnic/fbnic_mac.c
drivers/net/ethernet/meta/fbnic/fbnic_mac.h
drivers/net/ethernet/meta/fbnic/fbnic_phylink.c

index 284fcfbedb74fb12b9e36b4db6847b84d651ac01..5ff45463f9d2a467ecde1326b809815a8c994a5b 100644 (file)
@@ -540,7 +540,7 @@ static bool fbnic_pcs_get_link_asic(struct fbnic_dev *fbd)
        return link;
 }
 
-static void fbnic_mac_get_fw_settings(struct fbnic_dev *fbd, u8 *aui, u8 *fec)
+void fbnic_mac_get_fw_settings(struct fbnic_dev *fbd, u8 *aui, u8 *fec)
 {
        /* Retrieve default speed from FW */
        switch (fbd->fw_cap.link_speed) {
@@ -580,15 +580,10 @@ static void fbnic_mac_get_fw_settings(struct fbnic_dev *fbd, u8 *aui, u8 *fec)
 
 static int fbnic_pcs_enable_asic(struct fbnic_dev *fbd)
 {
-       struct fbnic_net *fbn = netdev_priv(fbd->netdev);
-
        /* Mask and clear the PCS interrupt, will be enabled by link handler */
        wr32(fbd, FBNIC_SIG_PCS_INTR_MASK, ~0);
        wr32(fbd, FBNIC_SIG_PCS_INTR_STS, ~0);
 
-       /* Pull in settings from FW */
-       fbnic_mac_get_fw_settings(fbd, &fbn->aui, &fbn->fec);
-
        return 0;
 }
 
index 151d785116cb736c03ba3090cca3b12d5bac7598..86fa06da2b3e1c47f25898c09d267d42798582bf 100644 (file)
@@ -93,4 +93,5 @@ struct fbnic_mac {
 };
 
 int fbnic_mac_init(struct fbnic_dev *fbd);
+void fbnic_mac_get_fw_settings(struct fbnic_dev *fbd, u8 *aui, u8 *fec);
 #endif /* _FBNIC_MAC_H_ */
index edd8738c981a292e18352ab82eb8f5666f810de7..a693a9f4d5fde6bed500485afbaf548b6428e094 100644 (file)
@@ -8,6 +8,22 @@
 #include "fbnic_mac.h"
 #include "fbnic_netdev.h"
 
+static phy_interface_t fbnic_phylink_select_interface(u8 aui)
+{
+       switch (aui) {
+       case FBNIC_AUI_100GAUI2:
+               return PHY_INTERFACE_MODE_100GBASEP;
+       case FBNIC_AUI_50GAUI1:
+               return PHY_INTERFACE_MODE_50GBASER;
+       case FBNIC_AUI_LAUI2:
+               return PHY_INTERFACE_MODE_LAUI;
+       case FBNIC_AUI_25GAUI:
+               return PHY_INTERFACE_MODE_25GBASER;
+       }
+
+       return PHY_INTERFACE_MODE_NA;
+}
+
 static struct fbnic_net *
 fbnic_pcs_to_net(struct phylink_pcs *pcs)
 {
@@ -128,6 +144,7 @@ static const struct phylink_mac_ops fbnic_phylink_mac_ops = {
 int fbnic_phylink_init(struct net_device *netdev)
 {
        struct fbnic_net *fbn = netdev_priv(netdev);
+       struct fbnic_dev *fbd = fbn->fbd;
        struct phylink *phylink;
 
        fbn->phylink_pcs.ops = &fbnic_phylink_pcs_ops;
@@ -135,18 +152,23 @@ int fbnic_phylink_init(struct net_device *netdev)
        fbn->phylink_config.dev = &netdev->dev;
        fbn->phylink_config.type = PHYLINK_NETDEV;
        fbn->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE |
-                                              MAC_10000FD | MAC_25000FD |
-                                              MAC_40000FD | MAC_50000FD |
+                                              MAC_25000FD | MAC_50000FD |
                                               MAC_100000FD;
        fbn->phylink_config.default_an_inband = true;
 
-       __set_bit(PHY_INTERFACE_MODE_XGMII,
+       __set_bit(PHY_INTERFACE_MODE_100GBASEP,
                  fbn->phylink_config.supported_interfaces);
-       __set_bit(PHY_INTERFACE_MODE_XLGMII,
+       __set_bit(PHY_INTERFACE_MODE_50GBASER,
                  fbn->phylink_config.supported_interfaces);
+       __set_bit(PHY_INTERFACE_MODE_LAUI,
+                 fbn->phylink_config.supported_interfaces);
+       __set_bit(PHY_INTERFACE_MODE_25GBASER,
+                 fbn->phylink_config.supported_interfaces);
+
+       fbnic_mac_get_fw_settings(fbd, &fbn->aui, &fbn->fec);
 
        phylink = phylink_create(&fbn->phylink_config, NULL,
-                                PHY_INTERFACE_MODE_XLGMII,
+                                fbnic_phylink_select_interface(fbn->aui),
                                 &fbnic_phylink_mac_ops);
        if (IS_ERR(phylink))
                return PTR_ERR(phylink);