DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wenzhuo Lu <wenzhuo.lu@intel.com>
To: dev@dpdk.org
Cc: konstantin.ananyev@intel.com, bruce.richardson@intel.com,
	jing.d.chen@intel.com, cunming.liang@intel.com,
	jingjing.wu@intel.com, helin.zhang@intel.com,
	Zhe Tao <zhe.tao@intel.com>
Subject: [dpdk-dev] [PATCH v5 4/4] i40e: implement device reset on VF
Date: Wed, 15 Jun 2016 11:03:34 +0800	[thread overview]
Message-ID: <1465959814-16557-5-git-send-email-wenzhuo.lu@intel.com> (raw)
In-Reply-To: <1465959814-16557-1-git-send-email-wenzhuo.lu@intel.com>

Implement the device reset function.
This reset function will detach device then
attach device, reconfigure dev, re-setup the Rx/Tx queues.

Signed-off-by: Zhe Tao <zhe.tao@intel.com>
---
 doc/guides/rel_notes/release_16_07.rst |  4 ++
 drivers/net/i40e/i40e_ethdev.h         |  4 ++
 drivers/net/i40e/i40e_ethdev_vf.c      | 83 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_rxtx.c           | 10 ++++
 drivers/net/i40e/i40e_rxtx.h           |  4 ++
 5 files changed, 105 insertions(+)

diff --git a/doc/guides/rel_notes/release_16_07.rst b/doc/guides/rel_notes/release_16_07.rst
index a4c0cc3..6661b07 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -62,6 +62,10 @@ New Features
   callback in the message handler to notice the APP. APP need call the device
   reset API to reset the VF port.
 
+* **Added VF reset support for i40e VF driver.**
+
+  Added a new implementaion to allow i40e VF driver to
+  reset the functionality and state of itself.
 
 Resolved Issues
 ---------------
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cfd2399..4e0df3b 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -540,6 +540,8 @@ struct i40e_adapter {
 	struct rte_timecounter systime_tc;
 	struct rte_timecounter rx_tstamp_tc;
 	struct rte_timecounter tx_tstamp_tc;
+	/* For VF reset */
+	uint8_t reset_number;
 };
 
 int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
@@ -593,6 +595,8 @@ void i40e_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
 void i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
 	struct rte_eth_txq_info *qinfo);
 
+void i40evf_emulate_vf_reset(uint8_t port_id);
+
 /* I40E_DEV_PRIVATE_TO */
 #define I40E_DEV_PRIVATE_TO_PF(adapter) \
 	(&((struct i40e_adapter *)adapter)->pf)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 90682ac..2f65a29 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -157,6 +157,12 @@ i40evf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id);
 static void i40evf_handle_pf_event(__rte_unused struct rte_eth_dev *dev,
 				   uint8_t *msg,
 				   uint16_t msglen);
+static int i40evf_dev_uninit(struct rte_eth_dev *eth_dev);
+static int i40evf_dev_init(struct rte_eth_dev *eth_dev);
+static void i40evf_dev_close(struct rte_eth_dev *dev);
+static int i40evf_dev_start(struct rte_eth_dev *dev);
+static int i40evf_dev_configure(struct rte_eth_dev *dev);
+static int i40evf_handle_vf_reset(struct rte_eth_dev *dev);
 
 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1];
@@ -223,6 +229,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
 	.reta_query           = i40evf_dev_rss_reta_query,
 	.rss_hash_update      = i40evf_dev_rss_hash_update,
 	.rss_hash_conf_get    = i40evf_dev_rss_hash_conf_get,
