From patchwork Tue Aug 16 22:29:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12945336 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BF39C32772 for ; Tue, 16 Aug 2022 22:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238007AbiHPW3f (ORCPT ); Tue, 16 Aug 2022 18:29:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237995AbiHPW3e (ORCPT ); Tue, 16 Aug 2022 18:29:34 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60064.outbound.protection.outlook.com [40.107.6.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39AEB75FE6 for ; Tue, 16 Aug 2022 15:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PY2hPqn9RUHkjB8570kjX7AnMeeJQP/jbfSCHdTWDUpItTGvl3F3nEpPASGwMKVmXMzgyjQOiUUypBtpKxofbzgkiQMNxnKthkcfX1Sk6LqPM0r3Da+gHKEEZfyz+I0RWqD1NtlxjONPtt31EkPteAjQU3ycndm4oCx/M4vD3MMLWj1Lmosgmi4BHgGI+vSncuXlo77770OCFNXd+tS4CMJPtNH8MCWn7reWDMFceB5VeHpRaU22BrqqRcAV5MWPjh+J/ujYMS1W19wX8ZZ9XTu/Rht8dr17c95cV6FB4PySTpTUJopUg3qm1mwkvbrDqPQ0efe3DKRD5JZV5INbZw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/9GZMpP5xWxvqHT+V+u8nKlJoZGgRsYQ1v+BTKIWw10=; b=PSN916r6YEWPBy+MPb5cr2O7iQDtdzTwl5TIVvN3/7Qt8AMtNtSsHqmhjNvDTS29C0vLdnAD6l4RCXB//RlM5+lnogIwCuU7hPQtVh/cmVtNxGnWE2A2Xvz4bhQ09Urp2F3j8MIIFo1Z46CGCusdbk3zc3F72+Zrigv6A64XRBVBceaE97bMQ+ZisK/qhgaQX1OOzapUlthjnxrPc0UPUSvhZM97Xzo1Kp7r5g1s4raPfX3G0LyX4bKTAHcIVtuO2SUoE5DTLzo+31JlPBnQl3ddeoGyqR/N4KHBDDg7fR52mgColbb/L/B3021WPZ6Y/QkHvP8rBcXaMsrKor46cQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/9GZMpP5xWxvqHT+V+u8nKlJoZGgRsYQ1v+BTKIWw10=; b=ovcVxS6AuiYaEEJ2U6lUtb5ejCwMUIqPUW4PXuMG5yXkyJEF9kGFcTDiUPiU5524wZavaidx94/w4WF1gxA1ceNu6sDmLKxIrtQCG4+o7v3FA52N8GXYTmLCl/pg98Ax2PoZO3bxKCKtq5W90R5jsYEt68P2gKLXWrNO+NMjBJg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8618.eurprd04.prod.outlook.com (2603:10a6:20b:439::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Tue, 16 Aug 2022 22:29:31 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 22:29:31 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes Subject: [RFC PATCH net-next 1/7] net: ethtool: netlink: introduce ethnl_update_bool() Date: Wed, 17 Aug 2022 01:29:14 +0300 Message-Id: <20220816222920.1952936-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816222920.1952936-1-vladimir.oltean@nxp.com> References: <20220816222920.1952936-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0021.eurprd05.prod.outlook.com (2603:10a6:800:92::31) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01c67073-3e10-4b98-ec0d-08da7fd6c97c X-MS-TrafficTypeDiagnostic: AM9PR04MB8618:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p0bwxsaclPTMWVlUFlwDd7UBGuN1j1cshzmRl6SJ8QF8XMNIPjJ/cLEsPdxd8xdfzmkluFAaO/XIrqwMUtVPHicGSZZIN1elB5lk4wcR0osoZRBDL0aSGDCJvVcETih+hd4fWWoPf2Yda44WCyPMtUkAS0/GSkpnBaj7EJ4OlRUtMclp4wWReydqHnJBsIak2Mr6KoqOP4uXTuDwEFpbIgXHMppFx6MirzcDRe4ZMIoBVUIzEe6yJoGBMOcmM6VVkNlNqhwRplPiRIsrG4cISj1j4p24WavghI9248Mya7LlCzNi5LXVZ7icd8deCbpMpV9J5mfNpRB8LT2N/dA6FGOL8Nc5r1A2vvdy8E1DhM6N4KLf0CoX07K9IiPcFZvMVXEJCYmMyoBfx5/8CXjeXqI1k3YWG/gyjJ4W1izhNvP078S3yyWD5WSjPz4+TcxYsnsIe0SGwpm1TrzbUa31iemHShvtP7dq0WMeitarokWC2/Tyx40D49VjkkZ6Ug35rkylReSS4GdPgVeO3v8wz49d9yqwm/uRnjVqZt+gmp1bY97MLtlyHE56V9IOVmbnQGt3l+gKks6WRy7F0lA4K0TiZs2Yg7KM78ui2dr9hnukU0RarT9C1Dbz1elbBAgJ5yXH9Odxy5tDHIa+J3a7ZSaz6sxsqDBNe7PvILFVLF+x/gwtvcZ8uBEJq1FNDBNY93664Dj2mF4FbyN9lDx9kBffTpU2o88Yu+ehTeXENJItJmYd6EuMgfkt5lleDbMrivfht+WzCois3FF/nPgsXOd6MVdjNfyXOA+rQ+UugA7NgLfA2G9fTgo+AqfSzy1UKXsh3ndtuNGY0NmrIl/Wsw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(136003)(366004)(346002)(39860400002)(376002)(66946007)(44832011)(316002)(1076003)(66556008)(8676002)(83380400001)(41300700001)(6666004)(6916009)(4326008)(2906002)(36756003)(54906003)(186003)(2616005)(38100700002)(26005)(38350700002)(6506007)(6512007)(66476007)(6486002)(8936002)(86362001)(478600001)(52116002)(5660300002)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B6Fg1Y+RllZFWjll7xc6GAF7dbUFLpGN+ejkCGIkDFFayxGimJEdifWnsd40FgLviq2Aa5LCnHvNbV9WXzTBB2RGDo8bHuxWwLsZg8nd/yKSVvPfrustTDIuzqJJ0i1I246iEHaA7Ion3LY8dbpAcp5+HYCDeQQmftqyZIAcaSC+8qwcVJ7tC7nXG9VHLCPxMhWEnapd+KhnmwuX6YXWI7mHuAGv3M8eDGf7MGX8aIiNj/RJw9dYTwNWBKJ34k9Jwrksel28T2jjOESxhM+jbyc9ZQk7XmqSyo0Iu10pwZrJnO/h5UnzoNg2HUVn1gdON92yqb0m0SCJWXDuTwDiApQEXUVax5qwt+bzriVQvhSeeTSon+eo6X5FB27Ti1lAmGuMfuZakpOPYF4+Yu87Gtzo27UeSI16JmzjycSpYuGtFT/fNKBsKCdHncgodrR4fYhaWAFxGv6dYesD0hbY/S020J00TGu93c404C9LWq4FmBel5uAx9ZkNcnBS2abfm8n0SdDw+Ie9a4E8NepiuDHJuGvxIcrgsWEXMKE28t8C9quAWqiczQbUoQLnNWJ1x0kwwpSPmi3/+9IizkS0PW3eZceVbVMMonqwSFiyhPgiad6SsrHYKadwJuSAk7cNDG7wEqkynmE4MsDUdzYTh03EYtjtusCd0IiRVyhoXw4KFBN6YbptVim/OuJFy/2yW3yUJqanxlyDLsbhEfB+mL7RQ0OqBav7qb1qwo9TAG5pex4cABbj7hmG5159JZhJQnuA8MuzqlIvfM1062IWzbimzAmyygs+LkqE/OzVRPaToCIhQqrRJbRkExhVBHLJDBUwtZ5pWhwSWJ3Zf/PWzB7reKruoUExDH5za8qoj4lHj6mjMIBuexe1gyXjvWrrD9LbaT++6bR6BFnIjAn07P1QPxDrnQewztqo48FvjNPWdmg2YI69CgKxwioQqXqmMMs4ArviMA+V0ypzJyGFgoZKKEN/X0i7bjxn+hZuHQGwaXe1ORT4Xd9oG+5MCc1XXBPp0jSYwCZ1wMoNEkzx2RlurVLdgpmUFfAR4ijucH762kfv0kbPYftmK4VqDdHM9dK5dctoEWHn6lFZ2pdTQfix7wJjze6r7GFHBCcszGG1r+K4u/JwM9okYg0NvSmGl2+c26+pNwl6fgjqVW/VdZOaeWP26OS/vOWuNcR7Id7bKPpyTuBXEA0GXD+eunKDm8plHZIRFRS8S8k3csiWctTVAuK6Px6Nja1hFVdpxw4UJ57DUP99nwakRMLyhISkin69hSUrNvx1FZ8+ftipTgysRzWIg+BiiECmV2qadFJEBquexOYXShdfc6knc2VFV161SOQ5JxCre2Wc8npENK/IDtGb4QdWsD27MW54jBzdIDj12Ji6jyyoHiGcxhJunYIARBTw8Q62ORajvQdEmGFYkT3+nAju57tjhmBZ/d6cqj6bbeDXkM0NIyMqCsnMQU91SDrGIS/GJO9pu9/jbQ3mXfbOxGkoTp2sJEo8dRqeeMjpfodFTbJxaSLrcwfuB54ayl1aAkp65kyDCPieB5IFoKD1EtVn0gwBMoSy8zF3MAZaTHoEDs1FoqHO7p2tFxcNUVH6EdpRbit8Ze7UsA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01c67073-3e10-4b98-ec0d-08da7fd6c97c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 22:29:31.0232 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZZr9PTanfj9JBiukdt9ZTx2hMNHktM3gMcNWFoyee/0Mvf4oiHDjSPM4/BW58s0h25fRoeGxG3MUBI6fjEQKdA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8618 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC For a reason I can't really understand, ethnl_update_bool32() exists, but the plain function that operates on a boolean value kept in an actual u8 netlink attribute doesn't. Introduce it; it's needed for things like verify-disabled for the MAC merge configuration. Signed-off-by: Vladimir Oltean --- net/ethtool/netlink.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index c0d587611854..1653fd2cf0cf 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -111,6 +111,32 @@ static inline void ethnl_update_u8(u8 *dst, const struct nlattr *attr, *mod = true; } +/** + * ethnl_update_bool() - update bool from NLA_U8 attribute + * @dst: value to update + * @attr: netlink attribute with new value or null + * @mod: pointer to bool for modification tracking + * + * Use the u8 value from NLA_U8 netlink attribute @attr to set bool variable + * pointed to by @dst to false (if zero) or 1 (if not); do nothing if @attr is + * null. Bool pointed to by @mod is set to true if this function changed the + * logical value of *dst, otherwise it is left as is. + */ +static inline void ethnl_update_bool(bool *dst, const struct nlattr *attr, + bool *mod) +{ + u8 val; + + if (!attr) + return; + val = !!nla_get_u8(attr); + if (*dst == val) + return; + + *dst = val; + *mod = true; +} + /** * ethnl_update_bool32() - update u32 used as bool from NLA_U8 attribute * @dst: value to update From patchwork Tue Aug 16 22:29:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12945338 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EF6AC32772 for ; Tue, 16 Aug 2022 22:29:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238017AbiHPW3o (ORCPT ); Tue, 16 Aug 2022 18:29:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238011AbiHPW3l (ORCPT ); Tue, 16 Aug 2022 18:29:41 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60064.outbound.protection.outlook.com [40.107.6.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19DE67A516 for ; Tue, 16 Aug 2022 15:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iacu8LLy/Qcnxql8rD4yxO27jcTxVjnDsBHrLM62ll0AiLNK0zlaGfaMIVDuwoCD3TguR2iGVFys8vdkul2KliiPx0F8w9NLp/+YlR7Y9EVYTWHVFbd7aiCN26se0CRB3QX3p1RtA9voY2p2ilQXYeEqwAgG1qlsW2eCs/LcgzryC4crKA0W6lsAA2mxZcr97NHZjX5mf4S30zbVyHrWMvDH0mToKejZztqdZEGNd+o8vkd3qUlAbxwOQM5JTURLXgiE3vaAMSJnLYYtKZOxvmTMwz5tesKgkTNemYetZWSk7sUYYsMNuQMzgZBwT6nopTlDBJG/sTu4LC13E4CUIQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=L8QAgZ0bvKjRmZRmw7Pasl2q6c1Dp/W9swj6gjKmlBY=; b=eZB8JZIiBoOk0z3TmDyUMJ4XsDEr30B5S12kYYqwBtLupeduYO0ABMEO78hYz5dFPFWpaMUv3mCYJeiS3/zoeUKNRKfeSlpiws8lKn3yKgjCxStAkCyXzgQ8Vz0zX9OWbeYooCzkkw8MqKezCg6vEHR3KsFxDa8ORu3UboM5s0Ab7Qy8yXvBvIoKMz/S3ek3hf7+/eQzm7jbFnAOqdBLf9CKELKEd1hM6ErNTZdS8aSgl5bAifXP40j14RFJbvTldFx5PMiV/OdxPCl8kgKeXye3eRmhCugPd81HHbp+BarFRgPmEEuBCOuuCT8DHkI+hMUZe+DhCvfdYROSseuVSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L8QAgZ0bvKjRmZRmw7Pasl2q6c1Dp/W9swj6gjKmlBY=; b=oSSm5ULODdf0yS4RDpLSZHuXS7PzXCX1b5AihQWk3S3ymxvuTrHtyDeon8L18pnX/8jcqG/ASGgzYRDjjOG5cs75Y7sO1K6C/xGBXYiXOr3JSLIb5yKSAOV8e1B19OPt9EL0QeuIlwYwmX0PsLwnDIsfNBYeRslMaOVRJN5gOTw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8618.eurprd04.prod.outlook.com (2603:10a6:20b:439::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Tue, 16 Aug 2022 22:29:32 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 22:29:32 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes Subject: [RFC PATCH net-next 2/7] net: ethtool: add support for Frame Preemption and MAC Merge layer Date: Wed, 17 Aug 2022 01:29:15 +0300 Message-Id: <20220816222920.1952936-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816222920.1952936-1-vladimir.oltean@nxp.com> References: <20220816222920.1952936-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0021.eurprd05.prod.outlook.com (2603:10a6:800:92::31) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 613b8e90-ac9b-4390-e20b-08da7fd6ca17 X-MS-TrafficTypeDiagnostic: AM9PR04MB8618:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cermo04FRdubhRxrTKr4UP0lm24XpvylNjNJVkxLmBxUikMQaG+QI0tScCjsOpkalH5uru70fWdeQfQGO7TRcdmA8HGCF56CPBG5g6uW0K8JJ0gN3e9bu2EOiL1MHenqFeUAE9A6mJ0xPC1Hf86bEjvDFjLQY02lQzEca39zdOTG+dMgPOpdGYol4PTdhtMyGcuTvGYb7p5DaneqWaiJgekZkZYMXcIB3FJGc1H1fvQDFUqt7/mgIDgUR/Md8Df06CTx8sw5gjP3a1+OhWS/2WUJ8w5+yeDL0+eO+EqD/GxUiZEFdLJSMnYwvf3vUfB26JupDkCVehOvDW+rx4Zv7i4F1+EE3Hq34X86VE2pyURPFZD5+mdPDKqsMxDqMwBnh6WBRMv03mDzSif8nSakGZbzCYP3+HqAiIGnmK4jzkpYu2OEs6k/GzKo41sHEV/jZsvekjlSkCgctdPV7GibLbxUhc6I1yMPLBdHGGmNZu+Zu1UmGXtNPYKO6bQYmOSWEKIQeLOFhmOFG10Ym2Ary6rkk26F911lP65zrhyNaNqq+JAW5wracT6CtmyTsQ7+pi9v4oDiLch2jfWRJkBA5itL+T3vVmxIItZ8JmZEMLfCPVB0tDXWKPlsCo5d4MjgWEiYe1aNJSgrqrt6vBSRCVW3iCKaiPt9umTVTk9dhQmWqe6mnInfGWH7o10RIwkdMbMX30/YP3DyQYmrRvCCHDFyWy8bY+lFG7fOd1Mf0f8Znep3QR1zj5t3PEQgx4RB7J/eo5rVDV2A+fttgqmk/B5qspdVHnzJwyUzPk+pVzzMZp3b6J66yY7cwTS8+wtYzU5PUf+nxXG6c2lN7ucIUIxI733eXHtIWPcdRmhjr+4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(136003)(366004)(346002)(39860400002)(376002)(66946007)(44832011)(316002)(1076003)(66556008)(8676002)(83380400001)(41300700001)(6666004)(6916009)(4326008)(2906002)(36756003)(54906003)(186003)(2616005)(38100700002)(26005)(38350700002)(30864003)(19627235002)(6506007)(6512007)(66476007)(6486002)(8936002)(86362001)(478600001)(52116002)(5660300002)(966005)(134885004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iwb3UU2ff7KpeBKKU3gGp18pamQ7wIURZCaELV7Vi+5f81FCASE6leIuCtov5pRC+gPp0RPu3b2wPh8JHduuu+IhotSN7furxpbSqYsOyruG++mEf7MtgdZ6B6N90gM6KSgQEMlW3VO/FwcxGCW5o8tNl7F28MmdGNrrejJNYhRlK3gYMh+4HSpFWmQESEJYUwfEN96vJUAsZWLv97rrRTaxjIHbEMn76k20GRMikgs0O5GEbwchKMeAwj5q9bQdyU3BKBG3MTR6CkplbKHmnDOPEusvSLVZM5/KyvAUcI76WXGH6jj4F+Vb9nn8ND+WH7w3AV7ImHxgcqIK3VDkHGA0XOgSy4m4bdZYIntpzjQE7ZkLzvFcF0SYKY0ZndNAmeFarPCGHl+BNVPF9vek+nsyFP5WRB6EumvbYf3F5kp6M39G7m1/w8Aw8u10iJGSCbNwY0D2KWp+hPheQQK1eEaSh3Tw/nsie7Gatw+wC+ny+8Nz1a8oA6uPZLlwoWNMV6cgw3rGji/LDLB6FYWscvxKdxpzN59EsjQgKrN3/NXZAznz+E6WgBVbdhoMvXvnjO3KNUFiDiqnX7rSvk0FqSFkuCj+sBjU9LenmbvV74RyPvTweXB0RrOQ3iD9W6s5jJIrxT4fDyKn+ASo9LMFuHImS2RTXl3SHAhoou0bIDjv5lTZz+nubIKAKeZlZAB+EKVsHU47+TzDTr8gMtZVckz5wusKDKwfwJCiAFjCFOFgzfn2ToVRzvRtlul45EjuqmjqBwONUpF6AfMASiuVTG+G/jzjHqNVcom8suU3C7YeZ2u1g6EFrcTFN3HdVeltyw32JU/e7wCz6BkWsB3J3t3XyYrhpr9MCj3R+Tea+jKsVn5k01h2f/6TkHee3157339+eHPA4kTBCPoINS/N5vrZ16IlbIFTWaf1wYmGLotz169IXsM1QvWZ80bxlETI3N/vX7gFPjXxp7tgV2fYhTuaLGFXD3gNm+n39wvKdpU4matSI3d3CYnB1fgAeQV30BEN3hzVMhsnfsEV3IaDZzSlzknW8HcewYn9IOiUJLCMX2UyYecFVLbDeQ2iga5/gIKMH/50xhDK77ZKeSH239iCi0/bqo9tvlLuh6TteTmQ29jf4eENUOMrMtFnR9e3bH+cXaHrTm83jSmq4FFUt+3uvBl0ZGGTrH+8S4H4/7f5uAtCkldtAMy3unAhIUogX4yRqwlt0trW9DlGnYWgCRbODU+ZXCqqXp+gc58DekxB9X831LqLhq7AK13CBOLeTEUDtMIsDiKls0CkHHTn/Ky+KJoIXXA9pdUb9paP0BBLnP4RX3BHF0+0SKsT9EjE5CJWpmMRNwEhPk7ynKRJ8RU9yPqPWF4gv+qO9k3+NRh9pi02NVmy0xTD9MnGvGYccBVcynImf11LhUg0/Ctj6C3HT12gwRlcFjwa3E9RsudbF1baklDFpLBu7WS95pEabIeRfORJGgmx8vZBxZYdclOSbyVo5lg/+B1q33qxa3arGWyyqZu31dQ97UkD80dSdka96HXgC2I2pUe8qJdR2WRENIf1zzTalv08ux3pRAtDY7q077UdkdwdT2yQ0gG8JZuK5oEAaYBukI0VVCxeeA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 613b8e90-ac9b-4390-e20b-08da7fd6ca17 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 22:29:31.8981 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kQ+JpmkbUEM511kIXGDYlwfi9ovUgd3neXYpEpgy0yjTYLbEABhRrJWgGvDrbdTUrEKPaDLq06sfkQSrhOEsHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8618 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Frame preemption (IEEE 802.1Q-2018 clause 6.7.2) and the MAC merge sublayer (IEEE 802.3-2018 clause 99) are 2 specifications, part of the Time Sensitive Networking enhancements, which work together to minimize latency caused by frame interference. The overall goal of TSN is for normal traffic and traffic belonging to real-time control processes to be able to cohabitate on the same L2 network and not bother each other too much. They achieve this (partly) by introducing the concept of preemptable traffic, i.e. Ethernet frames that have an altered Start-Of-Frame delimiter, which can be fragmented and reassembled at L2 on a link-local basis. The non-preemptable frames are called express traffic, and they can preempt preemptable frames, therefore having lower latency, which can matter at lower (100 Mbps) link speeds, or at high MTUs (jumbo frames around 9K). Preemption is not recursive, i.e. a PT frame cannot preempt another PT frame. Preemption also does not depend upon priority, or otherwise said, an ET frame with prio 0 will still preempt a PT frame with prio 7. In terms of implementation, the specs talk about the fact that the express traffic is handled by an express MAC (eMAC) and the preemptable traffic by a preemptable MAC (pMAC), and these MACs are multiplexed on the same MII by a MAC merge layer. On RX, packets go to the eMAC or to the pMAC based on their SFD (the definition of which was generalized to SMD, Start-of-mPacket-Delimiter, where mPacket is essentially an Ethernet frame fragment, or a complete frame). On TX, the eMAC/pMAC classification decision is taken by the 802.1Q spec, based on packet priority (each of the 8 priority values may have an admin-status of preemptable or express). I have modeled both the Ethernet part of the spec and the queuing part as separate netlink messages, with separate ethtool command sets intended for them. I am slightly flexible as to where to place the FP settings; there were previous discussions about placing them in tc. At the moment I haven't received a good enough argument to move them out of ethtool, so here they are. https://patchwork.kernel.org/project/netdevbpf/cover/20220520011538.1098888-1-vinicius.gomes@intel.com/ Signed-off-by: Vladimir Oltean --- include/linux/ethtool.h | 59 ++++++ include/uapi/linux/ethtool.h | 15 ++ include/uapi/linux/ethtool_netlink.h | 82 ++++++++ net/ethtool/Makefile | 3 +- net/ethtool/fp.c | 295 +++++++++++++++++++++++++++ net/ethtool/mm.c | 228 +++++++++++++++++++++ net/ethtool/netlink.c | 38 ++++ net/ethtool/netlink.h | 8 + 8 files changed, 727 insertions(+), 1 deletion(-) create mode 100644 net/ethtool/fp.c create mode 100644 net/ethtool/mm.c diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 99dc7bfbcd3c..fa504dd22bf6 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -453,6 +453,49 @@ struct ethtool_module_power_mode_params { enum ethtool_module_power_mode mode; }; +/** + * struct ethtool_fp_param - 802.1Q Frame Preemption parameters + */ +struct ethtool_fp_param { + u8 preemptable_prios; + u32 hold_advance; + u32 release_advance; +}; + +/** + * struct ethtool_mm_state - 802.3 MAC merge layer state + */ +struct ethtool_mm_state { + u32 verify_time; + enum ethtool_mm_verify_status verify_status; + bool supported; + bool enabled; + bool active; + u8 add_frag_size; +}; + +/** + * struct ethtool_mm_cfg - 802.3 MAC merge layer configuration + */ +struct ethtool_mm_cfg { + u32 verify_time; + bool verify_disable; + bool enabled; + u8 add_frag_size; +}; + +/* struct ethtool_mm_stats - 802.3 MAC merge layer statistics, as defined in + * IEEE 802.3-2018 subclause 30.14.1 oMACMergeEntity managed object class + */ +struct ethtool_mm_stats { + u64 MACMergeFrameAssErrorCount; + u64 MACMergeFrameSmdErrorCount; + u64 MACMergeFrameAssOkCount; + u64 MACMergeFragCountRx; + u64 MACMergeFragCountTx; + u64 MACMergeHoldCount; +}; + /** * struct ethtool_ops - optional netdev operations * @cap_link_lanes_supported: indicates if the driver supports lanes @@ -624,6 +667,11 @@ struct ethtool_module_power_mode_params { * plugged-in. * @set_module_power_mode: Set the power mode policy for the plug-in module * used by the network device. + * @get_fp_param: Query the 802.1Q Frame Preemption parameters. + * @set_fp_param: Set the 802.1Q Frame Preemption parameters. + * @get_mm_state: Query the 802.3 MAC Merge layer state. + * @set_mm_cfg: Set the 802.3 MAC Merge layer parameters. + * @get_mm_stats: Query the 802.3 MAC Merge layer statistics. * * All operations are optional (i.e. the function pointer may be set * to %NULL) and callers must take this into account. Callers must @@ -760,6 +808,17 @@ struct ethtool_ops { int (*set_module_power_mode)(struct net_device *dev, const struct ethtool_module_power_mode_params *params, struct netlink_ext_ack *extack); + void (*get_fp_param)(struct net_device *dev, + struct ethtool_fp_param *params); + int (*set_fp_param)(struct net_device *dev, + const struct ethtool_fp_param *params, + struct netlink_ext_ack *extack); + void (*get_mm_state)(struct net_device *dev, + struct ethtool_mm_state *state); + int (*set_mm_cfg)(struct net_device *dev, struct ethtool_mm_cfg *cfg, + struct netlink_ext_ack *extack); + void (*get_mm_stats)(struct net_device *dev, + struct ethtool_mm_stats *stats); }; int ethtool_check_ops(const struct ethtool_ops *ops); diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 2d5741fd44bb..7a21fcb26a43 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -736,6 +736,21 @@ enum ethtool_module_power_mode { ETHTOOL_MODULE_POWER_MODE_HIGH, }; +/* Values from ieee8021FramePreemptionAdminStatus */ +enum ethtool_fp_admin_status { + ETHTOOL_FP_PARAM_ENTRY_ADMIN_STATUS_EXPRESS = 1, + ETHTOOL_FP_PARAM_ENTRY_ADMIN_STATUS_PREEMPTABLE = 2, +}; + +enum ethtool_mm_verify_status { + ETHTOOL_MM_VERIFY_STATUS_UNKNOWN, + ETHTOOL_MM_VERIFY_STATUS_INITIAL, + ETHTOOL_MM_VERIFY_STATUS_VERIFYING, + ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED, + ETHTOOL_MM_VERIFY_STATUS_FAILED, + ETHTOOL_MM_VERIFY_STATUS_DISABLED, +}; + /** * struct ethtool_gstrings - string set for data tagging * @cmd: Command number = %ETHTOOL_GSTRINGS diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index d2fb4f7be61b..658810274c49 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -49,6 +49,10 @@ enum { ETHTOOL_MSG_PHC_VCLOCKS_GET, ETHTOOL_MSG_MODULE_GET, ETHTOOL_MSG_MODULE_SET, + ETHTOOL_MSG_FP_GET, + ETHTOOL_MSG_FP_SET, + ETHTOOL_MSG_MM_GET, + ETHTOOL_MSG_MM_SET, /* add new constants above here */ __ETHTOOL_MSG_USER_CNT, @@ -94,6 +98,10 @@ enum { ETHTOOL_MSG_PHC_VCLOCKS_GET_REPLY, ETHTOOL_MSG_MODULE_GET_REPLY, ETHTOOL_MSG_MODULE_NTF, + ETHTOOL_MSG_FP_GET_REPLY, + ETHTOOL_MSG_FP_NTF, + ETHTOOL_MSG_MM_GET_REPLY, + ETHTOOL_MSG_MM_NTF, /* add new constants above here */ __ETHTOOL_MSG_KERNEL_CNT, @@ -862,6 +870,80 @@ enum { ETHTOOL_A_MODULE_MAX = (__ETHTOOL_A_MODULE_CNT - 1) }; +/* FRAME PREEMPTION (802.1Q) */ + +enum { + ETHTOOL_A_FP_PARAM_ENTRY_UNSPEC, + ETHTOOL_A_FP_PARAM_ENTRY_PRIO, /* u8 */ + ETHTOOL_A_FP_PARAM_ENTRY_ADMIN_STATUS, /* u8 */ + + /* add new constants above here */ + __ETHTOOL_A_FP_PARAM_ENTRY_CNT, + ETHTOOL_A_FP_PARAM_ENTRY_MAX = (__ETHTOOL_A_FP_PARAM_ENTRY_CNT - 1) +}; + +enum { + ETHTOOL_A_FP_PARAM_UNSPEC, + ETHTOOL_A_FP_PARAM_ENTRY, /* nest */ + + /* add new constants above here */ + __ETHTOOL_A_FP_PARAM_CNT, + ETHTOOL_A_FP_PARAM_MAX = (__ETHTOOL_A_FP_PARAM_CNT - 1) +}; + +enum { + ETHTOOL_A_FP_UNSPEC, + ETHTOOL_A_FP_HEADER, /* nest - _A_HEADER_* */ + ETHTOOL_A_FP_PARAM_TABLE, /* nest */ + ETHTOOL_A_FP_HOLD_ADVANCE, /* u32 */ + ETHTOOL_A_FP_RELEASE_ADVANCE, /* u32 */ + + /* add new constants above here */ + __ETHTOOL_A_FP_CNT, + ETHTOOL_A_FP_MAX = (__ETHTOOL_A_FP_CNT - 1) +}; + +/* MAC MERGE (802.3) */ + +enum { + ETHTOOL_A_MM_STAT_UNSPEC, + ETHTOOL_A_MM_STAT_PAD, + + /* aMACMergeFrameAssErrorCount */ + ETHTOOL_A_MM_STAT_REASSEMBLY_ERRORS, /* u64 */ + /* aMACMergeFrameSmdErrorCount */ + ETHTOOL_A_MM_STAT_SMD_ERRORS, /* u64 */ + /* aMACMergeFrameAssOkCount */ + ETHTOOL_A_MM_STAT_REASSEMBLY_OK, /* u64 */ + /* aMACMergeFragCountRx */ + ETHTOOL_A_MM_STAT_RX_FRAG_COUNT, /* u64 */ + /* aMACMergeFragCountTx */ + ETHTOOL_A_MM_STAT_TX_FRAG_COUNT, /* u64 */ + /* aMACMergeHoldCount */ + ETHTOOL_A_MM_STAT_HOLD_COUNT, /* u64 */ + + /* add new constants above here */ + __ETHTOOL_A_MM_STAT_CNT, + ETHTOOL_A_MM_STAT_MAX = (__ETHTOOL_A_MM_STAT_CNT - 1) +}; + +enum { + ETHTOOL_A_MM_UNSPEC, + ETHTOOL_A_MM_HEADER, /* nest - _A_HEADER_* */ + ETHTOOL_A_MM_VERIFY_STATUS, /* u8 */ + ETHTOOL_A_MM_VERIFY_DISABLE, /* u8 */ + ETHTOOL_A_MM_VERIFY_TIME, /* u32 */ + ETHTOOL_A_MM_SUPPORTED, /* u8 */ + ETHTOOL_A_MM_ENABLED, /* u8 */ + ETHTOOL_A_MM_ACTIVE, /* u8 */ + ETHTOOL_A_MM_ADD_FRAG_SIZE, /* u8 */ + ETHTOOL_A_MM_STATS, /* nest - _A_MM_STAT_* */ + + /* add new constants above here */ + __ETHTOOL_A_MM_CNT, + ETHTOOL_A_MM_MAX = (__ETHTOOL_A_MM_CNT - 1) +}; + /* generic netlink info */ #define ETHTOOL_GENL_NAME "ethtool" #define ETHTOOL_GENL_VERSION 1 diff --git a/net/ethtool/Makefile b/net/ethtool/Makefile index b76432e70e6b..31e056f17856 100644 --- a/net/ethtool/Makefile +++ b/net/ethtool/Makefile @@ -7,4 +7,5 @@ obj-$(CONFIG_ETHTOOL_NETLINK) += ethtool_nl.o ethtool_nl-y := netlink.o bitset.o strset.o linkinfo.o linkmodes.o \ linkstate.o debug.o wol.o features.o privflags.o rings.o \ channels.o coalesce.o pause.o eee.o tsinfo.o cabletest.o \ - tunnels.o fec.o eeprom.o stats.o phc_vclocks.o module.o + tunnels.o fec.o eeprom.o stats.o phc_vclocks.o module.o \ + fp.o mm.o diff --git a/net/ethtool/fp.c b/net/ethtool/fp.c new file mode 100644 index 000000000000..20f19d8c1461 --- /dev/null +++ b/net/ethtool/fp.c @@ -0,0 +1,295 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright 2022 NXP + */ +#include "common.h" +#include "netlink.h" + +struct fp_req_info { + struct ethnl_req_info base; +}; + +struct fp_reply_data { + struct ethnl_reply_data base; + struct ethtool_fp_param params; +}; + +#define FP_REPDATA(__reply_base) \ + container_of(__reply_base, struct fp_reply_data, base) + +const struct nla_policy ethnl_fp_get_policy[ETHTOOL_A_FP_HEADER + 1] = { + [ETHTOOL_A_FP_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), +}; + +static int fp_prepare_data(const struct ethnl_req_info *req_base, + struct ethnl_reply_data *reply_base, + struct genl_info *info) +{ + struct fp_reply_data *data = FP_REPDATA(reply_base); + struct net_device *dev = reply_base->dev; + int ret; + + if (!dev->ethtool_ops->get_fp_param) + return -EOPNOTSUPP; + + ret = ethnl_ops_begin(dev); + if (ret < 0) + return ret; + + dev->ethtool_ops->get_fp_param(dev, &data->params); + ethnl_ops_complete(dev); + + return 0; +} + +static int fp_reply_size(const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + int len = 0; + + len += nla_total_size(0); /* _FP_PARAM_ENTRY */ + len += nla_total_size(sizeof(u8)); /* _FP_PARAM_ENTRY_PRIO */ + len += nla_total_size(sizeof(u8)); /* _FP_PARAM_ENTRY_ADMIN_STATUS */ + len *= 8; /* 8 prios */ + len += nla_total_size(0); /* _FP_PARAM_TABLE */ + len += nla_total_size(sizeof(u32)); /* _FP_HOLD_ADVANCE */ + len += nla_total_size(sizeof(u32)); /* _FP_RELEASE_ADVANCE */ + + return len; +} + +static int fp_fill_reply(struct sk_buff *skb, + const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + const struct fp_reply_data *data = FP_REPDATA(reply_base); + const struct ethtool_fp_param *params = &data->params; + enum ethtool_fp_admin_status admin_status; + struct nlattr *nest_table, *nest_entry; + int prio; + int ret; + + if (nla_put_u32(skb, ETHTOOL_A_FP_HOLD_ADVANCE, params->hold_advance) || + nla_put_u32(skb, ETHTOOL_A_FP_RELEASE_ADVANCE, params->release_advance)) + return -EMSGSIZE; + + nest_table = nla_nest_start(skb, ETHTOOL_A_FP_PARAM_TABLE); + if (!nest_table) + return -EMSGSIZE; + + for (prio = 0; prio < 8; prio++) { + admin_status = (params->preemptable_prios & BIT(prio)) ? + ETHTOOL_FP_PARAM_ENTRY_ADMIN_STATUS_PREEMPTABLE : + ETHTOOL_FP_PARAM_ENTRY_ADMIN_STATUS_EXPRESS; + + nest_entry = nla_nest_start(skb, ETHTOOL_A_FP_PARAM_ENTRY); + if (!nest_entry) + goto nla_nest_cancel_table; + + if (nla_put_u8(skb, ETHTOOL_A_FP_PARAM_ENTRY_PRIO, prio)) + goto nla_nest_cancel_entry; + + if (nla_put_u8(skb, ETHTOOL_A_FP_PARAM_ENTRY_ADMIN_STATUS, + admin_status)) + goto nla_nest_cancel_entry; + + nla_nest_end(skb, nest_entry); + } + + nla_nest_end(skb, nest_table); + + return 0; + +nla_nest_cancel_entry: + nla_nest_cancel(skb, nest_entry); +nla_nest_cancel_table: + nla_nest_cancel(skb, nest_table); + return ret; +} + +const struct ethnl_request_ops ethnl_fp_request_ops = { + .request_cmd = ETHTOOL_MSG_FP_GET, + .reply_cmd = ETHTOOL_MSG_FP_GET_REPLY, + .hdr_attr = ETHTOOL_A_FP_HEADER, + .req_info_size = sizeof(struct fp_req_info), + .reply_data_size = sizeof(struct fp_reply_data), + + .prepare_data = fp_prepare_data, + .reply_size = fp_reply_size, + .fill_reply = fp_fill_reply, +}; + +static const struct nla_policy +ethnl_fp_set_param_entry_policy[ETHTOOL_A_FP_PARAM_ENTRY_MAX + 1] = { + [ETHTOOL_A_FP_PARAM_ENTRY_PRIO] = { .type = NLA_U8 }, + [ETHTOOL_A_FP_PARAM_ENTRY_ADMIN_STATUS] = { .type = NLA_U8 }, +}; + +static const struct nla_policy +ethnl_fp_set_param_table_policy[ETHTOOL_A_FP_PARAM_MAX + 1] = { + [ETHTOOL_A_FP_PARAM_ENTRY] = NLA_POLICY_NESTED(ethnl_fp_set_param_entry_policy), +}; + +const struct nla_policy ethnl_fp_set_policy[ETHTOOL_A_FP_MAX + 1] = { + [ETHTOOL_A_FP_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), + [ETHTOOL_A_FP_PARAM_TABLE] = NLA_POLICY_NESTED(ethnl_fp_set_param_table_policy), +}; + +static int fp_parse_param_entry(const struct nlattr *nest, + struct ethtool_fp_param *params, + u8 *seen_prios, bool *mod, + struct netlink_ext_ack *extack) +{ + struct nlattr *tb[ARRAY_SIZE(ethnl_fp_set_param_entry_policy)]; + u8 preemptable_prios = params->preemptable_prios; + u8 prio, admin_status; + int ret; + + if (!nest) + return 0; + + ret = nla_parse_nested(tb, + ARRAY_SIZE(ethnl_fp_set_param_entry_policy) - 1, + nest, ethnl_fp_set_param_entry_policy, + extack); + if (ret) + return ret; + + if (!tb[ETHTOOL_A_FP_PARAM_ENTRY_PRIO]) { + NL_SET_ERR_MSG_ATTR(extack, nest, + "Missing 'prio' attribute"); + return -EINVAL; + } + + if (!tb[ETHTOOL_A_FP_PARAM_ENTRY_ADMIN_STATUS]) { + NL_SET_ERR_MSG_ATTR(extack, nest, + "Missing 'admin_status' attribute"); + return -EINVAL; + } + + prio = nla_get_u8(tb[ETHTOOL_A_FP_PARAM_ENTRY_PRIO]); + if (prio >= 8) { + NL_SET_ERR_MSG_ATTR(extack, nest, + "Range exceeded for 'prio' attribute"); + return -ERANGE; + } + + if (*seen_prios & BIT(prio)) { + NL_SET_ERR_MSG_ATTR(extack, nest, + "Duplicate 'prio' attribute"); + return -EINVAL; + } + + *seen_prios |= BIT(prio); + + admin_status = nla_get_u8(tb[ETHTOOL_A_FP_PARAM_ENTRY_ADMIN_STATUS]); + switch (admin_status) { + case ETHTOOL_FP_PARAM_ENTRY_ADMIN_STATUS_PREEMPTABLE: + preemptable_prios |= BIT(prio); + break; + case ETHTOOL_FP_PARAM_ENTRY_ADMIN_STATUS_EXPRESS: + preemptable_prios &= ~BIT(prio); + break; + default: + NL_SET_ERR_MSG_ATTR(extack, nest, + "Unexpected value for 'admin_status' attribute"); + return -EINVAL; + } + + if (preemptable_prios != params->preemptable_prios) { + params->preemptable_prios = preemptable_prios; + *mod = true; + } + + return 0; +} + +static int fp_parse_param_table(const struct nlattr *nest, + struct ethtool_fp_param *params, bool *mod, + struct netlink_ext_ack *extack) +{ + u8 seen_prios = 0; + struct nlattr *n; + int rem, ret; + + if (!nest) + return 0; + + nla_for_each_nested(n, nest, rem) { + struct sched_entry *entry; + + if (nla_type(n) != ETHTOOL_A_FP_PARAM_ENTRY) { + NL_SET_ERR_MSG_ATTR(extack, n, + "Attribute is not of type 'entry'"); + continue; + } + + ret = fp_parse_param_entry(n, params, &seen_prios, mod, extack); + if (ret < 0) { + kfree(entry); + return ret; + } + } + + return 0; +} + +int ethnl_set_fp_param(struct sk_buff *skb, struct genl_info *info) +{ + struct netlink_ext_ack *extack = info->extack; + struct ethnl_req_info req_info = {}; + struct ethtool_fp_param params = {}; + struct nlattr **tb = info->attrs; + const struct ethtool_ops *ops; + struct net_device *dev; + bool mod = false; + int ret; + + ret = ethnl_parse_header_dev_get(&req_info, tb[ETHTOOL_A_FP_HEADER], + genl_info_net(info), extack, true); + if (ret) + return ret; + + dev = req_info.dev; + ops = dev->ethtool_ops; + + if (!ops->get_fp_param || !ops->set_fp_param) { + ret = -EOPNOTSUPP; + goto out_dev; + } + + rtnl_lock(); + ret = ethnl_ops_begin(dev); + if (ret) + goto out_rtnl; + + dev->ethtool_ops->get_fp_param(dev, ¶ms); + + ethnl_update_u32(¶ms.hold_advance, tb[ETHTOOL_A_FP_HOLD_ADVANCE], + &mod); + ethnl_update_u32(¶ms.release_advance, + tb[ETHTOOL_A_FP_RELEASE_ADVANCE], &mod); + + ret = fp_parse_param_table(tb[ETHTOOL_A_FP_PARAM_TABLE], ¶ms, &mod, + extack); + if (ret || !mod) + goto out_ops; + + ret = dev->ethtool_ops->set_fp_param(dev, ¶ms, extack); + if (ret) { + if (!extack->_msg) + NL_SET_ERR_MSG(extack, + "Failed to update frame preemption parameters"); + goto out_ops; + } + + ethtool_notify(dev, ETHTOOL_MSG_FP_NTF, NULL); + +out_ops: + ethnl_ops_complete(dev); +out_rtnl: + rtnl_unlock(); +out_dev: + dev_put(dev); + return ret; +} diff --git a/net/ethtool/mm.c b/net/ethtool/mm.c new file mode 100644 index 000000000000..d4731fb7aee4 --- /dev/null +++ b/net/ethtool/mm.c @@ -0,0 +1,228 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright 2022 NXP + */ +#include "common.h" +#include "netlink.h" + +struct mm_req_info { + struct ethnl_req_info base; +}; + +struct mm_reply_data { + struct ethnl_reply_data base; + struct ethtool_mm_state state; + struct ethtool_mm_stats stats; +}; + +#define MM_REPDATA(__reply_base) \ + container_of(__reply_base, struct mm_reply_data, base) + +#define ETHTOOL_MM_STAT_CNT \ + (__ETHTOOL_A_MM_STAT_CNT - (ETHTOOL_A_MM_STAT_PAD + 1)) + +const struct nla_policy ethnl_mm_get_policy[ETHTOOL_A_MM_HEADER + 1] = { + [ETHTOOL_A_MM_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy_stats), +}; + +static int mm_prepare_data(const struct ethnl_req_info *req_base, + struct ethnl_reply_data *reply_base, + struct genl_info *info) +{ + struct mm_reply_data *data = MM_REPDATA(reply_base); + struct net_device *dev = reply_base->dev; + const struct ethtool_ops *ops; + int ret; + + ops = dev->ethtool_ops; + + if (!ops->get_mm_state) + return -EOPNOTSUPP; + + ethtool_stats_init((u64 *)&data->stats, + sizeof(data->stats) / sizeof(u64)); + + ret = ethnl_ops_begin(dev); + if (ret < 0) + return ret; + + ops->get_mm_state(dev, &data->state); + + if (ops->get_mm_stats && (req_base->flags & ETHTOOL_FLAG_STATS)) + ops->get_mm_stats(dev, &data->stats); + + ethnl_ops_complete(dev); + + return 0; +} + +static int mm_reply_size(const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + int len = 0; + + len += nla_total_size(sizeof(u8)); /* _MM_VERIFY_STATUS */ + len += nla_total_size(sizeof(u32)); /* _MM_VERIFY_TIME */ + len += nla_total_size(sizeof(u8)); /* _MM_SUPPORTED */ + len += nla_total_size(sizeof(u8)); /* _MM_ENABLED */ + len += nla_total_size(sizeof(u8)); /* _MM_ACTIVE */ + len += nla_total_size(sizeof(u8)); /* _MM_ADD_FRAG_SIZE */ + + if (req_base->flags & ETHTOOL_FLAG_STATS) + len += nla_total_size(0) + /* _MM_STATS */ + nla_total_size_64bit(sizeof(u64)) * ETHTOOL_MM_STAT_CNT; + + return len; +} + +static int mm_put_stat(struct sk_buff *skb, u64 val, u16 attrtype) +{ + if (val == ETHTOOL_STAT_NOT_SET) + return 0; + if (nla_put_u64_64bit(skb, attrtype, val, ETHTOOL_A_MM_STAT_PAD)) + return -EMSGSIZE; + return 0; +} + +static int mm_put_stats(struct sk_buff *skb, + const struct ethtool_mm_stats *stats) +{ + struct nlattr *nest; + + nest = nla_nest_start(skb, ETHTOOL_A_MM_STATS); + if (!nest) + return -EMSGSIZE; + + if (mm_put_stat(skb, stats->MACMergeFrameAssErrorCount, + ETHTOOL_A_MM_STAT_REASSEMBLY_ERRORS) || + mm_put_stat(skb, stats->MACMergeFrameSmdErrorCount, + ETHTOOL_A_MM_STAT_SMD_ERRORS) || + mm_put_stat(skb, stats->MACMergeFrameAssOkCount, + ETHTOOL_A_MM_STAT_REASSEMBLY_OK) || + mm_put_stat(skb, stats->MACMergeFragCountRx, + ETHTOOL_A_MM_STAT_RX_FRAG_COUNT) || + mm_put_stat(skb, stats->MACMergeFragCountTx, + ETHTOOL_A_MM_STAT_TX_FRAG_COUNT) || + mm_put_stat(skb, stats->MACMergeHoldCount, + ETHTOOL_A_MM_STAT_HOLD_COUNT)) + goto err_cancel; + + nla_nest_end(skb, nest); + return 0; + +err_cancel: + nla_nest_cancel(skb, nest); + return -EMSGSIZE; +} + +static int mm_fill_reply(struct sk_buff *skb, + const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + const struct mm_reply_data *data = MM_REPDATA(reply_base); + const struct ethtool_mm_state *state = &data->state; + + if (nla_put_u8(skb, ETHTOOL_A_MM_VERIFY_STATUS, state->verify_status) || + nla_put_u32(skb, ETHTOOL_A_MM_VERIFY_TIME, state->verify_time) || + nla_put_u8(skb, ETHTOOL_A_MM_SUPPORTED, state->supported) || + nla_put_u8(skb, ETHTOOL_A_MM_ENABLED, state->enabled) || + nla_put_u8(skb, ETHTOOL_A_MM_ACTIVE, state->active) || + nla_put_u8(skb, ETHTOOL_A_MM_ADD_FRAG_SIZE, state->add_frag_size)) + return -EMSGSIZE; + + if (req_base->flags & ETHTOOL_FLAG_STATS && + mm_put_stats(skb, &data->stats)) + return -EMSGSIZE; + + return 0; +} + +const struct ethnl_request_ops ethnl_mm_request_ops = { + .request_cmd = ETHTOOL_MSG_MM_GET, + .reply_cmd = ETHTOOL_MSG_MM_GET_REPLY, + .hdr_attr = ETHTOOL_A_MM_HEADER, + .req_info_size = sizeof(struct mm_req_info), + .reply_data_size = sizeof(struct mm_reply_data), + + .prepare_data = mm_prepare_data, + .reply_size = mm_reply_size, + .fill_reply = mm_fill_reply, +}; + +const struct nla_policy ethnl_mm_set_policy[ETHTOOL_A_MM_MAX + 1] = { + [ETHTOOL_A_MM_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), + [ETHTOOL_A_MM_VERIFY_DISABLE] = { .type = NLA_U8 }, + [ETHTOOL_A_MM_VERIFY_TIME] = { .type = NLA_U32 }, + [ETHTOOL_A_MM_ENABLED] = { .type = NLA_U8 }, + [ETHTOOL_A_MM_ADD_FRAG_SIZE] = { .type = NLA_U8 }, +}; + +static void mm_state_to_cfg(const struct ethtool_mm_state *state, + struct ethtool_mm_cfg *cfg) +{ + cfg->verify_disable = + state->verify_status == ETHTOOL_MM_VERIFY_STATUS_DISABLED; + cfg->verify_time = state->verify_time; + cfg->enabled = state->enabled; + cfg->add_frag_size = state->add_frag_size; +} + +int ethnl_set_mm_cfg(struct sk_buff *skb, struct genl_info *info) +{ + struct netlink_ext_ack *extack = info->extack; + struct ethnl_req_info req_info = {}; + struct ethtool_mm_state state = {}; + struct nlattr **tb = info->attrs; + struct ethtool_mm_cfg cfg = {}; + const struct ethtool_ops *ops; + struct net_device *dev; + bool mod = false; + int ret; + + ret = ethnl_parse_header_dev_get(&req_info, tb[ETHTOOL_A_MM_HEADER], + genl_info_net(info), extack, true); + if (ret) + return ret; + + dev = req_info.dev; + ops = dev->ethtool_ops; + + if (!ops->get_mm_state || !ops->set_mm_cfg) { + ret = -EOPNOTSUPP; + goto out_dev; + } + + rtnl_lock(); + ret = ethnl_ops_begin(dev); + if (ret) + goto out_rtnl; + + ops->get_mm_state(dev, &state); + + mm_state_to_cfg(&state, &cfg); + + ethnl_update_bool(&cfg.verify_disable, tb[ETHTOOL_A_MM_VERIFY_DISABLE], + &mod); + ethnl_update_u32(&cfg.verify_time, tb[ETHTOOL_A_MM_VERIFY_TIME], &mod); + ethnl_update_bool(&cfg.enabled, tb[ETHTOOL_A_MM_ENABLED], &mod); + ethnl_update_u8(&cfg.add_frag_size, tb[ETHTOOL_A_MM_ADD_FRAG_SIZE], + &mod); + + ret = ops->set_mm_cfg(dev, &cfg, extack); + if (ret) { + if (!extack->_msg) + NL_SET_ERR_MSG(extack, + "Failed to update MAC merge configuration"); + goto out_ops; + } + + ethtool_notify(dev, ETHTOOL_MSG_MM_NTF, NULL); + +out_ops: + ethnl_ops_complete(dev); +out_rtnl: + rtnl_unlock(); +out_dev: + dev_put(dev); + return ret; +} diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index e26079e11835..82ad2bd92d70 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -286,6 +286,8 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_STATS_GET] = ðnl_stats_request_ops, [ETHTOOL_MSG_PHC_VCLOCKS_GET] = ðnl_phc_vclocks_request_ops, [ETHTOOL_MSG_MODULE_GET] = ðnl_module_request_ops, + [ETHTOOL_MSG_FP_GET] = ðnl_fp_request_ops, + [ETHTOOL_MSG_MM_GET] = ðnl_mm_request_ops, }; static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb) @@ -598,6 +600,8 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = { [ETHTOOL_MSG_EEE_NTF] = ðnl_eee_request_ops, [ETHTOOL_MSG_FEC_NTF] = ðnl_fec_request_ops, [ETHTOOL_MSG_MODULE_NTF] = ðnl_module_request_ops, + [ETHTOOL_MSG_FP_NTF] = ðnl_fp_request_ops, + [ETHTOOL_MSG_MM_NTF] = ðnl_mm_request_ops, }; /* default notification handler */ @@ -691,6 +695,8 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { [ETHTOOL_MSG_EEE_NTF] = ethnl_default_notify, [ETHTOOL_MSG_FEC_NTF] = ethnl_default_notify, [ETHTOOL_MSG_MODULE_NTF] = ethnl_default_notify, + [ETHTOOL_MSG_FP_NTF] = ethnl_default_notify, + [ETHTOOL_MSG_MM_NTF] = ethnl_default_notify, }; void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data) @@ -1020,6 +1026,38 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_module_set_policy, .maxattr = ARRAY_SIZE(ethnl_module_set_policy) - 1, }, + { + .cmd = ETHTOOL_MSG_FP_GET, + .doit = ethnl_default_doit, + .start = ethnl_default_start, + .dumpit = ethnl_default_dumpit, + .done = ethnl_default_done, + .policy = ethnl_fp_get_policy, + .maxattr = ARRAY_SIZE(ethnl_fp_get_policy) - 1, + }, + { + .cmd = ETHTOOL_MSG_FP_SET, + .flags = GENL_UNS_ADMIN_PERM, + .doit = ethnl_set_fp_param, + .policy = ethnl_fp_set_policy, + .maxattr = ARRAY_SIZE(ethnl_fp_set_policy) - 1, + }, + { + .cmd = ETHTOOL_MSG_MM_GET, + .doit = ethnl_default_doit, + .start = ethnl_default_start, + .dumpit = ethnl_default_dumpit, + .done = ethnl_default_done, + .policy = ethnl_mm_get_policy, + .maxattr = ARRAY_SIZE(ethnl_mm_get_policy) - 1, + }, + { + .cmd = ETHTOOL_MSG_MM_SET, + .flags = GENL_UNS_ADMIN_PERM, + .doit = ethnl_set_mm_cfg, + .policy = ethnl_mm_set_policy, + .maxattr = ARRAY_SIZE(ethnl_mm_set_policy) - 1, + }, }; static const struct genl_multicast_group ethtool_nl_mcgrps[] = { diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 1653fd2cf0cf..a2e56df74c85 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -371,6 +371,8 @@ extern const struct ethnl_request_ops ethnl_module_eeprom_request_ops; extern const struct ethnl_request_ops ethnl_stats_request_ops; extern const struct ethnl_request_ops ethnl_phc_vclocks_request_ops; extern const struct ethnl_request_ops ethnl_module_request_ops; +extern const struct ethnl_request_ops ethnl_fp_request_ops; +extern const struct ethnl_request_ops ethnl_mm_request_ops; extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1]; extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1]; @@ -409,6 +411,10 @@ extern const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_GROUPS + 1 extern const struct nla_policy ethnl_phc_vclocks_get_policy[ETHTOOL_A_PHC_VCLOCKS_HEADER + 1]; extern const struct nla_policy ethnl_module_get_policy[ETHTOOL_A_MODULE_HEADER + 1]; extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MODE_POLICY + 1]; +extern const struct nla_policy ethnl_fp_get_policy[ETHTOOL_A_FP_HEADER + 1]; +extern const struct nla_policy ethnl_fp_set_policy[ETHTOOL_A_FP_MAX + 1]; +extern const struct nla_policy ethnl_mm_get_policy[ETHTOOL_A_MM_HEADER + 1]; +extern const struct nla_policy ethnl_mm_set_policy[ETHTOOL_A_MM_MAX + 1]; int ethnl_set_linkinfo(struct sk_buff *skb, struct genl_info *info); int ethnl_set_linkmodes(struct sk_buff *skb, struct genl_info *info); @@ -428,6 +434,8 @@ int ethnl_tunnel_info_start(struct netlink_callback *cb); int ethnl_tunnel_info_dumpit(struct sk_buff *skb, struct netlink_callback *cb); int ethnl_set_fec(struct sk_buff *skb, struct genl_info *info); int ethnl_set_module(struct sk_buff *skb, struct genl_info *info); +int ethnl_set_fp_param(struct sk_buff *skb, struct genl_info *info); +int ethnl_set_mm_cfg(struct sk_buff *skb, struct genl_info *info); extern const char stats_std_names[__ETHTOOL_STATS_CNT][ETH_GSTRING_LEN]; extern const char stats_eth_phy_names[__ETHTOOL_A_STATS_ETH_PHY_CNT][ETH_GSTRING_LEN]; From patchwork Tue Aug 16 22:29:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12945339 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AC3FC2BB41 for ; Tue, 16 Aug 2022 22:29:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238018AbiHPW3p (ORCPT ); Tue, 16 Aug 2022 18:29:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238012AbiHPW3l (ORCPT ); Tue, 16 Aug 2022 18:29:41 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60064.outbound.protection.outlook.com [40.107.6.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B26617B2BC for ; Tue, 16 Aug 2022 15:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XwhIBZziYp6utMRH3bfjTz85LrzaQvRFvewJzw+u1WfHxRYq+EdvuZomuvZgc5VcA4GBKbxUEZmyfTZaqabiB0Nhq7n1JuN1eSPcgvoJ9lhFI5tQ5hftD2DIIx3ftkeIJsCkO2lZFaotWvUtxSnsnDGu436V656Q5Kxa7cx/qAP3jQnBMuxTkImaeg4pPeZ5+Srmk2cC1YqayR4b4GljxuhDLHj1wlQGsiS1vHBCDaTI+vaXEnLLCUOH4LUPurhwDMhxjuU+qnM4UA3uMgiUDTcLY8smGigkMbaQJ2RC+uIPfQTM7heVLavoqNZeff6yca8se2sjQF3R9MdrDH52Fw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ci3BGnksxk1cuXJM6Ng9LUvnTbQwyddUiYsntfB15j8=; b=Nj1gxt/mGbDN/2l9Kis9DQO14MBZlGmb1CZRNUwuu6uqCn7nESHAbvgBuelK8bSGaxB+ikjNzy/BMHUsmOHQUbV6OQDpn06CR48npyKE0+f6UknAC/5e5XEe/3fgiYX8ezARziTmbYb+UHUOjADPuADw9NaxFgNUvvMG/Me1GblmGir0g0DgnUTlw4lK/5dQRoGeGg/TLlE7+ob4HxZQ4neESRoDzGf1kT6WdL4IL3CiJ1IwZj3N2kJgRR+UMdgOaMn4dR8laB6qvuqwmLaOhD+e0ULKKwT4WWhufDw1FLCMqafOQbuwWb3xMOMgsfEhR2TUbO9J7l16KOngW8cJ7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ci3BGnksxk1cuXJM6Ng9LUvnTbQwyddUiYsntfB15j8=; b=bFo2J9XgJD1KBTaE7IkAd5gtgY9o308iJ7dsw3ne2N1jgCjDduQU9BUB1nbAGsQLaPiXs7CFJ/pzuX1CTedter2HlMiIV77KfW/RS1Ur5FgGhBVt1PMfHpoE/t5eTA9KtprWVL9UZNf0xIgnzTeEluGr5/+149quQtPcK/O7tiM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8618.eurprd04.prod.outlook.com (2603:10a6:20b:439::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Tue, 16 Aug 2022 22:29:32 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 22:29:32 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes Subject: [RFC PATCH net-next 3/7] net: ethtool: stats: make stats_put_stats() take input from multiple sources Date: Wed, 17 Aug 2022 01:29:16 +0300 Message-Id: <20220816222920.1952936-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816222920.1952936-1-vladimir.oltean@nxp.com> References: <20220816222920.1952936-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0021.eurprd05.prod.outlook.com (2603:10a6:800:92::31) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 651d908d-e58d-4626-6342-08da7fd6ca9d X-MS-TrafficTypeDiagnostic: AM9PR04MB8618:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AVirBR+B/p8w249Jqff5u7xJJKJSisWRA4p4OXWD2tRTxq9hoKShkswI/sdMk0G66h9Cjvnxget4RjznoDUVZxTEXAaxLpnqniv2ajylb6euBPgBMWthON24YeWrh/ku0NSoS0Pi+FQ/pOXfbusu06Qs921Cb4TZqWuDiikjKa4vFqkHJNo/e+rU8XQAB55kqZFO/Ldcgt0k38n1jEiXOrSkkSFfOudN5nncSa/3LvIP/cxhQ+8OYeo9gO4Ib0UJP957q0KLnSuvBFouafNAKneuoLOKg+BsiFsPK1CH0/gQ/rj6m4u/sFa6Gl1rVdKfmafZkp2FL0r9lq+IaosQbyWlfJxgEb+QLhJfVMZ99c4d8PvC9AG/s3sxUWsLJSTj5KW2nP+prahMTQhmz+erm7oTLaEaTvG7WTGuKfGoLYBL19heIdsLMxn0J5cdODFwrz3r1ZOjVleAXg9dCU9yP1gdR3j2kolIHAwXirbXpZdYRkX9WFs0EICsFWnAkPcvtI3saGapsSKqO7JiMOp5RC3+CxudOB8jw2NIxbu/LOQ8OLgiiKPpgn9kERUixdeJ8evrxhXPC1/7JeFtTo0ZfNCzSa4luj0JvpFJKbr2Oqh6rMJ66pcdkrp8wn9s9UG4btHTre1IJEsiJRzzGGW6+bsVzrw5/cQ6mkwoCGa3uiQrbe2B/ZkdArZp7UUXz3l67A1BTCXkjy35qXyfCx3U8+Tv5VYy92hk8EQolphr1P4Lt1FXI2fe6IxO82W6lplTSbhZiXxT2M2mLU9DKSr80ZkjrTYQnISv4+TxxuRskFtM1SAwt5oFcdVGXQD4Q2RWlh8k9et7ovds50rGJstEjQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(136003)(366004)(346002)(39860400002)(376002)(66946007)(44832011)(316002)(1076003)(66556008)(8676002)(83380400001)(41300700001)(6666004)(6916009)(4326008)(2906002)(36756003)(54906003)(186003)(2616005)(38100700002)(26005)(38350700002)(30864003)(6506007)(6512007)(66476007)(6486002)(8936002)(86362001)(478600001)(52116002)(5660300002)(44824005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gmPGCsKd7k1pZPMJCtd4tuWLUbyBMMFE7WENMlLJIoKb9vui2iQ2mfij+G7GohpRxAZA6pfX/nCnK9swoR1S2iOgaCXgMgwVCN/Yn+XWVGZXDHlOY5NSmzhtOCYc+Ltj7M1lq3LGmanb+7tBrGZIleaTGHQaYkf+84NJ/jnSuAD7aj0MI8Fd5FeZ6wz4OCAu5fQ0tgEKQe9Q2BeJ+q/6kL1LLSRxNk+r5IVsBVoI54VLCx4I7lmym1/lSrDGTxfYjiM0tsEPPmnN6km0oFLNQ6pF2oRWikqZgJMeLxWjakbsaGun3DTLtyS2mRlvfT+42Pt7WE/jiomrNuhabbNRbKU/ib58rt4Ff27oEjyaetwnMtI/D4k8Yo5+1ik9pbJl1sEFhkSevFoUKjJifBMsCWIqQgcP+P1E/t/qE63x7hmTUCu9S852QrpVEzE5B2EVduS4Ut8ISqoogJzQLx0fMaRIpGRfM4zNX6gESs1wMjeVlKXBH6s/uNDx/c1YHAQR1l1sSkyZXJcD3U/VRXrRV+qI+3Ubr0nbUPwhk6+uk9F4eDfR9qQGF0k81l+WBjz4wUAAZEmkZ1k4H6mqaEdRqIcbwxqZKqmL+4eubGuOfamGCTaiPY0GPepg0nsyK9VMGGLF33hNAHI2QYxDNvuWPoGx2nyzlUvbpU8MXUpSN45GwJNSj8v0AFfRSmNmjkRk1EZv+1w3z5HvQDhB43UghBfaxTObUCdHyBECRj8w4hpG83ckO0RfX/5uYSMPTdUSAyVTSoavzhzjWz0XaYN4Xq+Vds+FYxyKcFI5grP1CtixMtOUqLiCH8yoioUfk+1gqgN9js0+Vg8inA/7zCPY9cGUhkQNDusUocESqrtyS8wFJclNyTKRoDt9lgNUS2LOoSLUNkJ5EK/VTSxoBAPPxAbVqJzD3QyifJfVmVhSH3AGxlXN1DK+A59C7NzwKRJyG/z0ykjICjXdUmwkd6C8JdYWL3sU2aTITJJQxozLA879MVSvsGiIBmkU06QnS07AARxjdsZuW7hNmLcwKXnCv1LZS5oo8Zm272Ojxcsa5vKUqtfolbGTLJzX5XupkO0zNLK2utRlptwQMHYHENXRG1ZQPjdj6buKklytajjRwPJHg5bNV3nbYxwO+LxpMmDgWQiuP77NqlNNyyTFYQY8ybKiYSFrPS/F/HCSWBrXi7/wFA6hHBl8o6bsT0/V4719Ph809Yvat40KdRMqs69lgF93FXmDPhTmW0ooBppBsxe7lk3D1hRI6fSWHMJ1zfX3Ma3/u0HhSQFeMMERzwd1oMIXoKXNRyBaPK2tXk9hd3Qz5pMIkWpKpsx1n4XFSoTEdHhueMeMKYezTYN043qKvfx62EjzURSakBCr6mPEaJgV5Ov/HFkErXnZ08knPbJQTyhtd3Kk1zb9mHMeqL1QoO6kLSkA/zFMImHt8rJ5MtGD26r2T/DWRaxu/+tEVLCMYab/gVx7YG3VeUIrAZmbg5FgwwvS90bPXU1XnVO0GCAzumWWQA7vztc69b1nPCRUprIS0NUcWwtHtzm/5oaDtHaZKXIPsw7oQDP0uvrhtC7MK4Le+vp3yNtuQKZOwPsnOenlznIOmtfXHVQFFqUzOg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 651d908d-e58d-4626-6342-08da7fd6ca9d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 22:29:32.7418 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hU2if1zuvAn7vIf6V8/R0K1tmDdH3QTSJJVWT5WedbhkGg6XS0ckDonSYp4+BbN9D+f9scM9+VBi1O8DKlF/TA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8618 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC IEEE 802.3 defines a MAC merge layer, for supporting the 802.1Q Frame Preemption capability. Beyond the MAC merge layer there are 2 distinct MACs, one is for express traffic (eMAC, aka the good old MAC that the Linux network stack knows about) and the other is for preemptable traffic (pMAC). The pMAC is a MAC in its own right, and has a full set of statistics that can be exposed through the standardized ethtool counters (RMON, 802.3 etc). In preparation for extending struct stats_reply_data to store both the eMAC and the pMAC stats structures, modify stats_put_stats() to not assume that we only care about the eMAC stats. Instead, we will introduce separate ops for pMAC stats, and put those stats into separate netlink attributes, and take them from different instances of the same structure types as in the case of the eMAC. Signed-off-by: Vladimir Oltean --- net/ethtool/stats.c | 148 +++++++++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 62 deletions(-) diff --git a/net/ethtool/stats.c b/net/ethtool/stats.c index a20e0a24ff61..8d4d3c70c0a4 100644 --- a/net/ethtool/stats.c +++ b/net/ethtool/stats.c @@ -9,6 +9,11 @@ struct stats_req_info { DECLARE_BITMAP(stat_mask, __ETHTOOL_STATS_CNT); }; +struct rmon_stats_put_ctx { + const struct ethtool_rmon_stats *rmon_stats; + const struct ethtool_rmon_hist_range *rmon_ranges; +}; + #define STATS_REQINFO(__req_base) \ container_of(__req_base, struct stats_req_info, base) @@ -110,8 +115,11 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base, const struct stats_req_info *req_info = STATS_REQINFO(req_base); struct stats_reply_data *data = STATS_REPDATA(reply_base); struct net_device *dev = reply_base->dev; + const struct ethtool_ops *ops; int ret; + ops = dev->ethtool_ops; + ret = ethnl_ops_begin(dev); if (ret < 0) return ret; @@ -122,18 +130,18 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base, memset(&data->stats, 0xff, sizeof(data->stats)); if (test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask) && - dev->ethtool_ops->get_eth_phy_stats) - dev->ethtool_ops->get_eth_phy_stats(dev, &data->phy_stats); + ops->get_eth_phy_stats) + ops->get_eth_phy_stats(dev, &data->phy_stats); if (test_bit(ETHTOOL_STATS_ETH_MAC, req_info->stat_mask) && - dev->ethtool_ops->get_eth_mac_stats) - dev->ethtool_ops->get_eth_mac_stats(dev, &data->mac_stats); + ops->get_eth_mac_stats) + ops->get_eth_mac_stats(dev, &data->mac_stats); if (test_bit(ETHTOOL_STATS_ETH_CTRL, req_info->stat_mask) && - dev->ethtool_ops->get_eth_ctrl_stats) - dev->ethtool_ops->get_eth_ctrl_stats(dev, &data->ctrl_stats); + ops->get_eth_ctrl_stats) + ops->get_eth_ctrl_stats(dev, &data->ctrl_stats); if (test_bit(ETHTOOL_STATS_RMON, req_info->stat_mask) && - dev->ethtool_ops->get_rmon_stats) - dev->ethtool_ops->get_rmon_stats(dev, &data->rmon_stats, - &data->rmon_ranges); + ops->get_rmon_stats) + ops->get_rmon_stats(dev, &data->rmon_stats, + &data->rmon_ranges); ethnl_ops_complete(dev); return 0; @@ -212,76 +220,82 @@ static int stat_put(struct sk_buff *skb, u16 attrtype, u64 val) return 0; } -static int stats_put_phy_stats(struct sk_buff *skb, - const struct stats_reply_data *data) +static int stats_put_phy_stats(struct sk_buff *skb, const void *src) { + const struct ethtool_eth_phy_stats *phy_stats = src; + if (stat_put(skb, ETHTOOL_A_STATS_ETH_PHY_5_SYM_ERR, - data->phy_stats.SymbolErrorDuringCarrier)) + phy_stats->SymbolErrorDuringCarrier)) return -EMSGSIZE; + return 0; } -static int stats_put_mac_stats(struct sk_buff *skb, - const struct stats_reply_data *data) +static int stats_put_mac_stats(struct sk_buff *skb, const void *src) { + const struct ethtool_eth_mac_stats *mac_stats = src; + if (stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_2_TX_PKT, - data->mac_stats.FramesTransmittedOK) || + mac_stats->FramesTransmittedOK) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_3_SINGLE_COL, - data->mac_stats.SingleCollisionFrames) || + mac_stats->SingleCollisionFrames) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_4_MULTI_COL, - data->mac_stats.MultipleCollisionFrames) || + mac_stats->MultipleCollisionFrames) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_5_RX_PKT, - data->mac_stats.FramesReceivedOK) || + mac_stats->FramesReceivedOK) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_6_FCS_ERR, - data->mac_stats.FrameCheckSequenceErrors) || + mac_stats->FrameCheckSequenceErrors) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_7_ALIGN_ERR, - data->mac_stats.AlignmentErrors) || + mac_stats->AlignmentErrors) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_8_TX_BYTES, - data->mac_stats.OctetsTransmittedOK) || + mac_stats->OctetsTransmittedOK) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_9_TX_DEFER, - data->mac_stats.FramesWithDeferredXmissions) || + mac_stats->FramesWithDeferredXmissions) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_10_LATE_COL, - data->mac_stats.LateCollisions) || + mac_stats->LateCollisions) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_11_XS_COL, - data->mac_stats.FramesAbortedDueToXSColls) || + mac_stats->FramesAbortedDueToXSColls) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_12_TX_INT_ERR, - data->mac_stats.FramesLostDueToIntMACXmitError) || + mac_stats->FramesLostDueToIntMACXmitError) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_13_CS_ERR, - data->mac_stats.CarrierSenseErrors) || + mac_stats->CarrierSenseErrors) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_14_RX_BYTES, - data->mac_stats.OctetsReceivedOK) || + mac_stats->OctetsReceivedOK) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_15_RX_INT_ERR, - data->mac_stats.FramesLostDueToIntMACRcvError) || + mac_stats->FramesLostDueToIntMACRcvError) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_18_TX_MCAST, - data->mac_stats.MulticastFramesXmittedOK) || + mac_stats->MulticastFramesXmittedOK) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_19_TX_BCAST, - data->mac_stats.BroadcastFramesXmittedOK) || + mac_stats->BroadcastFramesXmittedOK) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_20_XS_DEFER, - data->mac_stats.FramesWithExcessiveDeferral) || + mac_stats->FramesWithExcessiveDeferral) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_21_RX_MCAST, - data->mac_stats.MulticastFramesReceivedOK) || + mac_stats->MulticastFramesReceivedOK) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_22_RX_BCAST, - data->mac_stats.BroadcastFramesReceivedOK) || + mac_stats->BroadcastFramesReceivedOK) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_23_IR_LEN_ERR, - data->mac_stats.InRangeLengthErrors) || + mac_stats->InRangeLengthErrors) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_24_OOR_LEN, - data->mac_stats.OutOfRangeLengthField) || + mac_stats->OutOfRangeLengthField) || stat_put(skb, ETHTOOL_A_STATS_ETH_MAC_25_TOO_LONG_ERR, - data->mac_stats.FrameTooLongErrors)) + mac_stats->FrameTooLongErrors)) return -EMSGSIZE; + return 0; } -static int stats_put_ctrl_stats(struct sk_buff *skb, - const struct stats_reply_data *data) +static int stats_put_ctrl_stats(struct sk_buff *skb, const void *src) { + const struct ethtool_eth_ctrl_stats *ctrl_stats = src; + if (stat_put(skb, ETHTOOL_A_STATS_ETH_CTRL_3_TX, - data->ctrl_stats.MACControlFramesTransmitted) || + ctrl_stats->MACControlFramesTransmitted) || stat_put(skb, ETHTOOL_A_STATS_ETH_CTRL_4_RX, - data->ctrl_stats.MACControlFramesReceived) || + ctrl_stats->MACControlFramesReceived) || stat_put(skb, ETHTOOL_A_STATS_ETH_CTRL_5_RX_UNSUP, - data->ctrl_stats.UnsupportedOpcodesReceived)) + ctrl_stats->UnsupportedOpcodesReceived)) return -EMSGSIZE; + return 0; } @@ -322,33 +336,34 @@ static int stats_put_rmon_hist(struct sk_buff *skb, u32 attr, const u64 *hist, return -EMSGSIZE; } -static int stats_put_rmon_stats(struct sk_buff *skb, - const struct stats_reply_data *data) +static int stats_put_rmon_stats(struct sk_buff *skb, const void *src) { + const struct ethtool_rmon_hist_range *rmon_ranges; + const struct ethtool_rmon_stats *rmon_stats; + const struct rmon_stats_put_ctx *ctx = src; + + rmon_stats = ctx->rmon_stats; + rmon_ranges = ctx->rmon_ranges; + if (stats_put_rmon_hist(skb, ETHTOOL_A_STATS_GRP_HIST_RX, - data->rmon_stats.hist, data->rmon_ranges) || + rmon_stats->hist, rmon_ranges) || stats_put_rmon_hist(skb, ETHTOOL_A_STATS_GRP_HIST_TX, - data->rmon_stats.hist_tx, data->rmon_ranges)) + rmon_stats->hist_tx, rmon_ranges)) return -EMSGSIZE; if (stat_put(skb, ETHTOOL_A_STATS_RMON_UNDERSIZE, - data->rmon_stats.undersize_pkts) || + rmon_stats->undersize_pkts) || stat_put(skb, ETHTOOL_A_STATS_RMON_OVERSIZE, - data->rmon_stats.oversize_pkts) || - stat_put(skb, ETHTOOL_A_STATS_RMON_FRAG, - data->rmon_stats.fragments) || - stat_put(skb, ETHTOOL_A_STATS_RMON_JABBER, - data->rmon_stats.jabbers)) + rmon_stats->oversize_pkts) || + stat_put(skb, ETHTOOL_A_STATS_RMON_FRAG, rmon_stats->fragments) || + stat_put(skb, ETHTOOL_A_STATS_RMON_JABBER, rmon_stats->jabbers)) return -EMSGSIZE; return 0; } -static int stats_put_stats(struct sk_buff *skb, - const struct stats_reply_data *data, - u32 id, u32 ss_id, - int (*cb)(struct sk_buff *skb, - const struct stats_reply_data *data)) +static int stats_put_stats(struct sk_buff *skb, const void *src, u32 id, u32 ss_id, + int (*cb)(struct sk_buff *skb, const void *src)) { struct nlattr *nest; @@ -360,7 +375,7 @@ static int stats_put_stats(struct sk_buff *skb, nla_put_u32(skb, ETHTOOL_A_STATS_GRP_SS_ID, ss_id)) goto err_cancel; - if (cb(skb, data)) + if (cb(skb, src)) goto err_cancel; nla_nest_end(skb, nest); @@ -380,20 +395,29 @@ static int stats_fill_reply(struct sk_buff *skb, int ret = 0; if (!ret && test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask)) - ret = stats_put_stats(skb, data, ETHTOOL_STATS_ETH_PHY, + ret = stats_put_stats(skb, &data->phy_stats, + ETHTOOL_STATS_ETH_PHY, ETH_SS_STATS_ETH_PHY, stats_put_phy_stats); if (!ret && test_bit(ETHTOOL_STATS_ETH_MAC, req_info->stat_mask)) - ret = stats_put_stats(skb, data, ETHTOOL_STATS_ETH_MAC, + ret = stats_put_stats(skb, &data->mac_stats, + ETHTOOL_STATS_ETH_MAC, ETH_SS_STATS_ETH_MAC, stats_put_mac_stats); if (!ret && test_bit(ETHTOOL_STATS_ETH_CTRL, req_info->stat_mask)) - ret = stats_put_stats(skb, data, ETHTOOL_STATS_ETH_CTRL, + ret = stats_put_stats(skb, &data->ctrl_stats, + ETHTOOL_STATS_ETH_CTRL, ETH_SS_STATS_ETH_CTRL, stats_put_ctrl_stats); - if (!ret && test_bit(ETHTOOL_STATS_RMON, req_info->stat_mask)) - ret = stats_put_stats(skb, data, ETHTOOL_STATS_RMON, + if (!ret && test_bit(ETHTOOL_STATS_RMON, req_info->stat_mask)) { + struct rmon_stats_put_ctx ctx = { + .rmon_stats = &data->rmon_stats, + .rmon_ranges = data->rmon_ranges, + }; + + ret = stats_put_stats(skb, &ctx, ETHTOOL_STATS_RMON, ETH_SS_STATS_RMON, stats_put_rmon_stats); + } return ret; } From patchwork Tue Aug 16 22:29:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12945337 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68688C25B0E for ; Tue, 16 Aug 2022 22:29:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238009AbiHPW3m (ORCPT ); Tue, 16 Aug 2022 18:29:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237665AbiHPW3l (ORCPT ); Tue, 16 Aug 2022 18:29:41 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60064.outbound.protection.outlook.com [40.107.6.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37100796A5 for ; Tue, 16 Aug 2022 15:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PQIafFKeFhOtnUF54M2C5FQXlmD1GoNxLKuB3tTH7VGziPoeTIFQhAs8MQs3Hp/TumU4inRsSa5Jc6MpH3HSPbdsKO2MRtNfARbrZge4k28f6YMBPq0909WGboN+20aB4rMmPhXIqVsy78NtNa+fqjd5nT91GbGKu0UYPmJSxwHuoNkmAWzMTphA37VjqbCgNWsZoAE0wH2tpSdjlTd15tAvbLWTwfXULGns3zuYAvEjlTWF1SyD/2zb8ENcrru4kVh4+wvivrwHqhgKkF1nLggOtewrbVtUszpRgcS4SpA/WkCUr2kqkiFUtOdTrcuD3XYX2a7acdfHpvW2h4GoFw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=V7mtKcvUX2AZB2De/ByCccCMyDQrteS3klEW3zAm5+U=; b=NEOFMwgI9xB6PxPllobCI+6MiOwzZgh8TmowLTbTgC0zBN3ZGuMW96FzrXi5K++pPsonjhFMY8XTjEpyWwjqHEJjTCOu5bMKjlFgW8wh2idVSPVGXe/I/9h/JmbOAPQp0MrrwEDcjlV71WdqA/WYBY4ZOIbK0OFZzxESHoXF5vILu56DbG34jguCUdljSBt+plgQR6VszlkKhIyiTlG+p7pbWTp2M7s0tZsAEQ9VI+q58ZHUvJfUjpnX3fSm/qNvZTFMH0h2RxMjk6axn3aJJyX5YVJZOQGbNDAatjODbvxwlS3fKRXxDJomApSQqmrqxMw9s46kU+xyyoL2ZPxzHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V7mtKcvUX2AZB2De/ByCccCMyDQrteS3klEW3zAm5+U=; b=egyPUWINOLwKkKtga6X4/Pq5DurQTv+Jj+D0rRQzr85IKq3Y7mI+sKsIehn3eD0s2fv6SNeQQZVTaqAPJLFhh4PyLwTVi4Zi/z8bIBX3eukQMzRqOd3GJPA8RfmKNP2wp6jemzs91FVZ6Ht1DHNLO4UQDuvPPXNzR1yGXrvSc3U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8618.eurprd04.prod.outlook.com (2603:10a6:20b:439::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Tue, 16 Aug 2022 22:29:33 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 22:29:33 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes Subject: [RFC PATCH net-next 4/7] net: ethtool: stats: replicate standardized counters for the pMAC Date: Wed, 17 Aug 2022 01:29:17 +0300 Message-Id: <20220816222920.1952936-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816222920.1952936-1-vladimir.oltean@nxp.com> References: <20220816222920.1952936-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0021.eurprd05.prod.outlook.com (2603:10a6:800:92::31) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c309cca-4910-4d50-46f2-08da7fd6cb25 X-MS-TrafficTypeDiagnostic: AM9PR04MB8618:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iopOmuMz1kkzFQZt7F5cQzZIqPM0ucHKT16rNg2iYyjgFTSzvDYh/BH38ORL1Xr2+LLiGVjQn5TTxT/TqPqFwRujlGLp7eCbQrVfYj5jXabCBQS4PNWKwfMsS64kneB0lFDno3bh3M7YkhjKjtYFRsUw/4KZ2kYkG/0Kcnnw7J/7w79AGuz/lJKqRRF+ly89oeKkIUhmrwtQqxI0U0TNcOwV3SeSpiLpLtZ0Uc3fvjzMDunXF8ePyNF71ZI2jh0Zeho4HuN+lJ7s5VOhGwa7UwVMeAAVSNc1+PVVjIOMFK6gOxxh27i+CspIQ5QsTQ8QQxcrTMOVqpEjVMvd7hjMouXOPMGDQBNp/ds9Na5mbGKG4v+zwJj8KwfNn3avrjrv5E75XRishGNDIHGa60j3WYMJJtcbofVaqUGEeoBlxKxEQOiQ+Pi1cNSgHWH3mobX1QmP/8/gMX+wyvRw6+qG/cUOfKyq96Gp4RGuHGDXTCj31A9LQg9I08LCFmopfg7mE1cDb5rSCc1HTdRjr7by4g840PotyI086lUOvSI8v80+csFgWMqns7GgQxi/4ZkSkLZfFE2hlP2iHq3OIfUWjir8SX5/FLHAv/mlvOi3JUnKugIgWwbloMl8Yi96576SThxpoEB2kIdKHMRtwA+/n0ZqEZ+/fxhrQ2gzHyLSlVOApqhaRJX+aizpe2uCffIrxI0IQXweVWu4bPrCpf1SThdQNZmbN4eE0fH8rONPRRqx7Amg/5A0g2vb3Le7h+0/FHD38Oe8NFfNf30qQ2pnfH6gzM3noR7dtZ0AaoLWuEo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(136003)(366004)(346002)(39860400002)(376002)(66946007)(44832011)(316002)(1076003)(66556008)(8676002)(41300700001)(6666004)(6916009)(4326008)(2906002)(36756003)(54906003)(186003)(2616005)(38100700002)(26005)(38350700002)(6506007)(6512007)(66476007)(6486002)(8936002)(86362001)(478600001)(52116002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NloW9e60JuGrHsaQKphtk2nQ+Nr27nTMbLEm7WIogbapiU5KflJItyaaw7wNfc0+EIhVvqheAYk0GupqLDbl6HjahilO1M5VitOYgs/0r/w4sCPCoua/Bsio0eppyG+1we6Ya+ms9ylhYSsrMCeyQ09KrzLMamWoekCrQABEZNELfvTJp5teUCxGGDlHCk/eqx8hNMVwVIoP4v6kWYnA2m7A8VOr56CJbA0UreICzU3f9gTPVFtDGX7Mz/uYf0zeC/6QB+uAicAUMUfPHjrL5HfRfTCcpcjF+BJHFD2RKt2YLhGUptdxlKm0g+xHBkQCnI/rvLNPMLTiWEz/7wem/nVsa81rAjTshb2l3DT4QstT7NRyR7aoXGfeGU+6A1ZK4MOzgr98z8bDSnhVfNWD2sY2ElFkADwQLG9w5b8D5qu5Qmbxyi29VCPaDlNgSgy13+cGHCl591tI5t63Co8gngjit/Ky4IE0JSsoSouXUsX9ylLHh4oiZlO/0QV5I5uct9txqE7vP+Gu62yM0hJA9JrJHGk21wl0X6AGpeFSASd1vdU1UbMeuVd2m8Ng0ZGb/6g6zUVgUO/M31aSpar0cC22f9SkVL7s0dyNOnqvrNtyBOAp56x+ppnmJYpdBLCh9LPtG2KAfFiW7xRqYtzg5+Pv2IbEFQzM1jhdLKMB4yQ0jCJUoz8pt1fY6bAkJCeAw/y7P97458JYSsrzPICHkyRYN7um+gjKM3zSclPXZpWJXnZWFylpfH2phJkiMa1sUsuNFWrsgzFXrni1sQIEl1Dv5+VcgvAs1vObNK99zNcfFGNS/yRxCSPXcZ9sCoRqC1KU7KrMEZJw6QW3z3jPvOZ5NBVRTietIsCkjTZCBagCrn/9XMWvh/Uak6HSFbcqkLO/ckrBlniJbeKvxId4rUTFLsc0tBx0XK2cGL3Z+iTfQLUT/ed1E8ZY4cmAAv+Xuz2pbBZ1wIr2yhnlFx0VMURKoJQJNW8aAZujGB/U12++4v89/o2N//9umTTauIOkJgzxUprMHBV9eXG/i6XlP5ZzJ8F7HNNPrzzLvRf78xD2YaOS77NZdBnIQVJgWxg/oKJvbpjexmhGAsfKNvWmiza0236Ijn9e67smsl3xqZbYDsdXNO4AXQz/5enmsB5GL0g/kCUfJF59E911DFHef7OPzlGg8WrD8aNsOSosA0LGPrjxW8ZDNtIHnbGnY6fmezJXPks8M3eOoYJnnxHcNm3UlMFw1pFOYal5ac7wipZIQnq9lnAFmXr2AysV8KBWkPvzS5ol9sx4EMfDCsw/UTBa4U917rEzW8ez7BTlvlgbPsdOTTiZITDyqUUEXU2Ige4z6r7psigC3hgvRdJM0nIr0w5vsPac+f62uBnCK00c8hr0GqLZtJWhqIzQ6boM069Z7Whp4VJAicGv+xlBpIDpr8vZpxok0u5YAMPxDtmpcOatuRTLNffgMpH5I+bHw3AZtjaloBkomLZH3a3dUA0jwfQGvrjV36qn0LidkIjJ48eQPcsiwr6xs9iVwtQSdv+qx54aY+Ya12gveXsMQV7hX5dV1bibURy8GFG+Y7eLwk3/CW2nS3fojkZnqfmLiR3kdy6crbpuNmy3UxpOAw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c309cca-4910-4d50-46f2-08da7fd6cb25 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 22:29:33.6011 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BmkYy8/juBtals8MRoRmFoabpR1n2BpU940/bwT8csgN+CtE68+/y10CzH413c5xUX6nRUAQQ1ZTfCCI3mvbNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8618 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Devices supporting a MAC Merge layer will have a second Ethernet MAC per port which handles preemptable traffic. This has all the same counters as the regular (express) MAC, so export 4 new groups of statistics for it, which have all the same structure as the ones for the eMAC, except for different names. Signed-off-by: Vladimir Oltean --- include/linux/ethtool.h | 9 ++++ include/uapi/linux/ethtool_netlink.h | 4 ++ net/ethtool/stats.c | 70 ++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index fa504dd22bf6..ce3b118bcf19 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -802,6 +802,15 @@ struct ethtool_ops { void (*get_rmon_stats)(struct net_device *dev, struct ethtool_rmon_stats *rmon_stats, const struct ethtool_rmon_hist_range **ranges); + void (*get_eth_pmac_phy_stats)(struct net_device *dev, + struct ethtool_eth_phy_stats *phy_stats); + void (*get_eth_pmac_mac_stats)(struct net_device *dev, + struct ethtool_eth_mac_stats *mac_stats); + void (*get_eth_pmac_ctrl_stats)(struct net_device *dev, + struct ethtool_eth_ctrl_stats *ctrl_stats); + void (*get_pmac_rmon_stats)(struct net_device *dev, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges); int (*get_module_power_mode)(struct net_device *dev, struct ethtool_module_power_mode_params *params, struct netlink_ext_ack *extack); diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 658810274c49..a2743ffb6c63 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -742,6 +742,10 @@ enum { ETHTOOL_STATS_ETH_MAC, ETHTOOL_STATS_ETH_CTRL, ETHTOOL_STATS_RMON, + ETHTOOL_STATS_ETH_PMAC_PHY, + ETHTOOL_STATS_ETH_PMAC_MAC, + ETHTOOL_STATS_ETH_PMAC_CTRL, + ETHTOOL_STATS_PMAC_RMON, /* add new constants above here */ __ETHTOOL_STATS_CNT diff --git a/net/ethtool/stats.c b/net/ethtool/stats.c index 8d4d3c70c0a4..50e858b540c2 100644 --- a/net/ethtool/stats.c +++ b/net/ethtool/stats.c @@ -24,8 +24,13 @@ struct stats_reply_data { struct ethtool_eth_mac_stats mac_stats; struct ethtool_eth_ctrl_stats ctrl_stats; struct ethtool_rmon_stats rmon_stats; + struct ethtool_eth_phy_stats pmac_phy_stats; + struct ethtool_eth_mac_stats pmac_mac_stats; + struct ethtool_eth_ctrl_stats pmac_ctrl_stats; + struct ethtool_rmon_stats pmac_rmon_stats; ); const struct ethtool_rmon_hist_range *rmon_ranges; + const struct ethtool_rmon_hist_range *pmac_rmon_ranges; }; #define STATS_REPDATA(__reply_base) \ @@ -36,6 +41,10 @@ const char stats_std_names[__ETHTOOL_STATS_CNT][ETH_GSTRING_LEN] = { [ETHTOOL_STATS_ETH_MAC] = "eth-mac", [ETHTOOL_STATS_ETH_CTRL] = "eth-ctrl", [ETHTOOL_STATS_RMON] = "rmon", + [ETHTOOL_STATS_ETH_PMAC_PHY] = "eth-pmac-phy", + [ETHTOOL_STATS_ETH_PMAC_MAC] = "eth-pmac-mac", + [ETHTOOL_STATS_ETH_PMAC_CTRL] = "eth-pmac-ctrl", + [ETHTOOL_STATS_PMAC_RMON] = "pmac-rmon", }; const char stats_eth_phy_names[__ETHTOOL_A_STATS_ETH_PHY_CNT][ETH_GSTRING_LEN] = { @@ -143,6 +152,20 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base, ops->get_rmon_stats(dev, &data->rmon_stats, &data->rmon_ranges); + if (test_bit(ETHTOOL_STATS_ETH_PMAC_PHY, req_info->stat_mask) && + ops->get_eth_pmac_phy_stats) + ops->get_eth_pmac_phy_stats(dev, &data->pmac_phy_stats); + if (test_bit(ETHTOOL_STATS_ETH_PMAC_MAC, req_info->stat_mask) && + ops->get_eth_pmac_mac_stats) + ops->get_eth_pmac_mac_stats(dev, &data->pmac_mac_stats); + if (test_bit(ETHTOOL_STATS_ETH_PMAC_CTRL, req_info->stat_mask) && + ops->get_eth_pmac_ctrl_stats) + ops->get_eth_pmac_ctrl_stats(dev, &data->pmac_ctrl_stats); + if (test_bit(ETHTOOL_STATS_PMAC_RMON, req_info->stat_mask) && + ops->get_pmac_rmon_stats) + ops->get_pmac_rmon_stats(dev, &data->pmac_rmon_stats, + &data->pmac_rmon_ranges); + ethnl_ops_complete(dev); return 0; } @@ -176,6 +199,28 @@ static int stats_reply_size(const struct ethnl_req_info *req_base, nla_total_size(4)) * /* _A_STATS_GRP_HIST_BKT_HI */ ETHTOOL_RMON_HIST_MAX * 2; } + if (test_bit(ETHTOOL_STATS_ETH_PMAC_PHY, req_info->stat_mask)) { + n_stats += sizeof(struct ethtool_eth_mac_stats) / sizeof(u64); + n_grps++; + } + if (test_bit(ETHTOOL_STATS_ETH_PMAC_MAC, req_info->stat_mask)) { + n_stats += sizeof(struct ethtool_eth_mac_stats) / sizeof(u64); + n_grps++; + } + if (test_bit(ETHTOOL_STATS_ETH_PMAC_CTRL, req_info->stat_mask)) { + n_stats += sizeof(struct ethtool_eth_ctrl_stats) / sizeof(u64); + n_grps++; + } + if (test_bit(ETHTOOL_STATS_PMAC_RMON, req_info->stat_mask)) { + n_stats += sizeof(struct ethtool_rmon_stats) / sizeof(u64); + n_grps++; + /* Above includes the space for _A_STATS_GRP_HIST_VALs */ + + len += (nla_total_size(0) + /* _A_STATS_GRP_HIST */ + nla_total_size(4) + /* _A_STATS_GRP_HIST_BKT_LOW */ + nla_total_size(4)) * /* _A_STATS_GRP_HIST_BKT_HI */ + ETHTOOL_RMON_HIST_MAX * 2; + } len += n_grps * (nla_total_size(0) + /* _A_STATS_GRP */ nla_total_size(4) + /* _A_STATS_GRP_ID */ @@ -419,6 +464,31 @@ static int stats_fill_reply(struct sk_buff *skb, ETH_SS_STATS_RMON, stats_put_rmon_stats); } + if (!ret && test_bit(ETHTOOL_STATS_ETH_PMAC_PHY, req_info->stat_mask)) + ret = stats_put_stats(skb, &data->pmac_phy_stats, + ETHTOOL_STATS_ETH_PMAC_PHY, + ETH_SS_STATS_ETH_PHY, + stats_put_phy_stats); + if (!ret && test_bit(ETHTOOL_STATS_ETH_PMAC_MAC, req_info->stat_mask)) + ret = stats_put_stats(skb, &data->pmac_mac_stats, + ETHTOOL_STATS_ETH_PMAC_MAC, + ETH_SS_STATS_ETH_MAC, + stats_put_mac_stats); + if (!ret && test_bit(ETHTOOL_STATS_ETH_PMAC_CTRL, req_info->stat_mask)) + ret = stats_put_stats(skb, &data->pmac_ctrl_stats, + ETHTOOL_STATS_ETH_PMAC_CTRL, + ETH_SS_STATS_ETH_CTRL, + stats_put_ctrl_stats); + if (!ret && test_bit(ETHTOOL_STATS_PMAC_RMON, req_info->stat_mask)) { + struct rmon_stats_put_ctx ctx = { + .rmon_stats = &data->pmac_rmon_stats, + .rmon_ranges = data->pmac_rmon_ranges, + }; + + ret = stats_put_stats(skb, &ctx, ETHTOOL_STATS_PMAC_RMON, + ETH_SS_STATS_RMON, stats_put_rmon_stats); + } + return ret; } From patchwork Tue Aug 16 22:29:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12945340 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22D2CC25B0E for ; Tue, 16 Aug 2022 22:29:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238019AbiHPW3q (ORCPT ); Tue, 16 Aug 2022 18:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237995AbiHPW3m (ORCPT ); Tue, 16 Aug 2022 18:29:42 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60064.outbound.protection.outlook.com [40.107.6.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D44717C515 for ; Tue, 16 Aug 2022 15:29:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PvEhvQMJ7EsKoazYSX6hU1VJigvHlyjh5LeNNdtOWqoXVTii5DNcmGl1cUyceKjHtYkkd4IZLuAKJKtRHEfntjQ4d/++5kXmuMq2Wh/TEpJX9rwH9+ADAIQMtOE6TkvOIrvEyUO/M5dkO/JRPn2GsqRMy2273KbiiOIlwjjJrcKSCHyGyXtV8Uvm8YflDdK+G4svFCXsPgeX2QY/It8PHUPNFf1rvYtea8/b2YD/wwNpMUXBB0cb/2wSd8TVxw6BWFa/ZUIHeiXUXxx/4SbqxutqP1OLh/QLj0MHcDtv5Xv+dgPIhNntNQL/6l4qeFRqB3GRloQboIIjEmV2FX8gaw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Uk0NpJyq3ItGTurYlEhtJo1o3qA8DRnS9wBUUcMzjy8=; b=Ahj2r3RAcn/R7GUhaB/8m+01nnuRbIRBTSDbVFL7fB37ern4P53J7giaf4a1NQ517Czn7gCno2X2AShFum4WQl4JxqwxrtM81X1yv/PWyghzo1rE1ex0FbrSFkluiaJfuI2l2dgGz/n6aPeDBVQTAHKs6i2zfsjw4nIkFzP0v6l4DkK4rsAFlVPioji4/UIKG5F04YhLAucUNVwj2KuB0UWg3z/3llYjLU9Pu7D7fsf3qvfD22YgwZyt7TsrROdcxrkjBunyWou9xFr3W4zc0ChbdHlfFKzJdpwxQRPeao1kQUleOzOKyXYbazbsG2qy5OQV9kxJG5+/NsbrTy3Y9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uk0NpJyq3ItGTurYlEhtJo1o3qA8DRnS9wBUUcMzjy8=; b=YzG/K6z3N6j226KGG6mHIs2+MMYmW4oK1qrgTak05C6pHFymF2SQ3TDzHglD5IpATWpeUjuDtPGJLyPASIK/qjEXxlzOfmzR2ycrNgSWwqn/rhkk8p82vFOSYIASTrVir7ywL8S7kaXHcGRKFRHecs/Bo77ZxahQctcBm0uNUAk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8618.eurprd04.prod.outlook.com (2603:10a6:20b:439::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Tue, 16 Aug 2022 22:29:34 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 22:29:34 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes Subject: [RFC PATCH net-next 5/7] net: enetc: parameterize port MAC stats to also cover the pMAC Date: Wed, 17 Aug 2022 01:29:18 +0300 Message-Id: <20220816222920.1952936-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816222920.1952936-1-vladimir.oltean@nxp.com> References: <20220816222920.1952936-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0021.eurprd05.prod.outlook.com (2603:10a6:800:92::31) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3287262f-3b60-45f6-ef13-08da7fd6cbb1 X-MS-TrafficTypeDiagnostic: AM9PR04MB8618:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WtRSv6XgFYdqFhE/XyzOc/NOogn0mJ/dRGgQPX7RUhZ66pjz77isCjDdvPVTHxofNMREKjxyi/iJUqaDAV6uBktVk1kz3n7YOB4l4OZpMYbC5NlF24+JD3YfAWJ4Lu8vS9glCjggBrGLjsrLSXSQQHnquvNFMsYpqIIzz6S7OQVmcXVwEmsxjHUY321CjkP2Dt09kQcmSMOe88c3lT+8lR/XNvzUT7IuEZLiU+GyOgOYsVFIQroJBFgMEnLPq04wwezG972cxzy+Vep0UgqKr8+PEELa/zw2BzdXNSGfzVofCFqOimP0xTPn+VE/hxXiCN8htVaxRYzupMkUV72EBqyuUJnDnRBgI8BUqVGJKFJDkeprMQ6Ak5sssqFWjyWiPt08FCWkuFWY7cdtWDED+SKhjhB8ADU2ZkoK8wns+BtsyYUsmaLWAyJ5/zvJqbYrWQRYbXJUCXooBJ0FI8TzJMemgqwwjCwhbsIV14CrD5Uia1dmzsWwTi40HGy2ft53coIks8bAVKGWgphwyXadsS1OO29Csy0QoW1Bk4Mudm+xMlMC5ct6e2/pkGYmiVJkRBCMPH5C2INi2mR0XWB+y0e57q7bktC2/AuInQG16I0nknrpd1YdkbGutWW3G3vPMsvYagWXvNJoTQdnEaSap5XPlWDJvNnH3EbkPXi4VLUT4cMQv8IiOXOO5uEklmXpx6O/9ZWV7pDz76iiZhszLRTa607Yh/iHPr50cDuU+tPOJC2wMOQA+ltmwu+gbq8rYWULsc8AFVaMtcGfmtiL7+NLgxpxS+LTcWbcNv7cH6g= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(136003)(366004)(346002)(39860400002)(376002)(66946007)(44832011)(316002)(1076003)(66556008)(8676002)(83380400001)(41300700001)(6666004)(6916009)(4326008)(2906002)(36756003)(54906003)(186003)(2616005)(38100700002)(26005)(38350700002)(30864003)(6506007)(6512007)(66476007)(6486002)(8936002)(86362001)(478600001)(52116002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rf9WWlLykrk6qj5a7poAvS2q5sSVZiuRMb2mKgtgoeik8KcAh59UI3Gin1TGBWU7Qqm05VzQZo08QARDVWKNsUTco0a2gtyKRyxY9KUINjMUTS7OB2dfwXfSdBNYHq7ynf2RZgvTYIET73Z1zQwRRJOFGRfWzXKBlIG2R5wd0vnivqeHQLIMZf+90KHmv2scQa2K3NfsWKZLSeoI5DjwqbwSBtBtvfzYmjJwuY8BL7OTuGqQkDtV9QhBSWvOUN2BbGM2KIBVJkU4P0ydEpm0TDByw3CgDlgdo+4iQaq3/vEz6nx7imyLjdxWiXMrcg2il2YriZq40lpCFZOlACYRONPkzRVX9HUQe2LxGmLadOo/UPEIroWZB24nvMlZatEPmd+IdL227vbpFEqkT0TiBeBwHoR68MqzPNN/FffYRw4+ryvn20xRhqPE63nn1SKO1ePXTBIq49+4beaJ+VzPdMnkZNel98e7VHUvILDU6bN2gOECeeqxN6dz9yL5QgsE5Ln6XbTCwpc9RKAmPaYKNYkIT94g9uHkGdqZMCVCQnUuiYD3RrzTWga+FG0ShW5lXIfdD66L+MypJjPmpLZxQaymrWFoV8d0+f/m8qqLblSSiz3vgjtdtOqv7H+hxHEJ1IiS1oHQdElxNN46ZO887Z4XJkNVzIYEmKdvQ7nZT3TMLudVLipK8y0v1VnsiDgO5bqZiS9K5xcc7HPmeCaxzQNHGvjpSShRkWaD8WVUP2NB+sP0/Diw3MKYgkIu0UA/Kx8hyWAZ2yTbKlC5UyaLjo2cXNh6kYrhRh0PE1y4rJfpHUYqNaMGZ2EfD9IVRNV3cmMDwQQ+rZ0T4WrRM4BtSzsZpy0PI+IT1UexjWdzjSUpA7WY075eLOphKQU0hYrzui66PO8eWfBSGx7F4cMWt+VV0vug7wLcw8CydCwwHgbrcxvx6aM9HnZVZc3kN4QCZDN7VCIeNja05dpjjkbV36VMExv5pCUW5fMHYeKUxCC/DvDcqnoqjraNN16pNKEGikyPr+AUNG2salNdCAuSwG8v25ZkGFAk++umm9PeUIFSS0LMB3FJHUkZHatI4XeATKD3IPeKnd8QFfWnGnAeBCW72wx0lClQYUweWjEMBLTS/PaMHykG0/ybq3DPCca19T+zjG1/6wq5GYkfcvmdC92glJeVp4ew1adjt9u1RVAB22nSMLu2vD8kIx2pTIubBsvIjkOGIKOt8/oQ80ZW5DJgdSmHRk0AYyTJGU8Y3losFzXTYCioALcsC8iKA6fczLcvgwO0cztdRa47zVv27rpZcrUrsBk6C394jvoLRJhxFDTEv89IoyOR+JNzszdyiZAfxLsKomit0VeHKk7ITKroDYfUImmqOLTjoQCNpatbpN/dY0lZZHFAxkdq+lt+oEngOEfXzqPfHUV7hDD9/tH50+M10xQpxI7GfZ3oX9pTzHogKI0IKJs/2XZefrsLgLAmKgyz0vlDzFVtVO0zQiDTn7LlFVSjUbFEvhhXMkVuOubGcqQdHSRVrELDkWeW1PqaQsnxLz4+3xoCEs1WvyTdaQyXQVnrO+N3tTP3UainUk51W/zYKA2GhiVRqXZ67+CvxP9a4t9Zz1wPa4wOdw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3287262f-3b60-45f6-ef13-08da7fd6cbb1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 22:29:34.5854 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: obRWNEKQiJ+PJzDbUwxnrRzJdQDg/ZWFAUtgoS3v1ijQjJGRCwLRoGgq/eUfKSjQaBJcZzBX0w9R8On86mrZ6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8618 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The ENETC has counters for the eMAC and for the pMAC exactly 0x1000 apart from each other. The driver only contains definitions for PM0, the eMAC. Rather than duplicating everything for PM1, modify the register definitions such that they take the MAC as argument. Signed-off-by: Vladimir Oltean --- .../ethernet/freescale/enetc/enetc_ethtool.c | 124 +++++++++--------- .../net/ethernet/freescale/enetc/enetc_hw.h | 106 +++++++-------- 2 files changed, 116 insertions(+), 114 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c index ff872e40ce85..236bb24ec999 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c @@ -125,68 +125,68 @@ static const struct { int reg; char name[ETH_GSTRING_LEN]; } enetc_port_counters[] = { - { ENETC_PM0_REOCT, "MAC rx ethernet octets" }, - { ENETC_PM0_RALN, "MAC rx alignment errors" }, - { ENETC_PM0_RXPF, "MAC rx valid pause frames" }, - { ENETC_PM0_RFRM, "MAC rx valid frames" }, - { ENETC_PM0_RFCS, "MAC rx fcs errors" }, - { ENETC_PM0_RVLAN, "MAC rx VLAN frames" }, - { ENETC_PM0_RERR, "MAC rx frame errors" }, - { ENETC_PM0_RUCA, "MAC rx unicast frames" }, - { ENETC_PM0_RMCA, "MAC rx multicast frames" }, - { ENETC_PM0_RBCA, "MAC rx broadcast frames" }, - { ENETC_PM0_RDRP, "MAC rx dropped packets" }, - { ENETC_PM0_RPKT, "MAC rx packets" }, - { ENETC_PM0_RUND, "MAC rx undersized packets" }, - { ENETC_PM0_R64, "MAC rx 64 byte packets" }, - { ENETC_PM0_R127, "MAC rx 65-127 byte packets" }, - { ENETC_PM0_R255, "MAC rx 128-255 byte packets" }, - { ENETC_PM0_R511, "MAC rx 256-511 byte packets" }, - { ENETC_PM0_R1023, "MAC rx 512-1023 byte packets" }, - { ENETC_PM0_R1522, "MAC rx 1024-1522 byte packets" }, - { ENETC_PM0_R1523X, "MAC rx 1523 to max-octet packets" }, - { ENETC_PM0_ROVR, "MAC rx oversized packets" }, - { ENETC_PM0_RJBR, "MAC rx jabber packets" }, - { ENETC_PM0_RFRG, "MAC rx fragment packets" }, - { ENETC_PM0_RCNP, "MAC rx control packets" }, - { ENETC_PM0_RDRNTP, "MAC rx fifo drop" }, - { ENETC_PM0_TEOCT, "MAC tx ethernet octets" }, - { ENETC_PM0_TOCT, "MAC tx octets" }, - { ENETC_PM0_TCRSE, "MAC tx carrier sense errors" }, - { ENETC_PM0_TXPF, "MAC tx valid pause frames" }, - { ENETC_PM0_TFRM, "MAC tx frames" }, - { ENETC_PM0_TFCS, "MAC tx fcs errors" }, - { ENETC_PM0_TVLAN, "MAC tx VLAN frames" }, - { ENETC_PM0_TERR, "MAC tx frame errors" }, - { ENETC_PM0_TUCA, "MAC tx unicast frames" }, - { ENETC_PM0_TMCA, "MAC tx multicast frames" }, - { ENETC_PM0_TBCA, "MAC tx broadcast frames" }, - { ENETC_PM0_TPKT, "MAC tx packets" }, - { ENETC_PM0_TUND, "MAC tx undersized packets" }, - { ENETC_PM0_T64, "MAC tx 64 byte packets" }, - { ENETC_PM0_T127, "MAC tx 65-127 byte packets" }, - { ENETC_PM0_T255, "MAC tx 128-255 byte packets" }, - { ENETC_PM0_T511, "MAC tx 256-511 byte packets" }, - { ENETC_PM0_T1023, "MAC tx 512-1023 byte packets" }, - { ENETC_PM0_T1522, "MAC tx 1024-1522 byte packets" }, - { ENETC_PM0_T1523X, "MAC tx 1523 to max-octet packets" }, - { ENETC_PM0_TCNP, "MAC tx control packets" }, - { ENETC_PM0_TDFR, "MAC tx deferred packets" }, - { ENETC_PM0_TMCOL, "MAC tx multiple collisions" }, - { ENETC_PM0_TSCOL, "MAC tx single collisions" }, - { ENETC_PM0_TLCOL, "MAC tx late collisions" }, - { ENETC_PM0_TECOL, "MAC tx excessive collisions" }, - { ENETC_UFDMF, "SI MAC nomatch u-cast discards" }, - { ENETC_MFDMF, "SI MAC nomatch m-cast discards" }, - { ENETC_PBFDSIR, "SI MAC nomatch b-cast discards" }, - { ENETC_PUFDVFR, "SI VLAN nomatch u-cast discards" }, - { ENETC_PMFDVFR, "SI VLAN nomatch m-cast discards" }, - { ENETC_PBFDVFR, "SI VLAN nomatch b-cast discards" }, - { ENETC_PFDMSAPR, "SI pruning discarded frames" }, - { ENETC_PICDR(0), "ICM DR0 discarded frames" }, - { ENETC_PICDR(1), "ICM DR1 discarded frames" }, - { ENETC_PICDR(2), "ICM DR2 discarded frames" }, - { ENETC_PICDR(3), "ICM DR3 discarded frames" }, + { ENETC_PM_REOCT(0), "MAC rx ethernet octets" }, + { ENETC_PM_RALN(0), "MAC rx alignment errors" }, + { ENETC_PM_RXPF(0), "MAC rx valid pause frames" }, + { ENETC_PM_RFRM(0), "MAC rx valid frames" }, + { ENETC_PM_RFCS(0), "MAC rx fcs errors" }, + { ENETC_PM_RVLAN(0), "MAC rx VLAN frames" }, + { ENETC_PM_RERR(0), "MAC rx frame errors" }, + { ENETC_PM_RUCA(0), "MAC rx unicast frames" }, + { ENETC_PM_RMCA(0), "MAC rx multicast frames" }, + { ENETC_PM_RBCA(0), "MAC rx broadcast frames" }, + { ENETC_PM_RDRP(0), "MAC rx dropped packets" }, + { ENETC_PM_RPKT(0), "MAC rx packets" }, + { ENETC_PM_RUND(0), "MAC rx undersized packets" }, + { ENETC_PM_R64(0), "MAC rx 64 byte packets" }, + { ENETC_PM_R127(0), "MAC rx 65-127 byte packets" }, + { ENETC_PM_R255(0), "MAC rx 128-255 byte packets" }, + { ENETC_PM_R511(0), "MAC rx 256-511 byte packets" }, + { ENETC_PM_R1023(0), "MAC rx 512-1023 byte packets" }, + { ENETC_PM_R1522(0), "MAC rx 1024-1522 byte packets" }, + { ENETC_PM_R1523X(0), "MAC rx 1523 to max-octet packets" }, + { ENETC_PM_ROVR(0), "MAC rx oversized packets" }, + { ENETC_PM_RJBR(0), "MAC rx jabber packets" }, + { ENETC_PM_RFRG(0), "MAC rx fragment packets" }, + { ENETC_PM_RCNP(0), "MAC rx control packets" }, + { ENETC_PM_RDRNTP(0), "MAC rx fifo drop" }, + { ENETC_PM_TEOCT(0), "MAC tx ethernet octets" }, + { ENETC_PM_TOCT(0), "MAC tx octets" }, + { ENETC_PM_TCRSE(0), "MAC tx carrier sense errors" }, + { ENETC_PM_TXPF(0), "MAC tx valid pause frames" }, + { ENETC_PM_TFRM(0), "MAC tx frames" }, + { ENETC_PM_TFCS(0), "MAC tx fcs errors" }, + { ENETC_PM_TVLAN(0), "MAC tx VLAN frames" }, + { ENETC_PM_TERR(0), "MAC tx frame errors" }, + { ENETC_PM_TUCA(0), "MAC tx unicast frames" }, + { ENETC_PM_TMCA(0), "MAC tx multicast frames" }, + { ENETC_PM_TBCA(0), "MAC tx broadcast frames" }, + { ENETC_PM_TPKT(0), "MAC tx packets" }, + { ENETC_PM_TUND(0), "MAC tx undersized packets" }, + { ENETC_PM_T64(0), "MAC tx 64 byte packets" }, + { ENETC_PM_T127(0), "MAC tx 65-127 byte packets" }, + { ENETC_PM_T255(0), "MAC tx 128-255 byte packets" }, + { ENETC_PM_T511(0), "MAC tx 256-511 byte packets" }, + { ENETC_PM_T1023(0), "MAC tx 512-1023 byte packets" }, + { ENETC_PM_T1522(0), "MAC tx 1024-1522 byte packets" }, + { ENETC_PM_T1523X(0), "MAC tx 1523 to max-octet packets" }, + { ENETC_PM_TCNP(0), "MAC tx control packets" }, + { ENETC_PM_TDFR(0), "MAC tx deferred packets" }, + { ENETC_PM_TMCOL(0), "MAC tx multiple collisions" }, + { ENETC_PM_TSCOL(0), "MAC tx single collisions" }, + { ENETC_PM_TLCOL(0), "MAC tx late collisions" }, + { ENETC_PM_TECOL(0), "MAC tx excessive collisions" }, + { ENETC_UFDMF, "SI MAC nomatch u-cast discards" }, + { ENETC_MFDMF, "SI MAC nomatch m-cast discards" }, + { ENETC_PBFDSIR, "SI MAC nomatch b-cast discards" }, + { ENETC_PUFDVFR, "SI VLAN nomatch u-cast discards" }, + { ENETC_PMFDVFR, "SI VLAN nomatch m-cast discards" }, + { ENETC_PBFDVFR, "SI VLAN nomatch b-cast discards" }, + { ENETC_PFDMSAPR, "SI pruning discarded frames" }, + { ENETC_PICDR(0), "ICM DR0 discarded frames" }, + { ENETC_PICDR(1), "ICM DR1 discarded frames" }, + { ENETC_PICDR(2), "ICM DR2 discarded frames" }, + { ENETC_PICDR(3), "ICM DR3 discarded frames" }, }; static const char rx_ring_stats[][ETH_GSTRING_LEN] = { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 647c87f73bf7..0b85e37a00eb 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -276,58 +276,60 @@ enum enetc_bdr_type {TX, RX}; #define ENETC_PFMCAPR 0x1b38 #define ENETC_PFMCAPR_MSK GENMASK(15, 0) -/* MAC counters */ -#define ENETC_PM0_REOCT 0x8100 -#define ENETC_PM0_RALN 0x8110 -#define ENETC_PM0_RXPF 0x8118 -#define ENETC_PM0_RFRM 0x8120 -#define ENETC_PM0_RFCS 0x8128 -#define ENETC_PM0_RVLAN 0x8130 -#define ENETC_PM0_RERR 0x8138 -#define ENETC_PM0_RUCA 0x8140 -#define ENETC_PM0_RMCA 0x8148 -#define ENETC_PM0_RBCA 0x8150 -#define ENETC_PM0_RDRP 0x8158 -#define ENETC_PM0_RPKT 0x8160 -#define ENETC_PM0_RUND 0x8168 -#define ENETC_PM0_R64 0x8170 -#define ENETC_PM0_R127 0x8178 -#define ENETC_PM0_R255 0x8180 -#define ENETC_PM0_R511 0x8188 -#define ENETC_PM0_R1023 0x8190 -#define ENETC_PM0_R1522 0x8198 -#define ENETC_PM0_R1523X 0x81A0 -#define ENETC_PM0_ROVR 0x81A8 -#define ENETC_PM0_RJBR 0x81B0 -#define ENETC_PM0_RFRG 0x81B8 -#define ENETC_PM0_RCNP 0x81C0 -#define ENETC_PM0_RDRNTP 0x81C8 -#define ENETC_PM0_TEOCT 0x8200 -#define ENETC_PM0_TOCT 0x8208 -#define ENETC_PM0_TCRSE 0x8210 -#define ENETC_PM0_TXPF 0x8218 -#define ENETC_PM0_TFRM 0x8220 -#define ENETC_PM0_TFCS 0x8228 -#define ENETC_PM0_TVLAN 0x8230 -#define ENETC_PM0_TERR 0x8238 -#define ENETC_PM0_TUCA 0x8240 -#define ENETC_PM0_TMCA 0x8248 -#define ENETC_PM0_TBCA 0x8250 -#define ENETC_PM0_TPKT 0x8260 -#define ENETC_PM0_TUND 0x8268 -#define ENETC_PM0_T64 0x8270 -#define ENETC_PM0_T127 0x8278 -#define ENETC_PM0_T255 0x8280 -#define ENETC_PM0_T511 0x8288 -#define ENETC_PM0_T1023 0x8290 -#define ENETC_PM0_T1522 0x8298 -#define ENETC_PM0_T1523X 0x82A0 -#define ENETC_PM0_TCNP 0x82C0 -#define ENETC_PM0_TDFR 0x82D0 -#define ENETC_PM0_TMCOL 0x82D8 -#define ENETC_PM0_TSCOL 0x82E0 -#define ENETC_PM0_TLCOL 0x82E8 -#define ENETC_PM0_TECOL 0x82F0 +/* Port MAC counters: Port MAC 0 corresponds to the eMAC and + * Port MAC 1 to the pMAC. + */ +#define ENETC_PM_REOCT(mac) (0x8100 + 0x1000 * (mac)) +#define ENETC_PM_RALN(mac) (0x8110 + 0x1000 * (mac)) +#define ENETC_PM_RXPF(mac) (0x8118 + 0x1000 * (mac)) +#define ENETC_PM_RFRM(mac) (0x8120 + 0x1000 * (mac)) +#define ENETC_PM_RFCS(mac) (0x8128 + 0x1000 * (mac)) +#define ENETC_PM_RVLAN(mac) (0x8130 + 0x1000 * (mac)) +#define ENETC_PM_RERR(mac) (0x8138 + 0x1000 * (mac)) +#define ENETC_PM_RUCA(mac) (0x8140 + 0x1000 * (mac)) +#define ENETC_PM_RMCA(mac) (0x8148 + 0x1000 * (mac)) +#define ENETC_PM_RBCA(mac) (0x8150 + 0x1000 * (mac)) +#define ENETC_PM_RDRP(mac) (0x8158 + 0x1000 * (mac)) +#define ENETC_PM_RPKT(mac) (0x8160 + 0x1000 * (mac)) +#define ENETC_PM_RUND(mac) (0x8168 + 0x1000 * (mac)) +#define ENETC_PM_R64(mac) (0x8170 + 0x1000 * (mac)) +#define ENETC_PM_R127(mac) (0x8178 + 0x1000 * (mac)) +#define ENETC_PM_R255(mac) (0x8180 + 0x1000 * (mac)) +#define ENETC_PM_R511(mac) (0x8188 + 0x1000 * (mac)) +#define ENETC_PM_R1023(mac) (0x8190 + 0x1000 * (mac)) +#define ENETC_PM_R1522(mac) (0x8198 + 0x1000 * (mac)) +#define ENETC_PM_R1523X(mac) (0x81A0 + 0x1000 * (mac)) +#define ENETC_PM_ROVR(mac) (0x81A8 + 0x1000 * (mac)) +#define ENETC_PM_RJBR(mac) (0x81B0 + 0x1000 * (mac)) +#define ENETC_PM_RFRG(mac) (0x81B8 + 0x1000 * (mac)) +#define ENETC_PM_RCNP(mac) (0x81C0 + 0x1000 * (mac)) +#define ENETC_PM_RDRNTP(mac) (0x81C8 + 0x1000 * (mac)) +#define ENETC_PM_TEOCT(mac) (0x8200 + 0x1000 * (mac)) +#define ENETC_PM_TOCT(mac) (0x8208 + 0x1000 * (mac)) +#define ENETC_PM_TCRSE(mac) (0x8210 + 0x1000 * (mac)) +#define ENETC_PM_TXPF(mac) (0x8218 + 0x1000 * (mac)) +#define ENETC_PM_TFRM(mac) (0x8220 + 0x1000 * (mac)) +#define ENETC_PM_TFCS(mac) (0x8228 + 0x1000 * (mac)) +#define ENETC_PM_TVLAN(mac) (0x8230 + 0x1000 * (mac)) +#define ENETC_PM_TERR(mac) (0x8238 + 0x1000 * (mac)) +#define ENETC_PM_TUCA(mac) (0x8240 + 0x1000 * (mac)) +#define ENETC_PM_TMCA(mac) (0x8248 + 0x1000 * (mac)) +#define ENETC_PM_TBCA(mac) (0x8250 + 0x1000 * (mac)) +#define ENETC_PM_TPKT(mac) (0x8260 + 0x1000 * (mac)) +#define ENETC_PM_TUND(mac) (0x8268 + 0x1000 * (mac)) +#define ENETC_PM_T64(mac) (0x8270 + 0x1000 * (mac)) +#define ENETC_PM_T127(mac) (0x8278 + 0x1000 * (mac)) +#define ENETC_PM_T255(mac) (0x8280 + 0x1000 * (mac)) +#define ENETC_PM_T511(mac) (0x8288 + 0x1000 * (mac)) +#define ENETC_PM_T1023(mac) (0x8290 + 0x1000 * (mac)) +#define ENETC_PM_T1522(mac) (0x8298 + 0x1000 * (mac)) +#define ENETC_PM_T1523X(mac) (0x82A0 + 0x1000 * (mac)) +#define ENETC_PM_TCNP(mac) (0x82C0 + 0x1000 * (mac)) +#define ENETC_PM_TDFR(mac) (0x82D0 + 0x1000 * (mac)) +#define ENETC_PM_TMCOL(mac) (0x82D8 + 0x1000 * (mac)) +#define ENETC_PM_TSCOL(mac) (0x82E0 + 0x1000 * (mac)) +#define ENETC_PM_TLCOL(mac) (0x82E8 + 0x1000 * (mac)) +#define ENETC_PM_TECOL(mac) (0x82F0 + 0x1000 * (mac)) /* Port counters */ #define ENETC_PICDR(n) (0x0700 + (n) * 8) /* n = [0..3] */ From patchwork Tue Aug 16 22:29:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12945341 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32EE7C2BB41 for ; Tue, 16 Aug 2022 22:29:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238021AbiHPW3r (ORCPT ); Tue, 16 Aug 2022 18:29:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238013AbiHPW3o (ORCPT ); Tue, 16 Aug 2022 18:29:44 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60064.outbound.protection.outlook.com [40.107.6.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3356760C0 for ; Tue, 16 Aug 2022 15:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fxva301pQnluhIkJt1o0wiwTeylt9PaJkb1PEUBh7hfNKfYyl5D3wtsW8DZce8f1hgSczO8ibbpcFdtGVMOyg/0Gb+Tl4JlyNwEWgyu8zU0Diel8n0OFuSK/xNgydlMKX7H1Qj8wAldVxg64B85mGEIxBlQb4j4b06M5/jbATrDSGTH1Ei5m9TlnoRmfbllDoHbvr8uLbZ6kbbm5xH94STxpmtyZbONZL/xInXcFxY3f9Z0egz9gfgabaGPBN5gkG5qwG/D7VUkRqQbvth187iGtBBCe+8gXHmZB+3NQlFT+bP9casQwD4UB6Dv/X6Wem+SGuLfXRWSaumDo1V4Tkg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YiS/loU50rKJuHwMdqEWN3NZGIppkCdOKHnMrtZxw/4=; b=UiNNLVbUgDY+Yh6rD+5V3iSZtjPXic8dMwpXpy+d33OSMPhXGssT1OSfmpZetxVofcERd9enr597QPeVI3jnPBkZ/R/zB9s9XWTdPx2R6Hbr3YmKUUe0inrJ1VUi4aIJVJe/x5Y9mlHTBTYqFCG+onQqQDj/99q5OJ/bja93644ErEa7xJOYnMjTgCQBqvKHUq60TUc54WlvKQSCdsVYMzRTorOugNJylC3QDeKLPOGi6Cw+Arq5RhCsCZiXZwbzZUuJ6iSiM7J2nXCJT9o1awKpQ2+YHZ/thsVU0LrkACbmpts1ijHxkTyLaEZbzfnl4YcwfsEGDGE4YVz3ogIu6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YiS/loU50rKJuHwMdqEWN3NZGIppkCdOKHnMrtZxw/4=; b=GtsBgVw/d3/zfRhyK8LU9ZF1YkGoJNF0mHZo2Du6aHI5z5ykGKwXZFjp3mqEclwqWC6wVkykLFFgPubD+DlMim2iQ/nEDG1ToHwiqLY6G9SfynNYSJBV3JONmaEsn16NSgaelcgdd7A/2yxnN8k/A5+cyGc8naVbn/9P+oCUslg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8618.eurprd04.prod.outlook.com (2603:10a6:20b:439::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Tue, 16 Aug 2022 22:29:35 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 22:29:35 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes Subject: [RFC PATCH net-next 6/7] net: enetc: expose some standardized ethtool counters Date: Wed, 17 Aug 2022 01:29:19 +0300 Message-Id: <20220816222920.1952936-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816222920.1952936-1-vladimir.oltean@nxp.com> References: <20220816222920.1952936-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0021.eurprd05.prod.outlook.com (2603:10a6:800:92::31) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0bafccc4-c3c6-479d-973c-08da7fd6cc3e X-MS-TrafficTypeDiagnostic: AM9PR04MB8618:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +nRYyBaDU/KRGuZl74RtnX1sXDgC2NX2Cz7MSM66xnMu+KhPT6uJ9BOqJsy+bQETFUU9hO7e19KwaN7vy+zPX6pg3Lsefk7aMomEaAclciZLGW9aQBe7BVz9htNfcsnnuMBwEk41Bp+7sZFdNBqlTQEtf/BGzo5kA+rK8TeFV+OyoZYkz1yQ2VWZuHtskW0RxFMiMNQDYNgoQqT3OjRRpEdiN5NkkvGFvMI75ZIRJ91AUTIuw/7ul4AICzAvRyM8b3KsAa5ABlrCsl/zH0ke4Sf+m3xx9Ab5PqG/2B5M9RX17SpcF1iI7eJZZFF1O3vF/jjTee7nPqBcG4yk5ZtBtJPj0ZHHrugLycC4Y7KfNCAegWGUcFvIQusrbhvVKxKZH96D1QMHZfltH8rSZk/bTtsRmiWsmc4+7N36+eSfOCBpmLObgIAZgE+Jy7dmZK5CkVEwJ01WWg1VBbXwTYXEkPtcCvA54j3jp+oXm1eP0N6ZC/qQ3cOFDPyB9ItiO5858VMcWd8Pqv4ZZH1A7snP6ZnM9GCsO9emiHMWC13UPvdQh0QxM8tJh8fZF0a7Pg49vrDFqEqfBjHu4X8CW1oz3IB4EMRmuhT2MsosqCYe46NNpYa2phxZFcRYIDw0+RjgBi2lOZA4SDoSjVaitlOlS0klLsp8ncqiJe7MiZ66MCwuqoC6vk/NVjtW//hGohHpYbCsZouW9eJ1Xua805jX0MToCBqy6Bu5MVsNEMyiJ72lK1X1wqcFLnk1eZ+En+4E5PAgkg90SQyiwUkK8ZK+wp0IIUGpvdfv612+lm4PcpncuzoJy+8xbk3nKyI6l7UDAa2iZJz8MstV2AaX9dcJXw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(136003)(366004)(346002)(39860400002)(376002)(66946007)(44832011)(316002)(1076003)(66556008)(8676002)(83380400001)(41300700001)(6666004)(6916009)(4326008)(2906002)(36756003)(54906003)(186003)(2616005)(38100700002)(26005)(38350700002)(6506007)(6512007)(66476007)(40140700001)(6486002)(8936002)(86362001)(478600001)(52116002)(5660300002)(44824005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +Jo/OPE4xUbEb1jRa2EqnCatPg5Ws+nOLTQarm/wXY08nVeQJZRt96uJcgJVG+5gINm54ftAl3tUnJtZHcHUEC58RTaB1tDCZA8RaJVoDBsrtkEBTG2aw9jYlR5+ASDI1qY7StgRX7RJG3jcroy3U1eQk7+eXtScIRw4LYX5N6GMXEW9ripZR85aqr2NriTTgsKRIM31M2tlurAFD9qMu4CbHDOFPSG5m3mVwGP+oHeyCjPCNaXXB4JOZlCDY6NEVQ1QLkOnfN+dqLw8FCgfFSx4CZtwelENA4KIgX39BpupURlpZ+u+5gLRqkoDgiKkv+A1GtSlNzeNi7FWd2DdgHWIZyclzd6L6voH/j8o7WJ+MQnQTi/WjTXl7Cp7/ELWJ5DJcBNdryNuDzmeO3trKUOz8tzK0O4lynGZQ7li0zAfimBtQKmTNvoAb7PqOsAILERqmfHNs3depApoLi7YTlMOYZjQ+B5EiRucQ509MfYKP2h6bjZ2BRzcOXna1bRrJ8CKlsims2YBCXtdiKXcBUQy3WWOqIY+TORlin4XVGK0et4PngHlfHbvmYBwdmju4KM4aSKHVC20AoPARtNt8UomyqXJDXZtIHGt1CkE2PcDhG2U9eQilrvGmNROe+LpdtzoqbUTTd0b2/y9QbIXcYIpl62CaH0WGmOKwvJx0yEhWePzr98eZkTO4S6CkNUEEYlJs5BKenaNR1dWGDx68RANWkf9lcGFcIuwqceiRu83cOIt9kN3/a/pTH1grOG1C4bqcINqMwEm9w714tUUoKyJe92AD+ANNmkIIN+GDlxc38YDbtV9FX9g6osc9err/2jQJO/3TUP5b23nSM3AtE+SpQ+uqMk6i9TUlZFkUMIhsCMp50bfSnkvwV3tg3iBWBrCuh8Tfl154ZjmhT9s1nnaIOMsbs0dgkjuR1WScm5t3kpAY+zJE4M1aWc4bREQw4nFMGb2j8LD6blyWTxW9oWm/XXohT/1o4P4UwoiLOvJIsYaE04ANL1q/B73aiTaUZiR0cTiaYfRSkxdqKeIG1i0o5Y+QcfNA3gEmTm5v7rAkklT00hbx7OgSE+fRnB7ECKJB/mCToOcbTbATuOnpY2toqDFA28fOy+YtVtRaLpP8J3/ORfc607co+nofhOYVJkRDdL2u4b6Wd9bn7cWyV+IyFCZ8l/aU4RvYJqxbNGbtJxnqZZSLCNarSMscNCsqK1Ibt5AyAeMQjrC0E6oFWRqsrDkXa3z9/kF+m0RUULu6N4sZ9Kjo1WAqARxAJYQJRuPxThDNkv0jxeDTAz9EqwlXVrzUhSxnYcTfYWhjwTIMzyqu78Uh8Lrxj872CByvd0GHTZrFkHAwfWWd1maA16dgT6G5EdDLr7yXJVqVxNLFptTzRY0TbH4gAAdpkShKlpjUNtA5VYVVj9y6R4+XMquHl40ZuQBxlNnQrc/phn3fiw6LlNnoPFZ10CqxTGxJfuyEZQk8CgxeWsHrtqrk0ftwzpqLy0mO3W34Mis4UkY6hkaSHNUaienqmY6fN2x4qP4wuu3ziVjhHA1MzZXvah1wVVZontjnnr8sjtcvasvkCY/TmEzxdmd55zmSDB0yXYF5HR1FYYfjeWOyoex3w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0bafccc4-c3c6-479d-973c-08da7fd6cc3e X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 22:29:35.4916 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JXvywexjR7fSxUmsVEu0BC8V0S9xA3aHtZ3hy/3pNXPwSpVI5gpbE8OkSdA//kZL+Lj+e7D3D9HlK4c8H+lDPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8618 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Structure the code in such a way that it can be reused later for the pMAC statistics, by just changing the "mac" argument to 1. Usage: ethtool --include-statistics --show-pause eno2 ethtool -S eno0 --groups eth-mac ethtool -S eno0 --groups eth-ctrl ethtool -S eno0 --groups rmon Signed-off-by: Vladimir Oltean --- .../ethernet/freescale/enetc/enetc_ethtool.c | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c index 236bb24ec999..25705b2c1be9 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c @@ -301,6 +301,113 @@ static void enetc_get_ethtool_stats(struct net_device *ndev, data[o++] = enetc_port_rd(hw, enetc_port_counters[i].reg); } +static void enetc_get_pause_stats(struct net_device *ndev, + struct ethtool_pause_stats *pause_stats) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; + + pause_stats->tx_pause_frames = enetc_port_rd(hw, ENETC_PM_TXPF(0)); + pause_stats->rx_pause_frames = enetc_port_rd(hw, ENETC_PM_RXPF(0)); +} + +static void enetc_mac_stats(struct enetc_hw *hw, int mac, + struct ethtool_eth_mac_stats *s) +{ + s->FramesTransmittedOK = enetc_port_rd(hw, ENETC_PM_TFRM(mac)); + s->SingleCollisionFrames = enetc_port_rd(hw, ENETC_PM_TSCOL(mac)); + s->MultipleCollisionFrames = enetc_port_rd(hw, ENETC_PM_TMCOL(mac)); + s->FramesReceivedOK = enetc_port_rd(hw, ENETC_PM_RFRM(mac)); + s->FrameCheckSequenceErrors = enetc_port_rd(hw, ENETC_PM_RFCS(mac)); + s->AlignmentErrors = enetc_port_rd(hw, ENETC_PM_RALN(mac)); + s->OctetsTransmittedOK = enetc_port_rd(hw, ENETC_PM_TEOCT(mac)); + s->FramesWithDeferredXmissions = enetc_port_rd(hw, ENETC_PM_TDFR(mac)); + s->LateCollisions = enetc_port_rd(hw, ENETC_PM_TLCOL(mac)); + s->FramesAbortedDueToXSColls = enetc_port_rd(hw, ENETC_PM_TECOL(mac)); + s->FramesLostDueToIntMACXmitError = enetc_port_rd(hw, ENETC_PM_TERR(mac)); + s->CarrierSenseErrors = enetc_port_rd(hw, ENETC_PM_TCRSE(mac)); + s->OctetsReceivedOK = enetc_port_rd(hw, ENETC_PM_REOCT(mac)); + s->FramesLostDueToIntMACRcvError = enetc_port_rd(hw, ENETC_PM_RDRNTP(mac)); + s->MulticastFramesXmittedOK = enetc_port_rd(hw, ENETC_PM_TMCA(mac)); + s->BroadcastFramesXmittedOK = enetc_port_rd(hw, ENETC_PM_TBCA(mac)); + s->MulticastFramesReceivedOK = enetc_port_rd(hw, ENETC_PM_RMCA(mac)); + s->BroadcastFramesReceivedOK = enetc_port_rd(hw, ENETC_PM_RBCA(mac)); +} + +static void enetc_ctrl_stats(struct enetc_hw *hw, int mac, + struct ethtool_eth_ctrl_stats *s) +{ + s->MACControlFramesTransmitted = enetc_port_rd(hw, ENETC_PM_TCNP(mac)); + s->MACControlFramesReceived = enetc_port_rd(hw, ENETC_PM_RCNP(mac)); +} + +static const struct ethtool_rmon_hist_range enetc_rmon_ranges[] = { + { 64, 64 }, + { 65, 127 }, + { 128, 255 }, + { 256, 511 }, + { 512, 1023 }, + { 1024, 1522 }, + { 1523, 9000 }, + {}, +}; + +static void enetc_rmon_stats(struct enetc_hw *hw, int mac, + struct ethtool_rmon_stats *s, + const struct ethtool_rmon_hist_range **ranges) +{ + s->undersize_pkts = enetc_port_rd(hw, ENETC_PM_RUND(mac)); + s->oversize_pkts = enetc_port_rd(hw, ENETC_PM_ROVR(mac)); + s->fragments = enetc_port_rd(hw, ENETC_PM_RFRG(mac)); + s->jabbers = enetc_port_rd(hw, ENETC_PM_RJBR(mac)); + + s->hist[0] = enetc_port_rd(hw, ENETC_PM_R64(mac)); + s->hist[1] = enetc_port_rd(hw, ENETC_PM_R127(mac)); + s->hist[2] = enetc_port_rd(hw, ENETC_PM_R255(mac)); + s->hist[3] = enetc_port_rd(hw, ENETC_PM_R511(mac)); + s->hist[4] = enetc_port_rd(hw, ENETC_PM_R1023(mac)); + s->hist[5] = enetc_port_rd(hw, ENETC_PM_R1522(mac)); + s->hist[6] = enetc_port_rd(hw, ENETC_PM_R1523X(mac)); + + s->hist_tx[0] = enetc_port_rd(hw, ENETC_PM_T64(mac)); + s->hist_tx[1] = enetc_port_rd(hw, ENETC_PM_T127(mac)); + s->hist_tx[2] = enetc_port_rd(hw, ENETC_PM_T255(mac)); + s->hist_tx[3] = enetc_port_rd(hw, ENETC_PM_T511(mac)); + s->hist_tx[4] = enetc_port_rd(hw, ENETC_PM_T1023(mac)); + s->hist_tx[5] = enetc_port_rd(hw, ENETC_PM_T1522(mac)); + s->hist_tx[6] = enetc_port_rd(hw, ENETC_PM_T1523X(mac)); + + *ranges = enetc_rmon_ranges; +} + +static void enetc_get_eth_mac_stats(struct net_device *ndev, + struct ethtool_eth_mac_stats *mac_stats) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; + + enetc_mac_stats(hw, 0, mac_stats); +} + +static void enetc_get_eth_ctrl_stats(struct net_device *ndev, + struct ethtool_eth_ctrl_stats *ctrl_stats) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; + + enetc_ctrl_stats(hw, 0, ctrl_stats); +} + +static void enetc_get_rmon_stats(struct net_device *ndev, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; + + enetc_rmon_stats(hw, 0, rmon_stats, ranges); +} + #define ENETC_RSSHASH_L3 (RXH_L2DA | RXH_VLAN | RXH_L3_PROTO | RXH_IP_SRC | \ RXH_IP_DST) #define ENETC_RSSHASH_L4 (ENETC_RSSHASH_L3 | RXH_L4_B_0_1 | RXH_L4_B_2_3) @@ -766,6 +873,10 @@ static const struct ethtool_ops enetc_pf_ethtool_ops = { .get_sset_count = enetc_get_sset_count, .get_strings = enetc_get_strings, .get_ethtool_stats = enetc_get_ethtool_stats, + .get_pause_stats = enetc_get_pause_stats, + .get_rmon_stats = enetc_get_rmon_stats, + .get_eth_ctrl_stats = enetc_get_eth_ctrl_stats, + .get_eth_mac_stats = enetc_get_eth_mac_stats, .get_rxnfc = enetc_get_rxnfc, .set_rxnfc = enetc_set_rxnfc, .get_rxfh_key_size = enetc_get_rxfh_key_size, From patchwork Tue Aug 16 22:29:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12945342 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93CFDC25B0E for ; Tue, 16 Aug 2022 22:30:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238023AbiHPWaE (ORCPT ); Tue, 16 Aug 2022 18:30:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237762AbiHPW3p (ORCPT ); Tue, 16 Aug 2022 18:29:45 -0400 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60064.outbound.protection.outlook.com [40.107.6.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CDD47B2BC for ; Tue, 16 Aug 2022 15:29:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h4+hmiRyxrw6nqpIp+lA+F/ja82UCCIQeblkUo65dzkR0L1VQb4sCLv4gF2rVh2BI7zGrDBZGMYIOLMNSG+dP4pAVgMK72NvdILthoDILjKu1ZOEmXFyFZs5QQfZ+obBQ8Eo1XfcbES/YrNvgCaNkd2HdVfabq5XPvG22+YyIMXph59L4BdKHii/wh1VL6qQZykeGJDba9JSgPqyJI6rlqveK4Jy2OwMVN5Hw1yLBidKXwKFUShy7aSPW+MA2Exf+o8DgDkJy7XkgV167KzK8ZNRnlliWddtdIZ0UeNRUAG/iV+lWbKWo8AzOaeK2mgNsF5YEghJOH/wQcrghrgUQw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ha117TNM1voikqTY0y+AdVW12QCG2cr1c0e7lFKDS3E=; b=V7Af8fIqmvIKLrLsSIqVSUrfDDS/xtJLqgcIyWRSKv8DGnpBCvCw0jGtJ4FiAmsg7ZE1VM9A3RBo64PG0k0utLOIN4kPmGPbWNtpWPD5bt7tzFnbQobqB8AZ2vb/aL49uzCLZTT43LBkdPuaPflsTIWIfza6tSBIv+fij45Vv02zVOHD0UOyGUCfg8AK41jvzfyQqhS8c0KZeI962zfqY7VU0ZhYXAtEhLaktHUP67NA7InkHyvwrKYKh7p5D2uNpVzeRNeylFwnVJ0xjyDwctuZvsHmVC2eGv9oZupflzn8qZ6nepRohcmNQy88Sg2m8cngyd4/G7qTS7wJscYOpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ha117TNM1voikqTY0y+AdVW12QCG2cr1c0e7lFKDS3E=; b=L2xSxaVFNBglWORG4QAvcDsK/MEwVCgeks2GrQ5UsNY5ZvYMmpsQehIikwVRbZO6uED+8ygCL/cUUqdOmJfAN49Z8oTWf1INHWxrZz0Kt9c5MzFnopU2J/ZUl961RdgpDeqLEUEKNBPcvzkzw1lm6owXExzXdBUlh2M/3EZ+y5s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8618.eurprd04.prod.outlook.com (2603:10a6:20b:439::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Tue, 16 Aug 2022 22:29:36 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::71b7:8ed1:e4e0:3857%4]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 22:29:36 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes Subject: [RFC PATCH net-next 7/7] net: enetc: add support for Frame Preemption and MAC Merge layer Date: Wed, 17 Aug 2022 01:29:20 +0300 Message-Id: <20220816222920.1952936-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816222920.1952936-1-vladimir.oltean@nxp.com> References: <20220816222920.1952936-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0021.eurprd05.prod.outlook.com (2603:10a6:800:92::31) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3ebeba5d-357f-439a-b626-08da7fd6ccc1 X-MS-TrafficTypeDiagnostic: AM9PR04MB8618:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SyUcOCKebGgnAseK7m5pzMCrB9lGQydr/2DuvWmolCudRSkTIe1jJHN1S3cMgC/3y7MGxZUp5igcjMubrs87SdmtS1n9yg5gOsZUs/OloZ7G5sFDCgxqFGQ1nCv/QjEDoupvMA9aLi7ksH34YP/MaahttJRm0s5Aq/APl/w5ViYx0M5PmNo3I3DbsckLpfv89jhLACpf3Pou2JilmBawTE1Dc0yro5b3uqgQZJIJp/P5+bThHUFGliJHsgxc9oahHdkdn45Aw+rGoigThoM0L9lnu/Pa4ESq7fXpdS3UiflC6KsIHia2AaECoZSXAIrmEPHnM9r/giQpXrnC0rC2vUNhUwpInYw+3hep2dNNfwd+ZsCjtV7K3BGm7dFIJ/KHT5e7xGbbN0vJAsksBjDPCBGhs68fF0LEs6zuwuM7dar0fYyi/t2GlX5xL5VNn8/jakUcozILeQLHrDQTA+a+ve2uNpfhQEO0ly+MtW2e30VVl/zFCAkxe9p5ZS7yyJ6JoZgOAoSOn61BVDwQ4heZxnxl0uWir5Vd7BF5VMDr595a8Fvnwt5zsZJG+JzM9ePDOcTe4Tg4/1VBrl2y/zAn5jFnMDxJgmZrc6fGupkDlZF5IxxFJ7Cz/OMOebOMZAGyHTm8LWjLPE9ff+NA8L44L8bC9yHKQ0dEgYlI0iibvgqfpBo6XULRldC+5x9kTKW8OXKJFlLX5rEzCy1dYbHe1Xp1+1CO3SN2EpkV2RDuILGzK+I0KYzpBakhM3XBzPzBt5uBIN22VpqJj3UYKELUwDrX7L3v6kuGHsPvNZWNC/4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(136003)(366004)(346002)(39860400002)(376002)(66946007)(44832011)(316002)(1076003)(66556008)(8676002)(83380400001)(41300700001)(6666004)(6916009)(4326008)(2906002)(36756003)(54906003)(186003)(2616005)(38100700002)(26005)(38350700002)(6506007)(6512007)(66476007)(6486002)(8936002)(86362001)(478600001)(52116002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WkD++nv0hUef88aI34+G84BSM53Ls4cObFS12X2pVh/RiUIRSJmMTRQIJawoPJuam8PqJhGdc9EMGQmoAzP2PEkq15eYiHRL4MqnlRW2rLyOP2kQFWjmi4f9Gj9qxA7OjI2VSP16tqtMJFs/A5AU2lqeEMpokvW5nrBf1BGkQ26Za59fkxHzOxmMLugcjaNqmXcbUrErnpCJRnwXZU8dlHk6+iz4miHiFlNM+nxRyS8j6AffSa8PAo9ULatxcWotMBZapOvzh2B+6Kz1TdiHwqxmlzWX9QJOBdH7OpKuLTKp0gBjSmppovmQflxgMRSwv/JMRgjMtuTVbYW7+LwBFlSSBhtxb4NndYRoFm7MRQ/dA4DwzCbJZVBXcyAqjrw5T722bk0oMRmfY4QjB1LGdzZ9fsnwEqmc/g3qywQ2oDUZQkOWJDP0XF22TtU7PJKwTmQ7Mt3TwmfO+QV4ymqDQid827s1PI2HSwS7GM77TaHczWRdPft6zgzM/7th+sgcNp4WiF7V0Ra3zmtNwziVl6WDrP+hKzPO0Dzt3mIrKrwBcoNN+wtwYHIKUBcPsj/PfnFrqoRf7LmhHh43fUSDqyzksW29qXfItWVorAHHFTkJnMp7YK5zJmJ5+0/ZrcXi0H9Nl/H4WGxgMlCNyNO1jCCeGspPhEndn6p1pbYL7hxPyrVlmv+p0PZESTCZjOGxfXW8su4aDond/12r5RGLoex6icOfhKA10fvVpw55/Buu+sW3bKj4uOFmZeATjE/n1sjKH4ff2NTdKn0gQ5wI2TYQKs8AN+ye6g5I0wpen3pGl7PFfTy5yvkr3kTtZCxEv9NWfMcoEVe3KmvgtLDwIVgjK187xpUaR03wS0jrAu7zPkkxk59RE48tjQDRr2usNXDIRvZx9F3L60ahkVV7zVAd5F4npjVYNzFK9erfxak29p+DtW6NHexaiaOxUWCo/VhSV8C4i4irqHgw69FIG9MFpge6xQP/T78O+4v2uIPpzrlDwp95w9q9Qt4DwBPpY/2soBHWcMnZsxXnDBrFQboAGVodOy1Bjjpzi9Xe49NjfJDHHobnutUerKrCBH/jqY/C1YjcVrp6hzFo3X/rdCHTho5UFZ/BQIHDrBB0VHLqLlSsRQZJsOYXRjNJgWAOrCU9adgPpg5wQYFNGvKfjVUyMRHmiRFhkc1aiCt2LZR/dq8Mp6jp3GAL8CeSbx47cvgpuurGZ2bmCgIli42Wb+g5LrfJUrgZOKpTLYSO0qXXvqNBSGGr0LmycrOwoyYZkR37uWCjM2JJxd5xpygUKQF+MtyKrOtIaBMfqhKIlXAPrjGPJUcxk8xLOsfA3eNenyN+a/Q+r7caJg3CmFqJ4N7xcljuWcZ0OOiChmJP52J43QqQxAi8MVVkvHxqvGEsAn0NjwD20BcFiYCAZkny8ULio7SFiwhiRots3j8EMHoV/xsTqzla98Wju686GSNpSHhN4rKyRfeVhZCpYLdX+pHdSJVerce/F30ssHZBewloU2fAQmJm1FSkMoHYzvXrUn6ZjwVxBjpDkF3atDik88GbXCbgOf04D3FlNxQEu/j/+cU4eFA67O7OnxUsd8TQ5+2kRRB87DUbZCKclr48lw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ebeba5d-357f-439a-b626-08da7fd6ccc1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 22:29:36.4603 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b6YJwsXG6xHH7BQzBQvlGkRwJE4oG4xmBjDNUuZuMMI2vVcaOnLTsGQoZy8bQWqo7Sh89dPuqXo3A+wQlIVBCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8618 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Add PF driver support for the following: - Viewing and changing the Frame Preemption parameters. Currently only the admin-status (preemptable/express per priority) is exposed. The spec also mentions HoldAdvance and ReleaseAdvance as times in ns, however the ENETC treats these as bytes, and we currently lack the proper logic to do the bit time <-> byte count conversion as the link speed changes. - Viewing and changing the MAC Merge sublayer parameters, and seeing the verification state machine's current state. The verification handshake with the link partner is driven by hardware. - Viewing the standardized MAC Merge layer counters. - Viewing the standardized Ethernet MAC and RMON counters associated with the pMAC. Signed-off-by: Vladimir Oltean --- .../ethernet/freescale/enetc/enetc_ethtool.c | 164 ++++++++++++++++++ .../net/ethernet/freescale/enetc/enetc_hw.h | 26 ++- 2 files changed, 189 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c index 25705b2c1be9..9a6869c7663a 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c @@ -408,6 +408,34 @@ static void enetc_get_rmon_stats(struct net_device *ndev, enetc_rmon_stats(hw, 0, rmon_stats, ranges); } +static void enetc_get_pmac_mac_stats(struct net_device *ndev, + struct ethtool_eth_mac_stats *mac_stats) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; + + enetc_mac_stats(hw, 1, mac_stats); +} + +static void enetc_get_pmac_ctrl_stats(struct net_device *ndev, + struct ethtool_eth_ctrl_stats *ctrl_stats) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; + + enetc_ctrl_stats(hw, 1, ctrl_stats); +} + +static void enetc_get_pmac_rmon_stats(struct net_device *ndev, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; + + enetc_rmon_stats(hw, 1, rmon_stats, ranges); +} + #define ENETC_RSSHASH_L3 (RXH_L2DA | RXH_VLAN | RXH_L3_PROTO | RXH_IP_SRC | \ RXH_IP_DST) #define ENETC_RSSHASH_L4 (ENETC_RSSHASH_L3 | RXH_L4_B_0_1 | RXH_L4_B_2_3) @@ -864,6 +892,134 @@ static int enetc_set_link_ksettings(struct net_device *dev, return phylink_ethtool_ksettings_set(priv->phylink, cmd); } +static void enetc_get_fp_param(struct net_device *ndev, + struct ethtool_fp_param *params) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + u32 val; + int tc; + + for (tc = 0; tc < 8; tc++) { + val = enetc_port_rd(&priv->si->hw, ENETC_PTCFPR(tc)); + + if (val & ENETC_PTCFPR_FPE) + params->preemptable_prios |= BIT(tc); + } +} + +static int enetc_set_fp_param(struct net_device *ndev, + const struct ethtool_fp_param *params, + struct netlink_ext_ack *extack) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + u32 val; + int tc; + + for (tc = 0; tc < 8; tc++) { + val = enetc_port_rd(&priv->si->hw, ENETC_PTCFPR(tc)); + + if (params->preemptable_prios & BIT(tc)) + val |= ENETC_PTCFPR_FPE; + else + val &= ~ENETC_PTCFPR_FPE; + + enetc_port_wr(&priv->si->hw, ENETC_PTCFPR(tc), val); + } + + return 0; +} + +static void enetc_get_mm_state(struct net_device *ndev, + struct ethtool_mm_state *state) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + u32 val; + + val = enetc_port_rd(&priv->si->hw, ENETC_MMCSR); + + switch (ENETC_MMCSR_GET_VSTS(val)) { + case 0: + state->verify_status = ETHTOOL_MM_VERIFY_STATUS_DISABLED; + break; + case 1: + state->verify_status = ETHTOOL_MM_VERIFY_STATUS_INITIAL; + break; + case 2: + state->verify_status = ETHTOOL_MM_VERIFY_STATUS_VERIFYING; + break; + case 3: + state->verify_status = ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED; + break; + case 4: + state->verify_status = ETHTOOL_MM_VERIFY_STATUS_FAILED; + break; + case 5: + default: + state->verify_status = ETHTOOL_MM_VERIFY_STATUS_UNKNOWN; + break; + } + + state->supported = val & ENETC_MMCSR_LPS; + state->enabled = val & ENETC_MMCSR_LPE; + state->active = val & ENETC_MMCSR_LPA; + state->add_frag_size = ENETC_MMCSR_GET_RAFS(val); + state->verify_time = ENETC_MMCSR_GET_VT(val); +} + +static int enetc_set_mm_cfg(struct net_device *ndev, + struct ethtool_mm_cfg *cfg, + struct netlink_ext_ack *extack) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + u32 val; + + if (cfg->add_frag_size > 3) { + NL_SET_ERR_MSG_MOD(extack, "addFragSize out of range 0-3"); + return -ERANGE; + } + + if (cfg->verify_time < 1 || cfg->verify_time > 128) { + NL_SET_ERR_MSG_MOD(extack, "verifyTime out of range 1-128 ms"); + return -ERANGE; + } + + val = enetc_port_rd(&priv->si->hw, ENETC_MMCSR); + + if (cfg->verify_disable) + val |= ENETC_MMCSR_VDIS; + else + val &= ~ENETC_MMCSR_VDIS; + + if (cfg->enabled) + val |= ENETC_MMCSR_ME; + else + val &= ~ENETC_MMCSR_ME; + + val &= ~ENETC_MMCSR_VT_MASK; + val |= ENETC_MMCSR_VT(cfg->verify_time); + + val &= ~ENETC_MMCSR_RAFS_MASK; + val |= ENETC_MMCSR_RAFS(cfg->add_frag_size); + + enetc_port_wr(&priv->si->hw, ENETC_MMCSR, val); + + return 0; +} + +static void enetc_get_mm_stats(struct net_device *ndev, + struct ethtool_mm_stats *s) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; + + s->MACMergeFrameAssErrorCount = enetc_port_rd(hw, ENETC_MMFAECR); + s->MACMergeFrameSmdErrorCount = enetc_port_rd(hw, ENETC_MMFSECR); + s->MACMergeFrameAssOkCount = enetc_port_rd(hw, ENETC_MMFAOCR); + s->MACMergeFragCountRx = enetc_port_rd(hw, ENETC_MMFCRXR); + s->MACMergeFragCountTx = enetc_port_rd(hw, ENETC_MMFCTXR); + s->MACMergeHoldCount = enetc_port_rd(hw, ENETC_MMHCR); +} + static const struct ethtool_ops enetc_pf_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES | @@ -877,6 +1033,9 @@ static const struct ethtool_ops enetc_pf_ethtool_ops = { .get_rmon_stats = enetc_get_rmon_stats, .get_eth_ctrl_stats = enetc_get_eth_ctrl_stats, .get_eth_mac_stats = enetc_get_eth_mac_stats, + .get_pmac_rmon_stats = enetc_get_pmac_rmon_stats, + .get_eth_pmac_ctrl_stats = enetc_get_pmac_ctrl_stats, + .get_eth_pmac_mac_stats = enetc_get_pmac_mac_stats, .get_rxnfc = enetc_get_rxnfc, .set_rxnfc = enetc_set_rxnfc, .get_rxfh_key_size = enetc_get_rxfh_key_size, @@ -894,6 +1053,11 @@ static const struct ethtool_ops enetc_pf_ethtool_ops = { .set_wol = enetc_set_wol, .get_pauseparam = enetc_get_pauseparam, .set_pauseparam = enetc_set_pauseparam, + .get_fp_param = enetc_get_fp_param, + .set_fp_param = enetc_set_fp_param, + .get_mm_state = enetc_get_mm_state, + .set_mm_cfg = enetc_set_mm_cfg, + .get_mm_stats = enetc_get_mm_stats, }; static const struct ethtool_ops enetc_vf_ethtool_ops = { diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 0b85e37a00eb..b39ef6f03b3d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -222,7 +222,27 @@ enum enetc_bdr_type {TX, RX}; #define ENETC_PSIVHFR0(n) (0x1e00 + (n) * 8) /* n = SI index */ #define ENETC_PSIVHFR1(n) (0x1e04 + (n) * 8) /* n = SI index */ #define ENETC_MMCSR 0x1f00 -#define ENETC_MMCSR_ME BIT(16) +#define ENETC_MMCSR_VT_MASK GENMASK(29, 23) /* Verify Time */ +#define ENETC_MMCSR_VT(x) (((x) << 23) & ENETC_MMCSR_VT_MASK) +#define ENETC_MMCSR_GET_VT(x) (((x) & ENETC_MMCSR_VT_MASK) >> 23) +#define ENETC_MMCSR_TXSTS_MASK GENMASK(22, 21) /* Merge Status */ +#define ENETC_MMCSR_GET_TXSTS(x) (((x) & ENETC_MMCSR_TXSTS_MASK) >> 21) +#define ENETC_MMCSR_VSTS_MASK GENMASK(20, 18) /* Verify Status */ +#define ENETC_MMCSR_GET_VSTS(x) (((x) & ENETC_MMCSR_VSTS_MASK) >> 18) +#define ENETC_MMCSR_VDIS BIT(17) /* Verify Disabled */ +#define ENETC_MMCSR_ME BIT(16) /* Merge Enabled */ +#define ENETC_MMCSR_RAFS_MASK GENMASK(9, 8) /* Remote Additional Fragment Size */ +#define ENETC_MMCSR_RAFS(x) (((x) << 8) & ENETC_MMCSR_RAFS_MASK) +#define ENETC_MMCSR_GET_RAFS(x) (((x) & ENETC_MMCSR_RAFS_MASK) >> 8) +#define ENETC_MMCSR_LPA BIT(2) /* Local Preemption Active */ +#define ENETC_MMCSR_LPE BIT(1) /* Local Preemption Enabled */ +#define ENETC_MMCSR_LPS BIT(0) /* Local Preemption Supported */ +#define ENETC_MMFAECR 0x1f08 +#define ENETC_MMFSECR 0x1f0c +#define ENETC_MMFAOCR 0x1f10 +#define ENETC_MMFCRXR 0x1f14 +#define ENETC_MMFCTXR 0x1f18 +#define ENETC_MMHCR 0x1f1c #define ENETC_PTCMSDUR(n) (0x2020 + (n) * 4) /* n = TC index [0..7] */ #define ENETC_PM0_CMD_CFG 0x8008 @@ -944,6 +964,10 @@ static inline u32 enetc_usecs_to_cycles(u32 usecs) return (u32)div_u64(usecs * ENETC_CLK, 1000000ULL); } +/* Port traffic class frame preemption register */ +#define ENETC_PTCFPR(n) (0x1910 + (n) * 4) /* n = [0 ..7] */ +#define ENETC_PTCFPR_FPE BIT(31) + /* port time gating control register */ #define ENETC_QBV_PTGCR_OFFSET 0x11a00 #define ENETC_QBV_TGE BIT(31)