From: Dengdui Huang <huangdengdui@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@amd.com>, <aman.deep.singh@intel.com>,
<yuying.zhang@intel.com>, <thomas@monjalon.net>,
<andrew.rybchenko@oktetlabs.ru>,
<damodharam.ammepalli@broadcom.com>, <stephen@networkplumber.org>,
<jerinjacobk@gmail.com>, <ajit.khaparde@broadcom.com>,
<liuyonglong@huawei.com>, <fengchengwen@huawei.com>,
<haijie1@huawei.com>, <lihuisong@huawei.com>
Subject: [PATCH v2 4/6] net/hns3: use parse link mode info function
Date: Fri, 22 Mar 2024 15:09:21 +0800 [thread overview]
Message-ID: <20240322070923.244417-5-huangdengdui@huawei.com> (raw)
In-Reply-To: <20240322070923.244417-1-huangdengdui@huawei.com>
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(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index ecd3b2ef64..1b380ac75f 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -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);
--
2.33.0
next prev parent reply other threads:[~2024-03-22 7:09 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 7:52 [PATCH 0/3] support setting lanes Dengdui Huang
2024-03-12 7:52 ` [PATCH 1/3] ethdev: " Dengdui Huang
2024-03-19 3:02 ` Stephen Hemminger
2024-03-20 1:16 ` huangdengdui
2024-03-12 7:52 ` [PATCH 2/3] net/hns3: " Dengdui Huang
2024-03-12 7:52 ` [PATCH 3/3] app/testpmd: " Dengdui Huang
2024-03-15 21:47 ` Damodharam Ammepalli
2024-03-19 2:38 ` huangdengdui
2024-03-22 7:09 ` [PATCH v2 0/6] " Dengdui Huang
2024-03-22 7:09 ` [PATCH v2 1/6] ethdev: " Dengdui Huang
2024-03-22 13:58 ` Thomas Monjalon
2024-03-22 15:15 ` Ajit Khaparde
2024-03-22 17:32 ` Tyler Retzlaff
2024-03-22 22:30 ` Damodharam Ammepalli
2024-03-25 6:24 ` huangdengdui
2024-03-25 9:30 ` Thomas Monjalon
2024-03-25 21:14 ` Damodharam Ammepalli
2024-03-26 1:42 ` lihuisong (C)
2024-03-26 3:45 ` Ajit Khaparde
2024-03-26 10:30 ` Thomas Monjalon
2024-03-26 11:15 ` lihuisong (C)
2024-03-26 13:47 ` Ajit Khaparde
2024-03-26 18:11 ` Ajit Khaparde
2024-03-26 18:21 ` Damodharam Ammepalli
2024-03-30 11:38 ` huangdengdui
2024-04-01 20:07 ` Thomas Monjalon
2024-04-01 22:29 ` Damodharam Ammepalli
2024-04-02 8:37 ` huangdengdui
2024-04-02 15:28 ` Stephen Hemminger
2024-04-04 13:45 ` Ferruh Yigit
2024-03-29 3:25 ` lihuisong (C)
2024-03-22 7:09 ` [PATCH v2 2/6] test: updated UT for " Dengdui Huang
2024-03-22 7:09 ` [PATCH v2 3/6] ethdev: add function to parse link mode info Dengdui Huang
2024-03-22 7:09 ` Dengdui Huang [this message]
2024-03-22 7:09 ` [PATCH v2 5/6] net/hns3: support setting lanes Dengdui Huang
2024-03-22 7:09 ` [PATCH v2 6/6] app/testpmd: " Dengdui Huang
2024-04-04 13:58 ` [PATCH v2 0/6] " Ferruh Yigit
2024-03-18 14:56 ` [PATCH 0/3] " Thomas Monjalon
2024-03-18 21:26 ` Damodharam Ammepalli
2024-03-18 21:42 ` Stephen Hemminger
2024-03-18 22:55 ` Ajit Khaparde
2024-03-20 11:41 ` Thomas Monjalon
2024-03-20 12:31 ` Ferruh Yigit
2024-03-21 2:02 ` huangdengdui
2024-03-21 8:28 ` Thomas Monjalon
2024-03-22 2:28 ` huangdengdui
2024-03-22 4:38 ` Jerin Jacob
2024-03-22 5:25 ` Ajit Khaparde
2024-03-22 5:51 ` Jerin Jacob
2024-03-22 13:51 ` Thomas Monjalon
2024-03-25 14:04 ` Jerin Jacob
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240322070923.244417-5-huangdengdui@huawei.com \
--to=huangdengdui@huawei.com \
--cc=ajit.khaparde@broadcom.com \
--cc=aman.deep.singh@intel.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=damodharam.ammepalli@broadcom.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=ferruh.yigit@amd.com \
--cc=haijie1@huawei.com \
--cc=jerinjacobk@gmail.com \
--cc=lihuisong@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
--cc=yuying.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).