[v2,4/6] net/hns3: use parse link mode info function
Checks
Commit Message
This patch use the framework public function to
replace the driver's private function.
Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 51 +++++++---------------------------
1 file changed, 10 insertions(+), 41 deletions(-)
@@ -4810,45 +4810,6 @@ hns3_check_port_speed(struct hns3_hw *hw, uint32_t link_speeds)
return 0;
}
-static uint32_t
-hns3_get_link_speed(uint32_t link_speeds)
-{
- uint32_t speed = RTE_ETH_SPEED_NUM_NONE;
-
- if (link_speeds & RTE_ETH_LINK_SPEED_10M ||
- link_speeds & RTE_ETH_LINK_SPEED_10M_HD)
- speed = RTE_ETH_SPEED_NUM_10M;
- if (link_speeds & RTE_ETH_LINK_SPEED_100M ||
- link_speeds & RTE_ETH_LINK_SPEED_100M_HD)
- speed = RTE_ETH_SPEED_NUM_100M;
- if (link_speeds & RTE_ETH_LINK_SPEED_1G)
- speed = RTE_ETH_SPEED_NUM_1G;
- if (link_speeds & RTE_ETH_LINK_SPEED_10G)
- speed = RTE_ETH_SPEED_NUM_10G;
- if (link_speeds & RTE_ETH_LINK_SPEED_25G)
- speed = RTE_ETH_SPEED_NUM_25G;
- if (link_speeds & RTE_ETH_LINK_SPEED_40G)
- speed = RTE_ETH_SPEED_NUM_40G;
- if (link_speeds & RTE_ETH_LINK_SPEED_50G)
- speed = RTE_ETH_SPEED_NUM_50G;
- if (link_speeds & RTE_ETH_LINK_SPEED_100G)
- speed = RTE_ETH_SPEED_NUM_100G;
- if (link_speeds & RTE_ETH_LINK_SPEED_200G)
- speed = RTE_ETH_SPEED_NUM_200G;
-
- return speed;
-}
-
-static uint8_t
-hns3_get_link_duplex(uint32_t link_speeds)
-{
- if ((link_speeds & RTE_ETH_LINK_SPEED_10M_HD) ||
- (link_speeds & RTE_ETH_LINK_SPEED_100M_HD))
- return RTE_ETH_LINK_HALF_DUPLEX;
- else
- return RTE_ETH_LINK_FULL_DUPLEX;
-}
-
static int
hns3_set_copper_port_link_speed(struct hns3_hw *hw,
struct hns3_set_link_speed_cfg *cfg)
@@ -4980,14 +4941,22 @@ static int
hns3_apply_link_speed(struct hns3_hw *hw)
{
struct rte_eth_conf *conf = &hw->data->dev_conf;
+ struct rte_eth_link_mode_info mode_info = {0};
struct hns3_set_link_speed_cfg cfg;
+ int ret;
memset(&cfg, 0, sizeof(struct hns3_set_link_speed_cfg));
cfg.autoneg = (conf->link_speeds == RTE_ETH_LINK_SPEED_AUTONEG) ?
RTE_ETH_LINK_AUTONEG : RTE_ETH_LINK_FIXED;
if (cfg.autoneg != RTE_ETH_LINK_AUTONEG) {
- cfg.speed = hns3_get_link_speed(conf->link_speeds);
- cfg.duplex = hns3_get_link_duplex(conf->link_speeds);
+ ret = rte_eth_link_mode_parse(conf->link_speeds, &mode_info);
+ if (ret) {
+ hns3_err(hw, "failed to parse link mode, ret = %d", ret);
+ return ret;
+ }
+ cfg.speed = mode_onfo.speed_num;
+ cfg.speed = mode_info.speed_num;
+ cfg.duplex = mode_info.duplex;
}
return hns3_set_port_link_speed(hw, &cfg);