From patchwork Sat Apr 15 17:34: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: 83763 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1165539vqo; Sat, 15 Apr 2023 10:47:03 -0700 (PDT) X-Google-Smtp-Source: AKy350ZrSWe2LulcGtZQq2w/kKT/JVRFEGheq4JL85H010mwo0qc1y7qqPP2W8N+dS/WVU1gORGZ X-Received: by 2002:a05:6a00:1356:b0:627:df78:3b22 with SMTP id k22-20020a056a00135600b00627df783b22mr13525385pfu.0.1681580822953; Sat, 15 Apr 2023 10:47:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1681580822; cv=pass; d=google.com; s=arc-20160816; b=JXgGvGn2JfHITehWQjzax974CNXmkAApjdL06L2WgcHSGT3XUpbNVxa3Z25pzb2hRw AsN1UZvnTp61UMkc6TwIREh6pyu+UYDSmcCNqP3Ik/L9/towcUB+LYM1KHq/U3V6vgDF qKq3tJC2CTzy4RwY1Wl7NN5BKutFQOjtG40f84fXaISdud9gbN1IfACEAgXdKYfGSAiJ XMMXYfWTh/K5yGAylvBWB4jKWNth1lkzRgzn3ux4P66m39Cedm7HCdnS/4r/VA77G0pu bxDwMLdxe7NZYKkpomIC34BGVJI2ABZdzL2HuxV2VE/cduApvaUry3iLX1GRFLtqkFLr QZkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=djx9s4StOzchqIprWsTAWDvMggpPNPgl3/lqTPAuDCI=; b=J0pnqLXALQ+PlnabaKnF2JvvVvN6EmmVpvVUGqknmnwSy2wbM1gkPhZr1PtdUyIv+e QVJeFMk/CDjlMTACVCRbylpEq8XnpheZrbfoRjwBkk7+aKetSRxKDLNEq2K1PjT/mp9d UdZQOqsk7sS/ymmOFbl110o1Ko9/++Nnu/6O8igAF3PsxRamkF+8wOMg4QiyudyVO7Qm s/aUFo55pfqm0uIBahwZ78Us9rkEyiqoob6MuG31Je7D8F8rP+LCmyEFQVvc8Ph2GTnq m64mBed/doeTTAxdHMIrUQ3lbLJqdSIfUZ5C9JtGYCwBSmXcT4rdvsZMS19anQz/xcMZ nNoA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=RY4LRiOQ; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w26-20020a63475a000000b005139d2b9306si6998608pgk.514.2023.04.15.10.46.50; Sat, 15 Apr 2023 10:47:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=RY4LRiOQ; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230036AbjDORgX (ORCPT + 99 others); Sat, 15 Apr 2023 13:36:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbjDORgR (ORCPT ); Sat, 15 Apr 2023 13:36:17 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2045.outbound.protection.outlook.com [40.107.15.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69DF84EC5; Sat, 15 Apr 2023 10:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ifv6xZGW5pYrcdIF2ccJaTiPgKagTtU6IzjoPen1MmbbgQ3+NXrI54uTykfQ+bxcduJaAopLeBjZXjrLCK2VN1s/o3l9/z7Nn3AvnqVLKKVmwwfCZ+wd0E44XnTT0QTa+CZAf2jle5BETJw6I7EYK2eRsHGalavZFFU3yjCIYhGuRJtJlc49MrPVYOaf4PzsPwyrXqrUdZO0kZwRn31lPRTRsb9OEyelMJCd87R04O8tsEQzL/UFoKSi9Ig22rDZoytEbKv6hhPlIySVydp3kwAhZJa0mRCKYBoDlT5SobnU/DQicpAraxmsxpGrHT8laJAso6FBYSTwu/rGYpkxMQ== 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=djx9s4StOzchqIprWsTAWDvMggpPNPgl3/lqTPAuDCI=; b=agbWG6uOY/5q1O46h+yk66RXlVzXx9F+y/8VIJsQF00K+kJzK2bUWSYM5yKbSnKrspkRbOIHjWoU8OeZttCv/aGaqZV+XFkJhlvFPJdRZ/iEAt47lzUqKZRrixzPwYnsQISvmbhNwLBGq4oDjIl9SEVlO3/txCwVOZoKWXE0BQNwIOlOnWdZmEu9GwLXGVzpF1eyO7IPZl+/PGT1h5boQd+6cPUlxXfsSyI7kdR23heOEmXBnNl4vOJKgvhZddO2kwpTEycFyMor+o1QkpDMJgss+1n8/0JBV3Xd0wTdn2Mu512CSf48hSVTt+/cXTdE9O7rAv7RNCQeb8DATp8GCw== 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=djx9s4StOzchqIprWsTAWDvMggpPNPgl3/lqTPAuDCI=; b=RY4LRiOQrEf2re5wCpv8XgGPbfZVAZq7epD5ebyOQLJmJuG+lOahuqA4/lXPO/RELLaMeGR2MNZ8p03NScFGbyIaUOb+KyXXGn8l4SOehicefzoTnyOp3W8FD8zbcnrnuVuEaXk1ZPdCvB1/+77LONmt7vfbHN15cG0osQoJD3A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AM9PR04MB8322.eurprd04.prod.outlook.com (2603:10a6:20b:3e3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Sat, 15 Apr 2023 17:35:57 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Sat, 15 Apr 2023 17:35:57 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Michal Kubecek , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Xiaoliang Yang , linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/2] net: enetc: fix MAC Merge layer remaining enabled until a link down event Date: Sat, 15 Apr 2023 20:34:53 +0300 Message-Id: <20230415173454.3970647-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230415173454.3970647-1-vladimir.oltean@nxp.com> References: <20230415173454.3970647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0156.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AM9PR04MB8322:EE_ X-MS-Office365-Filtering-Correlation-Id: e656bbfb-1672-4b2c-2478-08db3dd7dec7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +0bZ4+eoTWSkt7mKkj+cMJCdjnxB81y0WlnyaEFPqff6GpEqLOWED4nx26R54eLJC+IaH7YfPaEfvNRJyT97e0cfgeP40WHIItVKg5xvLAu2EqaNutOzVEQqBNizYbKDFKp45M0DWKsTl8tHakmOemcBNkNo5zanIMIAxOI1D5SVBPBGjzkiiUgu5nYzYRA5iCVQ8BMb2nuoVJubiEwpT+YfLQhRGYbwLyPnTLZbN7vhGAeTr7yuWzqrVPiu6GWgLsJAzTyjEHSKb7CE6/f6EHp/toIFq17rjscWfkVCoVKpFJBGJ9kdJGiVTuoZ5Yr4p3eYyfKrTFksQ8Ssh+HSPUff1AeYWhYueHOGNkcKnYE1yFrgITXKubNd/NOzBhnHzx1ccBKvofnOgldIrPpfblXBtRH8l7Mstuabkyd+ov4Pr2BkuMHIXpl3Kg0dKRiMsf22byj50zW9Dwuot47M+7QftfzZtFkbzq6Ykjy17S2ktmC0VL8KF6mOYQh83JfIlK3PtI/zvdvsUmOVPVXgECTFgs+J099iD04KjjA0umpdBiWL/uAc6f/z+N76X1bdKJWMXCoeMryRqzAzxw8Qd/WbXsgpIsW8dM6abDTCrFluA7kcoZ0CvN2+8zbkRF0S X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(376002)(346002)(396003)(366004)(39860400002)(451199021)(54906003)(478600001)(83380400001)(1076003)(2616005)(6506007)(38100700002)(186003)(36756003)(6512007)(26005)(38350700002)(86362001)(6486002)(6666004)(2906002)(41300700001)(66476007)(316002)(66556008)(66946007)(4326008)(6916009)(44832011)(8676002)(8936002)(52116002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E+ks8fsNouY4ldrdvEDGzBPaLSpgn52X4+HicP2ZyOrl9aIeKfRXmiyCr0Q3GIdHsWOHEVz0Rtd66ZEbuxTmMN7+7ZleKeTC+4hXateyZ3dpqzlhCXeXrYbLE+XQgVhHyKwRNf0AGpuxY4u91Yt6L4/q7TgG8tBlwhfNPyB0WgYxjb5nSYKAOkHi7Te7lUo5Rkld+/Gp0CKCZ2j+yhZ5RT7miR10FiLQsSUgTc2uRXMd0ld3w+CjTxTR6/TBMnkYcoNZWGIRxH/XfkIsu2V5fMK+nWazIzTjGY3foxtLCpRS87cedldk2GJTtE0/Qsmdawv9ySTTO6SaW52eVdvalKNK6nQjBIsa6jYk005SHdxJDxGjR2GNGlnvF1tO6V1RLJ5eWxGoJbTevpLojMEBwht3Pg8Kve2IbxDmbcZT4456u47gCprNVxcHtLvKdfThHug6mUXDWNdj5fVNGZ/WI1sYzlgtYiFJWEeKANHdmsq1uHK6jjr39xyJndhIM+RnwrFjsijpJ4qz3X4nLToBuxwuWPf96AGGnJ1vCCH0qsVnG6mLUXBRTA081hFqpKeBukw4kFsiuAF6OqZpYa31boocqTocsj+qFbbq98OSHnvvrUGWZze3/bjO7VMgPgce/Gihp5855ki+4dEHCFgiSBRcexnbw/6hbZRnapBCPUU3fO7ak27b4Sae6DduGbLQekLL6+tgAmcnT9FyifEKCdi7Vv6r1L+84lmk5k/KO9ptLRIZtTS/kIgj4BT9oO/Qn9HxLAF9wdRw9GUBPZnL4g3sGYD0hHiSMM2a3moQjEkDYSasHtA5aP7YvkLEOqJyn1PjQ54tvF4OojMTn4OlOFyJitJeIJUvtiWBLFh5SsmvJrbptaIThnYx0s0EimQSfhuEBohx159wI+FrUl+qE3dYV0IkWDIupHm0w3uZ+WSizsXsD/hSN5e0VLlwwBntpy963YjtVy1ZHaof0kaJ4hI0ZLyI+aZAwLhLxHBEcSHlpwwWdcASVkSlh0XE1CwURrShZyoVIedAuIflJuSKfkCIzc+oOWBdVUdUT7t4lI8060XgaZU1xgArwvc2kXAVtaO4dtCKgNw+Jv5gCYDWBVLtF+kU2Ob4h+mXXpVt6Rd7LQCxZM+Z4Bo6FA6dMLQEHVJ3XnyWjpZCAKkvHaRnKZdujJxzhLLcU3wubXJtSiiKF2pdXee1UV800uEiPo27JYYdFTJTTRC/Qi8ZPMScNY0rRUVb4Z44Ng12AGVDEhftAe6Swu3U5a6965pwSLl7T7hVxIuB+aIpUNVbYdvGvuLkmCxgPmOkWciRabXgWVO/2usBBPlLxCHsfg95httQ6nNBMPB/4PBwMXRl3cVzPWJiFlHwBtNdfMjefgNIGpjmyE/yvL4u0m0/2yKPzZCVqstqb0fM72v4ilObNPltxz8uVybeyyU/ZmEG2FESCwICRzncz+QHhkQnro/axRPrfPn8GhnO5o+vdjnPUKGliJJ88Lv9w1wNnnXoGXC4TO6j/SlgSK6I7h0l+JC00cv9ssUaCXKaGa30i6ADlphdfiIK9+aPNDQBLZxq/hqbARfLS+0LAiLRQgqYfQW0+iZF88jlV7UJ8zyZPCD8thSCuQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e656bbfb-1672-4b2c-2478-08db3dd7dec7 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2023 17:35:56.9770 (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: blcHeQwRUYxRXkFNVB3FmSzYKPeaUlnJ+BjJekFhQkrX8QrzDpdr1NA8wCtaYM/k3vfcUE4pvUSftYqJmT5fPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8322 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763265292651955394?= X-GMAIL-MSGID: =?utf-8?q?1763265292651955394?= Current enetc_set_mm() is designed to set the priv->active_offloads bit ENETC_F_QBU for enetc_mm_link_state_update() to act on, but if the link is already up, it modifies the ENETC_MMCSR_ME ("Merge Enable") bit directly. The problem is that it only *sets* ENETC_MMCSR_ME if the link is up, it doesn't *clear* it if needed. So subsequent enetc_get_mm() calls still see tx-enabled as true, up until a link down event, which is when enetc_mm_link_state_update() will get called. This is not a functional issue as far as I can assess. It has only come up because I'd like to uphold a simple API rule in core ethtool code: the pMAC cannot be disabled if TX is going to be enabled. Currently, the fact that TX remains enabled for longer than expected (after the enetc_set_mm() call that disables it) is going to violate that rule, which is how it was caught. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c index 838750a03cf6..ee1ea71fe79e 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c @@ -1041,10 +1041,13 @@ static int enetc_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg, else priv->active_offloads &= ~ENETC_F_QBU; - /* If link is up, enable MAC Merge right away */ - if (!!(priv->active_offloads & ENETC_F_QBU) && - !(val & ENETC_MMCSR_LINK_FAIL)) - val |= ENETC_MMCSR_ME; + /* If link is up, enable/disable MAC Merge right away */ + if (!(val & ENETC_MMCSR_LINK_FAIL)) { + if (!!(priv->active_offloads & ENETC_F_QBU)) + val |= ENETC_MMCSR_ME; + else + val &= ~ENETC_MMCSR_ME; + } val &= ~ENETC_MMCSR_VT_MASK; val |= ENETC_MMCSR_VT(cfg->verify_time); From patchwork Sat Apr 15 17:34: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: 83761 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1165436vqo; Sat, 15 Apr 2023 10:46:44 -0700 (PDT) X-Google-Smtp-Source: AKy350bCpUIwUAO1U+fY8/g9ExVQAP1r8/D5JV54GAFdGGR5Roj1e2LnAawIULA/5pMPC/XzaRKg X-Received: by 2002:a05:6a00:1a13:b0:63b:7954:9881 with SMTP id g19-20020a056a001a1300b0063b79549881mr5799643pfv.28.1681580804319; Sat, 15 Apr 2023 10:46:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1681580804; cv=pass; d=google.com; s=arc-20160816; b=ZwcONrTs/83pvc6WqmIGtfJIjn9kYXEJrmMCDGqiGw8mkXspURVW01AAScHalP27UW MJowyRXcJWVUqvlM9H4MR12Hopq4K+ceFwiYrEkGDymlZlVGzMFNeoHaOX1b4P7Hr/um hQ8wIcVIvfYqWxD3xw+kNHXV464+zuUs2YB2yCfVw6JeHk61+iDbBEScAQO85MC6g5Df lTb+nacTQtJjNLabVxJyuxP+wVFkew2qWZwEUuxzD3IdmTwutJdJ24cjSv5C+gYFTiET Hw6uQ9iuMGvD15zKxmOFEq5Md8BjQaiAbmqkLXiPP0SGtoAf+/l6S1tHFRjbQz5Bodyf 4pcw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YqnotxNxZOo9YwZtR+TTEGTKUyCvcJSIimwo/xu5G80=; b=wRObWcoMbW4ivbwOBnAo0VhkwUz0rbh6VcUnqK71/ZkV0p2ORlHCnb+XXzO39LojHj zdwkwWYJgQUPL7GlDYX9gxYAoo4nLSIYKQA6RWoTUCbnYmLZdkoiOY9iNKPkXmbU8Ghe VK/t1U86gMUm11QeuG7cJBSwJZTcoiXgD1Wj5q/DhZ/fKLTrkDdYPeTqZvH9NvHLDX6w F3VwCnJyFHqkeOXsncTHEECKV4oDxfj9ssMcQoJYkgvVUK0NCQ2leI58dkfvL14L1XJY VDgmtxf1VyTbTnWUMPsSu8J/AmIQUMj77uW5Xs5P62iNA7jlyOUDjpJieRnPz2Ot/kzD lW7Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=BqbLK4uT; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 26-20020a630a1a000000b0050bc9305e5bsi7621154pgk.122.2023.04.15.10.46.32; Sat, 15 Apr 2023 10:46:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=BqbLK4uT; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230114AbjDORgq (ORCPT + 99 others); Sat, 15 Apr 2023 13:36:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbjDORgo (ORCPT ); Sat, 15 Apr 2023 13:36:44 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2045.outbound.protection.outlook.com [40.107.15.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC2D24EFE; Sat, 15 Apr 2023 10:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bu8umIQjjvwLIpmNbUKO4fRbBVSOwM9Gvf2MNyKe6sZCmIhxqUN/Tg3eI0l94izeGs701+GtrTsuePGYe/nPMM1X1XCtfRLLf0qqL34fQHQELdPcD8976pJf7aTeINfyVDmEAfJ4xgYWTOOa+LSx/ABvi+te7SREJt6R6EAR20NKU9EZywTdl3AnjdVzVj4t0cw9ym5JN20M9nFq5aD610kOtFryN2cmVyhZS8x1uHDPJbDbO8Gp/KHkr7a/VXMM82iQAUwiRkUFHmZND5H3cuCy94BZE4u1VmP7lTwbpbqtOdGQbQgH1omnrCfHlNz43F9d0a7BnLxWTTgmN/z4zA== 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=YqnotxNxZOo9YwZtR+TTEGTKUyCvcJSIimwo/xu5G80=; b=XcPr6pnCDrbFKJ9s4AQ18aruVkswhPlXEc637tkmU+DINmTF2TI0psLRP3QoS5QmUy9UFLnHQoUNIeHjtyOGFtNE5HV3tEj7hlMA0dP95bjI6sYHln3MoTq80iKomJMeMrcNpFG4ihdPcuHwIABRVcx9OTiktCG4iVUOTdNnHT3s50Dv3noMWZTqx2pGumP3+ERGuy8ks+AZ1MdSpbNJIXmLjnspvgeF97pR4mcQNXjd+QlC+TyWqn0xRvU6EPOOyDFWX1YMBoFTqwOGhPo2z9PNJfp2ksNJbxKi7IAL17clVyHJKBph+SN3TZZSa7AXLH7+TuysQ6H4G7MJDnh2Vg== 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=YqnotxNxZOo9YwZtR+TTEGTKUyCvcJSIimwo/xu5G80=; b=BqbLK4uTFeqmxNfA4iiWEuWRVvfglDbe5rrvX6Li9oRNKCoahYiDDnR2dFCtHxoQR/+bojtdwZHhgh4FnTIChbhRUJUb6B9pDabKMp3WsHc057+xrKpzR3aR36SdUn1P2I0Fjc9S+/r0JYqpM3vSfp6yl6vDY5qpgQVRX83Bc9I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AM9PR04MB8322.eurprd04.prod.outlook.com (2603:10a6:20b:3e3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Sat, 15 Apr 2023 17:35:57 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Sat, 15 Apr 2023 17:35:57 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Michal Kubecek , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Xiaoliang Yang , linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/2] net: ethtool: mm: sanitize some UAPI configurations Date: Sat, 15 Apr 2023 20:34:54 +0300 Message-Id: <20230415173454.3970647-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230415173454.3970647-1-vladimir.oltean@nxp.com> References: <20230415173454.3970647-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR3P281CA0156.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AM9PR04MB8322:EE_ X-MS-Office365-Filtering-Correlation-Id: d13484b8-864f-43ed-586a-08db3dd7df3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: moCyl5yxWfcQP6YfFQaHUkmKM1CPTYYNexJLb4r45iiC28if9tfUoVTnbkLwheDymfaBn5UMElQMB9VSlsgQ5P3heCtJJewfrXkl30zC/iMaHprSbk8m+KNL0et/RlD/MrR2gs7Nf1eyu3cxwX7hQv2MSX4yfeJ8Qt0s76+7FL3U5qRR/LmNtHPYh1tqhA293plLssqVA6wlckP0/vE9OcUnOAAjgWcGXYVsVAaOO6idrcg9ZGtNBesIS4Oi/viGliyG4mfZdNaOdPSPmYj5f2kXu9JqdH1aIWuJpUOM0JQEbgb1IgVgpv8QdbLbPhq/0R5e7g7/up/DVGR5v1jmhN1XaVDul6aBSq7fMp12S2qYZWMVK4REVWIFrx9GGs4nf9aEpsHq0H5M0Wu2H89G7y8VanUxnrCpcb0F3JB3JK7ZQxdW28gKsusRi4n8xGZ0uDOSNqHPHodW3xmzetieVZlZ2Ik1hPfBaMEHB+AZSbNHVFZ9VMYdrEV0e/QzEQQgEkcF8TaqInRCM2HA11D0e8v0cCIJk0Fv+HR3Sr/YytHiEe2E7YGJl8xN54v+oaz2Vb7VxbtiSBBGntYRfL6rS+UEPGzKTiTPm702K+DAzm8jaqLZHBtQqjqzZ+XaljAh X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(376002)(346002)(396003)(366004)(39860400002)(451199021)(54906003)(478600001)(83380400001)(1076003)(2616005)(6506007)(38100700002)(186003)(36756003)(6512007)(26005)(38350700002)(86362001)(6486002)(6666004)(2906002)(41300700001)(66476007)(316002)(66556008)(66946007)(4326008)(6916009)(44832011)(8676002)(8936002)(52116002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Qw+2zvcqj2vEjfjaYOeGbt3E+omC/1wTdmTeDn+WTnCFXQqsiWUBlAYoQncvbVVrxXoyDznVWCjj7zTe1UTfFMGCaDz14Q+c70hcNGm5G3qsunUJf/MqcBAvv0XBwAc+h4ETfLfQFj0rb1tCn0xiSAkFHYklVQfq1GKkoT4NfCRsQ9dLmx0HFUHQrnII6K+FFZt7dPS6gN6dk81FwYYKV+IeZsY3mPRIcmhWQnKgYaYBH7krxxR8DXNyDhm2Z3bm19JS7vXhMm+IfAPzs+yJkoMuv33qk9plgj21y1A6tKmOJ+HTZ4UKkvKHdwbMpIDpe8XF7F+d0OEpIKavE0xBX8URrVnjwQdZ4N9GxYfHxFA733U5tfu/oD59DxFZjmuEZbZpi9mxvwocNEoZXSjN3OrQcJ8SltRoGOyBZSrjgLBOuFbBW30ZUblGHxdcN4VjS1QExJx/+y9dV1ZCy4JmbmmsoVqF3kSn0p354UdvQLgtVLCmsCyPxs0fp6ESMx2VeWP9iNWEFu6mfZj0r2L4EJpGmNxg8dMJrbsO0O/VLhuw/jFxBJF1qPp3K0cIyrgKDqhRjDYifNMnBSBmGVeLM54h2rSxr4TphFu6idAGmEOf5AgxFvhk6uDvoccQO5+0CNF7Ypa0bLpqvQe7mlDGfFWhH6iFv0TiFJ2ZN1wSImu3klnDFpS2bYIXsOnWsFDoWGXu1d0DvxEvwAxHO+TovakTLvjT75GucTX2jXI06HXG6ta3H5jLcUuV1y6ZkMAVy+iu1hUpEoeXqC5fmgvl4uxOwWvqmBQtZgHfS2arKughb33Gln8QZgpg9Nv/ddr5GlOenOTUcKpA7gC1AO5Uc1nnT6Z+kAw/eMkSN5qwaAs5sdyf/ve/mJ7HihoDAs9R9V503sVqTxzLntNR2QQCYeL8IrJ9ES33LaL72xh033NeRwSg2IkT5h07wWouPlM1Fq92UklVDjIHBLKWDBWuoBdohT9zzHet3tP2Kefi/obccYIwCFLCK5+wuCgiEDRDfKcDuMQ41ZkWCb0FaIxd3v6rnrx4B33fzLVi00tXxdJutKRcH/yLpWTyHojd3B3hDzqWnMx8yuOZGcqPDYgiFeT3pBzFggM1EXa9613LHpc7XDfpEDZhy1HcQrksp4ncu2zUU9LJiF5YKyAY7HYIfhenoj9bdc0TFeoBMcRUDAEJa+1AqlFl4cWEnPdW5X11lRpuBZZ5pa3EvLDTJAh9WsOqutdv5aFJ5b5kOIHANX7CiPMaaCthwWCRxpc4CKGmHG2iYSosw2DlM4a1O7nwAUrjFxgAtqZykgtDhPni6uZoCtlGti2n+oEDTokAmqyi7BgLmtL+k5uS4qYQC56ictCW7ROcpGjZhF8KvM0zF/HGu6bnYJdCw7i9pYmLJv3tgDDES8n/R/Ce9zuuogwZmgALFNOJ41XCFjpmsOJGFNP2pWCcF76CcxRI/Vc/KuDAMU4tEHjIFrYuVARMHXjHt5YhE+zuTnPRJ0s7aCEJ/t9/LsXrgfDiy7ma3HSIjOccH/hbfVCqa/D3el0oKKWkHHZCsufvNVaoLg9Gmd9a3aaYICW/n6+KJZQxEW6O1tkrKcTb28mnlZXGxoIqxVSI1w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d13484b8-864f-43ed-586a-08db3dd7df3e X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2023 17:35:57.7631 (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: NTenl4cxetSBhhhyiDC3M2Kb1mZc6SNXJcV7S3ZtRjtX1dzghiMF9L6toLVcLyfHvRECu4hvIJgx1T8wyNUPkg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8322 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763265273379975406?= X-GMAIL-MSGID: =?utf-8?q?1763265273379975406?= The verify-enabled boolean (ETHTOOL_A_MM_VERIFY_ENABLED) was intended to be a sub-setting of tx-enabled (ETHTOOL_A_MM_TX_ENABLED). IOW, MAC Merge TX can be enabled with or without verification, but verification with TX disabled makes no sense. The pmac-enabled boolean (ETHTOOL_A_MM_PMAC_ENABLED) was intended to be a global toggle from an API perspective, whereas tx-enabled just handles the TX direction. IOW, the pMAC can be enabled with or without TX, but it doesn't make sense to enable TX if the pMAC is not enabled. Add two checks which sanitize and reject these invalid cases. Signed-off-by: Vladimir Oltean --- net/ethtool/mm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/ethtool/mm.c b/net/ethtool/mm.c index e00d7d5cea7e..0eb81231f342 100644 --- a/net/ethtool/mm.c +++ b/net/ethtool/mm.c @@ -214,6 +214,11 @@ static int ethnl_set_mm(struct ethnl_req_info *req_info, struct genl_info *info) return -ERANGE; } + if (cfg.tx_enabled && !cfg.pmac_enabled) { + NL_SET_ERR_MSG(extack, "TX enabled requires pMAC enabled"); + return -EINVAL; + } + ret = dev->ethtool_ops->set_mm(dev, &cfg, extack); return ret < 0 ? ret : 1; }