Commit 08aa17a0 authored by Guangbin Huang's avatar Guangbin Huang Committed by David S. Miller

net: hns3: net: hns3: add querying and setting fec off mode from firmware

For some new devices, the FEC mode can not be set to OFF in speed 200G.
In order to flexibly adapt to all types of devices, driver queries
fec ability from firmware to decide whether OFF mode can be supported.
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5c4f7284
...@@ -224,6 +224,7 @@ enum hnae3_fec_mode { ...@@ -224,6 +224,7 @@ enum hnae3_fec_mode {
HNAE3_FEC_BASER, HNAE3_FEC_BASER,
HNAE3_FEC_RS, HNAE3_FEC_RS,
HNAE3_FEC_LLRS, HNAE3_FEC_LLRS,
HNAE3_FEC_NONE,
HNAE3_FEC_USER_DEF, HNAE3_FEC_USER_DEF,
}; };
......
...@@ -1625,10 +1625,8 @@ static unsigned int loc_to_eth_fec(u8 loc_fec) ...@@ -1625,10 +1625,8 @@ static unsigned int loc_to_eth_fec(u8 loc_fec)
eth_fec |= ETHTOOL_FEC_LLRS; eth_fec |= ETHTOOL_FEC_LLRS;
if (loc_fec & BIT(HNAE3_FEC_BASER)) if (loc_fec & BIT(HNAE3_FEC_BASER))
eth_fec |= ETHTOOL_FEC_BASER; eth_fec |= ETHTOOL_FEC_BASER;
if (loc_fec & BIT(HNAE3_FEC_NONE))
/* if nothing is set, then FEC is off */ eth_fec |= ETHTOOL_FEC_OFF;
if (!eth_fec)
eth_fec = ETHTOOL_FEC_OFF;
return eth_fec; return eth_fec;
} }
...@@ -1639,8 +1637,7 @@ static unsigned int eth_to_loc_fec(unsigned int eth_fec) ...@@ -1639,8 +1637,7 @@ static unsigned int eth_to_loc_fec(unsigned int eth_fec)
u32 loc_fec = 0; u32 loc_fec = 0;
if (eth_fec & ETHTOOL_FEC_OFF) if (eth_fec & ETHTOOL_FEC_OFF)
return loc_fec; loc_fec |= BIT(HNAE3_FEC_NONE);
if (eth_fec & ETHTOOL_FEC_AUTO) if (eth_fec & ETHTOOL_FEC_AUTO)
loc_fec |= BIT(HNAE3_FEC_AUTO); loc_fec |= BIT(HNAE3_FEC_AUTO);
if (eth_fec & ETHTOOL_FEC_RS) if (eth_fec & ETHTOOL_FEC_RS)
...@@ -1672,6 +1669,8 @@ static int hns3_get_fecparam(struct net_device *netdev, ...@@ -1672,6 +1669,8 @@ static int hns3_get_fecparam(struct net_device *netdev,
fec->fec = loc_to_eth_fec(fec_ability); fec->fec = loc_to_eth_fec(fec_ability);
fec->active_fec = loc_to_eth_fec(fec_mode); fec->active_fec = loc_to_eth_fec(fec_mode);
if (!fec->active_fec)
fec->active_fec = ETHTOOL_FEC_OFF;
return 0; return 0;
} }
......
...@@ -1008,6 +1008,7 @@ static void hclge_update_fec_support(struct hclge_mac *mac) ...@@ -1008,6 +1008,7 @@ static void hclge_update_fec_support(struct hclge_mac *mac)
linkmode_clear_bit(ETHTOOL_LINK_MODE_FEC_BASER_BIT, mac->supported); linkmode_clear_bit(ETHTOOL_LINK_MODE_FEC_BASER_BIT, mac->supported);
linkmode_clear_bit(ETHTOOL_LINK_MODE_FEC_RS_BIT, mac->supported); linkmode_clear_bit(ETHTOOL_LINK_MODE_FEC_RS_BIT, mac->supported);
linkmode_clear_bit(ETHTOOL_LINK_MODE_FEC_LLRS_BIT, mac->supported); linkmode_clear_bit(ETHTOOL_LINK_MODE_FEC_LLRS_BIT, mac->supported);
linkmode_clear_bit(ETHTOOL_LINK_MODE_FEC_NONE_BIT, mac->supported);
if (mac->fec_ability & BIT(HNAE3_FEC_BASER)) if (mac->fec_ability & BIT(HNAE3_FEC_BASER))
linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_BASER_BIT, linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_BASER_BIT,
...@@ -1018,6 +1019,9 @@ static void hclge_update_fec_support(struct hclge_mac *mac) ...@@ -1018,6 +1019,9 @@ static void hclge_update_fec_support(struct hclge_mac *mac)
if (mac->fec_ability & BIT(HNAE3_FEC_LLRS)) if (mac->fec_ability & BIT(HNAE3_FEC_LLRS))
linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_LLRS_BIT, linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_LLRS_BIT,
mac->supported); mac->supported);
if (mac->fec_ability & BIT(HNAE3_FEC_NONE))
linkmode_set_bit(ETHTOOL_LINK_MODE_FEC_NONE_BIT,
mac->supported);
} }
static void hclge_convert_setting_sr(u16 speed_ability, static void hclge_convert_setting_sr(u16 speed_ability,
...@@ -1125,17 +1129,17 @@ static void hclge_convert_setting_fec(struct hclge_mac *mac) ...@@ -1125,17 +1129,17 @@ static void hclge_convert_setting_fec(struct hclge_mac *mac)
switch (mac->speed) { switch (mac->speed) {
case HCLGE_MAC_SPEED_10G: case HCLGE_MAC_SPEED_10G:
case HCLGE_MAC_SPEED_40G: case HCLGE_MAC_SPEED_40G:
mac->fec_ability = mac->fec_ability = BIT(HNAE3_FEC_BASER) | BIT(HNAE3_FEC_AUTO) |
BIT(HNAE3_FEC_BASER) | BIT(HNAE3_FEC_AUTO); BIT(HNAE3_FEC_NONE);
break; break;
case HCLGE_MAC_SPEED_25G: case HCLGE_MAC_SPEED_25G:
case HCLGE_MAC_SPEED_50G: case HCLGE_MAC_SPEED_50G:
mac->fec_ability = mac->fec_ability = BIT(HNAE3_FEC_BASER) | BIT(HNAE3_FEC_RS) |
BIT(HNAE3_FEC_BASER) | BIT(HNAE3_FEC_RS) | BIT(HNAE3_FEC_AUTO) | BIT(HNAE3_FEC_NONE);
BIT(HNAE3_FEC_AUTO);
break; break;
case HCLGE_MAC_SPEED_100G: case HCLGE_MAC_SPEED_100G:
mac->fec_ability = BIT(HNAE3_FEC_RS) | BIT(HNAE3_FEC_AUTO); mac->fec_ability = BIT(HNAE3_FEC_RS) | BIT(HNAE3_FEC_AUTO) |
BIT(HNAE3_FEC_NONE);
break; break;
case HCLGE_MAC_SPEED_200G: case HCLGE_MAC_SPEED_200G:
mac->fec_ability = BIT(HNAE3_FEC_RS) | BIT(HNAE3_FEC_AUTO) | mac->fec_ability = BIT(HNAE3_FEC_RS) | BIT(HNAE3_FEC_AUTO) |
......
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