From: luca.boccassi@gmail.com
To: dev@dpdk.org
Cc: wenzhuo.lu@intel.com, wei.dai@intel.com, remy.horton@intel.com,
Luca Boccassi <bluca@debian.org>
Subject: [dpdk-dev] [PATCH 3/3] net/ixgbe: implement VF reset
Date: Tue, 24 Oct 2017 14:16:30 +0100 [thread overview]
Message-ID: <20171024131630.16595-4-luca.boccassi@gmail.com> (raw)
In-Reply-To: <20171024131630.16595-1-luca.boccassi@gmail.com>
From: Luca Boccassi <bluca@debian.org>
This reset function will stop and restart the device, and then reset
the stats and check that the registers have been updated.
Signed-off-by: Luca Boccassi <bluca@debian.org>
---
drivers/net/ixgbe/ixgbe_ethdev.c | 60 +++++++++++++++++++++++++++++++++++-----
drivers/net/ixgbe/ixgbe_ethdev.h | 2 +-
drivers/net/ixgbe/ixgbe_rxtx.c | 12 ++++++--
3 files changed, 63 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 14b9c5303..13307466b 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -5026,7 +5026,9 @@ ixgbevf_dev_start(struct rte_eth_dev *dev)
ETH_VLAN_EXTEND_MASK;
ixgbevf_vlan_offload_set(dev, mask);
- ixgbevf_dev_rxtx_start(dev);
+ err = ixgbevf_dev_rxtx_start(dev);
+ if (err)
+ return err;
/* check and configure queue intr-vector mapping */
if (dev->data->dev_conf.intr_conf.rxq != 0) {
@@ -5127,15 +5129,59 @@ ixgbevf_dev_close(struct rte_eth_dev *dev)
static int
ixgbevf_dev_reset(struct rte_eth_dev *dev)
{
- int ret;
+ struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ int diag = 0;
+ uint32_t vteiam;
- ret = eth_ixgbevf_dev_uninit(dev);
- if (ret)
- return ret;
+ /* Nothing needs to be done if the device is not started. */
+ if (!dev->data->dev_started)
+ return -EAGAIN;
- ret = eth_ixgbevf_dev_init(dev);
+ PMD_DRV_LOG(DEBUG, "Link up/down event detected.");
- return ret;
+ /* Performance VF reset. */
+ do {
+ dev->data->dev_started = 0;
+ ixgbevf_dev_stop(dev);
+ if (dev->data->dev_conf.intr_conf.lsc == 0)
+ diag = ixgbe_dev_link_update(dev, 0);
+ if (diag) {
+ PMD_INIT_LOG(INFO, "Ixgbe VF reset: "
+ "Failed to update link.");
+ }
+ rte_delay_ms(1000);
+
+ diag = ixgbevf_dev_start(dev);
+ /* If fail to start the device, need to stop/start it again. */
+ if (diag) {
+ PMD_INIT_LOG(ERR, "Ixgbe VF reset: "
+ "Failed to start device.");
+ dev->data->dev_started = 1;
+ return -EAGAIN;
+ }
+ dev->data->dev_started = 1;
+ ixgbevf_dev_stats_reset(dev);
+ if (dev->data->dev_conf.intr_conf.lsc == 0)
+ diag = ixgbe_dev_link_update(dev, 0);
+ if (diag) {
+ PMD_INIT_LOG(INFO, "Ixgbe VF reset: "
+ "Failed to update link.");
+ diag = 0;
+ }
+
+ /**
+ * When the PF link is down, there is a chance
+ * that the VF cannot operate its registers.
+ * Check if the registers are written
+ * successfully. If not, repeat stop/start until
+ * the PF link is up, or in other words, until the
+ * registers can be written.
+ */
+ vteiam = IXGBE_READ_REG(hw, IXGBE_VTEIAM);
+ /* Reference ixgbevf_intr_enable when checking */
+ } while (diag || vteiam != IXGBE_VF_IRQ_ENABLE_MASK);
+
+ return 0;
}
static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index e28c8567e..87b929518 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -595,7 +595,7 @@ int ixgbevf_dev_rx_init(struct rte_eth_dev *dev);
void ixgbevf_dev_tx_init(struct rte_eth_dev *dev);
-void ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev);
+int ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev);
uint16_t ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 0038dfbb4..5a0be2cfe 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -5419,7 +5419,7 @@ ixgbevf_dev_tx_init(struct rte_eth_dev *dev)
/*
* [VF] Start Transmit and Receive Units.
*/
-void __attribute__((cold))
+int __attribute__((cold))
ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev)
{
struct ixgbe_hw *hw;
@@ -5455,8 +5455,10 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev)
rte_delay_ms(1);
txdctl = IXGBE_READ_REG(hw, IXGBE_VFTXDCTL(i));
} while (--poll_ms && !(txdctl & IXGBE_TXDCTL_ENABLE));
- if (!poll_ms)
+ if (!poll_ms) {
PMD_INIT_LOG(ERR, "Could not enable Tx Queue %d", i);
+ return -1;
+ }
}
for (i = 0; i < dev->data->nb_rx_queues; i++) {
@@ -5472,12 +5474,16 @@ ixgbevf_dev_rxtx_start(struct rte_eth_dev *dev)
rte_delay_ms(1);
rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i));
} while (--poll_ms && !(rxdctl & IXGBE_RXDCTL_ENABLE));
- if (!poll_ms)
+ if (!poll_ms) {
PMD_INIT_LOG(ERR, "Could not enable Rx Queue %d", i);
+ return -1;
+ }
rte_wmb();
IXGBE_WRITE_REG(hw, IXGBE_VFRDT(i), rxq->nb_rx_desc - 1);
}
+
+ return 0;
}
/* Stubs needed for linkage when CONFIG_RTE_IXGBE_INC_VECTOR is set to 'n' */
--
2.11.0
next prev parent reply other threads:[~2017-10-24 13:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-24 13:16 [dpdk-dev] [PATCH 0/3] RFC: implement VF reset for i40e, e1000 and ixgbe luca.boccassi
2017-10-24 13:16 ` [dpdk-dev] [PATCH 1/3] net/i40e: implement VF reset luca.boccassi
2017-10-24 13:16 ` [dpdk-dev] [PATCH 2/3] net/e1000: " luca.boccassi
2017-10-24 13:16 ` luca.boccassi [this message]
2017-10-25 1:17 ` [dpdk-dev] [PATCH 0/3] RFC: implement VF reset for i40e, e1000 and ixgbe Ferruh Yigit
2017-10-25 10:04 ` Luca Boccassi
2017-10-26 8:08 ` Dai, Wei
2017-10-26 10:43 ` Luca Boccassi
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=20171024131630.16595-4-luca.boccassi@gmail.com \
--to=luca.boccassi@gmail.com \
--cc=bluca@debian.org \
--cc=dev@dpdk.org \
--cc=remy.horton@intel.com \
--cc=wei.dai@intel.com \
--cc=wenzhuo.lu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).