From patchwork Wed Jan 11 16:16:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13096908 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54BC2C5479D for ; Wed, 11 Jan 2023 16:18:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235411AbjAKQRm (ORCPT ); Wed, 11 Jan 2023 11:17:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234496AbjAKQRc (ORCPT ); Wed, 11 Jan 2023 11:17:32 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2080.outbound.protection.outlook.com [40.107.247.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 722131C939; Wed, 11 Jan 2023 08:17:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gHRagcAPQCvv6bd3Ns5SBaBib3ppGY6hXsiLEna3wq95y4qnWqnb5nZ6Q7SURri/MZocr1U37BaZ/DAOxGSsoCm7PYt1js1ngP7iX+vcM0xfiPunnS6qrKitH1bPWZGFKQ+mYceaoBt7LIDXVLzNR5lE3jfTcrqfXKcp5MClg79afFRCKu+LRYvhUFFA+3ijeabBDwzGed8bUZeAQBWPJyuwXDvMYlL592ZqAK5ImZVYM5DXomVjgLzLjvNTxHhIHnvdqDXTJ/BLKiJTLjZJkvDkuPtW0ubRejulO4oue2T8nSS1UOtuXQZr2RA5GQcygz7+PbetF4UZSFwRVyyzjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U+K3mCrI0dzl3Y0k6y6S7df61prpHK+2vgLIdLHOEW0=; b=GiN/H2yMbmE3vGRLS38S7VZ7ywt4RILVu4WAraQQLXP4YJfqq2vMpon5ToB8bHgd6tlE8YyDM45oBUPy/K8il5qKGUgtLth3DmH/aaQncZtp787VBKfHez3394Zz426jO13Ji8IslD+gcB8VAPEf9ZqpSNFQtt2B49irVQgX+4/VfpVn0+iA1JXpPKmNk+ksNpZ1w5bqPONhMp6njUdSWQkEU38VnJEYEFF5ViHXqtGofXcGJIByvGh458gdmIvUVzbMb7SywdCjPA8cGbLlijse3O8jVp/u2ovPWjUFUicQzLgqpgEVouhdek7Cc7L4RZKMVpUUsnyoEuXo0P6+BQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U+K3mCrI0dzl3Y0k6y6S7df61prpHK+2vgLIdLHOEW0=; b=PfsOzVCgme38DLwSzVtlNWfEH+Zm9CXVHxpqPbEduOFpwjzBV7ZAktisuZAEtVgMR6tgeeABd0MV/nD459U9lgZ0cazwMsi3OyEelGMRqOf7Ofll4H+xKs4dalLYF1EL6BngyDW9lUH+x4aMvuRqOVee9vCbq0nS/5znq2WAH9c= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DB9PR04MB8462.eurprd04.prod.outlook.com (2603:10a6:10:2cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 16:17:18 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 16:17:18 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Kubecek , Claudiu Manoil , Vinicius Costa Gomes , Xiaoliang Yang , Kurt Kanzenbach , Rui Sousa , Ferenc Fejes , Pranavi Somisetty , Harini Katakam , Colin Foster , UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli Subject: [PATCH v2 net-next 01/12] net: ethtool: netlink: introduce ethnl_update_bool() Date: Wed, 11 Jan 2023 18:16:55 +0200 Message-Id: <20230111161706.1465242-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111161706.1465242-1-vladimir.oltean@nxp.com> References: <20230111161706.1465242-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0163.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:67::8) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: ca3d3772-e488-4dad-c386-08daf3ef4f1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tsx1WU9uDnhYv6TkuzAvPBxtrv/BO9E/bbvkHOloGVDTWGNe5+B83L/PAp7bGqcTAa3w5PqDLZV04TQ0GU1AXltPrbdckaWSvTFzWnD6rxv+nFWNMdKaauxkJrYNManDD0qFWwyipNemF20ShB9Z89i/kl1ZrNAVZhBXAaihx6NZT5bp/QXqv/VDah61zJAdopR1vNBpJ/7PuLaIQTzqOeF2VfueZdriEenRUXInb29LI3VagvnruDLwQVHAwVgiH6mEq/wrABqMrg7vjV57sGEKWp312zKb3lDLjV4JVF/8JBJy5kI9ivzfjPQB692TLdX7lJum8F5cqmQXJK2D3tN+3K9AjELdSecxnFDzj5V0eeZGqAFtxOyPtib6GrKSTW66+XRouUozvOKAVBveHO3oJmkXX199XdDyMZfd7cBjbAPAqB4s4OfdCDK9QfV0Kl1D6DvdFreB3SGLAgpiCJofGF93/w2M925qju5K6Vbf6SBDrXFp/BezC3F0m4kHEKKtZ2wdNSdJAnECE1z0q/t+ZDc1Pnq4tX5kwew7UYKTmRTyP21dqQ/cI658bjNMNqXwJ3tRYJ1rFOnZgL0f4greXyXfABL7PArE9k3dUOCY9BkrsGA17v3/1oEyjHUcW6G6z06yoQKgtZe2kHRNQmI69U1pOReiAl/NrtHq8occo2h0soIiEY4THOFH1KhWKi2jIWOPAEMvG3ZQRvNiyv05T8y3B9cEaN54siItCAw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(36756003)(26005)(186003)(8936002)(6666004)(6512007)(6486002)(6506007)(1076003)(2616005)(66946007)(5660300002)(66476007)(66556008)(52116002)(7416002)(6916009)(316002)(4326008)(86362001)(41300700001)(38100700002)(38350700002)(478600001)(54906003)(8676002)(83380400001)(44832011)(2906002)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w+4mAdpHXDDBP1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KJOtN9igxFcpT4B6v06r8HtceBH9yVkjJ4tetWw/Vxaajo9nVN+j0CguKjR3HnO5YyA669NL2btDfnfuxllxnPJwtUgXNyR7dj2WjXlbxgYxpvwSI6b7Zeabpoy4FPWWclMGm7GPmHDvVtUbBgGEFNPNFjPqCKgNz7V3MTM7fN9fws7P9f4Q+D2xtpeSjY1lJedOqfW8ZvsTwaqFyZV29PHO7mC9za33J+uoriQMoYkW3AbnLP2dujc/IeCwEZSaDCsU7T1HFe5sHO2qYDzW70Jw5abS5DoBNkdu401D2VdjPQBNPbn5xriSmBppakh/PL8ov6mV4ZcbLH0JDp6EvFyynbDXF/k7CwSnT8Ulk+6xUkNCMk1Wp/MF84SXpfCLuhCjevdqi11172fpGTCcz4Drf/gmi5LEFifuKqIiFM1g0bWYhOunJJWXpJHPMHxhvT9mzBKzTsuFVWAjXQtUZoWFC53sfQe2E0l6v+YTmj9jg8fEY3pY8JorUPB6M1rhF9rP1A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca3d3772-e488-4dad-c386-08daf3ef4f1d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 16:17:18.0336 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7ZBHiy6hh7y34iz/Np0qtGXW5T86mfjciLPfbYcAeBome53HKQceG0Sinr6Cf627rZgIPlJVo80lTIgakKVbtQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Due to the fact that the kernel-side data structures have been carried over from the ioctl-based ethtool, we are now in the situation where we have an ethnl_update_bool32() function, but the plain function that operates on a boolean value kept in an actual u8 netlink attribute doesn't exist. With new ethtool features that are exposed solely over netlink, the kernel data structures will use the "bool" type, so we will need this kind of helper. Introduce it now; it's needed for things like verify-disabled for the MAC merge configuration. Signed-off-by: Vladimir Oltean --- v1->v2: rewrite commit message net/ethtool/netlink.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 3753787ba233..744b3ab966b0 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -111,6 +111,32 @@ static inline void ethnl_update_u8(u8 *dst, const struct nlattr *attr, *mod = true; } +/** + * ethnl_update_bool() - update bool from NLA_U8 attribute + * @dst: value to update + * @attr: netlink attribute with new value or null + * @mod: pointer to bool for modification tracking + * + * Use the u8 value from NLA_U8 netlink attribute @attr to set bool variable + * pointed to by @dst to false (if zero) or 1 (if not); do nothing if @attr is + * null. Bool pointed to by @mod is set to true if this function changed the + * logical value of *dst, otherwise it is left as is. + */ +static inline void ethnl_update_bool(bool *dst, const struct nlattr *attr, + bool *mod) +{ + u8 val; + + if (!attr) + return; + val = !!nla_get_u8(attr); + if (*dst == val) + return; + + *dst = val; + *mod = true; +} + /** * ethnl_update_bool32() - update u32 used as bool from NLA_U8 attribute * @dst: value to update