From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nbfkord-smmo01.seg.att.com (nbfkord-smmo01.seg.att.com [209.65.160.76]) by dpdk.org (Postfix) with ESMTP id A9C164AC7 for ; Tue, 29 Nov 2016 17:20:54 +0100 (CET) Received: from unknown [12.187.104.26] (EHLO nbfkord-smmo01.seg.att.com) by nbfkord-smmo01.seg.att.com(mxl_mta-7.2.4-7) with ESMTP id 6eaad385.2b3e9405f940.83595.00-2499.173937.nbfkord-smmo01.seg.att.com (envelope-from ); Tue, 29 Nov 2016 16:20:54 +0000 (UTC) X-MXL-Hash: 583daae64b526cc2-491759ca92f24b7d93f0f473f1d34a98f03c0dbb Received: from unknown [12.187.104.26] by nbfkord-smmo01.seg.att.com(mxl_mta-7.2.4-7) with SMTP id 3eaad385.0.83424.00-2366.173873.nbfkord-smmo01.seg.att.com (envelope-from ); Tue, 29 Nov 2016 16:20:53 +0000 (UTC) X-MXL-Hash: 583daae5049cd498-469db222fc828b1b2cd001d30e17e3daf238484f Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Tue, 29 Nov 2016 08:20:26 -0800 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25 via Frontend Transport; Tue, 29 Nov 2016 08:20:25 -0800 Received: from uklogin.uk.solarflarecom.com (uklogin.uk.solarflarecom.com [10.17.10.10]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id uATGKOo9030024; Tue, 29 Nov 2016 16:20:24 GMT Received: from uklogin.uk.solarflarecom.com (localhost.localdomain [127.0.0.1]) by uklogin.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id uATGKM1o021233; Tue, 29 Nov 2016 16:20:24 GMT From: Andrew Rybchenko To: CC: , Artem Andreev Date: Tue, 29 Nov 2016 16:19:14 +0000 Message-ID: <1480436367-20749-43-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1480436367-20749-1-git-send-email-arybchenko@solarflare.com> References: <1479740470-6723-1-git-send-email-arybchenko@solarflare.com> <1480436367-20749-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-AnalysisOut: [v=2.1 cv=UoJlQrEB c=1 sm=1 tr=0 a=8BlWFWvVlq5taO8ncb8nKg==] X-AnalysisOut: [:17 a=L24OOQBejmoA:10 a=pK7X0mNQAAAA:8 a=zRKbQ67AAAAA:8 a=] X-AnalysisOut: [vkRlZemiprFAPncsQN0A:9 a=b2bNDOc92E1c_fD1:21 a=wBbkF231zBL] X-AnalysisOut: [lKbVK:21 a=5HA-qpC1VU4iIGLgRoNS:22 a=PA03WX8tBzeizutn5_OT:] X-AnalysisOut: [22] X-Spam: [F=0.4984988466; CM=0.500; S=0.498(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [12.187.104.26] Subject: [dpdk-dev] [PATCH v2 42/55] net/sfc: implement device operation to retrieve link info 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: Tue, 29 Nov 2016 16:20:55 -0000 From: Artem Andreev Reviewed-by: Andy Moreton Signed-off-by: Artem Andreev Signed-off-by: Andrew Rybchenko --- doc/guides/nics/features/sfc_efx.ini | 1 + doc/guides/nics/sfc_efx.rst | 2 ++ drivers/net/sfc/Makefile | 2 ++ drivers/net/sfc/sfc.h | 3 ++ drivers/net/sfc/sfc_ethdev.c | 42 ++++++++++++++++++++++++++ drivers/net/sfc/sfc_ev.c | 14 ++++++--- drivers/net/sfc/sfc_port.c | 58 ++++++++++++++++++++++++++++++++++++ 7 files changed, 118 insertions(+), 4 deletions(-) diff --git a/doc/guides/nics/features/sfc_efx.ini b/doc/guides/nics/features/sfc_efx.ini index 59eb830..7dc2e92 100644 --- a/doc/guides/nics/features/sfc_efx.ini +++ b/doc/guides/nics/features/sfc_efx.ini @@ -4,6 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +Link status = Y BSD nic_uio = Y Linux UIO = Y Linux VFIO = Y diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 271c8c6..46c892b 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -44,6 +44,8 @@ SFC EFX PMD has support for: - Multiple transmit and receive queues +- Link state information + Non-supported Features ---------------------- diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile index 04c1db1..89fc2f3 100644 --- a/drivers/net/sfc/Makefile +++ b/drivers/net/sfc/Makefile @@ -37,6 +37,8 @@ CFLAGS += -I$(SRCDIR)/base/ CFLAGS += -I$(SRCDIR) CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +# Strict-aliasing rules are violated by rte_eth_link to uint64_t casts +CFLAGS += -Wno-strict-aliasing # Enable extra warnings CFLAGS += -Wextra diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 042e504..100815b 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -215,6 +215,9 @@ int sfc_port_init(struct sfc_adapter *sa); void sfc_port_fini(struct sfc_adapter *sa); int sfc_port_start(struct sfc_adapter *sa); void sfc_port_stop(struct sfc_adapter *sa); +void sfc_port_link_mode_to_info(efx_link_mode_t link_mode, + struct rte_eth_link *link_info); + #ifdef __cplusplus } diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 316723e..ee52544 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -37,6 +37,7 @@ #include "sfc_debug.h" #include "sfc_log.h" #include "sfc_kvargs.h" +#include "sfc_ev.h" static void @@ -100,6 +101,46 @@ sfc_dev_start(struct rte_eth_dev *dev) return -rc; } +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"); + + if (sa->state != SFC_ADAPTER_STARTED) + return 0; + +retry: + EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t)); + *(int64_t *)&old_link = rte_atomic64_read((rte_atomic64_t *)dev_link); + + if (wait_to_complete) { + efx_link_mode_t link_mode; + + efx_port_poll(sa->nic, &link_mode); + 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); + } + + if (old_link.link_status != current_link.link_status) + sfc_info(sa, "Link status is %s", + current_link.link_status ? "UP" : "DOWN"); + + return old_link.link_status == current_link.link_status ? 0 : -1; +} + static void sfc_dev_stop(struct rte_eth_dev *dev) { @@ -147,6 +188,7 @@ static const struct eth_dev_ops sfc_eth_dev_ops = { .dev_start = sfc_dev_start, .dev_stop = sfc_dev_stop, .dev_close = sfc_dev_close, + .link_update = sfc_dev_link_update, .dev_infos_get = sfc_dev_infos_get, }; diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c index 179c4f8..ee4cd70 100644 --- a/drivers/net/sfc/sfc_ev.c +++ b/drivers/net/sfc/sfc_ev.c @@ -181,13 +181,19 @@ sfc_ev_timer(void *arg, uint32_t index) } static boolean_t -sfc_ev_link_change(void *arg, __rte_unused efx_link_mode_t link_mode) +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; - sfc_err(evq->sa, "EVQ %u unexpected link change", - evq->evq_index); - return B_TRUE; + EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t)); + + sfc_port_link_mode_to_info(link_mode, &new_link); + rte_atomic64_set((rte_atomic64_t *)dev_link, *(uint64_t *)&new_link); + + return B_FALSE; } static const efx_ev_callbacks_t sfc_ev_callbacks = { diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index 844363c..c124181 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -129,3 +129,61 @@ sfc_port_fini(struct sfc_adapter *sa) sfc_log_init(sa, "done"); } + +void +sfc_port_link_mode_to_info(efx_link_mode_t link_mode, + struct rte_eth_link *link_info) +{ + SFC_ASSERT(link_mode < EFX_LINK_NMODES); + + memset(link_info, 0, sizeof(*link_info)); + if ((link_mode == EFX_LINK_DOWN) || (link_mode == EFX_LINK_UNKNOWN)) + link_info->link_status = ETH_LINK_DOWN; + else + link_info->link_status = ETH_LINK_UP; + + switch (link_mode) { + case EFX_LINK_10HDX: + link_info->link_speed = ETH_SPEED_NUM_10M; + link_info->link_duplex = ETH_LINK_HALF_DUPLEX; + break; + case EFX_LINK_10FDX: + link_info->link_speed = ETH_SPEED_NUM_10M; + link_info->link_duplex = ETH_LINK_FULL_DUPLEX; + break; + case EFX_LINK_100HDX: + link_info->link_speed = ETH_SPEED_NUM_100M; + link_info->link_duplex = ETH_LINK_HALF_DUPLEX; + break; + case EFX_LINK_100FDX: + link_info->link_speed = ETH_SPEED_NUM_100M; + link_info->link_duplex = ETH_LINK_FULL_DUPLEX; + break; + case EFX_LINK_1000HDX: + link_info->link_speed = ETH_SPEED_NUM_1G; + link_info->link_duplex = ETH_LINK_HALF_DUPLEX; + break; + case EFX_LINK_1000FDX: + link_info->link_speed = ETH_SPEED_NUM_1G; + link_info->link_duplex = ETH_LINK_FULL_DUPLEX; + break; + case EFX_LINK_10000FDX: + link_info->link_speed = ETH_SPEED_NUM_10G; + link_info->link_duplex = ETH_LINK_FULL_DUPLEX; + break; + case EFX_LINK_40000FDX: + link_info->link_speed = ETH_SPEED_NUM_40G; + link_info->link_duplex = ETH_LINK_FULL_DUPLEX; + break; + default: + SFC_ASSERT(B_FALSE); + /* FALLTHROUGH */ + case EFX_LINK_UNKNOWN: + case EFX_LINK_DOWN: + link_info->link_speed = ETH_SPEED_NUM_NONE; + link_info->link_duplex = 0; + break; + } + + link_info->link_autoneg = ETH_LINK_AUTONEG; +} -- 2.5.5