From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: "Min Hu (Connor)" <humin29@huawei.com>,
Yisen Zhuang <yisen.zhuang@huawei.com>,
Lijun Ou <oulijun@huawei.com>
Subject: [PATCH 1/5] net/hns3: refactor adapter state dump
Date: Thu, 14 Apr 2022 21:00:52 +0800 [thread overview]
Message-ID: <20220414130056.37428-2-humin29@huawei.com> (raw)
In-Reply-To: <20220414130056.37428-1-humin29@huawei.com>
This patch refactor adapter state dump.
Fixes: 1a03c659cb9d ("net/hns3: dump device basic info")
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev_dump.c | 41 ++++++++++++++++-------------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
index beffdd9e32..8b7a90a67e 100644
--- a/drivers/net/hns3/hns3_ethdev_dump.c
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -13,26 +13,31 @@
#include "hns3_rxtx.h"
static const char *
-get_adapter_state_name(uint32_t state)
-{
- static const char * const state_name[] = {
- "UNINITIALIZED",
- "INITIALIZED",
- "CONFIGURING",
- "CONFIGURED",
- "STARTING",
- "STARTED",
- "STOPPING",
- "CLOSING",
- "CLOSED",
- "REMOVED",
- "NSTATES"
+get_adapter_state_name(enum hns3_adapter_state state)
+{
+ const struct {
+ enum hns3_adapter_state state;
+ const char *name;
+ } adapter_state_name[] = {
+ {HNS3_NIC_UNINITIALIZED, "UNINITIALIZED"},
+ {HNS3_NIC_INITIALIZED, "INITIALIZED"},
+ {HNS3_NIC_CONFIGURING, "CONFIGURING"},
+ {HNS3_NIC_CONFIGURED, "CONFIGURED"},
+ {HNS3_NIC_STARTING, "STARTING"},
+ {HNS3_NIC_STARTED, "STARTED"},
+ {HNS3_NIC_STOPPING, "STOPPING"},
+ {HNS3_NIC_CLOSING, "CLOSING"},
+ {HNS3_NIC_CLOSED, "CLOSED"},
+ {HNS3_NIC_REMOVED, "REMOVED"},
+ {HNS3_NIC_NSTATES, "NSTATES"},
};
+ uint32_t i;
- if (state < RTE_DIM(state_name))
- return state_name[state];
- else
- return "unknown";
+ for (i = 0; i < RTE_DIM(adapter_state_name); i++)
+ if (state == adapter_state_name[i].state)
+ return adapter_state_name[i].name;
+
+ return "Unknown";
}
static const char *
--
2.33.0
next prev parent reply other threads:[~2022-04-14 13:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-14 13:00 [PATCH 0/5] refactor for device info dump Min Hu (Connor)
2022-04-14 13:00 ` Min Hu (Connor) [this message]
2022-04-14 13:00 ` [PATCH 2/5] net/hns3: refactor feature capability dump Min Hu (Connor)
2022-04-14 13:00 ` [PATCH 3/5] net/hns3: refactor queue info dump Min Hu (Connor)
2022-04-14 13:00 ` [PATCH 4/5] net/hns3: fix dump TM info Min Hu (Connor)
2022-04-14 13:00 ` [PATCH 5/5] net/hns3: fix dump device info Min Hu (Connor)
2022-05-05 16:28 ` [PATCH 0/5] refactor for device info dump Ferruh Yigit
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=20220414130056.37428-2-humin29@huawei.com \
--to=humin29@huawei.com \
--cc=dev@dpdk.org \
--cc=oulijun@huawei.com \
--cc=yisen.zhuang@huawei.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).