From: Mingxia Liu <mingxia.liu@intel.com>
To: dev@dpdk.org
Cc: jingjing.wu@intel.com, beilei.xing@intel.com,
Mingxia Liu <mingxia.liu@intel.com>
Subject: [PATCH] net/idpf: refine dev_link_update function
Date: Mon, 26 Jun 2023 11:14:54 +0000 [thread overview]
Message-ID: <20230626111454.489844-1-mingxia.liu@intel.com> (raw)
This patch refines idpf_dev_link_update callback function according to
CPFL PMD basic code.
Signed-off-by: Mingxia Liu <mingxia.liu@intel.com>
---
drivers/net/idpf/idpf_ethdev.c | 63 ++++++++++++++++------------------
1 file changed, 30 insertions(+), 33 deletions(-)
diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index fb59655555..bfdac92b95 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -30,6 +30,23 @@ static const char * const idpf_valid_args[] = {
NULL
};
+uint32_t idpf_supported_speeds[] = {
+ RTE_ETH_SPEED_NUM_NONE,
+ RTE_ETH_SPEED_NUM_10M,
+ RTE_ETH_SPEED_NUM_100M,
+ RTE_ETH_SPEED_NUM_1G,
+ RTE_ETH_SPEED_NUM_2_5G,
+ RTE_ETH_SPEED_NUM_5G,
+ RTE_ETH_SPEED_NUM_10G,
+ RTE_ETH_SPEED_NUM_20G,
+ RTE_ETH_SPEED_NUM_25G,
+ RTE_ETH_SPEED_NUM_40G,
+ RTE_ETH_SPEED_NUM_50G,
+ RTE_ETH_SPEED_NUM_56G,
+ RTE_ETH_SPEED_NUM_100G,
+ RTE_ETH_SPEED_NUM_200G
+};
+
static const uint64_t idpf_map_hena_rss[] = {
[IDPF_HASH_NONF_UNICAST_IPV4_UDP] =
RTE_ETH_RSS_NONFRAG_IPV4_UDP,
@@ -110,42 +127,22 @@ idpf_dev_link_update(struct rte_eth_dev *dev,
{
struct idpf_vport *vport = dev->data->dev_private;
struct rte_eth_link new_link;
+ unsigned int i;
memset(&new_link, 0, sizeof(new_link));
- switch (vport->link_speed) {
- case RTE_ETH_SPEED_NUM_10M:
- new_link.link_speed = RTE_ETH_SPEED_NUM_10M;
- break;
- case RTE_ETH_SPEED_NUM_100M:
- new_link.link_speed = RTE_ETH_SPEED_NUM_100M;
- break;
- case RTE_ETH_SPEED_NUM_1G:
- new_link.link_speed = RTE_ETH_SPEED_NUM_1G;
- break;
- case RTE_ETH_SPEED_NUM_10G:
- new_link.link_speed = RTE_ETH_SPEED_NUM_10G;
- break;
- case RTE_ETH_SPEED_NUM_20G:
- new_link.link_speed = RTE_ETH_SPEED_NUM_20G;
- break;
- case RTE_ETH_SPEED_NUM_25G:
- new_link.link_speed = RTE_ETH_SPEED_NUM_25G;
- break;
- case RTE_ETH_SPEED_NUM_40G:
- new_link.link_speed = RTE_ETH_SPEED_NUM_40G;
- break;
- case RTE_ETH_SPEED_NUM_50G:
- new_link.link_speed = RTE_ETH_SPEED_NUM_50G;
- break;
- case RTE_ETH_SPEED_NUM_100G:
- new_link.link_speed = RTE_ETH_SPEED_NUM_100G;
- break;
- case RTE_ETH_SPEED_NUM_200G:
- new_link.link_speed = RTE_ETH_SPEED_NUM_200G;
- break;
- default:
- new_link.link_speed = RTE_ETH_SPEED_NUM_NONE;
+ for (i = 0; i < RTE_DIM(idpf_supported_speeds); i++) {
+ if (vport->link_speed == idpf_supported_speeds[i]) {
+ new_link.link_speed = vport->link_speed;
+ break;
+ }
+ }
+
+ if (i == RTE_DIM(idpf_supported_speeds)) {
+ if (vport->link_up)
+ new_link.link_speed = RTE_ETH_SPEED_NUM_UNKNOWN;
+ else
+ new_link.link_speed = RTE_ETH_SPEED_NUM_NONE;
}
new_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
--
2.34.1
next reply other threads:[~2023-06-26 2:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-26 11:14 Mingxia Liu [this message]
2023-06-30 8:27 ` Zhang, Qi Z
2023-06-30 10:46 ` Liu, Mingxia
2023-06-30 18:55 ` [PATCH v2] " Mingxia Liu
2023-07-03 2:21 ` Zhang, Qi Z
2023-07-03 3:17 ` Liu, Mingxia
2023-07-03 11:22 ` [PATCH v3] " Mingxia Liu
2023-07-03 6:51 ` Zhang, Qi Z
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=20230626111454.489844-1-mingxia.liu@intel.com \
--to=mingxia.liu@intel.com \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=jingjing.wu@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).