From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nbfkord-smmo03.seg.att.com (nbfkord-smmo03.seg.att.com [209.65.160.84]) by dpdk.org (Postfix) with ESMTP id B03DF475E for ; Thu, 15 Dec 2016 13:52:11 +0100 (CET) Received: from unknown [12.187.104.26] (EHLO nbfkord-smmo03.seg.att.com) by nbfkord-smmo03.seg.att.com(mxl_mta-7.2.4-7) with ESMTP id bf192585.2b634d087940.1049152.00-2468.2166141.nbfkord-smmo03.seg.att.com (envelope-from ); Thu, 15 Dec 2016 12:52:11 +0000 (UTC) X-MXL-Hash: 585291fb39506f7a-2c947ac1a9b07fc0856ba46fcc9c5de797571441 Received: from unknown [12.187.104.26] by nbfkord-smmo03.seg.att.com(mxl_mta-7.2.4-7) with SMTP id 9f192585.0.1049147.00-2355.2166130.nbfkord-smmo03.seg.att.com (envelope-from ); Thu, 15 Dec 2016 12:52:10 +0000 (UTC) X-MXL-Hash: 585291fa1d14bde9-b198d432517773e59d6a46284cb914f8359bc037 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; Thu, 15 Dec 2016 04:52:05 -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; Thu, 15 Dec 2016 04:52:05 -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 uBFCq38m006375; Thu, 15 Dec 2016 12:52:03 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 uBFCpceh010431; Thu, 15 Dec 2016 12:52:03 GMT From: Andrew Rybchenko To: CC: Date: Thu, 15 Dec 2016 12:50:59 +0000 Message-ID: <1481806283-10387-9-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1481806283-10387-1-git-send-email-arybchenko@solarflare.com> References: <1480664691-26561-1-git-send-email-arybchenko@solarflare.com> <1481806283-10387-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-AnalysisOut: [v=2.1 cv=HuVwbhnS c=1 sm=1 tr=0 a=8BlWFWvVlq5taO8ncb8nKg==] X-AnalysisOut: [:17 a=n5n_aSjo0skA:10 a=zRKbQ67AAAAA:8 a=sBjm08WUN41eEaLJI] X-AnalysisOut: [NwA:9 a=PA03WX8tBzeizutn5_OT:22] X-Spam: [F=0.4888115325; CM=0.500; S=0.488(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [12.187.104.26] Subject: [dpdk-dev] [PATCH v2 08/32] net/sfc: support link speed and duplex settings 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: Thu, 15 Dec 2016 12:52:12 -0000 Signed-off-by: Andrew Rybchenko Reviewed-by: Andrew Lee Reviewed-by: Robert Stonehouse --- doc/guides/nics/features/sfc_efx.ini | 1 + drivers/net/sfc/sfc.c | 38 ++++++++++++++++++++++++++++++++++-- drivers/net/sfc/sfc.h | 3 +++ drivers/net/sfc/sfc_ethdev.c | 9 +++++++++ drivers/net/sfc/sfc_port.c | 6 ++++++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/features/sfc_efx.ini b/doc/guides/nics/features/sfc_efx.ini index a845bfc..60ecca0 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] +Speed capabilities = Y Link status = Y Link status event = Y MTU update = Y diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index 36044a0..e2e6c9e 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -85,6 +85,33 @@ sfc_dma_free(const struct sfc_adapter *sa, efsys_mem_t *esmp) memset(esmp, 0, sizeof(*esmp)); } +static uint32_t +sfc_phy_cap_from_link_speeds(uint32_t speeds) +{ + uint32_t phy_caps = 0; + + if (~speeds & ETH_LINK_SPEED_FIXED) { + phy_caps |= (1 << EFX_PHY_CAP_AN); + /* + * If no speeds are specified in the mask, any supported + * may be negotiated + */ + if (speeds == ETH_LINK_SPEED_AUTONEG) + phy_caps |= + (1 << EFX_PHY_CAP_1000FDX) | + (1 << EFX_PHY_CAP_10000FDX) | + (1 << EFX_PHY_CAP_40000FDX); + } + if (speeds & ETH_LINK_SPEED_1G) + phy_caps |= (1 << EFX_PHY_CAP_1000FDX); + if (speeds & ETH_LINK_SPEED_10G) + phy_caps |= (1 << EFX_PHY_CAP_10000FDX); + if (speeds & ETH_LINK_SPEED_40G) + phy_caps |= (1 << EFX_PHY_CAP_40000FDX); + + return phy_caps; +} + /* * Check requested device level configuration. * Receive and transmit configuration is checked in corresponding @@ -96,8 +123,12 @@ sfc_check_conf(struct sfc_adapter *sa) const struct rte_eth_conf *conf = &sa->eth_dev->data->dev_conf; int rc = 0; - if (conf->link_speeds != ETH_LINK_SPEED_AUTONEG) { - sfc_err(sa, "Manual link speed/duplex choice not supported"); + sa->port.phy_adv_cap = + sfc_phy_cap_from_link_speeds(conf->link_speeds) & + sa->port.phy_adv_cap_mask; + if ((sa->port.phy_adv_cap & ~(1 << EFX_PHY_CAP_AN)) == 0) { + sfc_err(sa, "No link speeds from mask %#x are supported", + conf->link_speeds); rc = EINVAL; } @@ -516,6 +547,9 @@ sfc_attach(struct sfc_adapter *sa) if (rc != 0) goto fail_intr_attach; + efx_phy_adv_cap_get(sa->nic, EFX_PHY_CAP_PERM, + &sa->port.phy_adv_cap_mask); + sfc_log_init(sa, "fini nic"); efx_nic_fini(enp); diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index be33464..ff0bc3c 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -123,6 +123,9 @@ struct sfc_txq_info; struct sfc_port { unsigned int lsc_seq; + uint32_t phy_adv_cap_mask; + uint32_t phy_adv_cap; + unsigned int flow_ctrl; boolean_t flow_ctrl_autoneg; size_t pdu; diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 6690755..42c488e 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -53,6 +53,15 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_rx_pktlen = EFX_MAC_PDU_MAX; + /* Autonegotiation may be disabled */ + dev_info->speed_capa = ETH_LINK_SPEED_FIXED; + if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_1000FDX) + dev_info->speed_capa |= ETH_LINK_SPEED_1G; + if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_10000FDX) + dev_info->speed_capa |= ETH_LINK_SPEED_10G; + if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_40000FDX) + dev_info->speed_capa |= ETH_LINK_SPEED_40G; + dev_info->max_rx_queues = sa->rxq_max; dev_info->max_tx_queues = sa->txq_max; diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index ccc0854..1241af7 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -86,6 +86,11 @@ sfc_port_start(struct sfc_adapter *sa) if (rc != 0) goto fail_mac_fcntl_set; + sfc_log_init(sa, "set phy adv caps to %#x", port->phy_adv_cap); + rc = efx_phy_adv_cap_set(sa->nic, port->phy_adv_cap); + if (rc != 0) + goto fail_phy_adv_cap_set; + sfc_log_init(sa, "set MAC PDU %u", (unsigned int)port->pdu); rc = efx_mac_pdu_set(sa->nic, port->pdu); if (rc != 0) @@ -131,6 +136,7 @@ sfc_port_start(struct sfc_adapter *sa) fail_mac_filter_set: fail_mac_addr_set: fail_mac_pdu_set: +fail_phy_adv_cap_set: fail_mac_fcntl_set: efx_port_fini(sa->nic); -- 2.5.5