From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f53.google.com (mail-pg0-f53.google.com [74.125.83.53]) by dpdk.org (Postfix) with ESMTP id BCCA27CAE for ; Fri, 14 Jul 2017 20:30:49 +0200 (CEST) Received: by mail-pg0-f53.google.com with SMTP id t186so49538681pgb.1 for ; Fri, 14 Jul 2017 11:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Iyy9fhczQKjP9oqGriyyy+h1E452VyrKevtw0YBRN/E=; b=hD0ZU7OxvC2YtbsAbEgyCz1Yw2rdJc5l81yr4fa84wrLVcda5DkNq5ti4byE3M1/ph BcfJrznePp0oL3p6mbaAy5FgeKGadf2jB2usTfyhb85EphC/n/eldRtwnQA5P0fjngMn E+Wr3PpfTMKW5oH0oiVRVKqeQIvEW/cIF5ztd8bac6F7LlVzWGSaVqzDUADZwLW+bD+g UWCpNZagzKWDEEpwMz1jTM0XrW6aK8DyVu/ygwCXhpLxvlr8CmcKFtlGg2J1GK3KbmLw tsQzXZpqIHhTTRewZf4wWcQqDIQhwtMCmU/lS//TsfTwuLyiIit23ZnJF2dZYvHR9IWh ZEGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Iyy9fhczQKjP9oqGriyyy+h1E452VyrKevtw0YBRN/E=; b=AHViQf1ph3d5nzcjqqmd6tPM7378vngbkxBgacxXUtwWPDbyafrYYSAXxyYoNaCCfI rG2XlX5sLHrmAC6+UQYVtfYO0So4Qaq6p7wWIKssCs0CJgSNakLOzr5l9lpN3U8CMuxJ ZdQCvorUCf1rGmcyHgFi6oXmk2wA72dbjBmsMV0TaWHKPaZRsKp19cC9/kI5Yxz86vq4 6kRyvKcoUgs+JLs4utwmNQRaTA/wkd8Rp0YvuL1mlcZ1dJJ/i4nXIO4ktem/9291jVQq XaZy6qUtugkBV/OcmxWvYCB4Vg1oyeRSXeNr3Pg04JgoOpb/DriRHL2acfQraqH7Fs1w vQqg== X-Gm-Message-State: AIVw112775RVS1B22hLL2CM3MCSMYMuDWsFyPcmrCAj3hk1zVP8/q0rP vSrmljYuxpAq8ZtY/xNNWg== X-Received: by 10.98.35.214 with SMTP id q83mr6803029pfj.101.1500057048385; Fri, 14 Jul 2017 11:30:48 -0700 (PDT) Received: from xeon-e3.wavecable.com (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id r9sm22711163pfi.114.2017.07.14.11.30.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 11:30:47 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 14 Jul 2017 11:30:23 -0700 Message-Id: <20170714183027.16021-11-stephen@networkplumber.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170714183027.16021-1-stephen@networkplumber.org> References: <20170714183027.16021-1-stephen@networkplumber.org> Subject: [dpdk-dev] [RFC 10/14] i40e: use rte_eth_link_update (and bug fix) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jul 2017 18:30:50 -0000 Use new rte_link_update API, and as a side effect fix bug where driver was not correctly returning link status changes. Signed-off-by: Stephen Hemminger --- drivers/net/i40e/i40e_ethdev.c | 44 ++++++--------------------------------- drivers/net/i40e/i40e_ethdev_vf.c | 19 ++--------------- 2 files changed, 8 insertions(+), 55 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 97a73e1cb913..0f824b022ce2 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -650,34 +650,6 @@ static struct rte_pci_driver rte_i40e_pmd = { .remove = eth_i40e_pci_remove, }; -static inline int -rte_i40e_dev_atomic_read_link_status(struct rte_eth_dev *dev, - struct rte_eth_link *link) -{ - struct rte_eth_link *dst = link; - struct rte_eth_link *src = &(dev->data->dev_link); - - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) - return -1; - - return 0; -} - -static inline int -rte_i40e_dev_atomic_write_link_status(struct rte_eth_dev *dev, - struct rte_eth_link *link) -{ - struct rte_eth_link *dst = &(dev->data->dev_link); - struct rte_eth_link *src = link; - - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) - return -1; - - return 0; -} - RTE_PMD_REGISTER_PCI(net_i40e, rte_i40e_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_i40e, pci_id_i40e_map); RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "* igb_uio | uio_pci_generic | vfio-pci"); @@ -2252,17 +2224,16 @@ i40e_dev_link_update(struct rte_eth_dev *dev, #define MAX_REPEAT_TIME 10 /* 1s (10 * 100ms) in total */ struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct i40e_link_status link_status; - struct rte_eth_link link, old; + struct rte_eth_link link; int status; unsigned rep_cnt = MAX_REPEAT_TIME; bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; memset(&link, 0, sizeof(link)); - memset(&old, 0, sizeof(old)); - memset(&link_status, 0, sizeof(link_status)); - rte_i40e_dev_atomic_read_link_status(dev, &old); do { + memset(&link_status, 0, sizeof(link_status)); + /* Get link status information from hardware */ status = i40e_aq_get_link_info(hw, enable_lse, &link_status, NULL); @@ -2315,13 +2286,10 @@ i40e_dev_link_update(struct rte_eth_dev *dev, ETH_LINK_SPEED_FIXED); out: - rte_i40e_dev_atomic_write_link_status(dev, &link); - if (link.link_status == old.link_status) - return -1; - + status = _rte_eth_link_update(dev, &link); i40e_notify_all_vfs_link_status(dev); - return 0; + return status; } /* Get all the statistics of a VSI */ @@ -9746,7 +9714,7 @@ i40e_start_timecounters(struct rte_eth_dev *dev) /* Get current link speed. */ memset(&link, 0, sizeof(link)); i40e_dev_link_update(dev, 1); - rte_i40e_dev_atomic_read_link_status(dev, &link); + _rte_eth_link_read(dev, &link); switch (link.link_speed) { case ETH_SPEED_NUM_40G: diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index bab09f814215..491957bc65fa 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1124,20 +1124,6 @@ static const struct rte_pci_id pci_id_i40evf_map[] = { { .vendor_id = 0, /* sentinel */ }, }; -static inline int -i40evf_dev_atomic_write_link_status(struct rte_eth_dev *dev, - struct rte_eth_link *link) -{ - struct rte_eth_link *dst = &(dev->data->dev_link); - struct rte_eth_link *src = link; - - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) - return -1; - - return 0; -} - /* Disable IRQ0 */ static inline void i40evf_disable_irq0(struct i40e_hw *hw) @@ -2170,6 +2156,7 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, * while Linux driver does not */ + memset(&new_link, 0, sizeof(new_link)); /* Linux driver PF host */ switch (vf->link_speed) { case I40E_LINK_SPEED_100MB: @@ -2199,9 +2186,7 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_status = vf->link_up ? ETH_LINK_UP : ETH_LINK_DOWN; - i40evf_dev_atomic_write_link_status(dev, &new_link); - - return 0; + return _rte_eth_link_update(dev, &new_link); } static void -- 2.11.0