From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 193F69AE0 for ; Mon, 20 Jun 2016 08:24:48 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 19 Jun 2016 23:24:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,496,1459839600"; d="scan'208";a="722072657" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 19 Jun 2016 23:24:45 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id u5K6OgF4002678; Mon, 20 Jun 2016 14:24:42 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u5K6OcvK006895; Mon, 20 Jun 2016 14:24:40 +0800 Received: (from wenzhuol@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u5K6Oc3w006891; Mon, 20 Jun 2016 14:24:38 +0800 From: Wenzhuo Lu 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, thomas.monjalon@6wind.com, Wenzhuo Lu Date: Mon, 20 Jun 2016 14:24:29 +0800 Message-Id: <1466403870-6840-4-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1466403870-6840-1-git-send-email-wenzhuo.lu@intel.com> References: <1465191653-28408-1-git-send-email-wenzhuo.lu@intel.com> <1466403870-6840-1-git-send-email-wenzhuo.lu@intel.com> Subject: [dpdk-dev] [PATCH v6 3/4] igb: implement device reset on VF X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jun 2016 06:24:49 -0000 Implement the device reset function. Signed-off-by: Wenzhuo Lu --- doc/guides/rel_notes/release_16_07.rst | 2 +- drivers/net/e1000/igb_ethdev.c | 59 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/doc/guides/rel_notes/release_16_07.rst b/doc/guides/rel_notes/release_16_07.rst index d36c4b1..a4c0cc3 100644 --- a/doc/guides/rel_notes/release_16_07.rst +++ b/doc/guides/rel_notes/release_16_07.rst @@ -53,7 +53,7 @@ New Features VF. To handle this link up/down event, add the mailbox interruption support to receive the message. -* **Added device reset support for ixgbe VF.** +* **Added device reset support for ixgbe/igb VF.** Added the device reset API. APP can call this API to reset the VF port when it's not working. diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index b0e5e6a..f1ac4b5 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -268,6 +268,7 @@ static void eth_igb_configure_msix_intr(struct rte_eth_dev *dev); static void eth_igbvf_interrupt_handler(struct rte_intr_handle *handle, void *param); static void igbvf_mbx_process(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 @@ -409,6 +410,7 @@ static const struct eth_dev_ops igbvf_eth_dev_ops = { .mac_addr_set = igbvf_default_mac_addr_set, .get_reg_length = igbvf_get_reg_length, .get_reg = igbvf_get_regs, + .dev_reset = igbvf_dev_reset, }; /* store statistics names and its offset in stats structure */ @@ -2655,6 +2657,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 0; + + 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); + if (diag) { + PMD_INIT_LOG(ERR, "Igb VF reset: " + "Failed to start device."); + return diag; + } + dev->data->dev_started = 1; + 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 has chance + * that VF cannot operate its registers. Will + * check if the registers is 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 e1000_interrupt *intr = -- 1.9.3