From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id CCDB51322C for ; Tue, 9 Jan 2018 20:29:31 +0100 (CET) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1-us4.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id AD36C28006A; Tue, 9 Jan 2018 19:29:30 +0000 (UTC) Received: from [192.168.239.128] (188.242.181.57) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Tue, 9 Jan 2018 11:29:27 -0800 To: Stephen Hemminger CC: References: <20180108174514.14688-1-stephen@networkplumber.org> <20180108174514.14688-10-stephen@networkplumber.org> <20180109082732.4ba9115b@xeon-e3> From: Andrew Rybchenko Message-ID: Date: Tue, 9 Jan 2018 22:29:24 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180109082732.4ba9115b@xeon-e3> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [188.242.181.57] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ocex03.SolarFlarecom.com (10.20.40.36) X-MDID: 1515526171-ZoP7XZenG9xd Subject: Re: [dpdk-dev] [PATCH v3 09/15] net/sfc: use new rte_eth_linkstatus functions 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: Tue, 09 Jan 2018 19:29:32 -0000 On 01/09/2018 07:27 PM, Stephen Hemminger wrote: > On Tue, 9 Jan 2018 13:35:58 +0300 > Andrew Rybchenko wrote: > >> On 01/08/2018 08:45 PM, Stephen Hemminger wrote: >>> Use the new API (_rte_eth_linkstatus_set) to handle link status update. >>> >>> Signed-off-by: Stephen Hemminger >>> --- >>> drivers/net/sfc/sfc_ethdev.c | 27 +++++++-------------------- >>> drivers/net/sfc/sfc_ev.c | 23 ++++------------------- >>> 2 files changed, 11 insertions(+), 39 deletions(-) >>> >>> diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c >>> index 2f5f86f84877..e0a12b32b1a3 100644 >>> --- a/drivers/net/sfc/sfc_ethdev.c >>> +++ b/drivers/net/sfc/sfc_ethdev.c >>> @@ -238,22 +238,12 @@ static int >>> sfc_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) >>> { >>> struct sfc_adapter *sa = dev->data->dev_private; >>> - struct rte_eth_link *dev_link = &dev->data->dev_link; >>> - struct rte_eth_link old_link; >>> struct rte_eth_link current_link; >>> >>> sfc_log_init(sa, "entry"); >>> >>> -retry: >>> - EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t)); >>> - *(int64_t *)&old_link = rte_atomic64_read((rte_atomic64_t *)dev_link); >>> - >>> if (sa->state != SFC_ADAPTER_STARTED) { >>> sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, ¤t_link); >>> - if (!rte_atomic64_cmpset((volatile uint64_t *)dev_link, >>> - *(uint64_t *)&old_link, >>> - *(uint64_t *)¤t_link)) >>> - goto retry; >>> } else if (wait_to_complete) { >>> efx_link_mode_t link_mode; >>> >>> @@ -261,21 +251,18 @@ sfc_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) >>> link_mode = EFX_LINK_UNKNOWN; >>> sfc_port_link_mode_to_info(link_mode, ¤t_link); >>> >>> - if (!rte_atomic64_cmpset((volatile uint64_t *)dev_link, >>> - *(uint64_t *)&old_link, >>> - *(uint64_t *)¤t_link)) >>> - goto retry; >>> } else { >>> sfc_ev_mgmt_qpoll(sa); >>> - *(int64_t *)¤t_link = >>> - rte_atomic64_read((rte_atomic64_t *)dev_link); >>> + _rte_eth_linkstatus_get(dev, ¤t_link); >>> } >>> >>> - if (old_link.link_status != current_link.link_status) >>> - sfc_info(sa, "Link status is %s", >>> - current_link.link_status ? "UP" : "DOWN"); >>> + if (_rte_eth_linkstatus_set(dev, ¤t_link) == 0) >>> + return 0; >>> + >>> + sfc_info(sa, "Link status is %s", >>> + current_link.link_status ? "UP" : "DOWN"); >>> >>> - return old_link.link_status == current_link.link_status ? 0 : -1; >>> + return -1; >>> } >>> >>> static void >>> diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c >>> index a16dc27b380e..3e96536a9d60 100644 >>> --- a/drivers/net/sfc/sfc_ev.c >>> +++ b/drivers/net/sfc/sfc_ev.c >>> @@ -404,29 +404,14 @@ sfc_ev_link_change(void *arg, efx_link_mode_t link_mode) >>> { >>> struct sfc_evq *evq = arg; >>> struct sfc_adapter *sa = evq->sa; >>> - struct rte_eth_link *dev_link = &sa->eth_dev->data->dev_link; >>> struct rte_eth_link new_link; >>> - uint64_t new_link_u64; >>> - uint64_t old_link_u64; >>> - >>> - EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t)); >>> >>> sfc_port_link_mode_to_info(link_mode, &new_link); >>> + if (_rte_eth_linkstatus_set(sa->eth_dev, &new_link) == 0) >>> + return B_FALSE; >>> >>> - new_link_u64 = *(uint64_t *)&new_link; >>> - do { >>> - old_link_u64 = rte_atomic64_read((rte_atomic64_t *)dev_link); >>> - if (old_link_u64 == new_link_u64) >>> - break; >>> - >>> - if (rte_atomic64_cmpset((volatile uint64_t *)dev_link, >>> - old_link_u64, new_link_u64)) { >>> - evq->sa->port.lsc_seq++; >>> - break; >>> - } >>> - } while (B_TRUE); >>> - >>> - return B_FALSE; >>> + evq->sa->port.lsc_seq++; >>> + return B_TRUE; >> It still returns B_TRUE, but should return B_FALSE as before. >> Also before the patch lsc_seq is incremented in the case of any >> changes in link status, but now in the case of up/down change only. > The old code looked broken and did not match the comments. > It always returned B_FALSE independent of whether link status changed > or not. Which comments does it not match? Yes, because it is internal callback and return value is unrelated to link status changes. Return value affects further events processing. If B_TRUE is returned, it means something bad has happened and events processing should be aborted.