From mboxrd@z Thu Jan 1 00:00:00 1970 From: luca.boccassi@gmail.com Subject: [PATCH 2/3] net/e1000: implement VF reset Date: Tue, 24 Oct 2017 14:16:29 +0100 Message-ID: <20171024131630.16595-3-luca.boccassi@gmail.com> References: <20171024131630.16595-1-luca.boccassi@gmail.com> Cc: wenzhuo.lu@intel.com, wei.dai@intel.com, remy.horton@intel.com, Luca Boccassi To: dev@dpdk.org Return-path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 852681B801 for ; Tue, 24 Oct 2017 15:16:46 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id r196so3325857wmf.2 for ; Tue, 24 Oct 2017 06:16:46 -0700 (PDT) In-Reply-To: <20171024131630.16595-1-luca.boccassi@gmail.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Luca Boccassi 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 --- 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