From patchwork Wed Apr 14 03:44:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 421608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 686C9C433B4 for ; Wed, 14 Apr 2021 03:45:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44E3061222 for ; Wed, 14 Apr 2021 03:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347030AbhDNDp2 (ORCPT ); Tue, 13 Apr 2021 23:45:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:34368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346944AbhDNDpX (ORCPT ); Tue, 13 Apr 2021 23:45:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B71F161222; Wed, 14 Apr 2021 03:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618371903; bh=h3JqAuovJa5qISADuaVsDMb+HQYlp1RC4S+FpkmkBqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rYTXqIqsOnHC3+bhWbAxMnSH1CWv7eFVFp+vn7Cv/Tho/8P9VUZ+e9xB/a1ukeS40 yfKYPD8SNwEj1lushVhnNCFHqGWaOr97pTJzEw13Dn47oWDdDwkZho87cnFCm+oK3o +k0YJfSszRtg82wJc+3sSJsFgQxlT+yy3++Ni1SesV7OclCXIW4dNEwMdsxfU2VaGi wtV/QgYAEKOSNAXGhmXObRIjeSQ8eNf2QumiFz1C34ZZBYQyQCcCvO/Q9oc9LOAJet XLOWSIEyCyEyfZEtgeYPlqOklIIKkhP0p6JRTMeZFCfUkkvobTd4JgBrEDIU/we+f2 NH71NE5UkQ1ww== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, michael.chan@broadcom.com, saeedm@nvidia.com, leon@kernel.org, ecree.xilinx@gmail.com, habetsm.xilinx@gmail.com, f.fainelli@gmail.com, andrew@lunn.ch, mkubecek@suse.cz, ariela@nvidia.com, Jakub Kicinski Subject: [PATCH net-next 2/6] ethtool: fec_prepare_data() - jump to error handling Date: Tue, 13 Apr 2021 20:44:50 -0700 Message-Id: <20210414034454.1970967-3-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210414034454.1970967-1-kuba@kernel.org> References: <20210414034454.1970967-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Refactor fec_prepare_data() a little bit to skip the body of the function and exit on error. Currently the code depends on the fact that we only have one call which may fail between ethnl_ops_begin() and ethnl_ops_complete() and simply saves the error code. This will get hairy with the stats also being queried. No functional changes. Signed-off-by: Jakub Kicinski --- net/ethtool/fec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/ethtool/fec.c b/net/ethtool/fec.c index 31454b9188bd..3e7d091ee7aa 100644 --- a/net/ethtool/fec.c +++ b/net/ethtool/fec.c @@ -80,9 +80,8 @@ static int fec_prepare_data(const struct ethnl_req_info *req_base, if (ret < 0) return ret; ret = dev->ethtool_ops->get_fecparam(dev, &fec); - ethnl_ops_complete(dev); if (ret) - return ret; + goto out_complete; WARN_ON_ONCE(fec.reserved); @@ -98,7 +97,9 @@ static int fec_prepare_data(const struct ethnl_req_info *req_base, if (data->active_fec == __ETHTOOL_LINK_MODE_MASK_NBITS) data->active_fec = 0; - return 0; +out_complete: + ethnl_ops_complete(dev); + return ret; } static int fec_reply_size(const struct ethnl_req_info *req_base, From patchwork Wed Apr 14 03:44:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 421607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88A5DC433B4 for ; Wed, 14 Apr 2021 03:45:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C2F861154 for ; Wed, 14 Apr 2021 03:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347092AbhDNDpg (ORCPT ); Tue, 13 Apr 2021 23:45:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:34418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346963AbhDNDpZ (ORCPT ); Tue, 13 Apr 2021 23:45:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E44C3613C4; Wed, 14 Apr 2021 03:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618371904; bh=Tpta5X+xuSC6ObVpocfefy1XFdyBOdjLqcRTiOU08X4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QewgppHXrb1s4D+JH3eXF62JKWUOAV6BFZZfoBpHDs15i73vdDcPofbNfzJBknVjT 1sBtPPnHdv4KvjOwgEKPIDHFKc6fhCZXv3CqV9woDV3jXqqNSPyfmvmUzDFXPZKR+5 YmAGxteYeTTFUcanAIDlTV0ufCb6F+sltW51E33YMPmXfeGHNEO75VY7Rec6P3xDrA tWFgqzmEbBGNVXDjqWvEEkD8k36PzjyDw9t5kyT1e5ckpKUvn40s5pGJEegzqIGJ9P e8BU3fCYgiI1avI9boEbvJZEdPxKqlpfpDbIMbprIbb3wL2iXDNZhavEw/GTI90WsP uhExcCrebAQWQ== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, michael.chan@broadcom.com, saeedm@nvidia.com, leon@kernel.org, ecree.xilinx@gmail.com, habetsm.xilinx@gmail.com, f.fainelli@gmail.com, andrew@lunn.ch, mkubecek@suse.cz, ariela@nvidia.com, Jakub Kicinski Subject: [PATCH net-next 4/6] bnxt: implement ethtool::get_fec_stats Date: Tue, 13 Apr 2021 20:44:52 -0700 Message-Id: <20210414034454.1970967-5-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210414034454.1970967-1-kuba@kernel.org> References: <20210414034454.1970967-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Report corrected bits. Signed-off-by: Jakub Kicinski Reviewed-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 2f8b193a772d..7b90357daba1 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1930,6 +1930,20 @@ static int bnxt_get_fecparam(struct net_device *dev, return 0; } +static void bnxt_get_fec_stats(struct net_device *dev, + struct ethtool_fec_stats *fec_stats) +{ + struct bnxt *bp = netdev_priv(dev); + u64 *rx; + + if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) + return; + + rx = bp->rx_port_stats_ext.sw_stats; + fec_stats->corrected_bits.total = + *(rx + BNXT_RX_STATS_EXT_OFFSET(rx_corrected_bits)); +} + static u32 bnxt_ethtool_forced_fec_to_fw(struct bnxt_link_info *link_info, u32 fec) { @@ -3991,6 +4005,7 @@ const struct ethtool_ops bnxt_ethtool_ops = { ETHTOOL_COALESCE_USE_ADAPTIVE_RX, .get_link_ksettings = bnxt_get_link_ksettings, .set_link_ksettings = bnxt_set_link_ksettings, + .get_fec_stats = bnxt_get_fec_stats, .get_fecparam = bnxt_get_fecparam, .set_fecparam = bnxt_set_fecparam, .get_pause_stats = bnxt_get_pause_stats, From patchwork Wed Apr 14 03:44:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 421606 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23409C433ED for ; Wed, 14 Apr 2021 03:45:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0871F613BD for ; Wed, 14 Apr 2021 03:45:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347059AbhDNDpk (ORCPT ); Tue, 13 Apr 2021 23:45:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:34452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346987AbhDNDp0 (ORCPT ); Tue, 13 Apr 2021 23:45:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 050E6613CC; Wed, 14 Apr 2021 03:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618371905; bh=8A5lZhz4VPC/D5uhVkzzP2eEv/lpDgk9bG0EtXRY1cM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uPQf36vpM+sWQCokfV2brAVv62RA53SvmURPBVvmy1aDJYalV+Yg1ikiq/+C+M/8S /uWTFJyym8UM36Vb1ox1F7klJNrQFHN1JVYmEsCwHLXlQY4JlOIS8l4WSSYsxR0okv sY1ExgPIOObgqh3UXqcne4AEox1AGU4G6BLmF7Opb/nbFc64Ul/7Yi+qjlMqUs4nz6 KFE4la89EZCD1AaTgTQm9G9cuEpBnt4eIGwMwrBlYMZYsIBMtaK8cXaNNp/Kby0JlN HQgXE/8QQWv2xxAyd6vBm8iyehZ7bZkoBUBISgEZ/75A6H5A83LsrS+dTZbdIgoKOK apgWbbIc4tG8g== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, michael.chan@broadcom.com, saeedm@nvidia.com, leon@kernel.org, ecree.xilinx@gmail.com, habetsm.xilinx@gmail.com, f.fainelli@gmail.com, andrew@lunn.ch, mkubecek@suse.cz, ariela@nvidia.com, Jakub Kicinski Subject: [PATCH net-next 6/6] mlx5: implement ethtool::get_fec_stats Date: Tue, 13 Apr 2021 20:44:54 -0700 Message-Id: <20210414034454.1970967-7-kuba@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210414034454.1970967-1-kuba@kernel.org> References: <20210414034454.1970967-1-kuba@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Report corrected bits. Signed-off-by: Jakub Kicinski Acked-by: Saeed Mahameed --- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 9 ++++++ .../ethernet/mellanox/mlx5/core/en_stats.c | 28 +++++++++++++++++-- .../ethernet/mellanox/mlx5/core/en_stats.h | 2 ++ 3 files changed, 37 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 c8057a44d5ab..f17690cbeeea 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -1602,6 +1602,14 @@ static int mlx5e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) return mlx5_set_port_wol(mdev, mlx5_wol_mode); } +static void mlx5e_get_fec_stats(struct net_device *netdev, + struct ethtool_fec_stats *fec_stats) +{ + struct mlx5e_priv *priv = netdev_priv(netdev); + + mlx5e_stats_fec_get(priv, fec_stats); +} + static int mlx5e_get_fecparam(struct net_device *netdev, struct ethtool_fecparam *fecparam) { @@ -2209,6 +2217,7 @@ const struct ethtool_ops mlx5e_ethtool_ops = { .self_test = mlx5e_self_test, .get_msglevel = mlx5e_get_msglevel, .set_msglevel = mlx5e_set_msglevel, + .get_fec_stats = mlx5e_get_fec_stats, .get_fecparam = mlx5e_get_fecparam, .set_fecparam = mlx5e_set_fecparam, }; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c index ae0570ea08bf..aca096cc2c1c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c @@ -768,10 +768,10 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(802_3) mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0, 0); } -#define MLX5E_READ_CTR64_BE_F(ptr, c) \ +#define MLX5E_READ_CTR64_BE_F(ptr, set, c) \ be64_to_cpu(*(__be64 *)((char *)ptr + \ MLX5_BYTE_OFF(ppcnt_reg, \ - counter_set.eth_802_3_cntrs_grp_data_layout.c##_high))) + counter_set.set.c##_high))) void mlx5e_stats_pause_get(struct mlx5e_priv *priv, struct ethtool_pause_stats *pause_stats) @@ -791,9 +791,11 @@ void mlx5e_stats_pause_get(struct mlx5e_priv *priv, pause_stats->tx_pause_frames = MLX5E_READ_CTR64_BE_F(ppcnt_ieee_802_3, + eth_802_3_cntrs_grp_data_layout, a_pause_mac_ctrl_frames_transmitted); pause_stats->rx_pause_frames = MLX5E_READ_CTR64_BE_F(ppcnt_ieee_802_3, + eth_802_3_cntrs_grp_data_layout, a_pause_mac_ctrl_frames_received); } @@ -1015,6 +1017,28 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(phy) mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0, 0); } +void mlx5e_stats_fec_get(struct mlx5e_priv *priv, + struct ethtool_fec_stats *fec_stats) +{ + u32 ppcnt_phy_statistical[MLX5_ST_SZ_DW(ppcnt_reg)]; + struct mlx5_core_dev *mdev = priv->mdev; + u32 in[MLX5_ST_SZ_DW(ppcnt_reg)] = {0}; + int sz = MLX5_ST_SZ_BYTES(ppcnt_reg); + + if (!MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group)) + return; + + MLX5_SET(ppcnt_reg, in, local_port, 1); + MLX5_SET(ppcnt_reg, in, grp, MLX5_PHYSICAL_LAYER_STATISTICAL_GROUP); + mlx5_core_access_reg(mdev, in, sz, ppcnt_phy_statistical, + sz, MLX5_REG_PPCNT, 0, 0); + + fec_stats->corrected_bits.total = + MLX5E_READ_CTR64_BE_F(ppcnt_phy_statistical, + phys_layer_statistical_cntrs, + phy_corrected_bits); +} + #define PPORT_ETH_EXT_OFF(c) \ MLX5_BYTE_OFF(ppcnt_reg, \ counter_set.eth_extended_cntrs_grp_data_layout.c##_high) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h index 21d3b8747f93..3f0789e51eed 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h @@ -114,6 +114,8 @@ void mlx5e_stats_update_ndo_stats(struct mlx5e_priv *priv); void mlx5e_stats_pause_get(struct mlx5e_priv *priv, struct ethtool_pause_stats *pause_stats); +void mlx5e_stats_fec_get(struct mlx5e_priv *priv, + struct ethtool_fec_stats *fec_stats); /* Concrete NIC Stats */