From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-f41.google.com (mail-vk0-f41.google.com [209.85.213.41]) by dpdk.org (Postfix) with ESMTP id 6DB792A5D for ; Mon, 21 Nov 2016 15:47:31 +0100 (CET) Received: by mail-vk0-f41.google.com with SMTP id x186so220246298vkd.1 for ; Mon, 21 Nov 2016 06:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=o5SeKStqCOxBt1lsHh+/f4+8HV3y1dhlU7PtjkZuE74=; b=khskKpQribYnss3QDN5pvLbd1yahVYDflay3rPkr39DJ1o91+KTbt9IpSRDvsvnul8 FrC94J6I9hBANrO0JHT85Z4Bv9teloCcCXkaqRr0ocgNK/7skcrZG5XFEMRC5ER8i36z UjSYLQTHZqIr9AxozO6+T2jAnUwBVx3oc6JAKM/jIJmn6aYwL/i3egu1tqDiDaoVk0ZY 2ixV6uk/FUkuEuJE1klgtX3e1Pz5ZODU+edAxLTB9Atsck4keLnCSgz3APFh5n7s1R5m 1EawXlTM9cNTO/C3kV2UQAxJh1CesaFKnKfyWrsrgNktOSzSRlFEbY2OpnsvnZPBM+Fj suTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=o5SeKStqCOxBt1lsHh+/f4+8HV3y1dhlU7PtjkZuE74=; b=byb7WS/bf2FJjQxU3RhvZRrvIzAmJvLOqzx3yhVxyhQ9yLeEqv8DvL9uzBvdmAuCpc zCt3oBSUJKea6xGmsh9FresSK71+KT21mwgEB3dmUEYAjDUqitlcaJaWrNREWumVsbQz KMROVL3D7UPFtAHAnvWtARKfjqUjw6dmAPmox+tj5nS163s8Bnah3z6nwefCql+YrbWo fxxUbolaOLFgWJgEgJop4XumnRtv0/+/n4j/qHOIYyb2n+Zkd3XGjf+7gFjZLQ0qYaBx 7iNBeCAbIznkYT+7XErmvu4iqc3x2OV4mAYZbJ9PGBeBRQPpaIZKcb80xw9PK7Wv+r/n HUPA== X-Gm-Message-State: AKaTC02vh2kFxdDTQ9vfjt0JzO4rPvr3P9uvTOpJvnVwjNRLLLcEvPi2WJdY7hWmN7hYqPg7VDV6qwH3vuSwSBOO X-Received: by 10.31.49.216 with SMTP id x207mr6701383vkx.82.1479739650839; Mon, 21 Nov 2016 06:47:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.79.145 with HTTP; Mon, 21 Nov 2016 06:47:30 -0800 (PST) In-Reply-To: References: <1479485218-11931-1-git-send-email-alejandro.lucero@netronome.com> From: Alejandro Lucero Date: Mon, 21 Nov 2016 14:47:30 +0000 Message-ID: To: Ferruh Yigit Cc: dev Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v2] nfp: report link speed using hardware 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: Mon, 21 Nov 2016 14:47:31 -0000 On Mon, Nov 21, 2016 at 11:18 AM, Ferruh Yigit wrote: > On 11/18/2016 4:06 PM, Alejandro Lucero wrote: > > Previous reported speed was hardcoded. > > > > Signed-off-by: Alejandro Lucero > > --- > > drivers/net/nfp/nfp_net.c | 28 ++++++++++++++++++++++++++-- > > drivers/net/nfp/nfp_net_ctrl.h | 13 +++++++++++++ > > 2 files changed, 39 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c > > index c6b1587..24f3164 100644 > > --- a/drivers/net/nfp/nfp_net.c > > +++ b/drivers/net/nfp/nfp_net.c > > @@ -816,6 +816,17 @@ static void nfp_net_read_mac(struct nfp_net_hw *hw) > > struct rte_eth_link link, old; > > uint32_t nn_link_status; > > > > + static const uint32_t ls_to_ethtool[] = { > > + [NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED] = > ETH_SPEED_NUM_NONE, > > + [NFP_NET_CFG_STS_LINK_RATE_UNKNOWN] = > ETH_SPEED_NUM_NONE, > > + [NFP_NET_CFG_STS_LINK_RATE_1G] = ETH_SPEED_NUM_1G, > > + [NFP_NET_CFG_STS_LINK_RATE_10G] = > ETH_SPEED_NUM_10G, > > + [NFP_NET_CFG_STS_LINK_RATE_25G] = > ETH_SPEED_NUM_25G, > > + [NFP_NET_CFG_STS_LINK_RATE_40G] = > ETH_SPEED_NUM_40G, > > + [NFP_NET_CFG_STS_LINK_RATE_50G] = > ETH_SPEED_NUM_50G, > > + [NFP_NET_CFG_STS_LINK_RATE_100G] = > ETH_SPEED_NUM_100G, > > + }; > > + > > PMD_DRV_LOG(DEBUG, "Link update\n"); > > > > hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); > > @@ -831,8 +842,21 @@ static void nfp_net_read_mac(struct nfp_net_hw *hw) > > link.link_status = ETH_LINK_UP; > > > > link.link_duplex = ETH_LINK_FULL_DUPLEX; > > - /* Other cards can limit the tx and rx rate per VF */ > > - link.link_speed = ETH_SPEED_NUM_40G; > > + > > + nn_link_status = (nn_link_status >> NFP_NET_CFG_STS_LINK_RATE_SHIFT) > & > > + NFP_NET_CFG_STS_LINK_RATE_MASK; > > + > > + if ((NFD_CFG_MAJOR_VERSION_of(hw->ver) < 4) || > > + ((NFD_CFG_MINOR_VERSION_of(hw->ver) == 4) && > > + (NFD_CFG_MINOR_VERSION_of(hw->ver) == 0))) > > + link.link_speed = ETH_SPEED_NUM_40G; > > For specific firmware version, speed is still hardcoded to 40G, can you > please mention from this and if possible its reason in commit log? > > > + else { > > + if (nn_link_status == NFP_NET_CFG_STS_LINK_RATE_UNKNOWN || > > This check can be redundant, since > ls_to_ethtool[NFP_NET_CFG_STS_LINK_RATE_UNKNOWN] => ETH_SPEED_NUM_NONE > > This is for checking any wrong value from firmware/hardware. > > + nn_link_status >= RTE_DIM(ls_to_ethtool)) > > + link.link_speed = ETH_SPEED_NUM_NONE; > > + else > > + link.link_speed = ls_to_ethtool[nn_link_status]; > > + } > > > > if (old.link_status != link.link_status) { > > nfp_net_dev_atomic_write_link_status(dev, &link); > > diff --git a/drivers/net/nfp/nfp_net_ctrl.h b/drivers/net/nfp/nfp_net_ > ctrl.h > > index fce8251..f9aaba3 100644 > > --- a/drivers/net/nfp/nfp_net_ctrl.h > > +++ b/drivers/net/nfp/nfp_net_ctrl.h > > @@ -157,6 +157,19 @@ > > #define NFP_NET_CFG_VERSION_MINOR(x) (((x) & 0xff) << 0) > > #define NFP_NET_CFG_STS 0x0034 > > #define NFP_NET_CFG_STS_LINK (0x1 << 0) /* Link up or down > */ > > +/* Link rate */ > > +#define NFP_NET_CFG_STS_LINK_RATE_SHIFT 1 > > +#define NFP_NET_CFG_STS_LINK_RATE_MASK 0xF > > +#define NFP_NET_CFG_STS_LINK_RATE \ > > + (NFP_NET_CFG_STS_LINK_RATE_MASK << NFP_NET_CFG_STS_LINK_RATE_ > SHIFT) > > This macro is not used at all, just fyi. > > Thanks. I think I can remove it. > > +#define NFP_NET_CFG_STS_LINK_RATE_UNSUPPORTED 0 > > +#define NFP_NET_CFG_STS_LINK_RATE_UNKNOWN 1 > > +#define NFP_NET_CFG_STS_LINK_RATE_1G 2 > > +#define NFP_NET_CFG_STS_LINK_RATE_10G 3 > > +#define NFP_NET_CFG_STS_LINK_RATE_25G 4 > > +#define NFP_NET_CFG_STS_LINK_RATE_40G 5 > > +#define NFP_NET_CFG_STS_LINK_RATE_50G 6 > > +#define NFP_NET_CFG_STS_LINK_RATE_100G 7 > > #define NFP_NET_CFG_CAP 0x0038 > > #define NFP_NET_CFG_MAX_TXRINGS 0x003c > > #define NFP_NET_CFG_MAX_RXRINGS 0x0040 > > > >