DPDK patches and discussions
 help / color / mirror / Atom feed
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 2/3] net/e1000: implement VF reset
Date: Tue, 24 Oct 2017 14:16:29 +0100	[thread overview]
Message-ID: <20171024131630.16595-3-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/e1000/igb_ethdev.c | 59 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 003bdf0f6..1211d5371 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -280,6 +280,7 @@ static void eth_igb_configure_msix_intr(struct rte_eth_dev *dev);
 static void eth_igbvf_interrupt_handler(void *param);
 static void igbvf_mbx_process(struct rte_eth_dev *dev);
 static int igb_filter_restore(struct rte_eth_dev *dev);
+static int igbvf_dev_reset(struct rte_eth_dev *dev);
 
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
@@ -468,6 +469,7 @@ static const struct eth_dev_ops igbvf_eth_dev_ops = {
 	.txq_info_get         = igb_txq_info_get,
 	.mac_addr_set         = igbvf_default_mac_addr_set,
 	.get_reg              = igbvf_get_regs,
+	.dev_reset            = igbvf_dev_reset,
 };
 
 /* store statistics names and its offset in stats structure */
@@ -2975,6 +2977,63 @@ void igbvf_mbx_process(struct rte_eth_dev *dev)
 }
 
 static int
+igbvf_dev_reset(struct rte_eth_dev *dev)
+{
+	struct e1000_hw *hw =
+		 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	int diag = 0;
+	uint32_t eiam;
+	/* Reference igbvf_intr_enable */
+	uint32_t eiam_mbx = 1 << E1000_VTIVAR_MISC_MAILBOX;
+
+	/* Nothing needs to be done if the device is not started. */
+	if (!dev->data->dev_started)
+		 return -EAGAIN;
+
+	PMD_DRV_LOG(DEBUG, "Link up/down event detected.");
+
+	/* Performance VF reset. */
+	do {
+		 dev->data->dev_started = 0;
+		 igbvf_dev_stop(dev);
+		 if (dev->data->dev_conf.intr_conf.lsc == 0)
+			  diag = eth_igb_link_update(dev, 0);
+		 if (diag) {
+			  PMD_INIT_LOG(INFO, "Igb VF reset: "
+					 "Failed to update link.");
+		 }
+		 rte_delay_ms(1000);
+
+		 diag = igbvf_dev_start(dev);
+		 dev->data->dev_started = 1;
+		 if (diag) {
+			  PMD_INIT_LOG(ERR, "Igb VF reset: "
+					 "Failed to start device.");
+			  return -EAGAIN;
+		 }
+		 eth_igbvf_stats_reset(dev);
+		 if (dev->data->dev_conf.intr_conf.lsc == 0)
+			  diag = eth_igb_link_update(dev, 0);
+		 if (diag) {
+			  PMD_INIT_LOG(INFO, "Igb VF reset: "
+					 "Failed to update link.");
+		 }
+
+		 /**
+		  * 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, in other words, until the
+		  * registers can be written.
+		  */
+		 eiam = E1000_READ_REG(hw, E1000_EIAM);
+	} while (!(eiam & eiam_mbx));
+
+	return 0;
+}
+
+static int
 eth_igbvf_interrupt_action(struct rte_eth_dev *dev, struct rte_intr_handle *intr_handle)
 {
 	struct e1000_interrupt *intr =
-- 
2.11.0

  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 ` luca.boccassi [this message]
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-3-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).