+	.dev_reset            = i40evf_handle_vf_reset
 };
 
 /*
@@ -1309,6 +1316,82 @@ i40evf_uninit_vf(struct rte_eth_dev *dev)
 }
 
 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 void
+i40e_vf_reset_dev(struct rte_eth_dev *dev)
+{
+	struct i40e_adapter *adapter =
+		I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+
+	i40evf_dev_close(dev);
+	PMD_DRV_LOG(DEBUG, "i40evf dev close complete");
+	i40evf_dev_uninit(dev);
+	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);
+	i40evf_dev_init(dev);
+	PMD_DRV_LOG(DEBUG, "i40evf dev attached");
+	i40e_vf_queue_reset(dev);
+	PMD_DRV_LOG(DEBUG, "i40evf queue reset");
+	i40evf_dev_start(dev);
+	PMD_DRV_LOG(DEBUG, "i40evf dev restart");
+}
+
+static int
+i40evf_handle_vf_reset(struct rte_eth_dev *dev)
+{
+	struct i40e_adapter *adapter =
+		I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+
+	if (!dev->data->dev_started)
+		return 0;
+
+	adapter->reset_number = 1;
+	i40e_vf_reset_dev(dev);
+	adapter->reset_number = 0;
+
+	return 0;
+}
+
+void
+i40evf_emulate_vf_reset(uint8_t port_id)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+
+	i40evf_handle_vf_reset(dev);
+}
+
+static void
 i40evf_handle_pf_event(__rte_unused struct rte_eth_dev *dev,
 			   uint8_t *msg,
 			   __rte_unused uint16_t msglen)
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index c833aa3..8dbc64c 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2148,6 +2148,7 @@ i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	uint16_t len, i;
 	uint16_t base, bsf, tc_mapping;
 	int use_def_burst_func = 1;
+	struct rte_eth_rxconf conf = *rx_conf;
 
 	if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
 		struct i40e_vf *vf =
@@ -2186,6 +2187,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;
@@ -2365,6 +2368,7 @@ i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	uint32_t ring_size;
 	uint16_t tx_rs_thresh, tx_free_thresh;
 	uint16_t i, base, bsf, tc_mapping;
+	struct rte_eth_txconf conf = *tx_conf;
 
 	if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
 		struct i40e_vf *vf =
@@ -2488,6 +2492,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;
@@ -2950,8 +2956,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++) {
 		i40e_dev_rx_queue_release(dev->data->rx_queues[i]);
diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h
index 98179f0..9e1b05a 100644
--- a/drivers/net/i40e/i40e_rxtx.h
+++ b/drivers/net/i40e/i40e_rxtx.h
@@ -140,6 +140,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 {
@@ -181,6 +183,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 */
-- 
1.9.3

  parent reply	other threads:[~2016-06-15  3:03 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-06  5:40 [dpdk-dev] [PATCH 0/8] support reset of VF link Wenzhuo Lu
2016-06-06  5:40 ` [dpdk-dev] [PATCH 1/8] lib/librte_ether: support device reset Wenzhuo Lu
2016-06-06  5:40 ` [dpdk-dev] [PATCH 2/8] lib/librte_ether: defind RX/TX lock mode Wenzhuo Lu
2016-06-08  2:15   ` Stephen Hemminger
2016-06-08  7:34     ` Lu, Wenzhuo
2016-06-09  7:50       ` Olivier Matz
2016-06-12  5:25         ` Lu, Wenzhuo
2016-06-10 18:12       ` Stephen Hemminger
2016-06-12  5:27         ` Lu, Wenzhuo
2016-06-06  5:40 ` [dpdk-dev] [PATCH 3/8] ixgbe: RX/TX with lock on VF Wenzhuo Lu
2016-06-06  5:40 ` [dpdk-dev] [PATCH 4/8] ixgbe: implement device reset " Wenzhuo Lu
2016-06-06  5:40 ` [dpdk-dev] [PATCH 5/8] igb: RX/TX with lock " Wenzhuo Lu
2016-06-06  5:40 ` [dpdk-dev] [PATCH 6/8] igb: implement device reset " Wenzhuo Lu
2016-06-06  5:40 ` [dpdk-dev] [PATCH 7/8] i40e:RX/TX with lock " Wenzhuo Lu
2016-06-06  5:40 ` [dpdk-dev] [PATCH 8/8] i40e: implement device reset " Wenzhuo Lu
2016-06-15  3:03 ` [dpdk-dev] [PATCH v5 0/4] support reset of VF link Wenzhuo Lu
2016-06-15  3:03   ` [dpdk-dev] [PATCH v5 1/4] lib/librte_ether: support device reset Wenzhuo Lu
2016-06-16 15:31     ` Bruce Richardson
2016-06-16 15:36     ` Thomas Monjalon
2016-06-15  3:03   ` [dpdk-dev] [PATCH v5 2/4] ixgbe: implement device reset on VF Wenzhuo Lu
2016-06-15  3:03   ` [dpdk-dev] [PATCH v5 3/4] igb: " Wenzhuo Lu
2016-06-15  3:03   ` Wenzhuo Lu [this message]
2016-06-20  6:24 ` [dpdk-dev] [PATCH v6 0/4] support reset of VF link Wenzhuo Lu
2016-06-20  6:24   ` [dpdk-dev] [PATCH v6 1/4] lib/librte_ether: support device reset Wenzhuo Lu
2016-06-20  9:14     ` Jerin Jacob
2016-06-20 16:17       ` Stephen Hemminger
2016-06-21  3:51         ` Jerin Jacob
2016-06-21  6:14           ` Lu, Wenzhuo
2016-06-21  7:37             ` Jerin Jacob
2016-06-21  8:24               ` Lu, Wenzhuo
2016-06-21  8:55                 ` Jerin Jacob
2016-06-21  9:26                   ` Ananyev, Konstantin
2016-06-21 10:57                     ` Jerin Jacob
2016-06-21 13:10                       ` Ananyev, Konstantin
2016-06-21 13:30                         ` Jerin Jacob
2016-06-21 14:03                           ` Ananyev, Konstantin
2016-06-21 14:29                             ` Jerin Jacob
2016-06-22  1:35                               ` Lu, Wenzhuo
2016-06-22  2:37                                 ` Jerin Jacob
2016-06-22  3:32                                   ` Lu, Wenzhuo
2016-06-22  4:14                                     ` Jerin Jacob
2016-06-22  5:05                                       ` Lu, Wenzhuo
2016-06-22  6:10                                         ` Jerin Jacob
2016-06-22  6:42                                           ` Lu, Wenzhuo
2016-06-22  7:59                                             ` Jerin Jacob
2016-06-22  8:17                                               ` Thomas Monjalon
2016-06-22  8:25                                                 ` Lu, Wenzhuo
2016-06-22  9:18                                                   ` Thomas Monjalon
2016-06-22 11:06                                                     ` Jerin Jacob
2016-06-23  0:45                                                       ` Lu, Wenzhuo
2016-06-23  0:39                                                     ` Lu, Wenzhuo
2016-06-21  0:51       ` Lu, Wenzhuo
2016-06-20  6:24   ` [dpdk-dev] [PATCH v6 2/4] ixgbe: implement device reset on VF Wenzhuo Lu
2016-06-20  6:24   ` [dpdk-dev] [PATCH v6 3/4] igb: " Wenzhuo Lu
2016-06-20  6:24   ` [dpdk-dev] [PATCH v6 4/4] i40e: " Wenzhuo Lu
2016-07-04 15:48   ` [dpdk-dev] [PATCH v6 0/4] support reset of VF link Luca Boccassi
2016-07-05  0:52     ` Lu, Wenzhuo
2016-07-05  9:52       ` Luca Boccassi
2016-07-06  0:45         ` Lu, Wenzhuo
2016-07-06 16:26           ` Luca Boccassi
     [not found]           ` <1467822182.32466.34.camel@brocade.com>
2016-07-07  1:09             ` Lu, Wenzhuo
2016-07-07 10:20               ` Luca Boccassi
2016-07-07 13:12                 ` Lu, Wenzhuo
2016-07-07 16:19                   ` Luca Boccassi
2016-07-08  0:14                     ` Lu, Wenzhuo
2016-07-08 17:15                       ` Luca Boccassi
2016-07-11  1:32                         ` Lu, Wenzhuo
2016-07-11 12:02                           ` Luca Boccassi
2016-07-11 15:43                             ` Luca Boccassi
2016-07-12  1:19                               ` Lu, Wenzhuo
2016-08-26 12:58                               ` Luca Boccassi
2016-08-29  1:04                                 ` Lu, Wenzhuo

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=1465959814-16557-5-git-send-email-wenzhuo.lu@intel.com \
    --to=wenzhuo.lu@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=cunming.liang@intel.com \
    --cc=dev@dpdk.org \
    --cc=helin.zhang@intel.com \
    --cc=jing.d.chen@intel.com \
    --cc=jingjing.wu@intel.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=zhe.tao@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).