From patchwork Wed Jan 11 16:16:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096908 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 54BC2C5479D for ; Wed, 11 Jan 2023 16:18:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235411AbjAKQRm (ORCPT ); Wed, 11 Jan 2023 11:17:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234496AbjAKQRc (ORCPT ); Wed, 11 Jan 2023 11:17:32 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2080.outbound.protection.outlook.com [40.107.247.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 722131C939; Wed, 11 Jan 2023 08:17:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gHRagcAPQCvv6bd3Ns5SBaBib3ppGY6hXsiLEna3wq95y4qnWqnb5nZ6Q7SURri/MZocr1U37BaZ/DAOxGSsoCm7PYt1js1ngP7iX+vcM0xfiPunnS6qrKitH1bPWZGFKQ+mYceaoBt7LIDXVLzNR5lE3jfTcrqfXKcp5MClg79afFRCKu+LRYvhUFFA+3ijeabBDwzGed8bUZeAQBWPJyuwXDvMYlL592ZqAK5ImZVYM5DXomVjgLzLjvNTxHhIHnvdqDXTJ/BLKiJTLjZJkvDkuPtW0ubRejulO4oue2T8nSS1UOtuXQZr2RA5GQcygz7+PbetF4UZSFwRVyyzjg== 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=U+K3mCrI0dzl3Y0k6y6S7df61prpHK+2vgLIdLHOEW0=; b=GiN/H2yMbmE3vGRLS38S7VZ7ywt4RILVu4WAraQQLXP4YJfqq2vMpon5ToB8bHgd6tlE8YyDM45oBUPy/K8il5qKGUgtLth3DmH/aaQncZtp787VBKfHez3394Zz426jO13Ji8IslD+gcB8VAPEf9ZqpSNFQtt2B49irVQgX+4/VfpVn0+iA1JXpPKmNk+ksNpZ1w5bqPONhMp6njUdSWQkEU38VnJEYEFF5ViHXqtGofXcGJIByvGh458gdmIvUVzbMb7SywdCjPA8cGbLlijse3O8jVp/u2ovPWjUFUicQzLgqpgEVouhdek7Cc7L4RZKMVpUUsnyoEuXo0P6+BQ== 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=U+K3mCrI0dzl3Y0k6y6S7df61prpHK+2vgLIdLHOEW0=; b=PfsOzVCgme38DLwSzVtlNWfEH+Zm9CXVHxpqPbEduOFpwjzBV7ZAktisuZAEtVgMR6tgeeABd0MV/nD459U9lgZ0cazwMsi3OyEelGMRqOf7Ofll4H+xKs4dalLYF1EL6BngyDW9lUH+x4aMvuRqOVee9vCbq0nS/5znq2WAH9c= 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 DB9PR04MB8462.eurprd04.prod.outlook.com (2603:10a6:10:2cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:18 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:18 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 01/12] net: ethtool: netlink: introduce ethnl_update_bool() Date: Wed, 11 Jan 2023 18:16:55 +0200 Message-Id: <20230111161706.1465242-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: ca3d3772-e488-4dad-c386-08daf3ef4f1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tsx1WU9uDnhYv6TkuzAvPBxtrv/BO9E/bbvkHOloGVDTWGNe5+B83L/PAp7bGqcTAa3w5PqDLZV04TQ0GU1AXltPrbdckaWSvTFzWnD6rxv+nFWNMdKaauxkJrYNManDD0qFWwyipNemF20ShB9Z89i/kl1ZrNAVZhBXAaihx6NZT5bp/QXqv/VDah61zJAdopR1vNBpJ/7PuLaIQTzqOeF2VfueZdriEenRUXInb29LI3VagvnruDLwQVHAwVgiH6mEq/wrABqMrg7vjV57sGEKWp312zKb3lDLjV4JVF/8JBJy5kI9ivzfjPQB692TLdX7lJum8F5cqmQXJK2D3tN+3K9AjELdSecxnFDzj5V0eeZGqAFtxOyPtib6GrKSTW66+XRouUozvOKAVBveHO3oJmkXX199XdDyMZfd7cBjbAPAqB4s4OfdCDK9QfV0Kl1D6DvdFreB3SGLAgpiCJofGF93/w2M925qju5K6Vbf6SBDrXFp/BezC3F0m4kHEKKtZ2wdNSdJAnECE1z0q/t+ZDc1Pnq4tX5kwew7UYKTmRTyP21dqQ/cI658bjNMNqXwJ3tRYJ1rFOnZgL0f4greXyXfABL7PArE9k3dUOCY9BkrsGA17v3/1oEyjHUcW6G6z06yoQKgtZe2kHRNQmI69U1pOReiAl/NrtHq8occo2h0soIiEY4THOFH1KhWKi2jIWOPAEMvG3ZQRvNiyv05T8y3B9cEaN54siItCAw= 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:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(36756003)(26005)(186003)(8936002)(6666004)(6512007)(6486002)(6506007)(1076003)(2616005)(66946007)(5660300002)(66476007)(66556008)(52116002)(7416002)(6916009)(316002)(4326008)(86362001)(41300700001)(38100700002)(38350700002)(478600001)(54906003)(8676002)(83380400001)(44832011)(2906002)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w+4mAdpHXDDBP1v9b3ZK0SVWAaXNiX2a2AflQbYcBlYwrJt9cZVSNL+ftELwEOEK7mR3ihN6LJu0ES3KYwBYmCYwsVgiH18KjINj51lxAfs6TqvvvUY3Zi/NzCTRAIJd9GX8JPs7J9GA/eY0S4WoCyLrnOiOjxqKho6dxKipri3gK20oA6n5TOQwDparZavZpoyaD/DwBFn9AsYFprdaRjeg/P55HuCgo8y1gxyhTXwrtfUQPbJfc57Or9+8ErRFo0FJjsL3knw/MwolwFtYeqNVPTz9tpkB6uyAWOTF0b3HMLSWvu6HzJIetexLJUjUJroROtlRCMTkymlEPVzh7lIJtVZK/1EyF53DFwj9L9LmFvc0W5b5tkFOt5UUjCPawdulcy7RUwlW3PagsiHvxKEPKK9T8k3wFIeWEDtTOKE/b/tfV4IJadPRkYRXalOSjmRU8HUUhncX1Y1AeptY6AFgzuQd0hC/YD4UozBjfJ7IibeOeDDb08/xKd30FdzGDk8dsnN3/1bkSAMgIGmiAdPztWU44Q17I8bIOhAwRSxBmlyhi9v0QcathYJ1BAC5cstXXRttqnonQr1F+ahPo/VTPhml0VZx6r7hY2Ir8rL+L6OzFwukLgcxI5ZvRx4mPFtNRAeDogvd4gB+hvd+gkGhGcNrccp58BmP0Ijp0+Akg/o825oog63d2GqRx47UH4aZXE93iXY/Bm+3Y93Srl4rdiHsEvu1bVdwpFo7f0/fEgonfXvnVJzH9rx90DFi3NlClwJrKPf8JRH2quJ5tvAswYrW90xDGnFzk77ggTZbAwP7Fa03A990gcgS/ZQErkSAx0hHonYyNEj0pocLOzp7XjXVyw4ceuhT/XcRkeHjsHtTkoWoVkJIKbJRisRSKNZDUstXKCFwwB/oE1VSojlU2DXMX0/xGipeu8kP/pjbA4iGc0QKL+B634arO6lsdDY9p0OIMGgSWduenmnZr9PsLbai4WqnjTGdQXElqfFrT+ETqUZt9ohLfsUNHjQ+Wl4Gj88zcOyPzpc4eOzUG08i3e5mDu0qc5ZWHB8LMU58H7WWslk4bRrvM9I6ib1eY73WdJVYesy8yuQAKJOtN9igxFcpT4B6v06r8HtceBH9yVkjJ4tetWw/Vxaajo9nVN+j0CguKjR3HnO5YyA669NL2btDfnfuxllxnPJwtUgXNyR7dj2WjXlbxgYxpvwSI6b7Zeabpoy4FPWWclMGm7GPmHDvVtUbBgGEFNPNFjPqCKgNz7V3MTM7fN9fws7P9f4Q+D2xtpeSjY1lJedOqfW8ZvsTwaqFyZV29PHO7mC9za33J+uoriQMoYkW3AbnLP2dujc/IeCwEZSaDCsU7T1HFe5sHO2qYDzW70Jw5abS5DoBNkdu401D2VdjPQBNPbn5xriSmBppakh/PL8ov6mV4ZcbLH0JDp6EvFyynbDXF/k7CwSnT8Ulk+6xUkNCMk1Wp/MF84SXpfCLuhCjevdqi11172fpGTCcz4Drf/gmi5LEFifuKqIiFM1g0bWYhOunJJWXpJHPMHxhvT9mzBKzTsuFVWAjXQtUZoWFC53sfQe2E0l6v+YTmj9jg8fEY3pY8JorUPB6M1rhF9rP1A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca3d3772-e488-4dad-c386-08daf3ef4f1d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:18.0336 (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: 7ZBHiy6hh7y34iz/Np0qtGXW5T86mfjciLPfbYcAeBome53HKQceG0Sinr6Cf627rZgIPlJVo80lTIgakKVbtQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Due to the fact that the kernel-side data structures have been carried over from the ioctl-based ethtool, we are now in the situation where we have an ethnl_update_bool32() function, but the plain function that operates on a boolean value kept in an actual u8 netlink attribute doesn't exist. With new ethtool features that are exposed solely over netlink, the kernel data structures will use the "bool" type, so we will need this kind of helper. Introduce it now; it's needed for things like verify-disabled for the MAC merge configuration. Signed-off-by: Vladimir Oltean --- v1->v2: rewrite commit message net/ethtool/netlink.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 3753787ba233..744b3ab966b0 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 Wed Jan 11 16:16:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096915 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 B94B9C67871 for ; Wed, 11 Jan 2023 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234094AbjAKQSW (ORCPT ); Wed, 11 Jan 2023 11:18:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234188AbjAKQRg (ORCPT ); Wed, 11 Jan 2023 11:17:36 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2080.outbound.protection.outlook.com [40.107.247.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 563D51CB13; Wed, 11 Jan 2023 08:17:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cKd4ZaGN2fwkTNtxxf5sM2pE4NDMfJ3KZ2l3ghF5cZUTnIKp37zyNACtUwXY0Vmgfa3CJVsxZm9PGr7NCaQcAIqv6r4bgSVy2WM2fMXCsrVs8zYVeTADut61Bauheho3oKaQnv7DKz5kjixcCgaBNHbeMVm40qlKuWUY+waCKkEnR1n+pCmCt9gYf/BzCxWbYf72QsLv39gWWk2NqKrmj4oVWJ3vvZyXTs/cl+OelHnVbpf2NNacF9Cvt5g36EkjJnOA/XfnLkChQo6ldOvV5DmLkaKEBu2E6kjXpkqZfPIMD7tHyhxUdqIaldLELCAKbdf+KDzYtYPIjOFBm3JVAQ== 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=qQOnehjKcyI98mQhWBbwELdea7SwmpicWmcqIuoAMx0=; b=O2pxn5QBjFjaN3W0+VJzrdXNjt8Q/35DiyELzPUyPCTa0WDJ9P777+k/8oSfRzbCQRKeHqVOxgCm5D5FFVTR9CS8lEE/k2JHJsAhI/bN8jAwiezIp3v2KdKlWYVgiTjYpawWdEgvqywEnk3c2446RZMjLazpi3oewKuCwPAtoZXNJT8ub8PeYeS2cWHxUxHCB2hVLTIVlUYNEwcUriQ9zbzUA8sF7CyOmJy9+BJeDrmMny8WrhipCeOIe01a1Ah/RuO8DNwJGWNkGjovK/VB3yt0eNDvoxwoYt5Gj9QDiL/3ZubFlJeIPQHM9OI9+67sNauImboxuUtl/J6PD2/gaQ== 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=qQOnehjKcyI98mQhWBbwELdea7SwmpicWmcqIuoAMx0=; b=Mf1cSTPncYUR193qcH1vxu1/HYP9JSHdVIcDncucryb70gSxAOfCsY992T8hEvfE6QqUgYJYlHi268lGR8fMZK1PCXMFlm0iBejwsf509VY4dAwiaI7JX6NHvdVE93g4JlTcmcpPGQHRbRh9nwxR5+1gom3KNyPAGqQtVtZttHw= 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 DB9PR04MB8462.eurprd04.prod.outlook.com (2603:10a6:10:2cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:19 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:19 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 02/12] net: ethtool: add support for MAC Merge layer Date: Wed, 11 Jan 2023 18:16:56 +0200 Message-Id: <20230111161706.1465242-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f797211-c0d4-489a-15f3-08daf3ef5018 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +pdawDRMlNsPpyPvmh0bYGeu4K5aRxME7xTRyh9YTei5/0KBepsqVcs7uuYW99Bdtx8RkhyRX3gczd58QoAW5Tayhx1BGzkoahUB00OWXR4G8S/1DTAJ6UqLlrY9Cqmw0rOg6pSu8wTKz2/eYauTJEW/nnjhyi9D0UBnLZDgPtGx+30zUYEXKMPy7/hzdEcQ+fxgQ9yPa1QA2fuCZv3HzsU+6VT/2SJNFaPRJBTpXvj4dsnPppnRyJ90JOvAZJWSMxarlMSnLJD51wbI9+Zr6H+QBdiY104yfXTC1GmWMUS+5YGOzSBXaa3w2yBBpq7Z/nijqVryieMz7ykZvkjBcdAVh/EJP95fJhvQ4GXS9SCAhHVpEjnA4UAgsDgRFllMtwCJ+YplizFUjPMP8NHzixX2SAFr+LO77aXgxTT07Gz7O6nZeZfam8dKlsIOdH0nEWxIPDc8IZ5AX+akfSFxg3LFY52PHsBHCf9wtrYxK2jyFIkU1ASjgGLNMWcCo3ALwbYEp3ENEwDsWUEoB/SfZr2O2nD9RDe+KxkLuEVUn5DoNYNP4kLA+kt7DCOOm7mt1kQ91mu/r4tT+FApsgXL1JGRSG7WCHc/FpstScgozl2KeAgQr0Y1xtasDFvkl0LrIhJBOdsNoSaEXi/QwN22D88z9ssjoGR0QxXa3nW6WtNq2N2ORZXAXbrzonQzQjIHFnq5W67WZRK3jFkLyI05rk6t/45cWad3HufZuL1DqSI= 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:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(36756003)(26005)(186003)(8936002)(6666004)(6512007)(6486002)(6506007)(30864003)(1076003)(2616005)(66946007)(5660300002)(66476007)(66556008)(52116002)(7416002)(6916009)(316002)(4326008)(86362001)(41300700001)(38100700002)(38350700002)(478600001)(54906003)(8676002)(83380400001)(66899015)(44832011)(2906002)(134885004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Dvgp12EUAQGQqCzXiTg9KAE23bc4?= =?utf-8?q?EhcDFIlOMTbGpcJhgWk9H3T8l6gPbhQaRsAC2NWVG4Ap4VzIpBRIbyZtqQw3ipmWL?= =?utf-8?q?6/v8fN8hEEdoBeMvTVqJWkFv9miUmxA0/aq7JzYrQT6Yo8cK70bEhAIo4qgGvQwlw?= =?utf-8?q?7pcOY7ggQK4mYS0NDND9DmUjZW32x2mArHfGeEbp1TuiP944SRxaJDWAS915/YyHT?= =?utf-8?q?p+5wLi9GEi9b0EXE4nUc1pZkHdblquVel3p2PHEbGhHbxtejx8kBeSRGaRivPKfeP?= =?utf-8?q?LjBvaBX82EmzmasRpbCqd+j22y5Y4d4JqH92Va2bAWJ1M7RG4KlXq82sUY6HQlybY?= =?utf-8?q?k9U5hkClMOqlki5ANqW6k7UTF4B9lz+tc+X/F+rbsyCV5DWUjg32ueqc/OnfZZ+Fm?= =?utf-8?q?lGKY3F6rx8pK+px582fH4UCG0b4LM0Qmus83AXaAq4kp8EQy6HHVsvosO/X1zUaz2?= =?utf-8?q?5xcm0WkprRFjCHT71fOU6I6626+YSow08yM+mNIzzv7ANEiMqPraaRtziODkJV0rq?= =?utf-8?q?Sbwqey423XOZGCOoRByLUEFs+wcGu3x5hZUxK+j6PtCn4zc1OW5JYXpvoNF+sflew?= =?utf-8?q?I4pup/iwUit5C/cQwlWx0ImsjtW+cRNhTW67MWIbXUJxsJnTAUAyhl3nhxs93l30t?= =?utf-8?q?EWWMMRDpdhZF5kxy4Y5Ex/D8ixwBngfuRAcwl5lSJVKYNvsRVYetA8eVkBR4i3m2X?= =?utf-8?q?SLZZxZTyilOG17hUKRR18rkkJ1NCIjvia9rk9F11bzLWuiL1R/QPcLohXBExy384f?= =?utf-8?q?tIlFAUxphzMl+vgESqRA7vMUVUcu+s8CRkLwZnaCyz6j5DK7pxjbyp0mnYaucGgRQ?= =?utf-8?q?n8g2ls3vo/SQLsgvXZZrWOlcC44b0do2EwcLHIQs88rfX9Ayi/TYm3qgZMaviIOsv?= =?utf-8?q?1UXhdPiKL5G3Au/1o/iFPVLyxFSONX2oiRQdjWUPCN9eOSP3y59Hf2UN2CQQ+C6zJ?= =?utf-8?q?Ev7lggOh5wd7o5spXhfhKsBwSOLaRfnS3t1RtLAt9Zj5/EdrdZ9uneXYHP8rm7M6Z?= =?utf-8?q?48FU+EtKf74FhTzZTGhPjRpmlJpg3R+jU+AYAl82Dd5+J8RzI6QJuzAxk4MSG091y?= =?utf-8?q?43rhU+ZP5TRUFVBlOpqJvriDeD9Y0UoKryTAC6rI+kXG6UsKJ3AHfFkMb5AimBaJ8?= =?utf-8?q?//l234ENq2yF62yB3ApjTY4+XxWS1Tx65HA6fu2j3CE/tq0aprvJvbzgrGSMjYFPY?= =?utf-8?q?GIOUfpzd2dfeeOhy56n4/qscHyb7ZGbhSpO9Ep/A5rnyXyG9zgKgMayAUYUhinZy0?= =?utf-8?q?vP8Tk3i6A2/ZY4rK7kTLC2uhEN2Vd5TSOfpklzAGYR9IuAVmr9Q1W/NLp6b16OMX7?= =?utf-8?q?XQUa74QO8haimcLPiLOo5EJfe/4sB5/kxjroVBMUIUIcQ+SQ4AOuMCteazQ7o3W9J?= =?utf-8?q?SKlHab4RPUAGIbFgzRgZfM8y4o3nnQFhfwVKH6b5QrJa5MYEmCYgMMNr5f8CVUOu7?= =?utf-8?q?CWHSXJk3Q4xHphocHiP2W8mc3l3bSci+eb/es3NN/MJAHUzSK1+WCH7M3yAY7Gzi5?= =?utf-8?q?y/Fxpsi5Xdld71NZ/d63K8NQgV5YMz/EFg=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f797211-c0d4-489a-15f3-08daf3ef5018 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:19.5022 (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: jyqJ5ublE9WWHOysLl+F3OE0rGcHBCC209BE4oHw/FfUEX2chT9IbQK+2Qv13wuQpoWr/+G0jM7Gis26Dkzd4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The MAC merge sublayer (IEEE 802.3-2018 clause 99) is one of 2 specifications (the other being Frame Preemption; IEEE 802.1Q-2018 clause 6.7.2), which work together to minimize latency caused by frame interference at TX. The overall goal of TSN is for normal traffic and traffic with a bounded deadline to be able to cohabitate on the same L2 network and not bother each other too much. The standards achieve this (partly) by introducing the concept of preemptible traffic, i.e. Ethernet frames that have a custom value for the Start-of-Frame-Delimiter (SFD), and these frames can be fragmented and reassembled at L2 on a link-local basis. The non-preemptible frames are called express traffic, they are transmitted using a normal SFD, and they can preempt preemptible 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 P frame cannot preempt another P frame. Preemption also does not depend upon priority, or otherwise said, an E frame with prio 0 will still preempt a P frame with prio 7. In terms of implementation, the standards talk about the presence of an express MAC (eMAC) which handles express traffic, and a preemptible MAC (pMAC) which handles preemptible traffic, and these MACs are multiplexed on the same MII by a MAC merge layer. To support frame preemption, the definition of the SFD was generalized to SMD (Start-of-mPacket-Delimiter), where an mPacket is essentially an Ethernet frame fragment, or a complete frame. Stations unaware of an SMD value different from the standard SFD will treat P frames as error frames. To prevent that from happening, a negotiation process is defined. On RX, packets are dispatched to the eMAC or pMAC after being filtered by their SMD. On TX, the eMAC/pMAC classification decision is taken by the 802.1Q spec, based on packet priority (each of the 8 user priority values may have an admin-status of preemptible or express). The MAC Merge layer and the Frame Preemption parameters have some degree of independence in terms of how software stacks are supposed to deal with them. The activation of the MM layer is supposed to be controlled by an LLDP daemon (after it has been communicated that the link partner also supports it), after which a (hardware-based or not) verification handshake takes place, before actually enabling the feature. So the process is intended to be relatively plug-and-play. Whereas FP settings are supposed to be coordinated across a network using something approximating NETCONF. The support contained here is exclusively for the 802.3 (MAC Merge) portions and not for the 802.1Q (Frame Preemption) parts. This API is sufficient for an LLDP daemon to do its job. The FP adminStatus variable from 802.1Q is outside the scope of an LLDP daemon. I have taken a few creative licenses and augmented the Linux kernel UAPI compared to the standard managed objects recommended by IEEE 802.3. These are: - ETHTOOL_A_MM_PMAC_ENABLED: According to Figure 99-6: Receive Processing state diagram, a MAC Merge layer is always supposed to be able to receive P frames. However, this implies keeping the pMAC powered on, which will consume needless power in applications where FP will never be used. If LLDP is used, the reception of an Additional Ethernet Capabilities TLV from the link partner is sufficient indication that the pMAC should be enabled. So my proposal is that in Linux, we keep the pMAC turned off by default and that user space turns it on when needed. - ETHTOOL_A_MM_VERIFY_ENABLED: The IEEE managed object is called aMACMergeVerifyDisableTx. I opted for consistency (positive logic) in the boolean netlink attributes offered, so this is also positive here. Other than the meaning being reversed, they correspond to the same thing. - ETHTOOL_A_MM_MAX_VERIFY_TIME: I found it most reasonable for a LLDP daemon to maximize the verifyTime variable (delay between SMD-V transmissions), to maximize its chances that the LP replies. IEEE says that the verifyTime can range between 1 and 128 ms, but the NXP ENETC stupidly keeps this variable in a 7 bit register, so the maximum supported value is 127 ms. I could have chosen to hardcode this in the LLDP daemon to a lower value, but why not let the kernel expose its supported range directly. Signed-off-by: Vladimir Oltean --- v1->v2: - added documentation - introduced pmac_enabled - transformed verify_disable into verify_enabled - made add_frag_size take a value in octets - removed FP params (adminStatus) - renamed "enabled" to "tx_enabled" and "active" to "tx_active" include/linux/ethtool.h | 99 ++++++++++ include/uapi/linux/ethtool.h | 25 +++ include/uapi/linux/ethtool_netlink.h | 47 +++++ net/ethtool/Makefile | 4 +- net/ethtool/mm.c | 258 +++++++++++++++++++++++++++ net/ethtool/netlink.c | 19 ++ net/ethtool/netlink.h | 4 + 7 files changed, 454 insertions(+), 2 deletions(-) create mode 100644 net/ethtool/mm.c diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 9e0a76fc7de9..6336f105e667 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -467,6 +467,98 @@ struct ethtool_module_power_mode_params { enum ethtool_module_power_mode mode; }; +/** + * struct ethtool_mm_state - 802.3 MAC merge layer state + * @verify_time: + * wait time between verification attempts in ms (according to clause + * 30.14.1.6 aMACMergeVerifyTime) + * @max_verify_time: + * maximum accepted value for the @verify_time variable in set requests + * @verify_status: + * state of the verification state machine of the MM layer (according to + * clause 30.14.1.2 aMACMergeStatusVerify) + * @supported: + * set if device supports the MM layer (according to clause 30.14.1.1 + * aMACMergeSupport) + * @tx_enabled: + * set if the MM layer is administratively enabled in the TX direction + * (according to clause 30.14.1.3 aMACMergeEnableTx) + * @tx_active: + * set if the MM layer is enabled in the TX direction, which makes FP + * possible (according to 30.14.1.5 aMACMergeStatusTx). This should be + * true if MM is enabled, and the verification status is either verified, + * or disabled. + * @pmac_enabled: + * set if the preemptible MAC is powered on and is able to receive + * preemptible packets and respond to verification frames. + * @verify_enabled: + * set if the Verify function of the MM layer (which sends SMD-V + * verification requests) is administratively enabled (regardless of + * whether it is currently in the ETHTOOL_MM_VERIFY_STATUS_DISABLED state + * or not), according to clause 30.14.1.4 aMACMergeVerifyDisableTx (but + * using positive rather than negative logic). The device should always + * respond to received SMD-V requests as long as @pmac_enabled is set. + * @add_frag_size: + * the minimum size of non-final mPacket fragments that the link partner + * supports receiving, expressed in octets. Compared to the definition + * from clause 30.14.1.7 aMACMergeAddFragSize which is expressed in the + * range 0 to 3 (requiring a translation to the size in octets according + * to the formula 64 * (1 + addFragSize) – 4), a value in a continuous and + * unbounded range can be specified here. + */ +struct ethtool_mm_state { + u32 verify_time; + u32 max_verify_time; + enum ethtool_mm_verify_status verify_status; + bool supported; + bool tx_enabled; + bool tx_active; + bool pmac_enabled; + bool verify_enabled; + u32 add_frag_size; +}; + +/** + * struct ethtool_mm_cfg - 802.3 MAC merge layer configuration + * @verify_time: see struct ethtool_mm_state + * @verify_enabled: see struct ethtool_mm_state + * @tx_enabled: see struct ethtool_mm_state + * @pmac_enabled: see struct ethtool_mm_state + * @add_frag_size: see struct ethtool_mm_state + */ +struct ethtool_mm_cfg { + u32 verify_time; + bool verify_enabled; + bool tx_enabled; + bool pmac_enabled; + u32 add_frag_size; +}; + +/** + * struct ethtool_mm_stats - 802.3 MAC merge layer statistics + * @MACMergeFrameAssErrorCount: + * received MAC frames with reassembly errors + * @MACMergeFrameSmdErrorCount: + * received MAC frames/fragments rejected due to unknown or incorrect SMD + * @MACMergeFrameAssOkCount: + * received MAC frames that were successfully reassembled and passed up + * @MACMergeFragCountRx: + * number of additional correct SMD-C mPackets received due to preemption + * @MACMergeFragCountTx: + * number of additional mPackets sent due to preemption + * @MACMergeHoldCount: + * number of times the MM layer entered the HOLD state, which blocks + * transmission of preemptible traffic + */ +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 @@ -639,6 +731,9 @@ 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_mm: Query the 802.3 MAC Merge layer state. + * @set_mm: 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 @@ -777,6 +872,10 @@ 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_mm)(struct net_device *dev, struct ethtool_mm_state *state); + int (*set_mm)(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 3135fa0ba9a4..7ddc47a3fb32 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -779,6 +779,31 @@ enum ethtool_podl_pse_pw_d_status { ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR, }; +/** + * enum ethtool_mm_verify_status - status of MAC Merge Verify function + * @ETHTOOL_MM_VERIFY_STATUS_UNKNOWN: + * verification status is unknown + * @ETHTOOL_MM_VERIFY_STATUS_INITIAL: + * the 802.3 Verify State diagram is in the state INIT_VERIFICATION + * @ETHTOOL_MM_VERIFY_STATUS_VERIFYING: + * the Verify State diagram is in the state VERIFICATION_IDLE, + * SEND_VERIFY or WAIT_FOR_RESPONSE + * @ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED: + * indicates that the Verify State diagram is in the state VERIFIED + * @ETHTOOL_MM_VERIFY_STATUS_FAILED: + * the Verify State diagram is in the state VERIFY_FAIL + * @ETHTOOL_MM_VERIFY_STATUS_DISABLED: + * verification of preemption operation is disabled + */ +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 5799a9db034e..e84a80957138 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -52,6 +52,8 @@ enum { ETHTOOL_MSG_PSE_GET, ETHTOOL_MSG_PSE_SET, ETHTOOL_MSG_RSS_GET, + ETHTOOL_MSG_MM_GET, + ETHTOOL_MSG_MM_SET, /* add new constants above here */ __ETHTOOL_MSG_USER_CNT, @@ -99,6 +101,8 @@ enum { ETHTOOL_MSG_MODULE_NTF, ETHTOOL_MSG_PSE_GET_REPLY, ETHTOOL_MSG_RSS_GET_REPLY, + ETHTOOL_MSG_MM_GET_REPLY, + ETHTOOL_MSG_MM_NTF, /* add new constants above here */ __ETHTOOL_MSG_KERNEL_CNT, @@ -894,6 +898,49 @@ enum { ETHTOOL_A_RSS_MAX = (__ETHTOOL_A_RSS_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_SUPPORTED, /* u8 */ + ETHTOOL_A_MM_PMAC_ENABLED, /* u8 */ + ETHTOOL_A_MM_TX_ENABLED, /* u8 */ + ETHTOOL_A_MM_TX_ACTIVE, /* u8 */ + ETHTOOL_A_MM_ADD_FRAG_SIZE, /* u32 */ + ETHTOOL_A_MM_VERIFY_ENABLED, /* u8 */ + ETHTOOL_A_MM_VERIFY_STATUS, /* u8 */ + ETHTOOL_A_MM_VERIFY_TIME, /* u32 */ + ETHTOOL_A_MM_MAX_VERIFY_TIME, /* u32 */ + 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 228f13df2e18..ab824b2d3b7d 100644 --- a/net/ethtool/Makefile +++ b/net/ethtool/Makefile @@ -7,5 +7,5 @@ obj-$(CONFIG_ETHTOOL_NETLINK) += ethtool_nl.o ethtool_nl-y := netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.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 \ - pse-pd.o + tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \ + module.o pse-pd.o diff --git a/net/ethtool/mm.c b/net/ethtool/mm.c new file mode 100644 index 000000000000..01a2acc40046 --- /dev/null +++ b/net/ethtool/mm.c @@ -0,0 +1,258 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright 2022-2023 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) + 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(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) +{ + struct mm_reply_data *data = MM_REPDATA(reply_base); + const struct ethtool_mm_state *state = &data->state; + int len = nla_total_size(sizeof(u8)); /* _MM_SUPPORTED */ + + if (!state->supported) + return len; + + len += nla_total_size(sizeof(u8)); /* _MM_PMAC_ENABLED */ + len += nla_total_size(sizeof(u8)); /* _MM_TX_ENABLED */ + len += nla_total_size(sizeof(u8)); /* _MM_TX_ACTIVE */ + len += nla_total_size(sizeof(u8)); /* _MM_VERIFY_ENABLED */ + len += nla_total_size(sizeof(u8)); /* _MM_VERIFY_STATUS */ + len += nla_total_size(sizeof(u32)); /* _MM_VERIFY_TIME */ + len += nla_total_size(sizeof(u32)); /* _MM_MAX_VERIFY_TIME */ + len += nla_total_size(sizeof(u32)); /* _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_SUPPORTED, state->supported)) + return -EMSGSIZE; + + if (!state->supported) + return 0; + + if (nla_put_u8(skb, ETHTOOL_A_MM_TX_ENABLED, state->tx_enabled) || + nla_put_u8(skb, ETHTOOL_A_MM_TX_ACTIVE, state->tx_active) || + nla_put_u8(skb, ETHTOOL_A_MM_PMAC_ENABLED, state->pmac_enabled) || + nla_put_u8(skb, ETHTOOL_A_MM_VERIFY_ENABLED, state->verify_enabled) || + 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_u32(skb, ETHTOOL_A_MM_MAX_VERIFY_TIME, state->max_verify_time) || + nla_put_u32(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_ENABLED] = NLA_POLICY_MAX(NLA_U8, 1), + [ETHTOOL_A_MM_VERIFY_TIME] = NLA_POLICY_RANGE(NLA_U32, 1, 128), + [ETHTOOL_A_MM_TX_ENABLED] = NLA_POLICY_MAX(NLA_U8, 1), + [ETHTOOL_A_MM_PMAC_ENABLED] = NLA_POLICY_MAX(NLA_U8, 1), + [ETHTOOL_A_MM_ADD_FRAG_SIZE] = NLA_POLICY_RANGE(NLA_U32, 60, 252), +}; + +static void mm_state_to_cfg(const struct ethtool_mm_state *state, + struct ethtool_mm_cfg *cfg) +{ + /* We could also compare state->verify_status against + * ETHTOOL_MM_VERIFY_STATUS_DISABLED, but state->verify_enabled + * is more like an administrative state which should be seen in + * ETHTOOL_MSG_MM_GET replies. For example, a port with verification + * disabled might be in the ETHTOOL_MM_VERIFY_STATUS_INITIAL + * if it's down. + */ + cfg->verify_enabled = state->verify_enabled; + cfg->verify_time = state->verify_time; + cfg->tx_enabled = state->tx_enabled; + cfg->pmac_enabled = state->pmac_enabled; + cfg->add_frag_size = state->add_frag_size; +} + +int ethnl_set_mm(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 || !ops->set_mm) { + ret = -EOPNOTSUPP; + goto out_dev; + } + + rtnl_lock(); + ret = ethnl_ops_begin(dev); + if (ret) + goto out_rtnl; + + ops->get_mm(dev, &state); + + mm_state_to_cfg(&state, &cfg); + + if (cfg.verify_time > state.max_verify_time) { + NL_SET_ERR_MSG_MOD(extack, "verifyTime exceeds device maximum"); + return -ERANGE; + } + + ethnl_update_bool(&cfg.verify_enabled, tb[ETHTOOL_A_MM_VERIFY_ENABLED], + &mod); + ethnl_update_u32(&cfg.verify_time, tb[ETHTOOL_A_MM_VERIFY_TIME], &mod); + ethnl_update_bool(&cfg.tx_enabled, tb[ETHTOOL_A_MM_TX_ENABLED], &mod); + ethnl_update_bool(&cfg.pmac_enabled, tb[ETHTOOL_A_MM_PMAC_ENABLED], + &mod); + ethnl_update_u32(&cfg.add_frag_size, tb[ETHTOOL_A_MM_ADD_FRAG_SIZE], + &mod); + + ret = ops->set_mm(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 aee98be6237f..a8c5b2521c46 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -288,6 +288,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_MODULE_GET] = ðnl_module_request_ops, [ETHTOOL_MSG_PSE_GET] = ðnl_pse_request_ops, [ETHTOOL_MSG_RSS_GET] = ðnl_rss_request_ops, + [ETHTOOL_MSG_MM_GET] = ðnl_mm_request_ops, }; static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb) @@ -603,6 +604,7 @@ 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_MM_NTF] = ðnl_mm_request_ops, }; /* default notification handler */ @@ -696,6 +698,7 @@ 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_MM_NTF] = ethnl_default_notify, }; void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data) @@ -1047,6 +1050,22 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_rss_get_policy, .maxattr = ARRAY_SIZE(ethnl_rss_get_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, + .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 744b3ab966b0..a8012dbe39bb 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -373,6 +373,7 @@ 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_pse_request_ops; extern const struct ethnl_request_ops ethnl_rss_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]; @@ -414,6 +415,8 @@ extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MO extern const struct nla_policy ethnl_pse_get_policy[ETHTOOL_A_PSE_HEADER + 1]; extern const struct nla_policy ethnl_pse_set_policy[ETHTOOL_A_PSE_MAX + 1]; extern const struct nla_policy ethnl_rss_get_policy[ETHTOOL_A_RSS_CONTEXT + 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); @@ -434,6 +437,7 @@ 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_pse(struct sk_buff *skb, struct genl_info *info); +int ethnl_set_mm(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 Wed Jan 11 16:16:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096910 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 94B5DC54EBC for ; Wed, 11 Jan 2023 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233772AbjAKQSU (ORCPT ); Wed, 11 Jan 2023 11:18:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235083AbjAKQRh (ORCPT ); Wed, 11 Jan 2023 11:17:37 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2080.outbound.protection.outlook.com [40.107.247.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D1831DF10; Wed, 11 Jan 2023 08:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OluN8MMnqrnL/x1ov4vyanC2VUu9axCxVpiT3A46XCD0vlXSNEj859SFG0qz08lyqJkwwx0tU6S/cRO2WCAhRxP+nc6H5Rc9CKcVJzHUu5o5jqjLH40HycUvOdpUnJwACLJXxmSo5YEF+V7cp+m20x4IbwXzb3q8kaXzkT9JPy6jKSa8j1wEIOz1FBQcX4+ZYMU9v06SdgwXe6e4npYEtB3GqqSqznV1VC7ljeu3lPfCCn/3H7e7npZ1fs2txG92d2LQa7LoTei85MUOIId/3+0Ok3hBDkVh6A9mWsdFuf6zQ3kkbGqOT6kKS6hhEYLjUOo57/Irc6y/l40qTb/qfA== 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=EyQA46oB9Nuwxm78aAlK8CAGOcobwYp/BmmaMYYxMH4=; b=VMZdvP+hPfkmO85kTbrI0O8NFQMBlI/rtzM8YWO2xl4YZNnzDELUMEgwNO037/+CRH6NniQThzVuxzftuwiJy/dLR2iUnqN3v1UCXJa3LvJn/01iy5FhfaICxVPPBQoTJJ80Vv3jMzCHRdFixAlpSZ/SVeobfu/7kPq9CIKomwpFrciSKwldQeTr52gjvc0WTJcbUyqcSCWXRc27OCE7OIArU/RQcX9fXS8euVJ+wwxXqja1GV9Z3/HmVYeubD9HTFgI66urxi4Uf12JRWJkqOBl2Tehp+GrcZKhf+IOjBWbjUP6iKleftAGbAlksvKaEiG4DA9Xpxm0ePM2EjNZWg== 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=EyQA46oB9Nuwxm78aAlK8CAGOcobwYp/BmmaMYYxMH4=; b=l/z6uhjwzp5tbXQ4tLQtUtjftLP7cqN/BwFaEUhtr63xfyyvgY8XxeOZdsMWTohY1Qy0/TfxQ5famIVRmzENg9F7tssNnLsw7daXLT5frRlwgcgoJMEvvZ+It7RPRT3iG2qj9JsC7Go8L3EeTu7H1//q+E44UqeA1E6S7j1Yj9I= 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 DB9PR04MB8462.eurprd04.prod.outlook.com (2603:10a6:10:2cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:21 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:21 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 03/12] docs: ethtool-netlink: document interface for MAC Merge layer Date: Wed, 11 Jan 2023 18:16:57 +0200 Message-Id: <20230111161706.1465242-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: dee1bc98-0e1a-42d5-913a-08daf3ef50fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QWrsJowkyv0jegM0DMRfXrKuPEEdFqXSrQQZcZ8pwexLGgEn+YXBsM+PsAbLFuzs3QZyjNKP+ToGToEG9QShJn5Nz2IScsV8ToRN8ILftuODUhsd5TN1ARgHpMf2IgUSSDJ6WElp3SyGGpRbdgw3cUHGyRgXKl+f52fDhW18hbvVIVeUQtkVHyEZOyWoDN4/S9wVN+sCoV7HyjsJwIP8F+lZAM2sQY3omOZKPY+AmX52Vg6kOuPFiwOVz6tvxcrfx2+0sShR+Ye28nq0HnmaNCrcy22gPHYUFIJUvtJguLS1q6a7u3O70aP7sJwjWxKglCu/0Joo5EnyD5S8CMGTjSno3vZsiIQ/mVJnoXDfND0KhvNj86FBvlJ6ps8TaHJrNeBRhLTlYQgnalddTbOJ52+x/Fzku6zYBxjVcvGW7XsVZsXBnIW1Cbo1WJkeHXqUnGGV8DVugrGsjSn5CLbTk01z+1C3r9gLR309VjrPVfxJPTij4LBG1q9INYRcMlGe8o+aGbV/ossq9SqJvuHnWT9XonQVEbrWTACqHwEz1tV+IPLkN6Ty9LoIBtVAWyrs7xO88k6oPc7HjVgzsBqdWOyJABwhD47pneSnvrpGN3afnK6EJVwDtUfg3ag6Sm+hhcTE+7SACyPZGPwJI+TgD3KUb+2tadv+E+AzTKy2ZPGo0yXWIQM8npdhT0oOfaza 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:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(36756003)(26005)(186003)(8936002)(6666004)(6512007)(6486002)(6506007)(1076003)(2616005)(66946007)(5660300002)(66476007)(66556008)(52116002)(7416002)(6916009)(316002)(4326008)(86362001)(41300700001)(38100700002)(38350700002)(478600001)(54906003)(8676002)(83380400001)(44832011)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B7TbzZXX8smKVmcg0rQzADLtIuIITpUKKZLeNcrswxI9+BON4F/0Qdxvh+RZlO4rRT5iCNIVWyNrqgK4AlDs43OqIPEZjdsPCrNSwJBRY3SvcgEBKtCTWrLPU4aP20oUltRoXwxxgj+GezgK9ZKWKRWscfxODKlaitb6y3GJEborSAvXrlwR7zBj7vNz8Rw11tGaeHsS2LCqsmQ3eOx8zhppVPalnVnAd91eLyhex+eMxT7KWC03QaiBHa2D/kjK/+bE2WrMunWzcueGDqFoRhrSa4CxEnJ26qvhdNjXccSGRxfLMSz4HKlyKL7nb5LgZXwl3qFn997PpJFhjIgT1u7iQfbvjf/Pyy7CekBFkqPZ8+FBpH3V/Hahci9ONywnQYKCBOLaoMxAudARTqQWQBBYnn/U9A9Z9m1zTVzkuMyVgXuySf+05mIPgIAXKuQ2CqlsDOwBdAg8gEhFrSeJVMVvvxWKHTaXsZqsstVRdFKElVnCDUEwaDl++AG8gMfpHWe1iqO5OCUkiZ3WEr0OilKtBx69wx5vgzLnVTALCh2g7P4Dk99MrbaAnN9TIKPAYH5sRWLO1nvQFpgduukLG7iR9ji4VP/5QnvNc0wdaKoJ5bmf+S5HselJpkVXoIZ4dMJ1ZjUaGTq2nfXWBubWYRtOMn0+U6qRPvBKju1YApi9W6AxrdnadFH2Gk/SAezTVD5VLurHBmF0+V4CvsqKsZKV95uVkRLpfJB7IqVBSHRPl/D+gtKKDeRweprx3lHZcgH43Ydy8hVdDzTavSjjuE5wDzbSEA3T0JBDAN6d8o4k6xuUF6M0y6Qwz0OoyskF1wDpNB2LH48bs8W47mOp1PK3ql0JlCbKaJWVhjn2+XBiY82GKbR5zlXpK41umRKSuBo040WhLJBpm+RT0YwG9cxoIx+wbaPyttIGoDGRCfS0732d7vbb9NbjMjHGpFzpBNEFXjmfPlGRNh6yzkLw0g+4nBwGzZDNaDkAuUXQ7nxcSSrrcYXS0HgiT1oBt1H1YtjiAvPT73LI3TJsaex355uwSOAn07wuJAHASEWQZTa7roPdQ7CzTRlD4M9INc9Xw/9hSc18UPCITasKmC7YLw3Roj/zyykkedwqCOn8s0gTFtTzS7PSnKUSj/XlmmRp7sgKEB2OHa2HacWW4O2BBrQ3o4VXuDk37r4x7DWACA0mqA52Zl2Bw9YtGicWPHtsFFG5uUY13SMaZE489rp+dod/8ziZtV/A6pXoXhZcsnZcw7s6KzUj+uIOjCM1cT0SijM8SeWKNfj0m4os1TqHcmQqnya/I8qrnYSfAHJzZIWgiRhaUGjX2oO3RGvQvDikL6F8K3ISOLTn+pxMftH/idpxnIvR+r+2dE8sob02Bn3oMQoJj3d6lruHJJg0RTEILg/nEAXuEk76sloRpfRJgjGjZHa33vposX5PjHa0GKhoLS+7VddoVaHrKpNBZSOQxBKqxd/AuRY62VnoU0TrSIPFvegBxg7Pg5RoTscg71svbikBIZ5wFBHKD3TY/xWzZyPKTdWD3YlITgkAKQ4y9Vul3iW/8YClf7whG1IG26S+bepT/+P0gR1L72iV2hzuZ/FgRD7jqorNq9j7jQaK4w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dee1bc98-0e1a-42d5-913a-08daf3ef50fa X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:21.0021 (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: b4VAPOkfEwACYs7v+jmnzhtSU0HB345gJ3BBgASMOvvkwHBWEqRGZaunYKuBiap6MOxcRiDw6wfE4CDwHTwoTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Show details about the structures passed back and forth related to MAC Merge layer configuration, state and statistics. The rendered htmldocs will be much more verbose due to the kerneldoc references. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new Documentation/networking/ethtool-netlink.rst | 103 +++++++++++++++++++ Documentation/networking/statistics.rst | 1 + 2 files changed, 104 insertions(+) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index f10f8eb44255..490c2280ce4f 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -223,6 +223,8 @@ Userspace to kernel: ``ETHTOOL_MSG_PSE_SET`` set PSE parameters ``ETHTOOL_MSG_PSE_GET`` get PSE parameters ``ETHTOOL_MSG_RSS_GET`` get RSS settings + ``ETHTOOL_MSG_MM_GET`` get MAC merge layer state + ``ETHTOOL_MSG_MM_SET`` set MAC merge layer parameters ===================================== ================================= Kernel to userspace: @@ -265,6 +267,7 @@ Kernel to userspace: ``ETHTOOL_MSG_MODULE_GET_REPLY`` transceiver module parameters ``ETHTOOL_MSG_PSE_GET_REPLY`` PSE parameters ``ETHTOOL_MSG_RSS_GET_REPLY`` RSS settings + ``ETHTOOL_MSG_MM_GET_REPLY`` MAC merge layer status ======================================== ================================= ``GET`` requests are sent by userspace applications to retrieve device @@ -1716,6 +1719,104 @@ being used. Current supported options are toeplitz, xor or crc32. ETHTOOL_A_RSS_INDIR attribute returns RSS indrection table where each byte indicates queue number. +MM_GET +====== + +Retrieve 802.3 MAC Merge parameters. + +Request contents: + + ==================================== ====== ========================== + ``ETHTOOL_A_MM_HEADER`` nested request header + ==================================== ====== ========================== + +Kernel response contents: + + ================================ ====== =================================== + ``ETHTOOL_A_MM_HEADER`` Nested request header + + ``ETHTOOL_A_MM_SUPPORTED`` Bool set if device supports the MM layer + + ``ETHTOOL_A_MM_PMAC_ENABLED`` Bool set if RX of preemptible and SMD-V + frames is enabled + + ``ETHTOOL_A_MM_TX_ENABLED`` Bool set if TX of preemptible frames is + administratively enabled (might be + inactive if verification failed) + + ``ETHTOOL_A_MM_TX_ACTIVE`` Bool set if TX of preemptible frames is + operationally enabled + + ``ETHTOOL_A_MM_ADD_FRAG_SIZE`` U32 minimum size of transmitted + non-final fragments, in octets + + ``ETHTOOL_A_MM_VERIFY_ENABLED`` Bool set if TX of SMD-V frames is + administratively enabled (TX will + not take place when port is not up) + + ``ETHTOOL_A_MM_VERIFY_STATUS`` U8 state of the Verify function + + ``ETHTOOL_A_MM_VERIFY_TIME`` U32 delay between verification attempts + + ``ETHTOOL_A_MM_MAX_VERIFY_TIME`` U32 maximum interval supported by + device + + ``ETHTOOL_A_MM_STATS`` Nested IEEE 802.3-2018 subclause 30.14.1 + oMACMergeEntity statistics counters + + ================================ ====== =================================== + +If ``ETHTOOL_A_MM_SUPPORTED`` is reported as false, the other netlink +attributes will be absent. + +The attributes are populated by the device driver through the following +structure: + +.. kernel-doc:: include/linux/ethtool.h + :identifiers: ethtool_mm_state + +The ``ETHTOOL_A_MM_VERIFY_STATUS`` will report one of the values from + +.. kernel-doc:: include/uapi/linux/ethtool.h + :identifiers: ethtool_mm_verify_status + +If ``ETHTOOL_A_MM_VERIFY_ENABLED`` was passed as false in the ``MM_SET`` +command, ``ETHTOOL_A_MM_VERIFY_STATUS`` will report either +``ETHTOOL_MM_VERIFY_STATUS_INITIAL`` or ``ETHTOOL_MM_VERIFY_STATUS_DISABLED``, +otherwise it should report one of the other states. + +It is recommended that drivers start with the pMAC disabled, and enable it upon +user space request. It is also recommended that user space does not depend upon +the default values from ``ETHTOOL_MSG_MM_GET`` requests. + +``ETHTOOL_A_MM_STATS`` are reported if ``ETHTOOL_FLAG_STATS`` was set in +``ETHTOOL_A_HEADER_FLAGS``. The attribute will be empty if driver did not +report any statistics. Drivers fill in the statistics in the following +structure: + +.. kernel-doc:: include/linux/ethtool.h + :identifiers: ethtool_mm_stats + +MM_SET +====== + +Modifies the configuration of the 802.3 MAC Merge layer. + +Request contents: + + ====================================== ====== ========================== + ``ETHTOOL_A_MM_VERIFY_TIME`` u32 see MM_GET description + ``ETHTOOL_A_MM_VERIFY_ENABLED`` bool see MM_GET description + ``ETHTOOL_A_MM_TX_ENABLED`` bool see MM_GET description + ``ETHTOOL_A_MM_PMAC_ENABLED`` bool see MM_GET description + ``ETHTOOL_A_MM_ADD_FRAG_SIZE`` u32 see MM_GET description + ====================================== ====== ========================== + +The attributes are propagated to the driver through the following structure: + +.. kernel-doc:: include/linux/ethtool.h + :identifiers: ethtool_mm_cfg + Request translation =================== @@ -1817,4 +1918,6 @@ are netlink only. n/a ``ETHTOOL_MSG_PHC_VCLOCKS_GET`` n/a ``ETHTOOL_MSG_MODULE_GET`` n/a ``ETHTOOL_MSG_MODULE_SET`` + n/a ``ETHTOOL_MSG_MM_GET`` + n/a ``ETHTOOL_MSG_MM_SET`` =================================== ===================================== diff --git a/Documentation/networking/statistics.rst b/Documentation/networking/statistics.rst index c9aeb70dafa2..551b3cc29a41 100644 --- a/Documentation/networking/statistics.rst +++ b/Documentation/networking/statistics.rst @@ -171,6 +171,7 @@ statistics are supported in the following commands: - `ETHTOOL_MSG_PAUSE_GET` - `ETHTOOL_MSG_FEC_GET` + - `ETHTOOL_MSG_MM_GET` debugfs ------- From patchwork Wed Jan 11 16:16:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096917 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 1703BC678D9 for ; Wed, 11 Jan 2023 16:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235120AbjAKQSd (ORCPT ); Wed, 11 Jan 2023 11:18:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235408AbjAKQRl (ORCPT ); Wed, 11 Jan 2023 11:17:41 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2080.outbound.protection.outlook.com [40.107.247.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C42B1EED5; Wed, 11 Jan 2023 08:17:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nISfIWYp9gjHM0yWd/RVkpDjl+YLgjQ2uYHB/cuUOJ8BCtVmr6aKvKhDVYYYH/ng3VXIMQjs7EdRbzvzn1tKxPGNrUeJJu05U4YyCGfFeWglSjgE8aB3NuIe7GA5gzEThv+ay+uurqOCkoRv6+lWAv8aFCyzB1gnOvpKVW9EIwK5E2W7NbqdVi/wPoMpIexKxpM0NJmA1j9ajQvySKtcbT41NMOV5lKKBR1mTVEj85kw+C7VKQayaFdwGtER0YcHiIV7c5hLi98cDrPNg/EVEceueV3ljxbqAm+S8QWzmyF7nTngCov9wRClUeY/M2641BIW7C1Znh6SL0qLudHcMA== 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=n5gtlDo9Zu/zdICZlMt4zyblurSebPPn8C34wmr0xHw=; b=K3LhjJfIbhgYjkbaRwwB7H3TSe5poe0bYEGT1CpqDC0uDCMXd2wIUGNXHw/1GVlkT4tx/Orhbqt+VWAmrp3FpyIeiRGqYLoRSzwtl95NlR6EjijAQT1YTZ39lQFYZ5D3Y70qa79VpjPXC0skxt5pXSiBKHczTuSHk0gPpDT2mPBl7SUnGSrM34nfDjhUXUPhaKfsEn44wVeJvIwsT22cJSXCaNcSB/5JQsoi+/8RvQxSpr+UEw3RD+L6hu+IF8WoNPZsDvSXCd+G9gVqOeTYw/HQ+jNjnjD0b7jkkakLzS+uOyts09TgZDznYGNR+tYGtufoD0+HYtf8r3QtYaIRvg== 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=n5gtlDo9Zu/zdICZlMt4zyblurSebPPn8C34wmr0xHw=; b=eIE4sibsi8kH/WWc0lW0sTNdjA79HVIQ9rrTcinxLAn42sCosAp2XsyPhSuHRVMcgFo2G8+ZJ32V8cjfZyDkfCpebyVkvoTzsK5xtj0TG2op0PDweqqrdrVei4zoe4+/UrNA2AmkutDGjEXXYcSbHP7tPhMUfjhyF6ys50y6ZOM= 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 DB9PR04MB8462.eurprd04.prod.outlook.com (2603:10a6:10:2cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:22 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:22 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 04/12] net: ethtool: netlink: retrieve stats from multiple sources (eMAC, pMAC) Date: Wed, 11 Jan 2023 18:16:58 +0200 Message-Id: <20230111161706.1465242-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: b247e166-ffbe-4a24-0c93-08daf3ef51dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O8SXM24RebcI1bCmPXGFeYdCFEF5lrIKwAgl70As4ZwMJIaZoszKUEodRQD+Hj0T+YLrUzSSx1RiOkiQ5txflbaQ5Q68XXMBPneId8NCk6437zRyXZUWWpV/2sNMra100fFmVA0MPsECVFHo2CS8Wie/B7LN2neZGvhXP9WGMfPg/1+DyfUnVqFo5fIV7BTBV5HP2ckNRVdxO+vqzEkZTBAlrBsSU4Qfa/9tsIvCA/R4NuGHsj2LMuFkGcd1DaORrKwoUhG7+6MNZB0eRYmIAf87rLPDjk7kh1IIqjBBnlRPPPkyqE1MDqoezzHnGa2jU0/6bL+10mrokIWAUqrH6dph2Ccj+EmmeqxISQkHdbugOQGzTN4ZVSWw9UDzAjViedxAV99T42DomgIUdg5RnFWJAI9I7kr98ZY/8vtoy25qr1C6hwsPgdnFP2wIUjy25LuTIVx7f9yE9/Hv5kg/RcbS1onovHNxWO+ffV5OYgg2qMzN8H/eyzFfeQhwNtrSFzP5jGKRvBZvXplmjEMSVmm2bSCqy9gjXGJ+nYNRaRmxJR1NpWJDzPHQDvrnw9disQRHj1UpzrkK65p5IFWwqid0rFislFQxvQKrQW6fL35DNLSO9ejdR0+TwiQZLtzsHB3ZrH9h/5uFxfBPri0NdErf8U71GzJoHfOLAAbjaFOYry3kr5i9Sq2bNZnmYo2JUZ/7jXQSWdMD8b550MD1OPiLBk7BKrdjjoofU7z79Nk= 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:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(36756003)(26005)(186003)(8936002)(6666004)(6512007)(6486002)(6506007)(30864003)(1076003)(2616005)(66946007)(5660300002)(66476007)(66556008)(52116002)(7416002)(6916009)(316002)(4326008)(86362001)(41300700001)(38100700002)(38350700002)(478600001)(54906003)(8676002)(83380400001)(44832011)(2906002)(134885004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TDfRZYNQS3QHUpSIskNziV2+dFVOd+vdDdzFWi6YXnFK62XTb0w9LYSe3uU4eYPR7b1kZ0rlSnbInmqDT47UbhSD6PvQ52qAUnxzSSG/8PMlw997Zx4DMSlipTxy+QHkHIxQS/RruHToFPF1pT4QoA756TqJ1sf/Fyxt13K8V6gfNccY3GQ8WwUkeRsvSwM3CavEeypy1e0z26xE375JYOLr/dDm+g94wLqlXhORKKIMHyJqjX8GInmLg+qs5BJ5Vc/gjgM2QEEz6NO2qz1+hTb7XXT/uJtXfD6brrOVB+VKkiyHNdbAyhXQgPvYJHu/bhyk+DdPp0YCeSVdNpRwrHoI5LWr4Xnhf8zaE+8H7HkAKSnQ83HA7xpUHqvjPaPPTCOFsJgkjhxcne5oUw73UB5iSag7bvXMUWnzpSqt3e+Ev2Ofx+iCu3qfgA+DVOzSP3xP2zwKdo0zFOlz2gRdEeAcXyEmtnWWqGbTousSEkrty6qFPchRdXHLhZJ4zlpqcwp8/2C6+MpZlsogD/q8MYjj2JTDvqJhKKp1iuYv1QOXhpWf+AYiXMWDBGkn+1plr9KeWXoX6IzcFC+WVOjXYnu+IYbdJKIMTeXSM1kwomeGl8wwpnFrVgu+SMnId4mq0aKtitdG44MyviCo6cVPiXec2EFaBzg/6tSKl/jhDnfXrrBE3iK87c8OU2zM60c4Sp8uNOgpuFfuTglw/BPnpCX9fd2e4oLz6pWrtgOwXIaubAshrgS9mBwMm1cMlzClv5Y+uf8fGQRWyQbOw9+nBwI+oVL42VjBtRSIwIcWmobcIjuuSvdDg3FiQGc1NalVbqanSBJNZlyJbhRoainf827GE6fi9jUR6SpGgnviGSO9AA1/CWfwQhQpURg4z+Z1bUx5o2klM//JxrVrGwwx5vrGhxEzymMwFWc5Zqu29Dftn8uriXqrsDhhxmjZ8v/WaCGrc2LlDqA4tnOeZtABCGkl7Hrl7XX2mGoSwClQ+y2TdT0AlzQqYQ7F5HAI/fxeKr5P/fIMKcIhUghf1Z/e2Z+jobmNG/c23OJvK5Qhq4/jRzSv9jeCd4IRzCpKJVtL02EPqeLRRaSeaImEjpf5/ky2VOY4w/JUMpin9XSYfu+g3BpYqAnAsvt+mKDY0RL+MjKU3HhnD/Y28fx69Aq+tgtYtdGmLQXdf6lO+hlFCp9/W0i2SZn1CCpB40P68z+cV52IaVbt+jZF9wRF1vEn0OehWcmAvDs5QkScjav35yJmx1d4ysTMRQEWTnP9XukX28mmP0YmcVbc4tM0AuzlReOGp/rP+ogh9yoIPDhmx7Z6+EcMh6dKLOTHBXVgUwstHUW0dqcYK+a22QdmQ7Wg1IBg7Zdp2pJW/AmL6vewh/X1TW6lwV61oU2f8WrgXNCvBxYJDwg947teFoYQX6GYXcnrRho5lA0a6wF/su9x+71QWDNKoz0hJ7U1ILBxEGs1JswthUSNoz41ricv1JV1mKnHebTiJMdOAKoXiduv2Zyzm8QDCq0itwVJz8k1y1cgTM5lK5iNUS9UwOG/Gtb9KbeMqGENyO2HahvohnbzPI4FUQ3enCcHx+/5t3/ctBN+O5FrR53g0kXguyYPNWljAA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b247e166-ffbe-4a24-0c93-08daf3ef51dd X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:22.5020 (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: v1dbGJB/EupKsXh+8tTrfxSoH3z0BxmzH74ZHCIdK1zWV1kH3awdYBFaWu6WskSvcCe1N0lwa5eCXCml3+oHtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org IEEE 802.3-2018 clause 99 defines a MAC Merge sublayer which contains an Express MAC and a Preemptable MAC. Both MACs are hidden to higher and lower layers and visible as a single MAC (packet classification to eMAC or pMAC on TX is done based on priority; classification on RX is done based on SFD). For devices which support a MAC Merge sublayer, it is desirable to retrieve individual packet counters from the eMAC and the pMAC, as well as aggregate statistics (their sum). Introduce a new ETHTOOL_A_STATS_SRC attribute which is part of the policy of ETHTOOL_MSG_STATS_GET and, and an ETHTOOL_A_PAUSE_STATS_SRC which is part of the policy of ETHTOOL_MSG_PAUSE_GET (accepted when ETHTOOL_FLAG_STATS is set in the common ethtool header). Both of these take values from enum ethtool_stats_src, defaulting to "aggregate" in the absence of the attribute. Existing drivers do not need to pay attention to this enum which was added to all driver-facing structures, just the ones which report the MAC merge layer as supported. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new (Jakub's suggestion) include/linux/ethtool.h | 9 ++++++ include/uapi/linux/ethtool.h | 18 +++++++++++ include/uapi/linux/ethtool_netlink.h | 3 ++ net/ethtool/common.h | 2 ++ net/ethtool/mm.c | 15 +++++++++ net/ethtool/netlink.h | 4 +-- net/ethtool/pause.c | 47 ++++++++++++++++++++++++++++ net/ethtool/stats.c | 31 ++++++++++++++++-- 8 files changed, 125 insertions(+), 4 deletions(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 6336f105e667..06672b76b2c6 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -301,6 +301,7 @@ static inline void ethtool_stats_init(u64 *stats, unsigned int n) * via a more targeted API. */ struct ethtool_eth_mac_stats { + enum ethtool_stats_src src; u64 FramesTransmittedOK; u64 SingleCollisionFrames; u64 MultipleCollisionFrames; @@ -329,6 +330,7 @@ struct ethtool_eth_mac_stats { * via a more targeted API. */ struct ethtool_eth_phy_stats { + enum ethtool_stats_src src; u64 SymbolErrorDuringCarrier; }; @@ -336,6 +338,7 @@ struct ethtool_eth_phy_stats { * via a more targeted API. */ struct ethtool_eth_ctrl_stats { + enum ethtool_stats_src src; u64 MACControlFramesTransmitted; u64 MACControlFramesReceived; u64 UnsupportedOpcodesReceived; @@ -343,6 +346,8 @@ struct ethtool_eth_ctrl_stats { /** * struct ethtool_pause_stats - statistics for IEEE 802.3x pause frames + * @src: input field denoting whether stats should be queried from the eMAC or + * pMAC (if the MM layer is supported). To be ignored otherwise. * @tx_pause_frames: transmitted pause frame count. Reported to user space * as %ETHTOOL_A_PAUSE_STAT_TX_FRAMES. * @@ -356,6 +361,7 @@ struct ethtool_eth_ctrl_stats { * from the standard. */ struct ethtool_pause_stats { + enum ethtool_stats_src src; u64 tx_pause_frames; u64 rx_pause_frames; }; @@ -407,6 +413,8 @@ struct ethtool_rmon_hist_range { /** * struct ethtool_rmon_stats - selected RMON (RFC 2819) statistics + * @src: input field denoting whether stats should be queried from the eMAC or + * pMAC (if the MM layer is supported). To be ignored otherwise. * @undersize_pkts: Equivalent to `etherStatsUndersizePkts` from the RFC. * @oversize_pkts: Equivalent to `etherStatsOversizePkts` from the RFC. * @fragments: Equivalent to `etherStatsFragments` from the RFC. @@ -422,6 +430,7 @@ struct ethtool_rmon_hist_range { * ranges is left to the driver. */ struct ethtool_rmon_stats { + enum ethtool_stats_src src; u64 undersize_pkts; u64 oversize_pkts; u64 fragments; diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index 7ddc47a3fb32..16230dc6a8c1 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -711,6 +711,24 @@ enum ethtool_stringset { ETH_SS_COUNT }; +/** + * enum ethtool_stats_src - source of ethtool statistics + * @ETHTOOL_STATS_SRC_AGGREGATE: + * if device supports a MAC merge layer, this retrieves the aggregate + * statistics of the eMAC and pMAC. Otherwise, it retrieves just the + * statistics of the single (express) MAC. + * @ETHTOOL_STATS_SRC_EMAC: + * if device supports a MM layer, this retrieves the eMAC statistics. + * Otherwise, it retrieves the statistics of the single (express) MAC. + * @ETHTOOL_STATS_SRC_PMAC: + * if device supports a MM layer, this retrieves the pMAC statistics. + */ +enum ethtool_stats_src { + ETHTOOL_STATS_SRC_AGGREGATE, + ETHTOOL_STATS_SRC_EMAC, + ETHTOOL_STATS_SRC_PMAC, +}; + /** * enum ethtool_module_power_mode_policy - plug-in module power mode policy * @ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH: Module is always in high power mode. diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index e84a80957138..e938a7a50944 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -419,6 +419,7 @@ enum { ETHTOOL_A_PAUSE_RX, /* u8 */ ETHTOOL_A_PAUSE_TX, /* u8 */ ETHTOOL_A_PAUSE_STATS, /* nest - _PAUSE_STAT_* */ + ETHTOOL_A_PAUSE_STATS_SRC, /* u32 */ /* add new constants above here */ __ETHTOOL_A_PAUSE_CNT, @@ -735,6 +736,8 @@ enum { ETHTOOL_A_STATS_GRP, /* nest - _A_STATS_GRP_* */ + ETHTOOL_A_STATS_SRC, /* u32 */ + /* add new constants above here */ __ETHTOOL_A_STATS_CNT, ETHTOOL_A_STATS_MAX = (__ETHTOOL_A_STATS_CNT - 1) diff --git a/net/ethtool/common.h b/net/ethtool/common.h index b1b9db810eca..28b8aaaf9bcb 100644 --- a/net/ethtool/common.h +++ b/net/ethtool/common.h @@ -54,4 +54,6 @@ int ethtool_get_module_info_call(struct net_device *dev, int ethtool_get_module_eeprom_call(struct net_device *dev, struct ethtool_eeprom *ee, u8 *data); +bool __ethtool_dev_mm_supported(struct net_device *dev); + #endif /* _ETHTOOL_COMMON_H */ diff --git a/net/ethtool/mm.c b/net/ethtool/mm.c index 01a2acc40046..b99fdfa49a32 100644 --- a/net/ethtool/mm.c +++ b/net/ethtool/mm.c @@ -256,3 +256,18 @@ int ethnl_set_mm(struct sk_buff *skb, struct genl_info *info) dev_put(dev); return ret; } + +/* Returns whether a given device supports the MAC merge layer + * (has an eMAC and a pMAC). Must be called under rtnl_lock() and + * ethnl_ops_begin(). + */ +bool __ethtool_dev_mm_supported(struct net_device *dev) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + struct ethtool_mm_state state = {}; + + if (ops && ops->get_mm) + ops->get_mm(dev, &state); + + return state.supported; +} diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index a8012dbe39bb..43d2a7c98a3d 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -397,7 +397,7 @@ extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_HEAD extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBINED_COUNT + 1]; extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER + 1]; extern const struct nla_policy ethnl_coalesce_set_policy[ETHTOOL_A_COALESCE_MAX + 1]; -extern const struct nla_policy ethnl_pause_get_policy[ETHTOOL_A_PAUSE_HEADER + 1]; +extern const struct nla_policy ethnl_pause_get_policy[ETHTOOL_A_PAUSE_STATS_SRC + 1]; extern const struct nla_policy ethnl_pause_set_policy[ETHTOOL_A_PAUSE_TX + 1]; extern const struct nla_policy ethnl_eee_get_policy[ETHTOOL_A_EEE_HEADER + 1]; extern const struct nla_policy ethnl_eee_set_policy[ETHTOOL_A_EEE_TX_LPI_TIMER + 1]; @@ -408,7 +408,7 @@ extern const struct nla_policy ethnl_tunnel_info_get_policy[ETHTOOL_A_TUNNEL_INF extern const struct nla_policy ethnl_fec_get_policy[ETHTOOL_A_FEC_HEADER + 1]; extern const struct nla_policy ethnl_fec_set_policy[ETHTOOL_A_FEC_AUTO + 1]; extern const struct nla_policy ethnl_module_eeprom_get_policy[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS + 1]; -extern const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_GROUPS + 1]; +extern const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_SRC + 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]; diff --git a/net/ethtool/pause.c b/net/ethtool/pause.c index a8c113d244db..f3eac539f9a4 100644 --- a/net/ethtool/pause.c +++ b/net/ethtool/pause.c @@ -5,8 +5,12 @@ struct pause_req_info { struct ethnl_req_info base; + enum ethtool_stats_src src; }; +#define PAUSE_REQINFO(__req_base) \ + container_of(__req_base, struct pause_req_info, base) + struct pause_reply_data { struct ethnl_reply_data base; struct ethtool_pauseparam pauseparam; @@ -19,13 +23,40 @@ struct pause_reply_data { const struct nla_policy ethnl_pause_get_policy[] = { [ETHTOOL_A_PAUSE_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy_stats), + [ETHTOOL_A_PAUSE_STATS_SRC] = + NLA_POLICY_MAX(NLA_U32, ETHTOOL_STATS_SRC_PMAC), }; +static int pause_parse_request(struct ethnl_req_info *req_base, + struct nlattr **tb, + struct netlink_ext_ack *extack) +{ + struct pause_req_info *req_info = PAUSE_REQINFO(req_base); + enum ethtool_stats_src src = ETHTOOL_STATS_SRC_AGGREGATE; + + if (tb[ETHTOOL_A_PAUSE_STATS_SRC]) { + if (!(req_base->flags & ETHTOOL_FLAG_STATS)) { + NL_SET_ERR_MSG_MOD(extack, + "ETHTOOL_FLAG_STATS must be set when requesting a source of stats"); + return -EINVAL; + } + + src = nla_get_u32(tb[ETHTOOL_A_PAUSE_STATS_SRC]); + } + + req_info->src = src; + + return 0; +} + static int pause_prepare_data(const struct ethnl_req_info *req_base, struct ethnl_reply_data *reply_base, struct genl_info *info) { + const struct pause_req_info *req_info = PAUSE_REQINFO(req_base); struct pause_reply_data *data = PAUSE_REPDATA(reply_base); + struct netlink_ext_ack *extack = info->extack; + enum ethtool_stats_src src = req_info->src; struct net_device *dev = reply_base->dev; int ret; @@ -34,14 +65,25 @@ static int pause_prepare_data(const struct ethnl_req_info *req_base, ethtool_stats_init((u64 *)&data->pausestat, sizeof(data->pausestat) / 8); + data->pausestat.src = src; ret = ethnl_ops_begin(dev); if (ret < 0) return ret; + + if ((src == ETHTOOL_STATS_SRC_EMAC || src == ETHTOOL_STATS_SRC_PMAC) && + !__ethtool_dev_mm_supported(dev)) { + NL_SET_ERR_MSG_MOD(extack, + "Device does not support MAC merge layer"); + ethnl_ops_complete(dev); + return -EOPNOTSUPP; + } + dev->ethtool_ops->get_pauseparam(dev, &data->pauseparam); if (req_base->flags & ETHTOOL_FLAG_STATS && dev->ethtool_ops->get_pause_stats) dev->ethtool_ops->get_pause_stats(dev, &data->pausestat); + ethnl_ops_complete(dev); return 0; @@ -56,6 +98,7 @@ static int pause_reply_size(const struct ethnl_req_info *req_base, if (req_base->flags & ETHTOOL_FLAG_STATS) n += nla_total_size(0) + /* _PAUSE_STATS */ + nla_total_size(sizeof(u32)) + /* _PAUSE_STATS_SRC */ nla_total_size_64bit(sizeof(u64)) * ETHTOOL_PAUSE_STAT_CNT; return n; } @@ -77,6 +120,9 @@ static int pause_put_stats(struct sk_buff *skb, const u16 pad = ETHTOOL_A_PAUSE_STAT_PAD; struct nlattr *nest; + if (nla_put_u32(skb, ETHTOOL_A_PAUSE_STATS_SRC, pause_stats->src)) + return -EMSGSIZE; + nest = nla_nest_start(skb, ETHTOOL_A_PAUSE_STATS); if (!nest) return -EMSGSIZE; @@ -121,6 +167,7 @@ const struct ethnl_request_ops ethnl_pause_request_ops = { .req_info_size = sizeof(struct pause_req_info), .reply_data_size = sizeof(struct pause_reply_data), + .parse_request = pause_parse_request, .prepare_data = pause_prepare_data, .reply_size = pause_reply_size, .fill_reply = pause_fill_reply, diff --git a/net/ethtool/stats.c b/net/ethtool/stats.c index a20e0a24ff61..9238d99f560b 100644 --- a/net/ethtool/stats.c +++ b/net/ethtool/stats.c @@ -7,6 +7,7 @@ struct stats_req_info { struct ethnl_req_info base; DECLARE_BITMAP(stat_mask, __ETHTOOL_STATS_CNT); + enum ethtool_stats_src src; }; #define STATS_REQINFO(__req_base) \ @@ -75,10 +76,12 @@ const char stats_rmon_names[__ETHTOOL_A_STATS_RMON_CNT][ETH_GSTRING_LEN] = { [ETHTOOL_A_STATS_RMON_JABBER] = "etherStatsJabbers", }; -const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_GROUPS + 1] = { +const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_SRC + 1] = { [ETHTOOL_A_STATS_HEADER] = NLA_POLICY_NESTED(ethnl_header_policy), [ETHTOOL_A_STATS_GROUPS] = { .type = NLA_NESTED }, + [ETHTOOL_A_STATS_SRC] = + NLA_POLICY_MAX(NLA_U32, ETHTOOL_STATS_SRC_PMAC), }; static int stats_parse_request(struct ethnl_req_info *req_base, @@ -86,6 +89,7 @@ static int stats_parse_request(struct ethnl_req_info *req_base, struct netlink_ext_ack *extack) { struct stats_req_info *req_info = STATS_REQINFO(req_base); + enum ethtool_stats_src src = ETHTOOL_STATS_SRC_AGGREGATE; bool mod = false; int err; @@ -100,6 +104,11 @@ static int stats_parse_request(struct ethnl_req_info *req_base, return -EINVAL; } + if (tb[ETHTOOL_A_STATS_SRC]) + src = nla_get_u32(tb[ETHTOOL_A_STATS_SRC]); + + req_info->src = src; + return 0; } @@ -109,6 +118,8 @@ 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 netlink_ext_ack *extack = info->extack; + enum ethtool_stats_src src = req_info->src; struct net_device *dev = reply_base->dev; int ret; @@ -116,11 +127,24 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base, if (ret < 0) return ret; + if ((src == ETHTOOL_STATS_SRC_EMAC || src == ETHTOOL_STATS_SRC_PMAC) && + !__ethtool_dev_mm_supported(dev)) { + NL_SET_ERR_MSG_MOD(extack, + "Device does not support MAC merge layer"); + ethnl_ops_complete(dev); + return -EOPNOTSUPP; + } + /* Mark all stats as unset (see ETHTOOL_STAT_NOT_SET) to prevent them * from being reported to user space in case driver did not set them. */ memset(&data->stats, 0xff, sizeof(data->stats)); + data->phy_stats.src = src; + data->mac_stats.src = src; + data->ctrl_stats.src = src; + data->rmon_stats.src = src; + 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); @@ -143,8 +167,8 @@ static int stats_reply_size(const struct ethnl_req_info *req_base, const struct ethnl_reply_data *reply_base) { const struct stats_req_info *req_info = STATS_REQINFO(req_base); + int len = nla_total_size(sizeof(u32)); /* _STATS_SRC */ unsigned int n_grps = 0, n_stats = 0; - int len = 0; if (test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask)) { n_stats += sizeof(struct ethtool_eth_phy_stats) / sizeof(u64); @@ -379,6 +403,9 @@ static int stats_fill_reply(struct sk_buff *skb, const struct stats_reply_data *data = STATS_REPDATA(reply_base); int ret = 0; + if (nla_put_u32(skb, ETHTOOL_A_STATS_SRC, req_info->src)) + return -EMSGSIZE; + if (!ret && test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask)) ret = stats_put_stats(skb, data, ETHTOOL_STATS_ETH_PHY, ETH_SS_STATS_ETH_PHY, From patchwork Wed Jan 11 16:16:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096919 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 30F9DC5479D for ; Wed, 11 Jan 2023 16:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235408AbjAKQSm (ORCPT ); Wed, 11 Jan 2023 11:18:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235426AbjAKQRn (ORCPT ); Wed, 11 Jan 2023 11:17:43 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2080.outbound.protection.outlook.com [40.107.247.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EDC422C; Wed, 11 Jan 2023 08:17:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VTGAMjRSbReUQUWzhG884sC+TlgXI9FB2uoqsTGKGMwAXE/awvfV1Q3J/N1B71dgSMVCM4uTfoISs+vJG7Ge0EInBjezN5Y38tpzfX4lUkDDHkCcUUhhxYuVPpIYW59P388RECMTesweafsbg3ePuj6T9zJZldjHo+KvJ886Y2FJ72cUgnZCRte+OQJEY+qQ6XbfTWgcGbXNxJ6cGDRR3ZirH0NAJn3G3mfhlyaG9EC2FW3V26lS3hb58TUWfVCSruWACJQBfMW3OJrW0KZQUKiZBYXw9ZXfoX+obYXsr6uPF3bQWTFulnbHOTjt/DAvZ05YspeZRoZ6JPmkJotmpg== 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=cnt1GnRC1O1VQddtx48dYukW1sO5DRswUmys6wy7AhI=; b=mC7wmgdCy/40Js7n/1jGiECcUWiBlH6kjGwq9IZVgOIcicX5z3C2tk4Op7Jc/i2uTAcdG/z47W119E9C1le0/CRV7kRMvsFH4lO0cnYFBsXEW+0bOm82weLyqgot5qmfI1mXuyUrrmuPC2U1AEvF8FR1mFc013f61+42Tmr3XkPTJanRY9gfW2LY0WPvYssdiv5wbg3Q2k7ISEKi2fZyBS8nN921du1c29igM9+EhAOHlFKON5VvPjUrS482cGjoz5tS2p3a+GMgKCewhiMt2LmJAKCb/c+9zPhGTk/3gxjXReni8MTxI4lgQJc0HWAVOH8yw5iNoTQiqEWTjQa6fg== 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=cnt1GnRC1O1VQddtx48dYukW1sO5DRswUmys6wy7AhI=; b=rxSy5FUwGXKiqcPmTuFOiMXsWfKyEvPZjIXuBquybofMej0FvDdLTCMWaXD/LUmyd9hz0+cpgcSqXz0h9CAVb7xnsC+ts5DgleDpGrJ3fyKb9d5gwB6OQsMZTtL/DzFgrAxainIM8ncjmLZkwnPregQsMjmnj2e3rSQThUYi4uo= 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 DB9PR04MB8462.eurprd04.prod.outlook.com (2603:10a6:10:2cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:24 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:24 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 05/12] docs: ethtool: document ETHTOOL_A_STATS_SRC and ETHTOOL_A_PAUSE_STATS_SRC Date: Wed, 11 Jan 2023 18:16:59 +0200 Message-Id: <20230111161706.1465242-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 18130050-9d84-472b-110e-08daf3ef52c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hNeustVFZ8w2mEl0JOxoCl2+hImk5BqdcowsuyuPCib213+uV9LmqQaPDEjxyYzy2ja5wzUnsSenEqnH8drqYNzQRI7k94svFby/Uit1/6jbJfIhWH0x1E1ANuq1Mwb3eftRcGhR7t/451xAEIYHMIVl8y1oagY3LbmEw4Er8VNZE+6Hn2u23VHm6LjDHet3ymy2gwR6y8LEwOcbvpnE68Xt38dVEtZiOi5Ce0C6kcFZl2TspXqJyM97J1D1VF5L6T/jdM7co02QN+yLUwVwtqXiS2aJItEhmlztf/pl1hJ3eNsX/o4APWPORXcQr1STd/vJ92jfDQVCkgkubRsGeQaYVW/Qjac+/viXuaPfqamMGiAzMwZXodfIQrFVlSjak+G8H1Ut3scr6vjn0ruvCLsIok24j6jfa1zzCo7jIj2qx3Wcttu7++XELHqnf5SrZeTpzhHzTt2Cv9+DjUTIXN939XHAqrU5bJ/cEP9TC0IVmcRsKsXOCrbZQFcWJ06J+eXTmkTFiaPhbuAq1klti1Y4vd7SbsGGUqFK5h/541GIvKeAExBY894s2772uhQz5N84qsy6brBXjkMxD+oeVQf0J12/cNsT8/fhz+BE9XfQltbK6lRsLlwROhg3OT8dnQKhI9ssWtDtsaObqbCWPaYvvlfJ74gHnqbppK55TSG6Tt2LSelFTx/r8qjYUey8 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:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(36756003)(26005)(186003)(8936002)(6666004)(6512007)(6486002)(6506007)(1076003)(2616005)(66946007)(5660300002)(66476007)(66556008)(52116002)(7416002)(6916009)(316002)(4326008)(19627235002)(86362001)(41300700001)(38100700002)(38350700002)(478600001)(54906003)(8676002)(83380400001)(44832011)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RuDgozuwyDZns+uCSkQdJnZcFx+xrKN/LAp7nJa664cGl8bAgdk2n1OH/OovBwav9gfpovqYu6gqATlF8s9PWwcCGrtHghdWEMGX5FflLgotkYNXqILs0HW5AV2qkIQ8wLt8nt57bK0M5iWozgEdcUzhsS5UOGdVYLKQh1JA3SGx8MnRiaRFbrcISxXbeeALxvq0aU//Fa/2UKe6Pk/tBtKhO/zoZQPZZMNB90AvVdhLxO+pCngXeT9RSO1pFeS/O/3xxmsSnNa1tmhWlko8DKHUF4matnR/yJ9WbcL6d21Gsh2fZkithJlcZHurhOeeqk/2AMmu+xTkPebx9/U4vE7GE/IPRkQO6+rvtjrMRqqvE5fthcscFaZJhw+HRG3nsjefJ7MTbOdkAum/OmNuzt2o4W5f1P7ZeNRv4yht9bluQ83PTjXiX8soJgnGY6PNhaK5thlvWENd7bioikeSqza/BozdXj099wvYfxSzIIH5z0JffzXjyJEGBQ5Irux1Gslidy3HW8/WtZMRpps9aUVFNBCWj70Nx4nfuEb66Bsk87empuUBqmRJvm6NFnB380WivVbbqUbE4v351GMHa4U0F0ZKoK9HoTSC+CIFz3uG6c/kp+7wr9s4Oj+m67fFMumLeppxHOMx6pLUs3FPOiTZkbEQVjw10Z5PkfXwgAPEFvFAlpyjmAq0lr2WDLkqTVYjXMdeYv7Ib2U85C1sGENA7FaHQPKiz/slnOZzUM+A8YkllukESW2eco8uSi3j7iZsgbBzII+ifCR+6puNonqx0s95E0J0zRZUkqNjjPyN5KacndPL2Hl1dHzPCGjXTMI43nAoO1QiZoPeRZSBumT9Mnz3T/IbeahRZ5VplKRFWDHfo1BZJea0VqNMF8HM8SpdOuiUH60gxK8FMl2oc5/Qb6JEbj4hBcXXELA7FWpOUwDND6FPo/EAUOAeQNUzvbeBJ9Ba3sU0JdShynHqKULyE1vtVqbpYN3JU+18bjxApn807VMmlx4tBiwHWdGY6GavEJNsZLTfTyDxsYF0j+T2BGayjpTvyjLEpv5BiC/AmelNuhfrmLsCw5i1Ynnb4pgfd61wJPYoM7dPXZv1FWBWuEzY29TCuN1Aeol765QZyHtoDcvJl7N89aTGdKGXPeUeb3z6Qcr7DmkStL/AjKD4d15lbmEQWwQ94JIQ8HKJChvTq2c9B5H0xBGdC3RKPKflpilorwNTiRl2n0828wNoNqhZ9OVDV4dzhbDZ9Nz7CK8qOq5ajnhvGQhoikSayj9nAG6WOhdfdWblRSTw4l/OcN/YoBR44Ounwet4giXGK5+7nwIomH1HUxfkhxNYKhNQVqa8/T0XWlW4f3JLy0YCPp1sZ6wrPmkym/c7IXFthgm3+ZsVB+TT5nHKX8rbQ5GPfPibXjgUAGyMWQY9IhJ2LLMMAPwg/r4+KGLkuZf1cn94127gN7EbLyPDnH1Ol1clJ+secG/TBJHIY/1X69vNa8+MT6QfXqoyokkapgMaDM4iJI8BSDFF/jOsIAOsKENtn6Pngpvd+5RHrG+yfBXv43AKKFg/kOq1P0TAXkZLqR5bELJ4e5reO8ZU7OKeg7HAINO++CUaPWTw3BKjuw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18130050-9d84-472b-110e-08daf3ef52c9 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:23.9551 (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: 1i7ACDhV3aNYq5sxGEO7u6XnnNKnlYFig7f2MxZYrXyZWlUSC6VcyjatLn/MtGYzbsEzYUcxCf6vHeR/EoFnBA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Two new netlink attributes were added to PAUSE_GET and STATS_GET and their replies. Document them. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new Documentation/networking/ethtool-netlink.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index 490c2280ce4f..3805e57f9888 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -1075,8 +1075,17 @@ Request contents: ===================================== ====== ========================== ``ETHTOOL_A_PAUSE_HEADER`` nested request header + ``ETHTOOL_A_PAUSE_STATS_SRC`` u32 source of statistics ===================================== ====== ========================== +``ETHTOOL_A_STATS_SRC`` is optional. It takes values from: + +.. kernel-doc:: include/uapi/linux/ethtool.h + :identifiers: ethtool_stats_src + +If absent from the request, stats will be provided with +``ETHTOOL_A_STATS_SRC_AGGREGATE`` in the response. + Kernel response contents: ===================================== ====== ========================== @@ -1491,6 +1500,7 @@ Request contents: ======================================= ====== ========================== ``ETHTOOL_A_STATS_HEADER`` nested request header + ``ETHTOOL_A_STATS_SRC`` u32 source of statistics ``ETHTOOL_A_STATS_GROUPS`` bitset requested groups of stats ======================================= ====== ========================== @@ -1499,6 +1509,8 @@ Kernel response contents: +-----------------------------------+--------+--------------------------------+ | ``ETHTOOL_A_STATS_HEADER`` | nested | reply header | +-----------------------------------+--------+--------------------------------+ + | ``ETHTOOL_A_STATS_SRC`` | u32 | source of statistics | + +-----------------------------------+--------+--------------------------------+ | ``ETHTOOL_A_STATS_GRP`` | nested | one or more group of stats | +-+---------------------------------+--------+--------------------------------+ | | ``ETHTOOL_A_STATS_GRP_ID`` | u32 | group ID - ``ETHTOOL_STATS_*`` | @@ -1560,6 +1572,14 @@ Low and high bounds are inclusive, for example: etherStatsPkts512to1023Octets 512 1023 ============================= ==== ==== +``ETHTOOL_A_STATS_SRC`` is optional. It takes values from: + +.. kernel-doc:: include/uapi/linux/ethtool.h + :identifiers: ethtool_stats_src + +If absent from the request, stats will be provided with +``ETHTOOL_A_STATS_SRC_AGGREGATE`` in the response. + PHC_VCLOCKS_GET =============== From patchwork Wed Jan 11 16:17:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096918 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 47851C678DA for ; Wed, 11 Jan 2023 16:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238228AbjAKQSi (ORCPT ); Wed, 11 Jan 2023 11:18:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235533AbjAKQRq (ORCPT ); Wed, 11 Jan 2023 11:17:46 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2080.outbound.protection.outlook.com [40.107.247.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4D715FA0; Wed, 11 Jan 2023 08:17:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c+x3qu/7kaj6nm2nJroPhotS4QTTJ6KAjH5vv/pdsPpD5fm/kKgPb2o47d+qlKHW7jZTK/kqicN8T83Z+jzkczvCDQ9ZcEdA4PqVnSgnM+zyky11qKdcrrglp0rUNnRl1PYiYN8SQc1CEv/oENh6R0kBRAn7sXFVAUqTF3n9oekogWaC89yngkoD6HwCeRH+3dCM1YegD5v93tYIlHjY9wPp4YWzGBbrXfrD++tKWwZTMg+3mPTfHSzGfbPTmCXjPtgnk4Oy/5EPr9fgT2UedPlXIhMpWy69JQv4lOETq1jlpXjHXRStlgdRZoI0Bam3ccVsW8n4IoJFtapTC45KPw== 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=+KIt1gxmewtqqj6relnLOGcy/Yqt8J2A6GF8RQ0THJI=; b=Im1ahf1G5wwCuDw5o+EDp2uCNKsLiFcMo1MFce2OezHbGLHgOqle65UbW13b7hXwuO2jB2NTAztZZWLIG8E7Wdm0A0g4ZNeUCcHiPVYXgJHIVG2PVfyAWaK2tZV9T8AhMM7XoHSVwJyApOLmtABHvmEkSrvAalGPxCYH8fKYjxKU4BnSravDuk34+9GhOjCzI3W0167YO8MFNsFWqx5aALng7HxcMfUiFJINIWMKqWzKa0kbx6pT2X152/jR4GD1rRF9vyIbysare8ui3qTB/E8iRxcogoMuUwSFMXN9ZkXLeDw1I2XU/TpwZTR4ZfKFqAErdrOKGYz1bN/0lXq+gg== 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=+KIt1gxmewtqqj6relnLOGcy/Yqt8J2A6GF8RQ0THJI=; b=mJzFp4rQqMeliuIrwSBw/WJAoOB9cBDcS2+Sd0aqf9FxZhSwk/9/QHsm9m6zCxMTnZmKtqsSGauNxFiLMACAIHxIXITwNW6tIktz6ai7kFR7OWfcOKEnXy6qjTG3/hzQtn7pbfdPCOz6LDC/zyiUTGD8Jv9zwoc1C1W3CwPWoow= 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 DB9PR04MB8462.eurprd04.prod.outlook.com (2603:10a6:10:2cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:25 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:25 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 06/12] net: ethtool: add helpers for aggregate statistics Date: Wed, 11 Jan 2023 18:17:00 +0200 Message-Id: <20230111161706.1465242-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: b5f777f5-225a-4ae8-0324-08daf3ef53a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z6RAZ0qj2M5Kgh7anVmitprA9R0EvKiz4vGXkQ/FuV8/EJ+IpPyMQTUryUBrsv+55E6qpH9m9XQREiudlxKZqJZAKfMlOtQRn2fRnMw/4vnIHK9lW+QHPw+my8eyyeKRbLuRTvS+EhfOaTEDcKWyHdr3rGIyulU1t+7vHtWlkApyLh/54v9ONGn7okQ2LUEpBxiGc1wqyT8DMS9dQQMXt+SUCk1TbJc2gtxNMNJvHQ4YsfjH7s4M+FWGCRyb23PbhLaKMSxl1dvsXYjRkPND1Um2qKbb6rvXWFV54yh33zHrW7fomwQ0z12dengknVXrI3trfBk8kI98p5ACWSgt3Egrm8AThv17ZEIiFu+/IiMuNhbFQsXQQYcX3pbcwMC0Dy1pQITyhKs5n4PfDsFOi0M+4qm5h8BCCG5agTv0syNvqR6bYE78qhQq5KR9TrgkGwRC4hO8KFsSNkXH/ixv2ZwiRN3pbNnuSXumYde4yNsGaj3cKcvkOIQOYBYvbV8gcI5o+SMcx0KIiz9yPlCiSX6GyA2QbJrZYYnO6vl0K7A+QmrcPS9udpIic2IG1nVNjFb4R1xSJZ08IfjPTfxQ4Cn59rXvrYQIeUlUImXLgHHvbKnnpPp2NjeGbBFBgMCQvQagOHF56pade/CL1gBgFeTOMHpIJw3GlIuaWC1DWyoYN2wltM/IwuQbur+PeU38 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:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(36756003)(26005)(186003)(8936002)(6666004)(6512007)(6486002)(6506007)(1076003)(2616005)(66946007)(5660300002)(66476007)(66556008)(52116002)(7416002)(6916009)(316002)(4326008)(86362001)(41300700001)(38100700002)(38350700002)(478600001)(54906003)(8676002)(83380400001)(44832011)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bcXCX180VtXAR4bFRbr8ciL88AQkR8cJyPS3xSE2cxxzG3yJXRwL9Ea85z3uQO5GAXmP79gWw3C/xhZjwBkQ1/xvNYymGOJZdvdJKPiUHMm9Qa+L17c2LjpeJJHx3evFzMqehsncI3R32XyJb5o8YaxFY4AANVLNu2XkGBvKyre79RB+iuwvZDIRcuD2fIdb7VURpJETspBmGzCD32e0ua2TBrgj0qL7XiQH8ZTSq6geQe6tYiU+xjsjVwmK3H1Pv+xBS/F0zz2YdfH2cPWyQYZcd/wtmcgLZVWuUhLoYngdOxVhVIg7PBaOIL1xWSFbj3K/kU+UiFLFdxoFW7RQ7VNUmlZcSd52l/LaiE2htWi1KUZui3AOhTP/1lOtJuTpMwFbzXiJEM3P44lqhY8WvsClXcsQlTB0/oSQcgJ/4Vh5wF3aqiBU2EJnEn0oGWLnUUnuG/fxxgTS+CFjZ86BWxYX9rQ0b3sfhfHuaeFEPsSc2jk3sSOHTJFO00zoTkSzIP4b/0yvW06gWBvCXKKYtGsws08gcwvnlAnbyUt1OIW5QvE0hwBypJCdLShZWxzV3X7XiKsCzgONZEFlFFeIA8ks/CzcjN4nLkD70ktdxlIQTgXEQCyEUTPoWdB4DJtuhPskZ8tm1M7vUDGTqE5vaea9UrIld/tpQqkQ3B5FItQCMyPr0LtttOecKtoRE0/DtKakJZnXOcDM7xrpA+rGQ6bwtTVKnQB9tzhh4+2idJkigYXXKZxcoh39QQ2ftnLQ5vjiXNVLVyC7B16TOuxs9CKbodgBywgDohjdB87+yzpFtrDDGxKZBnvyeTvvZo2yjFz/17sTW0niPnPybtXCoyGV/HS0Js+tiEUVNkEmQF4uuKtn0f2Qfhd/m5fY4Vdt8M1+lCIoeWq+KAgosboMT7nWej5iZs6HtJ7N4D3J9byRNAYRQ8LDNoK2QYFf+IRy5CDsv+GQE5NvjMDAGxm98A0xCGfHqBSk0qYzsFyuA+gdz130omTpPjbktAKX1qQPCBt4CXcscTdz9GStUFlJmp+2g1D2aQe8KQP5DdFkGnU2ps/CkNAlZc7irqkRCO1OU2CQEL74sz2ChkFBd5fOIOqLLj8n1wnERYmH/Ep4UArAZ6PXlR+fMgi3Tvc+pM8EU7X8RCipFV0WELoRCXGnxBT0Hh0h7nUfHjvDZTeskSNUs+a65qhNo6ogJ2cX+6rfe/sSV1mLQa8yuPsqvckGHOOhe9oj+SH7+A/taoN7KKbMUJGyMf2fgBt0xrnuHd+XsQ+2kmuYB0OLtv5T6SRjy8tGt4AgTQ9cBa15rVpaQ9NeIfrMV3RN2wDrIuGxgu/FLoZCT804lYKGqV8yvARMJAu6YJRkzUB4e9E4Rw9zrbEh9bkmJtiyZ2fTP1kHW4oPqqgrAGZfKbN8HayBrXKBO3L0Pg29MnT7nMiDWo++y+xEB8enqrYRIjjWvaY/fWRHAId2h2k92MEWwz13p3tbh7EIa4bzZbDgbOvT77DPYvygWeFdU91IPXxvo/GDnIzj/gKjpqD5hQImTk25gZsWpZU3hit4WLFW/VD4aEIV5jkw0ghGXIaYDa/WlWyLh54uMWDsyszn+zNqjeGgWMcuFg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5f777f5-225a-4ae8-0324-08daf3ef53a2 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:25.5018 (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: a76+KaPK8yJleCMEZlZ3KLro3aoYArzb7xtHlPr9VJHR7y/FeEPWRMlkZ+dFSpyXwruFXc/PRrrHl9Sj0xn9EA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When a pMAC exists but the driver is unable to atomically query the aggregate eMAC+pMAC statistics, the user should be given back at least the sum of eMAC and pMAC counters queried separately. This is a generic problem, so add helpers in ethtool to do this operation, if the driver doesn't have a better way to report aggregate stats. Do this in a way that does not require changes to these functions when new stats are added (basically treat the structures as an array of u64 values, except for the first element which is the stats source). In include/linux/ethtool.h, there is already a section where helper function prototypes should be placed. The trouble is, this section is too early, before the definitions of struct ethtool_eth_mac_stats et.al. Move that section at the end and append these new helpers to it. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new include/linux/ethtool.h | 100 ++++++++++++++++++------------- net/ethtool/stats.c | 127 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+), 40 deletions(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 06672b76b2c6..01b1e34dc30e 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -106,11 +106,6 @@ enum ethtool_supported_ring_param { struct net_device; struct netlink_ext_ack; -/* Some generic methods drivers may use in their ethtool_ops */ -u32 ethtool_op_get_link(struct net_device *dev); -int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti); - - /* Link extended state and substate. */ struct ethtool_link_ext_state_info { enum ethtool_link_ext_state link_ext_state; @@ -302,28 +297,30 @@ static inline void ethtool_stats_init(u64 *stats, unsigned int n) */ struct ethtool_eth_mac_stats { enum ethtool_stats_src src; - u64 FramesTransmittedOK; - u64 SingleCollisionFrames; - u64 MultipleCollisionFrames; - u64 FramesReceivedOK; - u64 FrameCheckSequenceErrors; - u64 AlignmentErrors; - u64 OctetsTransmittedOK; - u64 FramesWithDeferredXmissions; - u64 LateCollisions; - u64 FramesAbortedDueToXSColls; - u64 FramesLostDueToIntMACXmitError; - u64 CarrierSenseErrors; - u64 OctetsReceivedOK; - u64 FramesLostDueToIntMACRcvError; - u64 MulticastFramesXmittedOK; - u64 BroadcastFramesXmittedOK; - u64 FramesWithExcessiveDeferral; - u64 MulticastFramesReceivedOK; - u64 BroadcastFramesReceivedOK; - u64 InRangeLengthErrors; - u64 OutOfRangeLengthField; - u64 FrameTooLongErrors; + struct_group(stats, + u64 FramesTransmittedOK; + u64 SingleCollisionFrames; + u64 MultipleCollisionFrames; + u64 FramesReceivedOK; + u64 FrameCheckSequenceErrors; + u64 AlignmentErrors; + u64 OctetsTransmittedOK; + u64 FramesWithDeferredXmissions; + u64 LateCollisions; + u64 FramesAbortedDueToXSColls; + u64 FramesLostDueToIntMACXmitError; + u64 CarrierSenseErrors; + u64 OctetsReceivedOK; + u64 FramesLostDueToIntMACRcvError; + u64 MulticastFramesXmittedOK; + u64 BroadcastFramesXmittedOK; + u64 FramesWithExcessiveDeferral; + u64 MulticastFramesReceivedOK; + u64 BroadcastFramesReceivedOK; + u64 InRangeLengthErrors; + u64 OutOfRangeLengthField; + u64 FrameTooLongErrors; + ); }; /* Basic IEEE 802.3 PHY statistics (30.3.2.1.*), not otherwise exposed @@ -331,7 +328,9 @@ struct ethtool_eth_mac_stats { */ struct ethtool_eth_phy_stats { enum ethtool_stats_src src; - u64 SymbolErrorDuringCarrier; + struct_group(stats, + u64 SymbolErrorDuringCarrier; + ); }; /* Basic IEEE 802.3 MAC Ctrl statistics (30.3.3.*), not otherwise exposed @@ -339,9 +338,11 @@ struct ethtool_eth_phy_stats { */ struct ethtool_eth_ctrl_stats { enum ethtool_stats_src src; - u64 MACControlFramesTransmitted; - u64 MACControlFramesReceived; - u64 UnsupportedOpcodesReceived; + struct_group(stats, + u64 MACControlFramesTransmitted; + u64 MACControlFramesReceived; + u64 UnsupportedOpcodesReceived; + ); }; /** @@ -362,8 +363,10 @@ struct ethtool_eth_ctrl_stats { */ struct ethtool_pause_stats { enum ethtool_stats_src src; - u64 tx_pause_frames; - u64 rx_pause_frames; + struct_group(stats, + u64 tx_pause_frames; + u64 rx_pause_frames; + ); }; #define ETHTOOL_MAX_LANES 8 @@ -431,13 +434,15 @@ struct ethtool_rmon_hist_range { */ struct ethtool_rmon_stats { enum ethtool_stats_src src; - u64 undersize_pkts; - u64 oversize_pkts; - u64 fragments; - u64 jabbers; - - u64 hist[ETHTOOL_RMON_HIST_MAX]; - u64 hist_tx[ETHTOOL_RMON_HIST_MAX]; + struct_group(stats, + u64 undersize_pkts; + u64 oversize_pkts; + u64 fragments; + u64 jabbers; + + u64 hist[ETHTOOL_RMON_HIST_MAX]; + u64 hist_tx[ETHTOOL_RMON_HIST_MAX]; + ); }; #define ETH_MODULE_EEPROM_PAGE_LEN 128 @@ -959,6 +964,21 @@ ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings, */ int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index); +/* Some generic methods drivers may use in their ethtool_ops */ +u32 ethtool_op_get_link(struct net_device *dev); +int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti); + +void ethtool_aggregate_mac_stats(struct net_device *dev, + struct ethtool_eth_mac_stats *mac_stats); +void ethtool_aggregate_phy_stats(struct net_device *dev, + struct ethtool_eth_phy_stats *phy_stats); +void ethtool_aggregate_ctrl_stats(struct net_device *dev, + struct ethtool_eth_ctrl_stats *ctrl_stats); +void ethtool_aggregate_pause_stats(struct net_device *dev, + struct ethtool_pause_stats *pause_stats); +void ethtool_aggregate_rmon_stats(struct net_device *dev, + struct ethtool_rmon_stats *rmon_stats); + /** * ethtool_sprintf - Write formatted string to ethtool string data * @data: Pointer to start of string to update diff --git a/net/ethtool/stats.c b/net/ethtool/stats.c index 9238d99f560b..a38516181e46 100644 --- a/net/ethtool/stats.c +++ b/net/ethtool/stats.c @@ -437,3 +437,130 @@ const struct ethnl_request_ops ethnl_stats_request_ops = { .reply_size = stats_reply_size, .fill_reply = stats_fill_reply, }; + +static u64 ethtool_stats_sum(u64 a, u64 b) +{ + if (a == ETHTOOL_STAT_NOT_SET) + return b; + if (b == ETHTOOL_STAT_NOT_SET) + return a; + return a + b; +} + +/* Avoid modifying the aggregation procedure every time a new counter is added + * by treating the structures as an array of u64 statistics. + */ +static void ethtool_aggregate_stats(void *aggr_stats, const void *emac_stats, + const void *pmac_stats, size_t stats_size, + size_t stats_offset) +{ + size_t num_stats = stats_size / sizeof(u64); + const u64 *s1 = emac_stats + stats_offset; + const u64 *s2 = pmac_stats + stats_offset; + u64 *s = aggr_stats + stats_offset; + int i; + + for (i = 0; i < num_stats; i++) + s[i] = ethtool_stats_sum(s1[i], s2[i]); +} + +void ethtool_aggregate_mac_stats(struct net_device *dev, + struct ethtool_eth_mac_stats *mac_stats) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + struct ethtool_eth_mac_stats pmac, emac; + + memset(&emac, 0xff, sizeof(emac)); + memset(&pmac, 0xff, sizeof(pmac)); + emac.src = ETHTOOL_STATS_SRC_EMAC; + pmac.src = ETHTOOL_STATS_SRC_PMAC; + + ops->get_eth_mac_stats(dev, &emac); + ops->get_eth_mac_stats(dev, &pmac); + + ethtool_aggregate_stats(mac_stats, &emac, &pmac, + sizeof(mac_stats->stats), + offsetof(struct ethtool_eth_mac_stats, stats)); +} +EXPORT_SYMBOL(ethtool_aggregate_mac_stats); + +void ethtool_aggregate_phy_stats(struct net_device *dev, + struct ethtool_eth_phy_stats *phy_stats) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + struct ethtool_eth_phy_stats pmac, emac; + + memset(&emac, 0xff, sizeof(emac)); + memset(&pmac, 0xff, sizeof(pmac)); + emac.src = ETHTOOL_STATS_SRC_EMAC; + pmac.src = ETHTOOL_STATS_SRC_PMAC; + + ops->get_eth_phy_stats(dev, &emac); + ops->get_eth_phy_stats(dev, &pmac); + + ethtool_aggregate_stats(phy_stats, &emac, &pmac, + sizeof(phy_stats->stats), + offsetof(struct ethtool_eth_phy_stats, stats)); +} +EXPORT_SYMBOL(ethtool_aggregate_phy_stats); + +void ethtool_aggregate_ctrl_stats(struct net_device *dev, + struct ethtool_eth_ctrl_stats *ctrl_stats) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + struct ethtool_eth_ctrl_stats pmac, emac; + + memset(&emac, 0xff, sizeof(emac)); + memset(&pmac, 0xff, sizeof(pmac)); + emac.src = ETHTOOL_STATS_SRC_EMAC; + pmac.src = ETHTOOL_STATS_SRC_PMAC; + + ops->get_eth_ctrl_stats(dev, &emac); + ops->get_eth_ctrl_stats(dev, &pmac); + + ethtool_aggregate_stats(ctrl_stats, &emac, &pmac, + sizeof(ctrl_stats->stats), + offsetof(struct ethtool_eth_ctrl_stats, stats)); +} +EXPORT_SYMBOL(ethtool_aggregate_ctrl_stats); + +void ethtool_aggregate_pause_stats(struct net_device *dev, + struct ethtool_pause_stats *pause_stats) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + struct ethtool_pause_stats pmac, emac; + + memset(&emac, 0xff, sizeof(emac)); + memset(&pmac, 0xff, sizeof(pmac)); + emac.src = ETHTOOL_STATS_SRC_EMAC; + pmac.src = ETHTOOL_STATS_SRC_PMAC; + + ops->get_pause_stats(dev, &emac); + ops->get_pause_stats(dev, &pmac); + + ethtool_aggregate_stats(pause_stats, &emac, &pmac, + sizeof(pause_stats->stats), + offsetof(struct ethtool_pause_stats, stats)); +} +EXPORT_SYMBOL(ethtool_aggregate_pause_stats); + +void ethtool_aggregate_rmon_stats(struct net_device *dev, + struct ethtool_rmon_stats *rmon_stats) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + const struct ethtool_rmon_hist_range *dummy; + struct ethtool_rmon_stats pmac, emac; + + memset(&emac, 0xff, sizeof(emac)); + memset(&pmac, 0xff, sizeof(pmac)); + emac.src = ETHTOOL_STATS_SRC_EMAC; + pmac.src = ETHTOOL_STATS_SRC_PMAC; + + ops->get_rmon_stats(dev, &emac, &dummy); + ops->get_rmon_stats(dev, &pmac, &dummy); + + ethtool_aggregate_stats(rmon_stats, &emac, &pmac, + sizeof(rmon_stats->stats), + offsetof(struct ethtool_rmon_stats, stats)); +} +EXPORT_SYMBOL(ethtool_aggregate_rmon_stats); From patchwork Wed Jan 11 16:17:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096916 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 285F3C678D8 for ; Wed, 11 Jan 2023 16:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235345AbjAKQSg (ORCPT ); Wed, 11 Jan 2023 11:18:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235628AbjAKQRu (ORCPT ); Wed, 11 Jan 2023 11:17:50 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2080.outbound.protection.outlook.com [40.107.247.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F0EE625C; Wed, 11 Jan 2023 08:17:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iDNUtrPo8HqftJnBAMjw1nUVszMM7cSL3pdoGJZj4STCRO7G4pH1XgTO9iUelcjThvlSjX7uuMyhzdcTbQd8gvigNo3ClvJp23PqQLa9yvzYemqTeGL3QxGGzthsRzwE9+DJ/tmgCoLgnERU+OLviGXOtCVwIwdlJcitzk4BGTGapc+88mJYvEP9JUTIKWA4pDUCISnUywWg7B+PrIkRUS1dm9fvX6izJGwp0N3JOeg8Pi7gc4JY1tnlxHTut738Ph7X3PWjBkZzvNyoGj5S3QPNlsVDOJUfMCxzQZzMTk2ULlN4k3kBtZgmC9CxAMdPEAeepYTgfyd9zkxMPs1VzQ== 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=Uz0/yH9xibMBYfJaN/oInbHGTP30pDPWCaVjYJrlXTo=; b=oATudsCJ7V5B5wH/7nQJCHVkhnILUPvuwrk1AO9VG0yieAFrewN2Mll5XvJ1Izi1uR4bXZ+I9n2mzxWFKBb/CXbIDEC8hQiUljBa8t4YH06X1TH4Ft6iR1G9jJfX2623UuIqVN4pgifPSK5SSRuePL6+d0Yx/boHi9SD3mZ5tx5RLno4kVaGQB9qbi5dh7gRy//Nai4Pv9PDIQlW0iL1ukmL1vncpzMCl1fPGNteJKrA7s/C6j5lGMtI7KJy1+ZIxt9jMgXbvRYPXNSRYMrcM4ckxeGxHpFK4fwhmEDiYheE7Msaiem6ZB8Je3BgKEzl5rx+N7yKhIMlCbuz9LVCrA== 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=Uz0/yH9xibMBYfJaN/oInbHGTP30pDPWCaVjYJrlXTo=; b=SZQ7+3vblT2zObmPeozoVJPNI/sqzITvYgcwcfHisGNx1LrYv3sitMskXQsPDGDqfsDnTtqBJFx+JlGrEpySx5OKmYBIvVL2fFK4w9Fa8Q6YwJNEC1v8jAS4VcisNx6oZD0Lx/IZKOun72NUPJELO+WNBZAT7DXw6Pei5JlH0Yw= 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 DB9PR04MB8462.eurprd04.prod.outlook.com (2603:10a6:10:2cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:27 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:27 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 07/12] net: ethtool: add helpers for MM addFragSize translation Date: Wed, 11 Jan 2023 18:17:01 +0200 Message-Id: <20230111161706.1465242-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 378872e5-d9b0-4872-cc4f-08daf3ef5492 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VQ14mn+KI/VvGa4oYVWG2LyaZtDTE3wNg+zU+uXkKazem/bMhhYWAOrTQgvWtk1HMnXyJSklfa2saMiUmARgUXoT5TJ6cGhPsp9ziX9qNaJ3BvBDyO+HDoCLKQjPrYM4S0qKu/vjzoLLXrC4WrsE2rr4LezKDnxuJyhv0cKfa2ealdN46cFtVd3qW/30KMynXgzvYvVStvWakjtCesiSqVst2nn5pxvXuucjML0Z64JR7bq++Ripx8X+rGHI9h22C3d1Ml5Uf8vQSj+my2LiASxX5xBanEXR86nAFGm19VbTCIFRST7w6UTD3m6Pn1t8zGdTW/Mi5YCtSOPS3Wh1COIvtFhopRcB5uBZ7+cRNWSiw76ehSmm7ZT/NtndDTwRjJBuAQ2VrZKPMCzxfMFk3x7ztgYLWFYhl4t4KnNFtQ/eN7AIYRJeV3bvuqL1htyY3Se673jbUDh6Pkpzq5gUX+QnT0vwdfPfiQZffOt3tY8Ndsz995y3s/iSQv066Z6Ykig5Az0xf+EQ43UwKUifMKDd83n7z6g3u0dfoyoIB1lSROKszb5I6V3Qn0/zEqab1JJRVS0bxj9Q4ttvjpc/SxRPAO/reDZLWfs0LssMg3l+5zzx0gGfead+lM0bUgBFjN7KLjNehomYnAM2d71DyKh5qi0fuSNU+RE7B8kgRw+TfaBNXR3B6BbxX6D6jdtV 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:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(36756003)(26005)(186003)(8936002)(6666004)(6512007)(6486002)(6506007)(1076003)(2616005)(66946007)(5660300002)(66476007)(66556008)(52116002)(7416002)(6916009)(316002)(4326008)(86362001)(41300700001)(38100700002)(38350700002)(478600001)(54906003)(8676002)(83380400001)(44832011)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SDeHSY7Gb4qd4vQmyjSG3O3BfZjAe8ik3qq7iPT6+7hscdTnkmqpSFs/8yrY06/jjKskfrQGiJvyGcGc+m0hm+zVxZBvZBcLPCEF7lb4iGn1KivZbBk2EkeuLJrYf/INo5NUq3vNDdj777fmQYaoL8PaMSxJNkWjN07PvTTa5IVlI1a7XvuMCwHr8aHbjWD9gpq4P6a+VjwznaclgYfEunvo+vtnBENNdxUoV/EGTM0zZshfb/RXJ0Nck+HI2T0i5T7JnG//yV3gdS4VY2Y0GUpMqLMw6MuA1TGh63QYNOazi2wpAzs4j5q6GlSuG4vGvV2VCIW6rPbomhgMySgFdGA6m5wGsRcpN1ODNGg5Fke5etSRf2Ihubci4wPfuCv6bxav9EeELrpWydeVRiyVXy559KBVpH2Lax/pIg0KJ2VO5HOXbngoBbPcjt9eJlCx9yAi0ia8SRWp+w14vujbA81b3zdFNdDOi7Bxg65Y+oR6uyymgVRMDZD4yhyNZdHYzQZGHM66CVV5jrxyzjFjzBt6Z+SxD1xt6hvpAoySZg9/J5KWs0EQZdnhn+jzK7o2IMY5WgJPrjrcpOYwS0mDMczIFRTmUeIvM5nHrlkL1nxm+zMtGmUvkkQJv4JRCad0kJh5xmFDQkeDG9c7Hmau+os2gqzUhb9OU/UTKePmtBybBirYfQqg+KU5uSR9a5yEI3WT+Sphcf2GIMG9c8E3eEpCW7fIjzi7k0+ZsQTxCDIsZG8A2AhNoyg5H2tjRFQAe9VIaaSPvBJQg38LLHmXDJHPLqZg4SPvChrflP3rsUOInnAFe7JAENguOqk0bjDMQYc+uJjKXTlqiYGvOc3BPcvDTtx2LsdiAr5lGucvpVfcG7KStumvUPSsNicSKFp5sKdaCa+RbVAK01WhUY3JQV6DQhzuL6OGBzCxsnRhKpEkqQzKQ7Kz9VFOgvzw4fiPmrf97tUEO5jmcVOHGeikK3RfUL2T7IMx1q3iWJP9z+AV6XuQ8T44Fd2yyhOTmntWoBl5S3L2XNYNnl5evXrBpAVD/uLWv/dyJGgbR4CfmtssttF7sdeRE7HzpfQjs1HEekvML78zYNT15NdOWzJJtMjXHwFbAbMKY/nwkE0GEhXR8ly0iaq13ipayjBGU9MfiD3yePj2f+4T0OpN6r4RAXD5YcHs/xaVJ68YWcDjyQclCwJSfNpgtDN8P4rVdZfULMf1cb52B/dr0YmCUTSlRbZC7VW3mWo2nh5Z9eb3btpbBQb+d7uJrT7gQC39PtNNql/fsCa6D4H77dLms3ZvBOlsTpb0lZh5Uhv30K5hahG08egjmBzahZg8QVgAhDALGguQ0TtrPX5abXYHjU/gEPL2BXXYJovXojDdemdPAGN4IdAC0SCPmRa2QYyh0OwrqmFEl7ICkUVl4x30jk48d0PI6jfUdCeAVjXy8mcCQpzdNgkmT/NpzWcWkzcnXgr0zWQ3juVtAYbjwKODtBxxoBmjHzlbfqyHHa2eggGKc62yYx+U2xTxh2myOvnPdzVCN/dqMh3jqRa/lxW6T1MoNJCmdE+n5uQ74B6zBRj205hLS/x1bimXrfd039/zsi93BHOFrTiTsAQNy6Lvl8ru1Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 378872e5-d9b0-4872-cc4f-08daf3ef5492 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:27.0173 (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: p4UEgL0Z2UsSEg4mDtG7UZRhXAB6ipSAStSKEuflEo7ShP3/OF559UgFsOfV8iNhBd1AtRYarliC18MFuchWHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org We deliberately make the Linux UAPI pass the additional fragment size in octets, even though IEEE 802.3 defines it as discrete values, and addFragSize is just the multiplier. This is because there is nothing impossible in operating with an in-between value for the fragment size of non-final preempted fragments, and there may even appear hardware which supports the in-between sizes. For the hardware which just understands addFragSize as being a multiplier, create two helpers which translate back and forth the values passed in octets. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new include/linux/ethtool.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 01b1e34dc30e..1c3e8fc53609 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -979,6 +979,45 @@ void ethtool_aggregate_pause_stats(struct net_device *dev, void ethtool_aggregate_rmon_stats(struct net_device *dev, struct ethtool_rmon_stats *rmon_stats); +/** + * ethtool_mm_add_frag_size_std_to_oct - Translate standard add_frag_size into + * value in octets + * @val_std: Value of addFragSize variable in octets + */ +static inline u32 ethtool_mm_add_frag_size_std_to_oct(u32 val_std) +{ + return 64 * (1 + val_std) - 4; +} + +/** + * ethtool_mm_add_frag_size_oct_to_std - Translate add_frag_size into + * standard value + * @val_oct: Value of addFragSize variable in octets + * @val_std: Pointer where the standard addFragSize value is to be returned + * @extack: Netlink extended ack + * + * Translate a value in octets to one of 0, 1, 2, 3 according to the reverse + * application of the 802.3 formula 64 * (1 + addFragSize) - 4. To be called + * by drivers which do not support programming addFragSize to a continuous + * range. Returns error on other fragment length values. + */ +static inline int ethtool_mm_add_frag_size_oct_to_std(u32 val_oct, u32 *val_std, + struct netlink_ext_ack *extack) +{ + u32 add_frag_size; + + for (add_frag_size = 0; add_frag_size < 4; add_frag_size++) { + if (ethtool_mm_add_frag_size_std_to_oct(add_frag_size) == val_oct) { + *val_std = add_frag_size; + return 0; + } + } + + NL_SET_ERR_MSG_MOD(extack, + "addFragSize required to be one of 60, 124, 188 or 252"); + return -EINVAL; +} + /** * ethtool_sprintf - Write formatted string to ethtool string data * @data: Pointer to start of string to update From patchwork Wed Jan 11 16:17:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096920 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 81053C46467 for ; Wed, 11 Jan 2023 16:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238429AbjAKQSt (ORCPT ); Wed, 11 Jan 2023 11:18:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236157AbjAKQRw (ORCPT ); Wed, 11 Jan 2023 11:17:52 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2080.outbound.protection.outlook.com [40.107.247.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 455901C417; Wed, 11 Jan 2023 08:17:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S+LrA46cWmJIYTvaofI8uCWmszO5ej6gNLrYYVYTH8lbsZ1SS4KmsoMJcsKfU/aNjBrI4c8HvK3RPI5U0m5Kdlj2dJ1tTfSHI2dAVqlOJxuZ4uuioRu7Rk+bPALJfqIA4qOm+MGqgBmDrry9Fl3HK55Rvq224x7X5s3iH46XYcW7TuE3s3agrPIe6Fyad00Gh3HE4pd0gjq4PUq+Aju/io1xqPWBQdSOiQpug/1b5yIitPzmsbk470T1/ndWZ8WWyJZ36LC+Wtm25mNdmJzkLLcPZpMfljicWHokMmsynWvNn4HEYVXjbWo1Ho6H/xgP/tdGzkExoe2c6rhdtjv4WA== 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=8IzBKz5jWFU9nf2/snHShZyCuIq8lzBpN5hXtoMhRY8=; b=kHCmzf6PFGTEyvBkalMbBPuYZK/JlNZcK++EDg3y6hbsqYY6zPVofHwzd5H8milW3R5qaHVN4SXWBVpNqAoWjknBraMMhkzyEdwB58oEq2H1uXgmXAfqlZxD6CV6pVR8Hc23iWz2xoASMQGvqXzs83d9d7aSsjVv+E2M38zRcibC3nuBnwhE7F7PPHrW8W8I/yC+cZH1ebYUEJlP6e6MUYeTL2MMqurV1dptwQIyxfFeHHj9kv9OXtkha6FzEb6fJl2OVE8y4wI5u4071xo/e4FhacvgX/1GDkpshV8MVUMMUW4uLNfXTegECG+njXD1nTrhvmrEC5CFpX8kKI5fXQ== 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=8IzBKz5jWFU9nf2/snHShZyCuIq8lzBpN5hXtoMhRY8=; b=FkAbDuoi17FkaAUT2PtpDMAQWMIMASZAvxjTiejt9stQqxQomZ1I1d3Ig1eO8WljZwLL+uzdCz/oifj9WFLUKFUXlT7+d+OnlPqfa87yFk2gwWczntYXF79ArdUmRKiTgoB5FLRJVhG78OQrVKPDMTpP8ZubRmLjv2xj6hznjiI= 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 DB9PR04MB8462.eurprd04.prod.outlook.com (2603:10a6:10:2cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:28 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:28 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 08/12] net: dsa: add plumbing for changing and getting MAC merge layer state Date: Wed, 11 Jan 2023 18:17:02 +0200 Message-Id: <20230111161706.1465242-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: ed5a17c7-1d10-42c0-8302-08daf3ef5570 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jMwtvm9L33IwEO4gZFcXn0L1NiYDVg9uqLHvopRLaFGGxHa+PeGeWkzzStov4/jVKXZ0nCfI4+6yw62hXKZI8VNsW5AI9ItOA8Tg6wBCoVC2B0262MwvQ5wiQflNeaQaQGs6BAkEtIDdTjNBnSKyqUmP2u+b6mu7bjTc3e7t30weFuEjwdSpIjdiAFQEE4cI5J5/YWtnrjO5e+bLDliAEUBRZxzDRHAvXBJcaIInpYmvtERvKlhWczoMSOD5MpuhwW2UkqAec0dDZQV0rGm+FPa5yM//wht8VQCmFXDLXLIwIiOSXvYq6iXM+H1L61DbobKDVKxK9zxpBgh2T4J6B5i57+ovKNHMZ7BjaiWLPIqr3zittpIIB+zRx2VKlXeMzohVGXeNaHmK7pNAqd3EqSU0dlTrfbLfA5GG2uoGcfZzK43tPZrK1wXYVM1gG80q5vSk4mF+jLBvSp1O6knd0WAcESbVT8yAn4sEraa8itBiycgMT0wNMqj5Xha5WnE5Fc8DSg3O0YV5qBuy6/55Fer568pJGE8/lz4Vqjy72E62sQ2vTxkq09t3gWHqwOnzgjhnR5yNlhUE0JXItvJQ8Kj1jiCMIJ79ACSyb30/kIioJp83lDuSOUPLP+QkAs3r3uX45ITuSZKm5hNUszfB+SOugT2ufX5gH0so2et70LQsM1muGR9cvR6yDeDW6TSa 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:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(36756003)(26005)(186003)(8936002)(6666004)(6512007)(6486002)(6506007)(1076003)(2616005)(66946007)(5660300002)(66476007)(66556008)(52116002)(7416002)(6916009)(316002)(4326008)(86362001)(41300700001)(38100700002)(38350700002)(478600001)(54906003)(8676002)(44832011)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2SL44taS+m8GWwHx/El9TiPxZEmTGTmFWOJM+KyivRsdkD9DDg4Nbie7pVVFjQtqE5BHKAOIn4CNpI+bigAJyTdJYtqaOqSJ5+OwPdaWMINX9EZCOsPY1B1fmdTNME6FVJ92Dj5KPlndtoWx7As7tS1mIo4ebwKWwthAPALNoVink04GrdIbTea9V/Gk4KxS7dumwPY9Yeeai4k7LLPaTrqkN+Kn9FGc4hmIRPo4UuHvBFEAVMJhFLJK9r0J53EIO1eWydfuIt0qe/5tyEiIew5O9A/ezOHfvy4ODvhZnUuMiQ7N37F1VN9Ac7h8YE6WFnmAJOTBZXUfnDHba3c96WkaFS9R7bMUOchhYHrUx6F+Nt8xBaP7ZGfLAKjuhDcwb9dJxlx9sEuCJrojOUJZWKzrVcwwysD3Apoymas4uM2EDqAFtyk73UjrK+ZcVhDqZPfZv924JpqjshpiS606OIv7VDhxjc6A8SqxlETytLskPlVs6K2hQORwNu8LW+k7LWTGg/ldTjctzLC0E9tMdSufyPZmLR3CWlEueb95PDnMdmi6hNIAG26//929sh4VbALbxIIdRKlRjFLI9qK6OuyI6P7DyybMZ759IqtUSappgVE1VzdAdjrskE7t71YZFgwm5xc7H+O/6h3d0fi9fqQXt74oBVS2mjMVPRYpyl2jULV/R5LpJ8UwjDJBawWMPKLuXOYqY0uZ88stutSaltvoORoRhuW8l3NuXRtLNhF3bIgUmdZQTYVMB2LtFnja9gfMqb87jxZJSzG+H+i3IiOGHQWgcwKA4caUNIKTjkXwqS8t7CsMhljPHBq85FR4niRsgvovtClQoqM3oe2uxEgby/I9tO47atN3gnoWDsjvxN4ck0PXC4Q5gwuHCjkzST4b/ztzMaB4H+ly3TTsGoCNYU8r12kycTjPvxXPwuFVl9lPyRwAwQTrsOZDzmdWaFZ9psIEIzPYW/oJ3yjLpI+PPtD/M5QFvNJx3iJMFJNeZ4bAf1K+uXJSbFNWK3wo4A2IveqQ+jLMohypG2pMrplVU8fmHBgjsoONLMMUjuvAZ/4DqQuEi2WW3dAQNsBLb13GdFUrPfL41qmS7AujspQm9TLWTnF9GEM153OvcXM59+OX3bifDT+vza08pgSRg6+AWWaSoRjjYntt8uRmdBT3aRm7scjx0SQmq+KxglINrDvF+39zdOINZ1h1sRx3v7pIkUzyQ6cDhqYNXlfdkvSTz20D6Y4VqwF9Ppe9ofYewZ/lpxOQGZavBtnCX76CH9sKAw1DS62dXYolfGfUkEuu9yG9SkYGAxr64Dmrsv10wx6De4bTu/iVgVgI4Zzy6koZTH7Y/WHQzgKVonYFplDkb2b8E+C0w6Cy7bpeJdiP37c49wO0D0JyHylScLRpD5Bp0CH+7+1u5APCK4MXZ3xne9xXs0tx6ME+2dL6tMNj3TLGULPZ2av1Ngxo+sXirurV5ipx+plNCVAyGHKgav2CV6bV7Lxr0asyhK2oQjkKqX9tfoAYWR2VQEH4j2BpG9TapebfPAxbQfNuMGvJ4zKd3DHBSTSdDsWziiuDl1oMjl/3q9AVs/QtiFSXuJ67EMuW3kIXPTlgM+/LxS4DcA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed5a17c7-1d10-42c0-8302-08daf3ef5570 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:28.4391 (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: ULk1GWLB3EQep2+r3xqLDkHw5kZme90fnZ3/gyUHYRKFCB1OBt1VRONP+N7pYYaF6rDKu7ODe/znVLrqWKddAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The DSA core is in charge of the ethtool_ops of the net devices associated with switch ports, so in case a hardware driver supports the MAC merge layer, DSA must pass the callbacks through to the driver. Add support for precisely that. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new include/net/dsa.h | 11 +++++++++++ net/dsa/slave.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 96086289aa9b..51b0dc0d0bc1 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -937,6 +937,17 @@ struct dsa_switch_ops { int (*get_ts_info)(struct dsa_switch *ds, int port, struct ethtool_ts_info *ts); + /* + * ethtool MAC merge layer + */ + void (*get_mm)(struct dsa_switch *ds, int port, + struct ethtool_mm_state *state); + int (*set_mm)(struct dsa_switch *ds, int port, + struct ethtool_mm_cfg *cfg, + struct netlink_ext_ack *extack); + void (*get_mm_stats)(struct dsa_switch *ds, int port, + struct ethtool_mm_stats *stats); + /* * DCB ops */ diff --git a/net/dsa/slave.c b/net/dsa/slave.c index aab79c355224..b6ed0f40a0ef 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1117,6 +1117,38 @@ static void dsa_slave_net_selftest(struct net_device *ndev, net_selftest(ndev, etest, buf); } +static void dsa_slave_get_mm(struct net_device *dev, + struct ethtool_mm_state *state) +{ + struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_switch *ds = dp->ds; + + if (ds->ops->get_mm) + ds->ops->get_mm(ds, dp->index, state); +} + +static int dsa_slave_set_mm(struct net_device *dev, struct ethtool_mm_cfg *cfg, + struct netlink_ext_ack *extack) +{ + struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_switch *ds = dp->ds; + + if (!ds->ops->set_mm) + return -EOPNOTSUPP; + + return ds->ops->set_mm(ds, dp->index, cfg, extack); +} + +static void dsa_slave_get_mm_stats(struct net_device *dev, + struct ethtool_mm_stats *stats) +{ + struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_switch *ds = dp->ds; + + if (ds->ops->get_mm_stats) + ds->ops->get_mm_stats(ds, dp->index, stats); +} + static void dsa_slave_get_wol(struct net_device *dev, struct ethtool_wolinfo *w) { struct dsa_port *dp = dsa_slave_to_port(dev); @@ -2205,6 +2237,9 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = { .set_rxnfc = dsa_slave_set_rxnfc, .get_ts_info = dsa_slave_get_ts_info, .self_test = dsa_slave_net_selftest, + .get_mm = dsa_slave_get_mm, + .set_mm = dsa_slave_set_mm, + .get_mm_stats = dsa_slave_get_mm_stats, }; static const struct dcbnl_rtnl_ops __maybe_unused dsa_slave_dcbnl_ops = { From patchwork Wed Jan 11 16:17:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096914 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 DB490C678D5 for ; Wed, 11 Jan 2023 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234777AbjAKQSa (ORCPT ); Wed, 11 Jan 2023 11:18:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236651AbjAKQRw (ORCPT ); Wed, 11 Jan 2023 11:17:52 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2080.outbound.protection.outlook.com [40.107.247.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BB3F1C42F; Wed, 11 Jan 2023 08:17:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SsIiPm2Jp5ghKaH5Fn94xuTpzq8AgQBEQUC+tBBIRoI/gwSN6TprY8V7msnne1mGmdD3Js+9kZE0txc6gRUQKseyRIuOBQpaLfZ7tobqPvssLS72jBBeGsVRHjHYsspoaghBjL8+pV2NG652UNnijc05FjYfaqNnqjQNLBISVEt99aqq4ZNsEcBsB1CgswVpQJOxFKcrgDyezpbOCkIHe7VKzYQPwWYZnX1JDFU4c3zwcgNiPYJ5SOpuD5Mtn61QBmKl4G/s8rSeXybLcIaOheqs/4TtpK7ooj4+EUAR2KvJKiudJYEtxvhMKlywYDgQWFFHyFKEfy7epvQ1GWIQwQ== 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=c/kqf8kWcW1zl52Dy0FCWuLDKz4LORY+DybWP+OBPnU=; b=dgEe+reW9pzYKN29HpBTfS+Z5Fa7dohzEon24XckndJ4HMb+ijKSljcquwNQ8FdGUw0m7mXu6beToPlIqctiJPE8AEC5AsRnDWZdLmkPdTd7jt630+8VqsLD8Z1+o8AkbYtqrSeKtwVoHzbz27+SuCPPXpuKi3XC2jYp0Xtt7F79cjigY5HEOVFEuqD7FobixHozSRyz/zNMKSVVHhdasNF1Neli4OOK2vOpTbPMA3do/msxZWXTXkuekIJ0fL7ciIKATKgG5K9A87+RK6E4zO9YvierxHv9Xw2fQcMjBen96qYl4/BB5FsGNhdqsrz7wlGHYbxQpDc/h+rWEZNGgg== 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=c/kqf8kWcW1zl52Dy0FCWuLDKz4LORY+DybWP+OBPnU=; b=qHlu24tiaeJIU04J6WL4+YjkpIffkMHrd1acL+qG86PL7IRtL+MxcK/6tvVEWb3zp+PBSnSrc8X9zdP0uRJGJ+6Jkj7/ku/5/t9TipdsZPv3rBLzrz5HCRnWLMnK7YR8CbMJysoZJf4B3Nt1L0e5Q9a+HNfOLe20zjJZEDr6Ego= 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 DB9PR04MB8462.eurprd04.prod.outlook.com (2603:10a6:10:2cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:30 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:29 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 09/12] net: mscc: ocelot: allow ocelot_stat_layout elements with no name Date: Wed, 11 Jan 2023 18:17:03 +0200 Message-Id: <20230111161706.1465242-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 6103b1d3-cb68-46b6-d764-08daf3ef564b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GNSqQPWVuFae2Y1zeFxP5xaoiJBZjadqsnarwEVf9qiyVEGLguBHPp5ACk0FTj64c5wirGI7rO9483DAYx/Kcsy4jC2ld2cmUKwzsGisLJiLX2+K45Omnm5Rx11Z87QvqhnnPLwRRntDo0vz+NIpHuG3pGDk68YFcXUHkqLQZHsSr2/HJ0OH/XrDmpv8/rpZuw1Du/i6z8vfIP0DoFTDiDLDmu84bUoBkXlorsAnmk2EwmNmc1IOFddykNAGf8mBn0e3lc4h8cpvjkSv3O5ULlo5o4U0DQKoJ+y6//7B96bS8t8+eVXUvLHpDD9xvB/OtLA3LIGzq/PEba5AQygq+B7xhFmVKaH6lmrhnlj4JyJIJZ01QQ5Gd/PRFM4TgyhiaYttKkUL50YE0T2//F15fit/pVivdGoAbbqb8nEMVFXj85Ov9MYvOwze0tJr0wDcloGMT8NE3+T5HrPbkSjfvjg1SnpAGSZFp7qu1AKFwRgPqcpPUNhzbC1xuCa+cTvEDwV2nyAkI3TIsQ8bPlUjB1Yks/PSgHgIwP6Inv1CQWe53EoiGJqdzi5yB7zEo88cmLUfuM9C5S3zcRwr3o9YT8bBXKgDlu4H4TtguWKKv2itstPFZP4sdtenAx72oTOCy05FTmHClqvmBtwW0tCDPGxucv6J8ojXxRYR0h1PIMmgnQCx/1CiaKgC2xWfpGec 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:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(36756003)(26005)(186003)(8936002)(6666004)(6512007)(6486002)(6506007)(1076003)(2616005)(66946007)(5660300002)(66476007)(66556008)(52116002)(7416002)(6916009)(316002)(4326008)(86362001)(41300700001)(38100700002)(38350700002)(478600001)(54906003)(8676002)(83380400001)(44832011)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M8H+Yoz7bQvQEMh+NSzLXF/37kcSxfCN6+CWdvDv6wO4K6eeSd3CnIh5zNOTQjkU8y6v43TSUGwoVnDVY28GvhzqSEfMbDg/CLUQp/1GKSN+nmXTmLCjZQE3rTOtncHFpYCwbHLDuqwkC0/zTM4OmcjaDp2GTLyYtEitFhmoAYH9Gwo01MSUp154mXXQFtrg/L9u+dHZJstPBSadpYudQzLgdC91aKiIO9YQTqgEvBQXX9ejpeYhCkQZcmGbZFIp1gikbGkBlNnOlcGKdtfXLKQHOSNdEEWldBf4QskklQdKKTUY6OWagYVZghA1N1L4qyMpWsekXF9oi48z310vKQEVi0uWgWUofc7I2vbyC3EJZkhuy9uUv12A9T4KpDcsssG1V/nR7O8vVfwixt64StW4Dk3ZhB7Qk6041o3SunNSDIYxhQKOKLaBH3nFGkQiKqLKogTLs6DFBVVi/WT3fvOqejJpARB+JB/jjYWvdiHy8s8ysayyYIvj22Vnh8fnDvjY6JGG8Rgdohjn1THBuML8V90P5VzUAKhaw0K5KBMZkPwuxZw8UGz+WhBG6a/ua4ALa0bgpTiFbp+8o3aW9vfAVdubDrC/NQnvQJbkpM8w7+Ch3l5+6q6C8UtXM6++Tncx9UsyMWhH5AjsEyCqbe/rJ6PMJFeiWBHuYiH6dovliLAOKZjOUYfBv73D1TrCM9rZw9mNnnLEioA1J2OUvzVJgzQaco2ODCnJ/jr1Hot+6fBAafGEJNyRuJgL69mdC4sD+qs1FiQU7/FgiWZPpsZsmmTiDbvFAqC4NFxcUn7O6dtpREAYqPvMWDx+jMBDpGN9ngmLsPgn50/W5ujHGFpTDXbNtb7R57e/sO3cWby0D9qZ9ZCjHXVXhxD7qABxnh+0+iNJg2fB8nv/5nsj8vdtH73kk5llmGCcQ65T7oT3yl7P+3SwKFLhd+140rzNsMm3LJW/wY3UYt0TGLP3pU6bjSHbS5t8N/JTkfbFke6qHqI69bfkc0YccOj9lSzB742ou4z46CJJi3vLQ1b5bXk1BTuR0kOd8EckE/b9abArSVrWPhIU2Ib62Yr41rrtmYDxuKAQMICidgETPbxs+Ra+dY5AzsA4q/f/Uego6Um7AfoHHT8dAlQZDXxaczcgITVZZlo2vbLfwxhLU0LS8dSH2oUzWWUZoXEU0o/p2SljyHdIqK/wMpB0g6qhtjT8AZ/70v98AVpcHP1exqU2UEehuMlp/V5B793lWL8/Q34zXHZynzOZK/vTNuYtFzETnah8gc1+RLNkXl0ZYj+2Mm+r1TMRhJYbYOkkYthoipKdBPIWIuT3OR2VwXMZkMtjB3PTeZMq8KGK8x2h1BHMZnZ6o7CwgrgINiOMAt5wCQIp7tM4MEYthE8qLym01TitYIeTpUL0d3/Mb97Q87N3hIyVx4RqyC1JIm1B8OYydMCMFoHzr3IejvXwWnQsnM/A669K/y8A1VpQiPondGLCOJIap1eM6mkw49ODdXxEfK6lpekXlKcQyc11BceBIKk3cmQczo8zmXr4GsmacXaeHM7S/E79ddYYk7sRSAWX974G4g601RDb8wUan2+GciAbKlQaaqtwDPUp3aBtJOQuVQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6103b1d3-cb68-46b6-d764-08daf3ef564b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:29.8921 (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: 1l1BSWzUWz94R3bbKCIELIkXwnqDu6XzI2xKFPzy/iQLlMNCxavTVGAe7VAQPX+qxp4fZeXdp117UljWoeaPow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org We will add support for pMAC counters and MAC merge layer counters, which are only reported via the structured stats, and the current ocelot_get_strings() stands in our way, because it expects that the statistics should be placed in the data array at the same index as found in the ocelot_stats_layout array. That is not true. Statistics which don't have a name should not be exported to the unstructured ethtool -S, so we need to have different indices into the ocelot_stats_layout array (i) and into the data array (data itself). Signed-off-by: Vladimir Oltean --- v1->v2: patch is new (v1 was written for enetc) drivers/net/ethernet/mscc/ocelot_stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_stats.c b/drivers/net/ethernet/mscc/ocelot_stats.c index 1478c3b21af1..01306172b7f7 100644 --- a/drivers/net/ethernet/mscc/ocelot_stats.c +++ b/drivers/net/ethernet/mscc/ocelot_stats.c @@ -315,8 +315,8 @@ void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data) if (ocelot_stats_layout[i].name[0] == '\0') continue; - memcpy(data + i * ETH_GSTRING_LEN, ocelot_stats_layout[i].name, - ETH_GSTRING_LEN); + memcpy(data, ocelot_stats_layout[i].name, ETH_GSTRING_LEN); + data += ETH_GSTRING_LEN; } } EXPORT_SYMBOL(ocelot_get_strings); From patchwork Wed Jan 11 16:17:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096912 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 EAC56C678D7 for ; Wed, 11 Jan 2023 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235011AbjAKQSc (ORCPT ); Wed, 11 Jan 2023 11:18:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234896AbjAKQRo (ORCPT ); Wed, 11 Jan 2023 11:17:44 -0500 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2054.outbound.protection.outlook.com [40.107.13.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D44605F4A; Wed, 11 Jan 2023 08:17:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kLmUiHunXXE285em5MBz+qLFz1noyWRBWhxyae5x7Fx8z41k37QQvtahPoHB67WqscmAReOvqVsb+O/mHpYJ45RsB5Myf3fbC1KuDki+4UkNZkmXLtf0mxdKlQnC47Ug6YMJN6Fc9RFcmTbTe0Ny1os7W8gl4bFhBTA+ACQCxtTXr4xRQiqBOxl6KVc2v8FnsAxSr12jxWPY8FFEsLYAwe7Hn18dL8QXYeJUNt4KP//kgGGZLZgnqTbM3JqU1oJsXBSxlt5rY4mpx0GY4FcEDnzcnFFAbuDXQ0z6X++XUYwo77sCjgB2pN0YeHMlSpn+D41VtNtWnWbZzJrdfeSsLg== 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=lfGDgR8XtBdxz/tXCK4dGk2/b046Jl6bSnKzUfD9r/o=; b=Oo9f5lBNjM54jZu4KsdZ9fxlGJO13MFVcEXT92pGMyHPdjS0CvgqwK6U+QJDGYyg8b2a45wpL/eydVEZ4A5qu55R4vIPm132gaisb1UUJ2+u7rllVArvrJI4EJg3I4PpE89e7uQzdXcnRsNjZv9SMV/j/J2iGWYBZIrJ2GYSbpYlthUK6+SAGuxPh9mFSjtRt1hTtRpHkiiNEbLgOEztO+bMDvjwkgS8GNEmvVGrnsIqx9pNuc7zW80krg2r5KjAH4L000nuzobe4qFqDlst+a7cGdQHgVk464kjj7OvphasLkYK0qVru5gRSZjrt9bUkUVxDLGDI35tveGNdJEmog== 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=lfGDgR8XtBdxz/tXCK4dGk2/b046Jl6bSnKzUfD9r/o=; b=AHZ6dMCge+269GRCu+oMBSKHhhOPwTQDpPRvUkjCqD6hsKbY9wlWpchBpRDXiJZht04I2/xTx0MEiEBTPHdsNtYDw3lT6LfMgw2BkuG7C9jaF6qfhH4p3Gii6OXXQJlyJzA5LIEYn40kaE5OxcdUCSlxi5gL0ZXTdfdtgzUd9GA= 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 PA4PR04MB7549.eurprd04.prod.outlook.com (2603:10a6:102:e0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:31 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:31 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 10/12] net: mscc: ocelot: hide access to ocelot_stats_layout behind a helper Date: Wed, 11 Jan 2023 18:17:04 +0200 Message-Id: <20230111161706.1465242-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7549:EE_ X-MS-Office365-Filtering-Correlation-Id: dfe4acb6-ad11-4468-2bc1-08daf3ef5727 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4g0n9FZvecSWzszyiU7mgOCDYm1s9pwPOBATHqwHlUF3tetHzhiqBV5EmwNs4VxIft50yIRlBF7Ywmq3lKX/2M+fP7XHaCLkTTLz91Jr4S0kahU7NvCihwwyTWJRInIofWrbaj9EBRwYpLZX5pydXdsiLcKYWX/OEIDIaMFaOlOG+TpiOehPRA9Ie3aH9BCi5WfDzSBW+9zMxtZ2gO3veDrIxfeHVXU7dypnljkpi1bvidgHfcCtlRhioE3+f6WtdZeH5cEErVs9Fo04qzFzF2CBHD112bgDn2G66lMNnFNcvK/1ihS4vK4OfP8rbRGHhh2E6mR7kSXw0VkxQKOqhcEsgF1q4CtGvMN9YK13j722FM8ZHHBYBSubnGNaPawzFNrG8oWUdcy441f801MRO+J8xoO0vbpA4Hufhmdq2S/rCdPCiofQkKRLkkGINaG736khmwc/wYJKWKrV6Q3vwZwXPFLsaVQJdoaR3OTILDIVV8olcxJothsZsdGfxwjju6vhueHyPHzZQ0tAEo1xWEYShelG9Gwrhf62FemQWvx7A9iCLqzznnivF5E8vLuJfi17ACg/FQgqjO7cJQfmn7q7mlW6iagIenjmtncS/7+gp/s8qJZr0+1CPGCjvQNDyVZR+VE1sCVgxhB8ch9phKAk9BqyEt2GMmnqVQfQ4YCZFVYsoQN7gfNJ9yJan23m 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:(13230022)(4636009)(376002)(346002)(366004)(136003)(39860400002)(396003)(451199015)(36756003)(38100700002)(8936002)(186003)(2906002)(41300700001)(7416002)(5660300002)(52116002)(6916009)(4326008)(66476007)(8676002)(66556008)(66946007)(316002)(54906003)(44832011)(38350700002)(6512007)(26005)(2616005)(1076003)(86362001)(83380400001)(478600001)(6486002)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DoUAGu176m++ID/iO4/9uYhOiRnCtd/qh9KZfFKpmwc/t/z/XHIYm9IgcFhghSEyldJpdUij6uJotfBVDyeVL/G1HAfIyJosA+FM8+I7MVJzY1vTPR1QY7mMrd7rDo9K3VVbLIk3aaS6ccpPEn9w2uU6pCEcIn0DppuY/Nk9D8KItiCMV11vLixALyk1d9zILBjDwBNPBe9mJJlrHeMwQZJJhMjPfZRAdV5cKQM/vr5tXRaKYJjlwlBBH40ZkdVcSQabrkQ2ETPdRNmuqWEVsHzAvoT1/ncSuf2Xpsw8NfLEC0/IP+B8ebtkBYDnUfzt099Y1gnSQsqD0EXmEnD0yhnTII3up6qoykLm/t97/03lZKwhzeuNXRVDJBFV8cGjf74mkQv+S1/EWBRHD8ehvY9+mma+/cXXurZb/yfUf8fakYbBUNqM+3/DGe4/e9HMIEZpoK1nBiD+CjYfa7D4q83QZNOw5etV4MMtNzhQfvPaM66BE1RogXklofa2xDJdACuE1Gf3x9Hkx9+mmX/xhtLEq2F51WxzLcwGIO91HGtRfALLhUjN7U6svCoUH9XRQ9cF4+9kX/E6vcnNFxI2zHpL+VKEylxU+JCx9XGg9Fgv9/KXfcG1gyaucm2ae39OWM/kXnvuQBUqvvdXX5wsmtYvHzzMUWyZT0mqMqAISPtWNRbajX+MH2vx8ra0L525kx48kgf8aODRYZlAenBwPd22j3GI1cE3FP09Y6RhKPrVxoqHZxKDyAylyKhPXyoB1WIzH0IeEIBdqPzAcY69tSSNacc3YvFLYSFBpgXvotayKMNGN+2ntK+F2M5g+vc7VGLe6lv8KWvh2GdDLZGUcehj9zEBZ16RXjpaEPEFLFcQllT56dqu+6U4GHKxZZpZqdyloa1n3/xRdlNsY9Re3Jhf939NFSnNGN35QhShLWXng6izmVt2M/za0KqtE4wOp63PnQfmFyc8C8uW4NnXS5vqe+4RgJVrwgIMrPuu+89e6pLlHhHk6nfildcZp4pBiNyTLRVrI/P3LMEw6GXo85J9Zf0EIcDgP9B5IIuTe8e5DuRWbWsm4Q0KWP+doBK9cJN6nOaf3WRJ36vOErrP8gcdOu1xxhTtxnoXMjnWZpliWbew2ZBU8LOaHCu8jycnDcOpj05K1owcokLd0SEscUyZUyZk8IqoLWhVohScXTbB3WIZAumOk0V1ku6p9mn63KB6soKDIUxiLjCN0WV1diptyVoSmxJiYi4HK7rywnlFiFRMMLtSZ+63fGNwicykhM7cM5X2n5LcSf7rxFLrpkhO7qnwUucStXlxMB0OKOawREKLxn6EWljnm+fzS37w7DSKycqJFP5Z6ojHsST6lehVlP+AeUP3SeSenLqnHQAzJYvulHa0ljVvMaTQP1UUr2u5Xrt/aXqSN739CyidIDUKgxLkqmtEVgk14fntO3CXfSQ/Ty0UeMyyqabfzoKA6+AapcHrgoeEewQppARlMTC1XVLFdAw3XDT1OIjmAgrqtfEpzy6+oF4ykJhhA9FSUN8nXsqdK1ysxrvJLld8c3w0W+tbsT9+hXfTCoRXkKV1YHjVAUZdlckN3UVZj9YzYY7yNJusFEowAEvbNt5BhA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfe4acb6-ad11-4468-2bc1-08daf3ef5727 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:31.2827 (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: EETpE2opMYtrHXAq6kpu8J1nsZSAGJ9X0ztdqIoQo6F280C+A3/txJonvVIyzccVkOJYsevlCHgMW36Kk/k+CA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7549 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Some hardware instances of the ocelot driver support the MAC Merge layer, which gives access to an extra preemptible MAC. This has implications upon the statistics. There will be a stats layout when MM isn't supported, and a different one when it is. The ocelot_stats_layout() helper will return the correct one. In preparation of that, refactor the existing code to use this helper. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new (v1 was written for enetc) drivers/net/ethernet/mscc/ocelot_stats.c | 40 +++++++++++++++++------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_stats.c b/drivers/net/ethernet/mscc/ocelot_stats.c index 01306172b7f7..551e3cbfae79 100644 --- a/drivers/net/ethernet/mscc/ocelot_stats.c +++ b/drivers/net/ethernet/mscc/ocelot_stats.c @@ -228,6 +228,12 @@ static const struct ocelot_stat_layout ocelot_stats_layout[OCELOT_NUM_STATS] = { OCELOT_COMMON_STATS, }; +static const struct ocelot_stat_layout * +ocelot_get_stats_layout(struct ocelot *ocelot) +{ + return ocelot_stats_layout; +} + /* Read the counters from hardware and keep them in region->buf. * Caller must hold &ocelot->stat_view_lock. */ @@ -306,16 +312,19 @@ static void ocelot_check_stats_work(struct work_struct *work) void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data) { + const struct ocelot_stat_layout *layout; int i; if (sset != ETH_SS_STATS) return; + layout = ocelot_get_stats_layout(ocelot); + for (i = 0; i < OCELOT_NUM_STATS; i++) { - if (ocelot_stats_layout[i].name[0] == '\0') + if (layout[i].name[0] == '\0') continue; - memcpy(data, ocelot_stats_layout[i].name, ETH_GSTRING_LEN); + memcpy(data, layout[i].name, ETH_GSTRING_LEN); data += ETH_GSTRING_LEN; } } @@ -350,13 +359,16 @@ static void ocelot_port_stats_run(struct ocelot *ocelot, int port, void *priv, int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset) { + const struct ocelot_stat_layout *layout; int i, num_stats = 0; if (sset != ETH_SS_STATS) return -EOPNOTSUPP; + layout = ocelot_get_stats_layout(ocelot); + for (i = 0; i < OCELOT_NUM_STATS; i++) - if (ocelot_stats_layout[i].name[0] != '\0') + if (layout[i].name[0] != '\0') num_stats++; return num_stats; @@ -366,14 +378,17 @@ EXPORT_SYMBOL(ocelot_get_sset_count); static void ocelot_port_ethtool_stats_cb(struct ocelot *ocelot, int port, void *priv) { + const struct ocelot_stat_layout *layout; u64 *data = priv; int i; + layout = ocelot_get_stats_layout(ocelot); + /* Copy all supported counters */ for (i = 0; i < OCELOT_NUM_STATS; i++) { int index = port * OCELOT_NUM_STATS + i; - if (ocelot_stats_layout[i].name[0] == '\0') + if (layout[i].name[0] == '\0') continue; *data++ = ocelot->stats[index]; @@ -602,16 +617,19 @@ EXPORT_SYMBOL(ocelot_port_get_stats64); static int ocelot_prepare_stats_regions(struct ocelot *ocelot) { struct ocelot_stats_region *region = NULL; + const struct ocelot_stat_layout *layout; unsigned int last = 0; int i; INIT_LIST_HEAD(&ocelot->stats_regions); + layout = ocelot_get_stats_layout(ocelot); + for (i = 0; i < OCELOT_NUM_STATS; i++) { - if (!ocelot_stats_layout[i].reg) + if (!layout[i].reg) continue; - if (region && ocelot_stats_layout[i].reg == last + 4) { + if (region && layout[i].reg == last + 4) { region->count++; } else { region = devm_kzalloc(ocelot->dev, sizeof(*region), @@ -620,17 +638,17 @@ static int ocelot_prepare_stats_regions(struct ocelot *ocelot) return -ENOMEM; /* enum ocelot_stat must be kept sorted in the same - * order as ocelot_stats_layout[i].reg in order to have - * efficient bulking + * order as layout[i].reg in order to have efficient + * bulking */ - WARN_ON(last >= ocelot_stats_layout[i].reg); + WARN_ON(last >= layout[i].reg); - region->base = ocelot_stats_layout[i].reg; + region->base = layout[i].reg; region->count = 1; list_add_tail(®ion->node, &ocelot->stats_regions); } - last = ocelot_stats_layout[i].reg; + last = layout[i].reg; } list_for_each_entry(region, &ocelot->stats_regions, node) { From patchwork Wed Jan 11 16:17:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096911 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 62CE7C46467 for ; Wed, 11 Jan 2023 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233316AbjAKQSR (ORCPT ); Wed, 11 Jan 2023 11:18:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235948AbjAKQRv (ORCPT ); Wed, 11 Jan 2023 11:17:51 -0500 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2054.outbound.protection.outlook.com [40.107.13.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2606F1C121; Wed, 11 Jan 2023 08:17:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eQXeAxE+7wBReQsk4WQ8recoc9AcngyK1VjtMUZ1SY/jMbPGShZxVnC6wlehhH8b/q1qG4A8m9XOGVMNWAoQKCiWWVXqclq6ytRmYQ8U69Ny2/V9Rjli1m30bnGch/zNe5XTeCpFRRT+wZ9IthqwaDYxg4U0wHZ0gYokwAnp0aEnqFkFZFRR4NDmu2MUO6xWha/nUKUofkK84wwVnJeA+imoEfCYfhtYVhdstEGBEb0tVdOC2kl3tBR4sV41bSUpOM9noakbIiWlKV4curxmklLZdjjfKyyTrtOrjNx6f9sZUf1bKDutS8K5zxivGQwsTzuPwjM00+Dbbf8ybqYY/Q== 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=5kpme7pSuwhxEiksw5G/NA7rrKyj4XaDOf58Tita2gg=; b=jtDeUVGTbyqlk/W1v+lh+zpRzQiodkDvB1xhSKKdigid2Lq380Hl/urnFwB6dZsho3dZXk6D/qoZlOb+c575nRZzhLOGy4v6/RnlccI2/47BPeqCrLU35Vwk4OnJhmw5b7WsEEV/EyUYEO8oVAjV1EDmQ83yRVdC8WiX6VEXBioP4ahrjMi7AI8tU4qfUGoKhkuRIYuvvr24EIVPDKZps6wI0KvK1ZNf1o9Mbrd3kvSelFoa4vt+OABdEh4KEtNcs5DV7eEcbmpXYRTjqlb4ztIgY4GLy5RtcSRjxOXP+H6sentA5VULoe1bCBqTkhFWBlZHMCtMxVbsG/XVqB34Uw== 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=5kpme7pSuwhxEiksw5G/NA7rrKyj4XaDOf58Tita2gg=; b=TIq5v7fa6cSlE+J1zVIvuoDmB8siWW96i3GyPt3u3V4YGu4LQIPf/miKqrAEcj4S+amxdVUFKUY0euw8mNXWKxWpJPh8W7mj/uyWjhD6DEcOsEI6pSGUy/TaJrcomhB0FpiH47sOPEYdCGJez21ax4rHZV3SfDuVO2SMygNXAcs= 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 PA4PR04MB7549.eurprd04.prod.outlook.com (2603:10a6:102:e0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:32 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:32 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 11/12] net: mscc: ocelot: export ethtool MAC Merge stats for Felix VSC9959 Date: Wed, 11 Jan 2023 18:17:05 +0200 Message-Id: <20230111161706.1465242-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7549:EE_ X-MS-Office365-Filtering-Correlation-Id: 42a3d1d8-dbb3-4d8f-593c-08daf3ef57fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1ocwwRbRLqhQGs5480uxHR2Op6OUDb49yBrMtw6XCuuUKZf6Y/CP4SRiw+FnqLssnDKMRBzx8/kQFXPvuQ4gGm6rbMmT32AapwrdT3BULijSpwzzvmE5CEN4r4Qv6BR3H6vZdaGKo+e8EoMnnMLOn8tYqa3SaENoj778wHhld4Oz5MAxFhXBeYV1wlv44YxnNiQsRUJun9UiLw36w9PkffNO42PfSevB9WmXj8aoEB3OzRXlcxVnjESHulGHslhv54f62RCuuHAeJdUTM9s+3/x3MIKYT8WdXQ2qjpKAUXy3jwW//2aB0YKtEdjvsYolC1/nzPH8OgYsxsJyBrQ4m/z0DrbDhBM+fNyLb1xnZR6mFaDlzcgTUTen1/mbRohlnycBNp4nvvL6Soxo/xYvkJxq4XIkCt88k1yycJBRWVWzzpwid3x/6zMafvBHnh1/VCoVeZUQPt0BcvM4RBjMJMo28j8GoNXwHRnvFQx/gRDBkBnzRrDRBQWphRk/IgZ326spOR0ERaGGj/tAloH32HINrBToIGBzigavW2U71sg/3MjQpForYeXU/vTyqyblE9VWjSylTeHDaGnZAi1cqKG7jHfGlr4CpjWaJ9zssH3G6d0PBFTXSBtDvMrN/+eqEeuaQAlGL6tJBX5wvyr/6o1Hp+ba4lFOY+QNCms+PFuG0tgPNmohQgzG5Z3tihnl 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:(13230022)(4636009)(376002)(346002)(366004)(136003)(39860400002)(396003)(451199015)(36756003)(38100700002)(8936002)(186003)(2906002)(41300700001)(7416002)(5660300002)(52116002)(6916009)(4326008)(66476007)(8676002)(66556008)(66946007)(316002)(54906003)(44832011)(38350700002)(6512007)(30864003)(26005)(2616005)(1076003)(86362001)(83380400001)(478600001)(6486002)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: t1HuV3SJ6cjQCp6W1/z5sr+FHWzhyfjXa3JyXeDEcLPJrOomaeRj4DLOYojGb5XOZQ+K3SDCVysaxf+9gHSRq/823r9T3uvdZ+/C4PBAA0qLXjQOsBZ6u9UY8Un6ijSVWGDliXo2a9Gg3e05bhg/gTWby9WFgRpcBEoPwSxe85Mes2SKTUNfevnRQ4ffqDIWaE3AIXyBDR/qrVitHyM1638aD6hex6CQcG4bjvZND+b8KQmIbeDf4pUWpC6hgWGa4/3AhyglFQT8s3lUoIIBKDRoVqgQUbzG6248dEJAjW7NYskFNOqvzOzAYjLAjrv9EbLfsady0kI+wttp5vAjm/Lf1vgQXlFne1BbkicGe9Kz3MiZwk2t5ZyIsaRJX/WHPSPyVw2zDjI2iLCxclyhW+yiLD8F+Y2WmHzI/qGWAiSCsjwTzzcFsS2dJq/47dUAedrfZFD2OSkgTnl1HVAsr/dpPMUAPgHgEss04bA9kLOrI6NkUiDT8hMNPkIeNoC+AzHU8HKvgUibcIOCWyzmuym4Yd0+qLBqufHYqZ2gXIhpLR3lHfn4vmvFs67sQlqjZXQTrCFSTOghFeDkjZYjyFnqsSansogESzlzrVWjeECARYD3mzX2DXnLC3LEyLfhNDHW8HSohV12wIEkwqK/bydd4lQyhrS/Hz3T9D0eOHaCnIddbPo9xBsTjRDx0zIARQgchlj3VrPCgL2M0sv9DfUxhxOP2hJblXUGOuIUGIEtr4rY6NMiv2SODis/TclmGkG1K6wjWPXqkU+bDtTtGj8R4Etj4QiiMTImgwC7u+/7SXeODeiVs6X7SsWm32vx5kkgAAkvvpN+pPNRG3oypTbWMOLkNJd/bDCRxjUG0RlUl1ab3DUZp+F088DhnNxmpgUEciONgsqWzZdWCizYAzO+VAAT/6VGkFW8A8O62XrUmZLaH430fiuTtbQODgUQVW8Hx2FFRl8m7tUgqdb/V9JXAC57nWeumElmoedq2lHivjElg50cRgKVCwxDEGtdsn5chQ54fGFE2ut6kpeqTi6zCMTGOveNPPYU/+TbLOiOZImczMtKsteg9uzXbVzaR8Deq5bsmLDrumW8NM6qrGzsBvs0HnXii7bPUEXi+9yeYv4wFQol8B+chSDTjQQIKeyXp+h83O5VHOCOcy9VhTJl2vcxmYUIsAzzNES7Z5ikZGa/w99sU0RTgsVr5SMmzOihgxZNBDXvumlyh5ScuI92yXaZ7xR9itS4xa88y5PE3tIs6EgdQUu1HoZnlnpxMatn/NhDA8c+nQeQV+rnP4OVBMpqKth2jpZxZO8jx19rlxF/lQPAiN1Y2+EH1Cu54vep6BDXXWsHeSGrXH/Ahft282WbnIwVtyUE3x3tQDQiWv/Bb06vWHejN8WY664A254ljFbrdaS8Z3MVnciNfK1LOKNeCxejLhaULhEIk5g8NCqmPIunH96Zp4CMDxQPDz4jPjSVgsme9fIhRrJrSI5qjqs4msICT0eaBibDG8KdyazhMX5pKLld/ZnOJGlSn+Sfvr0AP2lZtIE8Mv3DYZAAw18P5a3BHBmrPdusDE1eCnymt9Pvwjlw5GS5ecrIAyk4DQrYwokrM8j/lHxyDA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42a3d1d8-dbb3-4d8f-593c-08daf3ef57fb X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:32.7982 (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: VAtjM2/oqbuB7Rtb+jkjKdfxrXOjfJnall+AT53G8yfNn7Sqv98mox/XygU14fvfPMpsVYShOvXAEwaYEDeDow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7549 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The Felix VSC9959 switch supports frame preemption and has a MAC Merge layer. In addition to the structured stats that exist for the eMAC, export the counters associated with its pMAC (pause, RMON, MAC, PHY, control) plus the high-level MAC Merge layer stats. The unstructured ethtool counters, as well as the rtnl_link_stats64 were left to report only the eMAC counters. Because statistics processing is quite self-contained in ocelot_stats.c now, I've opted for introducing an ocelot->mm_supported bool, based on which the common switch lib does everything, rather than pushing the TSN-specific code in felix_vsc9959.c, as happens for other TSN stuff. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new (v1 was written for enetc) drivers/net/dsa/ocelot/felix.c | 9 + drivers/net/dsa/ocelot/felix_vsc9959.c | 38 +++ drivers/net/ethernet/mscc/ocelot_stats.c | 289 ++++++++++++++++++++++- include/soc/mscc/ocelot.h | 40 ++++ 4 files changed, 366 insertions(+), 10 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 00dda0e07d4b..09f839dc9e64 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -2066,6 +2066,14 @@ static int felix_port_del_dscp_prio(struct dsa_switch *ds, int port, u8 dscp, return ocelot_port_del_dscp_prio(ocelot, port, dscp, prio); } +static void felix_get_mm_stats(struct dsa_switch *ds, int port, + struct ethtool_mm_stats *stats) +{ + struct ocelot *ocelot = ds->priv; + + ocelot_port_get_mm_stats(ocelot, port, stats); +} + const struct dsa_switch_ops felix_switch_ops = { .get_tag_protocol = felix_get_tag_protocol, .change_tag_protocol = felix_change_tag_protocol, @@ -2073,6 +2081,7 @@ const struct dsa_switch_ops felix_switch_ops = { .setup = felix_setup, .teardown = felix_teardown, .set_ageing_time = felix_set_ageing_time, + .get_mm_stats = felix_get_mm_stats, .get_stats64 = felix_get_stats64, .get_pause_stats = felix_get_pause_stats, .get_rmon_stats = felix_get_rmon_stats, diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index ccdc25d47fe1..260d861c7072 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -318,6 +318,29 @@ static const u32 vsc9959_sys_regmap[] = { REG(SYS_COUNT_RX_GREEN_PRIO_5, 0x0000a4), REG(SYS_COUNT_RX_GREEN_PRIO_6, 0x0000a8), REG(SYS_COUNT_RX_GREEN_PRIO_7, 0x0000ac), + REG(SYS_COUNT_RX_ASSEMBLY_ERRS, 0x0000b0), + REG(SYS_COUNT_RX_SMD_ERRS, 0x0000b4), + REG(SYS_COUNT_RX_ASSEMBLY_OK, 0x0000b8), + REG(SYS_COUNT_RX_MERGE_FRAGMENTS, 0x0000bc), + REG(SYS_COUNT_RX_PMAC_OCTETS, 0x0000c0), + REG(SYS_COUNT_RX_PMAC_UNICAST, 0x0000c4), + REG(SYS_COUNT_RX_PMAC_MULTICAST, 0x0000c8), + REG(SYS_COUNT_RX_PMAC_BROADCAST, 0x0000cc), + REG(SYS_COUNT_RX_PMAC_SHORTS, 0x0000d0), + REG(SYS_COUNT_RX_PMAC_FRAGMENTS, 0x0000d4), + REG(SYS_COUNT_RX_PMAC_JABBERS, 0x0000d8), + REG(SYS_COUNT_RX_PMAC_CRC_ALIGN_ERRS, 0x0000dc), + REG(SYS_COUNT_RX_PMAC_SYM_ERRS, 0x0000e0), + REG(SYS_COUNT_RX_PMAC_64, 0x0000e4), + REG(SYS_COUNT_RX_PMAC_65_127, 0x0000e8), + REG(SYS_COUNT_RX_PMAC_128_255, 0x0000ec), + REG(SYS_COUNT_RX_PMAC_256_511, 0x0000f0), + REG(SYS_COUNT_RX_PMAC_512_1023, 0x0000f4), + REG(SYS_COUNT_RX_PMAC_1024_1526, 0x0000f8), + REG(SYS_COUNT_RX_PMAC_1527_MAX, 0x0000fc), + REG(SYS_COUNT_RX_PMAC_PAUSE, 0x000100), + REG(SYS_COUNT_RX_PMAC_CONTROL, 0x000104), + REG(SYS_COUNT_RX_PMAC_LONGS, 0x000108), REG(SYS_COUNT_TX_OCTETS, 0x000200), REG(SYS_COUNT_TX_UNICAST, 0x000204), REG(SYS_COUNT_TX_MULTICAST, 0x000208), @@ -349,6 +372,20 @@ static const u32 vsc9959_sys_regmap[] = { REG(SYS_COUNT_TX_GREEN_PRIO_6, 0x000270), REG(SYS_COUNT_TX_GREEN_PRIO_7, 0x000274), REG(SYS_COUNT_TX_AGED, 0x000278), + REG(SYS_COUNT_TX_MM_HOLD, 0x00027c), + REG(SYS_COUNT_TX_MERGE_FRAGMENTS, 0x000280), + REG(SYS_COUNT_TX_PMAC_OCTETS, 0x000284), + REG(SYS_COUNT_TX_PMAC_UNICAST, 0x000288), + REG(SYS_COUNT_TX_PMAC_MULTICAST, 0x00028c), + REG(SYS_COUNT_TX_PMAC_BROADCAST, 0x000290), + REG(SYS_COUNT_TX_PMAC_PAUSE, 0x000294), + REG(SYS_COUNT_TX_PMAC_64, 0x000298), + REG(SYS_COUNT_TX_PMAC_65_127, 0x00029c), + REG(SYS_COUNT_TX_PMAC_128_255, 0x0002a0), + REG(SYS_COUNT_TX_PMAC_256_511, 0x0002a4), + REG(SYS_COUNT_TX_PMAC_512_1023, 0x0002a8), + REG(SYS_COUNT_TX_PMAC_1024_1526, 0x0002ac), + REG(SYS_COUNT_TX_PMAC_1527_MAX, 0x0002b0), REG(SYS_COUNT_DROP_LOCAL, 0x000400), REG(SYS_COUNT_DROP_TAIL, 0x000404), REG(SYS_COUNT_DROP_YELLOW_PRIO_0, 0x000408), @@ -2626,6 +2663,7 @@ static int felix_pci_probe(struct pci_dev *pdev, } ocelot->ptp = 1; + ocelot->mm_supported = true; ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL); if (!ds) { diff --git a/drivers/net/ethernet/mscc/ocelot_stats.c b/drivers/net/ethernet/mscc/ocelot_stats.c index 551e3cbfae79..1932cea46cd0 100644 --- a/drivers/net/ethernet/mscc/ocelot_stats.c +++ b/drivers/net/ethernet/mscc/ocelot_stats.c @@ -54,6 +54,29 @@ enum ocelot_stat { OCELOT_STAT_RX_GREEN_PRIO_5, OCELOT_STAT_RX_GREEN_PRIO_6, OCELOT_STAT_RX_GREEN_PRIO_7, + OCELOT_STAT_RX_ASSEMBLY_ERRS, + OCELOT_STAT_RX_SMD_ERRS, + OCELOT_STAT_RX_ASSEMBLY_OK, + OCELOT_STAT_RX_MERGE_FRAGMENTS, + OCELOT_STAT_RX_PMAC_OCTETS, + OCELOT_STAT_RX_PMAC_UNICAST, + OCELOT_STAT_RX_PMAC_MULTICAST, + OCELOT_STAT_RX_PMAC_BROADCAST, + OCELOT_STAT_RX_PMAC_SHORTS, + OCELOT_STAT_RX_PMAC_FRAGMENTS, + OCELOT_STAT_RX_PMAC_JABBERS, + OCELOT_STAT_RX_PMAC_CRC_ALIGN_ERRS, + OCELOT_STAT_RX_PMAC_SYM_ERRS, + OCELOT_STAT_RX_PMAC_64, + OCELOT_STAT_RX_PMAC_65_127, + OCELOT_STAT_RX_PMAC_128_255, + OCELOT_STAT_RX_PMAC_256_511, + OCELOT_STAT_RX_PMAC_512_1023, + OCELOT_STAT_RX_PMAC_1024_1526, + OCELOT_STAT_RX_PMAC_1527_MAX, + OCELOT_STAT_RX_PMAC_PAUSE, + OCELOT_STAT_RX_PMAC_CONTROL, + OCELOT_STAT_RX_PMAC_LONGS, OCELOT_STAT_TX_OCTETS, OCELOT_STAT_TX_UNICAST, OCELOT_STAT_TX_MULTICAST, @@ -85,6 +108,20 @@ enum ocelot_stat { OCELOT_STAT_TX_GREEN_PRIO_6, OCELOT_STAT_TX_GREEN_PRIO_7, OCELOT_STAT_TX_AGED, + OCELOT_STAT_TX_MM_HOLD, + OCELOT_STAT_TX_MERGE_FRAGMENTS, + OCELOT_STAT_TX_PMAC_OCTETS, + OCELOT_STAT_TX_PMAC_UNICAST, + OCELOT_STAT_TX_PMAC_MULTICAST, + OCELOT_STAT_TX_PMAC_BROADCAST, + OCELOT_STAT_TX_PMAC_PAUSE, + OCELOT_STAT_TX_PMAC_64, + OCELOT_STAT_TX_PMAC_65_127, + OCELOT_STAT_TX_PMAC_128_255, + OCELOT_STAT_TX_PMAC_256_511, + OCELOT_STAT_TX_PMAC_512_1023, + OCELOT_STAT_TX_PMAC_1024_1526, + OCELOT_STAT_TX_PMAC_1527_MAX, OCELOT_STAT_DROP_LOCAL, OCELOT_STAT_DROP_TAIL, OCELOT_STAT_DROP_YELLOW_PRIO_0, @@ -228,9 +265,52 @@ static const struct ocelot_stat_layout ocelot_stats_layout[OCELOT_NUM_STATS] = { OCELOT_COMMON_STATS, }; +static const struct ocelot_stat_layout ocelot_mm_stats_layout[OCELOT_NUM_STATS] = { + OCELOT_COMMON_STATS, + OCELOT_STAT(RX_ASSEMBLY_ERRS), + OCELOT_STAT(RX_SMD_ERRS), + OCELOT_STAT(RX_ASSEMBLY_OK), + OCELOT_STAT(RX_MERGE_FRAGMENTS), + OCELOT_STAT(TX_MERGE_FRAGMENTS), + OCELOT_STAT(RX_PMAC_OCTETS), + OCELOT_STAT(RX_PMAC_UNICAST), + OCELOT_STAT(RX_PMAC_MULTICAST), + OCELOT_STAT(RX_PMAC_BROADCAST), + OCELOT_STAT(RX_PMAC_SHORTS), + OCELOT_STAT(RX_PMAC_FRAGMENTS), + OCELOT_STAT(RX_PMAC_JABBERS), + OCELOT_STAT(RX_PMAC_CRC_ALIGN_ERRS), + OCELOT_STAT(RX_PMAC_SYM_ERRS), + OCELOT_STAT(RX_PMAC_64), + OCELOT_STAT(RX_PMAC_65_127), + OCELOT_STAT(RX_PMAC_128_255), + OCELOT_STAT(RX_PMAC_256_511), + OCELOT_STAT(RX_PMAC_512_1023), + OCELOT_STAT(RX_PMAC_1024_1526), + OCELOT_STAT(RX_PMAC_1527_MAX), + OCELOT_STAT(RX_PMAC_PAUSE), + OCELOT_STAT(RX_PMAC_CONTROL), + OCELOT_STAT(RX_PMAC_LONGS), + OCELOT_STAT(TX_PMAC_OCTETS), + OCELOT_STAT(TX_PMAC_UNICAST), + OCELOT_STAT(TX_PMAC_MULTICAST), + OCELOT_STAT(TX_PMAC_BROADCAST), + OCELOT_STAT(TX_PMAC_PAUSE), + OCELOT_STAT(TX_PMAC_64), + OCELOT_STAT(TX_PMAC_65_127), + OCELOT_STAT(TX_PMAC_128_255), + OCELOT_STAT(TX_PMAC_256_511), + OCELOT_STAT(TX_PMAC_512_1023), + OCELOT_STAT(TX_PMAC_1024_1526), + OCELOT_STAT(TX_PMAC_1527_MAX), +}; + static const struct ocelot_stat_layout * ocelot_get_stats_layout(struct ocelot *ocelot) { + if (ocelot->mm_supported) + return ocelot_mm_stats_layout; + return ocelot_stats_layout; } @@ -410,14 +490,63 @@ static void ocelot_port_pause_stats_cb(struct ocelot *ocelot, int port, void *pr pause_stats->rx_pause_frames = s[OCELOT_STAT_RX_PAUSE]; } +static void ocelot_port_pmac_pause_stats_cb(struct ocelot *ocelot, int port, + void *priv) +{ + u64 *s = &ocelot->stats[port * OCELOT_NUM_STATS]; + struct ethtool_pause_stats *pause_stats = priv; + + pause_stats->tx_pause_frames = s[OCELOT_STAT_TX_PMAC_PAUSE]; + pause_stats->rx_pause_frames = s[OCELOT_STAT_RX_PMAC_PAUSE]; +} + +static void ocelot_port_mm_stats_cb(struct ocelot *ocelot, int port, + void *priv) +{ + u64 *s = &ocelot->stats[port * OCELOT_NUM_STATS]; + struct ethtool_mm_stats *stats = priv; + + stats->MACMergeFrameAssErrorCount = s[OCELOT_STAT_RX_ASSEMBLY_ERRS]; + stats->MACMergeFrameSmdErrorCount = s[OCELOT_STAT_RX_SMD_ERRS]; + stats->MACMergeFrameAssOkCount = s[OCELOT_STAT_RX_ASSEMBLY_OK]; + stats->MACMergeFragCountRx = s[OCELOT_STAT_RX_MERGE_FRAGMENTS]; + stats->MACMergeFragCountTx = s[OCELOT_STAT_TX_MERGE_FRAGMENTS]; + stats->MACMergeHoldCount = s[OCELOT_STAT_TX_MM_HOLD]; +} + void ocelot_port_get_pause_stats(struct ocelot *ocelot, int port, struct ethtool_pause_stats *pause_stats) { - ocelot_port_stats_run(ocelot, port, pause_stats, - ocelot_port_pause_stats_cb); + struct net_device *dev; + + switch (pause_stats->src) { + case ETHTOOL_STATS_SRC_EMAC: + ocelot_port_stats_run(ocelot, port, pause_stats, + ocelot_port_pause_stats_cb); + break; + case ETHTOOL_STATS_SRC_PMAC: + if (ocelot->mm_supported) + ocelot_port_stats_run(ocelot, port, pause_stats, + ocelot_port_pmac_pause_stats_cb); + break; + case ETHTOOL_STATS_SRC_AGGREGATE: + dev = ocelot->ops->port_to_netdev(ocelot, port); + ethtool_aggregate_pause_stats(dev, pause_stats); + break; + } } EXPORT_SYMBOL_GPL(ocelot_port_get_pause_stats); +void ocelot_port_get_mm_stats(struct ocelot *ocelot, int port, + struct ethtool_mm_stats *stats) +{ + if (!ocelot->mm_supported) + return; + + ocelot_port_stats_run(ocelot, port, stats, ocelot_port_mm_stats_cb); +} +EXPORT_SYMBOL_GPL(ocelot_port_get_mm_stats); + static const struct ethtool_rmon_hist_range ocelot_rmon_ranges[] = { { 64, 64 }, { 65, 127 }, @@ -456,14 +585,57 @@ static void ocelot_port_rmon_stats_cb(struct ocelot *ocelot, int port, void *pri rmon_stats->hist_tx[6] = s[OCELOT_STAT_TX_1024_1526]; } +static void ocelot_port_pmac_rmon_stats_cb(struct ocelot *ocelot, int port, + void *priv) +{ + u64 *s = &ocelot->stats[port * OCELOT_NUM_STATS]; + struct ethtool_rmon_stats *rmon_stats = priv; + + rmon_stats->undersize_pkts = s[OCELOT_STAT_RX_PMAC_SHORTS]; + rmon_stats->oversize_pkts = s[OCELOT_STAT_RX_PMAC_LONGS]; + rmon_stats->fragments = s[OCELOT_STAT_RX_PMAC_FRAGMENTS]; + rmon_stats->jabbers = s[OCELOT_STAT_RX_PMAC_JABBERS]; + + rmon_stats->hist[0] = s[OCELOT_STAT_RX_PMAC_64]; + rmon_stats->hist[1] = s[OCELOT_STAT_RX_PMAC_65_127]; + rmon_stats->hist[2] = s[OCELOT_STAT_RX_PMAC_128_255]; + rmon_stats->hist[3] = s[OCELOT_STAT_RX_PMAC_256_511]; + rmon_stats->hist[4] = s[OCELOT_STAT_RX_PMAC_512_1023]; + rmon_stats->hist[5] = s[OCELOT_STAT_RX_PMAC_1024_1526]; + rmon_stats->hist[6] = s[OCELOT_STAT_RX_PMAC_1527_MAX]; + + rmon_stats->hist_tx[0] = s[OCELOT_STAT_TX_PMAC_64]; + rmon_stats->hist_tx[1] = s[OCELOT_STAT_TX_PMAC_65_127]; + rmon_stats->hist_tx[2] = s[OCELOT_STAT_TX_PMAC_128_255]; + rmon_stats->hist_tx[3] = s[OCELOT_STAT_TX_PMAC_128_255]; + rmon_stats->hist_tx[4] = s[OCELOT_STAT_TX_PMAC_256_511]; + rmon_stats->hist_tx[5] = s[OCELOT_STAT_TX_PMAC_512_1023]; + rmon_stats->hist_tx[6] = s[OCELOT_STAT_TX_PMAC_1024_1526]; +} + void ocelot_port_get_rmon_stats(struct ocelot *ocelot, int port, struct ethtool_rmon_stats *rmon_stats, const struct ethtool_rmon_hist_range **ranges) { + struct net_device *dev; + *ranges = ocelot_rmon_ranges; - ocelot_port_stats_run(ocelot, port, rmon_stats, - ocelot_port_rmon_stats_cb); + switch (rmon_stats->src) { + case ETHTOOL_STATS_SRC_EMAC: + ocelot_port_stats_run(ocelot, port, rmon_stats, + ocelot_port_rmon_stats_cb); + break; + case ETHTOOL_STATS_SRC_PMAC: + if (ocelot->mm_supported) + ocelot_port_stats_run(ocelot, port, rmon_stats, + ocelot_port_pmac_rmon_stats_cb); + break; + case ETHTOOL_STATS_SRC_AGGREGATE: + dev = ocelot->ops->port_to_netdev(ocelot, port); + ethtool_aggregate_rmon_stats(dev, rmon_stats); + break; + } } EXPORT_SYMBOL_GPL(ocelot_port_get_rmon_stats); @@ -475,11 +647,35 @@ static void ocelot_port_ctrl_stats_cb(struct ocelot *ocelot, int port, void *pri ctrl_stats->MACControlFramesReceived = s[OCELOT_STAT_RX_CONTROL]; } +static void ocelot_port_pmac_ctrl_stats_cb(struct ocelot *ocelot, int port, + void *priv) +{ + u64 *s = &ocelot->stats[port * OCELOT_NUM_STATS]; + struct ethtool_eth_ctrl_stats *ctrl_stats = priv; + + ctrl_stats->MACControlFramesReceived = s[OCELOT_STAT_RX_PMAC_CONTROL]; +} + void ocelot_port_get_eth_ctrl_stats(struct ocelot *ocelot, int port, struct ethtool_eth_ctrl_stats *ctrl_stats) { - ocelot_port_stats_run(ocelot, port, ctrl_stats, - ocelot_port_ctrl_stats_cb); + struct net_device *dev; + + switch (ctrl_stats->src) { + case ETHTOOL_STATS_SRC_EMAC: + ocelot_port_stats_run(ocelot, port, ctrl_stats, + ocelot_port_ctrl_stats_cb); + break; + case ETHTOOL_STATS_SRC_PMAC: + if (ocelot->mm_supported) + ocelot_port_stats_run(ocelot, port, ctrl_stats, + ocelot_port_pmac_ctrl_stats_cb); + break; + case ETHTOOL_STATS_SRC_AGGREGATE: + dev = ocelot->ops->port_to_netdev(ocelot, port); + ethtool_aggregate_ctrl_stats(dev, ctrl_stats); + break; + } } EXPORT_SYMBOL_GPL(ocelot_port_get_eth_ctrl_stats); @@ -525,11 +721,60 @@ static void ocelot_port_mac_stats_cb(struct ocelot *ocelot, int port, void *priv mac_stats->AlignmentErrors = s[OCELOT_STAT_RX_CRC_ALIGN_ERRS]; } +static void ocelot_port_pmac_mac_stats_cb(struct ocelot *ocelot, int port, + void *priv) +{ + u64 *s = &ocelot->stats[port * OCELOT_NUM_STATS]; + struct ethtool_eth_mac_stats *mac_stats = priv; + + mac_stats->OctetsTransmittedOK = s[OCELOT_STAT_TX_PMAC_OCTETS]; + mac_stats->FramesTransmittedOK = s[OCELOT_STAT_TX_PMAC_64] + + s[OCELOT_STAT_TX_PMAC_65_127] + + s[OCELOT_STAT_TX_PMAC_128_255] + + s[OCELOT_STAT_TX_PMAC_256_511] + + s[OCELOT_STAT_TX_PMAC_512_1023] + + s[OCELOT_STAT_TX_PMAC_1024_1526] + + s[OCELOT_STAT_TX_PMAC_1527_MAX]; + mac_stats->OctetsReceivedOK = s[OCELOT_STAT_RX_PMAC_OCTETS]; + mac_stats->FramesReceivedOK = s[OCELOT_STAT_RX_PMAC_64] + + s[OCELOT_STAT_RX_PMAC_65_127] + + s[OCELOT_STAT_RX_PMAC_128_255] + + s[OCELOT_STAT_RX_PMAC_256_511] + + s[OCELOT_STAT_RX_PMAC_512_1023] + + s[OCELOT_STAT_RX_PMAC_1024_1526] + + s[OCELOT_STAT_RX_PMAC_1527_MAX]; + mac_stats->MulticastFramesXmittedOK = s[OCELOT_STAT_TX_PMAC_MULTICAST]; + mac_stats->BroadcastFramesXmittedOK = s[OCELOT_STAT_TX_PMAC_BROADCAST]; + mac_stats->MulticastFramesReceivedOK = s[OCELOT_STAT_RX_PMAC_MULTICAST]; + mac_stats->BroadcastFramesReceivedOK = s[OCELOT_STAT_RX_PMAC_BROADCAST]; + mac_stats->FrameTooLongErrors = s[OCELOT_STAT_RX_PMAC_LONGS]; + /* Sadly, C_RX_CRC is the sum of FCS and alignment errors, they are not + * counted individually. + */ + mac_stats->FrameCheckSequenceErrors = s[OCELOT_STAT_RX_PMAC_CRC_ALIGN_ERRS]; + mac_stats->AlignmentErrors = s[OCELOT_STAT_RX_PMAC_CRC_ALIGN_ERRS]; +} + void ocelot_port_get_eth_mac_stats(struct ocelot *ocelot, int port, struct ethtool_eth_mac_stats *mac_stats) { - ocelot_port_stats_run(ocelot, port, mac_stats, - ocelot_port_mac_stats_cb); + struct net_device *dev; + + switch (mac_stats->src) { + case ETHTOOL_STATS_SRC_EMAC: + ocelot_port_stats_run(ocelot, port, mac_stats, + ocelot_port_mac_stats_cb); + break; + case ETHTOOL_STATS_SRC_PMAC: + if (ocelot->mm_supported) + ocelot_port_stats_run(ocelot, port, mac_stats, + ocelot_port_pmac_mac_stats_cb); + break; + case ETHTOOL_STATS_SRC_AGGREGATE: + dev = ocelot->ops->port_to_netdev(ocelot, port); + ethtool_aggregate_mac_stats(dev, mac_stats); + break; + } } EXPORT_SYMBOL_GPL(ocelot_port_get_eth_mac_stats); @@ -541,11 +786,35 @@ static void ocelot_port_phy_stats_cb(struct ocelot *ocelot, int port, void *priv phy_stats->SymbolErrorDuringCarrier = s[OCELOT_STAT_RX_SYM_ERRS]; } +static void ocelot_port_pmac_phy_stats_cb(struct ocelot *ocelot, int port, + void *priv) +{ + u64 *s = &ocelot->stats[port * OCELOT_NUM_STATS]; + struct ethtool_eth_phy_stats *phy_stats = priv; + + phy_stats->SymbolErrorDuringCarrier = s[OCELOT_STAT_RX_PMAC_SYM_ERRS]; +} + void ocelot_port_get_eth_phy_stats(struct ocelot *ocelot, int port, struct ethtool_eth_phy_stats *phy_stats) { - ocelot_port_stats_run(ocelot, port, phy_stats, - ocelot_port_phy_stats_cb); + struct net_device *dev; + + switch (phy_stats->src) { + case ETHTOOL_STATS_SRC_EMAC: + ocelot_port_stats_run(ocelot, port, phy_stats, + ocelot_port_phy_stats_cb); + break; + case ETHTOOL_STATS_SRC_PMAC: + if (ocelot->mm_supported) + ocelot_port_stats_run(ocelot, port, phy_stats, + ocelot_port_pmac_phy_stats_cb); + break; + case ETHTOOL_STATS_SRC_AGGREGATE: + dev = ocelot->ops->port_to_netdev(ocelot, port); + ethtool_aggregate_phy_stats(dev, phy_stats); + break; + } } EXPORT_SYMBOL_GPL(ocelot_port_get_eth_phy_stats); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index df62be80a193..6de909d79896 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -362,6 +362,29 @@ enum ocelot_reg { SYS_COUNT_RX_GREEN_PRIO_5, SYS_COUNT_RX_GREEN_PRIO_6, SYS_COUNT_RX_GREEN_PRIO_7, + SYS_COUNT_RX_ASSEMBLY_ERRS, + SYS_COUNT_RX_SMD_ERRS, + SYS_COUNT_RX_ASSEMBLY_OK, + SYS_COUNT_RX_MERGE_FRAGMENTS, + SYS_COUNT_RX_PMAC_OCTETS, + SYS_COUNT_RX_PMAC_UNICAST, + SYS_COUNT_RX_PMAC_MULTICAST, + SYS_COUNT_RX_PMAC_BROADCAST, + SYS_COUNT_RX_PMAC_SHORTS, + SYS_COUNT_RX_PMAC_FRAGMENTS, + SYS_COUNT_RX_PMAC_JABBERS, + SYS_COUNT_RX_PMAC_CRC_ALIGN_ERRS, + SYS_COUNT_RX_PMAC_SYM_ERRS, + SYS_COUNT_RX_PMAC_64, + SYS_COUNT_RX_PMAC_65_127, + SYS_COUNT_RX_PMAC_128_255, + SYS_COUNT_RX_PMAC_256_511, + SYS_COUNT_RX_PMAC_512_1023, + SYS_COUNT_RX_PMAC_1024_1526, + SYS_COUNT_RX_PMAC_1527_MAX, + SYS_COUNT_RX_PMAC_PAUSE, + SYS_COUNT_RX_PMAC_CONTROL, + SYS_COUNT_RX_PMAC_LONGS, SYS_COUNT_TX_OCTETS, SYS_COUNT_TX_UNICAST, SYS_COUNT_TX_MULTICAST, @@ -393,6 +416,20 @@ enum ocelot_reg { SYS_COUNT_TX_GREEN_PRIO_6, SYS_COUNT_TX_GREEN_PRIO_7, SYS_COUNT_TX_AGED, + SYS_COUNT_TX_MM_HOLD, + SYS_COUNT_TX_MERGE_FRAGMENTS, + SYS_COUNT_TX_PMAC_OCTETS, + SYS_COUNT_TX_PMAC_UNICAST, + SYS_COUNT_TX_PMAC_MULTICAST, + SYS_COUNT_TX_PMAC_BROADCAST, + SYS_COUNT_TX_PMAC_PAUSE, + SYS_COUNT_TX_PMAC_64, + SYS_COUNT_TX_PMAC_65_127, + SYS_COUNT_TX_PMAC_128_255, + SYS_COUNT_TX_PMAC_256_511, + SYS_COUNT_TX_PMAC_512_1023, + SYS_COUNT_TX_PMAC_1024_1526, + SYS_COUNT_TX_PMAC_1527_MAX, SYS_COUNT_DROP_LOCAL, SYS_COUNT_DROP_TAIL, SYS_COUNT_DROP_YELLOW_PRIO_0, @@ -814,6 +851,7 @@ struct ocelot { struct workqueue_struct *owq; u8 ptp:1; + u8 mm_supported:1; struct ptp_clock *ptp_clock; struct ptp_clock_info ptp_info; struct hwtstamp_config hwtstamp_config; @@ -937,6 +975,8 @@ void ocelot_port_get_stats64(struct ocelot *ocelot, int port, struct rtnl_link_stats64 *stats); void ocelot_port_get_pause_stats(struct ocelot *ocelot, int port, struct ethtool_pause_stats *pause_stats); +void ocelot_port_get_mm_stats(struct ocelot *ocelot, int port, + struct ethtool_mm_stats *stats); void ocelot_port_get_rmon_stats(struct ocelot *ocelot, int port, struct ethtool_rmon_stats *rmon_stats, const struct ethtool_rmon_hist_range **ranges); From patchwork Wed Jan 11 16:17:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096913 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 C9318C677F1 for ; Wed, 11 Jan 2023 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234361AbjAKQS0 (ORCPT ); Wed, 11 Jan 2023 11:18:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237663AbjAKQRw (ORCPT ); Wed, 11 Jan 2023 11:17:52 -0500 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2054.outbound.protection.outlook.com [40.107.13.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7C81C427; Wed, 11 Jan 2023 08:17:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z1SF7dI41bdSFZUNM44FmCtu8dTyxqZHySdf60bcOW69U4DkZPJDsM4RdgdebXlpoJb0HCNmo7uw0C7r1l2IQ6jip9N8Myl2ec5ijP1zitmFkOpRJHiC0p+lCk1lFHOrrZ4dqkA6WTl36DSvpuabC5NQPLrI3ewCGBkudk/fUmv+5rux9/DwuUeTPnQ0oCYGfo6wsShTTk6eMROTPj9NLD1dql19fw5c196Z6GnmcDsLKD82xPwj7ZZ3sLyZ2aivSUDDl755RFUXIblU72cQkH01zyqNBZH7EhkhHyVq0VmcCi8feXa5wUCr9WEslETna5SOuaz8LH2v0IogjA42xw== 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=UE/+6tIP0KPsj9ih+4K+tEDsNMOH2Vrl400u9wUDDAs=; b=ITfpOgzCK/Yv6TsHBEhCId3Piu1c5CpI2es1FqVwlltR3i7OiKvJuupUTHMbT++kExgIW7oXva4seTioEqolGAvTcocFZhXA6m7mJNCthUd3Tg59rmxcD5XtMpB2y0WqYNtjZiQMm1HdCu62wSCQTfFgzdnP34wL69FOn4eULdFUUaSeEC+jM+/z3+a0vDEyYpiHNDgkK9FuPCOY6kqJg6iZq+nKijPOUL/PSPUb5fE7CTOa2o3uhhHabkx4PsUlr9RJ5xFpamp7yDevX1kCcoKOnU52usv03QMSw+ya7uVv9ws/iOPuugosYNbrgYSGycOGqxuawwzzBjk8vE6tcw== 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=UE/+6tIP0KPsj9ih+4K+tEDsNMOH2Vrl400u9wUDDAs=; b=hDFOjiuiHpGw8K/b39IXRfV98Vx4jb+bYVCE6As8ixaaAA7a37iyodmeb8x5X+17yuMFcJJFYJ71GaGrI4uW9WMZmKfEHFap6tXI7BCA4ApPEvOnb2tpFRcpMEIAdNQu3AzQyYegc3fFosadRxm+j0SNEBDtDegMJ/7cutTUVj0= 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 PA4PR04MB7549.eurprd04.prod.outlook.com (2603:10a6:102:e0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:34 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:34 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 12/12] net: mscc: ocelot: add MAC Merge layer support for VSC9959 Date: Wed, 11 Jan 2023 18:17:06 +0200 Message-Id: <20230111161706.1465242-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7549:EE_ X-MS-Office365-Filtering-Correlation-Id: 7312278e-67c5-491a-5dc4-08daf3ef58e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wxqIr6Ay30Bh+0A28Kl6gi5wXYPahAJD1nBV2XaYmfXNewRYCq9E4PsvFIE/XxL1clFFsvuWzTbBn7hIAMysS+Wv3OB1ly5PsL5kM75X34DCy1g5hpefd9wPqCzct24jPfme/OceqFyrmL8vo2ibFKruYTtrjx64ZZRzHEcDrsjbDgvn6et/v68q1NZXnL2JTLzVcMpuUcdD9g0m9z8tUfTmZIkAiXv7fE2SO95nVv0lCohv1cYOln7pU4+2gpwABNgkf+fDuzib7z8W6RNycnsdxSWNQKwFo7vGkZJHKzNdtXZBeBkIcF8pRMYTJKuIxETKw1i5j5hBshHjRlzCUIUz4dCNtCoTxJfhLONSE5RmRelgf5Bzsvjs/5qXehHyqaIM+ZCko2tZAe+UGIxBZ8NgSq5eX/GlpFHLlYsR9AR/7lee5N2VVpAksyo8abfafRjVe9EftO9G2vXS4Ly9uwWxCuieVDq7YOrkJLFBAjMcu6orPkTFPOUoal4n1+jyBcG9/cug66k44bRSIVVyr34tRMTNcXr2U5OajpxUCgp2HS6Fr4aTfPykBufRG7PCJzIT4nl9RKYprxz3lIXkrRz9LHw4jXDFIgqbUU+2eTM83kzN6KoPDXuDn+t92JbhQVmJEVpcbOVMGE7BBuufr5/HaJKC4SMzZdlnmeST9Rrt6rkXej4hziq+47WjSsEg 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:(13230022)(4636009)(376002)(346002)(366004)(136003)(39860400002)(396003)(451199015)(36756003)(38100700002)(8936002)(186003)(2906002)(41300700001)(7416002)(5660300002)(52116002)(6916009)(4326008)(66476007)(8676002)(66556008)(66946007)(316002)(54906003)(44832011)(38350700002)(6512007)(30864003)(26005)(2616005)(1076003)(86362001)(83380400001)(478600001)(6486002)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +xkqDV0tl5F/ztyVARwUY1FUKXpfRaGfXrLFEYAzJNBnxjyJKyWiYJiTv9Fgz96IKQivyEU8FnIn47YZOxAQcC7GGoMU12hf8UAOKAsEXZrStSqI52gQ9wX1XJzMs4FX7TrDsaPkQwGrLsAf8kgaYLG4miENF+yHyUGZS2pa2jTfG2KT+cd8VkjaqtrTMz2vae7t7RQtx5UIpwPq+deP5dBo8ZAQ5eewLVEdZrx2CxWnX+c/IW5FWbzKPmwMOli7bRqJU3fWBLKgVunWGbuxsTivz9nx81pETSfPriJmf+RBlRXmoYplbN6exZkN2VSqDig/VkJ0bfn3SlkwjlJNJ08AqRntmgh1gocTI0B4YAzD8Kr1q78us2Xpmr7LyFOl/o3qi5pRTqkXzo5yopOhpqZo0TqapJNkzFMjMBWErRd6IfBzafOK7I1BcpkleO2H6+4cP3ud3/6cRraHyHr8vhFI+eVO+5UQ41fiTE2qsuTtYa8lF2CCZ1d/6/6eBO5yUrMfwDoNqQ2o6trP/9hLqvGtJtLf5YLAYhaXNciSmoT3ymxtlnpVai02MFgwDSnLUgqswzxYSZ1jWMQKGhTq5pz1mDleltlKx71/7qjGQTIWIb/GzepFJLXx8DKGXzEdU7phWxgrojLgg6xOviJaGTEbkdl8q3/c/8v6QTz2ZptE6JxxCMR6MoYxdjQeCVM2jJp8yK1WkxDpSHlFf93Pqgu1shqZ2r7uTdZE/rvPMpX1HvQwZqzl18r8uaAHtQnnw7UjbRYytvtT/cbW2J6btyiYSIAsmE5vM3BEiFdzYZsLWQgs8xtfvBzR2w4bFociV0mhaF36DDI53z+REM1YJjLDunTSNCt9/psVBvFlJ2KDtmPxT57zZImPuFTbDUGJm5k2/1zQPWJq5tWSNmJfydADluhLJQXTGBsN48c2FsozjhUJbgKQ1KDb2nrwULCguBV+a+VsMruMhhY3KmZ7XEexv3XB65AEogDngaxBzpi5ba/GXIqLV8dOfrHC7Q8deDatwYk7gXG0J51u7p3RvKA/aqhG23I6zIbP5Foq+C3U+4B8FaUzSkKDq00qGc1csgqX1RnTNWESFFAJhsjO51XdrXOTfmjiynLqfXMhZOmwRTHb4yRajicej4i4ZzOmLzNHQ0avb3Srkz8Ax6JxbwmVNV1k8vZUQJzBJeaavE1xU6SqjPTag369C0l2m2DXI1Txk40nkgZYBFjgaKZcuIqAoTfnI+a6DwgXUXUgqy7WzIFy0VDxzfO7OEQ+Bt1ADLKfu4PbS7pqgbXb4hFrNe8+qPZ3H1WKTqBLDFKkd+RBuMeGrSn72lyXDQGIOMkUIzxgsuLhD6aXvSjU4rQLH0c2BVAfbaNIq23kIx3CE11n38oBEmziABfvQ2xyK7gjWHz6qkNxvvuS9rUmOiBgH6VP2CK+EOSHc6O8UpOez27XvbqT7ZY9EkEJX8toozjs1jL84PfRAgu0b3v968rSkaVtyAGkghk1QzcSdhmUFQ3mzMkpFned3KWNubOTZ4mRzvaR5dARCSmZfk3mqlJzT8+BmIh0bqqVDZf4GYJ1PhVz/lzvV87/hJZ9PnVWE8TBcwogPAtYteDntg7+rjJM9g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7312278e-67c5-491a-5dc4-08daf3ef58e7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:34.4387 (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: 04iuEA2OHlG57ilLNuKw/C+Ywv6BGmo070T6qTBWP1mmjRj4yu6nMeXptbW47wgMTYBQYY21OdErFd5mgnxTDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7549 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Felix (VSC9959) has a DEV_GMII:MM_CONFIG block composed of 2 registers (ENABLE_CONFIG and VERIF_CONFIG). Because the MAC Merge statistics and pMAC statistics are already in the Ocelot switch lib even if just Felix supports them, I'm adding support for the whole MAC Merge layer in the common Ocelot library too. There is an interrupt (shared with the PTP interrupt) which signals changes to the MM verification state. This is done because the preemptible traffic classes should be committed to hardware only once the verification procedure has declared the link partner of being capable of receiving preemptible frames. We implement ethtool getters and setters for the MAC Merge layer state. The "TX enabled" and "verify status" are taken from the IRQ handler, using a mutex to ensure serialized access. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new (v1 was written for enetc) drivers/net/dsa/ocelot/felix.c | 19 +++ drivers/net/dsa/ocelot/felix_vsc9959.c | 19 ++- drivers/net/ethernet/mscc/Makefile | 1 + drivers/net/ethernet/mscc/ocelot.c | 18 ++- drivers/net/ethernet/mscc/ocelot.h | 2 + drivers/net/ethernet/mscc/ocelot_mm.c | 213 +++++++++++++++++++++++++ include/soc/mscc/ocelot.h | 18 +++ include/soc/mscc/ocelot_dev.h | 23 +++ 8 files changed, 301 insertions(+), 12 deletions(-) create mode 100644 drivers/net/ethernet/mscc/ocelot_mm.c diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 09f839dc9e64..336ad7263042 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -2066,6 +2066,23 @@ static int felix_port_del_dscp_prio(struct dsa_switch *ds, int port, u8 dscp, return ocelot_port_del_dscp_prio(ocelot, port, dscp, prio); } +static void felix_get_mm(struct dsa_switch *ds, int port, + struct ethtool_mm_state *state) +{ + struct ocelot *ocelot = ds->priv; + + ocelot_port_get_mm(ocelot, port, state); +} + +static int felix_set_mm(struct dsa_switch *ds, int port, + struct ethtool_mm_cfg *cfg, + struct netlink_ext_ack *extack) +{ + struct ocelot *ocelot = ds->priv; + + return ocelot_port_set_mm(ocelot, port, cfg, extack); +} + static void felix_get_mm_stats(struct dsa_switch *ds, int port, struct ethtool_mm_stats *stats) { @@ -2081,6 +2098,8 @@ const struct dsa_switch_ops felix_switch_ops = { .setup = felix_setup, .teardown = felix_teardown, .set_ageing_time = felix_set_ageing_time, + .get_mm = felix_get_mm, + .set_mm = felix_set_mm, .get_mm_stats = felix_get_mm_stats, .get_stats64 = felix_get_stats64, .get_pause_stats = felix_get_pause_stats, diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 260d861c7072..e7020f9081f9 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -476,6 +477,9 @@ static const u32 vsc9959_dev_gmii_regmap[] = { REG(DEV_MAC_FC_MAC_LOW_CFG, 0x3c), REG(DEV_MAC_FC_MAC_HIGH_CFG, 0x40), REG(DEV_MAC_STICKY, 0x44), + REG(DEV_MM_ENABLE_CONFIG, 0x48), + REG(DEV_MM_VERIF_CONFIG, 0x4C), + REG(DEV_MM_STATUS, 0x50), REG_RESERVED(PCS1G_CFG), REG_RESERVED(PCS1G_MODE_CFG), REG_RESERVED(PCS1G_SD_CFG), @@ -2602,20 +2606,19 @@ static const struct felix_info felix_info_vsc9959 = { .tas_guard_bands_update = vsc9959_tas_guard_bands_update, }; +/* The INTB interrupt is shared between for PTP TX timestamp availability + * notification and MAC Merge status change on each port. + */ static irqreturn_t felix_irq_handler(int irq, void *data) { struct ocelot *ocelot = (struct ocelot *)data; - - /* The INTB interrupt is used for both PTP TX timestamp interrupt - * and preemption status change interrupt on each port. - * - * - Get txtstamp if have - * - TODO: handle preemption. Without handling it, driver may get - * interrupt storm. - */ + int port; ocelot_get_txtstamp(ocelot); + for (port = 0; port < ocelot->num_phys_ports; port++) + ocelot_port_mm_irq(ocelot, port); + return IRQ_HANDLED; } diff --git a/drivers/net/ethernet/mscc/Makefile b/drivers/net/ethernet/mscc/Makefile index 5d435a565d4c..16987b72dfc0 100644 --- a/drivers/net/ethernet/mscc/Makefile +++ b/drivers/net/ethernet/mscc/Makefile @@ -5,6 +5,7 @@ mscc_ocelot_switch_lib-y := \ ocelot_devlink.o \ ocelot_flower.o \ ocelot_io.o \ + ocelot_mm.o \ ocelot_police.o \ ocelot_ptp.o \ ocelot_stats.o \ diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index da56f9bfeaf0..c060b03f7e27 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2738,10 +2738,8 @@ int ocelot_init(struct ocelot *ocelot) return -ENOMEM; ret = ocelot_stats_init(ocelot); - if (ret) { - destroy_workqueue(ocelot->owq); - return ret; - } + if (ret) + goto err_stats_init; INIT_LIST_HEAD(&ocelot->multicast); INIT_LIST_HEAD(&ocelot->pgids); @@ -2756,6 +2754,12 @@ int ocelot_init(struct ocelot *ocelot) if (ocelot->ops->psfp_init) ocelot->ops->psfp_init(ocelot); + if (ocelot->mm_supported) { + ret = ocelot_mm_init(ocelot); + if (ret) + goto err_mm_init; + } + for (port = 0; port < ocelot->num_phys_ports; port++) { /* Clear all counters (5 groups) */ ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port) | @@ -2853,6 +2857,12 @@ int ocelot_init(struct ocelot *ocelot) ANA_CPUQ_8021_CFG, i); return 0; + +err_mm_init: + ocelot_stats_deinit(ocelot); +err_stats_init: + destroy_workqueue(ocelot->owq); + return ret; } EXPORT_SYMBOL(ocelot_init); diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index 70dbd9c4e512..e9a0179448bf 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -109,6 +109,8 @@ void ocelot_mirror_put(struct ocelot *ocelot); int ocelot_stats_init(struct ocelot *ocelot); void ocelot_stats_deinit(struct ocelot *ocelot); +int ocelot_mm_init(struct ocelot *ocelot); + extern struct notifier_block ocelot_netdevice_nb; extern struct notifier_block ocelot_switchdev_nb; extern struct notifier_block ocelot_switchdev_blocking_nb; diff --git a/drivers/net/ethernet/mscc/ocelot_mm.c b/drivers/net/ethernet/mscc/ocelot_mm.c new file mode 100644 index 000000000000..99c774f56aa8 --- /dev/null +++ b/drivers/net/ethernet/mscc/ocelot_mm.c @@ -0,0 +1,213 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Hardware library for MAC Merge Layer and Frame Preemption on TSN-capable + * switches (VSC9959) + * + * Copyright 2022 NXP + */ +#include +#include +#include +#include + +#include "ocelot.h" + +static const char * +mm_verify_state_to_string(enum ethtool_mm_verify_status state) +{ + switch (state) { + case ETHTOOL_MM_VERIFY_STATUS_INITIAL: + return "INITIAL"; + case ETHTOOL_MM_VERIFY_STATUS_VERIFYING: + return "VERIFYING"; + case ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED: + return "SUCCEEDED"; + case ETHTOOL_MM_VERIFY_STATUS_FAILED: + return "FAILED"; + case ETHTOOL_MM_VERIFY_STATUS_DISABLED: + return "DISABLED"; + default: + return "UNKNOWN"; + } +} + +static enum ethtool_mm_verify_status ocelot_mm_verify_status(u32 val) +{ + switch (DEV_MM_STAT_MM_STATUS_PRMPT_VERIFY_STATE_X(val)) { + case 0: + return ETHTOOL_MM_VERIFY_STATUS_INITIAL; + case 1: + return ETHTOOL_MM_VERIFY_STATUS_VERIFYING; + case 2: + return ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED; + case 3: + return ETHTOOL_MM_VERIFY_STATUS_FAILED; + case 4: + return ETHTOOL_MM_VERIFY_STATUS_DISABLED; + default: + return ETHTOOL_MM_VERIFY_STATUS_UNKNOWN; + } +} + +void ocelot_port_mm_irq(struct ocelot *ocelot, int port) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct ocelot_mm_state *mm = &ocelot->mm[port]; + enum ethtool_mm_verify_status verify_status; + u32 val; + + mutex_lock(&mm->lock); + + val = ocelot_port_readl(ocelot_port, DEV_MM_STATUS); + + verify_status = ocelot_mm_verify_status(val); + if (mm->verify_status != verify_status) { + dev_info(ocelot->dev, + "Port %d MAC Merge verification state %s\n", + port, mm_verify_state_to_string(verify_status)); + mm->verify_status = verify_status; + } + + if (val & DEV_MM_STAT_MM_STATUS_PRMPT_ACTIVE_STICKY) { + mm->tx_active = !!(val & DEV_MM_STAT_MM_STATUS_PRMPT_ACTIVE_STATUS); + + dev_info(ocelot->dev, "Port %d TX preemption %s\n", + port, mm->tx_active ? "active" : "inactive"); + } + + if (val & DEV_MM_STAT_MM_STATUS_UNEXP_RX_PFRM_STICKY) { + dev_err(ocelot->dev, + "Unexpected P-frame received on port %d while verification was unsuccessful or not yet verified\n", + port); + } + + if (val & DEV_MM_STAT_MM_STATUS_UNEXP_TX_PFRM_STICKY) { + dev_err(ocelot->dev, + "Unexpected P-frame requested to be transmitted on port %d while verification was unsuccessful or not yet verified, or MM_TX_ENA=0\n", + port); + } + + ocelot_port_writel(ocelot_port, val, DEV_MM_STATUS); + + mutex_unlock(&mm->lock); +} +EXPORT_SYMBOL_GPL(ocelot_port_mm_irq); + +int ocelot_port_set_mm(struct ocelot *ocelot, int port, + struct ethtool_mm_cfg *cfg, + struct netlink_ext_ack *extack) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + u32 mm_enable = 0, verify_disable = 0, add_frag_size; + struct ocelot_mm_state *mm; + int err; + + if (!ocelot->mm_supported) + return -EOPNOTSUPP; + + mm = &ocelot->mm[port]; + + err = ethtool_mm_add_frag_size_oct_to_std(cfg->add_frag_size, + &add_frag_size, + extack); + if (err) + return err; + + if (cfg->pmac_enabled) + mm_enable |= DEV_MM_CONFIG_ENABLE_CONFIG_MM_RX_ENA; + + if (cfg->tx_enabled) + mm_enable |= DEV_MM_CONFIG_ENABLE_CONFIG_MM_TX_ENA; + + if (!cfg->verify_enabled) + verify_disable = DEV_MM_CONFIG_VERIF_CONFIG_PRM_VERIFY_DIS; + + mutex_lock(&mm->lock); + + ocelot_port_rmwl(ocelot_port, mm_enable, + DEV_MM_CONFIG_ENABLE_CONFIG_MM_TX_ENA | + DEV_MM_CONFIG_ENABLE_CONFIG_MM_RX_ENA, + DEV_MM_ENABLE_CONFIG); + + ocelot_port_rmwl(ocelot_port, verify_disable | + DEV_MM_CONFIG_VERIF_CONFIG_PRM_VERIFY_TIME(cfg->verify_time), + DEV_MM_CONFIG_VERIF_CONFIG_PRM_VERIFY_DIS | + DEV_MM_CONFIG_VERIF_CONFIG_PRM_VERIFY_TIME_M, + DEV_MM_VERIF_CONFIG); + + ocelot_rmw_rix(ocelot, + QSYS_PREEMPTION_CFG_MM_ADD_FRAG_SIZE(cfg->add_frag_size), + QSYS_PREEMPTION_CFG_MM_ADD_FRAG_SIZE_M, + QSYS_PREEMPTION_CFG, + port); + + mutex_unlock(&mm->lock); + + return 0; +} +EXPORT_SYMBOL_GPL(ocelot_port_set_mm); + +void ocelot_port_get_mm(struct ocelot *ocelot, int port, + struct ethtool_mm_state *state) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct ocelot_mm_state *mm; + u32 val, add_frag_size; + + if (!ocelot->mm_supported) + return; + + mm = &ocelot->mm[port]; + + mutex_lock(&mm->lock); + + val = ocelot_port_readl(ocelot_port, DEV_MM_ENABLE_CONFIG); + state->pmac_enabled = !!(val & DEV_MM_CONFIG_ENABLE_CONFIG_MM_RX_ENA); + state->tx_enabled = !!(val & DEV_MM_CONFIG_ENABLE_CONFIG_MM_TX_ENA); + + val = ocelot_port_readl(ocelot_port, DEV_MM_VERIF_CONFIG); + state->verify_time = DEV_MM_CONFIG_VERIF_CONFIG_PRM_VERIFY_TIME_X(val); + state->max_verify_time = 128; + + val = ocelot_read_rix(ocelot, QSYS_PREEMPTION_CFG, port); + add_frag_size = QSYS_PREEMPTION_CFG_MM_ADD_FRAG_SIZE_X(val); + state->add_frag_size = ethtool_mm_add_frag_size_std_to_oct(add_frag_size); + + state->verify_status = mm->verify_status; + state->supported = ocelot->mm_supported; + state->tx_active = mm->tx_active; + + mutex_unlock(&mm->lock); +} +EXPORT_SYMBOL_GPL(ocelot_port_get_mm); + +int ocelot_mm_init(struct ocelot *ocelot) +{ + struct ocelot_port *ocelot_port; + struct ocelot_mm_state *mm; + int port; + + if (!ocelot->mm_supported) + return 0; + + ocelot->mm = devm_kcalloc(ocelot->dev, ocelot->num_phys_ports, + sizeof(*ocelot->mm), GFP_KERNEL); + if (!ocelot->mm) + return -ENOMEM; + + for (port = 0; port < ocelot->num_phys_ports; port++) { + u32 val; + + mm = &ocelot->mm[port]; + mutex_init(&mm->lock); + ocelot_port = ocelot->ports[port]; + + /* Update initial status variable for the + * verification state machine + */ + val = ocelot_port_readl(ocelot_port, DEV_MM_STATUS); + mm->verify_status = ocelot_mm_verify_status(val); + } + + return 0; +} diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 6de909d79896..81c4ff9a3405 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -515,6 +515,9 @@ enum ocelot_reg { DEV_MAC_FC_MAC_LOW_CFG, DEV_MAC_FC_MAC_HIGH_CFG, DEV_MAC_STICKY, + DEV_MM_ENABLE_CONFIG, + DEV_MM_VERIF_CONFIG, + DEV_MM_STATUS, PCS1G_CFG, PCS1G_MODE_CFG, PCS1G_SD_CFG, @@ -739,6 +742,12 @@ struct ocelot_mirror { int to; }; +struct ocelot_mm_state { + struct mutex lock; + enum ethtool_mm_verify_status verify_status; + bool tx_active; +}; + struct ocelot_port; struct ocelot_port { @@ -864,6 +873,8 @@ struct ocelot { spinlock_t ptp_clock_lock; struct ptp_pin_desc ptp_pins[OCELOT_PTP_PINS_NUM]; + struct ocelot_mm_state *mm; + struct ocelot_fdma *fdma; }; @@ -1122,6 +1133,13 @@ int ocelot_vcap_policer_add(struct ocelot *ocelot, u32 pol_ix, struct ocelot_policer *pol); int ocelot_vcap_policer_del(struct ocelot *ocelot, u32 pol_ix); +void ocelot_port_mm_irq(struct ocelot *ocelot, int port); +int ocelot_port_set_mm(struct ocelot *ocelot, int port, + struct ethtool_mm_cfg *cfg, + struct netlink_ext_ack *extack); +void ocelot_port_get_mm(struct ocelot *ocelot, int port, + struct ethtool_mm_state *state); + #if IS_ENABLED(CONFIG_BRIDGE_MRP) int ocelot_mrp_add(struct ocelot *ocelot, int port, const struct switchdev_obj_mrp *mrp); diff --git a/include/soc/mscc/ocelot_dev.h b/include/soc/mscc/ocelot_dev.h index 0c6021f02fee..fcf02baa76b2 100644 --- a/include/soc/mscc/ocelot_dev.h +++ b/include/soc/mscc/ocelot_dev.h @@ -93,6 +93,29 @@ #define DEV_MAC_STICKY_TX_FRM_LEN_OVR_STICKY BIT(1) #define DEV_MAC_STICKY_TX_ABORT_STICKY BIT(0) +#define DEV_MM_CONFIG_ENABLE_CONFIG_MM_RX_ENA BIT(0) +#define DEV_MM_CONFIG_ENABLE_CONFIG_MM_TX_ENA BIT(4) +#define DEV_MM_CONFIG_ENABLE_CONFIG_KEEP_S_AFTER_D BIT(8) + +#define DEV_MM_CONFIG_VERIF_CONFIG_PRM_VERIFY_DIS BIT(0) +#define DEV_MM_CONFIG_VERIF_CONFIG_PRM_VERIFY_TIME(x) (((x) << 4) & GENMASK(11, 4)) +#define DEV_MM_CONFIG_VERIF_CONFIG_PRM_VERIFY_TIME_M GENMASK(11, 4) +#define DEV_MM_CONFIG_VERIF_CONFIG_PRM_VERIFY_TIME_X(x) (((x) & GENMASK(11, 4)) >> 4) +#define DEV_MM_CONFIG_VERIF_CONFIG_VERIF_TIMER_UNITS(x) (((x) << 12) & GENMASK(13, 12)) +#define DEV_MM_CONFIG_VERIF_CONFIG_VERIF_TIMER_UNITS_M GENMASK(13, 12) +#define DEV_MM_CONFIG_VERIF_CONFIG_VERIF_TIMER_UNITS_X(x) (((x) & GENMASK(13, 12)) >> 12) + +#define DEV_MM_STAT_MM_STATUS_PRMPT_ACTIVE_STATUS BIT(0) +#define DEV_MM_STAT_MM_STATUS_PRMPT_ACTIVE_STICKY BIT(4) +#define DEV_MM_STAT_MM_STATUS_PRMPT_VERIFY_STATE(x) (((x) << 8) & GENMASK(10, 8)) +#define DEV_MM_STAT_MM_STATUS_PRMPT_VERIFY_STATE_M GENMASK(10, 8) +#define DEV_MM_STAT_MM_STATUS_PRMPT_VERIFY_STATE_X(x) (((x) & GENMASK(10, 8)) >> 8) +#define DEV_MM_STAT_MM_STATUS_UNEXP_RX_PFRM_STICKY BIT(12) +#define DEV_MM_STAT_MM_STATUS_UNEXP_TX_PFRM_STICKY BIT(16) +#define DEV_MM_STAT_MM_STATUS_MM_RX_FRAME_STATUS BIT(20) +#define DEV_MM_STAT_MM_STATUS_MM_TX_FRAME_STATUS BIT(24) +#define DEV_MM_STAT_MM_STATUS_MM_TX_PRMPT_STATUS BIT(28) + #define PCS1G_CFG_LINK_STATUS_TYPE BIT(4) #define PCS1G_CFG_AN_LINK_CTRL_ENA BIT(1) #define PCS1G_CFG_PCS_ENA BIT(0)