From patchwork Mon Aug 17 12:37:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 1346195 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BVYVH0Bhgz9sTs; Mon, 17 Aug 2020 22:37:58 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1k7eOh-0006Xl-6Z; Mon, 17 Aug 2020 12:37:55 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1k7eOc-0006V3-S5 for kernel-team@lists.ubuntu.com; Mon, 17 Aug 2020 12:37:50 +0000 Received: from mail-qk1-f197.google.com ([209.85.222.197]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1k7eOc-0000g0-FL for kernel-team@lists.ubuntu.com; Mon, 17 Aug 2020 12:37:50 +0000 Received: by mail-qk1-f197.google.com with SMTP id a130so10836683qkg.9 for ; Mon, 17 Aug 2020 05:37:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z9VHeM8Dm7NJeoUgi1IOTENGAVTm38Kx1kIGOiiavYk=; b=Yi1FshpbnQFi4IXo+fHDdwdaVr3TlihgQqOa+NVIeylYUxcU7p9hEgSt0jBmdRLXMi V0kgaKBt06fQ68RobC/fWw4AQ1PeWgH4CjJrPXsACSUnN+F9AURTd5Ho+Kgl+26J1cLj ZkbX3FqJWQcUOa3xHmeXPmQGxdJtZHrFJF9YIEYVYU3oaN4hgMtWc9UY4mEU11H0lp07 KubO9ewtmn8Y8uN3IA7LhoG8JkFwxzfshyaHdH2PfqPOpZb/9GqoRLLoGNh04d2z9rD0 ejiPFLhbG4IsCYJx6bW0vSIDV38pWEfeuJyhooHS6hck0FVe5daNJLoCISKTJ/ApkdtC aCbw== X-Gm-Message-State: AOAM532neFJkRcUBm89+W4u3v+kzKWP9rKg082pLDd7IfSIjc0Cnodtt j4pYfsXQ6P7Iz8G8oinmb+X14H92/DeSQkHyssyWh5ItH/qfUK+ZYODCQaC46X097VSfcI2hSVh 4TmGpPqD17yAUo313UQYP7Pc+7d3M2syFQRy4iC4i/A== X-Received: by 2002:ac8:70c3:: with SMTP id g3mr13416395qtp.164.1597667869023; Mon, 17 Aug 2020 05:37:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWwaHael3jZpXM2YvK3EJe15K7Xv2fMINHdnV9wfKzzUGdpBybDoOlLPx0gb9BmfqJQMCuIA== X-Received: by 2002:ac8:70c3:: with SMTP id g3mr13416383qtp.164.1597667868815; Mon, 17 Aug 2020 05:37:48 -0700 (PDT) Received: from localhost.localdomain (072-189-064-225.res.spectrum.com. [72.189.64.225]) by smtp.gmail.com with ESMTPSA id m15sm20177234qta.6.2020.08.17.05.37.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2020 05:37:48 -0700 (PDT) From: William Breathitt Gray To: kernel-team@lists.ubuntu.com Subject: [BIONIC/linux-azure-4.15][PATCH 2/3] net/mlx5: Expose port speed when possible Date: Mon, 17 Aug 2020 08:37:39 -0400 Message-Id: <20200817123740.6938-6-william.gray@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200817123740.6938-1-william.gray@canonical.com> References: <20200817123740.6938-1-william.gray@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mark Bloch When port speed can't be reported based on ext_eth_proto_capability or eth_proto_capability instead of reporting speed as unknown check if the port's speed can be inferred based on the data_rate_oper field. Signed-off-by: Mark Bloch Signed-off-by: Saeed Mahameed BugLink: https://bugs.launchpad.net/bugs/1876770 (backported from commit c268ca6087f553bfc0e16ffec412b983ffe32fd4) [ vilhelmgray: refactor data_rate_oper check for get_speed_duplex() ] Signed-off-by: William Breathitt Gray --- .../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index 3a1f798fbe8d..071a84f64881 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -707,7 +707,7 @@ int mlx5e_get_max_linkspeed(struct mlx5_core_dev *mdev, u32 *speed) } static void get_speed_duplex(struct net_device *netdev, - u32 eth_proto_oper, + u32 eth_proto_oper, u16 data_rate_oper, struct ethtool_link_ksettings *link_ksettings) { int i; @@ -724,6 +724,12 @@ static void get_speed_duplex(struct net_device *netdev, break; } } + if (!speed) { + if (data_rate_oper) + speed = 100 * data_rate_oper; + else + speed = SPEED_UNKNOWN; + } out: link_ksettings->base.speed = speed; link_ksettings->base.duplex = duplex; @@ -808,6 +814,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev, struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5_core_dev *mdev = priv->mdev; u32 out[MLX5_ST_SZ_DW(ptys_reg)] = {0}; + u16 data_rate_oper; u32 rx_pause = 0; u32 tx_pause = 0; u32 eth_proto_cap; @@ -833,6 +840,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev, an_disable_admin = MLX5_GET(ptys_reg, out, an_disable_admin); an_status = MLX5_GET(ptys_reg, out, an_status); connector_type = MLX5_GET(ptys_reg, out, connector_type); + data_rate_oper = MLX5_GET(ptys_reg, out, data_rate_oper); mlx5_query_port_pause(mdev, &rx_pause, &tx_pause); @@ -841,7 +849,8 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev, get_supported(eth_proto_cap, link_ksettings); get_advertising(eth_proto_admin, tx_pause, rx_pause, link_ksettings); - get_speed_duplex(netdev, eth_proto_oper, link_ksettings); + get_speed_duplex(netdev, eth_proto_oper, data_rate_oper, + link_ksettings); eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap;