From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
To: <dev@dpdk.org>
Cc: <xavier.huwei@huawei.com>
Subject: [dpdk-dev] [PATCH 05/10] net/hns3: get device capability in primary process
Date: Wed, 1 Jul 2020 19:54:37 +0800 [thread overview]
Message-ID: <1593604482-47494-6-git-send-email-xavier.huwei@huawei.com> (raw)
In-Reply-To: <1593604482-47494-1-git-send-email-xavier.huwei@huawei.com>
This patch optimizes the code to get device capability in primary process,
and moves the code of getting PCI revison id in order to avoid evaluating
the private hw->revision of shared PMD-specific private data in slave
process.
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 57 +++++++++++++++++++++++++--------------
drivers/net/hns3/hns3_ethdev.h | 4 +--
drivers/net/hns3/hns3_ethdev_vf.c | 43 ++++++++++++++++++++---------
3 files changed, 69 insertions(+), 35 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 5a2f049..a43ed82 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2798,6 +2798,36 @@ hns3_parse_speed(int speed_cmd, uint32_t *speed)
}
static int
+hns3_get_capability(struct hns3_hw *hw)
+{
+ struct rte_pci_device *pci_dev;
+ struct rte_eth_dev *eth_dev;
+ uint16_t device_id;
+ uint8_t revision;
+ int ret;
+
+ eth_dev = &rte_eth_devices[hw->data->port_id];
+ pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+ device_id = pci_dev->id.device_id;
+
+ if (device_id == HNS3_DEV_ID_25GE_RDMA ||
+ device_id == HNS3_DEV_ID_50GE_RDMA ||
+ device_id == HNS3_DEV_ID_100G_RDMA_MACSEC)
+ hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_DCB_B, 1);
+
+ /* Get PCI revision id */
+ ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN,
+ HNS3_PCI_REVISION_ID);
+ if (ret != HNS3_PCI_REVISION_ID_LEN) {
+ PMD_INIT_LOG(ERR, "failed to read pci revision id: %d", ret);
+ return -EIO;
+ }
+ hw->revision = revision;
+
+ return 0;
+}
+
+static int
hns3_get_board_configuration(struct hns3_hw *hw)
{
struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
@@ -2872,6 +2902,13 @@ hns3_get_configuration(struct hns3_hw *hw)
return ret;
}
+ /* Get device capability */
+ ret = hns3_get_capability(hw);
+ if (ret) {
+ PMD_INIT_LOG(ERR, "failed to get device capability: %d.", ret);
+ return ret;
+ }
+
/* Get pf resource */
ret = hns3_query_pf_resource(hw);
if (ret) {
@@ -5366,26 +5403,12 @@ static const struct hns3_reset_ops hns3_reset_ops = {
static int
hns3_dev_init(struct rte_eth_dev *eth_dev)
{
- struct rte_device *dev = eth_dev->device;
- struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev);
struct hns3_adapter *hns = eth_dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
- uint16_t device_id = pci_dev->id.device_id;
- uint8_t revision;
int ret;
PMD_INIT_FUNC_TRACE();
- /* Get PCI revision id */
- ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN,
- HNS3_PCI_REVISION_ID);
- if (ret != HNS3_PCI_REVISION_ID_LEN) {
- PMD_INIT_LOG(ERR, "Failed to read pci revision id, ret = %d",
- ret);
- return -EIO;
- }
- hw->revision = revision;
-
eth_dev->process_private = (struct hns3_process_private *)
rte_zmalloc_socket("hns3_filter_list",
sizeof(struct hns3_process_private),
@@ -5407,12 +5430,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev)
hns3_mp_init_primary();
hw->adapter_state = HNS3_NIC_UNINITIALIZED;
-
- if (device_id == HNS3_DEV_ID_25GE_RDMA ||
- device_id == HNS3_DEV_ID_50GE_RDMA ||
- device_id == HNS3_DEV_ID_100G_RDMA_MACSEC)
- hns3_set_bit(hw->flag, HNS3_DEV_SUPPORT_DCB_B, 1);
-
hns->is_vf = false;
hw->data = eth_dev->data;
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index a4db1c9..c390263 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -402,7 +402,7 @@ struct hns3_hw {
uint16_t alloc_rss_size; /* RX queue number per TC */
uint16_t tx_qnum_per_tc; /* TX queue number per TC */
- uint32_t flag;
+ uint32_t capability;
struct hns3_port_base_vlan_config port_base_vlan_cfg;
/*
@@ -533,7 +533,7 @@ struct hns3_adapter {
#define HNS3_DEV_SUPPORT_DCB_B 0x0
#define hns3_dev_dcb_supported(hw) \
- hns3_get_bit((hw)->flag, HNS3_DEV_SUPPORT_DCB_B)
+ hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_DCB_B)
#define HNS3_DEV_PRIVATE_TO_HW(adapter) \
(&((struct hns3_adapter *)adapter)->hw)
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index afa79a7..04a8364 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1059,6 +1059,29 @@ hns3vf_interrupt_handler(void *param)
}
static int
+hns3vf_get_capability(struct hns3_hw *hw)
+{
+ struct rte_pci_device *pci_dev;
+ struct rte_eth_dev *eth_dev;
+ uint8_t revision;
+ int ret;
+
+ eth_dev = &rte_eth_devices[hw->data->port_id];
+ pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+
+ /* Get PCI revision id */
+ ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN,
+ HNS3_PCI_REVISION_ID);
+ if (ret != HNS3_PCI_REVISION_ID_LEN) {
+ PMD_INIT_LOG(ERR, "failed to read pci revision id: %d", ret);
+ return -EIO;
+ }
+ hw->revision = revision;
+
+ return 0;
+}
+
+static int
hns3vf_check_tqp_info(struct hns3_hw *hw)
{
uint16_t tqps_num;
@@ -1208,6 +1231,13 @@ hns3vf_get_configuration(struct hns3_hw *hw)
hw->mac.media_type = HNS3_MEDIA_TYPE_NONE;
hw->rss_dis_flag = false;
+ /* Get device capability */
+ ret = hns3vf_get_capability(hw);
+ if (ret) {
+ PMD_INIT_LOG(ERR, "failed to get device capability: %d.", ret);
+ return ret;
+ }
+
/* Get queue configuration from PF */
ret = hns3vf_get_queue_info(hw);
if (ret)
@@ -2474,25 +2504,12 @@ static const struct hns3_reset_ops hns3vf_reset_ops = {
static int
hns3vf_dev_init(struct rte_eth_dev *eth_dev)
{
- struct rte_device *dev = eth_dev->device;
- struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev);
struct hns3_adapter *hns = eth_dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
- uint8_t revision;
int ret;
PMD_INIT_FUNC_TRACE();
- /* Get PCI revision id */
- ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN,
- HNS3_PCI_REVISION_ID);
- if (ret != HNS3_PCI_REVISION_ID_LEN) {
- PMD_INIT_LOG(ERR, "Failed to read pci revision id, ret = %d",
- ret);
- return -EIO;
- }
- hw->revision = revision;
-
eth_dev->process_private = (struct hns3_process_private *)
rte_zmalloc_socket("hns3_filter_list",
sizeof(struct hns3_process_private),
--
2.7.4
next prev parent reply other threads:[~2020-07-01 11:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-01 11:54 [dpdk-dev] [PATCH 00/10] misc updates for hns3 PMD driver Wei Hu (Xavier)
2020-07-01 11:54 ` [dpdk-dev] [PATCH 01/10] net/hns3: support symmetric RSS Wei Hu (Xavier)
2020-07-01 11:54 ` [dpdk-dev] [PATCH 02/10] net/hns3: support LRO Wei Hu (Xavier)
2020-07-01 11:54 ` [dpdk-dev] [PATCH 03/10] net/hns3: decrease non-nearby memory access in Rx Wei Hu (Xavier)
2020-07-01 11:54 ` [dpdk-dev] [PATCH 04/10] net/hns3: support setting VF PVID by PF driver Wei Hu (Xavier)
2020-07-01 11:54 ` Wei Hu (Xavier) [this message]
2020-07-01 11:54 ` [dpdk-dev] [PATCH 06/10] net/hns3: clear residual hardware configurations on init Wei Hu (Xavier)
2020-07-01 11:54 ` [dpdk-dev] [PATCH 07/10] net/hns3: report Tx descriptor segment limitations Wei Hu (Xavier)
2020-07-01 11:54 ` [dpdk-dev] [PATCH 08/10] net/hns3: fix Rx buffer size Wei Hu (Xavier)
2020-07-01 11:54 ` [dpdk-dev] [PATCH 09/10] net/hns3: fix reassembling multiple segment packets in Tx Wei Hu (Xavier)
2020-07-01 11:54 ` [dpdk-dev] [PATCH 10/10] net/hns3: add Scattered Rx and Multiprocess to feature list Wei Hu (Xavier)
2020-07-03 8:30 ` [dpdk-dev] [PATCH 00/10] misc updates for hns3 PMD driver 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=1593604482-47494-6-git-send-email-xavier.huwei@huawei.com \
--to=xavier.huwei@huawei.com \
--cc=dev@dpdk.org \
/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).