From: Andrew Rybchenko Date: Thu, 15 Dec 2016 12:50:59 +0000 (+0000) Subject: net/sfc: support link speed and duplex settings X-Git-Tag: spdx-start~4993 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=d23f3a89ab54;p=dpdk.git net/sfc: support link speed and duplex settings Signed-off-by: Andrew Rybchenko Reviewed-by: Andrew Lee Reviewed-by: Robert Stonehouse --- diff --git a/doc/guides/nics/features/sfc_efx.ini b/doc/guides/nics/features/sfc_efx.ini index a845bfc1d1..60ecca0982 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 6b3dc48a42..f884a2193e 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 83c44302a2..c155bc44c3 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -126,6 +126,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 98c26ccaea..7051f4348d 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -52,6 +52,15 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->pci_dev = RTE_DEV_TO_PCI(dev->device); 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 ccc085463e..1241af76cd 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 @@ fail_mac_stats_periodic: 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);