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 1/3] net/i40e: implement VF reset
Date: Tue, 24 Oct 2017 14:16:28 +0100 [thread overview]
Message-ID: <20171024131630.16595-2-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 detach then re-attach the device, reconfigure
it, and re-setup the Rx/Tx queues.
Signed-off-by: Luca Boccassi <bluca@debian.org>
---
drivers/net/i40e/i40e_ethdev.h | 3 +++
drivers/net/i40e/i40e_ethdev_vf.c | 56 ++++++++++++++++++++++++++++++++++++---
drivers/net/i40e/i40e_rxtx.c | 11 ++++++++
drivers/net/i40e/i40e_rxtx.h | 4 +++
4 files changed, 70 insertions(+), 4 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 2f1905e13..45714959a 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -1047,6 +1047,9 @@ struct i40e_adapter {
struct rte_timecounter rx_tstamp_tc;
struct rte_timecounter tx_tstamp_tc;
+ /* For VF reset */
+ uint8_t reset_number;
+
/* ptype mapping table */
uint32_t ptype_tbl[I40E_MAX_PKT_TYPE] __rte_cache_min_aligned;
/* flow type to pctype mapping table */
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 9f1487509..333ddb4ca 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -2294,21 +2294,69 @@ i40evf_dev_close(struct rte_eth_dev *dev)
i40evf_disable_irq0(hw);
}
-/*
- * Reset VF device only to re-initialize resources in PMD layer
- */
+static void
+i40e_vf_queue_reset(struct rte_eth_dev *dev)
+{
+ uint16_t i;
+
+ for (i = 0; i < dev->data->nb_rx_queues; i++) {
+ struct i40e_rx_queue *rxq = dev->data->rx_queues[i];
+
+ if (rxq->q_set) {
+ i40e_dev_rx_queue_setup(dev,
+ rxq->queue_id,
+ rxq->nb_rx_desc,
+ rxq->socket_id,
+ &rxq->rxconf,
+ rxq->mp);
+ }
+ }
+ for (i = 0; i < dev->data->nb_tx_queues; i++) {
+ struct i40e_tx_queue *txq = dev->data->tx_queues[i];
+
+ if (txq->q_set) {
+ i40e_dev_tx_queue_setup(dev,
+ txq->queue_id,
+ txq->nb_tx_desc,
+ txq->socket_id,
+ &txq->txconf);
+ }
+ }
+}
+
static int
i40evf_dev_reset(struct rte_eth_dev *dev)
{
int ret;
+ struct i40e_adapter *adapter =
+ I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+ if (!dev->data->dev_started)
+ return -EAGAIN;
+
+ adapter->reset_number = 1;
+ i40evf_dev_close(dev);
+ PMD_DRV_LOG(DEBUG, "i40evf dev close complete");
ret = i40evf_dev_uninit(dev);
if (ret)
return ret;
+ PMD_DRV_LOG(DEBUG, "i40evf dev detached");
+ memset(dev->data->dev_private, 0,
+ (uint64_t)&adapter->reset_number - (uint64_t)adapter);
+ i40evf_dev_configure(dev);
ret = i40evf_dev_init(dev);
+ if (ret)
+ return ret;
+ PMD_DRV_LOG(DEBUG, "i40evf dev attached");
- return ret;
+ i40e_vf_queue_reset(dev);
+ PMD_DRV_LOG(DEBUG, "i40evf queue reset");
+ i40evf_dev_start(dev);
+ PMD_DRV_LOG(DEBUG, "i40evf dev restart");
+ adapter->reset_number = 0;
+
+ return 0;
}
static int
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index f21c1c5d2..3d5125260 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -1745,6 +1745,7 @@ i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
uint32_t ring_size;
uint16_t len, i;
uint16_t reg_idx, base, bsf, tc_mapping;
+ struct rte_eth_rxconf conf = *rx_conf;
int q_offset, use_def_burst_func = 1;
if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
@@ -1789,6 +1790,8 @@ i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
return -ENOMEM;
}
rxq->mp = mp;
+ rxq->socket_id = socket_id;
+ rxq->rxconf = conf;
rxq->nb_rx_desc = nb_desc;
rxq->rx_free_thresh = rx_conf->rx_free_thresh;
rxq->queue_id = queue_idx;
@@ -2024,6 +2027,8 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
uint16_t reg_idx, i, base, bsf, tc_mapping;
int q_offset;
+ struct rte_eth_txconf conf = *tx_conf;
+
if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
vsi = &vf->vsi;
@@ -2149,6 +2154,8 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
}
txq->nb_tx_desc = nb_desc;
+ txq->socket_id = socket_id;
+ txq->txconf = conf;
txq->tx_rs_thresh = tx_rs_thresh;
txq->tx_free_thresh = tx_free_thresh;
txq->pthresh = tx_conf->tx_thresh.pthresh;
@@ -2628,8 +2635,12 @@ void
i40e_dev_free_queues(struct rte_eth_dev *dev)
{
uint16_t i;
+ struct i40e_adapter *adapter =
+ I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
PMD_INIT_FUNC_TRACE();
+ if (adapter->reset_number)
+ return;
for (i = 0; i < dev->data->nb_rx_queues; i++) {
if (!dev->data->rx_queues[i])
diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h
index 06c6a6592..43e227a52 100644
--- a/drivers/net/i40e/i40e_rxtx.h
+++ b/drivers/net/i40e/i40e_rxtx.h
@@ -136,6 +136,8 @@ struct i40e_rx_queue {
bool rx_deferred_start; /**< don't start this queue in dev start */
uint16_t rx_using_sse; /**<flag indicate the usage of vPMD for rx */
uint8_t dcb_tc; /**< Traffic class of rx queue */
+ uint8_t socket_id;
+ struct rte_eth_rxconf rxconf;
};
struct i40e_tx_entry {
@@ -177,6 +179,8 @@ struct i40e_tx_queue {
bool q_set; /**< indicate if tx queue has been configured */
bool tx_deferred_start; /**< don't start this queue in dev start */
uint8_t dcb_tc; /**< Traffic class of tx queue */
+ uint8_t socket_id;
+ struct rte_eth_txconf txconf;
};
/** Offload features */
--
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 ` luca.boccassi [this message]
2017-10-24 13:16 ` [dpdk-dev] [PATCH 2/3] net/e1000: implement VF reset luca.boccassi
2017-10-24 13:16 ` [dpdk-dev] [PATCH 3/3] net/ixgbe: " luca.boccassi
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-2-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).