From patchwork Sun Jun 7 14:59:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 208416 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 9C225C433DF for ; Sun, 7 Jun 2020 15:01:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 754EB20723 for ; Sun, 7 Jun 2020 15:01:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="U+Xf4a7g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726815AbgFGPAi (ORCPT ); Sun, 7 Jun 2020 11:00:38 -0400 Received: from mail-am6eur05on2089.outbound.protection.outlook.com ([40.107.22.89]:48904 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726595AbgFGPAd (ORCPT ); Sun, 7 Jun 2020 11:00:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZV3zjJNI+z+SHfizKNI2WYEKTQje1r/0Y+16SFTXv2xyNhiSf1YYOydfbiA2qC49qSkIg43NrCDV1oHdWCPkauCnPnI07CdXCHsHUtfxN9fl30Z7dtH1JY2n0D98ZVEmfHNIibfddySghCwmPLshZRuIMwohSt8ZqmCESJ3lOUz/oglF+ntNB5IabkjuEmAXFS7FW2sOiG3LJcdzSP7pyyhzdc1FFn1RhB22Q5RyQKotVFZlXMy+9ewgQ1jRuahhFMyCMxiH+E4gtsXmWoRCMjQYaqA65QhvGqff86n5HCOIq48c5/qj+zJrllISTRcSGt2EOgaLlQlgmdUC5qiBmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F0DJQrVs2r+2/gCHipL4+ugNK28EVx1ilcr/c/RLp08=; b=Rjqxi7XfZpgMpEV3F6I/3uUwcex9ZjM08k3IWiIo6635tIXmh3Eidpqw39QWsuQs7VUDZOYInNMNNq4C7YVNuLRta/m866c6FEth2EatD+opkJZgJ7PSLkP0+JJDpVaEAE8ePmRVCyu/l3OVSt6+DDPCtqyiP+xu5UKlPJr4UZd5P6CTdSALJtn16OtVHmRq9IW4nGRvaE/QLEJV4SI9hopgoariqnEeFxN2dIFkcbPJFJNp0emF3MOcvVQZaemRh3GvdCnPnqD/9xuWpJp9psZYwAKF+ey4QN2aekpj3Zr0PSbkM6YmYFXpcvyrW+iKfcjoTIVoqcu03s2RJ8OX5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F0DJQrVs2r+2/gCHipL4+ugNK28EVx1ilcr/c/RLp08=; b=U+Xf4a7gnxniXFhhmC0CWjJVZqkGrsJD17n3BeYsyt80l0+QxTi8Kj7bythO7g6+xtY5AIfX8bMJSBb1zCJZkuuyAKcEOkZ+d3T1U+1AaI6G4kdZLvOoeoO8R+Sb/jRFTpDG8gGKmK/bvDNp3Q5Ghu7XK9QM49vcgESzRf6rI1E= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR0502MB3826.eurprd05.prod.outlook.com (2603:10a6:208:1b::25) by AM0PR0502MB4003.eurprd05.prod.outlook.com (2603:10a6:208:2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.23; Sun, 7 Jun 2020 15:00:15 +0000 Received: from AM0PR0502MB3826.eurprd05.prod.outlook.com ([fe80::2dae:c2a2:c26a:f5b]) by AM0PR0502MB3826.eurprd05.prod.outlook.com ([fe80::2dae:c2a2:c26a:f5b%7]) with mapi id 15.20.3066.023; Sun, 7 Jun 2020 15:00:15 +0000 From: Amit Cohen To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, corbet@lwn.net, jiri@mellanox.com, idosch@mellanox.com, shuah@kernel.org, mkubecek@suse.cz, gustavo@embeddedor.com, amitc@mellanox.com, cforno12@linux.vnet.ibm.com, andrew@lunn.ch, f.fainelli@gmail.com, linux@rempel-privat.de, alexandru.ardelean@analog.com, ayal@mellanox.com, petrm@mellanox.com, mlxsw@mellanox.com, liuhangbin@gmail.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [RFC PATCH net-next 04/10] ethtool: Add link extended state Date: Sun, 7 Jun 2020 17:59:39 +0300 Message-Id: <20200607145945.30559-5-amitc@mellanox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200607145945.30559-1-amitc@mellanox.com> References: <20200607145945.30559-1-amitc@mellanox.com> X-ClientProxiedBy: AM0PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::25) To AM0PR0502MB3826.eurprd05.prod.outlook.com (2603:10a6:208:1b::25) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from dev-r-vrt-155.mtr.labs.mlnx (37.142.13.130) by AM0PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Sun, 7 Jun 2020 15:00:13 +0000 X-Mailer: git-send-email 2.20.1 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9594f15a-09cb-408c-a27d-08d80af37c63 X-MS-TrafficTypeDiagnostic: AM0PR0502MB4003: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 04270EF89C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cpxS632k45uRBcf+uwIZwVkdrjIUFqLs7PNemH6+YXtmxTXHuLR3sxy/isApaAqdS4dUJVSCLzzx7tG+H4UBibZ5Bx9sLxgbN0qD5vG4ZGhOQWIxfx5/BRoUfMR8OlJ9tqEFikyN5PI4qWYxjS3r0BhSQQ1miNxM7TAQg6byLd3t5YKkGPRrEsOB9Hb++L+1ZBmkkJlHEqIWA3u96ESzWsPF8Dsgrf/TDlmFol6lOIu+qNjFvW7rHQr7Asq+4Wh7SyTzS8PxSeUbXenpinZlJ+8ijDmrQh9nZu+iDbzlRES0FFcW9TRMXsgiVw3ucJCOjZIqoDHnWqGxaDj7Nbz+BA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR0502MB3826.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(376002)(366004)(346002)(136003)(39860400002)(66476007)(66946007)(66556008)(1076003)(186003)(8936002)(16526019)(26005)(52116002)(478600001)(6506007)(36756003)(2906002)(6666004)(7416002)(5660300002)(8676002)(4326008)(83380400001)(6486002)(316002)(86362001)(6916009)(2616005)(956004)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ENh9MsLx3G8ToEMtFPBSqzGnqi+GaB5UxDM3/2rjavEi8WS+URsSbZhGXCzkVWfhQic1dCnGlQECOz8ubmigMiC0RvUVGX8E8VihciCDuwY1n6dQ6xgEidiuZVIPLFWW9wM1g8JfhYi7uTmlWjManQbubPs89goXU0KRkOb+5hASsh16y3hCej1zPsDiwg3Am2+3hl3ExVbf3Vk6eykMkDjrh6+8FvQ01McxBnoulJQh0wamk37T/SyjpPugMR+X1OGVDXx4DtG6v2uRvFQn6/dB2RUcwqHuIvTaT7ibbVerNqkXHaiIa/9zh/DnLQIXiiM7cQXcpAjsOn7QhnnleV929s5dFXRgpahbkKw374mi8xuhdQih2+2496omUDYDUOnHRuakFtQPBPRIMfUQqqvfWjnXsAm2I5wcC7MnMWbZzUSUtpUxKgw6orXQt7xzN/olGrv1d1lOjzQ42axxNbVl3f8cyBz0B/2qprH8Pvo= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9594f15a-09cb-408c-a27d-08d80af37c63 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2020 15:00:15.5578 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sg7P1/6qeVUosc8kdVhPOLwlqDbTZHjOM/y6WuojuYKN6A3x4ehDfJQtiN+fmiJrNN8t+0/YNN7TAxk8pTDfaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB4003 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently, drivers can only tell whether the link is up/down using LINKSTATE_GET, but no additional information is given. Add attributes to LINKSTATE_GET command in order to allow drivers to expose the user more information in addition to link state to ease the debug process, for example, reason for link down state. Extended state consists of two attributes - ext_state and ext_substate. The idea is to avoid 'vendor specific' states in order to prevent drivers to use specific ext_state that can be in the future common ext_state. The substates allows drivers to add more information to the common ext_state. For example, vendor can expose 'Autoneg failure' as ext_state and add 'No partner detected during force mode' as ext_substate. If a driver cannot pinpoint the extended state with the substate accuracy, it is free to expose only the extended state and omit the substate attribute. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Reviewed-by: Jiri Pirko --- include/linux/ethtool.h | 22 +++++++++ include/uapi/linux/ethtool.h | 70 ++++++++++++++++++++++++++++ include/uapi/linux/ethtool_netlink.h | 2 + net/ethtool/linkstate.c | 40 ++++++++++++++++ 4 files changed, 134 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index a23b26eab479..48ec542f4504 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -86,6 +86,22 @@ struct net_device; u32 ethtool_op_get_link(struct net_device *dev); int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti); + +/** + * struct ethtool_ext_state_info - link extended state and substate. + */ +struct ethtool_ext_state_info { + enum ethtool_ext_state ext_state; + union { + enum ethtool_ext_substate_autoneg autoneg; + enum ethtool_ext_substate_link_training link_training; + enum ethtool_ext_substate_link_logical_mismatch link_logical_mismatch; + enum ethtool_ext_substate_bad_signal_integrity bad_signal_integrity; + enum ethtool_ext_substate_cable_issue cable_issue; + int __ext_substate; + }; +}; + /** * ethtool_rxfh_indir_default - get default value for RX flow hash indirection * @index: Index in RX flow hash indirection table @@ -245,6 +261,10 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, * @get_link: Report whether physical link is up. Will only be called if * the netdev is up. Should usually be set to ethtool_op_get_link(), * which uses netif_carrier_ok(). + * @get_ext_state: Report link extended state. Should set ext_state and + * ext_substate (ext_substate of 0 means ext_substate is unknown, + * do not attach ext_substate attribute to netlink message). If not + * implemented, ext_state and ext_substate will not be sent to userspace. * @get_eeprom: Read data from the device EEPROM. * Should fill in the magic field. Don't need to check len for zero * or wraparound. Fill in the data argument with the eeprom values @@ -384,6 +404,8 @@ struct ethtool_ops { void (*set_msglevel)(struct net_device *, u32); int (*nway_reset)(struct net_device *); u32 (*get_link)(struct net_device *); + int (*get_ext_state)(struct net_device *, + struct ethtool_ext_state_info *); int (*get_eeprom_len)(struct net_device *); int (*get_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *); diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index f4662b3a9e1e..830fa0d6aebe 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -579,6 +579,76 @@ struct ethtool_pauseparam { __u32 tx_pause; }; +/** + * enum ethtool_ext_state - link extended state + */ +enum ethtool_ext_state { + ETHTOOL_EXT_STATE_AUTONEG_FAILURE, + ETHTOOL_EXT_STATE_LINK_TRAINING_FAILURE, + ETHTOOL_EXT_STATE_LINK_LOGICAL_MISMATCH, + ETHTOOL_EXT_STATE_BAD_SIGNAL_INTEGRITY, + ETHTOOL_EXT_STATE_NO_CABLE, + ETHTOOL_EXT_STATE_CABLE_ISSUE, + ETHTOOL_EXT_STATE_EEPROM_ISSUE, + ETHTOOL_EXT_STATE_CALIBRATION_FAILURE, + ETHTOOL_EXT_STATE_POWER_BUDGET_EXCEEDED, + ETHTOOL_EXT_STATE_OVERHEAT, +}; + +/** + * enum ethtool_ext_substate_autoneg - more information in addition to + * ETHTOOL_EXT_STATE_AUTONEG_FAILURE. + */ +enum ethtool_ext_substate_autoneg { + ETHTOOL_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED = 1, + ETHTOOL_EXT_SUBSTATE_AN_ACK_NOT_RECEIVED, + ETHTOOL_EXT_SUBSTATE_AN_NEXT_PAGE_EXCHANGE_FAILED, + ETHTOOL_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED_FORCE_MODE, + ETHTOOL_EXT_SUBSTATE_AN_FEC_MISMATCH_DURING_OVERRIDE, + ETHTOOL_EXT_SUBSTATE_AN_NO_HCD, +}; + +/** + * enum ethtool_ext_substate_link_training - more information in addition to + * ETHTOOL_EXT_STATE_LINK_TRAINING_FAILURE. + */ +enum ethtool_ext_substate_link_training { + ETHTOOL_EXT_SUBSTATE_LT_KR_FRAME_LOCK_NOT_ACQUIRED = 1, + ETHTOOL_EXT_SUBSTATE_LT_KR_LINK_INHIBIT_TIMEOUT, + ETHTOOL_EXT_SUBSTATE_LT_KR_LINK_PARTNER_DID_NOT_SET_RECEIVER_READY, + ETHTOOL_EXT_SUBSTATE_LT_REMOTE_FAULT, +}; + +/** + * enum ethtool_ext_substate_logical_mismatch - more information in addition + * to ETHTOOL_EXT_STATE_LINK_LOGICAL_MISMATCH. + */ +enum ethtool_ext_substate_link_logical_mismatch { + ETHTOOL_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_BLOCK_LOCK = 1, + ETHTOOL_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_AM_LOCK, + ETHTOOL_EXT_SUBSTATE_LLM_PCS_DID_NOT_GET_ALIGN_STATUS, + ETHTOOL_EXT_SUBSTATE_LLM_FC_FEC_IS_NOT_LOCKED, + ETHTOOL_EXT_SUBSTATE_LLM_RS_FEC_IS_NOT_LOCKED, +}; + +/** + * enum ethtool_ext_substate_bad_signal_integrity - more information in + * addition to ETHTOOL_EXT_STATE_BAD_SIGNAL_INTEGRITY. + */ +enum ethtool_ext_substate_bad_signal_integrity { + ETHTOOL_EXT_SUBSTATE_BSI_LARGE_NUMBER_OF_PHYSICAL_ERRORS = 1, + ETHTOOL_EXT_SUBSTATE_BSI_UNSUPPORTED_RATE, +}; + +/** + * enum ethtool_ext_substate_cable_issue - more information in + * addition to ETHTOOL_EXT_STATE_CABLE_ISSUE. + */ +enum ethtool_ext_substate_cable_issue { + ETHTOOL_EXT_SUBSTATE_UNSUPPORTED_CABLE = 1, + ETHTOOL_EXT_SUBSTATE_SHORTED_CABLE, +}; + #define ETH_GSTRING_LEN 32 /** diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index e6f109b76c9a..1de8b77bedff 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -234,6 +234,8 @@ enum { ETHTOOL_A_LINKSTATE_LINK, /* u8 */ ETHTOOL_A_LINKSTATE_SQI, /* u32 */ ETHTOOL_A_LINKSTATE_SQI_MAX, /* u32 */ + ETHTOOL_A_LINKSTATE_EXT_STATE, /* u8 */ + ETHTOOL_A_LINKSTATE_EXT_SUBSTATE, /* u8 */ /* add new constants above here */ __ETHTOOL_A_LINKSTATE_CNT, diff --git a/net/ethtool/linkstate.c b/net/ethtool/linkstate.c index 7f47ba89054e..0f3a15fe9919 100644 --- a/net/ethtool/linkstate.c +++ b/net/ethtool/linkstate.c @@ -13,6 +13,8 @@ struct linkstate_reply_data { int link; int sqi; int sqi_max; + bool ext_state_provided; + struct ethtool_ext_state_info ethtool_ext_state_info; }; #define LINKSTATE_REPDATA(__reply_base) \ @@ -25,6 +27,8 @@ linkstate_get_policy[ETHTOOL_A_LINKSTATE_MAX + 1] = { [ETHTOOL_A_LINKSTATE_LINK] = { .type = NLA_REJECT }, [ETHTOOL_A_LINKSTATE_SQI] = { .type = NLA_REJECT }, [ETHTOOL_A_LINKSTATE_SQI_MAX] = { .type = NLA_REJECT }, + [ETHTOOL_A_LINKSTATE_EXT_STATE] = { .type = NLA_REJECT }, + [ETHTOOL_A_LINKSTATE_EXT_SUBSTATE] = { .type = NLA_REJECT }, }; static int linkstate_get_sqi(struct net_device *dev) @@ -61,6 +65,23 @@ static int linkstate_get_sqi_max(struct net_device *dev) mutex_unlock(&phydev->lock); return ret; +}; + +static void linkstate_get_ext_state(struct net_device *dev, + struct linkstate_reply_data *data) +{ + int err; + + if (!dev->ethtool_ops->get_ext_state) + return; + + err = dev->ethtool_ops->get_ext_state(dev, &data->ethtool_ext_state_info); + if (err) { + data->ext_state_provided = false; + return; + } + + data->ext_state_provided = true; } static int linkstate_prepare_data(const struct ethnl_req_info *req_base, @@ -88,6 +109,8 @@ static int linkstate_prepare_data(const struct ethnl_req_info *req_base, data->sqi_max = ret; + linkstate_get_ext_state(dev, data); + ethnl_ops_complete(dev); return 0; @@ -108,6 +131,12 @@ static int linkstate_reply_size(const struct ethnl_req_info *req_base, if (data->sqi_max != -EOPNOTSUPP) len += nla_total_size(sizeof(u32)); + if (data->ext_state_provided) + len += sizeof(u8); /* LINKSTATE_EXT_STATE */ + + if (data->ethtool_ext_state_info.__ext_substate) + len += sizeof(u8); /* LINKSTATE_EXT_SUBSTATE */ + return len; } @@ -129,6 +158,17 @@ static int linkstate_fill_reply(struct sk_buff *skb, nla_put_u32(skb, ETHTOOL_A_LINKSTATE_SQI_MAX, data->sqi_max)) return -EMSGSIZE; + if (data->ext_state_provided) { + if (nla_put_u8(skb, ETHTOOL_A_LINKSTATE_EXT_STATE, + data->ethtool_ext_state_info.ext_state)) + return -EMSGSIZE; + + if (data->ethtool_ext_state_info.__ext_substate && + nla_put_u8(skb, ETHTOOL_A_LINKSTATE_EXT_SUBSTATE, + data->ethtool_ext_state_info.__ext_substate)) + return -EMSGSIZE; + } + return 0; } From patchwork Sun Jun 7 14:59:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 208417 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 21DBAC433E0 for ; Sun, 7 Jun 2020 15:01:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E4F892067B for ; Sun, 7 Jun 2020 15:01:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="V+ZtD8tf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbgFGPBT (ORCPT ); Sun, 7 Jun 2020 11:01:19 -0400 Received: from mail-eopbgr140053.outbound.protection.outlook.com ([40.107.14.53]:5605 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726595AbgFGPAo (ORCPT ); Sun, 7 Jun 2020 11:00:44 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Id1+p2ZPbgB6/xGNMnsxAqRlcRlfn81NYLNxbkDuyUFK/xW/KcGnxqWF+EJo8IwNftJLTNnMI9c2Y8UPUmBnJRgKGrtZeR41VZvGr1BFat4MfgOkFQNdeVKTfr8qnM63dSqBDEg+4QgTMFeItwOonaBSDClWk+Av5eNR6s97sjuTotCLQqetOvy9bIMgh2L2oazKtK9CQamM70f9d59m5lIZsjJ1+CWXOh1Ue45FnQNAWjc1j01Ob01vrnsLOJDRfwRQM9xlqM+Uoc9yKvgcfEOz7PRwBZkF2ClZy70kersULkkHmes6kq2xj8j1oRtv6JUCiYK+GUmsQTPLXgIsiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MgRRxQ+O0Z2SZMU9eeAAdcWzucLsoqyMAt4nVQ8kTlE=; b=n9Ccl4k02Y+rQ7RIxF6e9ivE48aONSwynM/t6hvIXGypAWmn/40qoGfPnUzl+RG3nto1a/e1KuaQ3yYzETmWU6xj1UrXJ5cRNiGZBuqp1V+OJHX6oJm09D4j/FzHQtG7zzdmP/cssUjxkFaXZVus30GgO66tcXmgevrr6DjzReGinWhOdVPSmgBJRVd0/kk6hPWRfjY5Qs5fvWpeZNEnasgtKHsp+/zihE1TNaIEL0TgLAAgGbTDEDpuZvT35nL1crOgPph5MNZLQXvS+vz2n3AvD8GIyAW02q1aBeFdPAzNvUl0HxBeZhujX9Cp+h0F2wFYQDfEcoO7IHOvR4bTkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MgRRxQ+O0Z2SZMU9eeAAdcWzucLsoqyMAt4nVQ8kTlE=; b=V+ZtD8tfa0DZP7LOWbJOio1DTT7ZrNQRNmhQLvgxPrP3DbTEA2rSW/rDZbP4xc0DXUjJJQwA7qf4JNXyZhkcGebiRRy0ZuGxTx8NnysOCX6g1ep1LKVEHPF+bez/SDqwlz+0h+pORUiupHHi1AhhO/C8ADgwRxlh4VaRx00D+Og= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR0502MB3826.eurprd05.prod.outlook.com (2603:10a6:208:1b::25) by AM0PR0502MB4003.eurprd05.prod.outlook.com (2603:10a6:208:2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.23; Sun, 7 Jun 2020 15:00:20 +0000 Received: from AM0PR0502MB3826.eurprd05.prod.outlook.com ([fe80::2dae:c2a2:c26a:f5b]) by AM0PR0502MB3826.eurprd05.prod.outlook.com ([fe80::2dae:c2a2:c26a:f5b%7]) with mapi id 15.20.3066.023; Sun, 7 Jun 2020 15:00:20 +0000 From: Amit Cohen To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, corbet@lwn.net, jiri@mellanox.com, idosch@mellanox.com, shuah@kernel.org, mkubecek@suse.cz, gustavo@embeddedor.com, amitc@mellanox.com, cforno12@linux.vnet.ibm.com, andrew@lunn.ch, f.fainelli@gmail.com, linux@rempel-privat.de, alexandru.ardelean@analog.com, ayal@mellanox.com, petrm@mellanox.com, mlxsw@mellanox.com, liuhangbin@gmail.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [RFC PATCH net-next 06/10] mlxsw: reg: Port Diagnostics Database Register Date: Sun, 7 Jun 2020 17:59:41 +0300 Message-Id: <20200607145945.30559-7-amitc@mellanox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200607145945.30559-1-amitc@mellanox.com> References: <20200607145945.30559-1-amitc@mellanox.com> X-ClientProxiedBy: AM0PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::25) To AM0PR0502MB3826.eurprd05.prod.outlook.com (2603:10a6:208:1b::25) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from dev-r-vrt-155.mtr.labs.mlnx (37.142.13.130) by AM0PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Sun, 7 Jun 2020 15:00:18 +0000 X-Mailer: git-send-email 2.20.1 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 42992024-919a-43dc-e515-08d80af37f2a X-MS-TrafficTypeDiagnostic: AM0PR0502MB4003: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 04270EF89C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nEJTGRLjtrwdX1aagqckzbsCFAC4can4SvjyyX5lD9pBeIHJP726/RKpKidYQX3ObUYoWcgKBPBG4nj6H1cc/Huu3Xb/1N+7V+aB/MdMG96rdz278n9RT/kfTa3QtygP540ODf22jcQ6D17RnIln0dYGnRotVCrX20nSbD3TtZAQqONd2sXQ4r+SEc9fvcMZ0tE1MBeSKXbChLq9BrWGg5J8PUQhHoLttPH2s45WpCrAwMPf88RUvYGuh2oZ4ix/LdPml6IbKTn8Nh1SG6qaHr+m/Bl+Zb9vJHc9mgeOtfw1UYtgIi1SXeR6qgIgaLbtiXvEnVzwu4yZxL7NUE0pC0FAE38C8CX0wM9+WWnOu5ucs8WbNUxrBJoLF5nLmdeh X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR0502MB3826.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(376002)(366004)(346002)(136003)(39860400002)(66476007)(66946007)(66556008)(1076003)(186003)(8936002)(16526019)(26005)(52116002)(478600001)(6506007)(36756003)(2906002)(6666004)(7416002)(5660300002)(8676002)(4326008)(83380400001)(6486002)(316002)(86362001)(6916009)(2616005)(956004)(6512007)(130980200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /q+oVQjfTJCbDzJG8gvwx3F5lefNSYHsiSvq4gHQgVXToGNsDDv3+UBWfwVa3RlZVDn/yy1RPFMVrZ1ccpMbz3eeRleBK3aHUYZkTTc8hJDMFJbgY3/h7HZHb8raTHdLodlbF+MZnMJE7dexZWVxqFnm2W8jRIPmEwXamJsnnwzK9hEC6r5HxnkfKvd1sftw/xtYaODdqspoF9+QFGlpGmFzbUhzM3JRq6nEnwyWO235+MMp2FXmR6bggC3mpWzFaZyfHEb5t4ybEz6zEFHmAaTqcEfUn15yyjAXksI8W6oVO05B2mdDS6glfVDcezGQRC1nCO/P5YqLT6IyB2AmwtEvVDhuMmzvZijvvd4DHHHbp8mqtWeLfc2+Z04f3YUxUrP10DCFiTpS530pripp8RAUG6vrG1nb4ea+8ZSE2Ait8nantOliwPtfYezT6hQf6cMthdVEu9vSyrvXvRKcu8Xnj9M6jNuubNUSdIO29aM= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42992024-919a-43dc-e515-08d80af37f2a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2020 15:00:20.2411 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jRRdVPrxVHl0YGWLUNtzXgjwwTAr+xfmHeiAu2YbaZlasnmdj/7wdkSQ7y1P+yc+sugoxWRVJJp/vEgF1aHlPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB4003 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The PDDR register enables to read the Phy debug database. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Reviewed-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/reg.h | 51 +++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index fcb88d4271bf..b76c839223b5 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -5438,6 +5438,56 @@ static inline void mlxsw_reg_pplr_pack(char *payload, u8 local_port, MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL : 0); } +/* PDDR - Port Diagnostics Database Register + * ----------------------------------------- + * The PDDR enables to read the Phy debug database + */ +#define MLXSW_REG_PDDR_ID 0x5031 +#define MLXSW_REG_PDDR_LEN 0x100 + +MLXSW_REG_DEFINE(pddr, MLXSW_REG_PDDR_ID, MLXSW_REG_PDDR_LEN); + +/* reg_pddr_local_port + * Local port number. + * Access: Index + */ +MLXSW_ITEM32(reg, pddr, local_port, 0x00, 16, 8); + +enum mlxsw_reg_pddr_page_select { + MLXSW_REG_PDDR_PAGE_SELECT_TROUBLESHOOTING_INFO = 1, +}; + +/* reg_pddr_page_select + * Page select index. + * Access: Index + */ +MLXSW_ITEM32(reg, pddr, page_select, 0x04, 0, 8); + +enum mlxsw_reg_pddr_trblsh_group_opcode { + /* Monitor opcodes */ + MLXSW_REG_PDDR_TRBLSH_GROUP_OPCODE_MONITOR, +}; + +/* reg_pddr_group_opcode + * Group selector. + * Access: Index + */ +MLXSW_ITEM32(reg, pddr, trblsh_group_opcode, 0x08, 0, 16); + +/* reg_pddr_status_opcode + * Group selector. + * Access: RO + */ +MLXSW_ITEM32(reg, pddr, trblsh_status_opcode, 0x0C, 0, 16); + +static inline void mlxsw_reg_pddr_pack(char *payload, u8 local_port, + u8 page_select) +{ + MLXSW_REG_ZERO(pddr, payload); + mlxsw_reg_pddr_local_port_set(payload, local_port); + mlxsw_reg_pddr_page_select_set(payload, page_select); +} + /* PMTM - Port Module Type Mapping Register * ---------------------------------------- * The PMTM allows query or configuration of module types. @@ -10758,6 +10808,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { MLXSW_REG(pbmc), MLXSW_REG(pspa), MLXSW_REG(pplr), + MLXSW_REG(pddr), MLXSW_REG(pmtm), MLXSW_REG(htgt), MLXSW_REG(hpkt), From patchwork Sun Jun 7 14:59:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 208419 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, 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 4DDE7C433E0 for ; Sun, 7 Jun 2020 15:00:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2290C206A4 for ; Sun, 7 Jun 2020 15:00:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="sm/MLYco" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726958AbgFGPAs (ORCPT ); Sun, 7 Jun 2020 11:00:48 -0400 Received: from mail-am6eur05on2089.outbound.protection.outlook.com ([40.107.22.89]:48904 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726788AbgFGPAp (ORCPT ); Sun, 7 Jun 2020 11:00:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bfKZtA07VFF8U4lvCs/lSxpqT9QU9INkeAsnGkIzWLQRQTU/5ORYA3JD2HUUpJhclktrgTKR9f6OFM6FKPyjPIFEDkgkDGnOZO3qAIuedsi8qyuiyRQCSqRExNdfWL8ADTfUXWzGnnbbh1kn2zR25VgbBQ8AZo2Q+RNAMOxGif+SUntuTFoNpXPBYKCZMe2KFwSxThGzJk0uDKxJhfLyIHTsv7voMyxJnZOyZHY/md8x1QJwMBeeugQUtzhteQqNHh9M2IETzgy9vGSusW9xGMNaHTAkz3po/BIGkgF71drVczMxE28oHr+BG+miw3YykkCWisIcZHyx8V7aluIMqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s2UMiDVDdko7IYOLowdGl/kRXNyTFr+69nQTr/lNXrs=; b=VlD0sdg19iw/PlVxwr2K/UXtUqBLVuvaHuRvDFSBH2gpQOW3EC78uyzuJW9KeZoRG54ndtrmyjlRyxNfVr6RA/ZrshFy/skJaVSjOLFmh0wWkuIJ7hmfLlnZMFz0Vuktj+xV/AnuaasCMlCvhOTzMhumgLrRmsXCFONPxlq7x/iZvIHFBUnEZ6tiAtdOv1zmjoNaVt4f9/lhBd4av0XR7liqp95KB1KwCqJg2CBAUsfoLZ4JxDJu1KqhNTiYKyi5O68lp1xJqAjTtZTi9wJwg6wmEyPccjHCVhCl0/DmlgQzifEubGSg1avwmsO34cpHb016wontN4TywYuIRm3J/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s2UMiDVDdko7IYOLowdGl/kRXNyTFr+69nQTr/lNXrs=; b=sm/MLYcowNdmFaPwJuILAHiiiiMWDgxs9mVtzFmpL1z0NjYZ19vuDtwhZX6yS+urqBsttAcvr70fy1L8R6qndCCy7ltYt5A6pTEHFnIVZsGEd6lzBscIow8xgyOkWVApSQDbxL7WdIg85X8qM5Lmjk7TPol7DmjSZ7+7KaUbOGw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR0502MB3826.eurprd05.prod.outlook.com (2603:10a6:208:1b::25) by AM0PR0502MB4003.eurprd05.prod.outlook.com (2603:10a6:208:2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.23; Sun, 7 Jun 2020 15:00:22 +0000 Received: from AM0PR0502MB3826.eurprd05.prod.outlook.com ([fe80::2dae:c2a2:c26a:f5b]) by AM0PR0502MB3826.eurprd05.prod.outlook.com ([fe80::2dae:c2a2:c26a:f5b%7]) with mapi id 15.20.3066.023; Sun, 7 Jun 2020 15:00:22 +0000 From: Amit Cohen To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, corbet@lwn.net, jiri@mellanox.com, idosch@mellanox.com, shuah@kernel.org, mkubecek@suse.cz, gustavo@embeddedor.com, amitc@mellanox.com, cforno12@linux.vnet.ibm.com, andrew@lunn.ch, f.fainelli@gmail.com, linux@rempel-privat.de, alexandru.ardelean@analog.com, ayal@mellanox.com, petrm@mellanox.com, mlxsw@mellanox.com, liuhangbin@gmail.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [RFC PATCH net-next 07/10] mlxsw: spectrum_ethtool: Add link extended state Date: Sun, 7 Jun 2020 17:59:42 +0300 Message-Id: <20200607145945.30559-8-amitc@mellanox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200607145945.30559-1-amitc@mellanox.com> References: <20200607145945.30559-1-amitc@mellanox.com> X-ClientProxiedBy: AM0PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::25) To AM0PR0502MB3826.eurprd05.prod.outlook.com (2603:10a6:208:1b::25) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from dev-r-vrt-155.mtr.labs.mlnx (37.142.13.130) by AM0PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Sun, 7 Jun 2020 15:00:20 +0000 X-Mailer: git-send-email 2.20.1 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 80b36cdb-7e4e-4bd0-c336-08d80af3808d X-MS-TrafficTypeDiagnostic: AM0PR0502MB4003: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-Forefront-PRVS: 04270EF89C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VvqrHlC1BcQqMambWuNNo3rD/UdlZr1nWuSfSCFudvH+JuHzcxOqZjDumhhfE+3bHk7Jurx7o37RXlKanAr6Mbxsru658/iu7vJyfzlBhpvtDLQ1muV+yz4Ec/W3ss+pUGPH6ZwfDe/usVqxbORwx56q34QD2xfqeibC3X2XRQ1XtGoKfAfWExRDXuEyaN+NnizqEKzPvqRCPiEG+IeaXDqxWw+/Vmo+kCsiiboMcTioNbTjhGylhk+RToKPOwYpQQ+xvdBH9OZaF5hovHLMJV1OiUDnPoAPy5G7QJ0Ex1FzJpuucaJa9ZOAzuT3fELu X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR0502MB3826.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(376002)(366004)(346002)(136003)(39860400002)(66476007)(66946007)(66556008)(1076003)(186003)(8936002)(16526019)(26005)(52116002)(478600001)(6506007)(36756003)(2906002)(6666004)(7416002)(5660300002)(8676002)(4326008)(83380400001)(6486002)(316002)(86362001)(6916009)(2616005)(956004)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2/1rRiheNn6XZ63ZugGeqjYWupGInBX5FqxeE68aBL17eONLwCOMCD9PYn5vqwD80ZvgRqdZLEprskAIaFqeRovCmjg0gb41BC6okCvOCs96emWsx0e8Rj69PBQ75Khyf3w9MlDLI1Y6E2QhlCclVvYe6e5U4KVCkFT/kmuLsVw6GdDRqaHVs+jot5hq0UaMxzlOSW/RjQF8Y39lJaVxaInqenSPdp7cpqKaC0bwizfN91TWw+Q2xoytjQvsJWWUhLyjhFEqgw+i6ImUNUjOCRZiZnKFCSIavSMpbMXZrnADGQ1Df97qsBoS7/BKS4mbl+3dJnyoxcSBxZmDylu5uKDruHHdSpvILyqW37dwrI/5IeIsdITa+yvBNMufqVdkgGV7LPQ4xnKXhqkmbb0scGCSInb7N46e+b93h9cTxW7ws6hQw6zVWyhtlk5BDYZdZn9T5i3FbfK5GMmyJoAysA9dQvoq954qB7D1hvfhUho= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80b36cdb-7e4e-4bd0-c336-08d80af3808d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2020 15:00:22.5808 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dUavifxkBUGZ0oHo7uh6qYkhIhP9P3Vh8HikBBE6/2R3mEF6kbUt7VBcHhXijwBnScp4Wh8a+lBiBtCXAr0kmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB4003 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Implement .get_down_ext_state() as part of ethtool_ops. Query link down reason from PDDR register and convert it to ethtool ext_state. In case that more information than common ext_state is provided, fill ext_substate also with the appropriate value. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata Reviewed-by: Jiri Pirko --- .../mellanox/mlxsw/spectrum_ethtool.c | 142 ++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c index 04e1db604c69..ca0bfd07aab6 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c @@ -26,6 +26,147 @@ static void mlxsw_sp_port_get_drvinfo(struct net_device *dev, sizeof(drvinfo->bus_info)); } +struct mlxsw_sp_ethtool_ext_state_opcode_mapping { + u32 status_opcode; + enum ethtool_ext_state ext_state; + int ext_substate; +}; + +static const struct mlxsw_sp_ethtool_ext_state_opcode_mapping +mlxsw_sp_ext_state_opcode_map[] = { + {2, ETHTOOL_EXT_STATE_AUTONEG_FAILURE, + ETHTOOL_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED}, + {3, ETHTOOL_EXT_STATE_AUTONEG_FAILURE, + ETHTOOL_EXT_SUBSTATE_AN_ACK_NOT_RECEIVED}, + {4, ETHTOOL_EXT_STATE_AUTONEG_FAILURE, + ETHTOOL_EXT_SUBSTATE_AN_NEXT_PAGE_EXCHANGE_FAILED}, + {36, ETHTOOL_EXT_STATE_AUTONEG_FAILURE, + ETHTOOL_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED_FORCE_MODE}, + {38, ETHTOOL_EXT_STATE_AUTONEG_FAILURE, + ETHTOOL_EXT_SUBSTATE_AN_FEC_MISMATCH_DURING_OVERRIDE}, + {39, ETHTOOL_EXT_STATE_AUTONEG_FAILURE, + ETHTOOL_EXT_SUBSTATE_AN_NO_HCD}, + + {5, ETHTOOL_EXT_STATE_LINK_TRAINING_FAILURE, + ETHTOOL_EXT_SUBSTATE_LT_KR_FRAME_LOCK_NOT_ACQUIRED}, + {6, ETHTOOL_EXT_STATE_LINK_TRAINING_FAILURE, + ETHTOOL_EXT_SUBSTATE_LT_KR_LINK_INHIBIT_TIMEOUT}, + {7, ETHTOOL_EXT_STATE_LINK_TRAINING_FAILURE, + ETHTOOL_EXT_SUBSTATE_LT_KR_LINK_PARTNER_DID_NOT_SET_RECEIVER_READY}, + {8, ETHTOOL_EXT_STATE_LINK_TRAINING_FAILURE, 0}, + {14, ETHTOOL_EXT_STATE_LINK_TRAINING_FAILURE, + ETHTOOL_EXT_SUBSTATE_LT_REMOTE_FAULT}, + + {9, ETHTOOL_EXT_STATE_LINK_LOGICAL_MISMATCH, + ETHTOOL_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_BLOCK_LOCK}, + {10, ETHTOOL_EXT_STATE_LINK_LOGICAL_MISMATCH, + ETHTOOL_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_AM_LOCK}, + {11, ETHTOOL_EXT_STATE_LINK_LOGICAL_MISMATCH, + ETHTOOL_EXT_SUBSTATE_LLM_PCS_DID_NOT_GET_ALIGN_STATUS}, + {12, ETHTOOL_EXT_STATE_LINK_LOGICAL_MISMATCH, + ETHTOOL_EXT_SUBSTATE_LLM_FC_FEC_IS_NOT_LOCKED}, + {13, ETHTOOL_EXT_STATE_LINK_LOGICAL_MISMATCH, + ETHTOOL_EXT_SUBSTATE_LLM_RS_FEC_IS_NOT_LOCKED}, + + {15, ETHTOOL_EXT_STATE_BAD_SIGNAL_INTEGRITY, 0}, + {17, ETHTOOL_EXT_STATE_BAD_SIGNAL_INTEGRITY, + ETHTOOL_EXT_SUBSTATE_BSI_LARGE_NUMBER_OF_PHYSICAL_ERRORS}, + {42, ETHTOOL_EXT_STATE_BAD_SIGNAL_INTEGRITY, + ETHTOOL_EXT_SUBSTATE_BSI_UNSUPPORTED_RATE}, + + {1024, ETHTOOL_EXT_STATE_NO_CABLE, 0}, + + {16, ETHTOOL_EXT_STATE_CABLE_ISSUE, + ETHTOOL_EXT_SUBSTATE_UNSUPPORTED_CABLE}, + {20, ETHTOOL_EXT_STATE_CABLE_ISSUE, + ETHTOOL_EXT_SUBSTATE_UNSUPPORTED_CABLE}, + {29, ETHTOOL_EXT_STATE_CABLE_ISSUE, + ETHTOOL_EXT_SUBSTATE_UNSUPPORTED_CABLE}, + {1025, ETHTOOL_EXT_STATE_CABLE_ISSUE, + ETHTOOL_EXT_SUBSTATE_UNSUPPORTED_CABLE}, + {1029, ETHTOOL_EXT_STATE_CABLE_ISSUE, + ETHTOOL_EXT_SUBSTATE_UNSUPPORTED_CABLE}, + {1031, ETHTOOL_EXT_STATE_CABLE_ISSUE, + ETHTOOL_EXT_SUBSTATE_SHORTED_CABLE}, + + {1027, ETHTOOL_EXT_STATE_EEPROM_ISSUE, 0}, + + {23, ETHTOOL_EXT_STATE_CALIBRATION_FAILURE, 0}, + + {1032, ETHTOOL_EXT_STATE_POWER_BUDGET_EXCEEDED, 0}, + + {1030, ETHTOOL_EXT_STATE_OVERHEAT, 0}, +}; + +static void +mlxsw_sp_port_set_ext_state(struct mlxsw_sp_ethtool_ext_state_opcode_mapping ext_state_mapping, + struct ethtool_ext_state_info *ext_state_info) +{ + switch (ext_state_mapping.ext_state) { + case ETHTOOL_EXT_STATE_AUTONEG_FAILURE: + ext_state_info->autoneg = + ext_state_mapping.ext_substate; + break; + case ETHTOOL_EXT_STATE_LINK_TRAINING_FAILURE: + ext_state_info->link_training = + ext_state_mapping.ext_substate; + break; + case ETHTOOL_EXT_STATE_LINK_LOGICAL_MISMATCH: + ext_state_info->link_logical_mismatch = + ext_state_mapping.ext_substate; + break; + case ETHTOOL_EXT_STATE_BAD_SIGNAL_INTEGRITY: + ext_state_info->bad_signal_integrity = + ext_state_mapping.ext_substate; + break; + case ETHTOOL_EXT_STATE_CABLE_ISSUE: + ext_state_info->cable_issue = + ext_state_mapping.ext_substate; + break; + default: + break; + } + + ext_state_info->ext_state = ext_state_mapping.ext_state; +} + +static int +mlxsw_sp_port_get_ext_state(struct net_device *dev, + struct ethtool_ext_state_info *ext_state_info) +{ + struct mlxsw_sp_ethtool_ext_state_opcode_mapping ext_state_mapping; + struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); + char pddr_pl[MLXSW_REG_PDDR_LEN]; + int opcode, err, i; + u32 status_opcode; + + mlxsw_reg_pddr_pack(pddr_pl, mlxsw_sp_port->local_port, + MLXSW_REG_PDDR_PAGE_SELECT_TROUBLESHOOTING_INFO); + + opcode = MLXSW_REG_PDDR_TRBLSH_GROUP_OPCODE_MONITOR; + mlxsw_reg_pddr_trblsh_group_opcode_set(pddr_pl, opcode); + + err = mlxsw_reg_query(mlxsw_sp_port->mlxsw_sp->core, MLXSW_REG(pddr), + pddr_pl); + if (err) + return err; + + status_opcode = mlxsw_reg_pddr_trblsh_status_opcode_get(pddr_pl); + if (!status_opcode) + return -ENODATA; + + for (i = 0; i < ARRAY_SIZE(mlxsw_sp_ext_state_opcode_map); i++) { + ext_state_mapping = mlxsw_sp_ext_state_opcode_map[i]; + if (ext_state_mapping.status_opcode == status_opcode) { + mlxsw_sp_port_set_ext_state(ext_state_mapping, + ext_state_info); + return 0; + } + } + + return -ENODATA; +} + static void mlxsw_sp_port_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause) { @@ -827,6 +968,7 @@ mlxsw_sp_get_ts_info(struct net_device *netdev, struct ethtool_ts_info *info) const struct ethtool_ops mlxsw_sp_port_ethtool_ops = { .get_drvinfo = mlxsw_sp_port_get_drvinfo, .get_link = ethtool_op_get_link, + .get_ext_state = mlxsw_sp_port_get_ext_state, .get_pauseparam = mlxsw_sp_port_get_pauseparam, .set_pauseparam = mlxsw_sp_port_set_pauseparam, .get_strings = mlxsw_sp_port_get_strings, From patchwork Sun Jun 7 14:59:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Cohen X-Patchwork-Id: 208418 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 6DEB5C433DF for ; Sun, 7 Jun 2020 15:01:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E09E2067B for ; Sun, 7 Jun 2020 15:01:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="Pig01QM2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727776AbgFGPBE (ORCPT ); Sun, 7 Jun 2020 11:01:04 -0400 Received: from mail-eopbgr140053.outbound.protection.outlook.com ([40.107.14.53]:5605 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726528AbgFGPAs (ORCPT ); Sun, 7 Jun 2020 11:00:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VW+gF4qpspOL91s/VY+mnF+hzP2WCkoPv/b8KyEFcJeU9RoT4dACi+FrtjEw7VvvrEX/fRofD4FqFqJM3QpZsTGe9zJKpHkn+ibePWc5OyHX1i5v38CM1MLTBflx6KGMEW4JUBNGYL7J0YkgUyn6G444C/QikuNr8rTyZDHRmk1PVUd9uljNIrd1PdJFRN3z11I4ailviUT6F3mjTPkFBcfDVVKjAGpgwDt3DhOjdzmcLEL9TUQiTo89ajvwcKSgEeAZN2KWSLWKFGT0+LyEw6fBkUl0n57HwlSVN2h92uU3NE+USNXIsBFRNuSZdcNykye8E3XkdmK8U+eVaOsKGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AMkknZVuB+OLWasoPjJKxn7XvU/mbTnf217drmrHIBw=; b=Bq2IHlqW5UcKRLf21FN6WIHfyY2wI0rvqcmpttOl3gIYMJA8Ml86LY9VO2d3fmwStTNS8TojbtLuehEPq6ThMsPJzqpCygn+MIkgEp/Jnh5vYCLipgQhnrK5sJjUcpiKiKgxQ+Wuqk2zWQkurHgHnZkMvjZ11Mx6ZBx+fvaPnYU/0FhDbqPWQzZAHpKc49R4wo8Ifp6gYrqI45isPxlQePe8WctgD8nD22SaWty+keiEc8Se7DAsI9YyRsaONEren3yYjE5bXItl8ewr+i5vXRz1BJquxdlJJgbAGrp+lHx0L6bh2Oaeb3hOMqE68o84aMnSi8ylOw1clMkXT1luWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AMkknZVuB+OLWasoPjJKxn7XvU/mbTnf217drmrHIBw=; b=Pig01QM2IIP2D9rBKFsosr40awNiGeEU3dsQ2ZRfIBVroqi7iXHjdIlM8nkCDpQvzIESeDpEUMyAsAYrzUDhBMLrHc9risZ/B2W+qn6frugPGwJMy3iHEp+2ZCuve1Gtm6234/DutmjLaqopd9XxL6hozdrMzv0KgLJmIFloCdg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR0502MB3826.eurprd05.prod.outlook.com (2603:10a6:208:1b::25) by AM0PR0502MB4003.eurprd05.prod.outlook.com (2603:10a6:208:2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.23; Sun, 7 Jun 2020 15:00:25 +0000 Received: from AM0PR0502MB3826.eurprd05.prod.outlook.com ([fe80::2dae:c2a2:c26a:f5b]) by AM0PR0502MB3826.eurprd05.prod.outlook.com ([fe80::2dae:c2a2:c26a:f5b%7]) with mapi id 15.20.3066.023; Sun, 7 Jun 2020 15:00:25 +0000 From: Amit Cohen To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, corbet@lwn.net, jiri@mellanox.com, idosch@mellanox.com, shuah@kernel.org, mkubecek@suse.cz, gustavo@embeddedor.com, amitc@mellanox.com, cforno12@linux.vnet.ibm.com, andrew@lunn.ch, f.fainelli@gmail.com, linux@rempel-privat.de, alexandru.ardelean@analog.com, ayal@mellanox.com, petrm@mellanox.com, mlxsw@mellanox.com, liuhangbin@gmail.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [RFC PATCH net-next 08/10] selftests: forwarding: ethtool: Move different_speeds_get() to ethtool_lib Date: Sun, 7 Jun 2020 17:59:43 +0300 Message-Id: <20200607145945.30559-9-amitc@mellanox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200607145945.30559-1-amitc@mellanox.com> References: <20200607145945.30559-1-amitc@mellanox.com> X-ClientProxiedBy: AM0PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::25) To AM0PR0502MB3826.eurprd05.prod.outlook.com (2603:10a6:208:1b::25) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from dev-r-vrt-155.mtr.labs.mlnx (37.142.13.130) by AM0PR10CA0015.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Sun, 7 Jun 2020 15:00:22 +0000 X-Mailer: git-send-email 2.20.1 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 571f42b5-f637-46f0-7ebd-08d80af381ee X-MS-TrafficTypeDiagnostic: AM0PR0502MB4003: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:217; X-Forefront-PRVS: 04270EF89C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KrBJLHWMUbDNUb6PIs4rvlhoDc75rfVv0cUNZtJSkynwZ8LALOI075dbFv4B/WqhUDPGRB1Dvk0j7JdQReGtHI9PTQZnfMhQTcsWqM/BgCLSMTWtrLYPgv+8iFUPu2gjLN/mVt5MDUPvFJlj9Q2F2v5i5aHogASA7hICIA1lNiokeJ2l/42NafHyHlRgqirtDoRmw9MsEWCKQ2yIY29yavCatZw6mPwQCjc+nKMskoAPxxvWWp1iYZUdmc/sLZ0nYYoPqco4OnNRG6HWGH3+MBE1YZAbp7n91SQ9aPd83uqRA4vgmRJ1XfvE0VZaz1eX3K17Y05BttDd7P2kZ3NGgQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR0502MB3826.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(376002)(366004)(346002)(136003)(39860400002)(66476007)(66946007)(66556008)(1076003)(186003)(8936002)(16526019)(26005)(52116002)(478600001)(6506007)(36756003)(2906002)(6666004)(7416002)(5660300002)(8676002)(4326008)(83380400001)(6486002)(316002)(86362001)(6916009)(2616005)(956004)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HWw0iusJK412sJb3Fu2sduf8qJLvrjHO1nsAkXiielX4l6uPmeoyFh8n9MA0O3sY5txFOt08myrb108crfnTzW8wzQgviACNiy2zJF9riZDRzluBrShWLhjyrF2j/BQdnAhnmVchz6n9VlEl8h7YMJCJ8FWffvb5QjhgpaNf8wRBIu3Z8e9lVbpPwjoNwZgUYijnaLJstldkdoXVAlDgexBN+zEzk/zdOeZ8KO2tmwegeT9aEX7ycgtpdoiM4SWSsEH+XaWOk7JAOtOL/BLI7F36AVOhHGkPHR95D9kQv0XFiUNxHuBv4+m59M3aLzQGfSQdA9J2sF2GuRhloPBsD5ZamATL63ruRDRotEg4/tB7l7AVGK0q+nUfZ44ggctl/hZvhz7iSal1Af8FYYymXF5EuSzGWAxA5GVjY4rRu6T9nXR0+eHD9iLv9fttpdi3C9Sq179ocXdJMN/M2Gzf//KTnYNONB9Rhg3Ge0pxHeI= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 571f42b5-f637-46f0-7ebd-08d80af381ee X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2020 15:00:24.9075 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hl3F7CNOJ4jflwgWuw3JZTm5/KcapHlWJiAROPMjGN0yB+Cve/i9UTY/zq6Pf8cPTtVqs3KX7zjgkN0nC7DMGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB4003 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently different_speeds_get() is used only by ethtool.sh tests. The function can be useful for another tests that check ethtool configurations. Move the function to ethtool_lib in order to allow other tests to use it. Signed-off-by: Amit Cohen Reviewed-by: Petr Machata --- .../testing/selftests/net/forwarding/ethtool.sh | 17 ----------------- .../selftests/net/forwarding/ethtool_lib.sh | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/ethtool.sh b/tools/testing/selftests/net/forwarding/ethtool.sh index eb8e2a23bbb4..ea7a11a9f788 100755 --- a/tools/testing/selftests/net/forwarding/ethtool.sh +++ b/tools/testing/selftests/net/forwarding/ethtool.sh @@ -50,23 +50,6 @@ cleanup() h1_destroy } -different_speeds_get() -{ - local dev1=$1; shift - local dev2=$1; shift - local with_mode=$1; shift - local adver=$1; shift - - local -a speeds_arr - - speeds_arr=($(common_speeds_get $dev1 $dev2 $with_mode $adver)) - if [[ ${#speeds_arr[@]} < 2 ]]; then - check_err 1 "cannot check different speeds. There are not enough speeds" - fi - - echo ${speeds_arr[0]} ${speeds_arr[1]} -} - same_speeds_autoneg_off() { # Check that when each of the reported speeds is forced, the links come diff --git a/tools/testing/selftests/net/forwarding/ethtool_lib.sh b/tools/testing/selftests/net/forwarding/ethtool_lib.sh index 925d229a59d8..9188e624dec0 100644 --- a/tools/testing/selftests/net/forwarding/ethtool_lib.sh +++ b/tools/testing/selftests/net/forwarding/ethtool_lib.sh @@ -67,3 +67,20 @@ common_speeds_get() <(printf '%s\n' "${dev1_speeds[@]}" | sort -u) \ <(printf '%s\n' "${dev2_speeds[@]}" | sort -u) } + +different_speeds_get() +{ + local dev1=$1; shift + local dev2=$1; shift + local with_mode=$1; shift + local adver=$1; shift + + local -a speeds_arr + + speeds_arr=($(common_speeds_get $dev1 $dev2 $with_mode $adver)) + if [[ ${#speeds_arr[@]} < 2 ]]; then + check_err 1 "cannot check different speeds. There are not enough speeds" + fi + + echo ${speeds_arr[0]} ${speeds_arr[1]} +}