From patchwork Thu Jan 19 12:26:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107805 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 8079DC004D4 for ; Thu, 19 Jan 2023 12:28:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbjASM2s (ORCPT ); Thu, 19 Jan 2023 07:28:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230219AbjASM15 (ORCPT ); Thu, 19 Jan 2023 07:27:57 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2079.outbound.protection.outlook.com [40.107.14.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F6DE78A9E; Thu, 19 Jan 2023 04:27:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RaqQolBh8AArE7tEzPD2bUy2maxN+U4/PNftbLZMFiKZMf9+IXmRx9HCP9BaraL4agYJFsLovQDuotm9rYnov17fk6hntxLdhTKl0g8UykzQe2bP4OCZM432BmqESKa53nJQf0uZ4cljI6WfzkqmYoMQmVdSkmk+Am1MK2XXtuE8gLh3XsuhkHTeA2rvfZKyOb06KFDzQnpaT4IaY3dyHOTL51fAINbs83DtlZmb+NOXDSuVLdkLeCqoomSLxj0YNrk7ScZaWpykX1JXDUhd3sqonME5GII7RfrmaKBb2J2svdi8Fehhk4bedG1h2F8qwSdVzYtbU9dcLqEIJWSXig== 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=8VZ1bzQJWNxKiTHPMyICcY5kpOd9iIjikDdZvWhfQ2A=; b=Q5W0O8dBQ04yAYnDLBEXT2TnE6pZlT9tljuLFubeYPY+CkYf/xWmXSaAUkKJlyXWIfZ0CfQBLPsww+IhovT/2ps1jWKD1/n9oWM6KcTSs23xAF3VkcVNYCaoP4jDDzIBnMAsXy/os4Co8ro+40KomoVksZZqmwseEGMrxnHPBnfr9ljeWY5xfYSA857z38Ytubml0P9cIHqL4OveUDa5BBnY9UpJUM/7CRm6eayysoRFsPRj2oecIY+WGm4Yw1qSXmK9aQ/CtVWdgpmT/mit/i9T4ECWge4EiHjk7RhDSjLJhi72ghbUxrxSfc/TxzidGG1cO0FJSAMq3HqgByobAg== 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=8VZ1bzQJWNxKiTHPMyICcY5kpOd9iIjikDdZvWhfQ2A=; b=s9ijbTuX2BK3H2GehcVwTmxQD6echZYISAEkMW/BPw8vuWArhVD6FK33i+e+IhKR8cnZzhiBcCbYs1bqr6zz61Ogw8yCrDSJjIfkY0RuZutaxfqKqY1k8vERkSfy76/A4KS6dsVm2W91U52UMkwXoKsLGLZfZ1jzD2gFX2m+ywA= 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 PAXPR04MB9376.eurprd04.prod.outlook.com (2603:10a6:102:2b2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:27:40 +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.6002.024; Thu, 19 Jan 2023 12:27:40 +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 v4 net-next 01/12] net: ethtool: netlink: introduce ethnl_update_bool() Date: Thu, 19 Jan 2023 14:26:53 +0200 Message-Id: <20230119122705.73054-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9376:EE_ X-MS-Office365-Filtering-Correlation-Id: 01459fc2-d1ed-486b-b30f-08dafa188e20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C064C50L98v1VwG0X8gzLtSO3p6dID5CD/6b+bbIoStsIlDtQbc7BiHjp1rXilhJdWPC4BSFXWO9Y/c7Yn9QkxcUEVSEO/MHalLmbRuGs8sWuU0WdibamVz9TokgeIUcn+DrN3GfXSzzrJyR0c05yfD7I0zFhJPx9vGY6GM1BFX13uppsqNBYzw1VdxE2ZzaQiVRc8GEE7gu54OMh2Ni6lEEzBW/3IWH9DsIP9bzdWlQAd6522K8YY5nRv7GmbAAVg/77QQ8kqTIYEw3qBT3ohPAeR6a3EDDaMmYmgdLWSJNjPYxhpy+7+uUYQYTxbiE4qOdj/PBqDy8LOt9/k2ENONyZbgBNnXowiF/4gZu4XSsVxARuR76KQ8AMJNj9qaIj9DytdFsNuYBSQRS1h7S4C6tu7vM9GPMDQ4QuLbFlNQGDHMVUgjSE4tu+LqhZNfWXkJJmD4qrp9WW/wmYcUDvtA5XV/RiTGrnvZi6Jodx++uAy9S0eqnDLygmztgJ0dI0m43IAxJy/ecwpvgyHzKpQcqy+FTI4sjbvsb+i8AFdl04m+a/lAC17hkeKYYxjqS8ejbWRtT8Et3xqDi9oXndMUyfE+mQ2JC1FWRbQK4V0NC6Rxot5qnfrjBfunzEfOR03IqF1D5P7qhapzhh8xSziL5pSKcJrWq12lwV/tz6F4mHYJPMGlCQow30EXWueqoNxoS+GYzu8Pbgk7Aq+0vRVke01MQ/mm3RxsYs1TF1lc= 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)(39860400002)(376002)(136003)(346002)(366004)(451199015)(6506007)(66946007)(66476007)(44832011)(66556008)(7416002)(8936002)(5660300002)(2906002)(38350700002)(38100700002)(316002)(6666004)(54906003)(52116002)(86362001)(36756003)(4326008)(6486002)(478600001)(6916009)(41300700001)(8676002)(26005)(1076003)(6512007)(186003)(83380400001)(2616005)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: t1O+m+canfJghtQVAeLHujY8/CCupuaf4TLLRz/yykjf/SNgbUxxdB6MQL5UOyEgNKZIzyZYIWCiyhC4+7npFDJxzBuCDZQw4OiR5NPkOJPankiIZBTu/upG9A2I6ndi5NfSei99nOlGllR9ndSq9z8p1vQTMrJC2d4lpEiyoAwJ4fcgd4koyhDpq4uXZrzYpM54r089wJIqYgd1Al8rqSqd0VjAOhuVJ3DpP0bgYmtbMBZypvZF543r/3AFKNVuPvj4k6CDLPBUKhmvJFST3TGrC1GE/Kko5O3JejRZct5Uav8lQkuTSPEh3wRlAftHLrdveBRSY5cnVq7j99ZXat7TLYa7AcxJOrT+acQUSu9DNtZ/pR7/6aYhxRhBw1hV8EOk8alzCf/smjrAsH6NrJFZqLbo+6fNzRkChIEswCO0bgJHvTpeSxSt3+FIVvM5LxxSfuZiyRs/v9V32IGxEaR9R3dxQbznsih1lPuTwpJJyzhjvWm1YmTC0uRNbRs67c1xaA7VOu1QT9v5vgYpWgw8zVFtZiG380T2wz6PsmGQYd71fIAb3HaMFSiJyNu9r0f/5kH4KGFTfodAcj9V8E79n8cD5ALWsnFTVqn2YLwbMqN6w9jXn2BtHoIJ/LpiD2X2HRIAdiEIN53mGMw+96V5decqXQxorDhvG9XpdH231Qsjec3ZYXXvOk7hXMiFIHRUlPL8MCpkZFe+tsPEPpHfKACFjOzU+FtAxIGTASNMxiBO5GQZ88m62GbOiQNfhSmhkHTEUqiVeUrdU5UiD2UvslqviNB7AcWeE4V6hF0t8Oa35MY9GHObdzi043VU0gTuXzHh/7hAj+d359uu5gfJT2iSBZPGkzBP0yND1UEi4zaWF2DTtQA3NafETctW8fP2j96kdl7AjnJQJmZvktnJ5idK3xxPaw9koFoRRs7lKWbzLX/l9SW6OOj3Sj1Y79lpkdDYfdIY/7hoVcsVZjc6uB69O0JBxjkv0HCg5MxtsF6VgNJq8YUJgL5lmUi7XwjTHc8MTm15LalbocCFaoAU/nUlC/6WkTDAEIzp0pK3zOhtTrIqp8RDbq1PCXF++Mg+a5f2AVXDOo3MFh3PAoofmK8s202QS5N9zVbIUv5k+Wz8yaHRY7DnoU5ytIUcQVuoYeBoGrFTM/FkSjqGRaTzO8iITPFwHLcWOEj5LKOV7eo14catXYxVXDFFQqhwtiotNSxQmkpdmC73h3osH6jbtHQg/mquccKuTxtQSJr6SyiDvaNrOfuxAYz8rX3HFFO6tVjJeLL097ZXU4D4tGAruOQzsgnF7aiVT8+Vd3zuEqBgxoCxdox9NCkSRJCsDuiyelOezTpXIrZcYoAXHPA1/0oUGuSYGc7gA/k1Rp6LOMeDdOJ6UUklSZ0OTUiE4KTKNBiWnySFBhKvFbrYYzuRpVlkom0VRYA1UvXaAh8aTdXjWHuddwiB5p7dNUJ3Yob8MXZg2fpT/n8A5NjTN16Z4+PNzAuauUmxJzs5pHVtT2YGuSQN9LxXOKe2Stwoeut9wd+p1xuAT8EKC9JQHDtEpu1u1rzTOHIvvOMWNFeSG3mP+db1dCSXvCofOAhDlNkLoLIAhqsJdtYh0StgeA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01459fc2-d1ed-486b-b30f-08dafa188e20 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:27:40.1700 (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: necYRrzVgHbALeF4mNyxezOKvBtIGf/Whs0+FEPH9W+6iF+cqLI2ul0YL+AoWztDpEp6KGQYNXIM4iHPhOTFxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9376 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->v4: 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 Thu Jan 19 12:26:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107808 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 ADBFFC00A5A for ; Thu, 19 Jan 2023 12:29:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230215AbjASM26 (ORCPT ); Thu, 19 Jan 2023 07:28:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230146AbjASM15 (ORCPT ); Thu, 19 Jan 2023 07:27:57 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2079.outbound.protection.outlook.com [40.107.14.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB30978A9F; Thu, 19 Jan 2023 04:27:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HO5Jl6CHBhdUT3DqxBE2/+3cYljIWMj+vQA5yNWsOeuNcRe1xy97+ccH2Mz8VWFno3OkKpoLDOCby47u1O3qevL/eyySvMPMbtHbmHTWIsdQIhIJplVZFQ6bRbOz7sNxWyCr6ogzhyPP3OBAOabNjf0Z7cDQfiz8qwXzxjutCZI5tAboK7+vz/TWZorFDOLEw0kLWJ2FCBw08qTuZJQC+Bo9gHcS2wolnCnPmrP6m5Y8z468zkb+tMhlz2vCh0N+zDHP5uNk5z0bNT1ZiDY7QZ58jBga4j+SxCAao2nlDVBMkP4H0NgcIAkA6lJQ+cCnsvkHDQP3Y8OnxgMZtt0Rog== 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=pDXQTGJqz7UX0bvcFlBJAOVkcTZxBZfCbVcX3m8xa6o=; b=LCQppRp+bWO57YC/sEUGNkQY5+l9vnc4Zmw2MHWhnmkzg9ujyxxvhu7v62mvCuHXyyPH8N99H8D7DgApfHt6iARBK3S0HTGa3yYL65dJFG+OuO+UM7uKlN+vnHIzcXJPu8F7A5+Ktzs1MLACoiMZb6tRFmnsrdu/kBp9n+piDKX7ZckupkM0QHW06lv53AIaC87RlCx3UKq9b/LdYv1ahcCNzTS+xFDCzmpnP+WDCPaZmwbKRmeUWwuqorStsYgoYUUSiDvSHD4Kkbo+XasfVQk3txzr0/ml86RI5Cayv7gkaHExymAjzYGyUpbzCq9QGTZuUOP6cRiXezgXD3JtKg== 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=pDXQTGJqz7UX0bvcFlBJAOVkcTZxBZfCbVcX3m8xa6o=; b=FU/qbN8gEcHKganwzFWy8iP1lXgXI1h/KJwRcvgwXHWHuy4t9hngEdmxkkgSCdXKqewhmQicm8LaZgeySp2UOhIeYmQZ4Gl37BQkdZyGDSB83vTU9m+OH3S/hZTx32NN6vwHLyEZtCOIrtCwSgKcIQjXYxWXjRZFtUsm6ZHSVLY= 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 PAXPR04MB9376.eurprd04.prod.outlook.com (2603:10a6:102:2b2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:27:42 +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.6002.024; Thu, 19 Jan 2023 12:27:42 +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 v4 net-next 02/12] net: ethtool: add support for MAC Merge layer Date: Thu, 19 Jan 2023 14:26:54 +0200 Message-Id: <20230119122705.73054-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9376:EE_ X-MS-Office365-Filtering-Correlation-Id: 20a1e63e-c63a-4a5c-ff77-08dafa188f77 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OQatFh/1cUu0KoseYP123LMoZ5wGY2VozBEftpdN4vMNFQneGfpb2jnZwwPBuTAHbb3+Z9ebdn9AH8PJWe9qgWommvkFElZyp9IRlkITwfJYzs8nDjajkG2GIRdx9kWIEv3Uw68xd0rxNA1jO0jSo8hrApuKez+dybOGiOeA6+JYuIKYZKn9XbHi7F42zSlos9m1tUtD6asPm9xQ8vD7bNBVE6RI8ndZgNAgUGU8N8wzY2YK9yK4Xe4T5uKFK0dEVPwfqlwdEV9HgLDB+cfhyPSHn4l5JQxiYJQiTitWF2OIcOG+VE8QsUFOEylvM9Kv+QylKhY5RK3Ovv7FYIlPILhQw1E5xkD2OhZ38BAqgNShOgvk+qwdeBetgRXufKLLNBsp5Xng80Q/5VQQK92waQnoSo8kvkk0qfAcNXdQKzWwEQOaw0YuA+PCC3oHyubSg5696+XVRFcus6qTbXPYo1PgnJdbXHlijqCMfcrohRCln0BACp6IRDS/QcOVUEttwG9H8CAvcB0H9RF4RaWbWm4lRN3NKhGlG5ejmHfwzvaQcpc9Q2sHs1841shHRFk7tVLdIzCNLNVyuLOEQROLgZ8dt+wfkIlXXopOMAir3NYruSVRBvS6ds+5VdoBjOsnj3vsoKNwkBqCsLS8OJA+2GL/eDQP3ApWZFaealb9AqzCWt6GiSV8cADw+trDx/ukOl47bd+A1nI6aUCoe1ZRASSayr1B4rXrb5Kxzq2s/Ao= 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)(39860400002)(376002)(136003)(346002)(366004)(451199015)(6506007)(66899015)(66946007)(66476007)(44832011)(30864003)(66556008)(7416002)(8936002)(5660300002)(2906002)(38350700002)(38100700002)(316002)(6666004)(54906003)(52116002)(86362001)(36756003)(4326008)(6486002)(478600001)(6916009)(41300700001)(8676002)(26005)(1076003)(6512007)(186003)(83380400001)(2616005)(134885004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qdlem1iYWE3mGHZJiM7TdqTM1IHezoiGSVOVCpBQDhxK7o7JipNucKm9Mn8mDyAwnfyvu6OSEm6q4yBc1NY6MU7Iw153dVm3VkXbP95yFzMB+VpDmoHzKSJT/JivKF7xaV9dVXj7aJCurNy4eL92K3lMHiPqOWDjgtbK7PAcQfDJKd6E8LRkoX8bAGgd6KqjjcUTzncamC6WWXon2Xl7FaM5vWMQVHuj28TXEdG/k6OyAkiLU9X28EEZQVFouAb5jsJo0kZDXTeXEM2wnlgMVd8Q1Sr7XrugVoUZNlgdRFLh/rQnVMpyyP9Y/KDuMz1Zyf0/R8ddpS1jC7wGQ/2DEqzU83PeRhuNznPCpfXFrXW/+uVXmlh3P84K/cUhE8F7rFj2vSpX9cTOE6CS30MrotYbhtXNJk1wzrMr73TfOjAJDmaQAHaCfgQBXuquelrhznpAmGdm48G6CIdJqOF1X/BZ/O7GGAO3wxX0f/PHndmAnD6mdqhNE9x/jjqyIJ7rkt5es29AdKyIBF3QvsMUoXCF7tk+r3swXus0yokpu323fv/ph/EzOkYyxCPHT3LB4YR8riQHVMKhzDf4MGxyYYqDsYRPCGfmpCD1J6lDypYfvB90teopsitfjNnTsGQcwRL8dtllJf+JrEPSZpnr3VRBoVhnwgeNuzy8XH5FYPV/aLecgvmcM4pFuHzeWrgMKT6lwfS/YOEDTRZZ16H8AMJtDSm6Kwhn51jvE0qddgXqYVW4qnfSwLfaxgRE4SH2mNG6ddzgW3keNRTu2zAGGaBoOtH0MwrqElEXuxMnZKBppsUNjPBm9qIMzRG7OBs0rgyeD/HZ8HAmxAdtBY/iptR3XQ96LTVDfFkfqG5jxBAGPZC0s76RuhQ2hGj1C+SlWMXXBZd/G+9fv8pDwm6i1yJ/zBHPPyLaDEwkLgSEcbjlVe4Gly0kT0wrOISX5/jlsrfJFBCGn6K7BCbJUG/ZA43fz60CxFPnowasTKopwFFR+9lnbRszTLIBLi9X1L2pDB9y4QuDCqNEU/i/ZQGHrvmMJ8VAoouv0tjeKGLzZqguYyS5fPpq3zpfQUQu6k/IkbELe/u9skSSa8xmUy5AYsDvZw8uxQrGHEK98dH4OJ0qWCV+fi1zMBhFb8AY2LTGw2ivc3s7qa01RRM701GhEMP13VL6gAYHBPmCq0KP0R+cD0Tc2/85HsyiNHkqywAZVaHDdMQMB8pEabQZ3WP4LiecwMFWewsItXll58+xtEbMvf9u4Y+o7dyQ5g2GtQzJhRJGZDvMh9hr+4TliOHJFceQfuGNq9F+W3P2D/NkEeX6Bkq+y7eoqow/w9JgoSESp8XQbaDEONfaE72gbAuNMxwbg8gyfxfhsQw/AaRECUXeVzuDzfYud/052SqI2ND/8erT7ch+U+sjFjdDgt9HiKDKpsIfZmxFnrdWpdGSHIU7ai0+eraBdumGhHB4BzG48IwsALiXC3pU/xDL+bdidcJRRl/NnbEUsOsdGVFCoiJUGVbiN75/bkhG6BRsUlX0i8pqkYzJ8SYfiDC4KohPcTjjRJYyJkzzENluD3XluJTReUDZ9V6cr4pTn5erLnE/WcMKCxWFp5pNQW1GnLCE/A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20a1e63e-c63a-4a5c-ff77-08dafa188f77 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:27:42.5761 (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: 2RR35y+5RTka7TYYLn9mVv85SNNM8PO9kIYF595GhuwBprl2vRmjgng/SNc++jluQAIRgpv0Q1oA2Qed5Fvk3w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9376 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 --- v3->v4: - moved cfg.verify_time range checking so that it actually takes place for the updated rather than old value 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..76b209ad53d2 --- /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); + + 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; + + 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; + } + + 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 Thu Jan 19 12:26:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107806 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 2F059C004D4 for ; Thu, 19 Jan 2023 12:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230077AbjASM2v (ORCPT ); Thu, 19 Jan 2023 07:28:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbjASM15 (ORCPT ); Thu, 19 Jan 2023 07:27:57 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2079.outbound.protection.outlook.com [40.107.14.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72D801BE7; Thu, 19 Jan 2023 04:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VMQCE4O4K3A8FW17opQEeYO0tfuQO+NqFUHKyYF7gPU2mDlTiM1OMbQbzPcNMcbtCn7aKNClY7xAxILW9f6Y+PCqnzzlymWFl4gTC9lRIT8+NVPm0oXiNDMUPj0cal1CHH0uUue1FkBioMM/NOmOElYL8RNF2UDtbXXBm6Y7shf8bPt9b320vxrItdQZGVmspRiEtV0jVgDp7keWAuR5sdKjnx1ZUd5evHvQoQtnU8uE6OLroI4MJwnctmfuoFoJQDBXNVK7M8k4hWPYiM+WBFjPO1jxY5/LeyTsPXbkAVLuz+/rQ9dRS965ywB6OkXWY50wWsOXHQsXdHILrzLPag== 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=NxZXkwtN/X96R3TMw9KkdVjlgbAtG4c9L0u/i8kgzRM=; b=I7K+Q3F642eXt7TTPjS0zdewa5LkuZCJOldEEMv5qzNuxQZ62o3UPuu7A/n7iDBsZ5D/cXpLK4TaYnH+5eNFnhTmJEa2f/3Xonsob/aFC/tPPtZDRc2eqfW83WsbZcyVd33SRnRh/2Rs1JTVqbNDJE3+zD95xLo4bkaUdhojmvM3bvSJwF6O3NNQ0kwhXjHSSu1gjQjoEpZcTbd0Oc/fbP7JOcXM7/q2qJZzRUbfTB6LOXzI68z9FtJYf9rB/VoEtvDT6JchAMMIRHW5RTQ+Y+iZlIRfNCnKlAMeRiHm1fpm9iBtpFAa7IUjC2lkzXMFYA+b5UN+1vag9mWaadUnSw== 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=NxZXkwtN/X96R3TMw9KkdVjlgbAtG4c9L0u/i8kgzRM=; b=MOg8DsPxZYmW2l5QkZOyu4U2Z1SfsmmmXIYIcHtgWFvoOUpgkXP1R9kXWrpQf6uShPNOdUgga0b4OewlPadaWMJ1STCoEeb1xm54GL6g/MzvlGqrNR/MY04RGP9jaqzSnI78WRae9K3VxOR+Dp9SUj2flGGFag+vk3SQnUDyH3Q= 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 PAXPR04MB9376.eurprd04.prod.outlook.com (2603:10a6:102:2b2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:27:45 +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.6002.024; Thu, 19 Jan 2023 12:27:45 +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 v4 net-next 03/12] docs: ethtool-netlink: document interface for MAC Merge layer Date: Thu, 19 Jan 2023 14:26:55 +0200 Message-Id: <20230119122705.73054-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9376:EE_ X-MS-Office365-Filtering-Correlation-Id: f620746b-f85d-42ca-aa41-08dafa18910f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u/DcpD0cFddEfSRRndlbtZ/biux/FkUe1aNcqK15c22omi1XvsZXanh4xhZS5G8dAk0/J6rvIWEEDhOuEQSiICQmF6AunbFWItR4t+uXOfwcnpkRD+JRdUtgMd91ZXBnKX7rS7RPVGcGtGuTaInaY7PK15DFpWM3mU/VVOHm2XCzFwVkMYh2TRgSky2ZjPCMCWUtAB9lSa62DSwKJmLUg9XR7o2s8d3L4DYLkRMGtcnSolwZ6EGMDAnF12mrg2xRQfYDuz3RnZhOTnAtD/f6OeuU+wK6yb4FcC+iNiJJqQHsxxgKtr32f7zyZTrNK/baTwg6ipxrUNEknN3YRngwkccfRjOEYepDzxX4/nSRgDxeSgguVFjuSBpFeS+wGHGEKiGlZjjSxlIhkr9ackj2T53QBeyZRQN+WP3qymEoLwWxV/C8tI/YA5WPHq23irlL/Mg4ldjP1URE3ARrrrkyTjvyUO5Aw91vFgUo0z2Amry6xvYN2rAG4JfOmKjEQO8By4Y0o5H9EIHOI0bFhGmz7g4HX0ObVR0gvXN8J426nDFbU90144cEmfad3/upXi43mbik91QekmhooPDbM4uGAwy6LBeQisKkou40jD/D2Twci1G4cVWzpaHZhgu1hrUtS5XUtDkr1/Xji2jtozrKFm2NxnDlyxHSLDGglStBba9ZDCkTYvFf/K5Q0Ag79G3iJOmgpUxkIlE8DANxp0bZXw== 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)(39860400002)(376002)(136003)(346002)(366004)(451199015)(6506007)(66946007)(66476007)(44832011)(66556008)(7416002)(8936002)(5660300002)(2906002)(38350700002)(38100700002)(316002)(6666004)(54906003)(52116002)(86362001)(36756003)(4326008)(6486002)(478600001)(6916009)(41300700001)(8676002)(26005)(1076003)(6512007)(186003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p4t/hMFblKtxqPTp3yyJ+tY3qfL2A5QkwBY+WLvPfevxeu8sC+qmQ2rHduSPJ4rig7iC9djTaLlCyzm3uN3rGXanMJ2JOJLboVIvrENSEJrJO+gzMU7KghK9BePtwkJK4ngaPc8G3QyNQtT0PuiYOHoadgM9Kqvex+/ANpbJkHb4Kfks3kstyIQEq2GdOMD4HECiLsv3SRAyssmUzJpdQEKU8QPVcEhDblCC9mWB3iUVE6BWOnc4LmWWDt9CwaH7KIMmxYqviXlMjlQcDJDY77Xl1tf+QcFE/H6AU6GfRm6aGbbCUnDp0wB1TmeJwPLpJZkgVzFSn0zQfriHCOk8e/7epmhgk6cXAT7Ip4gkynLhs+k2K+/P0Eg/HwHXY5iZ7hSYtOrvFD+eYsDQJTdlrWLmIadH3oKziFxEwXnI5+weuTByIBVgFjF2nrD7E/PjlYoZAzzKVesQX8Qhq2emx5otdxctlbppWd2tanPsbRnwNrz2Cm59kOi/INt20orBnAKVjSN1HM/IvZ3Wai01PL2dnTTD7nWT01yztfxS/c3wl55daIXgvGGaPNXgctj3CrsJ8CwI1Url92DOrcgD1tuqelMpsTpW/1o3NGWPCwa1tmSKo87WUM4FM/XV53+rEKXOaPlSlNWAWN29p857JAkQf9UaKdlM/13Q6egd16baOQ8oybvltU+DkqcUtIKExu8Ho/11s87pxTg73BrIDRfdFtH9fYVe15yQOjHG9sBkELDBeZvjFRn42X72XMQkLCR8cj31uL5OC5GbGjY93vtSXE56O59KL8KkmBYmq5vmB86J/bKzMgWS8gDzyKDk0z1j44Tq+j7SKbZhteK3J145MY4N3vksC8nWyUoHCeZi8QDi209r3XAhDQn2IA5TSOdPUMDvqL/YoP4i1TXDcNY62Plq6ov3gn8hoU9L4t1nOxQR6OjGLGW2PvBncN5/P1C9lCGdDbjfHAO88uiQ8VvlU3mvBp9YEqD6LvQa3/uN++K3rFXWnel153CCodk1N5HCzNxx7CTdhrAtzdvxF7fYDorDtlIcrk0bllXBolu05VhQLffW6rNriYCyguR7agXdw6gPZLbyklB3bQchK4BXZ6EFrAiG2mlLsoXy9lf23MMaJrAlq2Rf/RzVhvP+WTB6Z+3SCtclWDd9rfQ8mxMcoPrQnQn89wQTXAElH56G+f8mdzahnI9YJcSa+hyryTAwDDnDUHZ/1Wv77CjYEqs+gOtbzqQi5/7eWpIh83tuVVlHLeGlHwMHLpBHFYoc5w2QjFAArtJhrQhN8NBG2QFVa29yBiZR1huZmr0sN9pHLG7hfRVcuAbVJjoiAF6nMOhaADHQlFJM4r3SdTmX9eGdSV6nqRziUeE+x5lb23Do2CjDWWcN5LacXle4WPG1vtBPItisC3dBojiJonjgfZT3cy7ECIvKPOxo6Zwm+4VBaNyOoMe69Ndxk7Cv3RbfxCmtNSh4Stf9BJ5xpcWWLi/wUvTvdlASlQJNwZYd/ibwnTTvOMDFgox/QkydajitamVRyqPAPXgc8VbMVCVWyKvh+eKjVHTBbTIdtM7yhgc8b+otghDQddFbwWMDWALxRI6GJXgGzx7yeDUgyP+SUw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f620746b-f85d-42ca-aa41-08dafa18910f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:27:44.8884 (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: K/cMz6HcywOEQVB0JHx0UXfJR9NU17iZM18kdD2PKcbD4QAnCfncmg42V4Ds6kq45T4muupRATxfT8GucdI++w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9376 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 --- v3->v4: none 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 Thu Jan 19 12:26:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107809 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 78975C678DF for ; Thu, 19 Jan 2023 12:29:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230329AbjASM3B (ORCPT ); Thu, 19 Jan 2023 07:29:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230240AbjASM16 (ORCPT ); Thu, 19 Jan 2023 07:27:58 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2079.outbound.protection.outlook.com [40.107.14.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D746C45F75; Thu, 19 Jan 2023 04:27:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ehAY7P05XeWdYOQ7wfTRY5KwhpPrwgqRsy7JcUD5uTIjEnS8zqmTfbwvTj7A10jbBbr7sfr4SofjhSETQiI+2Jj/WqrvXmhKLo0RyxYuUP7FW3o35TIB+gIQzIE4YEbiSvCd58pgz7Y6odT89yJREYEI4TS/oV7fp8FGPPA6dadj7bqTLHTygOmrAc3PLWqi2rj4NtP/hjndJ1NeufEv76kK+A8YwZWIZ8T3/LXTyKGgRhk1TwkcPf5HItM0oJdKeQ5UykoB8rdG+icaoLb8CKbhXKx2AvoCGb4dg4JYvl0FL6rznfzDuU20b1ZHXG0uZSwIMvON6GoN0C5yeK2l0Q== 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=si+H5qi4gV2od/wVwdQ6vXelbErQn1IhBuuyhQbQ7KY=; b=mAO7ZQ15vgX4I+ZXfhgj5imJ4lJah1MgTv75iNAG3N3wmFKa3zagZI7CAkxf1HY8tej+ux/b+1nM3pPgV7uXEogImHIjgrJgnqkmxwq4XPnokJJn3yR5JAJKbbLtL78sryiL1J0nFjtE3lAoHDdCxa2ygSFTNmps7TVD2grnVHZ8nPEkvD8Ikp1QMU6+5w2xAtOyu75FLJVNtOHoM5XctEjrO0/TXHW+UkPTbKTjKrN/eP9daJwCGqBEsRIMj8giy/KO5RXSEtLknFVT5WLl9moD5IICFuc/741I9Wb01IhsRtiTns6yBAQqrbMM9MYZT0xYnto5q8ZEEbokLqUXYQ== 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=si+H5qi4gV2od/wVwdQ6vXelbErQn1IhBuuyhQbQ7KY=; b=Ln5nirgqmd9BH1brUKMTtcnNrN3zANrUhRzkP8AI8gKzVZ6JhWSDLvA1+z9rZg/wDaqsnH5NRVJGvVCbX/9ahxWaHZctwvsn7OFixf4p1Tm8W+kKvSFou3nugukN4oginbQy93ujTIMuT5HiMxJFqjtyG6yp53owf4nXD4nEVEU= 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 PAXPR04MB9376.eurprd04.prod.outlook.com (2603:10a6:102:2b2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:27:47 +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.6002.024; Thu, 19 Jan 2023 12:27:47 +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 v4 net-next 04/12] net: ethtool: netlink: retrieve stats from multiple sources (eMAC, pMAC) Date: Thu, 19 Jan 2023 14:26:56 +0200 Message-Id: <20230119122705.73054-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9376:EE_ X-MS-Office365-Filtering-Correlation-Id: f2021e81-5527-4d64-3411-08dafa189243 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8ZqtNnpaRnE7Zlz9HtEhoZLbnhPNekZOWJzlWmNo15IEXjmxgLR4bK+Cpjk0oVI5aoW1SXxkYdJK5aTGUQIA5wRClK25xNz9Nw8zBMRN6vD6xK30pNliNFq5PxjQQ4iNw3Ecd1VgscN+eN1viM9lFeQ0KNWVCnkt3y9K28HSh58cZ3g7K0ML8yrWc+rPnscUE/UH2+1oSfK7xWITKopE7sCh5wQ5o2IjmOcHcYnHncGgUx6yWixSOFI3VCAMV7sSFDFltMaTW93PqRnq6joqg1vCvOwSXEfGSDZ1fr6wYKnm0Mank2avYxcEEsK4kpeEMXuYsLwqKM9upnjFETnjJJG8YHnQkSqz4LOsPpRx6TEKCZLp5Uu7rsP6F9QQfQ0AT7lah0HDwVDytvVliL/mqsKnOaOEf075b1qYtuj0xKDUpa+U4DEq3plRF89O3vq5qarIKWJ2y5l5jjFP1tVqN9pSzjBWACYw8Z16n2xXcbidhsttABWjfrgBJiFomdoFY9LycbsAbTHVFKn55QAkrVB4+9YoOKvVBnPQPmOmiYPlOPflEmy2kIq27PTrSvQanjojHyfyzCd4IWoM3VIAVNEiKiE7DnQpiFPFCVjc4XZemLhXYV60z+XtRu3khyZSELGLOHkVscECHXi+zb37EJkx6xlAr0xMB3mob/0wYdma750VnU9TSgPkj+WCvmglvDdTwA50dm9H2MwDi3PvZ1b0U6AIc7RXOLEXMlcN8IWF/eK5mZ2De1xXX6qeedWr 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)(39860400002)(376002)(136003)(346002)(366004)(451199015)(6506007)(66946007)(66476007)(44832011)(30864003)(66556008)(7416002)(8936002)(5660300002)(2906002)(38350700002)(38100700002)(316002)(6666004)(54906003)(52116002)(86362001)(36756003)(4326008)(6486002)(478600001)(6916009)(41300700001)(8676002)(26005)(1076003)(6512007)(186003)(83380400001)(2616005)(309714004)(134885004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CgHTQM2EQVeHnaRk1h548mr4OKIYHwa4ZaT57IN8cD3nLwl9ne+z8HLImNHRUzRZPgdBFapW9InqJBsbyZnwkYjWLKNIG8+Ax93sKcNPW+CSfONKkPicAE8h2brdB0jbxl2bEQNVuKQU4D1kcmVe4bBdZ73m3Ost3Cdc/q8SLhXvBBb/VCzMhiex74wklbrqVKnO+g+JiU8m0iP4rwB0WYmpLt8/4mHZNtaG64OsP8foNSGNmN/heRmhFuC20TdNa7U7lvdoPU/7ufzYJW7Gp4ViYcV4po6ff7gHKibkZ4AM7uhdA7iLuG8U8kl0vT5NYkj7JEoGQf7R9i57fBD0lPKzGFUXRmMBfxbvRtTeUcuf74sTzNR3PefBPwDLYUCacGHRXHmtwjmBhNr+Q8TzYFrC6JOqfYy0/ivxV7+h/WD2qnqv9/dskqLRgmPVFCs6w8exr19YAxEG22FlZAOTGmFlU9hiv/EEEOUzYUAS7UYRRBH4gRySBpUOcw8IwH7KIwpzXKGGMThSkS0KdEhiccVulP/nYkkd8WbrYC9xEIrKbXwylTbAoBk27ZArWs5WKo5t5/hxT+Q64pn1Y71dfPP2KZNGj8gNDaC+90fAerUay5KbUmlClY1pL20FyTtoZV/dv8ne9y++Ij5LavXv2/1yQzPgTK6nQNXFjkXYZL5GfjXRR18McMwEBJ715qTVPNd17tVrXBPjTk7zQttz5MkAHBwtLjAMTt4WFwbJgQzq9InfniC5rfaxpGv3Y07/FyJs2KY8ZUvtIWs9B5VUid/VVy48bzzqHH4ZSHvyb1MStow8ScyfXb6xpbwaLDmsZfPaL7/3WZEv4+UIObP5SFY/bq7oUKXoRJJC9QUBCK8mZ/i10vgBfj84Rt6V3kipw3yO8b5XcqwoezqAjBTdefoTsOSD9vToowFnraNpJQjuhw2XiIPuK4beC3Ur/hL4suf+YCIPoEl4Dcl/WY33LImmH1APS/Ow9QN2tgrTR7ff7EXofaYEBQlGvBQDVm40nj/Pr0J5d5HjhepZVTNdPb+TQ3JEK/VYYWjiq9ESBHpL+hUpb1y46ItaJm//Dr+Wv5Qjg3FeV07P2xSA1VgEYwAAXeWU9eYEPylK7TJsT9yhgqQmaWToWyh7OuL2jQWeOqfKqiPXfv2s/eBPEkNgqaPpvAGLj/w4YmMDyioT+hmHjORS/2znnmc23S3ORU9tQ529rE9uWnEkTW+CiPfM1ulEBfx8Ucce+elWv45/EcPfCUQPDor1xq3uCGBcmYLLP1U7E+q8OyhDKHuYO2oKdpiTjVuHE89k83pCO2endMOMv1hlbywg8N4slw9GwuJhjC+YhsykS7M9DweRVVTxD3eMLWVC0F+lkKYZoDmAfyEm6Vblac+/fQde4bG3309K5MEX00sdFiAcxupTLOA7TpERVEfZ7tGbP7sLc3Oc5LXngQ+9B0c4O0ueyiFxIk27aufQmRot/uGcQ0MX3Blj/IGsDkF+JPSKTjRNsaccZLO/RrmUrCvV4sMmZYP1CVT/zcMXOk7dBTZX1mRcQgiNlTQHQR3vRQAWEoVrF0yzFHqIxQaBRyJNKB7zH+4NTNuT7fvuNjb5fvnisAqwVMkACQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2021e81-5527-4d64-3411-08dafa189243 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:27:47.0445 (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: Qq7EyvffR6NEQa5hOBd8za8rE/iOxzX07MqU6k4JzjWy0W7nkMI2HbH0/tZBlsP6QD6tSDcA83nISnZomF0MOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9376 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 Preemptible 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 --- v3->v4: s/Preemptable/Preemptible/ 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 76b209ad53d2..809d196665c6 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 Thu Jan 19 12:26:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107807 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 BF08FC00A5A for ; Thu, 19 Jan 2023 12:28:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230093AbjASM2z (ORCPT ); Thu, 19 Jan 2023 07:28:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230231AbjASM15 (ORCPT ); Thu, 19 Jan 2023 07:27:57 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2048.outbound.protection.outlook.com [40.107.22.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADF5A30F6; Thu, 19 Jan 2023 04:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=emq5pwh5p8HxxfREvf2+tnsecM6hDCpLLrvAlNm1xX4XwlHz7mYUOXQR/3hd7p39kCjI/fUNfvIuvlpXMRwtqwlb0KJcXerDVy8pXohrJH24tpqU7+gEZ96mt3Fl04gjU6xxblVoWni4NUPcTG/jHhp6Ie3p6nXAUYr7oFIvENNJRyVX/OXT4/4CCiyjzmPazhMz6PfTvzYRuvfFkUxqqIkGh+MD3mFqTEs9bRekPTSdu61lYbNWC/zPAeE+X5bzJ17Ev9Lo7AK9Xlbd2Ixlqx+x/xXluCCn02kh3vpUk6h6nKgb9BfbedSNuAmwfcGUu+lvI+Clih3U2EhsDeSiMg== 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=EmwtzsimrUpAYTUJuD7a8JjWi88RitxXhPAn9lcrmwo=; b=KZHHKKmKyh3x7vqyEDNHhNUvTcALrQUi3kkLLM13+dCHau9MzdVMoWMNBo4i6g5oIL6sC7Ixzzlz30bDDWnUKr7zfrTiO7amQO8ycwiu/7CtAZ7emRoccREF1qG6Fzw/W+abuHGbC/DxRlrf+ygACgq8R7edF6xtE/wbIl7s6ILcuspIwkGoVDjjNgXgDqoXSzGmg5c4DS7eshuSR4AhpMwLDYnG8qYerQNNOHZ2T2L2sPYIBYQDSTLb9fYQMo0FGiDLJWca1nPYXLAIaKfdo0NkieFVBaLKFeW1fN1bsMcaa4/gbEzcagtkuJ+MtVW1cL/1/vP64b9nXzu8ScSSng== 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=EmwtzsimrUpAYTUJuD7a8JjWi88RitxXhPAn9lcrmwo=; b=Ufl5jHbelljaGFxaKCPrNMJQxZ/xwx3h0Kh3sMlKafnLfl6OLWoi/QpfWGN6Vz+cx/vlvoUtqCk3KnjGYHWkeTkpo/Ib2qQC2qJWMs4T/QdAmpV/QjcXdxlhIcOLrFrzRwLSkZ9JfuNeIfKKvgwe80E/gGvp82IFOyicj5GlDZ0= 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 PAXPR04MB8206.eurprd04.prod.outlook.com (2603:10a6:102:1cb::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:27:49 +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.6002.024; Thu, 19 Jan 2023 12:27:49 +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 v4 net-next 05/12] docs: ethtool: document ETHTOOL_A_STATS_SRC and ETHTOOL_A_PAUSE_STATS_SRC Date: Thu, 19 Jan 2023 14:26:57 +0200 Message-Id: <20230119122705.73054-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8206:EE_ X-MS-Office365-Filtering-Correlation-Id: 47cc8fe3-4b82-40c2-329d-08dafa18938c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2d960woHa8e0r+gkvkUJ9dOUgRvtMzmSu6n+b5+kTu6CKGRV6q14kpkNaoplf6htpuKuxWKcnOJgbj5NJlfhuZD/j9r0YeChIn/M9+pdkDMULeZLiU1t/Si2FESKEaICqqaIX7becup67XigZQptTuehnKzeSykVUhbj8HqhCO++FObPXujZk/k7oDcFkQvfELLeNvr7lIbKFwE/hVYaexLssbMe3Sntt7rxDTJbii4yyIn3iFq1SOCEngfvnQs4PCs9wsKBQmR9h9IO2XLtqNIY1wEePwfT76W2aEx90eebiDoqbASBs9VF7rbGqsW2xKjZBAwIz8tmYu3G2s7n8MNnk4Rh0jIr2gtMpEdZR+8664ZjghFafW9V8hyQoHbFz8DAfNxEjFzSJSApQSdBl/v9kxE1Ok7BJi8gHrl49+h6GVBnBSkY237oKGO26Y9PvHKrFpaRo22a7n69qrm6SBgRP4qWB51M+O9vnqWfT5J/Op5rHVY8lWAltujavM9YupfR6mHS0wTExbtKoaOtGZ1p9Pr/hMyKD+yYha7FehiqcZwryiGKgLXJaQjGTBH0hzG1S4fO1Quw0pB8qTPiywJHq64XswW7hZuHxB0bZvT5sxHTF7UXtlkEqD44v3dLK0F88bcctLvh/ILPVmpTN1MhLAufNTPwCh70b8ELl5MRXCjMgOB0uMuyFHf0v9UWxmTo5Onq1mfCy0V4uTlcSg== 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)(39860400002)(376002)(346002)(366004)(396003)(451199015)(6506007)(86362001)(44832011)(66556008)(7416002)(5660300002)(8936002)(2906002)(66476007)(66946007)(38350700002)(38100700002)(316002)(19627235002)(6666004)(52116002)(54906003)(4326008)(36756003)(478600001)(6486002)(6916009)(41300700001)(8676002)(186003)(1076003)(6512007)(83380400001)(2616005)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QcB/IxpckiZ9hUavNYQ9yJuOEWHRSeb+rsY+wim3+W44AqxdQrb72hDx9+sFuapIweudQemnE9MJPVT44Usa936xxBwHO/kPeYnYp/1GoPSpmgPtlPdICciSy9bIlCOLjN2oZ2ifv9DYN3Xz3+DbClpZpyMHE9qFxEiSsTzOTy+0BAX5+fWNbuykXD9/DWEj+T8qAED7kWgBBb/EJGtdwYfb6tEt6dAsz+RO1nU2m1azCGXs0csy/uji1IEnFICpVoDLEHDPslkPX+SDngqfiZXonI/NlvpsdzblMGksCzrlbIAFTv9vIejH5oWApSVnJV0cZi2O+2gbNyY2RuMpg7Vo3b2nZR2Q524xDEk4RvJoi+3cNQLuPo/VLRs6wUpfEIXw/GOjHrzaYYGpPlsusblqCEmlOdKmhHstIKSRe22lL8HFoxIUP9Dh6/E3MUZVmevB7VniOwo1PoV5nRvX3r8jqxz6gOeuuOU8/oBAbG7v3NdqUiJxOK1hyPUzjMKMeKYBN3zYVQWUnreA7g47pWbwdm/6xvrQ83AOl2F4zXIAz5zTcaiy5HMHpzyzCX9zD6OW1rZ8ELfp3JOS/+HS5KAzMhxunHzITJSRS7il8v+3gkiGxNZBWWyI1PJWg6MDiH6PxYBRB/TNm4ORZwnC0G2JPTxrXlb5qYCgLurgNP54duyluuO1CX67CVDe01FwJ7GRlqwLBZTf5vnZ2WZX89Wm9JTY9TaagrVFaNi0Fsf/V+VfSyyD2IztcW349ysoWOEp4WEfu4h9jgzmXPfT6ygmA8O+XWF4nxVsPFbcx5rAD5dPFzRSuNVM2mKVa3D6Ri9FUenj8eTdevRJnpiSQiMMBZLNVWtGFXiMq1TUUlL3zviCavHxi8LZp1Cbd7P1PM/w7wleImmGMU9T7sLVo+PmXFpq+qmD6NnVC+t2Uw4vGBeNSYljaEvAhpUZs5MmZNasvsS9nhNZZr45t8wSD7pMkyQy2Tq05MVaxiKXy813EuBUxnz9wlSLolQdZkkzkx3Ktpzzx7llzIgWa+IN59Hh3B41aaqw1aqrwlax6zeUOdw83zunkW2zyzdZ5ghGeQph8ngcdHrpx42U1j84fAPPCcQqozxeSUBR5w6BTWfqtZPVyfMHiOjwnVUdaPzhhadpjElmTYRnlK4wM8+EH/+HOdmqo1xir0kU/u8pBBCwAblBnrnuxFTW1xCH4X3UstKgo82gMXHHWi3ZFg8jeHesp+L/jkzSRGxYRFgmAH/kUMhgT+HlIuqlz7ydyOogjiDYLFl4l+jRWwW9/KAmjBgxUqtZAudpbVIusOFJwAAVZRxrEnJjaTdSEozmdMYwE0SzX9iiNKL3SUQvnyfS7yiSogK72FgJztEoiOkiyMYV9rhlawaqV185cdoMh6qyx9BOcXXg+PPaljCCYmvFgJrp4ynR1lo+xyqLOzvUiBJuFUR4+HCwNYs6ld9Lm4cfsaJ9hKS5ce9E1DKNFit+LeOMeAL/qCkuuFOR+xR9BKxmdPqULFb4RD6iB1VOtaSZLacN8WI3ir8xjwU0ySowjlg0L9ZTj+KvXrtTPunZWBuHf9MjSOnPKq3Ro9mkHp4SJ8GO8c03LzzL0//+IoZ2cQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47cc8fe3-4b82-40c2-329d-08dafa18938c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:27:49.0912 (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: mODGoi8VR6w4PUokAAQ0sH8YDgnB2HIoh8UXdClIGqhptY6SAXiGJ2EGg/ZlVrjN/CUyqRSD0Abqv18m82XWXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8206 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 --- v3->v4: none 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 Thu Jan 19 12:26:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107810 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 DEAA6C46467 for ; Thu, 19 Jan 2023 12:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229771AbjASM3E (ORCPT ); Thu, 19 Jan 2023 07:29:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbjASM16 (ORCPT ); Thu, 19 Jan 2023 07:27:58 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2079.outbound.protection.outlook.com [40.107.14.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1531C457DD; Thu, 19 Jan 2023 04:27:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jUpMWmw5bAQkgJEQuM4IE1M4j0a0eNpXl25PFK12i+h8bXzJB2rcRSkt1LQP0LvBkYL+Wbak28AtQLijCYatFxuW3TTKEQ9MZJ/iAKi4vIqJRItjP9p6tuVRasgbOBZ7z6DI3brCK1R1m1HMYFnKsQUa/ZUJuNw9Ro+3mO4ukmPHmOzGdIth/f52rNwIXCiLB9DfguZhe/nGN8nFpnD07Dk/p3KcMFJopgw3DWQkC2HlAky0DlnHuFRPTmqjowrScUWsjfkeswJWumtWVZsz3G/6M2O9I4PBoXyKGmNSM6QBkfJzbXYmkFVPHAXuyj0oIkMS/ZC+1VDfEScFaJOlKQ== 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=RlTug8VnVJuExMcXrxSgCTUdzrxOKK8UQ3QgGJX0lWk=; b=nMNp0TeFj3ehC0zW3HrAnXcWbRFSanO7anI3GzbqDRp6N8hkmFMvc9pl6cyY/L+1ssx90nJBhA7DAsTvVyRw0TgXTRObXFWGeBSMARM2B9mt1GhrQN/ZU/9wVlJjgSEy55Jkl0YkPloUVE89Y3yjJksNPmXO+7DcoA5yAjvkzFZlYnACZHN7LX8eOwDtDcMX8QzP/c9tY3yfW1r1lFS9nlbQE+5v5M37WaxShMf9vuVp/F8HbaFw5l0oAmAqPspNefHV66m7+iFT/QblKZMHZIb41q6P//WVLiQeBGzy4+Bhw/0ZFaQ4OYuUfU23F/+Q5DJMRWHtz9r5cCGjr762sg== 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=RlTug8VnVJuExMcXrxSgCTUdzrxOKK8UQ3QgGJX0lWk=; b=KmoloQG6xaUQA1nuPAcA2sF8cm2xy2u9d9LcsmGAICyNboA4fy0XPE2DhAGCh8noZwMt+LTBX9Vd0RL9s5lG6+OUUbJ2QzaB59XZFefuW6vfAd6lF0jyGQr1kwl5mxKOyJdL/fK6g9BNQpub0Psi6cnqiO3aI8Yp7aVD3jeHlQ8= 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 PAXPR04MB9376.eurprd04.prod.outlook.com (2603:10a6:102:2b2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:27:51 +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.6002.024; Thu, 19 Jan 2023 12:27:51 +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 v4 net-next 06/12] net: ethtool: add helpers for aggregate statistics Date: Thu, 19 Jan 2023 14:26:58 +0200 Message-Id: <20230119122705.73054-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9376:EE_ X-MS-Office365-Filtering-Correlation-Id: b0706ed6-2d5c-43bc-0a3e-08dafa1894ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W8QNPCYJjLqvL9iF2xH7NowBEaowqr7ypARDvr4BLTyrLcXqO58ay+UD0oSGSTdzm2FSQeg+nB/GIbO4sJnS1f0QGLrJCwQqgTCoDzKcgAYSa9NaXWAfscF3DovtEvj13h1braLDNCI+s8xlyawIvYz64j2xb/h5cG+2lTCLunDU/5Fn80kngnSXwe92MJuHslxuVRQswHmRHs0VL7ueLB5qseworSF5j6tgurE72iSes8bsuonnin+uhRVvy3P5njJJRMmGk540FcGunMoLO8dL900xeAlZiEyuxjO/3x1bt7FMbkiPyV3y7O7QKz24GKCR8mC0atwjQzDsrJMrwQPw0DaAoErOiyuPXw5lJ5DUv33nQHvaGnaxpup6n4Ch1ey0g3NyOFZbt5EqdqNK5vWhfJoR3g+Zi1CWEIlyNU/fNZZYrEJMaqPq+VAoiauk30EMbl+Dks3iEV3L/nZPhICWyqa6VxyUp9TbWj5Ng/irOksl1fxeq9mKi+gnMAVCHDHOvYoLo7aC66TxJxyak+fcG1n4P9tOjq/YPdkAUq7v7gIYR/qeD1s2KIzj2jEDYNb0IzOp/8hy3k4PjDum9MNv2U2zEoQmvhubQZHXZrssPDFxRXbQfR3gK0Q0vwP7u/toEnN41nFdA5I8RNlnqr1DjB6JJULHQlhdELSeux3KKOF8izmVy+4M8aZoUA/I 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)(39860400002)(376002)(136003)(346002)(366004)(451199015)(6506007)(66946007)(66476007)(44832011)(66556008)(7416002)(8936002)(5660300002)(2906002)(38350700002)(38100700002)(316002)(54906003)(52116002)(86362001)(36756003)(4326008)(6486002)(478600001)(6916009)(41300700001)(8676002)(26005)(1076003)(6512007)(186003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i3rWvqJNAPBalo9RHQgAumAaOE13nGJckWZXmBqjvbThSK/MPQQ0T5F7VxU7JZy/SIRTHgI+7ZVfj6/GDtYSw7WQCzK48EHpgb/Pa+NyfxkLBSE0V/GlWbgXyAWvTejosSjZ7sgtmXjQbwFRpSEcsKw6wAeEPKirQ+baxXTQ0cY00MBafVrZNkn0rl6cKGOLwPl53j+LrR0LGbIykn2LNn7oReqiEERiOPh1Xz/ag8HLJQH/JqovZ75kTXK6QOgre+fTbHI/9qVw8yFvC25vLbMO6B7LshHkmdtIwNP3+cW7HfCZjNUCQ7UjIfIbjsqQWffaflbZi70mpI/k9LyXQ8r9TKXY2rXAPT93yoEslAvP3PPQrgxcnOgTX4TjkYFOgy70O4rVhfDSijFnN8uQYAr5DvAXlTodoaQzqDNz2/cnPmZ42UQxMeRXOmoSdKqmDYYkf2P1751LBzRsTg4DB7TyCynZAUN0LgOnXDJxOeFtM36PSl+6D+MS+dUCR89OSehuphYPSU5jQZ9Y5zukjWIgW8eya9SwZcqI50laLAKhj4Az3I0o2p6rOuvrPDZUtVG50UaVC+txbeMgL7dd7NQBK33BiotkRJeCe+XDssImKd1xJKcnHSGjF6Zk8HcCnR7QIhPZCm6gcAjxtMpizd8dQcscEg9k3bcGZvH6tuvQe/+C9V3ajhOEFmf78Afoq0tQb3Dfh5GlD0dJQxfiMCxMkIxflL1M3siGaZuZc8apJsQdN4LLvjy2YCxpmrL2tkDrnJZVCRRHOg4DtgEz6bWeT6zpiCHmWyV6ut24k+5qdWzUYfO/4h9r8yuj2bnGvHn9/ya5DtR4c1p0y0cYYyHyhEAFhEoiJmrda0BwgM3Ud7isTpRnVX4RtRAHNR+UCM7mdaLHkgRVI+tORqm2WeQ7+Iyavg2xFVbOqehEhbtqAP/TqfNz3Ni98Jf0n9MQJcEpiCSgWej/htPLgh3+HWUyc48+mGPXg6QmuIRkH2Kaa32/sw2+zvqs/kXGSGxJNWg+gloncr+Eqz1l9Y5ddlfIOg90npTIO2ejnOZQqTyKEiWjoJCuAAfaEc424lgAXR4NpVwB8DGQb2Ej0pPv8CzbEQUgh8Ipqb582elF39k7hsjfTauELZQVa+0H6/VVmKA28QImVPgXuL4SEIsBTotH0UBQbPe/P27veh7HRMMOzhTGHgAvTqoJx9IqQFQFOdBZR5VR4l4dbKdibQbQnqNAx+/E0AQPTkN1KiOYcWu3DXhQaHRGqCnQ+462Q4ZvihEcJIV97hF1pz6bUL9GuZZpXpUOYQDP/mQiJ8CoC7ZC50nAq4lxeAT2/2f/lsYhPPeQtume+Czqcs0CSer1uSpxMzb26ofnopnH65mIP2robQK/JZ2bXk4fnWLzO/SORNu9bOwGajI8/D/8KJWOLI3pacyNNlOnJnGNc+OiAT0Bsu8zAOF+r/IT8DDbkRc31SJXuvwSElziMxTNekMh7jsihoRANEdlEjGm3I8yhPg+/08adMEUAgeRoXrXxgUFMzQ5ucKgOFm6yUdt64h1UaHqBXm2NaFXp2yyMvSNTix7gLcW2s97DLSELs43tgee++FStlzdA5vOgcqqJjygZA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0706ed6-2d5c-43bc-0a3e-08dafa1894ce X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:27:51.2786 (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: eOZesaeWoDqD5eK9TKzIcgXjc4q9Dz79K0wsctVQo5yUcQrRPLuRbWPCulUbB/eI0en53tB4qDwj8FxsBToUWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9376 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 --- v3->v4: none 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 Thu Jan 19 12:26:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107811 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 3CDBEC00A5A for ; Thu, 19 Jan 2023 12:29:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230135AbjASM3I (ORCPT ); Thu, 19 Jan 2023 07:29:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbjASM17 (ORCPT ); Thu, 19 Jan 2023 07:27:59 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2079.outbound.protection.outlook.com [40.107.14.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CD474ED21; Thu, 19 Jan 2023 04:27:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZEO5N33B3c+qDFk4RXQgbpqgr7cKlYqUyHtYoO3LzztgmUe2hPnz10kpFjPrI41Zv7sdjgjVqjJSSfD+HeDAK/EXRGS5VnRXuk8wjwnKKYbiWDUOaIj2xwOWcldaXhB4V8Vmov/eO7IFPUceXnf70AyGeYUdpi4tI92+MDYOnBHC9OEHfOASvVjywLpHra1qtFt86YVDmjkRKIs1qCmFBkXb2gyRyzvJUNUUP8dKe/Pl6v4qRBaJTpSCvUtKsp+eIfSn5WVAlHhwze3ivtb6NP3e7GCKj58ZDD7zfZCKctVtImt4arCGt/wXU9c5wkqZcGxNletKwEz9qrYTCzi+Bw== 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=z4W21MZjorFHix/oWTag/+RlbbnVBD8mhmhpca8aKQw=; b=b9XSca6NrMHrNShJjeGBaj7YMAw1vWoU2V218LGtskfVmBf/xS88lwuALNE3w1a/Q4q1xDLCJh6JeTICT/ItWRFWIH18PY1C6I6lz3Kr8YgWuJ45YNWsyqijkQBh6QpEErugqGQc7pxWvJd9hTz1VgUWRtqgpvqtxDkkMW2T92JE0Xo2GqruxhEIkk3kBzpByW+oBHUz6PfgsCRo6j6TjKKJdyptLTD2ZlXx4fAkpkEHhlGi8lP9mTM5x9ooKo7MA/f6FT3T73WczVC1RgXjWKnRDEg0SAVminZ70x9NkyJFUvvweZgxEBDNKIDrqrW1noRp/FJVpUoUcJlRf7KlQQ== 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=z4W21MZjorFHix/oWTag/+RlbbnVBD8mhmhpca8aKQw=; b=BUHmRYNt6J+R1468P3fSf3n5zbzMn1pPDZsia1tX6zLKWzT/+xyFep2l+p6nsPc6VbhjYFLYVS9bh+DcQynM7gr0Dr9yvoZvIYprOTwXfK258NhbV4wjbk+nalgbMNnT2j3NVuo43rOiQ7fM2+0C01DLs9FmmyE3DWOyOZRQCKQ= 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 PAXPR04MB9376.eurprd04.prod.outlook.com (2603:10a6:102:2b2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:27:53 +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.6002.024; Thu, 19 Jan 2023 12:27:53 +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 v4 net-next 07/12] net: ethtool: add helpers for MM fragment size translation Date: Thu, 19 Jan 2023 14:26:59 +0200 Message-Id: <20230119122705.73054-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9376:EE_ X-MS-Office365-Filtering-Correlation-Id: 20c8a780-0550-4991-54ae-08dafa189644 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rQrqQJNM+X27EfyJjqFQ0BMr1ngGRyxUXcmOtmGyaldMB0YQanrMadHjfbk7gWaI7jUdsCN1IYI9bTplchhd4ixURwsgWmcLIBXHTjISALeAtN9KDHsFrBm6kDOAscwSnbC9PJuthMcGU4+U9sjSuh3sO+FhIQYcN1+eIZoTEZUJ+U99QFkOLelHWqyqDagFktM+yQn5c/BQjdc+7ZBgZkkZ6w4kocd5KszmQGwQvfnQvcFwztxrPOZURf2TIVxteLTxv7eUxta9MMFa72uECyuUZP/uNT9HduxpeLqpPa+p2l9VpExjYZ+O4sF3lRAVpJDk+z2oASEy5YNIYlPgh83mTMyBEsYvOpN3QFuSmltU1cd9ZmKkz+ug3dA1udg83taUGcHE2Vr7S6d5q3TjWQJSSLiXbOozbu6fcqD4Sh++wKYymHjgmXx3TaTF0lwJ+wUjSCcjoLJG19jNyzkM7tGsqzL6mxG+NYNcR3xizsL8XaAltnZJT8Z+vfH0vdqvKnHpJJOW28CkiqfcRmFvizmrSye3VxvxKDbyN1rmnwI1sVPTiglcF0zpzT8cIjgcIuteb2dh0VIbjvGCbHMQt2uWEPLP6Hs4+TgMXFxaPSHGdZKhnEjp6iciRzEsCko1nabeBVcJK7QpHFk7SCXvX+U9AGyCGZUQzLXLrxp13OwGCwRAGT/HzAfk0CaRjwdO 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)(39860400002)(376002)(136003)(346002)(366004)(451199015)(6506007)(66946007)(66476007)(44832011)(66556008)(7416002)(8936002)(5660300002)(2906002)(38350700002)(38100700002)(316002)(54906003)(52116002)(86362001)(36756003)(4326008)(6486002)(478600001)(6916009)(41300700001)(8676002)(26005)(1076003)(6512007)(186003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UrKRnffKYWbqdXyJZTSKzS2dNE5tZzkasIOdNr0Il3X/cmuGSOxVXt/rc1J0Orzx/+bs71vSzSN4gvM+9eEGtZ5boc/Ojgl+LEoy1U48DArDFUdk9fMnjY71MQy7bHq7wHuZbNDQ3oIqCVM0YRCC0DlkF4FfHYx/ubHYRn2JvcKg/LjNPDO/7lyobvglkqIcfYAMp9S1u1ELDCcIYvZ7xC7+wCkcrWZxLp2jY98LEh41/bt+ziRqsfoE8qMeEwg9FW0x0Lo7c8ZXRq8gUVhBwPN4i3W3g7uRCSRxuCNOq1mEBmuJY4VOWyNq1cf+EctIn+ukuxr7FwymkfZ0Hg9Qj/hnkHrRBnYzjDgl3W7u7tjC7zEk62srGffPvMBR2H/w2Ewc9AkI1CdfZZ7vVMZEZsoNtbjjXEaX7BSxcUxJI8H8gJCdfcugGbMidHCsGS/6w2v/B4ALtYT4s21GIrw4jRsoQ8jrohwq3w2jJDg+/vrTM6yvjalCdSUieX4rd2p9TZQ/fRE2/bCW7TWmtK2S1rHQvbldPgtgCqfdkfaRJZe5adz57crleMXbqUGmyYa7W4diuNBKqFQOTxKwvHl89hOj2dQ2ziesHEjy24//QI/wmP6cNjX5XMJx1Fl2jUUDex3KlZhgiUV+d3VuvgLRJGWggmw9zASqA2gHVhtGDZSTzuii7t86ezkkuDdlG6dSNkLAlVOJVBm0Yey7f0ZsycuS7ihi7bTxwt1asSbhMdTScR2yOiECbiIQjmwCCOSHXNQM2G2nQfLx0BdGiI0uRHfyAizMlGvs4o+b+suRof31zacygPoanf8G+PgiVDSxQ66XiGBGapbrqu1CigbiySYsRNjJdYCY/aqmQD/ggM3PEgSNgBCZXA0PxNIGWkpBOzQZEDvbXudVPvmx6+Tf00pff+RnjX+7OaUsG5vrGE5RBv/ZZOGuufakUS0iTHspcq0d38WvJheha6TQjOVezf93j1p3qji4k+NYUwGge09LQDZrEMaNubfGjmVKewzqeR/k89EZ5lwAHGtLtP0iLVOZqhjmI3ygit+Yw6cLdbfQzA8YyJvyGdXDDazic8BcxzC09P1x5wFzOXBAWjxCI9JeiBCuhbg5yRPOA2nR9zUXHqPtr4NOt0ajodiLucLX6gUvpVHzqNKySKf/p9IcdF1D3uvwhbepNwf222cwdHGv/gTIm5ELCfS2lERr5TFNRO0hvWGMiM0lyyOdX6r/Ds9bz6S9ruoKv868NE7ikfF1ERUOyEI4Z8HQj1ob4sZmjBCaIc4fimAaQNGfpI30rXEllmOJN0qAl0ZLOBUB0faNXMwEf/ZrMiBHEuKRZRu5gqJ7EG+eQww2aakxIBLaAd7RKASYPOAX3QOCeBIDge69dE4ejY1+EmpENsQYv/477RbLXdXac3Jvj03T/JVgRITNoSU65ZKkh6Sm/lLTRh7XlxI+DNTx80/OfMbd4kfkyWu2jay8YpPzdmBbcgvevZykYMDAYib0237h1ICRZedOHmIWSRbuZYd7h1sNe03khhSJSIEdNmQ23eLxsr2d1NYQiC3eK01koZrMSZK/nTtT9Wv5HVbxIOPssFA3c0gvRmKOZaSE2ycv3cvoicaQFA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20c8a780-0550-4991-54ae-08dafa189644 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:27:53.6847 (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: OMM/F9L3+LsZ8FJz7OeNLwDkT0HqNcGIZ10NsRf+VWbP66vCc7eA1id4vVhQUBbdZL3ID0d0Z3R9X/poVSeSbw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9376 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 --- v3->v4: none 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 Thu Jan 19 12:27:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107812 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 EF6BDC00A5A for ; Thu, 19 Jan 2023 12:29:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230359AbjASM3N (ORCPT ); Thu, 19 Jan 2023 07:29:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbjASM2A (ORCPT ); Thu, 19 Jan 2023 07:28:00 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2079.outbound.protection.outlook.com [40.107.14.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEAC561881; Thu, 19 Jan 2023 04:27:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nYXtayTZCzOdUK1jkN8UttvOTefqzqNmm5memK2j8JOVO+fJKbKgxQCi7JMl80QPoM34YuS+8MdMPIvLeFnTPP5PFb7WUTHahGMldqBARKnHYPZKDWFKaCXH7jBKbtkaOVTglF3cakxHisRx56zsbn6HFAsbpfGJQ+64AIf55HMcjiyo09Tjh08D+0NQP4QPoFCLrAUR6lvskMwkLIe0RCh2beKSI0AL1HWW3K1bC3qzQzLNonsjB7zNTHeXEUCJdPDZHNNRW8iLMkJA1B7lHTQp3MxnUNtfXLHFw7FYfPXKDPMZGl3jWwT0aziR3p2STV5pqORSDddAepk3vH3vSA== 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=sPIcQvi5NyHzktP2rGc9ZArsLGcxMx4VnLiCAyCPHG0=; b=kC81kyEDbIhXN6zYcIho/NlGUwbC+S0hKTEgMcthsjj13huMfX3nM1j3ZA/QOeMzYPTB0zBEBeRqP+PC1dgTqo83wSqxxAOZBbMhX1LJA7Ej1UTCrRE/iNtQi5nYQepxNkPsNAgjDzQI/3hf6joCp3YIcyVuQMwGMuFIEckaqdxPH9fQSB5vaz2aWU6s/+YuDsyawszuXT07E8mBYFKZphmPQ1haZCnYeahHghKs/yFUYLnpmGOgFR4OTIeDWx+h0W324fstfnwR8Ayn7P2Vk4ZErEu64AaBRfbDRmDVC9W3Jb3GFPEJ0EeRHenT8QXRXV7nf3v7R2HK0hnREUPM9g== 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=sPIcQvi5NyHzktP2rGc9ZArsLGcxMx4VnLiCAyCPHG0=; b=rc9RlvrpD5PTkZDQUB/17bYyUWE5jYVevCPnl+g87SUp7IDC30Xps+2RNBHW0bp8zL7GLBaT9EjUkg1Ugj9YkYZVOzyrUz5jU3wgYxGRgtzx04vU7TAOiXcxUPer0sG/N/WMuG+5iey8w0ECOelRs3Fd6T/cBTUOFSdRZ1jqbG0= 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 PAXPR04MB9376.eurprd04.prod.outlook.com (2603:10a6:102:2b2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:27:55 +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.6002.024; Thu, 19 Jan 2023 12:27:55 +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 v4 net-next 08/12] net: dsa: add plumbing for changing and getting MAC merge layer state Date: Thu, 19 Jan 2023 14:27:00 +0200 Message-Id: <20230119122705.73054-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9376:EE_ X-MS-Office365-Filtering-Correlation-Id: 8eee1fef-81da-4433-ca0b-08dafa189783 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QjoeoFpcVaQTnu9DVHYqIhuj2bwzfzfUk0Z+2dsfWMyhnuZqr/ad2N7NuORauDq5b6mbGnGmvVZbK/wgdlg1Kzz0JRciIDjJSoT3jSXSqni6Du9hWBnb1sGgA1/1Z9hlQ36AXkPTEV7WvOPJXO/ikR01fAcTM1ibiqMJ/xKmPwHAWTr9xWeEfsUiPTlUAflyoTMg7oh/sHhlB47lVHT0yU6dRS2ry+zcST4afFZdiaOpkjEnczPQHh6ah7lRphb0wjhEXGm4cv6zXCUlSX6jtwBi8Q+66No2+9GSRxYUvRENWro+2As1AVf+05B046eyJ1BaLUmBtznEwh8B/TLK5xsDfXrSFe0YbhuzpVSLQAv9pBI8y97lTyKQ4++s5KjIvo/YuKRn4013lq9IKQD+DhkTSrIQQE543zzP72cpcEepPuvRbyaVBge/D9RxaXYLeNY5lDzn7M3ZxP/AvvesAP+7JI5Cnviq6d/GUdThfcpoqkGIz5fEARCu2Ru4IwromFFN0oMgKJQFEv3tuVEeZziqVAVfManmybm9pMTzp2oenHLhQUp89hYAq/Di21yrk3LvMbvw5Lz4e4NlgzciNVbNlkUc8o6r4iV0yZgcpXVhBs+iGhOiGmGZa8wFN8Ik1lRKcvQdnYL2yLMTZvGViay2miwwcEZ6Houecj3VSlMwTU99Y7LwY2P8wElTMXG+ 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)(39860400002)(376002)(136003)(346002)(366004)(451199015)(6506007)(66946007)(66476007)(44832011)(66556008)(7416002)(8936002)(5660300002)(2906002)(38350700002)(38100700002)(316002)(6666004)(54906003)(52116002)(86362001)(36756003)(4326008)(6486002)(478600001)(6916009)(41300700001)(8676002)(26005)(1076003)(6512007)(186003)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ddfmVmLknLXrJO1IXHgLgCzh7G1sgmnz13VP0Y/AovAkpnJ7FO/NRucx7eX7tFh7zmVFyitgSLNGogll9NlPi0WdFpQkarM3hgsBjoblfOax6SVCy9t4cYv/6/3NRr2W64lkk9uckdGwH38bzlcEjwYhhLO9idMvFqSLN5An9+CpRGf5NkBgxddOM+rOK5G5NKu9Cvnl9vn7/vm7dKSu69xeNhgmxgtAqkPXgjGqhmBB+7Y4jHTn1nzcd/l+Z/vNN1er5GWStCeMaHHhY9EQq3HiwtI8NmUT901bEtsN3DCvxuLaP3AOupjF7KwGPrJIoBviHTzWYV82NZP2OQqvI8xFutuSl5UoXLmUDXP2Daca5ng5gN2qMawNZXHVtCI1U+cKkA0qQwi8+BZb/OOuoqYi6nswqdAU8/JUbGeEosxVgD3PR5v/6lO8TXF6YmY246WN6mp9N5CVeLY1WmsiPIbgnUpvtgC/7SAlYpytmEl4ikE4r6pDA1nSrXruZqu0UXRi7NMyZJW7wi+wPVaKe5997IORlJxrkHo8CcnCsuKc8wHOhoHYyXIgKcyPuX/NWSdW+DqkE3OwAFGsw74EPXpClTkwdiCSew87QIk441/ao9DTejZEyBpOO4eQ//Pxxl5gkVOCyVEUOhCaIWSx/e7vXRR6GTskak9GM8voe93BtRh8YMlTamimS/MkmkgtdJxx9TcZxKy2n1yjbUd6gy1YDHJOenbLNk9maL1iAPe0NcbXYm4FnY7gK8mMpZV2LUwommTraVnK4Zgwh25H2OlcJNkTZZZfnltxRc/+kRCEJeGxjxu0ogXmyrNqcsOQoIPe6YGWaIsMv/puesECtIFk0S8B8oE8b3C5XiYTaScBVG9q2ImFph9cIB4Aw9zBYp1vBkuIwWiZcokXR/EYeEk9u2RfqNQX7hPRbDxE4xQf633f6lZ+YzlEJXn5Sx+2GPjKyuFwm2IVHkBVJrQZcKrZ2jfkt/XhntXCzr19kqbtnAo4XNf0/dXZ7nPLW06JZX2Vuzix9NlwO8I+BJLdlzCWDMGijhgo9khK7OJ85C5kOopEQuaLMDhs7Xt71YUeRTT2L2q5hfxW78I8hbjjj4wrpyhjDN+uvgF2CrW5TDKiNm3/+Pz/f7GNKbNGtbaRXnZ7IYtL+9s+fRV/Z72SRXIUD3rsmOJuIi9qcKR0fz43Hm1mssMO4mRHKiPgEhwzs4Cvdx4GqV+k8JuAft8TDMFlgXwKcX0bv5hKLyapaakMjmbyEbtlwqlmBVycPEdMZqTZwV4Vyj0jmSmWc2PEcNEQSkQYljq+DVbJlPrtczgOS1dBg4RMuBsdLgEQsljHzkrccILEy2slMb2KKBmG4VI+g4fV0IP38g5hmv1J6UROdPxhvoTMstTm4QquArU1d5GCcEEKbNnzyDI8FJjlDWHytQkXXP6mX4uf6kCIHua3jocKeCFLAvVWHV6EJwCQdTpvxHFI8Uh9pMCewrhzAxhmv2VoGj0W9dC8CeDxk6ouNfSjnlH2qeaW2UvZ7i1kv4+th3UnJ6NldbFxzms1v5/flXpiVkdJyfAsQeL0J4ErWpqKKCUXrD4BisMkd67/w0ab18Z9d/Tg17UCIVQHnQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8eee1fef-81da-4433-ca0b-08dafa189783 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:27:55.7470 (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: gcPdSK7vC7KHWqyFmcVdS2TcNBkUz6Hf//PeqiJhNYDfbiCxc7nbSP5remNXaYNiNpx1puc8l3jx+Y7wfFwbpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9376 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 --- v3->v4: none 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 Thu Jan 19 12:27:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107813 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 9F379C678D6 for ; Thu, 19 Jan 2023 12:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230378AbjASM3Q (ORCPT ); Thu, 19 Jan 2023 07:29:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbjASM2D (ORCPT ); Thu, 19 Jan 2023 07:28:03 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2079.outbound.protection.outlook.com [40.107.14.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F4D26923A; Thu, 19 Jan 2023 04:28:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rc22ycshFMhvoxwxpSEwUf2t0RRMMJYOTaNqHwmKoCfkAf4LZ3qCkohd7JNVfc59Pa9xQRPCiPUUg2qbqyLOm622+uoc5lVlzfwtLrUma7Vtjpl6NX2LhCi8lPQujJXkuVij4/CzGbDlRE87pf3xHXpPnJ0ut1D1CtAqJGQNnI3KFFFji+Kdgmm3yhpM6ZPkK8tlxjsjO2CzIbhBs6ATkXdVeuvpR5vmgBsTA6Prt9AgG/XIdDTNhl5F5xtS1HOgkKj+L7d9LXdCP4slrX+f6WpbSTTDN5SlxNqPQrczvEQJCrvXyMQwe3IQTM/f/TCCsSjhRLhIwXFYu8JxF+sgBg== 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=9ezRlgl6x3LiQifZBXNjx6U4npuVgQCVw+Eq+mc5ovk=; b=hmynbfj065WiMruluB6nVHbXjLyibKefCGjQzybHZPlY27PF9yrF5DkVUNKMKagdQJ5RW+Vz/NEDODrVVayuD6IsNJX9Kwe5f+ZxSVueKrSl3paxouDGTuehCQ2OR3wxXwTGLx8QijY1Z1pRtUI9KJTEhebUvjOLdpMcvUFLWrT6Bqdhlc+dw2YabXbbjUuTBSCxQQ9Xj/XvxQBbSDxXrlfrdWJvzJh2EPtpfQeC/mcLNLl2w5rVtvcpYZpG6fGSIb/GGMzlsQ3bUUe8hvNN4M1wZlbBaIf+AMA6d1OjtBYPVoerunAs1NMKq15i6kuPv5LfHZse9RVwOjxWL+u8gQ== 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=9ezRlgl6x3LiQifZBXNjx6U4npuVgQCVw+Eq+mc5ovk=; b=Rl/JSHrntxSMdpuIYJyHwcmwGH1XcQS3Mp0TtUNghOXQg1bDpBdrYWxekWZNnIcdRn5y0XqNJGDLZ+yIFB2s/bJEBCNNiRHqsjBJqC/zn8kxeQeP8ERnFJyqME9X+TEbpFK94iH+vQSfQfUmhS+3in/dn8DZd7tkKKrffkEsnlc= 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 PAXPR04MB9376.eurprd04.prod.outlook.com (2603:10a6:102:2b2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:27:57 +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.6002.024; Thu, 19 Jan 2023 12:27:57 +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 v4 net-next 09/12] net: mscc: ocelot: allow ocelot_stat_layout elements with no name Date: Thu, 19 Jan 2023 14:27:01 +0200 Message-Id: <20230119122705.73054-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9376:EE_ X-MS-Office365-Filtering-Correlation-Id: e6105401-86f8-4a5d-1878-08dafa1898bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zSFHQcNgwcOCJ0mPoPDE+vwnsFxnqiucuclxOjxTE77iMtTqLj6lbqcZ9uqZU0T+5PGCYutuYDzzAnzwjYogh8bmOqbTpf9368k2krCBx9nZD4hOlej2dGToIJAXRB9DdwoCAoigVi31oSYHj98n8c5UOdl/KldLh1T4DlQwjIS6fUQxJhmwbpMnWKhDg3Dye+uD/IwXpBNfUaNMV4Aj2hujQ02gjyopysb8lBOybL/praBFNhtVsJR1FZ5O5bQ7zEAvC1liRvBI4U96CCaCBMGGGJHrTZ/v9P+riyWWprUF90f8VbMQ2KXZjikP2o+sWB4c1+8vn2KS9eDHN4auVCQyrnjODJudVRON4IKQ4qh2x7q8tSvFxAwUpGVOr647Z/N/8BozE9djanTjkoPTf2xRnQNc6jRuMFhruBnrTNiEya8qk62UK6xAeV/YeRUwP0I116NGpK96l3wUivxvLw63ctx34vbMG2TfThndhm6fVWpjqvIcKvngUCe1QMi6R2lxHIoG8U0RAZiGsHDJ6RLBFJFRpnLQEWxxIux/f87C3sHPsMouwBdDI+Du0SkO3g8e8ci0CeLAY51CLjUV3ZfMzn/v5qDKuXX1pKVvfU1kePIgQ9J516Q2UoK+1iktNnRkUHy6dSA1R+FGGNTsHm32OdB8gxMPgaBT8WEffwTzou0AFAECQcHnYD83f54kT9w+z7WmiOJzSshf5DkoLQ== 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)(39860400002)(376002)(136003)(346002)(366004)(451199015)(6506007)(66946007)(66476007)(44832011)(66556008)(7416002)(8936002)(5660300002)(2906002)(38350700002)(38100700002)(316002)(6666004)(54906003)(52116002)(86362001)(36756003)(4326008)(6486002)(478600001)(6916009)(41300700001)(8676002)(26005)(1076003)(6512007)(186003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: px9LiMhy9FgDNUWT8r91TRSSboiqmx5eyvs2S/VcmXlWE5rX6yccK5yxljWH9RdjMs0VycHP6f6pMcxXMLFYMY6a5NP39tJPzGi82/e7isforgTmEA7R1g8e2dJee3bTzsXhztAElnjvWd1YGDrdVdM0KNY2TwCox52fEFVHaqNXDEmpnAwhPY/aPILXs6VZDv0JyhhXVZGpZpif5cvxpR+/RcLhqYtUie+EvpxMs+26CAndANqZbyOeAGpneYJAdeYM4LMuJwt5ixQ8NuiOwHOdlLm926H/q+jyCm8+5itaZg7yYhGpVgY+O56+OlrrV+78xtpaAywzanz51tYNNpUgXSiEWpEDdVzmjFmIdE04MNbfOEf3Co+CrYMHKoiMOQhgr727Obh0NS47AFhX+S4CN01SqNsGR6l3ZAmoRfZEFEVqu0ElhNcvWBQ1FPNaRzsCL5Bnxnn7iO3ok9w7/s9VwedrGntLqAbOG6rfO8MqelOx8xMNizZuxAqGKBhbWtk5A5VG5h8KHiWFM5A67RMmpkR5c2VDKeUnDkW761e9vwf3/defos7RBxNLWTaisou+nTqRt+hvK8eEdIYJpZNBOdprv7bdJJL5UE68EKzr3sapWeL1TaEBAyZyg2e6YOqYBmWy+AKBxcPNLVkb7ztvGUqKhlyIPr/GDV/KPK46Ek2c/ZwXIoeaon2Z8nt2GvNioByiFKRrC1six0JDt8X1/Hh55ePhVYVKei8BYQr3VwoB1pIRQNGGFfxph37whZgeQf70i7IDdvUYcaMR0rtbZiRVwRTfbajpiYIrE6sRdA96xKDZYg+5WwrTgsjKgjyiKJ+tWQOeOnUInPnGG+vcG+SnX7KPzVEZQqJsgBS37VF9GtSJhQN0qLOwbIJuLhfhCwaRBQHM3dwmselbl95PmMjDSlCMh30+ffBr8Lyh4KvOP40Qdl1TvOuqFJiM9q+VfwZ5MyBpH9LQzevayqSgRmJpNzo/Q2kbf2sEPgDsC877x72xnOe/ULvYDuIGIGWjK/c4NZ3WJESbpUQ3COf0EwUsQvETGwjB7DIEnLAyqo4+TW017egnBDS51ENHTVwu+wBvrJfhd/TOnn+dSuwU4ajS0J1NueGW1/568Gp0C7VLE+kJdqbpb01XhbACXackGrYDZmuiA8PCYeRFCKlbMM8mNPpgEP85EjkZ/j9NDEclOceGhdG1WUY3Ymtere8GC4hIqTbaULNIOkIK7HnJmyEV2EJT9A34Wp9GPr9bZgnEZ68PAIP85levef8n6lOQ7qNLsdsKzGJlr++79L6XaFSmLrEe+OKZ/8FF1yA6zEtClUPz6Tw5TNE+230cudrMT83Pm1hAwOL+I5VQRpR7CgDgTSv6ULBmjSOKyyLRPWvuH72Q4M2x0wZ+5hLd/DTob8Feg4zsbeTP/9AwrOd9D/Yc0pFGY1FhqD4gsDteOfCP+rrHPpfqpaQ51+vsZyR08Q/A5YkOXqCI8Htx+uPr6FECYxskaTjEzPe5Wtw/xWNeYdxMGqp1101OTcaNTLeIjHwhTsL+S7EtO+OamGW9Bcik4Rmi8Gu+kR2yOhteixlkxS+InMfedqQUN2PxuEHi/dmhXmFbIsV3Ntktcw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6105401-86f8-4a5d-1878-08dafa1898bc X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:27:57.7938 (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: zb22irZWNVWYN0wxhFBP8+pXg5dyIo8KRMaXjGvSUXF4DCAaZnyHebvNJdTM1byGt030VOEiRnk8V3mQp+cZvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9376 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->v4: 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 Thu Jan 19 12:27:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107814 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 9AA33C00A5A for ; Thu, 19 Jan 2023 12:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230322AbjASM3T (ORCPT ); Thu, 19 Jan 2023 07:29:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbjASM2E (ORCPT ); Thu, 19 Jan 2023 07:28:04 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2079.outbound.protection.outlook.com [40.107.14.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9190F71F17; Thu, 19 Jan 2023 04:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S3IZUkN22D2m87LpMXMKotSGmSTUr3aTwK3oBKv8Li8JskXSDjW2oyXnb2idQRXH4R0htJM2cYwmg/dCqObSEUxs3F4Q8//AsoHlUOMdkbRP8ZMX4xCDLlTg+Mh9aBYgkfhamNOAZct7exLstBZbPG9EJ6DNnSv5AmRgJOMPX+XH/5/ZZuYe8VJOzeF5tV2pVYDFBeqHNoFp/nNkDHgqAPZJ1NyJCze136vRcMQP+p2bNVBY1Nj3KXbahxwyZ9fz5VqjMLr+3jsp+ftCpcVgEq2Al0KEmE/4/f56ktZ/AtGDlnx3CUUHMlR98soslYXrOG11XpTDmID3OKmt2pUJkg== 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=M+vYijF6RivZml5xLzO5xYG1FrZUa+bWRjEFZw72mzg=; b=YCvIcBp0GhzhbqPUbMZCm8ZKEMT4iX0puBimk0Cgui1HTPcyu4ZLMFGUmtrNlnuf3q9/dCtyvNi4/LYyG8kTf3GEghx7jbKVtNrPsXUdCHiZ7cx1TehnJ2g395NV0QKDqGZmsUYONt4ZuX06kdtMnUMYZznwF+rhLR5VNkW4yK63766MhH/gwkDICPkOeZ/1r3vZ1XXzkWLZdicKcCQwQPZ/Kn2QcbSpJQqHcxLJoiBZbm/J4lS/bEDagdFS2a76JAG0f8sRBmSdu2sUlSgrbNOJo4LEGFxl2y8ydczW+mTTE8QkgSXqNBp6knW1COvQKiSwueYBg6oRrGpwnNnUKQ== 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=M+vYijF6RivZml5xLzO5xYG1FrZUa+bWRjEFZw72mzg=; b=XuxVV5CyRDH1NdCdTNoGV/12elTr9pbjpt/Cq8QAZoRDdkTLm0r0nl773Pc4Zsq1TUlNsAcvHtWqTxwdIUH2Ol/slHGB97QbHSJ1511bEdrca7hdtiZiY/HEXmzKzBfgQUQxU6pnCojD0iKUWPnxdiH2gXX0lMD3hGdMmknguCQ= 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 PAXPR04MB9376.eurprd04.prod.outlook.com (2603:10a6:102:2b2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:28: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.6002.024; Thu, 19 Jan 2023 12:27:59 +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 v4 net-next 10/12] net: mscc: ocelot: hide access to ocelot_stats_layout behind a helper Date: Thu, 19 Jan 2023 14:27:02 +0200 Message-Id: <20230119122705.73054-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9376:EE_ X-MS-Office365-Filtering-Correlation-Id: 29047ac0-37ef-4995-2b7a-08dafa1899f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y2WfE8iYJN6c4PSFZljXYuktCXh1Ln4QITlmguO61OPbOUjAnslMEzyg7F++/7A+2OZPUSzU2cetXqzuFgGfzyH0nVa4UgBFy7orv11B4yhESzHT59GlIg8YekSCv0PhNU49eeaRow41ol85U6gB9xUF6Izr3JwPqDekEf9jiuD+dmrt0JhYTI7ojBQkI76jJQ6BglW7oeoP0P/tgVCLJfZucIqgEBXfyO0+4Ri2pTXf1Iqp/0VFfvreHlnOYx54xxDYBrlwlgInATqS16UDqOTkS2gX5Hhl+JtmmCDdcG2H6jG+bzILaYsGy22ok2zY7YgvRastZGE7LD214cTrPVTzjw/zvIjav1Rdx8ESrGQxaQZAXRCoSaGQo6A17IkIcPIWhsVSRoYGLFpvFwYLy4ksv8urIJ1P5jx7DIssN5sVLeiHGVCP/0mZrXAxX2QuWAgVjO6y+R/E6WOoX4Sl5ehw5A1u7V5YYZ+7sTWVEa0UZMhxRtQ9YOCe95ILNUrysZ9rLnvsSMug0n8lpqQPsmhjvFr+XMHCVNVs0419iX6zGYnzhOFttWAx/DUvlbRHVKtntC88DneJZOYbZ6Ddhj1FSBls1HAnd/mmIdBi88X631j7xUqueeCgiIELkYVIpIL/CVZTii6ZsCsUoGtGmILFhdaWUtW1SdIAVsBF2c7w2ZfQeJOj0uVJdAI/9cCCJzjeQJn6Yxjl72CqMcqAog== 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)(39860400002)(376002)(136003)(346002)(366004)(451199015)(6506007)(66946007)(66476007)(44832011)(66556008)(7416002)(8936002)(5660300002)(2906002)(38350700002)(38100700002)(316002)(6666004)(54906003)(52116002)(86362001)(36756003)(4326008)(6486002)(478600001)(6916009)(41300700001)(8676002)(26005)(1076003)(6512007)(186003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +dN6qYuIb2EF2b9MRkjQVrCK0GNzIkXhzqv4keU7PmqkZoBoWMZyQecbIC4yk1+MkgLQkg6+eGGAp9X534E92Fv7Cz0ODv2ElST9NFE9GCC2i11p0GxIoXQTmXCxAxybs2+yOZSz00cS4q2RpblzSDWbFk7tDIo2Kh36G8EHNqbiU1FLdXv0fXNYFMVRZs+DQ62NZlG135dK1x37byefnpX7yV7t+kjJbM7GCElIUZaA1W6z2ayQbEcB96VZ77HUZ41wHjot8p2uVthdUtbygbWWK4L6Endlx1gVQ9vfdaFqPns3+Y5kzyMdSay1W9eUJ7FBbsr8OvjQKv29wZOdLoTkOLTE09s5U7ztsBjxOmoKfgj8SWW6vFDqwrjJOBsF/TrY/utJWJsA/9tYf0ncnR+ZOTMZJrctqaZBVHH7CyUlzx6eaZcLMADxkaiDKhcpYIHhGTkX3knuTzYFaOQPo3Z/DfFeXmNuCbxsYMW+2iu8PPbciqy7leB9RsX8A0+io41eam+t/0kKsKtxpOKlsIWGHxsr7pJMLCfRbGzsI2Ly1xJ7A7RVW+ACsvO/HMHQLFsClLFNJvsgwyLU4MPeEulOxCuwi3Yj/rF49vUxW/KJzUl8ZcEcU8U2KMijLaSFNDPlb9JaLbrGyWntoRI7l3ep8MGA3vi7XQUbNJv0mEnCFvUx1FgK0ebzWqF1ku4IoSy/9yoBzAdcA4BMNUbW5ej1SuUNOLhKmRc3u+uG1eVFfkPizxgCMa9i0JxP07uCSfVGKSBSe9e8LL+KyuPGPrbu5IZ1ya0DK5VB3eWnivbhdl88aPSlpikENwDIoHb8lxqwUQlzDWVTon9RphG+/Os315EwJTLKc/C8g5vJH7g1ccbn1pG3krwyu2lIsJmSAOCIEEmD1Ms5lsE/ugGvHmShS3KCq8EmB4ITlQUP1VWX8A2F0HZbcDnbHu7ZKASIJmIJSHqDTviyTPChWvk+rjTVNtn2UfRCZQs8J8wqNUj1CxVo3d6lAX5OdUOqNo3rTdAOGNE9MyVgskym+1H1BvTjfnGTn2Rh5Q0y7nwwvGXCa6JrvW73SFuY1noepaS+j9t8kgqPTJAzCvwm0T+DwuaO5mZoqykglRQaanyrsCDhKIFdFXMhjbeaG7QWpX1VEd2T+u9t/buTY0u2Nbcw7V4AAPQnhUtt2hblSqSiFEBsvQjz7QAgvuJCMFOl/oVDfamOetXZozVrGNrSUvgTy7T9M6ePKl3UXbuqnGTxHWx+1L2saBjPj1dWEOQa7rN8kAE9oGUmvmRipETmvTzhyCKH+eMs+Bz9kLMcYnXQ0WcWpOpT7gEqyQQ2vq7HYMGW7btPa5dA2ZDk72CYkUb6vP1S1r2G+DyXLY8+RyL6I+UUha8ay5PcO5n7gxM56BsCza2buo1T6xckNT71v3Hueh0G/JmBQf/XR/Ld58ik9Tn039t7Y96xKBouu8m6YH0ifWkcDtMoLTk9KDiCSO/61UFdSRKAcd1kjI369JGm03ojIlrs0VpGiSQXfN9z57ytrCer5XvWZXVlXNg49dcdcZPAVrmM7KtxcjfGXWESBDP5dGZ3Q4JLjXPwCGeof5UcutGXShLugpFbzSU+VwUGSg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29047ac0-37ef-4995-2b7a-08dafa1899f9 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:27:59.8561 (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: /uTlCyRQBC6WR6bHOudwUyiRu/QpOFwOf9rs79DAGA8MEFJ52h7UnyqXBmMsnCZfualruhQpfWdtRzSdFzik8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9376 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->v4: 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 Thu Jan 19 12:27:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107815 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 3281CC00A5A for ; Thu, 19 Jan 2023 12:29:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229989AbjASM3W (ORCPT ); Thu, 19 Jan 2023 07:29:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbjASM2I (ORCPT ); Thu, 19 Jan 2023 07:28:08 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2055.outbound.protection.outlook.com [40.107.22.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2974C5CE49; Thu, 19 Jan 2023 04:28:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RPqCaak2z3g9d6/9sYJGZqsRc/EiQsK3diEYzu0upxw7o0/MIiIQh+de9H9RZq4k95WfX/ocZ1mgr+PmqWXu0tjFDiyjNzAvkQz0v+eip6oeKOeBSRxR5d4TDdqeRTGyHQeqKePQquSQc9bWKImdf66M8Pt9VJE65iSo2vw56Pwb+uQ30Wsk2RRj7O0Bzl/ZOMvstKqxr7NtkM+/YsyyHhyIuhHW8yicwWVSnOpiJcW98mcmF9Wdb+Dhw23I1jZxmUDdw+0pXOKxdLTSr2EYqnqxb1B+aDrAv9N9QeudjyPSO5dfgQDTEcaCwtsJdCnl9GOjekTj7fg1W4DZPBiiHA== 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=JSmvI1kwqu1rshOeg/mzMgk5FXONNHJSpRncJdwrN8Q=; b=nVe5v1ihMuRNk8V/HlKuJOV7+OcUrD/BANZW9iGfv5ai6j+flUqEcJcEkeEuCGl48shZM8juPnQm1w5d/XlGkm7RKxrXDCkbk/y8B4v5SL1FylhQiQ7eiW/YwDcsPvDQ+GmeX8b/MIIotiJyGVV6b7jbpTef8Lxu816rUlM4SfVGLO+7G47r1ObAEmodef/LaYV2OPiCBibGRcCoU0+tJaO5jQBJUqPh89ISLkTujZBiP63IZEHKq/L6rYPZeO4hZ62x273lualTMkw8kel/xtpCCWOlRW4lbzSk8WS+UITIiaMH70zGF5G5mrxmAw+n5FqGUZTkJMwSl9M8KyXbEw== 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=JSmvI1kwqu1rshOeg/mzMgk5FXONNHJSpRncJdwrN8Q=; b=MGhU/DlhBFaRMNu8qzF/FLxSD9aBsJQZJMe2ZOhVMeekqBPyJO5amsG1KajEQ123BDeorj3UIyE2t/pMSryvYMBjaUTtX8r6xpdqMPaYomC5Y36PrDf5M+oPI2/sNavwy/eFSRlvY0/+MEURn8pHcgjxTV6rL3LFPpGaUB7FR+U= 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 PAXPR04MB8206.eurprd04.prod.outlook.com (2603:10a6:102:1cb::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:28: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.6002.024; Thu, 19 Jan 2023 12:28: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 v4 net-next 11/12] net: mscc: ocelot: export ethtool MAC Merge stats for Felix VSC9959 Date: Thu, 19 Jan 2023 14:27:03 +0200 Message-Id: <20230119122705.73054-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8206:EE_ X-MS-Office365-Filtering-Correlation-Id: bfcee6e5-765d-4733-79e3-08dafa189b31 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: //I1r54IFaCp9iwtX2klW2ub6jhqk1wsC3/zIlNP3EmN78Bcvyx9ZS1WD20PlEzr1M2lHPQnO3Y03tcADeSpp8sOmSrfzjdf7NYs0qiaflaUqkIEQ/BLA2on0RMJ/B3HfVptTvFrk9QHJGLZruMzr9QBDRpXsmJXRnrJZVuGFkFHuzMOg3jzsPcd8WIJdtfdJJGjaOFkvtVNVozm76cxdIm/yWxwP7mqyw/NtseDQFk/WsGWd+elgd81lLtVHV2IbsCX5lmRbCmaefLngwqx/LA7OgMxE46+vuEHDW+i82O+sxHy81yVeMHb/rlWpn5XNUSsEeEd+1fvBa0e8tm7PE02xyW2NhKBHpEik3iw+q1lokvBY7EUeA1nFdcBhMUlqkWObXE1xKBnMZf+1SQVKpB6qcpBCn9hl81qPboeAPsHHVLtYl/mh3/jrVaekeBBWOpQzv5YXHsVcw3KseT5jaXYIjIWMeuGGyrWxFgA7goezYoKzR1vP1nKWgS+xwjDw5fsmDoSeTiIGZsVwReDCpe0w8fbYJDm5ulQdvotK/UzrHqY4PE6s5aNb9Td3JGxr0FhmupnX6j2aDVisbeyDkf7/lZtX2EYzgAW9FAeNOaxKsA+JeA+QSbZ2Tuq7YuRmubNawAMTdQCKkuU8a6O40QPJYMPQYoz0uDwu6kitR+8yI/E7FgKwueAwXiT8eK4MTpjTrj+BdwX4L0gfvzTfw== 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)(39860400002)(376002)(346002)(366004)(396003)(451199015)(6506007)(86362001)(44832011)(66556008)(7416002)(5660300002)(8936002)(2906002)(66476007)(30864003)(66946007)(38350700002)(38100700002)(316002)(52116002)(54906003)(4326008)(36756003)(478600001)(6486002)(6916009)(41300700001)(8676002)(186003)(1076003)(6512007)(83380400001)(2616005)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: meapa64ukuyPWSOfh+Qd1gCCvhoVGZB8H29m/rsqgF5KNU5N8OK1WiDomH87Md/HQx8YR1v0e0ZZZ3bV67TAJoElrBSjPsErXfh68Umk0zxRyXC5Ii/LnEzWoIZlci4hHrtfJCle+WEofFwko0MMSDkgWXdoGC7LjbCVxLS/Q8mGDd0uwz5/Ip7QrJBYXzfXKvn0GrL3bNH6rehAF7Qk5H9jIINJflCaHztwnAPmOMAH8EMZruhySioVtkdsS+Pwj34a+kz3Dq3ITFnj6xmvIbCjCSdIMqvvUK7YvpbFpg2j0wagNstM2i4Xk+LHjOItmLVSs/bnjPQCmTYNzP1hw50HxaMmJmxvEjz35Al/ErpD33rAPrAWPG6kzqTyPfwLbERhOA4b5W2+TUCTYdRHEaGv8uENd2DFCRZ8dOLwwz+9MKLohDwcRoWe4ouP5u4Ks3JMWiM/cJROwM53fxfraxJfUfmafsqHPIT27V7WPWj5XHSLQKaptXvZEBj5Rn7AB1DptSPt3fGi0vCaNh7TypeJaNVBKQgd+Ajd/ASnh66T5LGXidcXbLhwaEHfUvD8MYYtmwB/AeKIcnUXAEli+m2CcQnui2EDaXgt0sKw2ebdWwPygZ+dbRXR/04a1NxxThVXyFo4b0Wx0YuzO7wbfDlSlb/ExKK/MXN5wNwiq95mdBVWs+sXWx+Quxew8hSbFR+OZbjCNLssvNkvZjZo1uvsfovTMJbIrU+SbcM5i5Mx49lD0ImKv4xa8h3WNvNZxtC13JZQX7a9HV24rECPx0s/LkVxV5bNzKwojpWZm+Fn/VnjWZtFjEaKWtF/WU8nC3DwjebNRo2TeLUS/AGI/Daa06UAr6PKv56CoeJmcLc4DLqYvRkkco3tl1Eb85NrMCUmkfehg939U+eL/60V90QvxSaZ6ItRvLlWpGhP+8SC3FWpI6TxMSGFpsFIviAopQBN5Vk7U/rE/+X5ihKJBRTrzGmYiNYcIypVftl22Ucl5ZbA3lTTvah0GLqKwZkOm8gbkgenGJFMpxjIqf2cT2Q+nbVkBdvCieEM+pC9H5OLs5kbjmvtQI9poOTVvuZ+81JJivEErFtsHDiXElb4boK3sRxZDhKguubcSEnHlR8VrhX+8tBvg4qI9PLZ+9sF++7wFv8UQGddatDC9tzLPP2eoePXkjv8LV0nwtBmwyE91H3JLJ+jpEt7VhoCZ5OMN8JCRn02xe6jMZO9sYvnAOBvl1UCRRee9d+rH5FjMMAnLPNugfdTJdn2JVJgOoflMVk0ucLV14aWfjWggP51kxi6rPr2wKhAXCNbvPAW+BqQhhqweykaDK2KfyTemcVLjkQP1Ab86fW7q3X6dnRCdaVgdHXa5w22DD88X2A0ZjxRF40jN5c5aGP/HSV8UePQfF8hZOY9LANUenzVgDtWdUK5vTgiCFNrFXhtmES3JkQM5xoFnmVjpItuwrw7CrTn+M+7l5Zs046o1f4Sa0IL/IiIK+MRiS1bw7N8ldg0X5yrPYCs/in0pQi9fxyg3DQ+uKVhpts0uP00L9A9jzpreDdzvjMoTUVz5CCB/Axd2SxRW/xsVpIU9yBMifYZORzo9hNhXhCVJaBre9uLWmtuNA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bfcee6e5-765d-4733-79e3-08dafa189b31 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:28:02.0591 (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: pu4YsrCZopXRrIHlqc1vr6FA2W/3wp4YsThDMaRz2AJgqhty+6PmG0n51hwLOEuRHuiCs+u0DUN036UJmZcU1w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8206 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 --- v3->v4: none 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 Thu Jan 19 12:27:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13107816 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 887FEC004D4 for ; Thu, 19 Jan 2023 12:29:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230195AbjASM3p (ORCPT ); Thu, 19 Jan 2023 07:29:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230152AbjASM2L (ORCPT ); Thu, 19 Jan 2023 07:28:11 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2055.outbound.protection.outlook.com [40.107.22.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 273B375A07; Thu, 19 Jan 2023 04:28:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AIVnz/eu/Pb4DOpHFIuJvLzERKkJ9ss1BIKQ5m1k9XPAgBBbhvPQWjX1w0HF8eoP/3hXhoegdm8O/2smzLBmEekstZQoqJ+TvSYDtV8wrY0kIbKdFQOx9MJEztOQctkbbTmTzmEg8LS/1V6JWrRfCDQ7V9XqCTaYvKfklctsCXAnaK8zM9MRGiSuq1b8QuDn7QelsHj3nSL/TFcKwIFiiRbFR0cEWZir3eEbPnOpVnduOH7WGyK7oJxrGOmXBzSifcKqu1VR/6ZbR26sN5wJ1GxY1ktfwyS/GQNQx2TdL9tfx+5qMoue9fIsHAVNDWIZ4afF2wEqGFdvz7oBUpm0gA== 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=ZlCEvoaAPG8zFF+Mbd/9J6dxGXSWjWiWEeqfx02DbA0=; b=SrE1Ou7EHtofBzG1crdMNTY/WyU/fBDONM7isZ4zMJ4tQShLZ7FfIAaf129Bc835WX44jqCTT94CTTvUqE6Bue9PdhHphW6Hk0FsZ5EkQmUN2KeO7kliv29xurY/L6eVUr860zdYRr9xx+E4lSxnO/QiQ/dMoIea8SqfTUC/Dl8FhxqVkTiT8/m1zUoehKxulUqnK6DC7xo7Li1ot3J901nqFXQQph8Xa8puBGu0WTD6Rra8C5j3zZN8m+/F7CyBDj1QTf4istZApf6wscOU8s7fJuPomgFgr9aRZSwRtijUeHfU+aCij82L3WFhNCKUH0uoA8Io4rOtFkkxb4g8/Q== 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=ZlCEvoaAPG8zFF+Mbd/9J6dxGXSWjWiWEeqfx02DbA0=; b=dyoSZf5LmAd1NbzoEunwYD3TtFdNVK/nvhtVPz/jkVUg7tG1pcIPJAejS2fIx8vGZ7zXLl2maYXdPKOTUHVLk8mdoOmLXKBI1m+Sqhg1pzOhrQz+P3aRBCxzIioj6gcDrUupMQ7LPt+v4CUkv8jRNEb7MRbIws99otUnGjmeoQY= 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 PAXPR04MB8206.eurprd04.prod.outlook.com (2603:10a6:102:1cb::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Thu, 19 Jan 2023 12:28:04 +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.6002.024; Thu, 19 Jan 2023 12:28:04 +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 v4 net-next 12/12] net: mscc: ocelot: add MAC Merge layer support for VSC9959 Date: Thu, 19 Jan 2023 14:27:04 +0200 Message-Id: <20230119122705.73054-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119122705.73054-1-vladimir.oltean@nxp.com> References: <20230119122705.73054-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P189CA0020.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:218::25) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8206:EE_ X-MS-Office365-Filtering-Correlation-Id: fe5fff0a-f754-4cb7-01b5-08dafa189c84 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HNV8K6iwEy/87eaOzA/7upvtTUCTBk0cpbBvMiC1x6l3R62vv8iPfzWFn9gXEizsXcH2nNerKNuT07RahTiKPrmdK+0Oi9rNa0kggrJ3nN6Jm+eLaswpQTTrQyeR5fDmJW1tMA8FCRPkPMj9DlHtTzKJCVHKasvWt2nPYGoGh38+SLo2VCFxtywvEUwFV3pECNSAJbT1hJ2hG8OSuGvpeGJ8CxdU0IcwiQiLSlL3TX152+bGKJ4kUfBsvLr+ciIEA9jNLj7wBZqOjUXj1+h72Jfysyqyvci+amASLaTnfVRH8CLHq/2+nxu2oPLce6Z63KfdvqtZm36rRD94LtGtQmaX62VAKKjMeysPiboBYHkwAg0PWXNIh5TwG8a42cORTijO1caJlpMVkZwik5RMZcLM1nB7BvtJDUrVLaLoV1gDtZzea+85Z3NUcG/voHAS5PuM39bxL4mROfcJ4Xv/4idygHkt2mLLUnFT9aN+YgGmyVkiWWViRd0xoX6b6d5zz0BDCI/D//0W2+ino0mF85JVN1siDsmK2SK2Q06xfusIe5yhErlE/kfMSpiLaixyqCe3WLtRX/CyBPjo2vvjj+Sk7wTVVUbKicZXvfKCPz0TzNP8+747NxwxflrfyPNIdTnyE2BBleCoBC5TygHdaCUsyiQi2PzcY+2lzxIgBnnVf7R15W5vwNwnaa+6gQ1i 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)(39860400002)(376002)(346002)(366004)(396003)(451199015)(6506007)(86362001)(44832011)(66556008)(7416002)(5660300002)(8936002)(2906002)(66476007)(30864003)(66946007)(38350700002)(38100700002)(316002)(52116002)(54906003)(4326008)(36756003)(478600001)(6486002)(6916009)(41300700001)(8676002)(186003)(1076003)(6512007)(83380400001)(2616005)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8gmT3QFppn+dp2pGOz4lWxEEJMI3bRDVL2znKdxrR2CfP6pXvDssE+A7qE8UsV2D3J7azjkXiX7ILAH0ZTnr+tsdsa6a+8JbUD/+KxO/JJyOG2Gc6gM0A1MSi2+BsKu4k86OvbXn/9SSUZi5cfNyOWMppUO6dK/yO6H3Nu80uWkfBJpwWFdeoFUl88CrIKyUu+Z+59N2V8omrAsU19VYW3P4d8f+tmpWCeA7YcV4NUccyNv+qMPi9WbIrK0Pqyc42ZwgzKxDn2wbp+OjOD0zAySrjXS/AtPUFhri4yXdnugdoM93cp3WZ94sITxvPPjd6emK12vAvWQ33RJjRFAS95qmwTB8LmAfTZU0pOT9XoHcaXzYx20o05m/iUSKG7p9Ih+a45+c8hal3briE7/kCjT6220zS7fWHjpDrjpzB6wZiQOU7BTo1DbuU2TFWmdUPuF8S28G2C6AFWDDNidHx3CoHMPKnTtAAIrU0GE/HT40P9+z9GST/MZK+hUlVEEyeuf48R1U34E/21A9H7QVN8kKkQPrFBUdpVXTeevBlznIhrNX6CIr7zYkOUID6bw7FWpa8P5nSKbg9NRzgTENUWqZlR5tgba97MV//tWxDP5WRUjFIFp9FYxLyG23LJFNqcaX2U/OyDJrUSQ3I5MjfyPYZzz49z6Wz/0M1rsLPHyYHu9x0nJ5OWay2Q5QlJHsaaVQb37+6q1P+PffYSFyu/sg6Iufh+S2FKUSmIKmUu4ReCAitIHgFnrsXzVdTc9gKIzPH1Ypd2rFSG5cIRMk/YsC2fRm0vMv04HZAUwLsZfiS5F1kDo1a08pfGWOadbQpuEoVp+fW1Qz0GBFb7DTh3zManl2lvDP/KnoeGFIImGSyfPpVYhUh3aSJDLR9gvvbnDRixkcIAzDHEHozOGvUBIdOK9y+sejIfcwMzh8fZogPsXKKMz0DGzo0hNfMTw05f/jXMy+b6DvnrRMLnyk8Kdxnx2KTXf+dFds90qh77asT0N+Tjql5YcuL0R6hPa9J2VaQLNV7l655grNf+aAorY24p07guID8y+XGJ3oIqlMgoyKEOvs6vvXXtivGLKX5clyzPq2zIK+q5ufi8SEgFcDqtLy1Yq0ejB2vCP/vOAkeRamxeZvAi6vrfATiYp5UuTSNCYYRwA1Uw0snlwerFZaYhtLOTK9N78hX5q2/x5ttMDQjrMpd7Kd3WQdFxc2ksUIaVuCQhUCRjVEn06sjXuinXuOf5C6ETw/6qRIxe8jDXMzqslfJ4kfC2sQ4wxD5EANXSFDo6+RDTEbabLwq1T0mrhsfR1ltWMs7Lbq1FSpgT44OzJ4MJlBOq+QYXyrmowJiXFI6CfcU1JEaiWMWlfCWnYxRvRUeK+Aqb9CvIn+m8iivsbujiRL0Hj6KYuhOHJ0f+QqRygJAB5dAdaO2wHvp8Gj2kGVSvEW/57nSMG69Jr/o6+oc4oSG7qG1riNTPNR4L3+A3YRlc5Urvy7t78oYEBypmbyHDKqmEmPKe5Qeqhy3T6dCM4EALwUvdtLCYmGc3cQscEThJ3TfpcOiwVYp2+am/OpvzSdkzgAcA/znDv3E0ewpVHuqws/a/XZbqXylmm1O5wakduzh7FXYQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe5fff0a-f754-4cb7-01b5-08dafa189c84 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 12:28:04.1683 (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: cOWZzh/iL9kMP6Sy4X8yyrcq98fG5r93QzaxgkQDxP3s5wK52TLCm1l5PhhndkDix/XwZ/YRU3tcF6yurq54XQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8206 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 --- v3->v4: add missing opening bracket in ocelot_port_mm_irq() 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..08820f2341a1 --- /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)