From patchwork Tue Jan 17 08:59:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104337 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 55C8FC3DA78 for ; Tue, 17 Jan 2023 09:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234106AbjAQJB5 (ORCPT ); Tue, 17 Jan 2023 04:01:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236176AbjAQJBZ (ORCPT ); Tue, 17 Jan 2023 04:01:25 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2081.outbound.protection.outlook.com [40.107.247.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 432DA2ED59; Tue, 17 Jan 2023 01:00:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HtSViqJjzdKyUAzcOnbgsQIWHuFuHojy1Q6sCbJ2jjflFuUg+0p1OJ/uQXZItHcFTHv0MJ+EeTP2A0ERvLLHffmPNFDcwIdgXCUrbtXOekboFu+mbcwn5tQPnUl2/TPLe+dRdyHn0dBkyuPI8Al0n+gQ6FQKdk8FurQOn1XVEKUmKYXezzLxIPUOjKA14maJqDSPz7ttUgqTZSvGVGJ1JUIYzwC8ojn1neqbuunIJcpfp3eLYsEni/VUkFC3ewBDZGp3sFO5QbXJ2VrwKc+e06Aehr/T2Ywv8G7kDsgKlNwokwAN/IN8xxikXBRYv5iWiQvAWKGjLlx99hLZYeJ8oA== 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=uJmd2lCj+WdnhRTPB8Dv9xjQZn/5spjmP2627kp/1zw=; b=D0LPSkXLJkq3wnQB6EjnX/FIgVzs4h90TxgKgzfSkXsgG4QyGZ7WLWF6t/4kgKvAllaeTjPJJOwAkOZ/aFAvNRZvRMq7KJnF+SRpl7ydEBdo5FO7os8YeloY5Dv0I+5JFlXxl5pcTErKJMs8qtEeaji/KfOt+hsAXkHeKw++DycWXfD/fMagV7UBm6LUbZ8EFpJYec+OwwAZFbPIP5AmK5zlIutG8x7SUdirNQwCrjpSG+QYLV6EUean+gbF2NOIYl6d/l4RJHNJ2eHn6IWgIJej+qNcc3fm+y3htT4tycwB2EzIm8y2mMWo1oOGfXiSu8VKHCGx9KgnLP7h8M9udA== 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=uJmd2lCj+WdnhRTPB8Dv9xjQZn/5spjmP2627kp/1zw=; b=k4BwBqDURB6vsMwLKqhhG0PKmjreX64ETaVNHRpIzJ3I2hfGFDX5+tapaHORcAo0/W4nwqEyJSruZtgbEqToB49B9ndphRD10TMEXJLPUsXl59kLV9Y6W28TW64pa43Ctw54F0eCXAQRfhNNTTDrr/gowxbv8qV6kFF7M1R0/LQ= 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 PAXPR04MB9304.eurprd04.prod.outlook.com (2603:10a6:102:2b6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Tue, 17 Jan 2023 09:00:00 +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.023; Tue, 17 Jan 2023 09:00:00 +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 v3 net-next 01/12] net: ethtool: netlink: introduce ethnl_update_bool() Date: Tue, 17 Jan 2023 10:59:36 +0200 Message-Id: <20230117085947.2176464-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9304:EE_ X-MS-Office365-Filtering-Correlation-Id: 60030366-33b7-4fe1-2650-08daf869369f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 33tA+yRvxOC1Cx3O3moT+ercUt9jgR8jgw3IBaxDAIYj2PDrMXoy5X5qbmDp+44DnLuQtwgCRYmATNTOSyARQtQFNIL4Qvzp2eYW4t0W3SQw275BRG1VdmNPs5N7Q3grJ3Y2DEScOOTvJjur6JF2CdSqJOsYl4SJVO6SCTT7lYhmbmayyScre/lhKgQ5ui6Ea4bYMamx4ZIS9ajTAUcWn6u4LE5r/Ecao6Esw1tKayR4UjBvpeMJ9CKMVF9f6yELV7hvz5B2so5kDEwPHAIRMiGXo1yiZcKU4QGR7Bo/Lz+nZmR/25ay8Gn4Y4HM7W03vahYA5BxvRDc+8SUKfT8oFmznPa1/rES0Bt2buDTYd9cfcp20aFxqh7iU+D3kGwXDpQJYDZoXyz5xqtvtLqyfv0wnVYOH0do/p1eY2E1HeqtyKLwpRlLo3EHxD/R7UnTpwwMAwQZkPOIZQVr/4MLCKpZdYNERXfsxTE7a67yrvjTgWP048fv0hRP3LR/qOOVJONOhwvDGwNh5K+8t5Dup6TuUPb3kIf4WGpNDCnOMTFP1+UZ1q9VciCAWaRK63IEtpXiby2s627G2lXY7A0TvYXKnMfApvgFP/yyGwrlriQw+fP72YjSuG5ucZY8YfHMInjQEOiaYwl+RvhMmjGZjuqCR+u7+BcYmmxo6wzQfa7iH7aCihgBrt8lAmB5NSendgRziN7aOWUXPgo22QBFRPls67XlqFSrKNajgP4WdOU= 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)(346002)(376002)(136003)(366004)(39860400002)(451199015)(6486002)(6512007)(478600001)(186003)(26005)(6666004)(52116002)(6506007)(66556008)(2616005)(66946007)(66476007)(316002)(54906003)(8676002)(6916009)(4326008)(36756003)(83380400001)(41300700001)(8936002)(44832011)(1076003)(2906002)(7416002)(38350700002)(38100700002)(5660300002)(86362001)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +N+Aj83vqoY8vpEWp/DVTOV7iMEKNtg5WTb/ae10d2aF9FH2qlc8CPMvAddYWoGKsiM2boM2EAuCHul8vidNScOeA0Bkdn9agINR8sLAUURcYxdhfTrXR3c+Rp9dv00jYwNhM4pMBed0M5XKaG2dvyckxfqDM7Cy7WqpIj624p3niZqECHy2trbh2AcJ3+hf0QqP9Zc9T4tXnNFWh+V3U6pMBsGOd/PUf8EvXRPzKin3CHyoVSzHgkmWsImzSYqzQhIamYH62iCGx68S29tBtZhShrmY9m0fAo/kLaaxtJNcZl0HrcXDhtEMH0xMUaoOMuWWQ79AGdYZGD4+SwFUumeCpCoiOpgfn1FQURJ0bDNITOH9GlPqBJXAH9TbL70XoaDUcoSAegK1JKmIATuZOhpILft6fCMZvOqulkxEJJ4BT5c5wmW8PD7OBVjDLoxyugr01X3NaEjnt4+TBPFsE8+0QG6I88ANPJR4EyuO0HctmkyMkq+id2cAG6wA0j5TTOvuejmVNIrPZEYS23TPVlK2xzGsQKs5+f55R9uwA/uGqDdJcNOg2eC1mWBKNQySoIKskv5Lr9KfvFn4Qb0qECulpSpLBm77wpZK8ZKPXAh6dnVTb9UqGVuO7VWnlsCrphbxx65SvunzBd9j7I2dIYZgJzlmZyRDSYzVcE5hBeIS1a6TwZziLn2EaZd0Ka0aeQRje3nTzK4Kqnu6MlQwS3j+5vPUk9hObyWCwT8sWLhflnmPmApFN7YtJTI01V3aaVKUknoDMo3DW3rfZ10CfyIeSpm3cWid5+0+oOW33zyDA1tyJxkBrDo/LnlBFjmoOC5R5fs+ToJ38/dq9oSTphurG3//+9Y+AhPrYrAP/ziqH4eakmceUl/NGbAbfwO+dBe0EW1Cs7uViXtO6D1IXWf+g++zpexmpStukaFPCkYSnhtVSYpAEM5bwqyDXb07/caNs/m015NbySstHgdvDXQPEAg0Xm4FZLKU2qrFgVjSLFi5swwEk0LTPBicUrlqcMXwVzcOrw2LpYrzUtBSnU+ySJlu+Co6W6ApagbSR+giP+rQsCS6i0+y0M9fM676dGrFIgKHr+WSZIhObENr66BWUAHxpHwAGfiZYKjIlqd+0pX3TmM7HqR01v0o422HFOOQAlwdZft1HKhaktXIjA4tgvEtJhk8bVEgu3j/LfwnafdOATLM33VfsJXIirssEi+B14eEITheOOq6vRY9ZjY5Vvmf8rjPt96TvIhJNga9ehe+0knzsmIOXseDQjyF2zeL/ATlo+7AGqVKXoZwBnapt1TdePrhGlO8tTUMmUe7LFaSaMIhd/3ixC7xkqkkqJaAeS2W9NYgX7Ur3q1RM5HHH0s/l3MPmaJydCojwtiJmj1ZAv73zLu30MnZxfpTl7fQRRY6NyFYjJ1yLK9+hkxdpcKzLldM4EcErBpPpEXLxUD7N9MOwjEHLCOlfH75IVRLrjksbazhtQccO09f6oHHkE5lkjxfGOOvJJAxkYgbYtrVsv7D+EerRITiuzSHydb9AdIOlOEovv6H8KO5dMUErU08OaJTaSqD7mBwRsX9gHFtjOvZYFobIRlK6OgBhL5o1Y/aJN5ObzjiVvH5aw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60030366-33b7-4fe1-2650-08daf869369f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:00.3781 (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: fMGMvovirdrUyOgbF7X4k9D4XYibNn2xBCAkrvSYnHctil9ZPKEsNFE6Yf0HCXo6popzdv6U9AV/zfBRPPFbEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9304 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 --- v2->v3: none 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 f271266f6e28..f675f62fe181 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -111,6 +111,32 @@ static inline void ethnl_update_u8(u8 *dst, const struct nlattr *attr, *mod = true; } +/** + * ethnl_update_bool() - update bool from NLA_U8 attribute + * @dst: value to update + * @attr: netlink attribute with new value or null + * @mod: pointer to bool for modification tracking + * + * Use the u8 value from NLA_U8 netlink attribute @attr to set bool variable + * pointed to by @dst to false (if zero) or 1 (if not); do nothing if @attr is + * null. Bool pointed to by @mod is set to true if this function changed the + * logical value of *dst, otherwise it is left as is. + */ +static inline void ethnl_update_bool(bool *dst, const struct nlattr *attr, + bool *mod) +{ + u8 val; + + if (!attr) + return; + val = !!nla_get_u8(attr); + if (*dst == val) + return; + + *dst = val; + *mod = true; +} + /** * ethnl_update_bool32() - update u32 used as bool from NLA_U8 attribute * @dst: value to update From patchwork Tue Jan 17 08:59:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104338 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 C6627C3DA78 for ; Tue, 17 Jan 2023 09:02:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236358AbjAQJCP (ORCPT ); Tue, 17 Jan 2023 04:02:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235952AbjAQJB0 (ORCPT ); Tue, 17 Jan 2023 04:01:26 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2081.outbound.protection.outlook.com [40.107.247.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67F101D921; Tue, 17 Jan 2023 01:00:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZNXzNiHcqTDMCN6xcPxqDLsAWs2g3TjK34kRjGw5JtJfMwpTwGlejj8Vh1LRGyWEP+E7AAfI4f0+GpaE5PLWkaTsXZc4xwWxRcB9B6pHTdqSLhb/0H8pDx0FPLRQ6UdQx4NznYm5Zgg3yjsVLa2yXl5/khdxNX7dyPSTKSWxU4r/Jd462OjGVZichiuNjJtIC7tlqSdAQyhykEvH6Vg7JxVR92BohptHZLe6BRcQLKIZYBGhqwLQdT9hEIo5PDYP008nYv98oKeYWAfSUyEq2iCBITmXLJ4G/0Hm1eYWpgRuuLm/Qdr6TM5U4hdc6XqcG5O7JTPe9K8PgZIPfttTYQ== 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=6a4OjJVov1G0Xlk+SOasc/WZ6jHKr0GhxWUc5fCHR1M=; b=hVARo+m4uo0X0OrErRg0mmmhLDJeyFphPJfiGcjE/cLM6a0eAZ9Org3eDfi4B/OjpKBNONlkqs01mUQ0P50rKBWRfRJEgUgkduUOuynG2y+h1Scd7Ma7NLjmnP+X2OsdqNw2KuMJJLIrFCT9dng2BakSkWS0liyUC6KFDRhPbMwnNMIUMRT71gWwYVZ5onu56ikfw8GZqIg5h/RCm0TBi31+KZZkM0/yUPeiNBBSSMfEeWKroxOEVwuXLCollKJ2uh+KnJupRzIY04Xkg62cmBOdrJgEzC3jKm1ValnNcDn5Rw+2FoJerKiza2kid6bfKJhwBpWNR25NvRjJOXFKEw== 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=6a4OjJVov1G0Xlk+SOasc/WZ6jHKr0GhxWUc5fCHR1M=; b=bfubTDLBLHbzvAxC7ene5bEMX8DVGlNSm5AHb3QQ5eVVAk91uv0UlemvZ/dp44++dmnWg0Y2rcNqPP3a4ZUzrL+kFnfxdDVqwL3uCTP1CqHsN0XHSTDZOI2T8Jp5TZdJqAwzv0PX5rzmhW7v/P9grK6DUBofJr9k7EmDQy4b4VM= 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 PAXPR04MB9304.eurprd04.prod.outlook.com (2603:10a6:102:2b6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Tue, 17 Jan 2023 09:00:02 +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.023; Tue, 17 Jan 2023 09:00:02 +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 v3 net-next 02/12] net: ethtool: add support for MAC Merge layer Date: Tue, 17 Jan 2023 10:59:37 +0200 Message-Id: <20230117085947.2176464-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9304:EE_ X-MS-Office365-Filtering-Correlation-Id: 856a09ca-6b10-4fb3-4ddf-08daf86937d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OPduEVe50KC+1c5S/rqLmKIqLsmXxmfWHLrlCEiLXNy7KwA7ARdgOwry996FQjRibQcFE+MhPwZxqVAU/AaAXAZB895iY20ssRF4F0VrlyFGdlL2DcDBSAHqrKDGLtLvA9w/ZwaqLoigEMBZ1ODPhL0elfjwrHJevjoP1mlP5yz7btwpwVOvYnNR9JaTbp1W/0rUsbPH1ADkZuvw7xsmvwfoWR2mF06HpP/4McE0nnaAm5tgbYk8ybQ95TTSeAkwczFYm0p480IzegZiwxIieOoGWaG86KM8YxU5lyo1OjFNQhWhtBeqI55tB723XARW5zaXGVpPEfhB2E6kO2nwgdMj7g7oqNuEf1mFPquZTLjZWJ+DJw+3z0LgRsQWr/sDkmNWw1llPSeuH5qMWotBOHcFMPSrSAedj94OCjx2Q6lwziu6C25pez9oQ3yCv0iqPKwvGvIMh9esGL7+imvwk1lJ24oYIOkEynK+kcP479XN/JhoCX8trLYaDIrjHroOXGhCrXjS7spjTTF9hgtbDK/U8DbIVKdA7KOo2JsgyoNfxQZN0mXQvPxEBLDbBw6iXKnkh+BUyCjhoUm5sVLYhR1k0qLDKU8Pva0jcPC+sdomrSnUXzc5kKK7jMnOw6oD1CjML0hKE7VqnETfAZ6F5YFZjIFAVFQ80I5A1iubuNCpRPVXlrBHgb+AuaNjCpcz+bWPQnLmX8IHfhjt/Z5GyAe9U4yEU2TKhWxkvgC+8Vo= 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)(346002)(376002)(136003)(366004)(39860400002)(451199015)(6486002)(6512007)(478600001)(66899015)(186003)(26005)(6666004)(52116002)(6506007)(66556008)(2616005)(66946007)(66476007)(316002)(54906003)(8676002)(6916009)(4326008)(36756003)(83380400001)(41300700001)(8936002)(44832011)(1076003)(2906002)(30864003)(7416002)(38350700002)(38100700002)(5660300002)(86362001)(134885004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qVbxA2A/PH2pfzDggobwv5WECk/dAzKzRd2S3vXaB9TaD/QwM4goxEHNHIrpQeCWK9Q4+5S11zvhjHoRceflQ+3OGroO0YidQCUQ5mY4hJDsjPJGZHc2gfuZ+Ccb9yGQazk1AEfO4bWJqTRB8YHmvVE9fKVNzOO66B+9+oZYidq/vphNr6FDk7HfZPzCx3PW+WSny1TgNcl2HlWhyqFYcDuKT/gSfT3Wh5C525ax2tnrzQZBln+gybtNi+ojHmHvu/rKDqE/SDFiJFKfNJwhnNqOu5GckNWY2IVvLR3Rjiy4GdX5vRI4dxG14CWgEhAztwiz9DUbmZq+p9JQ3wuZz6QJJIunu2PEaXa8Y6OmSh73rKhV5vs3AnNpDHtM599wrW5vk0aZ8XDN1Hxr0q1B+wEKBf75Gc5G3HZCqiaqjCNfKBx0khXmV+Jht1T63rUduXD9la7SAVrTybQPmVcZ+5aGXmta3sHRlAijlu5C/bQAF7dqZHQHALlVkDnQ7SnmyvBXh3RcoKtHYS5aENL4bfRnDLdqG4iww6QZILIroh0Dbk/a6mGqp2gIjJBR9zA1lmR1moR7Dfku5Uw0vZbUBVUxHNkHg/aJii7Uh/DwhXAEgLr5EN6RxI3vfcswqckS4qEtUsCVwGiNfqth1Ub9CW/gfgpq9RH3PYI3k9tpBKs5DbL7PVxFksy6LFINe8q4tytEvbWsGjLbDd8XX87RAQYicZN27jv5rcYikMCWucxl9FI7ohiWlmnqW8Jx/cjznZ/zqV3SiowekrzfguBdnbioRlFHTGufxMZwlX6cLaItwS0jr1F0pK6bryCP1RVvrG249exH5/ry+rwJ7fYEpqkrtrxrRpsCBtHRgWy7N1iJnzpuW9OpAwTxMoVc2UmbahSe4xJOXS5pVosGE9C/rEcaNPQ+a/lgDDaTjApNgJBsmEHkLZMbXISiKbDacq//dstoA+/4YN9UXiwNlTr+NURRob20AP0HqukwYWEECsOo90b+sZbfIk812NVlZ6LiYS2buy/gozBMAdFYoG38bmXZpje0Wz70SRpw472+hH4J5xPVhinjdjqRPi5qTDDsPkrBRI6mLq2KoMmXnWZXxpsB4s69+C3ek64RP6mwDC8Y7Q/p8XRf8tKL0mr6RE4Bq7o4iOE4SET6EiEAquuq/XFVnLr6BEi/rtpl0OEsdEaDfBRNMpfafkJ8pvlZem76bfHw4HVZXsZkBn5AtgXypxeYHbGrubUf6ZZqgazIg442vtvCVN4vW0GrMpts+/EfvrEbiElwD3421FM+P/bJpFZb3YrSDuM8W4iSG3ECQQFBE8DLThOJBh913Z78xucsMg13NDyA1hbGGRGYJnR/3fcyBjf8xx53ojTahjqoqIs5M5IcICty8tneqBpzj2B/7xTBcJDxgMVlBx0qGcpkQTIq2pfsCWy//mL/Ggv8Sb+Z1xg3JA2oJ4QuEfrvHp5Q3hJBab2TGynQ5IQKJolkIDfpBn2ucWo9S8SFMv6obp6I3qKmJKQc9i8NMykQyWXlVSEF/xTIGOLch9CnGcgtyAExQZRETvVDn4cvtTFe3Mr2R+c+HMM9KmZjLGqdA4AlEYk/CRNdQm6V1d1XRO8mVA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 856a09ca-6b10-4fb3-4ddf-08daf86937d0 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:02.1124 (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: rsAywcfcT4cKJj7L9Fe0tfUEbjCWjuK1IIuXXtgs9ujCNupAOpdxLofKdgVmjb98sHBKq8WCfOOgfc0rWTQw1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9304 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. - ETHTOOL_A_MM_TX_MIN_FRAG_SIZE: the standard managed object is called aMACMergeAddFragSize, and expresses the "additional" fragment size (on top of ETH_ZLEN), whereas this expresses the absolute value of the fragment size. - ETHTOOL_A_MM_RX_MIN_FRAG_SIZE: there doesn't appear to exist a managed object mandated by the standard, but user space clearly needs to know what is the minimum supported fragment size of our local receiver, since LLDP must advertise a value no lower than that. Signed-off-by: Vladimir Oltean --- v2->v3: - deleted ETHTOOL_A_MM_SUPPORTED (to be deduced from return value of ETHTOOL_MSG_MM_GET) - made get_mm return int instead of void - renamed "add_frag_size" to "tx_min_frag_size" - added "rx_min_frag_size" as a read-only netlink attribute - rebase on top of PLCA changes 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 | 255 +++++++++++++++++++++++++++ net/ethtool/netlink.c | 19 ++ net/ethtool/netlink.h | 4 + 7 files changed, 451 insertions(+), 2 deletions(-) create mode 100644 net/ethtool/mm.c diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 20d197693d34..37eba38da502 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -477,6 +477,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) + * @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. + * @tx_min_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. + * @rx_min_frag_size: + * the minimum size of non-final mPacket fragments that this device + * supports receiving, expressed in octets. + */ +struct ethtool_mm_state { + u32 verify_time; + u32 max_verify_time; + enum ethtool_mm_verify_status verify_status; + bool tx_enabled; + bool tx_active; + bool pmac_enabled; + bool verify_enabled; + u32 tx_min_frag_size; + u32 rx_min_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 + * @tx_min_frag_size: see struct ethtool_mm_state + */ +struct ethtool_mm_cfg { + u32 verify_time; + bool verify_enabled; + bool tx_enabled; + bool pmac_enabled; + u32 tx_min_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 @@ -649,6 +741,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 @@ -787,6 +882,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); + int (*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 6389953c32cf..529a93696ab6 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 83557cae0b87..58af390823b0 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -55,6 +55,8 @@ enum { ETHTOOL_MSG_PLCA_GET_CFG, ETHTOOL_MSG_PLCA_SET_CFG, ETHTOOL_MSG_PLCA_GET_STATUS, + ETHTOOL_MSG_MM_GET, + ETHTOOL_MSG_MM_SET, /* add new constants above here */ __ETHTOOL_MSG_USER_CNT, @@ -105,6 +107,8 @@ enum { ETHTOOL_MSG_PLCA_GET_CFG_REPLY, ETHTOOL_MSG_PLCA_GET_STATUS_REPLY, ETHTOOL_MSG_PLCA_NTF, + ETHTOOL_MSG_MM_GET_REPLY, + ETHTOOL_MSG_MM_NTF, /* add new constants above here */ __ETHTOOL_MSG_KERNEL_CNT, @@ -922,6 +926,49 @@ enum { ETHTOOL_A_PLCA_MAX = (__ETHTOOL_A_PLCA_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_PMAC_ENABLED, /* u8 */ + ETHTOOL_A_MM_TX_ENABLED, /* u8 */ + ETHTOOL_A_MM_TX_ACTIVE, /* u8 */ + ETHTOOL_A_MM_TX_MIN_FRAG_SIZE, /* u32 */ + ETHTOOL_A_MM_RX_MIN_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 563864c1bf5a..504f954a1b28 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 plca.o + tunnels.o fec.o eeprom.o stats.o phc_vclocks.o mm.o \ + module.o pse-pd.o plca.o mm.o diff --git a/net/ethtool/mm.c b/net/ethtool/mm.c new file mode 100644 index 000000000000..0c8135393c14 --- /dev/null +++ b/net/ethtool/mm.c @@ -0,0 +1,255 @@ +// 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; + + ret = ops->get_mm(dev, &data->state); + if (ret) + goto out_complete; + + if (ops->get_mm_stats && (req_base->flags & ETHTOOL_FLAG_STATS)) + ops->get_mm_stats(dev, &data->stats); + +out_complete: + ethnl_ops_complete(dev); + + return 0; +} + +static int mm_reply_size(const struct ethnl_req_info *req_base, + const struct ethnl_reply_data *reply_base) +{ + int len = 0; + + len += nla_total_size(sizeof(u8)); /* _MM_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_TX_MIN_FRAG_SIZE */ + len += nla_total_size(sizeof(u32)); /* _MM_RX_MIN_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_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_TX_MIN_FRAG_SIZE, state->tx_min_frag_size) || + nla_put_u32(skb, ETHTOOL_A_MM_RX_MIN_FRAG_SIZE, state->rx_min_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_TX_MIN_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->tx_min_frag_size = state->tx_min_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_put; + } + + rtnl_lock(); + ret = ethnl_ops_begin(dev); + if (ret < 0) + goto out_rtnl_unlock; + + ret = ops->get_mm(dev, &state); + if (ret) + goto out_complete; + + mm_state_to_cfg(&state, &cfg); + + if (cfg.verify_time > state.max_verify_time) { + NL_SET_ERR_MSG_ATTR(extack, tb[ETHTOOL_A_MM_VERIFY_TIME], + "verifyTime exceeds device maximum"); + ret = -ERANGE; + goto out_complete; + } + + 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.tx_min_frag_size, + tb[ETHTOOL_A_MM_TX_MIN_FRAG_SIZE], &mod); + + if (!mod) + goto out_complete; + + ret = ops->set_mm(dev, &cfg, extack); + if (ret) + goto out_complete; + + ethtool_notify(dev, ETHTOOL_MSG_MM_NTF, NULL); + +out_complete: + ethnl_ops_complete(dev); +out_rtnl_unlock: + rtnl_unlock(); +out_dev_put: + ethnl_parse_header_dev_put(&req_info); + return ret; +} diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 9f924875bba9..6412c4dc663d 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -290,6 +290,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_RSS_GET] = ðnl_rss_request_ops, [ETHTOOL_MSG_PLCA_GET_CFG] = ðnl_plca_cfg_request_ops, [ETHTOOL_MSG_PLCA_GET_STATUS] = ðnl_plca_status_request_ops, + [ETHTOOL_MSG_MM_GET] = ðnl_mm_request_ops, }; static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb) @@ -606,6 +607,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = { [ETHTOOL_MSG_FEC_NTF] = ðnl_fec_request_ops, [ETHTOOL_MSG_MODULE_NTF] = ðnl_module_request_ops, [ETHTOOL_MSG_PLCA_NTF] = ðnl_plca_cfg_request_ops, + [ETHTOOL_MSG_MM_NTF] = ðnl_mm_request_ops, }; /* default notification handler */ @@ -700,6 +702,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { [ETHTOOL_MSG_FEC_NTF] = ethnl_default_notify, [ETHTOOL_MSG_MODULE_NTF] = ethnl_default_notify, [ETHTOOL_MSG_PLCA_NTF] = ethnl_default_notify, + [ETHTOOL_MSG_MM_NTF] = ethnl_default_notify, }; void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data) @@ -1076,6 +1079,22 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_plca_get_status_policy, .maxattr = ARRAY_SIZE(ethnl_plca_get_status_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 f675f62fe181..60278485b00b 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -375,6 +375,7 @@ 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_plca_cfg_request_ops; extern const struct ethnl_request_ops ethnl_plca_status_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]; @@ -419,6 +420,8 @@ extern const struct nla_policy ethnl_rss_get_policy[ETHTOOL_A_RSS_CONTEXT + 1]; extern const struct nla_policy ethnl_plca_get_cfg_policy[ETHTOOL_A_PLCA_HEADER + 1]; extern const struct nla_policy ethnl_plca_set_cfg_policy[ETHTOOL_A_PLCA_MAX + 1]; extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER + 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); @@ -440,6 +443,7 @@ 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_plca_cfg(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 Tue Jan 17 08:59:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104354 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 D7171C3DA78 for ; Tue, 17 Jan 2023 09:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235963AbjAQJDZ (ORCPT ); Tue, 17 Jan 2023 04:03:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235986AbjAQJB2 (ORCPT ); Tue, 17 Jan 2023 04:01:28 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2081.outbound.protection.outlook.com [40.107.247.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01933301A5; Tue, 17 Jan 2023 01:00:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cLaOqZIWGHpEwn5uuowZTdvj9tUP/twnZo7kjtMawGurw7BiO+ozk1UUUdbG+1n97YV+FBitG1V/h4QO0OBx5PULe4pCGr1I24hoDH+jG9fvEXEKNj/H6efEdmHJGVqoWpvv9Vd65huqzSMLsMAN6MIws+gIGDwOUdzLwANvrLk5a7ZOcZyNE/0dXTyUoO5+GmWFa8aZhTDqCWEv9Ksq6zcSG52JsTLYhh8zlIzrFzwliMiXiKo23sWyQbJB2iTlpb72fA9eNlF0ZCNNDdHcBMFx4RuF4nn3Ypvf4j3kXIwJGrnWZU0Yv9wM+sfqlnGmaVZVYtvd1HsdSKsKOA4wKw== 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=CHxLwuUqBuXH013xgu0M6un9FR7oCkd6yEnY9NF5pc4=; b=nXeeZ7UeQawDbHiR+wvn2Y4iV0Sqtuyv36bleFuhsbZF6C/C41YuywwP7NT/iK4X9zNn9SK3cZBtAS3O3uAtkHJQPdauDgBuHIGy9c9ytWwVR61PHFISaqf4ROQ98mqwaY0rt73q9TCZWCi7wDH761Qp8jq9HaHFz6ebwS3bJ9CSdC3dVJ7spIzcUr1JC00GVoSO2KDHmER/2ZY2HxfbaLm/7mXeCjH316cCMjnlqJ/cROjJB+twBXk00BDt70Kgt5gd01SLfIoOsMihVzShwPodNLODiWC6ujptdniozgyRvR8Ale+dOl5ok+iCFnikAQzOG/OPMSdykZYyw28ZuA== 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=CHxLwuUqBuXH013xgu0M6un9FR7oCkd6yEnY9NF5pc4=; b=RCEDQGSr2hPR4GXoY8AKqZb2Qr4jXVSa+yKLnlU5qR1CJ2uMsIHPt4dK5pv7B5jTR7ey4hGboaHGBSLP4c9rJn/TgbcoqvVBQoe1sKtDZEOGccRsapJcODrQ/vwYf8U7jU0utQpcE7SWSzHmAG3LXJkUDPAKgmjHaaTUthd/OcA= 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 PAXPR04MB9304.eurprd04.prod.outlook.com (2603:10a6:102:2b6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Tue, 17 Jan 2023 09:00:03 +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.023; Tue, 17 Jan 2023 09:00:03 +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 v3 net-next 03/12] docs: ethtool-netlink: document interface for MAC Merge layer Date: Tue, 17 Jan 2023 10:59:38 +0200 Message-Id: <20230117085947.2176464-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9304:EE_ X-MS-Office365-Filtering-Correlation-Id: a1449309-91b6-46df-a042-08daf86938ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q8RQXJ+Ai8/5u9t8ZY+6A7O4fIPKdWSk+ItiZ53tx69w9+kMzaSoBzHVanj5A6c5nE4aDQVQI1yRysfcWr6T/rNXuDt36Tq/r80roEYquhSDu4iGOe9IWGJlUl+xZcp/aEHELGS1vmXR8XEBEn6+8FLK6ONOLNY5hpd8vydyeBtmqafTUwOzMW6wO9RkH8j4aWXtHkpUt6lzXwmKdsSpnhl5Pa7F/7Lr9qkiEmxF2VcS7n1xYrNVEokzCtbQA4ff0rC67KVX3GI2R8CZbXYLxyLNxkNOVt5hBtiSosKFD9OoamQxCKK8pfIBPA/ufeEjcSZjkHBYf9Wf0adbH/KNKEhjhD9oqQ2OvRWISR5f+KFoE5xCiIB5Vq/fZ3aRDBVvZ+Qi8EJ/1DMGcZsT9FrjV+gDtTxb25+uVSJE92zXcs5TcpT7e96p5pjRMj9L+Y1SZycxnwbSDjR68sBn4hfor3r1tEXDnjflydydfwA0HSiBKg9LFAFBPzT3uUf/fQwI9M6pu++BRfLJ3cWJLMLNEfwMC80/cFwJSryrTB5pdgXqRwDtLlrdCZCQHYDyXCC36uoUTVPVgCX1QWW4PEVOC+IiN7UyfXKlwahGJ8NzQ1NJLUPdBTNDz3SAQgQyIy//YRTM5KwGm1rwCZZ7VgYvLGlRbJmKDiqfM9A1FkGSWEwv3kbmNvzdlQKyQDecbkOPJtKQfWGw+W8L+IQE0I+5pQ== 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)(346002)(376002)(136003)(366004)(39860400002)(451199015)(6486002)(6512007)(478600001)(186003)(26005)(6666004)(52116002)(6506007)(66556008)(2616005)(66946007)(66476007)(316002)(54906003)(8676002)(6916009)(4326008)(36756003)(83380400001)(41300700001)(8936002)(44832011)(1076003)(2906002)(7416002)(38350700002)(38100700002)(5660300002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N7uJp7BLOBh6+vnocTh7Ig15MKDoLdjLJHWMYJoKgadbHXH600owiRCmlX4atQTlIxNbnJJCAhS2uH1g01EqIBPukyP7wQGe2NCL3nFeFJLHrCndvj9MRLoolEqQdMoAS+zwRxGM770ouh0iZo+Dr/WOQaRVc3grgthf/2FfUmwdQ5h8hYuyJGF68kghrXulV9vIY/2Y/Fp/dlTQe8DsLq+G+EbrRWCZl2reDdkmioQcXtvvBQocfLujtBoeJ6EnAbgavdwnKH00PyR0VdQDldHxs+ADSLJ6r4q/6RWZq0gDkR6x2pvt53EPqmp+rFNpNek+FIecvFBpxLOZoj0D1ee4dnFUz8bz1xcZhSzH2W9OOaX4Yn87OywqtUy5co9lele7gLUU1MP9G+Yt9GZOJqiL11xNmYFkt2RFtvFvq5XWrFQy71hKKrJydeIkyUKrRyF8H8jupTTb5iHstwV2cPMeY72AeXc0+xABrqsUafPDLmTLmRIceX8QTohejy/eze51nvBA3LjCwfyejUfEQdsK08v2eu3L4u7Xd6Ok6pDh2BEjdhxNjXB5uMEfHjp0owP53Fwmc36dOA4ZpbFPUxNOl6pELmh6ERkV98S4IfzI5GmDpFPZeKOh8HAhM5aDCLKP0CLtyG5XbFMsE1eCxLGAtj9LgTiyHjzgTkdJrPvuolLVWoilDAHwSaVDPkipdPkiMj7gjGL4IpiRITfY7MdVJaX+UWiRX/FBnlJsiXT2nRQ1o4hN4SDOZb6NL9mRKuOWLg3dQfqMVWupCGfTixL/gN1LHSlOouqcSVYim4+mnl+6pVi9rGo5bGJhx4ABajeYYu5EcbjvI6T9ODG77gdvtObm1rJE/camAVFTvuLuU9HBaXVwr/teBYOd7YcL8vW3GqwQMXx8QMj22vKZvqJVqyJoz6fhH/NRdI0+zGt2Ryf6F0hqzuR8pMxpl1/TujK6t/nrc8jtn6aX21aEZ9/XIvGgh6t2TaQDp69yayKpXjn02aSP4Aum09BXMpFfoYI3okwJU+x4VoVWIdPgerIMl3w+X6HudXzdBsIEaGdEbJteGsXLhW3AB4m+k870z+EyYz79EC8aJNqz76/tvLkv1nk5vJrAFN3mTi9zaHvOpdiWmNCMp5V/uwU3Ioj/Nd8hFEmXJ0Ipa+mjZg0/TLJ7bl1OFz/8yEIISBSaSWPIK4bqVc9Rjd5ugqcT32uAFKA5g5Tjg0aB6ZSxgVkf/ZbZQLst3LUuv6Lgim0+6MXGSypSDyz/XozIx9sS3HwY1bkqxBRHC+CLC4r/MhlqBxjxC1hSQWB/zK2jxp1cTnOxdlIDCdZzh/GXvClnDxMs1/DCCZDlisg9UfJWMZ0qR2IUlGi/OeW+D34BbgGdnYK3NvzquaEetdRsNMHEE0XL5QV0UoTPAxXlyf7uC8fQHePKQFR1c1XbLHkud7i7/FxFPrdSmLf1YyyHFsgI7Dw4Wai2CGLx0QVUCdpJoLf9fuQpHqSVi7xHwmOHwalRGjaOLuTZ7Z5r1FCC/0knWFRxzBGgJnCaS7lso9XKS1voiotzgbmauXWrbQK8AsrTmv3I7fym8gZerI+4qrJ4mZN9mO9o1g7JoLvIT6GQ3sOYYQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1449309-91b6-46df-a042-08daf86938ca X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:03.6748 (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: jq3A3KFPygPuuh7/J56VcG0pSLvYXHjAT02WnOJju3gmXeG/xmep7QePaXh6+MNghAPSAx08sr/R9RmuC0TH4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9304 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 --- v2->v3: - reformat tables - delete obsolete netlink attributes and document new ones v1->v2: patch is new Documentation/networking/ethtool-netlink.rst | 89 ++++++++++++++++++++ Documentation/networking/statistics.rst | 1 + 2 files changed, 90 insertions(+) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index d345f5df248e..31413535dce5 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 @@ -1868,6 +1871,90 @@ When set, the ``ETHTOOL_A_PLCA_STATUS`` attribute indicates whether the node is detecting the presence of the BEACON on the network. This flag is corresponding to ``IEEE 802.3cg-2019`` 30.16.1.1.2 aPLCAStatus. +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_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_TX_MIN_FRAG_SIZE`` u32 minimum size of transmitted + non-final fragments, in octets + ``ETHTOOL_A_MM_RX_MIN_FRAG_SIZE`` u32 minimum size of received non-final + fragments, in octets + ``ETHTOOL_A_MM_VERIFY_ENABLED`` bool set if TX of SMD-V frames is + administratively enabled + ``ETHTOOL_A_MM_VERIFY_STATUS`` u8 state of the verification function + ``ETHTOOL_A_MM_VERIFY_TIME`` u32 delay between verification attempts + ``ETHTOOL_A_MM_MAX_VERIFY_TIME``` u32 maximum verification interval + supported by device + ``ETHTOOL_A_MM_STATS`` nested IEEE 802.3-2018 subclause 30.14.1 + oMACMergeEntity statistics counters + ================================= ====== =================================== + +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_TX_MIN_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 =================== @@ -1972,4 +2059,6 @@ are netlink only. n/a ``ETHTOOL_MSG_PLCA_GET_CFG`` n/a ``ETHTOOL_MSG_PLCA_SET_CFG`` n/a ``ETHTOOL_MSG_PLCA_GET_STATUS`` + 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 Tue Jan 17 08:59:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104357 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 E0AE5C3DA78 for ; Tue, 17 Jan 2023 09:03:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236052AbjAQJDw (ORCPT ); Tue, 17 Jan 2023 04:03:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236255AbjAQJBj (ORCPT ); Tue, 17 Jan 2023 04:01:39 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2081.outbound.protection.outlook.com [40.107.247.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4B0F301B5; Tue, 17 Jan 2023 01:00:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ewFLE8bdyEzY4b2Re1GlwC7fituSIyRAfLGRBAhmbSPgHIjaIYJ6HlhtGnRE9zJXOseM6ggB6AKjRVSD0PEbBNbqy90mxa4t1WzV09NbXf0n9PEUIHLaq3gF7ugPNGpDCL6XXxQ66uBpDBkOlGmTZr6OniZ/Kvbgjki2HNkxZ2K9Ycxge9iTHQWgD5iaHQIjkX1MprtQteJuQOJxTeUYDxyCRqCJPTdfB0AaOuVGnKjPl9nkp/xzIf0yPcgAJQaHyRwj0ZSSLE3+4Tw46fabcnumXJTxkLA19PAddDigk0SZagmXtJ/3EJjkAk1S2x8D0C+gW8ynfFwh567oGzaPNg== 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=lMDtLQuOffeccLqPYxopIR24k8NAAQdgQ96Shio/Uaw=; b=ZwUtCCM2LBLDnpB5qS1ffqN6yRFCFFcjqyE6rPnyLWzBU9/qVZyRzZqNgT4X2v86Oj20Dwfu8GFoNo8YpE5hiSfMV+IXjb1aVeVpfwd1qOStx0w4EH4PzCMG0TJR3SNAem7x/0liQzqBr5AoHpEUUcwojwN2oJdnNk4F7q/7+6imErctNi6eqD6gCxzoP9J/nqKA3Ato2WqauTMcOda8jLF63Fbb1p59HmaABbQjJWgZLQ/PcUANNoqwuQGQeOAw2nZCkzdB/xxLRNrULufJNUZxa8fKNPO7O00lmfFEJXg2SXSL2mMU2TORt4dz5R1vRzNGysAt4PtviG7V6L5RBg== 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=lMDtLQuOffeccLqPYxopIR24k8NAAQdgQ96Shio/Uaw=; b=R644fVtUfewph7+DNi3yxWhWiRkbP/HH/9baHJ+3MWE5DlKfvMcbBkALmrSqINcYYdGEouK90tKR49HZbN39fCAz5eUnY6wt6cMzajedJimB2BVtGTRI6+Cuzcg+barQcSx3Vv9yaAJeYz+LVr7ZFkCtYc3ZUJN21Zuh9nMmzmk= 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 PAXPR04MB9304.eurprd04.prod.outlook.com (2603:10a6:102:2b6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Tue, 17 Jan 2023 09:00:05 +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.023; Tue, 17 Jan 2023 09:00:05 +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 v3 net-next 04/12] net: ethtool: netlink: retrieve stats from multiple sources (eMAC, pMAC) Date: Tue, 17 Jan 2023 10:59:39 +0200 Message-Id: <20230117085947.2176464-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9304:EE_ X-MS-Office365-Filtering-Correlation-Id: 171dc6c6-1093-463a-1999-08daf86939cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yx3wecUg1P4fdXOUMPp0WLKPZ8meatW452Y1kcB4ueREBnLzd/TCY5w+8+uSVvj8dfQWbcfqnG43XhF+3fkYLljCUGpZrTDPeIja1g8Cu/8OQUpAk29Kbw98gj47cg+8XKoqZgj8BVZZ78KcuoRNs83UWedgVFs4+m6e9WrhepBTVyHv780ML6Vv6LRh7rb1woxc6wyPJw8eTVhTGo8lO2Ak9jRkGV4hP+iZGEbADTmeoCAEo1NC1EUn5BSI+d+xilMfh5CgKX0Un2mBegwkR1HVimtKC7x5KA+KuB35tjLKTf9NgUC/+W3avQnVKC9EbNQbiyB0nn0CW+kZKzwhkVX+Ra/ZlTaTFkInjrt7OHUriBg3c0lREUcz25LrmQxTNsbIl326lHJRxNLhW0cNErXYD2PxzyHNcK5eA95fHGbPLo6OcSgOxZBsuSOaKXPDOHTxYOQon0JCZLQyuJv+fCJLwTKxRcskgAnw9fTMEwD+tqoF497lyQdElZmW4zqRraZnsXfv9b5iWY8oVOSqLdXl+Pb2gvqiNx0hQHXnUBGwNn7HK2PWhyInWuGiHXdcrTOjdIFRUp6dII4xzjChbMM53y1G6jlyS0buwsdGXRbaIopYxXT4CJSkH8BXd0GtjmQLVykcTnnxiNrhcHsPKx7t7c0QvEjlsxx++qfP8dg8zb1UJUHcpAPNj0IR3OYNk/vvtIBh9BxCWO5atjH7ci+TuHmN9o3uPejS5fYPOgXzi2a7xx3g8JXqcuvUWsjc 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)(346002)(376002)(136003)(366004)(39860400002)(451199015)(6486002)(6512007)(478600001)(186003)(26005)(6666004)(52116002)(6506007)(66556008)(2616005)(66946007)(66476007)(316002)(54906003)(8676002)(6916009)(4326008)(36756003)(83380400001)(41300700001)(8936002)(44832011)(1076003)(2906002)(30864003)(7416002)(38350700002)(38100700002)(5660300002)(86362001)(309714004)(134885004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EHGN278sfhuRj3i3Rj0hdpcvLQsaYAPSPuZZ7xfBdWX0RcnN7khEJtXXueeo2bECtVHtzZ1oY//F+nbjwEUf+zPGRjjs8HPYiJwpRheUp+oRjLfKHJQWSrlw6jePGBjjq0jDqjMGuuVq3QLJ3OfGwTUF/P9gXSlKECEhe/VytU4zpyjc/rFSfyVxg3AZicq04HAwREOPSbXVuKCugAouJU3xxmN4I3TyYYk5Xlaufa0TmKZGapkkBCRz7wVOu9PPagcn0YPDN32DXp24rvqLHsaaiqIExvtT62a5HD7zl8pFewOwwGqmIuroQ6Cpm3nN9jECJTCi8nJbreT9fO7S7vlfOcEZCH/iRFnaQDAe+k/2ZGMqn5QEP+qIruSTl8DIQ/boOv9/5C6Lm3ccVmtBLsiY5AYB5rJL0Ih9sZreKIym1gK2Rydu+hdzTAIXL//34OrS6VWMR9/oyoCJsnZ/UgAhK+1M0lswJJRDTmf6ujQifSWxKhGGt6szeZdj3amdtI0plEIOO07zSo06/ZQpx86YtW+9ujFNjCDlpvrFarfQ9GLpztZhpvgredN4GUpGs5d9QnYWzWMrdvuVMr1WiEVCF2Yw8sbrsddcZ3ZqT/mK4WoPH/LOwIPzkttIMihp+e0nA7sAjL4YolH4oxRY+KT1Ax2eWYs7+RZwumRwoxRwEZ6CJvZHobAsXBwSBgvgsNZ4fQnVRNPeSf9lIhiFhHpxAamdIlhaZgEyWxlAUPJwS1CtS4Q0NMqAB7bOpO6Dbnbg+Rt+coqEsnG5M0nORRf/oqdVSkusbh4cdOTkGb2kAPo5pMYp0JIvoYhxMAvY4oefE1fAVoHEfHbcknOQBPi/AKQdTXtxl8JbMxoEYrqpjjkz0RHwkszAW75VKfmGM5aOUHZkdj/AoE8H4u/iY2hOW6X+Ho5OJF26fV0GjUr4WQxOT31PG6M7qi/ZQ46TQmzSoWxql1ZVfkO1IOokx3hUIU9futd7K6mmYXMPOtXxT4MtS35vNcCWe0RRPYybsJJQqDyahq7haRgteygbj5UmDWkDsAbwcZ9vKlltqOIr/1srL+FMGPgEOeqcxPLXfEeJw+LCCaVjuVICkJJJQcg8+wV8tqsAs0E/gH330EWzcUx9obaSlxuKj2O4GOQmdvoMfoSfsRImawxbqR7HOXs7vmPuHU7SF6XnYyQwGY4hznjz7LZDXHK8xY7FiKIJu3k2aPgHvp0nIXRTDoPCayzO6puB/eyi461qVP0qiyV/0G5Sx/s2Vy/jbTeaLaS4wNAH0qsog3L1Y8sZh0HKS00Ff58UofYjQsOWSU+oB9hr2XpjM7SyB4RGxhETKm+rB/tUDhU8qxiwvYs/cY/5kMprImfyPTKtB0pBdXjrCH73o4P5omdo4HBQ1LoHAqK82Q+X/F7cpAq7yFREubJ33Ax3Lf+NbJ3t3pOw/SH1plb9LkChkbwgKSPLvZ0uhnhllWslVanlEyZAaR2rDtc/g8zCgjwM2364FFBx8d3m+isfnNpiMvk2Vmpj7lPrLZzAMhNxze4/brgUrpiZ5MNC8SvGKjCDEA30qYE78JFVXEwseA7TWHoDnWwXcRckf/K3FEL6gS3UVzcZIzW/9ho3NA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 171dc6c6-1093-463a-1999-08daf86939cc X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:05.4090 (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: Te/9koRfNgjPi8nJBrAGX/hN0Xr7yFYzMuXFwK6epMItlgBRvfW2+agMF1jTNsterbDvce4go4LH0kp0FPpx3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9304 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_mac_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 --- v2->v3: - rename enum ethtool_stats_src to enum ethtool_mac_stats_src - rename ETHTOOL_STATS_SRC_* to ETHTOOL_MAC_STATS_SRC_* - change how __ethtool_dev_mm_supported() is implemented 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 | 16 ++++++++++ net/ethtool/netlink.h | 4 +-- net/ethtool/pause.c | 48 ++++++++++++++++++++++++++++ net/ethtool/stats.c | 32 ++++++++++++++++++- 8 files changed, 129 insertions(+), 3 deletions(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 37eba38da502..0ccba6612190 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -311,6 +311,7 @@ static inline void ethtool_stats_init(u64 *stats, unsigned int n) * via a more targeted API. */ struct ethtool_eth_mac_stats { + enum ethtool_mac_stats_src src; u64 FramesTransmittedOK; u64 SingleCollisionFrames; u64 MultipleCollisionFrames; @@ -339,6 +340,7 @@ struct ethtool_eth_mac_stats { * via a more targeted API. */ struct ethtool_eth_phy_stats { + enum ethtool_mac_stats_src src; u64 SymbolErrorDuringCarrier; }; @@ -346,6 +348,7 @@ struct ethtool_eth_phy_stats { * via a more targeted API. */ struct ethtool_eth_ctrl_stats { + enum ethtool_mac_stats_src src; u64 MACControlFramesTransmitted; u64 MACControlFramesReceived; u64 UnsupportedOpcodesReceived; @@ -353,6 +356,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. * @@ -366,6 +371,7 @@ struct ethtool_eth_ctrl_stats { * from the standard. */ struct ethtool_pause_stats { + enum ethtool_mac_stats_src src; u64 tx_pause_frames; u64 rx_pause_frames; }; @@ -417,6 +423,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. @@ -432,6 +440,7 @@ struct ethtool_rmon_hist_range { * ranges is left to the driver. */ struct ethtool_rmon_stats { + enum ethtool_mac_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 529a93696ab6..f7fba0dc87e5 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_mac_stats_src - source of ethtool MAC statistics + * @ETHTOOL_MAC_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_MAC_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_MAC_STATS_SRC_PMAC: + * if device supports a MM layer, this retrieves the pMAC statistics. + */ +enum ethtool_mac_stats_src { + ETHTOOL_MAC_STATS_SRC_AGGREGATE, + ETHTOOL_MAC_STATS_SRC_EMAC, + ETHTOOL_MAC_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 58af390823b0..ffb073c0dbb4 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -428,6 +428,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, @@ -744,6 +745,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 0c8135393c14..7ebc4e82e83d 100644 --- a/net/ethtool/mm.c +++ b/net/ethtool/mm.c @@ -253,3 +253,19 @@ int ethnl_set_mm(struct sk_buff *skb, struct genl_info *info) ethnl_parse_header_dev_put(&req_info); 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 = {}; + int ret = -EOPNOTSUPP; + + if (ops && ops->get_mm) + ret = ops->get_mm(dev, &state); + + return !!ret; +} diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 60278485b00b..29aef39476eb 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -399,7 +399,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]; @@ -410,7 +410,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..e2be9e89c9d9 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_mac_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_MAC_STATS_SRC_PMAC), }; +static int pause_parse_request(struct ethnl_req_info *req_base, + struct nlattr **tb, + struct netlink_ext_ack *extack) +{ + enum ethtool_mac_stats_src src = ETHTOOL_MAC_STATS_SRC_AGGREGATE; + struct pause_req_info *req_info = PAUSE_REQINFO(req_base); + + 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); + enum ethtool_mac_stats_src src = req_info->src; + struct netlink_ext_ack *extack = info->extack; struct net_device *dev = reply_base->dev; int ret; @@ -34,14 +65,26 @@ 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_MAC_STATS_SRC_EMAC || + src == ETHTOOL_MAC_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 +99,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 +121,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 +168,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..26a70320e01d 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_mac_stats_src src; }; #define STATS_REQINFO(__req_base) \ @@ -75,16 +76,19 @@ 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_MAC_STATS_SRC_PMAC), }; static int stats_parse_request(struct ethnl_req_info *req_base, struct nlattr **tb, struct netlink_ext_ack *extack) { + enum ethtool_mac_stats_src src = ETHTOOL_MAC_STATS_SRC_AGGREGATE; struct stats_req_info *req_info = STATS_REQINFO(req_base); 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); + enum ethtool_mac_stats_src src = req_info->src; + struct netlink_ext_ack *extack = info->extack; struct net_device *dev = reply_base->dev; int ret; @@ -116,11 +127,25 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base, if (ret < 0) return ret; + if ((src == ETHTOOL_MAC_STATS_SRC_EMAC || + src == ETHTOOL_MAC_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); @@ -146,6 +171,8 @@ static int stats_reply_size(const struct ethnl_req_info *req_base, unsigned int n_grps = 0, n_stats = 0; int len = 0; + len += nla_total_size(sizeof(u32)); /* _STATS_SRC */ + if (test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask)) { n_stats += sizeof(struct ethtool_eth_phy_stats) / sizeof(u64); n_grps++; @@ -379,6 +406,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 Tue Jan 17 08:59:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104355 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 D9C5EC6379F for ; Tue, 17 Jan 2023 09:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235916AbjAQJDr (ORCPT ); Tue, 17 Jan 2023 04:03:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235975AbjAQJB3 (ORCPT ); Tue, 17 Jan 2023 04:01:29 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2042.outbound.protection.outlook.com [40.107.8.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 115592313C; Tue, 17 Jan 2023 01:00:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NbwC/ayUUdCssRl76NQpoDpBXF8/HyisfRdeu36c7tUayuWJU5fKt2aNfScPTWpuwYm/NBHoftIeNtKUiUi8+gbiH6wp7PdlUas1/C3S9ewIMU7yAIi8INH+37QWdJZxwQZzya7W3CI/D2T7eAWPSaCxMPCmd8g1fRBBSi7JwRICs3h4KBWdFfdBNp5Yws4NsJd1ToCcnPMFWhgwKfchdJekd/L6gHgHxxtDtyaAUBdqv2oYmD3WRscb8fxow6Wws3wKollRVKUiT3ylSYS8+meBxU11UluVlIckIU155d9Ppai6i5YQORxWt7N8/59AmyxtCX5ECduTSldCiNGqDw== 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=upH1joA+5/L2/D4IJOUrmNnEzTo9jfQgvYrtCG15Ros=; b=K5roGUJU3JzT4HEoi3b23nPMtkffuk8Tk3KjhgRxXc7WcGAEoFbs5nkP6kNMWo+YhHTzMLmHrfLOtma5t1ik1MlSoK3qwHFHmN/NEb+XukRSKMlN20JkTEx8aNuueHQUCnpVVYUGeDygkKDbAzj355ZwPOEH8pDdTjF5ywzZDRnHq0fDrhMRZHXetchzgHXxK9qlvI6EHvEymd8rsiKd+H3/VNbCYrKG9mkuoLwFEt3Uz7ZVQF3qBiqKgGeoYefSTUZUiNTv5icDWrCTQwaV+OnnZp4D55F7LJNoQ8ipxZZefWn23YoDkEybYB1cbFl4BjAn+ysX8CbvUDwBdR+FmA== 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=upH1joA+5/L2/D4IJOUrmNnEzTo9jfQgvYrtCG15Ros=; b=F62EnQ5VVnrp41Xkx9PFgK1y7nVCXji1VmTEUo3KGFjQd4yyiRzFxBrJfxfZpeR5CweQVO+38xlLJLadrM75E3bEe4oJTb1ocF12V/dX2PDeDlXNQrhEMIm6IvQfj/jPmShLqo0mLdPil903r8U2LPj6CN1bdVvfil8dU83NNvE= 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 GV1PR04MB9182.eurprd04.prod.outlook.com (2603:10a6:150:26::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Tue, 17 Jan 2023 09:00:07 +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.023; Tue, 17 Jan 2023 09:00:07 +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 v3 net-next 05/12] docs: ethtool: document ETHTOOL_A_STATS_SRC and ETHTOOL_A_PAUSE_STATS_SRC Date: Tue, 17 Jan 2023 10:59:40 +0200 Message-Id: <20230117085947.2176464-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|GV1PR04MB9182:EE_ X-MS-Office365-Filtering-Correlation-Id: 95b3f9f8-df05-4a4a-598a-08daf8693ab3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I5jLonPxaj17ecRTSPW2GX0rEmre2NjgwBq7p0rkpykJL14IXsNkhGxoBXGdU66Ajyt7TmcIaxPBuZZIADDS6ye9+qkSKU1hqTRGJwZYsCiKso9mIwK89A5IQ2VR1UK+HBUKOxYW5VThvfJD+pJIakCbuH2p1rLg+Wkd5AlEzgcAW96GXGHXrdHxtSyhJnKOfeourVEvK+m8D8/yqZ0efEGEsyYamXmfAEJWyI2BGH+o2+iGx7lRRjfbBpQ+myLzsAJJJwVaJ2k3gxuWQwe88ME1o5F5JE+brpzQ5o3BSqFrWJL3tLIFki+ONxBrUJBeoiRMkmkdnFtRsbrWwylDqPLEfpW+8iscFnLvm1ZpV+2mUpjEwZbPpr2H+K3ctf3VtXrw4ZnwS1lcW/8ik8Sro8zt7bFrveQ3nBB8juV9yn3kw06mxrxtYgFG2ubIEJs9w2ziEn2nR+Cmy08I5ApMDQQllNXlP02ji98bIFwQgKyV1aoBzcGv60Xmz6UjsIJomMmpoi5dsADUG8V2OU2AwqRf8VMP0oU5ulVZkJJJKPWq8m/MQ5TlB0jZqQ16XlfNGrR8OXbIRLYuCniRjY1Eid5LM/hjyALvGQhp6WXSMhPrJ8s/29HTZN8j9rxieVlqXp1J/6Ns3SOJN4cO8WPfmgIs7IAvp6bpMjsVQ52wb9l+JvQgoy2H4Id8xgtgTvEL/EGjNUEDg8N135ejiZyMZA== 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)(136003)(376002)(39860400002)(396003)(366004)(346002)(451199015)(52116002)(26005)(6512007)(186003)(478600001)(6486002)(66556008)(66476007)(316002)(19627235002)(1076003)(6666004)(54906003)(66946007)(2616005)(8676002)(6506007)(6916009)(4326008)(38350700002)(8936002)(38100700002)(5660300002)(7416002)(41300700001)(83380400001)(44832011)(86362001)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FF/ot5cTjQV5DwBfxP8Tl0hQWZh6jh9A5VEx+aMy98biQ9I1uF4AfylzA+KxM3AfhMhMa1rTrWShQqvTrc6YJYxn5u8zNoqlBhn6qC6EvDExM1N+ts3Oxx0MaloGVUjn2lG60xYTvZ36dlxfvhLEOwtqc2GwZ3YUC6VMmh9C6gsv78uGLmoLQUbZf5FajcJlFLTwPxvIPAJ12EmL2bhH66D4YPGLgVaBeIRfmllK9CxChPS54eYGjsga9zIA1dNh+iSASwtJXXuBOrKu8nptk+so18xQtOuEi6NstfcMuG1a5BFP9wUmV+ngNR3UXQtkR/DSLTFG1gwu/5i9tJzpFW3nJuaxV6AyzG+841vUCHGTDDAicFIECUxx/IvFT1OrhexMaYVy3K6PtC+g3MGKp3c1n+doNzWpHfVOuf+46sqwyXJBayYGnvrVZkculSz3nJHXYCPo9nP8oSnOQzBaFhGjLwj0jPcUA+s1xG92sSNjq3v+ZtlhBRaQF9jrMS0iuAgrkzL4+0dcAKKHNBgm9CPPl3lxjFtMpV7ucCEMk1gjt59J9ZKbdp1tsBP+2dGYUUe5g5aeo5Yw0uM9aax3pW0XDSM8cW+ozp0N169a2EvA27KXFpgpL61T4QgnwKYxsf54qlQO0fJWTmOyycs6R58L7Pmafj/EA47SD2PWgJy7JLw8r7zEprEpElEhszsU3hw68k/9GZvF1yJLSiieoeJX3XB+r/9jMGZ7ALv2pxNXK32ybau3rV3WDxzqKmGfOvO+YGOP6/heKFGhadL5WTBPeBMc0xNtc/VrFwlnkhy9nbM/UjjF/ULHcY/Pp7+SJMLbb+gWKlBOhAB5zKWMYrkrLhhTvj2oXlbG06nHy3DxMMOL5iLE+coCUinB9atVb/10QAwvi0COkw4sk9T//RKCTkXsIXNJ/X8CJJCQ5sulHu1SOYVmSPDMtQz9CLnUefKkMJoyZCE4Rv2X0/mM4Ut49VQNhodgzsqOZIJiwhq+v6aL0EeAQv7fHT9V5m9d7rFbdY1fdtXzTPVvdj3wyGOzd6E9vGJPl2096za99eH9vjdxWlPsCHfGKBLYSJLa/uCHMmoDXf6llMrPjphCfebx+DWhbTsDfqyoB5YOwhm4X+5QRPdyFxM3+2fVMJAe9NbyCi7Czz5olwn7AyyjI3qf5CFB8BKwPi5l/etLh3f7kCuuUzijoa4hF9caExdyyNrXFjzs1tg90ts8SWSfx6F+pd3pXbHSOWXCMuPLe65mUH4wdjZMOBSq7C1Lj/hPLz9DHuomTpxokovNgx5wQuKuqHJnnexPsWw0pRTWoXCugvxAc/cBn7IWAdpj1WAAjkdhZqdPOzZxTSgKWY4a8ZY2OUvBLuhXhZpDBQA+Np2YVsSYRt9n1lY5XWBXCrTQi/azU7IyHga7k3Q8A4oj7ijszOXSLEPugrXFcC8xSW5SyFKHg537IwkTsEABh6w0+9ej+X+ejAsYvp7eqzfTfICyE+jokH30glJNRAvOR45LOM+lixu8gWwpt+4y8iyZsX/UNT7qmgUnydyxn4c1K/mw0uhy+ytJQXklmWVeSTpOE4w/GmyUVq3igVkQOm8y1/2E6L8/63ijxWbYQ0ERkQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95b3f9f8-df05-4a4a-598a-08daf8693ab3 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:06.8777 (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: 2FS9NKXTenZIX4WxNL+WGI80oBSl9C4KMWiWk3U5ZTY2GWELfTHdbdbslY7MbZStIrVxB6aGkpVpQ6dl7XAhwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9182 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 --- v2->v3: - adapt to renaming of constants - add a single kernel-doc reference to enum ethtool_mac_stats_src (second one gives warning apparently) v1->v2: patch is new Documentation/networking/ethtool-netlink.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index 31413535dce5..1626e863eec9 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -1092,8 +1092,18 @@ Request contents: ===================================== ====== ========================== ``ETHTOOL_A_PAUSE_HEADER`` nested request header + ``ETHTOOL_A_PAUSE_STATS_SRC`` u32 source of statistics ===================================== ====== ========================== +``ETHTOOL_A_PAUSE_STATS_SRC`` is optional. It takes values from: + +.. kernel-doc:: include/uapi/linux/ethtool.h + :identifiers: ethtool_mac_stats_src + +If absent from the request, stats will be provided with +an ``ETHTOOL_A_PAUSE_STATS_SRC`` attribute in the response equal to +``ETHTOOL_MAC_STATS_SRC_AGGREGATE``. + Kernel response contents: ===================================== ====== ========================== @@ -1508,6 +1518,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 ======================================= ====== ========================== @@ -1516,6 +1527,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_*`` | @@ -1577,6 +1590,11 @@ Low and high bounds are inclusive, for example: etherStatsPkts512to1023Octets 512 1023 ============================= ==== ==== +``ETHTOOL_A_STATS_SRC`` is optional. Similar to ``PAUSE_GET``, it takes values +from ``enum ethtool_mac_stats_src``. If absent from the request, stats will be +provided with an ``ETHTOOL_A_STATS_SRC`` attribute in the response equal to +``ETHTOOL_MAC_STATS_SRC_AGGREGATE``. + PHC_VCLOCKS_GET =============== From patchwork Tue Jan 17 08:59:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104356 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 51CA6C3DA78 for ; Tue, 17 Jan 2023 09:03:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235964AbjAQJDt (ORCPT ); Tue, 17 Jan 2023 04:03:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236163AbjAQJBj (ORCPT ); Tue, 17 Jan 2023 04:01:39 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2042.outbound.protection.outlook.com [40.107.8.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6F82301BD; Tue, 17 Jan 2023 01:00:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m4kmA4ppbE48RY20pir9rqom6TXte7e0OcLcSZ4j+yeKeogakHhGycsyrPiFN9IoEThczOPJ0fQCl8PxlYJ7jCotyhSSpoPkayoJUZgUmzJ/Ml4Lmjm6PLs4GtlQfVWRI45T6VCBdR7hEjD+Ot9yawelvGEwUnb6deROnWe/9H7FlV87AWqi9rosrN00E+QdXhXIcxAjvMfSsfuvGQrk0/ZFKHdWkbfmRMZpTiTpMzWxBl+hT9IhiwOEPG8WPB5JudqA/26SoBT477iQy7AhooPxmwHCGQk//jh4vxR9ZLtY/+VlR44nbrhMfUx5JsYGAvKgG/4cpTeqTgEYCX5rrA== 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=bs1ZF1mDEJBOdkygmSCDgG8eD2RKbuq8AxAGx4w4ZPk=; b=gVkD/WVVYxmsv/H+eNDX4CBkNe+5CvKrXK3xrae96BtcoBWl6MKgGKaT5KQiVgJ1Icfzn4c2UXtRt/20KKv0lELs50xaJiPMmMA8XjF0gqxL2FkPuhFqV2OHtD1yHRurImihbVXln4oQcV1GeSIFj3yFbXG7ffC0LCnelvGxKy5Z1QrtScPHpDh6XplxxGJ1bNpnRF30Lkq2ZRORT2xpmTkVzGP8rOtwxBA+ridQO9Jlvadpkj7ws8NjoGpmWnWylKw4C3OGHAlmQslnQY9UBZ6jfLgfOBTJoFNahUI33Zkjlh/asu496hNxaevG+s93bam94NGddtGl/tOzPNG7DQ== 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=bs1ZF1mDEJBOdkygmSCDgG8eD2RKbuq8AxAGx4w4ZPk=; b=RNjtl7vGTfYJ+olpipV3uMD7C6Tcyf79xwNjHGiUVIdFa4v2WBK6eCgGXVZwIonFzDmpUR0fxXrisX8H5klcwwBW78dOUiqNMnKBzviLviw6NvzcLrhBMP6sM1r6cJ6nFoRZkq8TxPgx2TPihivxsMtAM2hA94WgbQpfLaYLd3o= 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 GV1PR04MB9182.eurprd04.prod.outlook.com (2603:10a6:150:26::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Tue, 17 Jan 2023 09:00:08 +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.023; Tue, 17 Jan 2023 09:00:08 +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 v3 net-next 06/12] net: ethtool: add helpers for aggregate statistics Date: Tue, 17 Jan 2023 10:59:41 +0200 Message-Id: <20230117085947.2176464-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|GV1PR04MB9182:EE_ X-MS-Office365-Filtering-Correlation-Id: 0acb89ad-de18-4eef-998d-08daf8693b9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: frOJ92ggop1Dg3tW2CxAgXINYYoBDPVRv+wY9DQsK8AR1OdUbmAmZy1SKZFANfcNlO8S1O716p0IGlDA1aXhPjQVGWnPXi9VTqM3DiU8eiFqI5MHN3K8CehUdRF9L5Vi6SzhINheNlmgQm6c9wjMsZ611TSP1sSWaWZRh52eaB5iwa0z/F1bdXfzjnimMqY7fad6ECwOEgEt56mov0ARTEyXaQGQnnnMBkNRW0J+YlTqQX/sDHPkI691a6ApuVn70m3MFxlfkBUcRlCPp2av4HDIGZKYw/rL1DOATqL2u2MYpvVjVHj9suBm/TcvBnNeRbF26niRMtEfQvzBLJhKqHcoqJhQZgiShGiqN9BK4HinkT9Yz288fC8AVvQ7TAcnsn7HJIhdPdBoK9D7hvgV9+pCLjkq/lKMj6F1hIXwHfgi8cH5zCvhB3j3zm5uA76gwLWY1qs3F341nR65nwJDzorMlxb4A1QYdfhR7HSvW+WogYc6PtyvMxD0l47u1WNAy1fhltJxxqFSm6hvCtLCR8yjdqi3bAmWXwYx78xqMM1SqBd3FJNXSOHTM9qbjh7acQ1IwzcZgLhrwqIKtvjWTevaEGPdOUacFqbgxrF1Iab/78NoZ0aKaF3RKXjIiUr3qpSECu/zcfTnx+u3b9eTGWXdGx7GgvTH0eFOheTI0HpHbDM+CvOePtvKUD2IoCHA 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)(136003)(376002)(39860400002)(396003)(366004)(346002)(451199015)(52116002)(26005)(6512007)(186003)(478600001)(6486002)(66556008)(66476007)(316002)(1076003)(6666004)(54906003)(66946007)(2616005)(8676002)(6506007)(6916009)(4326008)(38350700002)(8936002)(38100700002)(5660300002)(7416002)(41300700001)(83380400001)(44832011)(86362001)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vhFYfnFQU2TCDgcU7WAe5An0LFXGda9svLoUg1ALQXpxdU+1pksZNaCt3SZDH8FZ3V3mET41jnYDyWjqft0TTufIKM8NCzQKXBiW3CY3HUfPi75N5AWhdKUu6gYzvy/fqK+FHPttx5bbUl6IFJrM7ijxXwbJ3fjqvBGKLaPYj8EaVFOZAjB/SQXQemJl47OLmi0MCk+WHWPMHS3mkhfPhtyoenusIna6nYi7LKLbFlUz0yp/V50jwaeyuGkoHEgziemdrgGrOzFhWr5MYUQnN5M6j/6d7Of29M6kc1HaATmnINkkYziG0t1kVt4bIfYT7cGezKKePidsmV61IizLjGnw1Kh1e41njcgX/pSmM6qRwnm59ty3wvEnsI75lPsC31WNbaAUy4k5G7I9zvqHUjeODJA9nyWH9brzVCWzhxJLPfu80Ivec4ou+/Ftnhu7ytIdqnoGBCyuOzjU0kzhRrLO/jSMpSfWKHabHTEpdiPOEMizQF742e8zorYKTU2D60N1ughmpHYIyQbSOD0YKU2ku61Hkdk9xwYXxY2R3FkIcIGh/EyQCztnaQRyWq5EM4Bzc/+Y8RyN5vegHgjiPcXyb1tJbZPASIWQpN0xr0gENgrbMF8+l6MMh17qvk++K2VsKMG5dFnn+s1HMUNTEkcZAsoOuKFxfCLWcJkAB+gkgB6AnlEuFwyLdLmpFCR/FhwOFJXd+HX/TYzEjSsp/RYXIHkXdMv6QRibJmevciwaQ8GkhBeBTcceFmU1yVrLxoDVN0xt476TZ2rBPYJ+fhZPdBKZ4WGN11VZSMwNeumhfsDiRoa9+i2VYbct2o+9NVwiC8xXlVOhGgs401cRkfOJrdPXzz5hROshG3yC+92bj9bpxQd5zEntJWpDDUA/VkzGj5QyuTEvD5TA9pyInrbl4SFlUKncZbSC+5jGokKV+gpB+TR1JIkLLxykpioTwvOoL10EXmRlaB6RGoSLFxhlsTiSLJjBt8oV9n0f5Y/pCe0iPiHIlcFd0rLjKP2waXSqO6CDb44OI2LFOoMXRgUmPV+DtEYglHZ/ffGbTgrSI+1kBgbRuVIQd2MbSEFjVFVx2nV3e9Gdd4IYw5LNEdWXpGaliaHcdF7kYbIIaM5jowvsaR/V5mKeo5CUwWwDcGstAVxmPfbYWfiNyRpOecxhzksQQ+ze6YTS++aX88RwiE3W3GVN3+j61e0yn56IPe3MimfwCYv5IW+iRat+NjokQwynhb92fI8iaE4mqLuSKHvO7logRY1ou8dyY6NjelJdPXtuoHS57QKPE76EKY+Ls/A0x33RHOKkumn6/9rWFDQQF2q4gtV8Vbu8enmmNlej8sWDrVkKr1/QgRcf1owZa0tKh0ePSApLl7GozbGYUPRjlgQsL7BuAG95m0F0rdmbPUEsGJiWiye9xA9i8hxGbd3R/HJnsqEVHQNCc8xry72ndy143SRryAwaMpRsCRx4CDjc0IwuV57rDBzxJMAwOdkjP1+n1F9z6wswMi+ahu3+YHjQ4Drb+9O/dcL6MqaOf4kjI5lqiDsds3AEmnCejf+PfnvtUtPiSa2QHPJtc+2GSydSilJOvtNChd50aW/qj97LYgl3Q5dtMAGKzQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0acb89ad-de18-4eef-998d-08daf8693b9a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:08.4244 (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: gCa/tEZ22+bmg9aRLACjvVyKzoiot+61yYOklLShN17TmVo0UZbxTiDOmpGV5PX4vrZDEDGDsgZerKOuwzeCmA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9182 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 --- v2->v3: adapt to ETHTOOL_STATS_SRC_* renaming 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 0ccba6612190..6746dee5a3fd 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; @@ -312,28 +307,30 @@ static inline void ethtool_stats_init(u64 *stats, unsigned int n) */ struct ethtool_eth_mac_stats { enum ethtool_mac_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 @@ -341,7 +338,9 @@ struct ethtool_eth_mac_stats { */ struct ethtool_eth_phy_stats { enum ethtool_mac_stats_src src; - u64 SymbolErrorDuringCarrier; + struct_group(stats, + u64 SymbolErrorDuringCarrier; + ); }; /* Basic IEEE 802.3 MAC Ctrl statistics (30.3.3.*), not otherwise exposed @@ -349,9 +348,11 @@ struct ethtool_eth_phy_stats { */ struct ethtool_eth_ctrl_stats { enum ethtool_mac_stats_src src; - u64 MACControlFramesTransmitted; - u64 MACControlFramesReceived; - u64 UnsupportedOpcodesReceived; + struct_group(stats, + u64 MACControlFramesTransmitted; + u64 MACControlFramesReceived; + u64 UnsupportedOpcodesReceived; + ); }; /** @@ -372,8 +373,10 @@ struct ethtool_eth_ctrl_stats { */ struct ethtool_pause_stats { enum ethtool_mac_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 @@ -441,13 +444,15 @@ struct ethtool_rmon_hist_range { */ struct ethtool_rmon_stats { enum ethtool_mac_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 @@ -981,6 +986,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 26a70320e01d..7294be5855d4 100644 --- a/net/ethtool/stats.c +++ b/net/ethtool/stats.c @@ -440,3 +440,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_MAC_STATS_SRC_EMAC; + pmac.src = ETHTOOL_MAC_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_MAC_STATS_SRC_EMAC; + pmac.src = ETHTOOL_MAC_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_MAC_STATS_SRC_EMAC; + pmac.src = ETHTOOL_MAC_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_MAC_STATS_SRC_EMAC; + pmac.src = ETHTOOL_MAC_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_MAC_STATS_SRC_EMAC; + pmac.src = ETHTOOL_MAC_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 Tue Jan 17 08:59:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104358 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 636AAC3DA78 for ; Tue, 17 Jan 2023 09:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236082AbjAQJD4 (ORCPT ); Tue, 17 Jan 2023 04:03:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236103AbjAQJBk (ORCPT ); Tue, 17 Jan 2023 04:01:40 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2042.outbound.protection.outlook.com [40.107.8.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B83430295; Tue, 17 Jan 2023 01:00:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bGwxojH5TuyyKAmQkcF9U1V+QHOk3Na5/iWgsQjWCnTl5ASak3hmZd39Eib9yMsBk66uB03joazcEewNRjZFgFDRc0AfBw2CrxvotItSqI4/VJFYbWup4x1CZrLiHSEtWN8tuia97ioiM1nUzaE6okdSaSRR4XV4iEhm0EgsNQeWaQu/p4NgO96fiWiNmxk8/u30d6MHvb5eP+s5oBz0MpLIDd1j+oE5u1w6qkOh1XrKIeBEIfqRY05NNsibR5qb4P/V1t1yg+QBH07GKcsNu75oCGPDowrFS6Tk7D7r2PC/aO0OulVbQFnMo/A0yiuq4JXdVbsb04d7pAAxzw8KOQ== 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=VrhFs7Gp7ZYt6fsRqG6usv/p25wO3m2Pu8TOq6E/dzA=; b=aIsizc8FalCYTGuOLeTCEaBwb4J7iLCFhY2ShUWwy2/jeBQEF9sqr5rUh1Il+8NrgcybppwYVPX3gkkzEacKAChyolcZL5N7A0iBOTn22ky5T4bT/Q515tEgsy03LLdeCkPW19Uf3lKBFDEB3QFkgby5AKSkkIFzFbvxyq2sytUdWa11qcU0wC1LAMRAQfdR7RWodmk91RFwCStNNK/C6Fw8SpIu6I4g4mdG7Bsgs4rlYbmkifnRP4IGlUYq1SqUu0rrfhyBmDytn23RLMFqh4su/BJvQRlNPdhvUblRZ7DGLEH7ch7T0mud+lBrXey1L5AyOgGRtwfEiblP06Cmmg== 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=VrhFs7Gp7ZYt6fsRqG6usv/p25wO3m2Pu8TOq6E/dzA=; b=rY/EcaknI3r43rzK6WgEKpNXrbCsbtGwWWfmmlgqFfxyiOt8LJMv3Z0d9r05tZw2m6BvKoXh93ZNYHSzcI9s1LVG/QycLQji9aXDwg23O7ih+bVPoxIvvOEa5MmSsWm4RSrP/SUBukGclitJ5nYhn8zkEsOIwpLa2nz76H4cTpE= 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 GV1PR04MB9182.eurprd04.prod.outlook.com (2603:10a6:150:26::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Tue, 17 Jan 2023 09:00:10 +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.023; Tue, 17 Jan 2023 09:00:10 +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 v3 net-next 07/12] net: ethtool: add helpers for MM fragment size translation Date: Tue, 17 Jan 2023 10:59:42 +0200 Message-Id: <20230117085947.2176464-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|GV1PR04MB9182:EE_ X-MS-Office365-Filtering-Correlation-Id: 92a9bd1b-75de-4496-7723-08daf8693c7f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a4oJ08CNO9oueJQYhR8pxj0sqpqwOkNuTQsNXSaeVymzCw+V3Fzq0EjeIg60C/vRuDZRXwZTaONlIiU9zYsC5kwNlIY/W8IyicpUgyRS9w+cFY3isN1IiEnSJMP6z+/3aFfQFQi9twL7S88/2/xWLAWiF0eoz4XkZsKw4IZDjnlQxG75tCDxFm74nIDHRsu6HvaR+v+yoVZCt8DHofyYqyhUOxEogfkkbX0pbxNX3qK+YjvIfH1iMKHsIX9u7ml0hYOc98/wTdCa93ySvmWMzI46bh30vhm6iCqqD62sNCUlaAZkZecajEnWW9CPpzaMswDQZ2bMrVh+raNrwTIjCxCB7J/HLdGkivKWzVRY9Qqs07noPW2wm6MHRfFcTuYj3N08834Gbl/pTHyPzDodgym/sAuk9niVuS94YCehJtxrQCxqxweUmj0w0ZCfKjkhWj4fj4WCG5N38CpWFcM7Ms3/d9ZyfhpWkXV5WqP8QEngfD2Vh3yp3QqAeLiU8l1pvtIzZiJ2bIelvhsWUvG0N8EeX2MPOehqKcI/60VVhC2wvpIljMqqEisN+E2oDdThUdXb1JmqAnsiEglSbN2iTFon1YQRevE5N1WXyHeOWB87UGc3Y4KNicSRY1m1Fkv712AazShELELvfoz0OgH741+RMtmzAEFGuAIljeimiqRcf0ys8QB8/keEQFlNPQdx 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)(136003)(376002)(39860400002)(396003)(366004)(346002)(451199015)(52116002)(26005)(6512007)(186003)(478600001)(6486002)(66556008)(66476007)(316002)(1076003)(6666004)(54906003)(66946007)(2616005)(8676002)(6506007)(6916009)(4326008)(38350700002)(8936002)(38100700002)(5660300002)(7416002)(41300700001)(83380400001)(44832011)(86362001)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kmHeIaBGKNbXLdxa0DyqgRw66p2pEPCT8Dqzxq/twc9H9fb/yCnttvzhey6Y9gvDcddr7ejjbQO1rhxazqLzoooh0GvHIzAUtacfV1E/6s+SqvMMhjcD8ps3DvEBxm7Q+yuMhF1flSMlmczzi7m6r8K3hCLtUpGKe/CSEeRsy2m4vosTueue4XOxXqw5fSCl8BfajFVfv/vwBmRW1rTFag8yA4C0k8LKmk7n7qNr/134WDA11cHc2xpthSiWKP2nKbmk2US4mPPHOlvxgI5KkiC/Vi5qzCArbBkN2j/sqDI28KXZWTt62lChwTGnIvxthiY8E7IXdXjMhSxvgPM7AEPu/UqkhJ9w+gwiXnp6fWr/iDtFbwZj/xCv2+Okd0kfzLhsihdtEavhDh4CslW0eMf9Yy1JfJRknFCDN1H7zq+sv8da90xuKmjuW3KAggaxnLeyPffLELGPXIJ60yDWNIDOCr12EJ6Kpst10kBWYD6dsj0d4paptKGlAm+E/A6sp++7IneFlGccttPSc5unfwyqdOQ2yZrQ6hyzOuOhvJF0wIalZJkl3U5tQfjHqvKMk7/xdLoT72hcZKXO7xVxxTFftRoSqKiPUi6C9TmDPzkhQe8KqCldYMlRcCKneh9K3H7tZyPPTAfvw68dddFSTJ1XyOrFq9DnnkBqGS83LABWM4nfCYR0uBBQpncxqcVxhNcYag86pUZgQzQT7ocKmS9EM6zjflrf7opdt1jnthhzz6FdXwNMAhfCZTN1ZH9gFw+guhZuMpGnfhRXIQ2mPygCOXZ2TiALqj4PCNiotRe8Ykl82BVdtEJGHGhJ/DAAaEx2ttBkGBXCbfGCkHVFMUbsT1bB6zrTmFLtk9lTbCPoMdfsTgUESOiAOVXRV7DqGQWhnGMB3c+al5Ox7RXCCNghdi1dsqa+JMeXD8+qJtRprKyjzY0RISJSKWt5gaSnur8nn6jxj1O66hEVE6uXyw8zZJRzXNzTfrMPEYKN8NLehyqzVr4sbg/To5ZGnwX6KJOAXV8nYzk58rWHyRq4xP/qz/UTMPYnO/i68TlfAqV759zN40suf4Nv6HiTwUvZbUMOILK7DTEHtSTIIy7LlUKog9ehLiWiUklRQz43g/Y2mojHw6ravbVME3vyqTnSqpQvhzqK5vIQa6UOIi4C71aK3ASN5A2meVD5B5F3p/3HxjqSA4q6VJ01M3QeUAUjYY60upLAXpZKg4s9wkb7W5jwaswc3sIWNuH7F6aS6SHCmAgTiUqT4SCe9tJHEL/bm4daykKXt7qLGkkL3qarvfvV+s8KMShJg9qODDyJ6vHRQJqpC5t8gMatftgIaHNuQ1YZxqm5DsJZmuYw7IjaDW6sfr/I5YNc3YXIgo+PRmFyS6nH36f+JV4/HohyjTwp30ZKzsKZ+Vyy44jmWh+JBjPK6susv5XdlkK/KrAIjyqxh3NSkSf41pHiDq2mOEesiPPHHoH3sSvDpda/SOSHWoltvr1WDxbsIBn4cbgO53l/qnb5ONbo2J1Ea2zoPzuuOQKq+iwciqwrI2DUpLZuynLxPXJiWVz44y6cvVKm8tosZSpD4RlK5zkU7mqv8hc9RvhtfFAq/lpVdv/DlA6Baw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92a9bd1b-75de-4496-7723-08daf8693c7f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:10.0024 (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: QOkdGmaEax8tlRA0ESxoCckCKbTKSgWog5BxJEGz0zYWu3N7BK0C0iLO3CnC3G/9FQ0ObD/8Jvwt6MJjLKXKWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9182 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 minimum 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 the addFragSize multiplier, create two helpers which translate back and forth the values passed in octets. Signed-off-by: Vladimir Oltean --- v2->v3: - adapt to renaming of "add_frag_size" to "min_frag_size" - use some macros instead of 4 and 64 v1->v2: patch is new include/linux/ethtool.h | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 6746dee5a3fd..6a8253d3fea8 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -1001,6 +1002,47 @@ 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_frag_size_add_to_min - Translate (standard) additional fragment + * size expressed as multiplier into (absolute) minimum fragment size + * value expressed in octets + * @val_add: Value of addFragSize multiplier + */ +static inline u32 ethtool_mm_frag_size_add_to_min(u32 val_add) +{ + return (ETH_ZLEN + ETH_FCS_LEN) * (1 + val_add) - ETH_FCS_LEN; +} + +/** + * ethtool_mm_frag_size_min_to_add - Translate (absolute) minimum fragment size + * expressed in octets into (standard) additional fragment size expressed + * as multiplier + * @val_min: Value of addFragSize variable in octets + * @val_add: 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 the minimum fragment size to a + * continuous range. Returns error on other fragment length values. + */ +static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add, + struct netlink_ext_ack *extack) +{ + u32 add_frag_size; + + for (add_frag_size = 0; add_frag_size < 4; add_frag_size++) { + if (ethtool_mm_frag_size_add_to_min(add_frag_size) == val_min) { + *val_add = add_frag_size; + return 0; + } + } + + NL_SET_ERR_MSG_MOD(extack, + "minFragSize 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 Tue Jan 17 08:59:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104359 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 3510DC63797 for ; Tue, 17 Jan 2023 09:04:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236153AbjAQJEA (ORCPT ); Tue, 17 Jan 2023 04:04:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236133AbjAQJBm (ORCPT ); Tue, 17 Jan 2023 04:01:42 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2042.outbound.protection.outlook.com [40.107.8.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F38F53029D; Tue, 17 Jan 2023 01:00:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nAlbjlhyCzPpTVs5N52+Atn+mH6WN2EsmTpvZPDyC4EAilTKx8QsmvFyjWQgkSEV+mCFWytGIS6UC6vvv8wZtxNKHyv8WIHXpd3HVhWowLqIk7iIquKZuRpt+RtLALBRLndhJquoRTUHt0ZbcqscHwNcYU0Z6l3P2K8PJxpEJV7z2ar79etwlzHr7M8odvHgj2aU34MGavZ0MRFtpYim6EVeljr4SG6367BiVfuxXFzO4ytaKy9uoNLDvOhRZasB5K+Fr1IDwt/dgiUArb3DH/d/ZcJVlQieDAtZRvjwndL/YcrjxwMdwqCL25hIFi1Nf284GYKtSihAVHMLCEI7JQ== 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=HJjB/37prwoVGpq8bg3p78876HXFSMiHPWlOj1JxWLM=; b=bb+Uwl+lkpqnOsrt+Vs/TvOlbUrIXqdCSTozrxM/2NsMk+y/7QeLqbmfgJC3tRq3pUKqD35GvBUlURXp/y9220Bt6T6a6DWC4X34h1/4zZPkld98XQjTKkeUNOi1tr9eyrVpEam5vGPC2Qz62+SqR0LWrBebS3XSz0KCTjqclh88Lsr8XFTt0Vi5FGdmNspe9mBoYv2hl81WqR1SLBcFw78DPkvyItwbog6g/Sc0KLrEwXwxp33hFmTvAP8HLlsbuPuN9X61QyC6PyICEoYk4TaLCy76l1hUovr2451YgCKsYZ0tQxzW/iHDdkL7Nnl3QVBHbdNdONqzuXUMsa4Nqg== 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=HJjB/37prwoVGpq8bg3p78876HXFSMiHPWlOj1JxWLM=; b=g87WuVQyo1VcKy6qBFE6Q89sIERbuumO8rwklprHhk2F6vXzHLLEkhKDpML+cAdUa5mwSCS9FyZhi1HazJebqog7gPp/q65wbWZR0WL0p2wuiBkes4mGxowWEjlSf58UTVoKBbfnN2IZ5JtDV+WpOSjJ5VAjPqHj48tyRx3S1o0= 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 GV1PR04MB9182.eurprd04.prod.outlook.com (2603:10a6:150:26::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Tue, 17 Jan 2023 09:00:12 +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.023; Tue, 17 Jan 2023 09:00:11 +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 v3 net-next 08/12] net: dsa: add plumbing for changing and getting MAC merge layer state Date: Tue, 17 Jan 2023 10:59:43 +0200 Message-Id: <20230117085947.2176464-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|GV1PR04MB9182:EE_ X-MS-Office365-Filtering-Correlation-Id: e9d73961-d5ea-4f3b-6749-08daf8693d77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Lkge7ksxy4RsbOwsKjfTKAtfODB1PPC2qEXEb/rJPyDXmw60lPWWxcVp1JeH8XmYP3M0OO+ELybXmWAeWRhMp4r485NmCYF5V7zXr8gzCox6IrhZOrrkHt9o2v/BkIqUgkuju95SyYzkKlFsA9kUyxO/CzaUOjO7aVmuwDB28BkRcnv2bTApBlLCCjUcRbxQo/yBwExMUVdjonbBkeQvKq6OtZ5QnKJ2g5Af2L+424DAlU73Nsxq112KVsY9gL4JE2oNRufh3hNoZ8j2Zfbb5n2VcsFydf7K3vWyWDWwfDgwI7YBrbhnTij8NJuGucYXQ7lBGOINl/ksw2PlKaJAuGMERbCZbYRdIIw0pxm5R1XqhbGIo/tTniCg9pj5mMOOKO/B0ZbtWARiVrcyZKx1i0oBErIsHP1PzzBC+3rde/uRvzIxdbC7iKS3GoZtqGmc4/r092M1AkIwo0IsZi5yuTyaBThC9mY5pJV04AhjwCODTwEky0ScEL4+/OkZpobwSuk+WNR/R9eTpNTw4ipW+RMVQrE177oLsruE7XDVvDjOHcJR4a9B6/1Cn/QD/GQSnQvaT8y9XEEynUsVDDd99ncnn+hlycN1TqAe/mJ9/lG2FaHtYcpAGFPyosmQ1+euVGP9edGd6/MtBYSpsg4mUY+rh0vIbGeCR2hZZj86x/Z/ubwDuhr9SEgIey5lWV0/ 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)(136003)(376002)(39860400002)(396003)(366004)(346002)(451199015)(52116002)(26005)(6512007)(186003)(478600001)(6486002)(66556008)(66476007)(316002)(1076003)(6666004)(54906003)(66946007)(2616005)(8676002)(6506007)(6916009)(4326008)(38350700002)(8936002)(38100700002)(5660300002)(7416002)(41300700001)(44832011)(86362001)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DVzJVCHhJbHGu99hImrZqVliRIOJaR9cupMnhwDNHgqcMtEoHHrDPVi0uI3Rikfpwf9r3KVdvyyPjgni2PXD9h6JcMLQTE3p7kTJur48OHT1kmvjPyzURN/ldtNssk6lDm+hLgALjSl4BS/YlkTSCF8KVTmrjDd1WwZmPF88zQnhjpYb8vNDTwmDggkTs38etpY0qUyQsV7vKajAAHYMIdaRH5Cd9dg4RxZRtXDirNODWXTqrNADZU/jRJqOCXsAySH7t9AJEsa8r2kjHGqIWhpUgyBg5F27KcC69vhw38P3KnlGBnH1BvE69CBFvdpj0eciTWD9lqDML4suKt/sBXqGdmdSbflEKTEI1QV634glEBmS8ag2qxhwbjmAkKDDzv5ZkayqwETYbgS65JSYCDs04wusnSxabHY/arEmbvrahNVFtjGb2nL4UmWbKqkyd6nUgxnbDy+r13+PbwZ3fYZSTl8hyTIqKwO9uHFl01H1aBRMs2q9JyW3vsd6zIfcucmeNX0Kzess76rCoQ+9TkGxwq5aZay9revwIPBoOEs7H4MTH8qCpwCvfygEEHhTkuSoxkmZV2vUqfDF6iMOgYOaGk5A6+CswToOYKcIPvNwiWbx9CpZOyovseJI119UvHM1f95GsWeLkn2GxjmU1kKPTdWzUVadFtRr+RCEEibol5fzv1ZPGzJ24VnW4FGJrM6frzH2ruN1LQDE9xTgrfMfsUekPtoba3DxdlM0P3FBaXyR8TqsrkbECly9qDpADG4pBRLjFudNGLHVrGMkFdj37SCtiEFix08RHWWCpf+uL4Jw2LTQA5qXGuH3E85ueNac8ObNBmss04X6VsrJKrtlrYZ2k92IVfoS21NQ0Tr0lnnO+ksdeOnGYoGdG+iLZbVuzjlPp3Y6DkcXZmmUq4ow8h6KVpgJWsRmXEiEz1rs8EhpQz+zTCse59b+5bgn4ETy4QdfjjNhS+VzONdXNPtQD7tFaKiQNBWXv4+9mP6bson6kkFr5v0ZCYRHiwpWXYZnZZ0ZPXsFMba5XRGHsXyRXVNu0Q73IXXdfkvnzaNvVNwr+eoTF/6mwbShrxA7jEf6AQhl1KXLrM0kZ0zGAqBe3KSHI8SoeU5r820KOn2YqyiOAmuYshWSjxqgGHZrd/rbENE6hoiUEIEHFfAKBOcFcJfJR5ZfhnXBGdkxOM4Kylw+4z/F24qXenSR/3yHKRw1bCjIzGW9DTb+QWZQN0inedACEZtKPHCxawWvrSgwe8kmmnAZ1iLyVc1+bG1QKmIPk9b1gO1jX2Vhsaw8SeiUuLLjCpjEkj3Sv9KUtipkTlCt4B7b79ZXGXgSO7J6QUmGf8fPJPMK531YNtJ7K+gC0w2eKABmm2pGE2ANd3Q13v9alhwpDeHYZ3dwUymf3YulyOaGuw/qTQ52CRrwzOKqbSOu3NMVUFxp8fngfbkfRhAxEOzZPC7RbYARGVYPGf9P2JsV5PxDCg1Wf6/POH4J05cPcAty4GSe3bE0ocSKD3N+eeZfT0lXmcG+0MSfJbRjoCQasXP8/0gPgrY8BlWiXKUX5v2o03Vz6tquXItYIXzR5wBk3o7UA5aEyP7j+x25oC69704XEgRZcRh8fw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9d73961-d5ea-4f3b-6749-08daf8693d77 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:11.7992 (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: Ye/Uce6xopEE9H+7PvGD8ltPJfAdmHKORK3GtDeywQVCXJIU6w4pfxc/Jo5ANkUQbKIz1Yr9lnulrf2x9+MzsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9182 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 --- v2->v3: get_mm now returns int v1->v2: patch is new include/net/dsa.h | 11 +++++++++++ net/dsa/slave.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 96086289aa9b..a15f17a38eca 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 + */ + int (*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..6014ac3aad34 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1117,6 +1117,40 @@ static void dsa_slave_net_selftest(struct net_device *ndev, net_selftest(ndev, etest, buf); } +static int 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) + return -EOPNOTSUPP; + + return 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 +2239,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 Tue Jan 17 08:59:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104361 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 61053C678D4 for ; Tue, 17 Jan 2023 09:04:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235992AbjAQJEG (ORCPT ); Tue, 17 Jan 2023 04:04:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235672AbjAQJBo (ORCPT ); Tue, 17 Jan 2023 04:01:44 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2042.outbound.protection.outlook.com [40.107.8.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10B45302A2; Tue, 17 Jan 2023 01:00:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OdylFrgfZjpJQ7qkh0E9HTCRx/CAJYjwCsgXkJ9fICX7os9qTvnTgDQ26pOJvXKdWY1X/0XIfnGg66wGWrWyrs9RwRw5Ayds+0n7+6nlNthVXTFv6ydUwYb74h2oax43A72hi+LPNgshahAGR+KCf95opWcDvPLOUCOjhuPmRxrCx9U4K58ZqrB+UF8EHE8MYnzOROPVU4VfEQ998mmQKGeGQ1NkaPtroC4ojksQguCsbxekTUm68pMdxZKAXIIyqJC+7wgVK4Jm5RUhVo5NntrEM+iJxQ3zi286llcdxjc/OKycDAzzmw5ieA9m0NOlfe5LojXyhPnGPRbgMw4DKg== 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=oKksSES58XgQr62Qj6ao5CTuzUuwjhZXivOpP4Hyneo=; b=G9OI+eGZMHW9a36SU3MwRCXNEQO4ym7D/QLHEe52BgaQukawos0wwGSCRi2GaZOh0eaIF6QVU4INn11TEExUCYJwGUUX/TVU8s50Xa8xtUrcKpzCFLabl+cgIJmOpz1RiUWST36rTEDru/wqVgM8+8hAhz/GJDNmBhZhD2RSa9vpVMBu462bJb6oJGFM5CoaPhnAdJbhxpsMblSCZBoSAhu43iNCOadGYWt/jwGxE69+UCsbS8AeqTFNs3kSzt28WOeAQqRj3Ot5ME5r5SKY81woCGrtcG3GInG5HGem+iI+o0fyE5Hhy2Lo4i5mRO89CpgF60ie69Zs6tpWmOVC0A== 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=oKksSES58XgQr62Qj6ao5CTuzUuwjhZXivOpP4Hyneo=; b=Xgwll/oRW4oeLKpy4RPgPmlF+nWolbqSvhineDQgGTdnTVDEpTA0D4iLeEUK7C89ZszsrB9ucU3NA21/fq37SRpXZf+7FYx+X7fdB2yk2jBaVDL346wlptcSTUfOLXSMdxpLR650TlkkaY6DdOerzMghcxrGyJ9Iig8MTctmmPY= 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 GV1PR04MB9182.eurprd04.prod.outlook.com (2603:10a6:150:26::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Tue, 17 Jan 2023 09:00:13 +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.023; Tue, 17 Jan 2023 09:00:13 +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 v3 net-next 09/12] net: mscc: ocelot: allow ocelot_stat_layout elements with no name Date: Tue, 17 Jan 2023 10:59:44 +0200 Message-Id: <20230117085947.2176464-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|GV1PR04MB9182:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a008d3a-a64b-43d7-cc1e-08daf8693e84 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z50ua2adfBCer5HJZO8dpHejyrZrAjD5VywOnAmEsSMgnSBuMdCvVNvr8LdwMhAly9pD1sE7WTWltmQ/C09CfNpQBO5BuVOm6WxtXk4AIvCIGR31SHKBZTenEoj+r3ccv47dkcmbeNTkZu63H8LnyTF9QkLAfDuBYoCNwTLFvlG+WyW5lNnPditX6UP78T8oPRgO5OrVJ8dqBK8ccmzRmUq6WCA8clWiL3CqLUKHk/FbrXu2l6Z4c/Wc5ccGxZEy+qq3YmE01Mj17fqfboX9bO/y+7qQ1VM29dIWqcyh6uzQLw0LByR9y0T1ExgDBv/Fb5P39ky/+dpr63sNWxgx7ka1srNcFNHL+lUuE0NXl3Ee4izQuYjcyZa3vRiAxS5pObVkXQ/B1vdAFh6uWSzprYvuBGHLu4B+4EznUbvOxmIfidf6Kg/xyxvbWuVMlqxJIsnopMu8qovPCacDMoc2hznxA/dCrL3pY+TURA9fZawIPiIQRZR5ZMCfflGbwAMOYeirJ0T49dF9WMp8r2rzP+KfSfWho9dmLjRROwhCwzTcGg0CaAygAELw/6IpyY37JXw5bPXoGhBwGk5Gy06IMtllVRu4Yw4yikY0TSZhxihXilTG++Tmw1QgjCcu1CAxgD8lMxg3SifKj+zcAdUy3DvmFInRzZpbKvs+lW/KlKkSnxYTUOPKy9HiHeQxmIN5 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)(136003)(376002)(39860400002)(396003)(366004)(346002)(451199015)(52116002)(26005)(6512007)(186003)(478600001)(6486002)(66556008)(66476007)(316002)(1076003)(6666004)(54906003)(66946007)(2616005)(8676002)(6506007)(6916009)(4326008)(38350700002)(8936002)(38100700002)(5660300002)(7416002)(41300700001)(83380400001)(44832011)(86362001)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IH6ZVRFMEdEEEg2XTQydGiMKpQbGMOF2SA3xe3qPq61YXfSAc4yvcR9Dg/9/CDS2wzdaaosyWr0IXxXTFlHIu8YN1xxyvxjIdd9xiMcgNPNbCNdZhLX++hjERKHef0fCF22Oto+wiCGFGos5jIII4OH4g2LZvGJ5/dw6JbCa75w1dfFC5zGoEsO30EDxMp1hFHGD2MAzxb8U6ZQw6EKXYtlRCJ5vlnkdjPzatqK059sYWzbSeFV8f1xbzCjsv7ELDX0Gj/tXk1K/rmt2azfzG4MUoZQx8Zgm/ZJVejjkZYiURBBBmXeIZHXwe9op6lAnJwrOQH87r4JYHl0M/6b0Iy2++0Iv2QCwBbp2SDrQnICuqG5vV3iysuKc1qGocfg4VamVuqEIvqusZH0+nON4y2vJ//74QNySS6Rxlp0ZOInGkiy4gyMwOOfso6PJ/3MTmCEoR+wctx6BPgSK6r7F012gWQlXx1Q7mzflonKduVQp1zyxhELuXjbCgQSianNMERXjr2YSk5mzuHAdUSO2bKYHVDtdT8MV7mNtX7sAl17cDbPW6ueHHO9jP8GLsSueUbycnYTJx19SqdXPVxRUiUwA7q7OMSKmUedh4xMYUeLVyeVoRqVETBdej1+GxQHxok3TFqkXmdHKB/kNThkX8S4OiP3FYodj0+MrqhtbZYJbKEtp3X3cYH0UVqTd7yyY89U9O6+qFNb+/ggZ8+0RfKxQSzQn66L4cYu994B48Ex5kponCs0sDOUgL6X42d3+vx1lqSAHC1l2JybDd6ZUDkUH9dFwWCdR3cNCm0ibZbKRQ8V0znOXFz3e9T/0TU3NQ8pCZsSd0+ov6IufaUw8S0cRTuC4nle7jWZdiVP8moYQj/h930vvO2XMbI19YjKzJ2fQeEhc2FV00SlDFxOuj8wTFRH/Qin8H4Uli0ERK/DBSfinUxgR59Ii085U/2f5HOf9IDqx1hxqHdn/FQ2oANU4PP19wBe0/QwUy9zEumA+OOOwxUP1NoAf8QcUOym1skMcv7vZeihvsdioYG5XJERKlH7nMO/kyCT7oOlakhaLov9sv9oqP/ZZ9lxeQ5N8W2KQ44h6nM6B2nLPgrS/FxE0fkql8ho/lb42T69HZqx1Q9Hv9q3KgHmbmd9/hIHS/ILcHOrX8B/uOdG9nCvtUdNcVFOqCwEYXU83ICN7GTsAiWaJauhHqstpDwKa84M6o9aPkCQ8+8/TLuylOXbk5t8B4CvBn0sOS0YFiMC7L5D6Ik69Mcq/MmFFsHoFpr+9o7ZSGs9ECfD/0kDd8ZKjnfu8YF6G67EyC0wCDZRPpu2U/kMYG903JY25WBRVC1iuErOPrc0usyprSeVodNcaXCKnaYW4H+DeGFk5XmqFooj2s0cpb/IFQwuxALuY0PuDn9iNIR5+zl1A7UqgTvJXmsGmxfQk1X2towRhLx2+9+avO9vbyvRwkw4H+YOX5uGfeSdwXRbJwUMHDHb6lP0SqrqOGzPRJBjohORgXVkvN5n5kXJfHbBwHnsRwoQG994dxz2qup/oXXX8JwJ5ZrHjSeXAYOOz7oDfXThmhpDAUze4ykaj7vLrJR3W10JbqXOt+As0xUOwCqAOgi5QyMHjyw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a008d3a-a64b-43d7-cc1e-08daf8693e84 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:13.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: WhbVJxiPeAbmm9fQouuHmo8eInvNdKuvs4v/ECiSoQE3T+I74szcoqyWnCQC86MN8mYwX/7pMW2S+zmRKrJi+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9182 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 --- v2->v3: none 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 Tue Jan 17 08:59:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104360 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 4A014C3DA78 for ; Tue, 17 Jan 2023 09:04:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236241AbjAQJED (ORCPT ); Tue, 17 Jan 2023 04:04:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236334AbjAQJBo (ORCPT ); Tue, 17 Jan 2023 04:01:44 -0500 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2079.outbound.protection.outlook.com [40.107.13.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53DF5302A8; Tue, 17 Jan 2023 01:00:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dlQzoWu1zNfu3I+rey0Hg8PDBhvUAPGY9gdREQ+RsYDPPKKm1dxkZ1AVlts9XteQIX3G+m18wEKKNxiw/KZdPjUjli5YQfhyBc0HoZeW2rTkTkn+ej8v55uWSGhzA8cPAv0YDPP7BT2dIiEFHuS7Th5yjYMAP6VsejPepb4QZwptBBrZgtRo/oawfdPwWANYfbCAqSh7vU5Fch9UAD5TEGgkPyYgzEFLbWYSHo5Rd8tSek7c33FQrQy3A7HqkcXaD+y3K6lIsTDXrxhtOgvDFcORsiKpR9ycyrYMobM+Wxdo1GoV7BzPHBYg7R58BHedl5rLyCQyK3Ijv86i4SgDdQ== 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=jUViFYUJxDtQ118HMqUSPlfLX2uflDjdj8HxS3yoZSc=; b=BFxnQrq5USW8Q4IavOLsbDAXqUC9YR7Pz4StB91T2AXT+ZaLiEUMaZbttQ+vBcdnmFH5SVA2kwD/3HfiEBKX3iBa9ZCWsX1GwUCWN5MCjZTM901X2EPiBHmUz+o4Bodc9lS8SwzUjdG+ECUcwF3nHk6bmnSoicf3v+EZ3ScOTFZxhbMAMqIlRhFa+PzZjhn/qhWsZhOu9+VRvovnYvRBVVjsxmuSy9vBjBP4OyQsFv3LklNo6mX0VeYDjlhA3jiEsNpr3ov1CWhi0aCU8J4LXhm9l0Zxcd2BFQ/vTKHXzOMUilryLttYO4cXj6q1hP2GNBSQR0D9xXWxJy18N6hu7Q== 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=jUViFYUJxDtQ118HMqUSPlfLX2uflDjdj8HxS3yoZSc=; b=W8yxg1sIZofVrpKGdoqdtRcov+TlnIkAodbpT/IJsaADunOINQT6SWB+fLwB4+mzlqV1qgvI1QEnMeP196odQ+ItLinBt8gy7zHY5+R1zkQivdJGTbZs7FtnDakozn5COcSowX+Ki+odwt8alJekr0X6Bt9E22v7CN8Dct8gxEo= 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 AS8PR04MB7861.eurprd04.prod.outlook.com (2603:10a6:20b:2a9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Tue, 17 Jan 2023 09:00:15 +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.023; Tue, 17 Jan 2023 09:00:15 +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 v3 net-next 10/12] net: mscc: ocelot: hide access to ocelot_stats_layout behind a helper Date: Tue, 17 Jan 2023 10:59:45 +0200 Message-Id: <20230117085947.2176464-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AS8PR04MB7861:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d2fb7dc-e8f4-49da-4184-08daf8693fc4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z2KPy4pzoftm8BdFh/xE1PcDAjE+3LW7B6jKHYk1p4H3iJepHyQchkRxY0ZES8Ie8a/1LzihDeX9+GjD3HvHhHB2MURNc8UpsaSJybNcqpK7lZe4W2+5NuyqYN8DOtS93/ugH/6C1upeYTAo1u4vFfDEyKe1DmZfx6mez1vd8od/xQnUEo/1FVsrzDDFGmfzN/JORIUnMsf19CxdCMGGoUZrMmrWH0+kKuwY5riDTyGLpCky/VPpnLIhpMRJKawSmEHaDmqcnypnOPCoWnSqcSRbWDvoFPrp/eE6PpWDQbMlFltpz9Jna4kTqdv0QXepXOQbZZUUYO6foZ8vx7Yi9dFNMRy8ZqoCyrkT5jwzy+Hxdqo4LV7fMD2tU8ntMUCf7umiNOIQCg96vLC9d9eRmMQKJARhs4tWO1khudIwkKrxbpBUBtYJne1LqHvmukq9g5tBGlhZrMOePNQnO2zfmxpV/AclMwdvJONPG/T3yKLq5pzwzQc7yKRzXNmdLVC0L5EnifUODoeumVPBPCe9l2U13JybnDe71d+jJAGR9n5yYQeE150rj81vKF0ndvtRFRQ7RMdfMzNDFvQSj82idV/wM40SBDZGuNnrFiAJRwErtNznrxN/LuEltDbwCOlq5RF9dBDVe/YTOwebUaTOQ+eiaQliULpeC2y4ILDy9pQBqOYg8KO2iDdroxaPQ2II 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)(136003)(346002)(396003)(39860400002)(366004)(451199015)(36756003)(86362001)(186003)(6916009)(4326008)(6512007)(8676002)(26005)(66556008)(41300700001)(66476007)(66946007)(2616005)(1076003)(316002)(6506007)(52116002)(6666004)(54906003)(478600001)(44832011)(6486002)(2906002)(7416002)(38100700002)(38350700002)(83380400001)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ius8xkCucIp2atb2jJFF70olsoDmOT1UYPXojhAOoPhM8i5hTe24yjUm1CKQQ+lHqM3zDIHI+Ep34cvKjZVg8eQdgJUcKPSyj4afqYRvwiZiqaFlmgb/XGV3Jh4UWDxy7Kouij+Hz74C2O3vtOiLDJ+QxlAtRSzXuKXaDA7DLNA1XfQBk4Sx3bQIJ5tE/mjZG/zvbulXnwbTmj29xLx0aPMJti7dVd00CUbiMLzEAfy1b1CoFo15bze97JajHmJOBO+UiW9T443VeymnX61xA6aD9Wsis2FCBG1KouSGsXrtyPhuyCAFd2bggUkKw8tgsv3l5Vc5sQDe+5to9WgF9addV9Y0uPy5Ohhd9hskD91B1LDZITl0GerZ39txbQeQdYaRfLirFvXbUIDEGaQ7+pM68fbWQU5zDHZvWDMfvYb5xtCLaNbh6ZYDF0Q4eAyExpB6tIjdIHvg4OUtec/rMsEBLIvg4gJbUtTyGk4WTsW7cbg8pxrT2Z0tuYRBxw7aHMzHBDKVufc1iCBnQDhaQowOpYKlDpXFYKDUyBuCCug+0KtOuz0raNuKkwOUnOj3E+ZUE/bLFVhucTPAdN0D3YXEZNipj9e8y0waBylyTxfES1ssUEhSO/i+cPE+S9is0IWckzIRn4S7nQOPPZgnSae4kRApj6o8juKN6vLIZNLP1057XVBEEng7tvINSzB25TXbTIAstq8Rcln/hQJX15okLXf7Uz4BAb3RYryF5bxmtHrQBtJWjTo/qnhGNoSkh0p9miSzjfyOSJIbIzvSXQv9lNOuUw4yIQdaTx/YFFpqBKNwLQtlD/SpHXyDDQE4nopyj5mdkj2ZTDbbmnrB+BS9uelX5jsZ/jes8bVQpzR831Ac27Udl+IK+1IvRA1ddDe+UROy5TvZhJN2m3/IpuJ/EZEfBuhSLPL8mu43o8EQHLUUhsO60Ew+sjhp+ysfuslMOhvC6jckIhzl3gwmgDW3JdpZlVH55uYIR4SMHcDEAqjw8HjnQ7RCpTaroW5gRtv83PgnHq9t8YiazjGJVy4duxvESmWz3HmxJ/TFF7wKxm9wFvoYf9kA2tst6uhd5SCHTRDmmERlcIK35qSv/+cnw11kiWIF5n2LegAL9wIUaQ1DbPWmY6OiGT8vd1LOkURXmRgm/W5+FHiZB6ftTkfYVmp9MQU6Jb/8aBD//2RVZuVWNs3h+289icPqHmdgJZY09mSdbQyxTr8mhOzRmTh2pitwWb0oM/xh8sl6k5KumI1e5QEjTNpHOr+U5VP/TbKvzDkKvgiCxal3j0iT0ri72IQKFb8DfPeO9Q07VetEJRnYkLsUdf1+FUljG7otA8tHDUYiZzXOHQ4QJ1tnpAyyTXLYbGX7Hu4pFu4O0GMN/k1Z0/jHWZq2LKlpYSGh4EGV1BerOWtXAGS69OGKmS8SDPVLsmnCc24g0PnsM86iQwLa9HBQiOiQfU8SQz96QSGFdSvOrdwYkTk9m/ThKPznUz6uhmE6yI4V2jkKtdDUviuGnO6eNyWA+3lIMlmUsoAfYkRU9MgYveOyBhDSEEoChkExx/GxqzhQW/nN6T6bS7As/NplVEwK25rM/bq9XbaxGHyyrAj+FqitCDBWaQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d2fb7dc-e8f4-49da-4184-08daf8693fc4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:15.4083 (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: 0cK3L6z2PDa5TQ5G+3mo1NjTATgopBRkbXdZG7AaIRBVqkR9S4uujKJyP7V0gFIx2Vuc8q5eVGBdlfZzp+KBbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7861 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 --- v2->v3: none 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 Tue Jan 17 08:59:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104362 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 B74BCC63797 for ; Tue, 17 Jan 2023 09:04:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236270AbjAQJEH (ORCPT ); Tue, 17 Jan 2023 04:04:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236064AbjAQJBp (ORCPT ); Tue, 17 Jan 2023 04:01:45 -0500 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2079.outbound.protection.outlook.com [40.107.13.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E46CF22A1D; Tue, 17 Jan 2023 01:00:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZcIx4hozDRBd6ibeK5zxzLk80rEMlpnA/FjGQod8qxyOXmQfOYHgyaAJ900OONj4ERfJ0l6iucG3pAXI8TYiP2UdRkdKMn7eOTuewyo0Sod6P7u1RiC1468XmSv1pcBGZh6ASbDB+BD7MfOA8P2b0UsOeXrNkDlsdNUeLFSuKWr3zx2B1sDo8qcBKx/Swjp3If284TQVfo0pAqS+uF9i61SoUn428dTrBv/FsIY0QZxELHi5meZwo3iUrkSbXRG6EjkPT4bPXgSAAX/KDGeU+UqAyAMCEYLXWRyYTUp1eqNlqEek5NaeBiLH536C9zM6DkNqKzUjZnRr7JBvAmHZnQ== 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=1eeoWzge5aHMbkgOjO8OZXBKJ8tt7f+gGhi/Pki6myQ=; b=h+t059QP0MaY1wxzJ9tGRrnALH8+VAWLKoAN1Q+AzZwcRIYv+jdjelNMm5mwsSwjLHylHfgL+U4IztNmF0C8revOEzbaEonGhbb9QiTbpBrluHQWMY0gJKSmO5yaOyL6wLzmt835fmyeZgP9hd9z+Ns7w4kmrtPhxS5M9l9rGs520VEelkmJXQdFFc6cynZjWRi8FyQgE2ceKrKkL4JyAvxdBsOeirmHcfb3qpEc/C3oOCmm4+MbbsQwdMhXAywc45PToD6D3a2Hu/a+sOmJKgnbyhva9rODTRQrJFnuVGOofsPmDNzEAekpLE9W/m1gFPOEId2hQEAtMeO+mbEzbg== 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=1eeoWzge5aHMbkgOjO8OZXBKJ8tt7f+gGhi/Pki6myQ=; b=gj+dqQ2X1h+6Y0uvTHUrUyBiFBWg5os2tyjZjsmtJADJQhInxlLMcE6SSoQQvWNmbghsv3oSIf7xNPhwzPA2TuPhvn1HpVwXs9inEdgfLxD9MEmcIedRbCfzRlJkI83e/X3L3rRZhsvjTY0mhKbkwkV5kiyKWVNB62isKfrWFIs= 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 AS8PR04MB7861.eurprd04.prod.outlook.com (2603:10a6:20b:2a9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Tue, 17 Jan 2023 09:00:17 +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.023; Tue, 17 Jan 2023 09:00:17 +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 v3 net-next 11/12] net: mscc: ocelot: export ethtool MAC Merge stats for Felix VSC9959 Date: Tue, 17 Jan 2023 10:59:46 +0200 Message-Id: <20230117085947.2176464-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AS8PR04MB7861:EE_ X-MS-Office365-Filtering-Correlation-Id: da4f76e8-95f6-4c6f-a473-08daf86940f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BsOiolfJ/gteefso1ZDQr3Y5o54nWZZBCJRuE6uA6/harxZVbywa8dirQsjx7zxAw8lUTGYtOEsJf5ydKNGV/a8cbhGhwWIkVF3KA8XbDZci/t/8PKODsDjkPrOrjX9FMsmL3J72tAWO9wY+1j8OLyuLD6Rsrxua0hyVe06mTdjpDfpbxwYtlMrcI7m8j3mFmIaV8d71mHC5QXIGcB2HTmjjCuyAfoqWo5vYy8aBG9YlYlIt88bgPDy9D1EqztwMHDgKmyqHSKXUfE0ZPS/51gORK9kzfHdQjp4GtEfDQIZ0yeLav+eNkX1EbIP4/khXEdOuxbFane/e6RP9Lwza7xtOqb58Lfc2KjzAR1E4giR75SwHlc21rFVK2ih1FKyyO8gUIbqrqzlcU0wb6Cju9g/kSEOZdaZs4hjMd61pDyx6biqUEcsvRcVDk9R5n3cyipyhijMognisgJbZEeeCuXk7Dl8K/145uBmGzMka74pnbdS5VPbRwXxZEEcT6leKTDmBI7aM3/kRsZpyndXfq3jjyBUMx7bW6TsCpxomeF1MidNKy6TvYTPL1gCR9Xd8GR5XRvXQRj6cxjhVxs1IAPlcWude5Tr1A0O0htmrlRC+W3yRcjcG1B0qc2FSTKBVzG4yMgdfQbIeXcZFNavNsLglhw6Anolic7KgNoOn2g1JTK7VKoQ198XL9bf69HUZ 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)(136003)(346002)(396003)(39860400002)(366004)(451199015)(36756003)(86362001)(186003)(6916009)(4326008)(6512007)(8676002)(26005)(66556008)(41300700001)(66476007)(66946007)(2616005)(1076003)(316002)(6506007)(52116002)(6666004)(54906003)(478600001)(44832011)(6486002)(2906002)(7416002)(38100700002)(38350700002)(83380400001)(5660300002)(30864003)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NJ0iuxP8W6j8FKnVkhuJ3LUgzGMBN4N5ybZMUzSG0hWe5bnCgwSExJFFfaJ7JFL2GvPZnhPMSq5PsxscQuNc9kZ7Rm1xWExmgAt4xvpXdDbMyAZ/Dh1q9UOHt5QrBJ6SmqKyL49O5TpXE9v4WXLco2udWAZBbD0Av/iHmjGhwxdBZ0FFv7ByGad+eSMrJ5pcuaRnTdWnZ48hkkRASz/jzlH2CLig4eLYsbjAfl+T+gus+gMrOMy5cigQWJeTcEgivpCL+2svjzKJYIVgOuZNtcz13C9jYeUYiAL+ueOKWLrp8Zv6WVs6nFmhB+exhc5TBTc7FPnPmfxpkMiucHWn6KsXzUzYvmvItacfs18AT37wSRVWRsDRVH/vVSrJjlN2rCMhqWNtvrJS0TWymuMS+nTXY7q4S0nspAmvNzXB8DLXnx+l/nBja64c2mTyowN4yn2mVq+xcjg6LKzakDoniy+RZ4HjBp+LSEr0mUIXqOgfySlAOhAyWvLbPbb6gPKvwZ9pPPWJtPuN1mizkAMIpGVGexA63SkGwea/d9WnAYmfIeB7wR+YO0VZDpWNkPTuCvqhc+Btr5Wvej5Wwivslt7agUGXtJdqYX8OeD/S1cIyJo5wxo9oj7i84TzznEcOCt8xCz/zTz5NmKt2d6cyMybOBZkjTopsHArbWNQsv+K91jpf0mi5TabnHHVvQGD4b/p2nerqc/Wz2J3W9eUo2MrelaJ1OUnU8Z0bB4L3FazhXy3yY/5O2oMpERva+fKwdYb6Ic9LgVq+MFGZPWpYvCnxPf/8pPvDge7h4aAY/UvDf0caAFDrJFO2So398dJIT4MdVAPEnEniCFV62XyKPfTmweTfoFEgq7U6yW40yg05c4R+b4D7Z0bTwFIWygI+4WbFAq5O7z9MuivVUWyDb2L5Hb1hhxKTU0aKudlPg0JE2kiLfvhgBgapYqqFenFmhZkg01Ka1YO7CNuBHgDT5xv0PG0CXB0bpFnRsQa6IjcojmhS2qHTtlYqtHGPpkXD/GUnfmGeMyndkH1czEztjbPoR09n5ntyQTwBmrsoFPcCt2t4TlJ9cri7PPBW/JudVO4KEpmjpfgwToZKg4VmAiw0WoNNZNiyO9TkRb9NDCiJdar+V2PFgcwL+zluD9ZfNGTbX76gaeBOHb8eKoz81R42U6wfgxvJ/M9K3ZaMjt+vczQvarj0IRxXb1/4anAzZxfXZNv19+51X0k6MZmPjRN/+PPUxw4zbeFiR6Xe19veL7oBt0usvgW6QHwiQ3dYvqTnITeJkUW0imj+qunH417rOIit/IBjaIKbL0uCW/QN9IvDbhxp3vkQZolFCMt7Noi2t6gGT5YS48zOSTRLhP+cCikQJa4ceATzSCVlWt3e6rRpfL6QZgrtUwvJQmYZjsS9zYQ0QgJlYYeQNpuwXCS8Atm2XEouWg1hTw/eoTT/MHp9CcVHcjSHw1qtXucRRIJB0o1XJ9Hdj59Vk8PMqMnQ3ZlRCTxRCarfkuYQa9fkT/ttSKefBrZ4raKn3MfqXJc/7Ks8l5aAK0IgNysVQZwW+PcGDGPizphl2alVlzTHS9yxQV6AfTNxEOuQCx4cGIOQrCgu3NzOPmOvFVJxxw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: da4f76e8-95f6-4c6f-a473-08daf86940f0 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:17.3925 (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: q9BcVXOAaLGaYOvN/0f3MFNx7yp4rrZW4nm3p1YC5ilGblvcTJxHdu6A0b+PtxT+BMD+Ta8PSJtBGBNN8RdIsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7861 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 --- v2->v3: adapt to ETHTOOL_STATS_SRC_* -> ETHTOOL_MAC_STATS_SRC_* rename 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 3b738cb2ae6e..7867ca85410f 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -2024,6 +2024,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, @@ -2031,6 +2039,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 cbcc457499f3..535512280f12 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), @@ -2623,6 +2660,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..f660eef4a287 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_MAC_STATS_SRC_EMAC: + ocelot_port_stats_run(ocelot, port, pause_stats, + ocelot_port_pause_stats_cb); + break; + case ETHTOOL_MAC_STATS_SRC_PMAC: + if (ocelot->mm_supported) + ocelot_port_stats_run(ocelot, port, pause_stats, + ocelot_port_pmac_pause_stats_cb); + break; + case ETHTOOL_MAC_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_MAC_STATS_SRC_EMAC: + ocelot_port_stats_run(ocelot, port, rmon_stats, + ocelot_port_rmon_stats_cb); + break; + case ETHTOOL_MAC_STATS_SRC_PMAC: + if (ocelot->mm_supported) + ocelot_port_stats_run(ocelot, port, rmon_stats, + ocelot_port_pmac_rmon_stats_cb); + break; + case ETHTOOL_MAC_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_MAC_STATS_SRC_EMAC: + ocelot_port_stats_run(ocelot, port, ctrl_stats, + ocelot_port_ctrl_stats_cb); + break; + case ETHTOOL_MAC_STATS_SRC_PMAC: + if (ocelot->mm_supported) + ocelot_port_stats_run(ocelot, port, ctrl_stats, + ocelot_port_pmac_ctrl_stats_cb); + break; + case ETHTOOL_MAC_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_MAC_STATS_SRC_EMAC: + ocelot_port_stats_run(ocelot, port, mac_stats, + ocelot_port_mac_stats_cb); + break; + case ETHTOOL_MAC_STATS_SRC_PMAC: + if (ocelot->mm_supported) + ocelot_port_stats_run(ocelot, port, mac_stats, + ocelot_port_pmac_mac_stats_cb); + break; + case ETHTOOL_MAC_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_MAC_STATS_SRC_EMAC: + ocelot_port_stats_run(ocelot, port, phy_stats, + ocelot_port_phy_stats_cb); + break; + case ETHTOOL_MAC_STATS_SRC_PMAC: + if (ocelot->mm_supported) + ocelot_port_stats_run(ocelot, port, phy_stats, + ocelot_port_pmac_phy_stats_cb); + break; + case ETHTOOL_MAC_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 Tue Jan 17 08:59:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13104363 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 B4BD7C6379F for ; Tue, 17 Jan 2023 09:04:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236292AbjAQJEJ (ORCPT ); Tue, 17 Jan 2023 04:04:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236079AbjAQJBp (ORCPT ); Tue, 17 Jan 2023 04:01:45 -0500 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2079.outbound.protection.outlook.com [40.107.13.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29AA3193EC; Tue, 17 Jan 2023 01:00:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f43mSEieyKuODB4HyygA6FpIQB3/XP50NaxiuZCWqbQuHTz+LmwF1xlv7dsDED2DoYWAvq5KIXgp2S1wZdBJmymcFhbtYUfddZegF3URiik/iWS4wd9lmGU1ioIGpBjozgTwLaC1c4jTpoXtCAkxLAMuelLXziaGrLugKr2NSsv1h8Q48HzRC3epRXSi7T2Ga2u2jpySAZOpJQnIU9czNa/CCPiD4Gr2ScWvrx0CfPM+MnfnjAHvddRzf2qIHnj+TWf0wMvqhR1/G1RB55S/LYdT6kL0YLO75ehgtawdqWP/J/UBiWSLEqYpxFsSnv3h41kBwjikRKWn64Nj2YCifQ== 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=AmyJotyTpMjPklNgGEG7PhEyo4Tgtlro1blhRtB3Rqk=; b=MmGOMDHieWTOgycJTOHt5pJ6hAFCJN+InzE32zX/mnWiJstvPMksTE9cgwdHOsiUdi2fbrNOafVAlEjRBkFBkfVJDFv10i7Axn4qgFuCDjR6uTUixVHYjYBoRTnMpyWPjEJ2lQskbkvVJaXCm45rRNFaASycChItH8A6WRPokemd9+9DbB/rw3PCmqHQwOk2o2toDAcapszXoA8/CTZyb60Ot+vEEZII5zfFeh0wNqM1XweZGO+cuzZ8gMihzTtN32y3wrnew8aKrXODZM7xQ2NmN4IUXiu9zxoaNKjegWFikECqn0hZLWoKrTtycN9/gUFL27weAbX8QJUObSe11Q== 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=AmyJotyTpMjPklNgGEG7PhEyo4Tgtlro1blhRtB3Rqk=; b=U1V+zeu51Qmb4yO1J1MQyZ+vaOWMJJgEbSPsE5PmsiTbZ+agpXp5LAZGmyyPbwwL8tznadUw7QmLBaf9HoqYKnUaLLFhu4B18rkUI2cBVd+wM079KZLfMs6mNo7DtrVEi+0PPetchyrhFh7IHh3Ebh2iZ/YL6w5ncd+yBdyKR5I= 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 AS8PR04MB7861.eurprd04.prod.outlook.com (2603:10a6:20b:2a9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Tue, 17 Jan 2023 09:00: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.023; Tue, 17 Jan 2023 09:00: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 v3 net-next 12/12] net: mscc: ocelot: add MAC Merge layer support for VSC9959 Date: Tue, 17 Jan 2023 10:59:47 +0200 Message-Id: <20230117085947.2176464-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117085947.2176464-1-vladimir.oltean@nxp.com> References: <20230117085947.2176464-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7b::9) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AS8PR04MB7861:EE_ X-MS-Office365-Filtering-Correlation-Id: ec807381-8d4d-400e-304f-08daf8694205 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T8bma1yI7ExTZI6PcDVygHwcsmP9LTyveCtJrJ4aCqiEp0VJI0QTWaEptL9G0R829zPBvdDiPHZ3TPjM4rROvUGgcybgwg9YfE2h3eL0slcE76I4o/CTe9sgFL5waQprq7VMn6OLFKHfdgzLSJtHEyEY3ARElQWrEsI4avVytgyYY7nHPZKiY1oaFyYjqKe52L3LxMOz4mvVTOozUVX17F2njY9VF6JhXcUAKdIe6dWqKvAdS04VHRc+BqIZ9TGAsxp8L2VQZqMIdU6MBCaY3yTdpHqgK3JQYJTyAKQ1yDUAj/ueLiO3544DP+miYeRKepdT/nuuFxL6dxorMzjGhtNcywAdNzHYmiG4X3nPbF5eAr6CcWVl8zEhoN2apQwxgD+cWdTGtjVHIus6Xdkeg8yRI2cvJt9iZiunS4oALFSxstXxZxG9n1rNbbmQ8OWkC84gxQbQwG2SjNRSJVIy4Ca7Ilzs8wB7Ur8cGr1UdtI2jS+eO+nCn0lZCCCZfaqMSsT11S+gRgPPZbhKJYPpap7NhlOZ28LdK55rTU9TWn1R1ALYnBWpYH2Mm7suMNDslBa/Je1gG1TVLZAV+ActS+JgKMsOL0CjXD10k2JgJmI0/pTqquaUr4bmW6gMXd28o6tBHtG8pYyviRbJAH86CzHwW8Rl39+LoQwiEtW5lreGCG9EhfeqqEXuqdkiTmmo 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)(136003)(346002)(396003)(39860400002)(366004)(451199015)(36756003)(86362001)(186003)(6916009)(4326008)(6512007)(8676002)(26005)(66556008)(41300700001)(66476007)(66946007)(2616005)(1076003)(316002)(6506007)(52116002)(6666004)(54906003)(478600001)(44832011)(6486002)(2906002)(7416002)(38100700002)(38350700002)(83380400001)(5660300002)(30864003)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I/vNqUP+uu0CLv69l9CnwwZrh/Zhz5fP8WPuAgBqXrM3+ULBBLwV6k98EvMJP7sqpzwXHaegqus72pXStLJ9+mz1nmYmsB9HeGhj7yXFHpbqvP+N3c40ZVA2qvohvXQefmtzAhzPDJvx95AUE/zbQDBEsiPIuaW29k2m6HVNgR0V1JPuO0PJxuwuGWaopqcr2kAQbP4CjHhza4WxIH1Rm5h+Gqcmpt40T81wtQL2sTNkulNxOY/kMD3P7qfVM/KetH/mYxO8x6WaaAuCl+B2F6gFv2FmzV/jfl9PkQ7WlNYEkw7epF70PLEvTvb3bHlHKkGcloRcLDkcYzhYYwyZFH8wnqkj62pRhB3R+cLP7/qnfSjG9SOtwGkmcxs5HYAxp9vfvHz8UgHtNyoGvna0/oXawBL1mfEqLBzPGGGlAD4+ylVZ3XXpGJjDdih6BsVicIgNqn328N3h6UrzfuENnluedj1oVYB3nFWejgFAX8Bi9Aan1HXh5p9eAFwP8+YEQ7c+s6SsUrfsCNtmTKJoyLly9NWxo6nhpgKcjfjPCSvD60CcO0gl3IVSOSCEeExWYDhIs2AIjJ9FKJWjrvtQJT3/mvu9SsVZuSjGzW4/DWyeLWB1xulcEChmtp4xh8kJTs6OospZaSnPZ73D9/vwGPsVncCrdua+EAYad5iWQwXabJdy3CIPmTduZ9OF9IZyWjZEiV98JWkHTOAUvgbFQbbM/kvG5N95/8dZUGUhM9f/asvKJywYclWnGjEISz4UEbOpaHNRuM2gYR1oDh7zxgldwWdZslFRzHsaOB9kkKLbvo22KD5jjNwHG+b1smywy5ErjN5nGgmfgA7kGUKIts0rLjLIe0SBuCR+LgIIofj26KP96RVwaURZ9eBpCnIbeMD5EIieEHVmH3MIkRlEJIWVUL6KUBouop6lVO7CBeoBq0D9RHwWh+PeBSt78+fxpBONWAy/ACuj4F7AWGQJnxEFk5hAd8cLV7SKezgvDb4gvIdpM3iBK/6szd52MH3mWTT9ktZx631plevpmZ/6jYUxG/26gsJjTXI+tGz1gorZmdzNZlMN0z83oa9tA6bwum1T72ygGs1XV1trd2NI3FZO1bmlmXX3SBnW3GqMhtkI9IXzAVq3Fmu5rJj0SqA0xFzmGPTLdYWP4DU1YjadZrOnYxOBfVBk2l+sn2oCyOEmWFwhZhmJorXP14XSJ+RKpQw2IUsyZyF68dg223mPtjmWRh9pyMr8jgPm/jl1GCRLl2AJdYoXwLsoVCGFiaj/DWnrgeSIsZYXZpOW10i7DLRlpEyNMrlE9khOqKJzDWrSW/NIDeeC0tzHMZ2/vY2+/7LXeetH7eKDtShKC8uuIv0NsVucM39mkLi4UI1Avo9B+1e2QllL5eN3MyDUdHajvHIIwy9lD/j94ez1fB+ifbVpkobbzd9zz5/jsxzHP+zohg9Bk2yhvBamH+6I+3FjdQ4mZpOuNzBZJF5Yujm5sSfiGGfRYyrfVBzCKQ+VUAxeHErbA+BsBplFG86XcE/g8AK0IM/ostaeFIhJOac6bjTvvhPVRQCzJrofzgkLNLeL9g33tKVWgAuTYLlDdtl1nq5kq+df6ajwZQsQVp8r4Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec807381-8d4d-400e-304f-08daf8694205 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:00:19.1580 (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: XUp6MiV1gNxboBJyO0dg8/Kx0Abq1AnoIxJ+xn4kgoM3oZAtYVj/8jiiFf2vbt242+okTyW0wR1oSWEC2Eopew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7861 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 --- v2->v3: - adapt to add_frag_size -> tx_min_frag_size rename - populate rx_min_frag_size = ETH_ZLEN - demote log level of distracting prints to debug 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 | 214 +++++++++++++++++++++++++ include/soc/mscc/ocelot.h | 18 +++ include/soc/mscc/ocelot_dev.h | 23 +++ 8 files changed, 302 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 7867ca85410f..d21e7be2f8c7 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -2024,6 +2024,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 int felix_get_mm(struct dsa_switch *ds, int port, + struct ethtool_mm_state *state) +{ + struct ocelot *ocelot = ds->priv; + + return 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) { @@ -2039,6 +2056,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 535512280f12..43dc8ed4854d 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), @@ -2599,20 +2603,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..fcec1a0fbb0c --- /dev/null +++ b/drivers/net/ethernet/mscc/ocelot_mm.c @@ -0,0 +1,214 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Hardware library for MAC Merge Layer and Frame Preemption on TSN-capable + * switches (VSC9959) + * + * Copyright 2022-2023 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_dbg(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_dbg(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_frag_size_min_to_add(cfg->tx_min_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(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); + +int 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 -EOPNOTSUPP; + + 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->tx_min_frag_size = ethtool_mm_frag_size_add_to_min(add_frag_size); + state->rx_min_frag_size = ETH_ZLEN; + + state->verify_status = mm->verify_status; + state->tx_active = mm->tx_active; + + mutex_unlock(&mm->lock); + + return 0; +} +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..afb11680a793 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); +int 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)