From: "Wei Hu (Xavier)" <huwei013@chinasoftinc.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 4/9] net/hns3: fix Rx interrupt after reset
Date: Fri, 10 Apr 2020 19:09:25 +0800 [thread overview]
Message-ID: <20200410110930.15717-5-huwei013@chinasoftinc.com> (raw)
In-Reply-To: <20200410110930.15717-1-huwei013@chinasoftinc.com>
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
next prev parent reply other threads:[~2020-04-10 11:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Wei Hu (Xavier) [this message]
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
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=20200410110930.15717-5-huwei013@chinasoftinc.com \
--to=huwei013@chinasoftinc.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).