* [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver
@ 2020-04-10 11:09 Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 1/9] net/hns3: simplify process of some return values Wei Hu (Xavier)
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Wei Hu (Xavier) @ 2020-04-10 11:09 UTC (permalink / raw)
To: dev
This series are cleanup and bugfix for hns3 PMD driver.
Chengchang Tang (3):
net/hns3: fix failure when adding a MC MAC address
net/hns3: fix default VLAN filter configuration for PF
net/hns3: fix VLAN filter when setting promisucous mode
Chengwen Feng (2):
net/hns3: fix Rx interrupt after reset
net/hns3: fix residual flow directory rules when app restart
Lijun Ou (3):
net/hns3: simplify process of some return values
net/hns3: fix missing RSS in Rx offload capability
net/hns3: fix missing length of hash key when getting RSS
Wei Hu (Xavier) (1):
net/hns3: replace zero with macro defined in DPDK framework
drivers/net/hns3/hns3_dcb.c | 28 +--
drivers/net/hns3/hns3_ethdev.c | 403 ++++++++++++++++++++++++------
drivers/net/hns3/hns3_ethdev_vf.c | 342 +++++++++++++++++++------
drivers/net/hns3/hns3_fdir.c | 21 ++
drivers/net/hns3/hns3_intr.c | 2 +
drivers/net/hns3/hns3_rss.c | 4 +-
drivers/net/hns3/hns3_rxtx.c | 27 +-
drivers/net/hns3/hns3_rxtx.h | 2 +
8 files changed, 645 insertions(+), 184 deletions(-)
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH 1/9] net/hns3: simplify process of some return values
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
@ 2020-04-10 11:09 ` Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 2/9] net/hns3: replace zero with macro defined in DPDK framework Wei Hu (Xavier)
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Wei Hu (Xavier) @ 2020-04-10 11:09 UTC (permalink / raw)
To: dev
From: Lijun Ou <oulijun@huawei.com>
Currently, the return value processing of some functions can be combined
and the result is that some codes can be optimized.
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
drivers/net/hns3/hns3_dcb.c | 28 +++++++++-------------------
drivers/net/hns3/hns3_ethdev.c | 27 ++++++++-------------------
drivers/net/hns3/hns3_ethdev_vf.c | 18 ++++++------------
3 files changed, 23 insertions(+), 50 deletions(-)
diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c
index 8688de2a7..3fde222dc 100644
--- a/drivers/net/hns3/hns3_dcb.c
+++ b/drivers/net/hns3/hns3_dcb.c
@@ -749,12 +749,10 @@ hns3_dcb_schd_mode_cfg(struct hns3_hw *hw)
}
ret = hns3_dcb_lvl34_schd_mode_cfg(hw);
- if (ret) {
+ if (ret)
hns3_err(hw, "config lvl34_schd_mode failed: %d", ret);
- return ret;
- }
- return 0;
+ return ret;
}
static int
@@ -845,12 +843,10 @@ hns3_dcb_dwrr_cfg(struct hns3_hw *hw)
}
ret = hns3_dcb_pri_dwrr_cfg(hw);
- if (ret) {
+ if (ret)
hns3_err(hw, "config pri_dwrr failed: %d", ret);
- return ret;
- }
- return 0;
+ return ret;
}
static int
@@ -932,12 +928,10 @@ hns3_pri_q_qs_cfg(struct hns3_hw *hw)
/* Cfg q -> qs mapping */
ret = hns3_q_to_qs_map(hw);
- if (ret) {
+ if (ret)
hns3_err(hw, "nq_to_qs mapping fail: %d", ret);
- return ret;
- }
- return 0;
+ return ret;
}
static int
@@ -1552,12 +1546,10 @@ hns3_update_queue_map_configure(struct hns3_adapter *hns)
hns3_dcb_update_tc_queue_mapping(hw, nb_rx_q, nb_tx_q);
ret = hns3_q_to_qs_map(hw);
- if (ret) {
+ if (ret)
hns3_err(hw, "failed to map nq to qs! ret = %d", ret);
- return ret;
- }
- return 0;
+ return ret;
}
int
@@ -1569,10 +1561,8 @@ hns3_dcb_cfg_update(struct hns3_adapter *hns)
if ((uint32_t)mq_mode & ETH_MQ_RX_DCB_FLAG) {
ret = hns3_dcb_configure(hns);
- if (ret) {
+ if (ret)
hns3_err(hw, "Failed to config dcb: %d", ret);
- return ret;
- }
} else {
/*
* Update queue map without PFC configuration,
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 215e2b2c6..e55e46e38 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -312,11 +312,9 @@ hns3_restore_vlan_table(struct hns3_adapter *hns)
uint16_t vlan_id;
int ret = 0;
- if (pf->port_base_vlan_cfg.state == HNS3_PORT_BASE_VLAN_ENABLE) {
- ret = hns3_vlan_pvid_configure(hns, pf->port_base_vlan_cfg.pvid,
- 1);
- return ret;
- }
+ if (pf->port_base_vlan_cfg.state == HNS3_PORT_BASE_VLAN_ENABLE)
+ return hns3_vlan_pvid_configure(hns,
+ pf->port_base_vlan_cfg.pvid, 1);
LIST_FOREACH(vlan_entry, &pf->vlan_list, next) {
if (vlan_entry->hd_tbl_status) {
@@ -2238,12 +2236,10 @@ hns3_config_mtu(struct hns3_hw *hw, uint16_t mps)
}
ret = hns3_buffer_alloc(hw);
- if (ret) {
+ if (ret)
hns3_err(hw, "Failed to allocate buffer, ret = %d", ret);
- return ret;
- }
- return 0;
+ return ret;
}
static int
@@ -2725,12 +2721,10 @@ hns3_get_configuration(struct hns3_hw *hw)
}
ret = hns3_get_board_configuration(hw);
- if (ret) {
+ if (ret)
PMD_INIT_LOG(ERR, "Failed to get board configuration: %d", ret);
- return ret;
- }
- return 0;
+ return ret;
}
static int
@@ -3664,7 +3658,6 @@ hns3_set_promisc_mode(struct hns3_hw *hw, bool en_uc_pmc, bool en_mc_pmc)
struct hns3_promisc_param param;
bool en_bc_pmc = true;
uint8_t vf_id;
- int ret;
/*
* In current version VF is not supported when PF is driven by DPDK
@@ -3674,11 +3667,7 @@ hns3_set_promisc_mode(struct hns3_hw *hw, bool en_uc_pmc, bool en_mc_pmc)
vf_id = 0;
hns3_promisc_param_init(¶m, en_uc_pmc, en_mc_pmc, en_bc_pmc, vf_id);
- ret = hns3_cmd_set_promisc_mode(hw, ¶m);
- if (ret)
- return ret;
-
- return 0;
+ return hns3_cmd_set_promisc_mode(hw, ¶m);
}
static int
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 8be743d19..a1286a71e 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -283,10 +283,9 @@ hns3vf_add_mc_mac_addr(struct hns3_adapter *hns,
mac_addr);
hns3_err(hw, "Failed to add mc mac addr(%s) for vf: %d",
mac_str, ret);
- return ret;
}
- return 0;
+ return ret;
}
static int
@@ -306,10 +305,9 @@ hns3vf_remove_mc_mac_addr(struct hns3_adapter *hns,
mac_addr);
hns3_err(hw, "Failed to remove mc mac addr(%s) for vf: %d",
mac_str, ret);
- return ret;
}
- return 0;
+ return ret;
}
static int
@@ -550,13 +548,11 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint8_t vector_id,
op_str = mmap ? "Map" : "Unmap";
ret = hns3_send_mbx_msg(hw, code, 0, (uint8_t *)&bind_msg,
sizeof(bind_msg), false, NULL, 0);
- if (ret) {
+ if (ret)
hns3_err(hw, "%s TQP %d fail, vector_id is %d, ret is %d.",
op_str, queue_id, bind_msg.vector_id, ret);
- return ret;
- }
- return 0;
+ return ret;
}
static int
@@ -1675,12 +1671,10 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
return ret;
ret = hns3_start_queues(hns, reset_queue);
- if (ret) {
+ if (ret)
hns3_err(hw, "Failed to start queues: %d", ret);
- return ret;
- }
- return 0;
+ return ret;
}
static int
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH 2/9] net/hns3: replace zero with macro defined in DPDK framework
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 1/9] net/hns3: simplify process of some return values Wei Hu (Xavier)
@ 2020-04-10 11:09 ` Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 3/9] net/hns3: fix failure when adding a MC MAC address Wei Hu (Xavier)
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Wei Hu (Xavier) @ 2020-04-10 11:09 UTC (permalink / raw)
To: dev
From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
This patch replaces the specific macro named RTE_INTR_VEC_ZERO_OFFSET
provided by DPDK framework instead of the magic number 0.
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 8 ++++----
drivers/net/hns3/hns3_ethdev_vf.c | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index e55e46e38..7ed5e7e89 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -4185,9 +4185,9 @@ hns3_map_rx_interrupt(struct rte_eth_dev *dev)
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ uint8_t base = RTE_INTR_VEC_ZERO_OFFSET;
+ uint8_t vec = RTE_INTR_VEC_ZERO_OFFSET;
uint32_t intr_vector;
- uint8_t base = 0;
- uint8_t vec = 0;
uint16_t q_id;
int ret;
@@ -4319,8 +4319,8 @@ hns3_unmap_rx_interrupt(struct rte_eth_dev *dev)
struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
- uint8_t base = 0;
- uint8_t vec = 0;
+ uint8_t base = RTE_INTR_VEC_ZERO_OFFSET;
+ uint8_t vec = RTE_INTR_VEC_ZERO_OFFSET;
uint16_t q_id;
if (dev->data->dev_conf.intr_conf.rxq == 0)
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index a1286a71e..edbcd5bd6 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1542,8 +1542,8 @@ hns3vf_unmap_rx_interrupt(struct rte_eth_dev *dev)
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
- uint8_t base = 0;
- uint8_t vec = 0;
+ uint8_t base = RTE_INTR_VEC_ZERO_OFFSET;
+ uint8_t vec = RTE_INTR_VEC_ZERO_OFFSET;
uint16_t q_id;
if (dev->data->dev_conf.intr_conf.rxq == 0)
@@ -1683,9 +1683,9 @@ hns3vf_map_rx_interrupt(struct rte_eth_dev *dev)
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ uint8_t base = RTE_INTR_VEC_ZERO_OFFSET;
+ uint8_t vec = RTE_INTR_VEC_ZERO_OFFSET;
uint32_t intr_vector;
- uint8_t base = 0;
- uint8_t vec = 0;
uint16_t q_id;
int ret;
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH 3/9] net/hns3: fix failure when adding a MC MAC address
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 1/9] net/hns3: simplify process of some return values Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 2/9] net/hns3: replace zero with macro defined in DPDK framework Wei Hu (Xavier)
@ 2020-04-10 11:09 ` Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 4/9] net/hns3: fix Rx interrupt after reset Wei Hu (Xavier)
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Wei Hu (Xavier) @ 2020-04-10 11:09 UTC (permalink / raw)
To: dev
From: Chengchang Tang <tangchengchang@huawei.com>
Currently, when upper application calls the rte_eth_dev_mac_addr_add API
function to add a MC mac address based on hns3 PF/VF device, it will fail.
In hns3 network engine adding UC and MC mac address with different commands
with firmware. We need to determine whether the input address is a UC or a
MC address to call different commands in the '.mac_addr_add' and
'.mac_addr_remove' ops implementation functions in hns3 PF and VF driver as
below:
hns3_add_mac_addr
hns3vf_add_uc_mac_addr
hns3_remove_mac_addr
hns3vf_remove_mac_addr
By the way, it is recommended calling the rte_eth_dev_set_mc_addr_list API
function to set the MC mac address, because using the
rte_eth_dev_mac_addr_add API function to set MC mac address may affect the
specifications of UC mac addresses.
Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations")
Cc: stable@dpdk.org
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 133 ++++++++++++++---
drivers/net/hns3/hns3_ethdev_vf.c | 231 +++++++++++++++++++++++-------
2 files changed, 295 insertions(+), 69 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 7ed5e7e89..2d0b78d70 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -79,6 +79,11 @@ static int hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid,
int on);
static int hns3_update_speed_duplex(struct rte_eth_dev *eth_dev);
+static int hns3_add_mc_addr(struct hns3_hw *hw,
+ struct rte_ether_addr *mac_addr);
+static int hns3_remove_mc_addr(struct hns3_hw *hw,
+ struct rte_ether_addr *mac_addr);
+
static void
hns3_pf_disable_irq0(struct hns3_hw *hw)
{
@@ -1407,6 +1412,53 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
return ret;
}
+static int
+hns3_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
+{
+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
+ struct rte_ether_addr *addr;
+ int ret;
+ int i;
+
+ for (i = 0; i < hw->mc_addrs_num; i++) {
+ addr = &hw->mc_addrs[i];
+ /* Check if there are duplicate addresses */
+ if (rte_is_same_ether_addr(addr, mac_addr)) {
+ rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+ addr);
+ hns3_err(hw, "failed to add mc mac addr, same addrs"
+ "(%s) is added by the set_mc_mac_addr_list "
+ "API", mac_str);
+ return -EINVAL;
+ }
+ }
+
+ ret = hns3_add_mc_addr(hw, mac_addr);
+ if (ret) {
+ rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+ mac_addr);
+ hns3_err(hw, "failed to add mc mac addr(%s), ret = %d",
+ mac_str, ret);
+ }
+ return ret;
+}
+
+static int
+hns3_remove_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
+{
+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
+ int ret;
+
+ ret = hns3_remove_mc_addr(hw, mac_addr);
+ if (ret) {
+ rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+ mac_addr);
+ hns3_err(hw, "failed to remove mc mac addr(%s), ret = %d",
+ mac_str, ret);
+ }
+ return ret;
+}
+
static int
hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
uint32_t idx, __attribute__ ((unused)) uint32_t pool)
@@ -1416,12 +1468,27 @@ hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
int ret;
rte_spinlock_lock(&hw->lock);
- ret = hns3_add_uc_addr_common(hw, mac_addr);
+
+ /*
+ * In hns3 network engine adding UC and MC mac address with different
+ * commands with firmware. We need to determine whether the input
+ * address is a UC or a MC address to call different commands.
+ * By the way, it is recommended calling the API function named
+ * rte_eth_dev_set_mc_addr_list to set the MC mac address, because
+ * using the rte_eth_dev_mac_addr_add API function to set MC mac address
+ * may affect the specifications of UC mac addresses.
+ */
+ if (rte_is_multicast_ether_addr(mac_addr))
+ ret = hns3_add_mc_addr_common(hw, mac_addr);
+ else
+ ret = hns3_add_uc_addr_common(hw, mac_addr);
+
if (ret) {
rte_spinlock_unlock(&hw->lock);
rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
mac_addr);
- hns3_err(hw, "Failed to add mac addr(%s): %d", mac_str, ret);
+ hns3_err(hw, "failed to add mac addr(%s), ret = %d", mac_str,
+ ret);
return ret;
}
@@ -1443,7 +1510,7 @@ hns3_remove_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
if (!rte_is_valid_assigned_ether_addr(mac_addr)) {
rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
mac_addr);
- hns3_err(hw, "Remove unicast mac addr err! addr(%s) invalid",
+ hns3_err(hw, "remove unicast mac addr err! addr(%s) invalid",
mac_str);
return -EINVAL;
}
@@ -1470,16 +1537,18 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx)
int ret;
rte_spinlock_lock(&hw->lock);
- ret = hns3_remove_uc_addr_common(hw, mac_addr);
+
+ if (rte_is_multicast_ether_addr(mac_addr))
+ ret = hns3_remove_mc_addr_common(hw, mac_addr);
+ else
+ ret = hns3_remove_uc_addr_common(hw, mac_addr);
+ rte_spinlock_unlock(&hw->lock);
if (ret) {
- rte_spinlock_unlock(&hw->lock);
rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
mac_addr);
- hns3_err(hw, "Failed to remove mac addr(%s): %d", mac_str, ret);
- return;
+ hns3_err(hw, "failed to remove mac addr(%s), ret = %d", mac_str,
+ ret);
}
-
- rte_spinlock_unlock(&hw->lock);
}
static int
@@ -1575,19 +1644,22 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del)
for (i = 0; i < HNS3_UC_MACADDR_NUM; i++) {
addr = &hw->data->mac_addrs[i];
- if (!rte_is_valid_assigned_ether_addr(addr))
+ if (rte_is_zero_ether_addr(addr))
continue;
- if (del)
- ret = hns3_remove_uc_addr_common(hw, addr);
+ if (rte_is_multicast_ether_addr(addr))
+ ret = del ? hns3_remove_mc_addr(hw, addr) :
+ hns3_add_mc_addr(hw, addr);
else
- ret = hns3_add_uc_addr_common(hw, addr);
+ ret = del ? hns3_remove_uc_addr_common(hw, addr) :
+ hns3_add_uc_addr_common(hw, addr);
+
if (ret) {
err = ret;
rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
addr);
- hns3_dbg(hw,
- "Failed to %s mac addr(%s). ret:%d i:%d",
- del ? "remove" : "restore", mac_str, ret, i);
+ hns3_err(hw, "failed to %s mac addr(%s) index:%d "
+ "ret = %d.", del ? "remove" : "restore",
+ mac_str, i, ret);
}
}
return err;
@@ -1634,7 +1706,7 @@ hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
if (!rte_is_multicast_ether_addr(mac_addr)) {
rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
mac_addr);
- hns3_err(hw, "Failed to add mc mac addr, addr(%s) invalid",
+ hns3_err(hw, "failed to add mc mac addr, addr(%s) invalid",
mac_str);
return -EINVAL;
}
@@ -1663,7 +1735,7 @@ hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
hns3_err(hw, "mc mac vlan table is full");
rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
mac_addr);
- hns3_err(hw, "Failed to add mc mac addr(%s): %d", mac_str, ret);
+ hns3_err(hw, "failed to add mc mac addr(%s): %d", mac_str, ret);
}
return ret;
@@ -1728,7 +1800,7 @@ hns3_set_mc_addr_chk_param(struct hns3_hw *hw,
uint32_t j;
if (nb_mc_addr > HNS3_MC_MACADDR_NUM) {
- hns3_err(hw, "Failed to set mc mac addr, nb_mc_addr(%d) "
+ hns3_err(hw, "failed to set mc mac addr, nb_mc_addr(%d) "
"invalid. valid range: 0~%d",
nb_mc_addr, HNS3_MC_MACADDR_NUM);
return -EINVAL;
@@ -1741,7 +1813,7 @@ hns3_set_mc_addr_chk_param(struct hns3_hw *hw,
rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
addr);
hns3_err(hw,
- "Failed to set mc mac addr, addr(%s) invalid.",
+ "failed to set mc mac addr, addr(%s) invalid.",
mac_str);
return -EINVAL;
}
@@ -1752,12 +1824,30 @@ hns3_set_mc_addr_chk_param(struct hns3_hw *hw,
rte_ether_format_addr(mac_str,
RTE_ETHER_ADDR_FMT_SIZE,
addr);
- hns3_err(hw, "Failed to set mc mac addr, "
+ hns3_err(hw, "failed to set mc mac addr, "
"addrs invalid. two same addrs(%s).",
mac_str);
return -EINVAL;
}
}
+
+ /*
+ * Check if there are duplicate addresses between mac_addrs
+ * and mc_addr_set
+ */
+ for (j = 0; j < HNS3_UC_MACADDR_NUM; j++) {
+ if (rte_is_same_ether_addr(addr,
+ &hw->data->mac_addrs[j])) {
+ rte_ether_format_addr(mac_str,
+ RTE_ETHER_ADDR_FMT_SIZE,
+ addr);
+ hns3_err(hw, "failed to set mc mac addr, "
+ "addrs invalid. addrs(%s) has already "
+ "configured in mac_addr add API",
+ mac_str);
+ return -EINVAL;
+ }
+ }
}
return 0;
@@ -3541,6 +3631,7 @@ hns3_get_mac_ethertype_cmd_status(uint16_t cmdq_resp, uint8_t resp_code)
"add mac ethertype failed for undefined, code=%d.",
resp_code);
return_status = -EIO;
+ break;
}
return return_status;
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index edbcd5bd6..48b074bff 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -59,6 +59,10 @@ static enum hns3_reset_level hns3vf_get_reset_level(struct hns3_hw *hw,
static int hns3vf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
static int hns3vf_dev_configure_vlan(struct rte_eth_dev *dev);
+static int hns3vf_add_mc_mac_addr(struct hns3_hw *hw,
+ struct rte_ether_addr *mac_addr);
+static int hns3vf_remove_mc_mac_addr(struct hns3_hw *hw,
+ struct rte_ether_addr *mac_addr);
/* set PCI bus mastering */
static void
hns3vf_set_bus_master(const struct rte_pci_device *device, bool op)
@@ -134,6 +138,76 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op)
return -ENXIO;
}
+static int
+hns3vf_add_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
+{
+ /* mac address was checked by upper level interface */
+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
+ int ret;
+
+ ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST,
+ HNS3_MBX_MAC_VLAN_UC_ADD, mac_addr->addr_bytes,
+ RTE_ETHER_ADDR_LEN, false, NULL, 0);
+ if (ret) {
+ rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+ mac_addr);
+ hns3_err(hw, "failed to add uc mac addr(%s), ret = %d",
+ mac_str, ret);
+ }
+ return ret;
+}
+
+static int
+hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
+{
+ /* mac address was checked by upper level interface */
+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
+ int ret;
+
+ ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST,
+ HNS3_MBX_MAC_VLAN_UC_REMOVE,
+ mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN,
+ false, NULL, 0);
+ if (ret) {
+ rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+ mac_addr);
+ hns3_err(hw, "failed to add uc mac addr(%s), ret = %d",
+ mac_str, ret);
+ }
+ return ret;
+}
+
+static int
+hns3vf_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
+{
+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
+ struct rte_ether_addr *addr;
+ int ret;
+ int i;
+
+ for (i = 0; i < hw->mc_addrs_num; i++) {
+ addr = &hw->mc_addrs[i];
+ /* Check if there are duplicate addresses */
+ if (rte_is_same_ether_addr(addr, mac_addr)) {
+ rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+ addr);
+ hns3_err(hw, "failed to add mc mac addr, same addrs"
+ "(%s) is added by the set_mc_mac_addr_list "
+ "API", mac_str);
+ return -EINVAL;
+ }
+ }
+
+ ret = hns3vf_add_mc_mac_addr(hw, mac_addr);
+ if (ret) {
+ rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+ mac_addr);
+ hns3_err(hw, "failed to add mc mac addr(%s), ret = %d",
+ mac_str, ret);
+ }
+ return ret;
+}
+
static int
hns3vf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
__attribute__ ((unused)) uint32_t idx,
@@ -144,14 +218,26 @@ hns3vf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
int ret;
rte_spinlock_lock(&hw->lock);
- ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST,
- HNS3_MBX_MAC_VLAN_UC_ADD, mac_addr->addr_bytes,
- RTE_ETHER_ADDR_LEN, false, NULL, 0);
+
+ /*
+ * In hns3 network engine adding UC and MC mac address with different
+ * commands with firmware. We need to determine whether the input
+ * address is a UC or a MC address to call different commands.
+ * By the way, it is recommended calling the API function named
+ * rte_eth_dev_set_mc_addr_list to set the MC mac address, because
+ * using the rte_eth_dev_mac_addr_add API function to set MC mac address
+ * may affect the specifications of UC mac addresses.
+ */
+ if (rte_is_multicast_ether_addr(mac_addr))
+ ret = hns3vf_add_mc_addr_common(hw, mac_addr);
+ else
+ ret = hns3vf_add_uc_mac_addr(hw, mac_addr);
+
rte_spinlock_unlock(&hw->lock);
if (ret) {
rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
mac_addr);
- hns3_err(hw, "Failed to add mac addr(%s) for vf: %d", mac_str,
+ hns3_err(hw, "failed to add mac addr(%s), ret = %d", mac_str,
ret);
}
@@ -168,15 +254,17 @@ hns3vf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx)
int ret;
rte_spinlock_lock(&hw->lock);
- ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST,
- HNS3_MBX_MAC_VLAN_UC_REMOVE,
- mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN, false,
- NULL, 0);
+
+ if (rte_is_multicast_ether_addr(mac_addr))
+ ret = hns3vf_remove_mc_mac_addr(hw, mac_addr);
+ else
+ ret = hns3vf_remove_uc_mac_addr(hw, mac_addr);
+
rte_spinlock_unlock(&hw->lock);
if (ret) {
rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
mac_addr);
- hns3_err(hw, "Failed to remove mac addr(%s) for vf: %d",
+ hns3_err(hw, "failed to remove mac addr(%s), ret = %d",
mac_str, ret);
}
}
@@ -239,39 +327,39 @@ hns3vf_configure_mac_addr(struct hns3_adapter *hns, bool del)
{
struct hns3_hw *hw = &hns->hw;
struct rte_ether_addr *addr;
- enum hns3_mbx_mac_vlan_subcode opcode;
char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
- int ret = 0;
+ int err = 0;
+ int ret;
int i;
- if (del)
- opcode = HNS3_MBX_MAC_VLAN_UC_REMOVE;
- else
- opcode = HNS3_MBX_MAC_VLAN_UC_ADD;
for (i = 0; i < HNS3_VF_UC_MACADDR_NUM; i++) {
addr = &hw->data->mac_addrs[i];
- if (!rte_is_valid_assigned_ether_addr(addr))
+ if (rte_is_zero_ether_addr(addr))
continue;
- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, addr);
- hns3_dbg(hw, "rm mac addr: %s", mac_str);
- ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_UNICAST, opcode,
- addr->addr_bytes, RTE_ETHER_ADDR_LEN,
- false, NULL, 0);
+ if (rte_is_multicast_ether_addr(addr))
+ ret = del ? hns3vf_remove_mc_mac_addr(hw, addr) :
+ hns3vf_add_mc_mac_addr(hw, addr);
+ else
+ ret = del ? hns3vf_remove_uc_mac_addr(hw, addr) :
+ hns3vf_add_uc_mac_addr(hw, addr);
+
if (ret) {
- hns3_err(hw, "Failed to remove mac addr for vf: %d",
- ret);
- break;
+ err = ret;
+ rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
+ addr);
+ hns3_err(hw, "failed to %s mac addr(%s) index:%d "
+ "ret = %d.", del ? "remove" : "restore",
+ mac_str, i, ret);
}
}
- return ret;
+ return err;
}
static int
-hns3vf_add_mc_mac_addr(struct hns3_adapter *hns,
+hns3vf_add_mc_mac_addr(struct hns3_hw *hw,
struct rte_ether_addr *mac_addr)
{
char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
- struct hns3_hw *hw = &hns->hw;
int ret;
ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_MULTICAST,
@@ -289,11 +377,10 @@ hns3vf_add_mc_mac_addr(struct hns3_adapter *hns,
}
static int
-hns3vf_remove_mc_mac_addr(struct hns3_adapter *hns,
+hns3vf_remove_mc_mac_addr(struct hns3_hw *hw,
struct rte_ether_addr *mac_addr)
{
char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
- struct hns3_hw *hw = &hns->hw;
int ret;
ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_MULTICAST,
@@ -311,45 +398,92 @@ hns3vf_remove_mc_mac_addr(struct hns3_adapter *hns,
}
static int
-hns3vf_set_mc_mac_addr_list(struct rte_eth_dev *dev,
- struct rte_ether_addr *mc_addr_set,
- uint32_t nb_mc_addr)
+hns3vf_set_mc_addr_chk_param(struct hns3_hw *hw,
+ struct rte_ether_addr *mc_addr_set,
+ uint32_t nb_mc_addr)
{
- struct hns3_adapter *hns = dev->data->dev_private;
- struct hns3_hw *hw = &hns->hw;
- struct rte_ether_addr *addr;
char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
- int cur_addr_num;
- int set_addr_num;
- int num;
- int ret;
- int i;
+ struct rte_ether_addr *addr;
+ uint32_t i;
+ uint32_t j;
if (nb_mc_addr > HNS3_MC_MACADDR_NUM) {
- hns3_err(hw, "Failed to set mc mac addr, nb_mc_addr(%d) "
+ hns3_err(hw, "failed to set mc mac addr, nb_mc_addr(%d) "
"invalid. valid range: 0~%d",
nb_mc_addr, HNS3_MC_MACADDR_NUM);
return -EINVAL;
}
- set_addr_num = (int)nb_mc_addr;
- for (i = 0; i < set_addr_num; i++) {
+ /* Check if input mac addresses are valid */
+ for (i = 0; i < nb_mc_addr; i++) {
addr = &mc_addr_set[i];
if (!rte_is_multicast_ether_addr(addr)) {
rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
addr);
hns3_err(hw,
- "Failed to set mc mac addr, addr(%s) invalid.",
+ "failed to set mc mac addr, addr(%s) invalid.",
mac_str);
return -EINVAL;
}
+
+ /* Check if there are duplicate addresses */
+ for (j = i + 1; j < nb_mc_addr; j++) {
+ if (rte_is_same_ether_addr(addr, &mc_addr_set[j])) {
+ rte_ether_format_addr(mac_str,
+ RTE_ETHER_ADDR_FMT_SIZE,
+ addr);
+ hns3_err(hw, "failed to set mc mac addr, "
+ "addrs invalid. two same addrs(%s).",
+ mac_str);
+ return -EINVAL;
+ }
+ }
+
+ /*
+ * Check if there are duplicate addresses between mac_addrs
+ * and mc_addr_set
+ */
+ for (j = 0; j < HNS3_VF_UC_MACADDR_NUM; j++) {
+ if (rte_is_same_ether_addr(addr,
+ &hw->data->mac_addrs[j])) {
+ rte_ether_format_addr(mac_str,
+ RTE_ETHER_ADDR_FMT_SIZE,
+ addr);
+ hns3_err(hw, "failed to set mc mac addr, "
+ "addrs invalid. addrs(%s) has already "
+ "configured in mac_addr add API",
+ mac_str);
+ return -EINVAL;
+ }
+ }
}
+
+ return 0;
+}
+
+static int
+hns3vf_set_mc_mac_addr_list(struct rte_eth_dev *dev,
+ struct rte_ether_addr *mc_addr_set,
+ uint32_t nb_mc_addr)
+{
+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ struct rte_ether_addr *addr;
+ int cur_addr_num;
+ int set_addr_num;
+ int num;
+ int ret;
+ int i;
+
+ ret = hns3vf_set_mc_addr_chk_param(hw, mc_addr_set, nb_mc_addr);
+ if (ret)
+ return ret;
+
rte_spinlock_lock(&hw->lock);
cur_addr_num = hw->mc_addrs_num;
for (i = 0; i < cur_addr_num; i++) {
num = cur_addr_num - i - 1;
addr = &hw->mc_addrs[num];
- ret = hns3vf_remove_mc_mac_addr(hns, addr);
+ ret = hns3vf_remove_mc_mac_addr(hw, addr);
if (ret) {
rte_spinlock_unlock(&hw->lock);
return ret;
@@ -358,9 +492,10 @@ hns3vf_set_mc_mac_addr_list(struct rte_eth_dev *dev,
hw->mc_addrs_num--;
}
+ set_addr_num = (int)nb_mc_addr;
for (i = 0; i < set_addr_num; i++) {
addr = &mc_addr_set[i];
- ret = hns3vf_add_mc_mac_addr(hns, addr);
+ ret = hns3vf_add_mc_mac_addr(hw, addr);
if (ret) {
rte_spinlock_unlock(&hw->lock);
return ret;
@@ -389,9 +524,9 @@ hns3vf_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del)
if (!rte_is_multicast_ether_addr(addr))
continue;
if (del)
- ret = hns3vf_remove_mc_mac_addr(hns, addr);
+ ret = hns3vf_remove_mc_mac_addr(hw, addr);
else
- ret = hns3vf_add_mc_mac_addr(hns, addr);
+ ret = hns3vf_add_mc_mac_addr(hw, addr);
if (ret) {
err = ret;
rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH 4/9] net/hns3: fix Rx interrupt after reset
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
` (2 preceding siblings ...)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 3/9] net/hns3: fix failure when adding a MC MAC address Wei Hu (Xavier)
@ 2020-04-10 11:09 ` Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 5/9] net/hns3: fix residual flow directory rules when app restart Wei Hu (Xavier)
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Wei Hu (Xavier) @ 2020-04-10 11:09 UTC (permalink / raw)
To: dev
From: Chengwen Feng <fengchengwen@huawei.com>
Currently, Rx interrupt cannot work normally after reset (such as FLR,
global reset and IMP reset), when running l3fwd-power application based on
hns3 network engine.
The root cause is that the hardware configuration about Rx interrupt does
not recover after reset.
This patch fixes it with the following modification.
1. The internal static function named hns3(vf)_init_ring_with_vector is
moved from hns3_init_pf to hns3(vf)_init_hardware because
hns3(vf)_init_hardware is called both in the initialization and the
RESET_STAGE_DEV_INIT stage of the reset process.
2. The internal static function named hns3(vf)_restore_rx_interrupt is
added in hns3(vf)_restore_conf, it is used to recover hardware
configuration about interrupt vectors of rx queues in the
RESET_STAGE_DEV_INIT stage of the reset process.
3. The internal static function named hns3_dev_all_rx_queue_intr_enable and
hns3_enable_all_queues are added in hns3(vf)_dev_start(which called in
the initialization, so after calling the rte_eth_dev_start API
successfully, the driver is ready to work.
4. The function named hns3_dev_all_rx_queue_intr_enable and
hns3_enable_all_queues are also added in hns3(vf)_start_service(which
called in the RESET_STAGE_DEV_INIT stage of the reset process), so after
start_service, the driver is ready to work.
Note:
1. Because FLR will clear queue's interrupt enable bit hardware
configuration, so we add calling hns3_dev_all_rx_queue_intr_enable
to enable interrupt before enabling queues.
2. After finished the initialization, we can enable queues to work by
calling the internal function named hns3_enable_all_queues.
Fixes: 02a7b55657b2 ("net/hns3: support Rx interrupt")
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Hongbo Zheng <zhenghongbo3@huawei.com>
---
Note:
Because the patch "net/hns3: support Rx interrupt" was merged into
DPDK 20.02, so this patch needn't cc stable@dpdk.org.
---
drivers/net/hns3/hns3_ethdev.c | 82 +++++++++++++++++++++++++------
drivers/net/hns3/hns3_ethdev_vf.c | 82 +++++++++++++++++++++++++------
drivers/net/hns3/hns3_intr.c | 2 +
drivers/net/hns3/hns3_rxtx.c | 27 +++++++++-
drivers/net/hns3/hns3_rxtx.h | 2 +
5 files changed, 162 insertions(+), 33 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 2d0b78d70..b6997aa03 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -4107,6 +4107,19 @@ hns3_init_hardware(struct hns3_adapter *hns)
PMD_INIT_LOG(ERR, "Failed to config gro: %d", ret);
goto err_mac_init;
}
+
+ /*
+ * In the initialization clearing the all hardware mapping relationship
+ * configurations between queues and interrupt vectors is needed, so
+ * some error caused by the residual configurations, such as the
+ * unexpected interrupt, can be avoid.
+ */
+ ret = hns3_init_ring_with_vector(hw);
+ if (ret) {
+ PMD_INIT_LOG(ERR, "Failed to init ring intr vector: %d", ret);
+ goto err_mac_init;
+ }
+
return 0;
err_mac_init:
@@ -4185,16 +4198,6 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
goto err_fdir;
}
- /*
- * In the initialization clearing the all hardware mapping relationship
- * configurations between queues and interrupt vectors is needed, so
- * some error caused by the residual configurations, such as the
- * unexpected interrupt, can be avoid.
- */
- ret = hns3_init_ring_with_vector(hw);
- if (ret)
- goto err_fdir;
-
return 0;
err_fdir:
@@ -4339,6 +4342,31 @@ hns3_map_rx_interrupt(struct rte_eth_dev *dev)
return ret;
}
+static int
+hns3_restore_rx_interrupt(struct hns3_hw *hw)
+{
+ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];
+ struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+ struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+ uint16_t q_id;
+ int ret;
+
+ if (dev->data->dev_conf.intr_conf.rxq == 0)
+ return 0;
+
+ if (rte_intr_dp_is_en(intr_handle)) {
+ for (q_id = 0; q_id < hw->used_rx_queues; q_id++) {
+ ret = hns3_bind_ring_with_vector(hw,
+ intr_handle->intr_vec[q_id], true,
+ HNS3_RING_TYPE_RX, q_id);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
static void
hns3_restore_filter(struct rte_eth_dev *dev)
{
@@ -4365,19 +4393,30 @@ hns3_dev_start(struct rte_eth_dev *dev)
rte_spinlock_unlock(&hw->lock);
return ret;
}
+ ret = hns3_map_rx_interrupt(dev);
+ if (ret) {
+ hw->adapter_state = HNS3_NIC_CONFIGURED;
+ rte_spinlock_unlock(&hw->lock);
+ return ret;
+ }
hw->adapter_state = HNS3_NIC_STARTED;
rte_spinlock_unlock(&hw->lock);
- ret = hns3_map_rx_interrupt(dev);
- if (ret)
- return ret;
hns3_set_rxtx_function(dev);
hns3_mp_req_start_rxtx(dev);
rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, dev);
hns3_restore_filter(dev);
+ /* Enable interrupt of all rx queues before enabling queues */
+ hns3_dev_all_rx_queue_intr_enable(hw, true);
+ /*
+ * When finished the initialization, enable queues to receive/transmit
+ * packets.
+ */
+ hns3_enable_all_queues(hw, true);
+
hns3_info(hw, "hns3 dev start successful!");
return 0;
}
@@ -4458,12 +4497,12 @@ hns3_dev_stop(struct rte_eth_dev *dev)
rte_spinlock_lock(&hw->lock);
if (rte_atomic16_read(&hw->reset.resetting) == 0) {
hns3_do_stop(hns);
+ hns3_unmap_rx_interrupt(dev);
hns3_dev_release_mbufs(hns);
hw->adapter_state = HNS3_NIC_CONFIGURED;
}
rte_eal_alarm_cancel(hns3_service_handler, dev);
rte_spinlock_unlock(&hw->lock);
- hns3_unmap_rx_interrupt(dev);
}
static void
@@ -4977,9 +5016,18 @@ hns3_start_service(struct hns3_adapter *hns)
eth_dev = &rte_eth_devices[hw->data->port_id];
hns3_set_rxtx_function(eth_dev);
hns3_mp_req_start_rxtx(eth_dev);
- if (hw->adapter_state == HNS3_NIC_STARTED)
+ if (hw->adapter_state == HNS3_NIC_STARTED) {
hns3_service_handler(eth_dev);
+ /* Enable interrupt of all rx queues before enabling queues */
+ hns3_dev_all_rx_queue_intr_enable(hw, true);
+ /*
+ * When finished the initialization, enable queues to receive
+ * and transmit packets.
+ */
+ hns3_enable_all_queues(hw, true);
+ }
+
return 0;
}
@@ -5013,6 +5061,10 @@ hns3_restore_conf(struct hns3_adapter *hns)
if (ret)
goto err_promisc;
+ ret = hns3_restore_rx_interrupt(hw);
+ if (ret)
+ goto err_promisc;
+
if (hns->hw.adapter_state == HNS3_NIC_STARTED) {
ret = hns3_do_start(hns, false);
if (ret)
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 48b074bff..144f2c34b 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1504,6 +1504,18 @@ hns3vf_init_hardware(struct hns3_adapter *hns)
goto err_init_hardware;
}
+ /*
+ * In the initialization clearing the all hardware mapping relationship
+ * configurations between queues and interrupt vectors is needed, so
+ * some error caused by the residual configurations, such as the
+ * unexpected interrupt, can be avoid.
+ */
+ ret = hns3vf_init_ring_with_vector(hw);
+ if (ret) {
+ PMD_INIT_LOG(ERR, "Failed to init ring intr vector: %d", ret);
+ goto err_init_hardware;
+ }
+
ret = hns3vf_set_alive(hw, true);
if (ret) {
PMD_INIT_LOG(ERR, "Failed to VF send alive to PF: %d", ret);
@@ -1607,16 +1619,6 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev)
hns3_set_default_rss_args(hw);
- /*
- * In the initialization clearing the all hardware mapping relationship
- * configurations between queues and interrupt vectors is needed, so
- * some error caused by the residual configurations, such as the
- * unexpected interrupt, can be avoid.
- */
- ret = hns3vf_init_ring_with_vector(hw);
- if (ret)
- goto err_get_config;
-
return 0;
err_get_config:
@@ -1725,13 +1727,12 @@ hns3vf_dev_stop(struct rte_eth_dev *dev)
rte_spinlock_lock(&hw->lock);
if (rte_atomic16_read(&hw->reset.resetting) == 0) {
hns3vf_do_stop(hns);
+ hns3vf_unmap_rx_interrupt(dev);
hns3_dev_release_mbufs(hns);
hw->adapter_state = HNS3_NIC_CONFIGURED;
}
rte_eal_alarm_cancel(hns3vf_service_handler, dev);
rte_spinlock_unlock(&hw->lock);
-
- hns3vf_unmap_rx_interrupt(dev);
}
static void
@@ -1881,6 +1882,31 @@ hns3vf_map_rx_interrupt(struct rte_eth_dev *dev)
return ret;
}
+static int
+hns3vf_restore_rx_interrupt(struct hns3_hw *hw)
+{
+ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];
+ struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+ struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+ uint16_t q_id;
+ int ret;
+
+ if (dev->data->dev_conf.intr_conf.rxq == 0)
+ return 0;
+
+ if (rte_intr_dp_is_en(intr_handle)) {
+ for (q_id = 0; q_id < hw->used_rx_queues; q_id++) {
+ ret = hns3vf_bind_ring_with_vector(hw,
+ intr_handle->intr_vec[q_id], true,
+ HNS3_RING_TYPE_RX, q_id);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
static void
hns3vf_restore_filter(struct rte_eth_dev *dev)
{
@@ -1906,18 +1932,29 @@ hns3vf_dev_start(struct rte_eth_dev *dev)
rte_spinlock_unlock(&hw->lock);
return ret;
}
+ ret = hns3vf_map_rx_interrupt(dev);
+ if (ret) {
+ hw->adapter_state = HNS3_NIC_CONFIGURED;
+ rte_spinlock_unlock(&hw->lock);
+ return ret;
+ }
hw->adapter_state = HNS3_NIC_STARTED;
rte_spinlock_unlock(&hw->lock);
- ret = hns3vf_map_rx_interrupt(dev);
- if (ret)
- return ret;
hns3_set_rxtx_function(dev);
hns3_mp_req_start_rxtx(dev);
rte_eal_alarm_set(HNS3VF_SERVICE_INTERVAL, hns3vf_service_handler, dev);
hns3vf_restore_filter(dev);
+ /* Enable interrupt of all rx queues before enabling queues */
+ hns3_dev_all_rx_queue_intr_enable(hw, true);
+ /*
+ * When finished the initialization, enable queues to receive/transmit
+ * packets.
+ */
+ hns3_enable_all_queues(hw, true);
+
return ret;
}
@@ -2069,9 +2106,18 @@ hns3vf_start_service(struct hns3_adapter *hns)
eth_dev = &rte_eth_devices[hw->data->port_id];
hns3_set_rxtx_function(eth_dev);
hns3_mp_req_start_rxtx(eth_dev);
- if (hw->adapter_state == HNS3_NIC_STARTED)
+ if (hw->adapter_state == HNS3_NIC_STARTED) {
hns3vf_service_handler(eth_dev);
+ /* Enable interrupt of all rx queues before enabling queues */
+ hns3_dev_all_rx_queue_intr_enable(hw, true);
+ /*
+ * When finished the initialization, enable queues to receive
+ * and transmit packets.
+ */
+ hns3_enable_all_queues(hw, true);
+ }
+
return 0;
}
@@ -2142,6 +2188,10 @@ hns3vf_restore_conf(struct hns3_adapter *hns)
if (ret)
goto err_vlan_table;
+ ret = hns3vf_restore_rx_interrupt(hw);
+ if (ret)
+ goto err_vlan_table;
+
if (hw->adapter_state == HNS3_NIC_STARTED) {
ret = hns3vf_do_start(hns, false);
if (ret)
diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c
index 6c3ebd3ee..9953a1d98 100644
--- a/drivers/net/hns3/hns3_intr.c
+++ b/drivers/net/hns3/hns3_intr.c
@@ -1001,7 +1001,9 @@ hns3_reset_post(struct hns3_adapter *hns)
hw->reset.attempts = 0;
hw->reset.stats.success_cnt++;
hw->reset.stage = RESET_STAGE_NONE;
+ rte_spinlock_lock(&hw->lock);
hw->reset.ops->start_service(hns);
+ rte_spinlock_unlock(&hw->lock);
gettimeofday(&tv, NULL);
timersub(&tv, &hw->reset.start_time, &tv_delta);
hns3_warn(hw, "%s reset done fail_cnt:%" PRIx64
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 0c965b1b8..0728cb182 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -315,7 +315,7 @@ hns3_init_tx_queue_hw(struct hns3_tx_queue *txq)
HNS3_CFG_DESC_NUM(txq->nb_tx_desc));
}
-static void
+void
hns3_enable_all_queues(struct hns3_hw *hw, bool en)
{
uint16_t nb_rx_q = hw->data->nb_rx_queues;
@@ -543,6 +543,26 @@ hns3_queue_intr_enable(struct hns3_hw *hw, uint16_t queue_id, bool en)
hns3_write_dev(hw, addr, value);
}
+/*
+ * Enable all rx queue interrupt when in interrupt rx mode.
+ * This api was called before enable queue rx&tx (in normal start or reset
+ * recover scenes), used to fix hardware rx queue interrupt enable was clear
+ * when FLR.
+ */
+void
+hns3_dev_all_rx_queue_intr_enable(struct hns3_hw *hw, bool en)
+{
+ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];
+ uint16_t nb_rx_q = hw->data->nb_rx_queues;
+ int i;
+
+ if (dev->data->dev_conf.intr_conf.rxq == 0)
+ return;
+
+ for (i = 0; i < nb_rx_q; i++)
+ hns3_queue_intr_enable(hw, i, en);
+}
+
int
hns3_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
{
@@ -742,6 +762,10 @@ hns3_start_tx_queues(struct hns3_adapter *hns)
hns3_init_tx_ring_tc(hns);
}
+/*
+ * Start all queues.
+ * Note: just init and setup queues, and don't enable queue rx&tx.
+ */
int
hns3_start_queues(struct hns3_adapter *hns, bool reset_queue)
{
@@ -763,7 +787,6 @@ hns3_start_queues(struct hns3_adapter *hns, bool reset_queue)
}
hns3_start_tx_queues(hns);
- hns3_enable_all_queues(hw, true);
return 0;
}
diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h
index 5ba6ee915..771f3c9be 100644
--- a/drivers/net/hns3/hns3_rxtx.h
+++ b/drivers/net/hns3/hns3_rxtx.h
@@ -302,8 +302,10 @@ void hns3_dev_rx_queue_release(void *queue);
void hns3_dev_tx_queue_release(void *queue);
void hns3_free_all_queues(struct rte_eth_dev *dev);
int hns3_reset_all_queues(struct hns3_adapter *hns);
+void hns3_dev_all_rx_queue_intr_enable(struct hns3_hw *hw, bool en);
int hns3_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id);
int hns3_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id);
+void hns3_enable_all_queues(struct hns3_hw *hw, bool en);
int hns3_start_queues(struct hns3_adapter *hns, bool reset_queue);
int hns3_stop_queues(struct hns3_adapter *hns, bool reset_queue);
void hns3_dev_release_mbufs(struct hns3_adapter *hns);
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH 5/9] net/hns3: fix residual flow directory rules when app restart
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
` (3 preceding siblings ...)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 4/9] net/hns3: fix Rx interrupt after reset Wei Hu (Xavier)
@ 2020-04-10 11:09 ` Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 6/9] net/hns3: fix missing RSS in Rx offload capability Wei Hu (Xavier)
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Wei Hu (Xavier) @ 2020-04-10 11:09 UTC (permalink / raw)
To: dev
From: Chengwen Feng <fengchengwen@huawei.com>
This patch fixes that the flow directory rules are not cleared during
initialization, which lead to remaining flow directory rules after upper
application(such as testpmd) restarted.
Fixes: fcba820d9b9e ("net/hns3: support flow director")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
drivers/net/hns3/hns3_fdir.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index ca3c78e1c..53c6448cd 100644
--- a/drivers/net/hns3/hns3_fdir.c
+++ b/drivers/net/hns3/hns3_fdir.c
@@ -772,6 +772,20 @@ static int hns3_config_action(struct hns3_hw *hw, struct hns3_fdir_rule *rule)
return hns3_fd_ad_config(hw, ad_data.ad_id, &ad_data);
}
+static int hns3_fd_clear_all_rules(struct hns3_hw *hw, uint32_t rule_num)
+{
+ uint32_t i;
+ int ret;
+
+ for (i = 0; i < rule_num; i++) {
+ ret = hns3_fd_tcam_config(hw, true, i, NULL, false);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
int hns3_fdir_filter_init(struct hns3_adapter *hns)
{
struct hns3_pf *pf = &hns->pf;
@@ -785,6 +799,13 @@ int hns3_fdir_filter_init(struct hns3_adapter *hns)
.hash_func = rte_hash_crc,
.hash_func_init_val = 0,
};
+ int ret;
+
+ ret = hns3_fd_clear_all_rules(&hns->hw, rule_num);
+ if (ret) {
+ PMD_INIT_LOG(ERR, "Clear all fd rules fail! ret = %d", ret);
+ return ret;
+ }
fdir_hash_params.socket_id = rte_socket_id();
TAILQ_INIT(&fdir_info->fdir_list);
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH 6/9] net/hns3: fix missing RSS in Rx offload capability
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
` (4 preceding siblings ...)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 5/9] net/hns3: fix residual flow directory rules when app restart Wei Hu (Xavier)
@ 2020-04-10 11:09 ` Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 7/9] net/hns3: fix missing length of hash key when getting RSS Wei Hu (Xavier)
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Wei Hu (Xavier) @ 2020-04-10 11:09 UTC (permalink / raw)
To: dev
From: Lijun Ou <oulijun@huawei.com>
Currently, when upper application calls rte_eth_dev_info_get API function
to query the Rx offload capability based on hns3 network engine, RSS hash
offload capacity is missing.
This patch fixes it by adding the related capacity in the '.dev_infos_get'
ops implementation function named hns3_dev_infos_get and
hns3vf_dev_infos_get for hns3 PF/VF PMD driver.
Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 3 ++-
drivers/net/hns3/hns3_ethdev_vf.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index b6997aa03..63401bdda 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2407,7 +2407,8 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
DEV_RX_OFFLOAD_QINQ_STRIP |
DEV_RX_OFFLOAD_VLAN_FILTER |
DEV_RX_OFFLOAD_VLAN_EXTEND |
- DEV_RX_OFFLOAD_JUMBO_FRAME);
+ DEV_RX_OFFLOAD_JUMBO_FRAME |
+ DEV_RX_OFFLOAD_RSS_HASH);
info->tx_queue_offload_capa = DEV_TX_OFFLOAD_MBUF_FAST_FREE;
info->tx_offload_capa = (DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
DEV_TX_OFFLOAD_IPV4_CKSUM |
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 144f2c34b..057e0b2b5 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -908,7 +908,8 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
DEV_RX_OFFLOAD_VLAN_STRIP |
DEV_RX_OFFLOAD_QINQ_STRIP |
DEV_RX_OFFLOAD_VLAN_FILTER |
- DEV_RX_OFFLOAD_JUMBO_FRAME);
+ DEV_RX_OFFLOAD_JUMBO_FRAME |
+ DEV_RX_OFFLOAD_RSS_HASH);
info->tx_queue_offload_capa = DEV_TX_OFFLOAD_MBUF_FAST_FREE;
info->tx_offload_capa = (DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
DEV_TX_OFFLOAD_IPV4_CKSUM |
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH 7/9] net/hns3: fix missing length of hash key when getting RSS
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
` (5 preceding siblings ...)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 6/9] net/hns3: fix missing RSS in Rx offload capability Wei Hu (Xavier)
@ 2020-04-10 11:09 ` Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 8/9] net/hns3: fix default VLAN filter configuration for PF Wei Hu (Xavier)
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Wei Hu (Xavier) @ 2020-04-10 11:09 UTC (permalink / raw)
To: dev
From: Lijun Ou <oulijun@huawei.com>
When upper application calls the rte_eth_dev_rss_hash_conf_get API
function to get the RSS key parameters, the function should return the
RSS key length supported by the device. Otherwise, an error will occur
when the upper application needs to use the RSS key length supported
by this specified hardware for judgment and configure the specified
key into hardware.
For example, in the following scenario:
When users want to use their own RSS key, but the length of the key is
bigger than the one of the supported by hardware.
As a result, users need to get the RSS key length supported by hardware
according to the above API firstly, and then compare the actual obtained
RSS key length with the length of their own RSS key.
If the drvier does not return the actual value, error may coccur when user
calls the rte_eth_dev_rss_hash_update API function to configure their own
kye into hardware.
Besides, this patch fixes the problem of stepping on memory when the RSS
key array configured by users are less than the RSS key length supported
by the driver at the same time.
Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
---
| 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 95a637ddc..a6cab29c9 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -328,8 +328,10 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
rss_conf->rss_hf = rss_cfg->conf.types;
/* Get the RSS Key required by the user */
- if (rss_conf->rss_key)
+ if (rss_conf->rss_key && rss_conf->rss_key_len >= HNS3_RSS_KEY_SIZE) {
memcpy(rss_conf->rss_key, rss_cfg->key, HNS3_RSS_KEY_SIZE);
+ rss_conf->rss_key_len = HNS3_RSS_KEY_SIZE;
+ }
rte_spinlock_unlock(&hw->lock);
return 0;
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH 8/9] net/hns3: fix default VLAN filter configuration for PF
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
` (6 preceding siblings ...)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 7/9] net/hns3: fix missing length of hash key when getting RSS Wei Hu (Xavier)
@ 2020-04-10 11:09 ` Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 9/9] net/hns3: fix VLAN filter when setting promisucous mode Wei Hu (Xavier)
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Wei Hu (Xavier) @ 2020-04-10 11:09 UTC (permalink / raw)
To: dev
From: Chengchang Tang <tangchengchang@huawei.com>
Currently, By default VLAN filter is enabled during initialization and
couldn't be turned off based on hns3 PF device. If upper applications
don't call rte_eth_dev_vlan_filter API function to set vlan based on hns3
PF device, hns3 PF PMD driver will can't receive the packets with vlan tag.
It will leads to some compatibility issues, the behaviors of using hns3
network engine and other NICs are different.
This patch disables the VLAN filter during initialization and allows the
upper level applications to enable or disable the VLAN filter.
Fixes: 411d23b9eafb ("net/hns3: support VLAN")
Cc: stable@dpdk.org
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 65 ++++++++++++++++++++++++++++------
1 file changed, 55 insertions(+), 10 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 63401bdda..b7601455c 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -558,7 +558,7 @@ hns3_set_vlan_filter_ctrl(struct hns3_hw *hw, uint8_t vlan_type,
}
static int
-hns3_enable_vlan_filter(struct hns3_adapter *hns, bool enable)
+hns3_vlan_filter_init(struct hns3_adapter *hns)
{
struct hns3_hw *hw = &hns->hw;
int ret;
@@ -566,14 +566,29 @@ hns3_enable_vlan_filter(struct hns3_adapter *hns, bool enable)
ret = hns3_set_vlan_filter_ctrl(hw, HNS3_FILTER_TYPE_VF,
HNS3_FILTER_FE_EGRESS, false, 0);
if (ret) {
- hns3_err(hw, "hns3 enable filter fail, ret =%d", ret);
+ hns3_err(hw, "failed to init vf vlan filter, ret = %d", ret);
return ret;
}
+ ret = hns3_set_vlan_filter_ctrl(hw, HNS3_FILTER_TYPE_PORT,
+ HNS3_FILTER_FE_INGRESS, false, 0);
+ if (ret)
+ hns3_err(hw, "failed to init port vlan filter, ret = %d", ret);
+
+ return ret;
+}
+
+static int
+hns3_enable_vlan_filter(struct hns3_adapter *hns, bool enable)
+{
+ struct hns3_hw *hw = &hns->hw;
+ int ret;
+
ret = hns3_set_vlan_filter_ctrl(hw, HNS3_FILTER_TYPE_PORT,
HNS3_FILTER_FE_INGRESS, enable, 0);
if (ret)
- hns3_err(hw, "hns3 enable filter fail, ret =%d", ret);
+ hns3_err(hw, "failed to %s port vlan filter, ret = %d",
+ enable ? "enable" : "disable", ret);
return ret;
}
@@ -591,6 +606,20 @@ hns3_vlan_offload_set(struct rte_eth_dev *dev, int mask)
rte_spinlock_lock(&hw->lock);
rxmode = &dev->data->dev_conf.rxmode;
tmp_mask = (unsigned int)mask;
+ if (tmp_mask & ETH_VLAN_FILTER_MASK) {
+ /* Enable or disable VLAN filter */
+ enable = rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER ?
+ true : false;
+
+ ret = hns3_enable_vlan_filter(hns, enable);
+ if (ret) {
+ rte_spinlock_unlock(&hw->lock);
+ hns3_err(hw, "failed to %s rx filter, ret = %d",
+ enable ? "enable" : "disable", ret);
+ return ret;
+ }
+ }
+
if (tmp_mask & ETH_VLAN_STRIP_MASK) {
/* Enable or disable VLAN stripping */
enable = rxmode->offloads & DEV_RX_OFFLOAD_VLAN_STRIP ?
@@ -599,7 +628,8 @@ hns3_vlan_offload_set(struct rte_eth_dev *dev, int mask)
ret = hns3_en_hw_strip_rxvtag(hns, enable);
if (ret) {
rte_spinlock_unlock(&hw->lock);
- hns3_err(hw, "failed to enable rx strip, ret =%d", ret);
+ hns3_err(hw, "failed to %s rx strip, ret = %d",
+ enable ? "enable" : "disable", ret);
return ret;
}
}
@@ -926,7 +956,7 @@ hns3_init_vlan_config(struct hns3_adapter *hns)
if (rte_atomic16_read(&hw->reset.resetting) == 0)
init_port_base_vlan_info(hw);
- ret = hns3_enable_vlan_filter(hns, true);
+ ret = hns3_vlan_filter_init(hns);
if (ret) {
hns3_err(hw, "vlan init fail in pf, ret =%d", ret);
return ret;
@@ -968,17 +998,29 @@ hns3_restore_vlan_conf(struct hns3_adapter *hns)
{
struct hns3_pf *pf = &hns->pf;
struct hns3_hw *hw = &hns->hw;
+ uint64_t offloads;
+ bool enable;
int ret;
+ /* restore vlan filter states */
+ offloads = hw->data->dev_conf.rxmode.offloads;
+ enable = offloads & DEV_RX_OFFLOAD_VLAN_FILTER ? true : false;
+ ret = hns3_enable_vlan_filter(hns, enable);
+ if (ret) {
+ hns3_err(hw, "failed to restore vlan rx filter conf, ret = %d",
+ ret);
+ return ret;
+ }
+
ret = hns3_set_vlan_rx_offload_cfg(hns, &pf->vtag_config.rx_vcfg);
if (ret) {
- hns3_err(hw, "hns3 restore vlan rx conf fail, ret =%d", ret);
+ hns3_err(hw, "failed to restore vlan rx conf, ret = %d", ret);
return ret;
}
ret = hns3_set_vlan_tx_offload_cfg(hns, &pf->vtag_config.tx_vcfg);
if (ret)
- hns3_err(hw, "hns3 restore vlan tx conf fail, ret =%d", ret);
+ hns3_err(hw, "failed to restore vlan tx conf, ret = %d", ret);
return ret;
}
@@ -990,6 +1032,7 @@ hns3_dev_configure_vlan(struct rte_eth_dev *dev)
struct rte_eth_dev_data *data = dev->data;
struct rte_eth_txmode *txmode;
struct hns3_hw *hw = &hns->hw;
+ int mask;
int ret;
txmode = &data->dev_conf.txmode;
@@ -1003,9 +1046,11 @@ hns3_dev_configure_vlan(struct rte_eth_dev *dev)
txmode->hw_vlan_reject_untagged);
/* Apply vlan offload setting */
- ret = hns3_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK);
+ mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK;
+ ret = hns3_vlan_offload_set(dev, mask);
if (ret) {
- hns3_err(hw, "dev config vlan Strip failed, ret =%d", ret);
+ hns3_err(hw, "dev config rx vlan offload failed, ret = %d",
+ ret);
return ret;
}
@@ -1013,7 +1058,7 @@ hns3_dev_configure_vlan(struct rte_eth_dev *dev)
ret = hns3_vlan_pvid_set(dev, txmode->pvid,
txmode->hw_vlan_insert_pvid);
if (ret)
- hns3_err(hw, "dev config vlan pvid(%d) failed, ret =%d",
+ hns3_err(hw, "dev config vlan pvid(%d) failed, ret = %d",
txmode->pvid, ret);
return ret;
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [dpdk-dev] [PATCH 9/9] net/hns3: fix VLAN filter when setting promisucous mode
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
` (7 preceding siblings ...)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 8/9] net/hns3: fix default VLAN filter configuration for PF Wei Hu (Xavier)
@ 2020-04-10 11:09 ` Wei Hu (Xavier)
2020-04-14 8:31 ` [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Ferruh Yigit
2020-04-17 11:09 ` oulijun
10 siblings, 0 replies; 12+ messages in thread
From: Wei Hu (Xavier) @ 2020-04-10 11:09 UTC (permalink / raw)
To: dev
From: Chengchang Tang <tangchengchang@huawei.com>
Currently, when upper level application call the API function named
rte_eth_dev_set_vlan_offload to configure the hardware vlan filter offload
and call the rte_eth_promiscuous_enable API to enable promiscuous mode
based on hns3 PF device, driver can't receive the packets with a vlan tag
which has not been added by calling the API function named
rte_eth_dev_vlan_filter.
This patch fixes it by disabling the vlan filter when setting the
promiscuous mode and enabling the vlan filter again after the promiscuous
mode are disabled.
Fixes: 19a3ca4c99cf ("net/hns3: add start/stop and configure operations")
Cc: stable@dpdk.org
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 119 +++++++++++++++++++++++++--------
1 file changed, 91 insertions(+), 28 deletions(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index b7601455c..037ca4604 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -607,16 +607,19 @@ hns3_vlan_offload_set(struct rte_eth_dev *dev, int mask)
rxmode = &dev->data->dev_conf.rxmode;
tmp_mask = (unsigned int)mask;
if (tmp_mask & ETH_VLAN_FILTER_MASK) {
- /* Enable or disable VLAN filter */
- enable = rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER ?
- true : false;
+ /* ignore vlan filter configuration during promiscuous mode */
+ if (!dev->data->promiscuous) {
+ /* Enable or disable VLAN filter */
+ enable = rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER ?
+ true : false;
- ret = hns3_enable_vlan_filter(hns, enable);
- if (ret) {
- rte_spinlock_unlock(&hw->lock);
- hns3_err(hw, "failed to %s rx filter, ret = %d",
- enable ? "enable" : "disable", ret);
- return ret;
+ ret = hns3_enable_vlan_filter(hns, enable);
+ if (ret) {
+ rte_spinlock_unlock(&hw->lock);
+ hns3_err(hw, "failed to %s rx filter, ret = %d",
+ enable ? "enable" : "disable", ret);
+ return ret;
+ }
}
}
@@ -1002,14 +1005,16 @@ hns3_restore_vlan_conf(struct hns3_adapter *hns)
bool enable;
int ret;
- /* restore vlan filter states */
- offloads = hw->data->dev_conf.rxmode.offloads;
- enable = offloads & DEV_RX_OFFLOAD_VLAN_FILTER ? true : false;
- ret = hns3_enable_vlan_filter(hns, enable);
- if (ret) {
- hns3_err(hw, "failed to restore vlan rx filter conf, ret = %d",
- ret);
- return ret;
+ if (!hw->data->promiscuous) {
+ /* restore vlan filter states */
+ offloads = hw->data->dev_conf.rxmode.offloads;
+ enable = offloads & DEV_RX_OFFLOAD_VLAN_FILTER ? true : false;
+ ret = hns3_enable_vlan_filter(hns, enable);
+ if (ret) {
+ hns3_err(hw, "failed to restore vlan rx filter conf, "
+ "ret = %d", ret);
+ return ret;
+ }
}
ret = hns3_set_vlan_rx_offload_cfg(hns, &pf->vtag_config.rx_vcfg);
@@ -3830,16 +3835,43 @@ hns3_clear_all_vfs_promisc_mode(struct hns3_hw *hw)
static int
hns3_dev_promiscuous_enable(struct rte_eth_dev *dev)
{
+ bool allmulti = dev->data->all_multicast ? true : false;
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
+ uint64_t offloads;
+ int err;
int ret;
rte_spinlock_lock(&hw->lock);
ret = hns3_set_promisc_mode(hw, true, true);
- rte_spinlock_unlock(&hw->lock);
- if (ret)
- hns3_err(hw, "Failed to enable promiscuous mode, ret = %d",
+ if (ret) {
+ rte_spinlock_unlock(&hw->lock);
+ hns3_err(hw, "failed to enable promiscuous mode, ret = %d",
ret);
+ return ret;
+ }
+
+ /*
+ * When promiscuous mode was enabled, disable the vlan filter to let
+ * all packets coming in in the receiving direction.
+ */
+ offloads = dev->data->dev_conf.rxmode.offloads;
+ if (offloads & DEV_RX_OFFLOAD_VLAN_FILTER) {
+ ret = hns3_enable_vlan_filter(hns, false);
+ if (ret) {
+ hns3_err(hw, "failed to enable promiscuous mode due to "
+ "failure to disable vlan filter, ret = %d",
+ ret);
+ err = hns3_set_promisc_mode(hw, false, allmulti);
+ if (err)
+ hns3_err(hw, "failed to restore promiscuous "
+ "status after disable vlan filter "
+ "failed during enabling promiscuous "
+ "mode, ret = %d", ret);
+ }
+ }
+
+ rte_spinlock_unlock(&hw->lock);
return ret;
}
@@ -3850,15 +3882,36 @@ hns3_dev_promiscuous_disable(struct rte_eth_dev *dev)
bool allmulti = dev->data->all_multicast ? true : false;
struct hns3_adapter *hns = dev->data->dev_private;
struct hns3_hw *hw = &hns->hw;
+ uint64_t offloads;
+ int err;
int ret;
/* If now in all_multicast mode, must remain in all_multicast mode. */
rte_spinlock_lock(&hw->lock);
ret = hns3_set_promisc_mode(hw, false, allmulti);
- rte_spinlock_unlock(&hw->lock);
- if (ret)
- hns3_err(hw, "Failed to disable promiscuous mode, ret = %d",
+ if (ret) {
+ rte_spinlock_unlock(&hw->lock);
+ hns3_err(hw, "failed to disable promiscuous mode, ret = %d",
ret);
+ return ret;
+ }
+ /* when promiscuous mode was disabled, restore the vlan filter status */
+ offloads = dev->data->dev_conf.rxmode.offloads;
+ if (offloads & DEV_RX_OFFLOAD_VLAN_FILTER) {
+ ret = hns3_enable_vlan_filter(hns, true);
+ if (ret) {
+ hns3_err(hw, "failed to disable promiscuous mode due to"
+ " failure to restore vlan filter, ret = %d",
+ ret);
+ err = hns3_set_promisc_mode(hw, true, true);
+ if (err)
+ hns3_err(hw, "failed to restore promiscuous "
+ "status after enabling vlan filter "
+ "failed during disabling promiscuous "
+ "mode, ret = %d", ret);
+ }
+ }
+ rte_spinlock_unlock(&hw->lock);
return ret;
}
@@ -3877,7 +3930,7 @@ hns3_dev_allmulticast_enable(struct rte_eth_dev *dev)
ret = hns3_set_promisc_mode(hw, false, true);
rte_spinlock_unlock(&hw->lock);
if (ret)
- hns3_err(hw, "Failed to enable allmulticast mode, ret = %d",
+ hns3_err(hw, "failed to enable allmulticast mode, ret = %d",
ret);
return ret;
@@ -3898,7 +3951,7 @@ hns3_dev_allmulticast_disable(struct rte_eth_dev *dev)
ret = hns3_set_promisc_mode(hw, false, false);
rte_spinlock_unlock(&hw->lock);
if (ret)
- hns3_err(hw, "Failed to disable allmulticast mode, ret = %d",
+ hns3_err(hw, "failed to disable allmulticast mode, ret = %d",
ret);
return ret;
@@ -3909,11 +3962,21 @@ hns3_dev_promisc_restore(struct hns3_adapter *hns)
{
struct hns3_hw *hw = &hns->hw;
bool allmulti = hw->data->all_multicast ? true : false;
+ int ret;
- if (hw->data->promiscuous)
- return hns3_set_promisc_mode(hw, true, true);
+ if (hw->data->promiscuous) {
+ ret = hns3_set_promisc_mode(hw, true, true);
+ if (ret)
+ hns3_err(hw, "failed to restore promiscuous mode, "
+ "ret = %d", ret);
+ return ret;
+ }
- return hns3_set_promisc_mode(hw, false, allmulti);
+ ret = hns3_set_promisc_mode(hw, false, allmulti);
+ if (ret)
+ hns3_err(hw, "failed to restore allmulticast mode, ret = %d",
+ ret);
+ return ret;
}
static int
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
` (8 preceding siblings ...)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 9/9] net/hns3: fix VLAN filter when setting promisucous mode Wei Hu (Xavier)
@ 2020-04-14 8:31 ` Ferruh Yigit
2020-04-17 11:09 ` oulijun
10 siblings, 0 replies; 12+ messages in thread
From: Ferruh Yigit @ 2020-04-14 8:31 UTC (permalink / raw)
To: Wei Hu (Xavier), dev
On 4/10/2020 12:09 PM, Wei Hu (Xavier) wrote:
> This series are cleanup and bugfix for hns3 PMD driver.
>
> Chengchang Tang (3):
> net/hns3: fix failure when adding a MC MAC address
> net/hns3: fix default VLAN filter configuration for PF
> net/hns3: fix VLAN filter when setting promisucous mode
>
> Chengwen Feng (2):
> net/hns3: fix Rx interrupt after reset
> net/hns3: fix residual flow directory rules when app restart
>
> Lijun Ou (3):
> net/hns3: simplify process of some return values
> net/hns3: fix missing RSS in Rx offload capability
> net/hns3: fix missing length of hash key when getting RSS
>
> Wei Hu (Xavier) (1):
> net/hns3: replace zero with macro defined in DPDK framework
>
Series applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
` (9 preceding siblings ...)
2020-04-14 8:31 ` [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Ferruh Yigit
@ 2020-04-17 11:09 ` oulijun
10 siblings, 0 replies; 12+ messages in thread
From: oulijun @ 2020-04-17 11:09 UTC (permalink / raw)
To: dev
test
在 2020/4/10 19:09, Wei Hu (Xavier) 写道:
> This series are cleanup and bugfix for hns3 PMD driver.
>
> Chengchang Tang (3):
> net/hns3: fix failure when adding a MC MAC address
> net/hns3: fix default VLAN filter configuration for PF
> net/hns3: fix VLAN filter when setting promisucous mode
>
> Chengwen Feng (2):
> net/hns3: fix Rx interrupt after reset
> net/hns3: fix residual flow directory rules when app restart
>
> Lijun Ou (3):
> net/hns3: simplify process of some return values
> net/hns3: fix missing RSS in Rx offload capability
> net/hns3: fix missing length of hash key when getting RSS
>
> Wei Hu (Xavier) (1):
> net/hns3: replace zero with macro defined in DPDK framework
>
> drivers/net/hns3/hns3_dcb.c | 28 +--
> drivers/net/hns3/hns3_ethdev.c | 403 ++++++++++++++++++++++++------
> drivers/net/hns3/hns3_ethdev_vf.c | 342 +++++++++++++++++++------
> drivers/net/hns3/hns3_fdir.c | 21 ++
> drivers/net/hns3/hns3_intr.c | 2 +
> drivers/net/hns3/hns3_rss.c | 4 +-
> drivers/net/hns3/hns3_rxtx.c | 27 +-
> drivers/net/hns3/hns3_rxtx.h | 2 +
> 8 files changed, 645 insertions(+), 184 deletions(-)
>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-04-17 11:10 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 1/9] net/hns3: simplify process of some return values Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 2/9] net/hns3: replace zero with macro defined in DPDK framework Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 3/9] net/hns3: fix failure when adding a MC MAC address Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 4/9] net/hns3: fix Rx interrupt after reset Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 5/9] net/hns3: fix residual flow directory rules when app restart Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 6/9] net/hns3: fix missing RSS in Rx offload capability Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 7/9] net/hns3: fix missing length of hash key when getting RSS Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 8/9] net/hns3: fix default VLAN filter configuration for PF Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 9/9] net/hns3: fix VLAN filter when setting promisucous mode Wei Hu (Xavier)
2020-04-14 8:31 ` [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Ferruh Yigit
2020-04-17 11:09 ` oulijun
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).