]> git.baikalelectronics.ru Git - kernel.git/commitdiff
amd-xgbe: use enums for mailbox cmd and sub_cmds
authorRaju Rangoju <Raju.Rangoju@amd.com>
Thu, 20 Oct 2022 06:42:12 +0000 (12:12 +0530)
committerJakub Kicinski <kuba@kernel.org>
Sat, 22 Oct 2022 05:40:21 +0000 (22:40 -0700)
Instead of using hardcoded values, use enumerations for mailbox command
and sub commands.

Signed-off-by: Raju Rangoju <Raju.Rangoju@amd.com>
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
drivers/net/ethernet/amd/xgbe/xgbe.h

index 19b943eba560ea6341a98e9f02773d1ffb7ff33b..8cf5d81fca363f4169cff3621737a6d9d229b424 100644 (file)
@@ -1989,7 +1989,7 @@ static void xgbe_phy_pll_ctrl(struct xgbe_prv_data *pdata, bool enable)
 }
 
 static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata,
-                                       unsigned int cmd, unsigned int sub_cmd)
+                                       enum xgbe_mb_cmd cmd, enum xgbe_mb_subcmd sub_cmd)
 {
        unsigned int s0 = 0;
        unsigned int wait;
@@ -2036,7 +2036,7 @@ reenable_pll:
 static void xgbe_phy_rrc(struct xgbe_prv_data *pdata)
 {
        /* Receiver Reset Cycle */
-       xgbe_phy_perform_ratechange(pdata, 5, 0);
+       xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_RRC, XGBE_MB_SUBCMD_NONE);
 
        netif_dbg(pdata, link, pdata->netdev, "receiver reset complete\n");
 }
@@ -2046,7 +2046,7 @@ static void xgbe_phy_power_off(struct xgbe_prv_data *pdata)
        struct xgbe_phy_data *phy_data = pdata->phy_data;
 
        /* Power off */
-       xgbe_phy_perform_ratechange(pdata, 0, 0);
+       xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_POWER_OFF, XGBE_MB_SUBCMD_NONE);
 
        phy_data->cur_mode = XGBE_MODE_UNKNOWN;
 
@@ -2061,14 +2061,17 @@ static void xgbe_phy_sfi_mode(struct xgbe_prv_data *pdata)
 
        /* 10G/SFI */
        if (phy_data->sfp_cable != XGBE_SFP_CABLE_PASSIVE) {
-               xgbe_phy_perform_ratechange(pdata, 3, 0);
+               xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI, XGBE_MB_SUBCMD_ACTIVE);
        } else {
                if (phy_data->sfp_cable_len <= 1)
-                       xgbe_phy_perform_ratechange(pdata, 3, 1);
+                       xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI,
+                                                   XGBE_MB_SUBCMD_PASSIVE_1M);
                else if (phy_data->sfp_cable_len <= 3)
-                       xgbe_phy_perform_ratechange(pdata, 3, 2);
+                       xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI,
+                                                   XGBE_MB_SUBCMD_PASSIVE_3M);
                else
-                       xgbe_phy_perform_ratechange(pdata, 3, 3);
+                       xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_SFI,
+                                                   XGBE_MB_SUBCMD_PASSIVE_OTHER);
        }
 
        phy_data->cur_mode = XGBE_MODE_SFI;
@@ -2083,7 +2086,7 @@ static void xgbe_phy_x_mode(struct xgbe_prv_data *pdata)
        xgbe_phy_set_redrv_mode(pdata);
 
        /* 1G/X */
-       xgbe_phy_perform_ratechange(pdata, 1, 3);
+       xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_1G_KX);
 
        phy_data->cur_mode = XGBE_MODE_X;
 
@@ -2097,7 +2100,7 @@ static void xgbe_phy_sgmii_1000_mode(struct xgbe_prv_data *pdata)
        xgbe_phy_set_redrv_mode(pdata);
 
        /* 1G/SGMII */
-       xgbe_phy_perform_ratechange(pdata, 1, 2);
+       xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_1G_SGMII);
 
        phy_data->cur_mode = XGBE_MODE_SGMII_1000;
 
@@ -2111,7 +2114,7 @@ static void xgbe_phy_sgmii_100_mode(struct xgbe_prv_data *pdata)
        xgbe_phy_set_redrv_mode(pdata);
 
        /* 100M/SGMII */
-       xgbe_phy_perform_ratechange(pdata, 1, 1);
+       xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_100MBITS);
 
        phy_data->cur_mode = XGBE_MODE_SGMII_100;
 
@@ -2125,7 +2128,7 @@ static void xgbe_phy_kr_mode(struct xgbe_prv_data *pdata)
        xgbe_phy_set_redrv_mode(pdata);
 
        /* 10G/KR */
-       xgbe_phy_perform_ratechange(pdata, 4, 0);
+       xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_10G_KR, XGBE_MB_SUBCMD_NONE);
 
        phy_data->cur_mode = XGBE_MODE_KR;
 
@@ -2139,7 +2142,7 @@ static void xgbe_phy_kx_2500_mode(struct xgbe_prv_data *pdata)
        xgbe_phy_set_redrv_mode(pdata);
 
        /* 2.5G/KX */
-       xgbe_phy_perform_ratechange(pdata, 2, 0);
+       xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_2_5G, XGBE_MB_SUBCMD_NONE);
 
        phy_data->cur_mode = XGBE_MODE_KX_2500;
 
@@ -2153,7 +2156,7 @@ static void xgbe_phy_kx_1000_mode(struct xgbe_prv_data *pdata)
        xgbe_phy_set_redrv_mode(pdata);
 
        /* 1G/KX */
-       xgbe_phy_perform_ratechange(pdata, 1, 3);
+       xgbe_phy_perform_ratechange(pdata, XGBE_MB_CMD_SET_1G, XGBE_MB_SUBCMD_1G_KX);
 
        phy_data->cur_mode = XGBE_MODE_KX_1000;
 
index 49d23abce73d2273d642437208dd81bc21fb206f..71f24cb479355e8a40d9cdfbeea5f5736ddeb2a3 100644 (file)
@@ -611,6 +611,31 @@ enum xgbe_mdio_mode {
        XGBE_MDIO_MODE_CL45,
 };
 
+enum xgbe_mb_cmd {
+       XGBE_MB_CMD_POWER_OFF = 0,
+       XGBE_MB_CMD_SET_1G,
+       XGBE_MB_CMD_SET_2_5G,
+       XGBE_MB_CMD_SET_10G_SFI,
+       XGBE_MB_CMD_SET_10G_KR,
+       XGBE_MB_CMD_RRC
+};
+
+enum xgbe_mb_subcmd {
+       XGBE_MB_SUBCMD_NONE = 0,
+
+       /* 10GbE SFP subcommands */
+       XGBE_MB_SUBCMD_ACTIVE = 0,
+       XGBE_MB_SUBCMD_PASSIVE_1M,
+       XGBE_MB_SUBCMD_PASSIVE_3M,
+       XGBE_MB_SUBCMD_PASSIVE_OTHER,
+
+       /* 1GbE Mode subcommands */
+       XGBE_MB_SUBCMD_10MBITS = 0,
+       XGBE_MB_SUBCMD_100MBITS,
+       XGBE_MB_SUBCMD_1G_SGMII,
+       XGBE_MB_SUBCMD_1G_KX
+};
+
 struct xgbe_phy {
        struct ethtool_link_ksettings lks;