Commit 1246d086 authored by Raju Rangoju's avatar Raju Rangoju Committed by Jakub Kicinski

amd-xgbe: use enums for mailbox cmd and sub_cmds

Instead of using hardcoded values, use enumerations for mailbox command
and sub commands.
Signed-off-by: default avatarRaju Rangoju <Raju.Rangoju@amd.com>
Acked-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f97fc7ef
...@@ -1989,7 +1989,7 @@ static void xgbe_phy_pll_ctrl(struct xgbe_prv_data *pdata, bool enable) ...@@ -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, 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 s0 = 0;
unsigned int wait; unsigned int wait;
...@@ -2036,7 +2036,7 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, ...@@ -2036,7 +2036,7 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata,
static void xgbe_phy_rrc(struct xgbe_prv_data *pdata) static void xgbe_phy_rrc(struct xgbe_prv_data *pdata)
{ {
/* Receiver Reset Cycle */ /* 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"); 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) ...@@ -2046,7 +2046,7 @@ static void xgbe_phy_power_off(struct xgbe_prv_data *pdata)
struct xgbe_phy_data *phy_data = pdata->phy_data; struct xgbe_phy_data *phy_data = pdata->phy_data;
/* Power off */ /* 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; phy_data->cur_mode = XGBE_MODE_UNKNOWN;
...@@ -2061,14 +2061,17 @@ static void xgbe_phy_sfi_mode(struct xgbe_prv_data *pdata) ...@@ -2061,14 +2061,17 @@ static void xgbe_phy_sfi_mode(struct xgbe_prv_data *pdata)
/* 10G/SFI */ /* 10G/SFI */
if (phy_data->sfp_cable != XGBE_SFP_CABLE_PASSIVE) { 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 { } else {
if (phy_data->sfp_cable_len <= 1) 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) 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 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; phy_data->cur_mode = XGBE_MODE_SFI;
...@@ -2083,7 +2086,7 @@ static void xgbe_phy_x_mode(struct xgbe_prv_data *pdata) ...@@ -2083,7 +2086,7 @@ static void xgbe_phy_x_mode(struct xgbe_prv_data *pdata)
xgbe_phy_set_redrv_mode(pdata); xgbe_phy_set_redrv_mode(pdata);
/* 1G/X */ /* 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; phy_data->cur_mode = XGBE_MODE_X;
...@@ -2097,7 +2100,7 @@ static void xgbe_phy_sgmii_1000_mode(struct xgbe_prv_data *pdata) ...@@ -2097,7 +2100,7 @@ static void xgbe_phy_sgmii_1000_mode(struct xgbe_prv_data *pdata)
xgbe_phy_set_redrv_mode(pdata); xgbe_phy_set_redrv_mode(pdata);
/* 1G/SGMII */ /* 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; phy_data->cur_mode = XGBE_MODE_SGMII_1000;
...@@ -2111,7 +2114,7 @@ static void xgbe_phy_sgmii_100_mode(struct xgbe_prv_data *pdata) ...@@ -2111,7 +2114,7 @@ static void xgbe_phy_sgmii_100_mode(struct xgbe_prv_data *pdata)
xgbe_phy_set_redrv_mode(pdata); xgbe_phy_set_redrv_mode(pdata);
/* 100M/SGMII */ /* 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; phy_data->cur_mode = XGBE_MODE_SGMII_100;
...@@ -2125,7 +2128,7 @@ static void xgbe_phy_kr_mode(struct xgbe_prv_data *pdata) ...@@ -2125,7 +2128,7 @@ static void xgbe_phy_kr_mode(struct xgbe_prv_data *pdata)
xgbe_phy_set_redrv_mode(pdata); xgbe_phy_set_redrv_mode(pdata);
/* 10G/KR */ /* 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; phy_data->cur_mode = XGBE_MODE_KR;
...@@ -2139,7 +2142,7 @@ static void xgbe_phy_kx_2500_mode(struct xgbe_prv_data *pdata) ...@@ -2139,7 +2142,7 @@ static void xgbe_phy_kx_2500_mode(struct xgbe_prv_data *pdata)
xgbe_phy_set_redrv_mode(pdata); xgbe_phy_set_redrv_mode(pdata);
/* 2.5G/KX */ /* 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; phy_data->cur_mode = XGBE_MODE_KX_2500;
...@@ -2153,7 +2156,7 @@ static void xgbe_phy_kx_1000_mode(struct xgbe_prv_data *pdata) ...@@ -2153,7 +2156,7 @@ static void xgbe_phy_kx_1000_mode(struct xgbe_prv_data *pdata)
xgbe_phy_set_redrv_mode(pdata); xgbe_phy_set_redrv_mode(pdata);
/* 1G/KX */ /* 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; phy_data->cur_mode = XGBE_MODE_KX_1000;
......
...@@ -611,6 +611,31 @@ enum xgbe_mdio_mode { ...@@ -611,6 +611,31 @@ enum xgbe_mdio_mode {
XGBE_MDIO_MODE_CL45, 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 xgbe_phy {
struct ethtool_link_ksettings lks; struct ethtool_link_ksettings lks;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment