From patchwork Mon Apr 3 21:20:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Roulin X-Patchwork-Id: 13198799 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 71A0EC76188 for ; Mon, 3 Apr 2023 21:21:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231788AbjDCVVP (ORCPT ); Mon, 3 Apr 2023 17:21:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232711AbjDCVVL (ORCPT ); Mon, 3 Apr 2023 17:21:11 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2079.outbound.protection.outlook.com [40.107.94.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3769049CA for ; Mon, 3 Apr 2023 14:20:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JG5FSgSPeTzTpVlG6GV1Vz+9Ou9rj/fBNAyXOsgxyutG17u8FKS8bSAQJnjAhWAg/iD4XcY5g/jCO3LQUBDvjsqKm3QiDDhs2FjS40fpsHMhjgW//0q7hWYKTL6LRi2HfQaIBNUBit+QYp9+iIjFW0sGls8oIUZ5FKK+H5YMk1ddKhnd1ct1KvfHmDGFjT1yLBdzlHaMHmO9YaKxl9NS8hZbb7R3/TFHZe/xAUdNH8MAzX7PKJY2Db1eE4YoEYuCNiT/3yLp5YtUf+nJSn2LBeVOMoipQUrETWRHcxyJSIlDpqBErtBrhtEtkpNv05R350UoT75VjPhEw+iESDPemQ== 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=bZxu2RY0E/EJ931hUzLmGMVydr9zoWLk2VgTaGhtAT8=; b=gtdgbKNufgkberfKsxuatGz9BFY2nKD8EC396krzR1gzs0fIK1hKfe0bNPmu/brinsprdwg0PO35ehGOitdZDeag3DJGx3Y8efOB9KLkF950T32atuqVy+28UzoxeyOdsq00ganGJOQ4d5OrJ/+QqLKDLY50oFs/QrFY6EN+D3e5snVvwhBqVs1NLgrxgeEmC6OFqc9g4LStQnQiStNi3lT2QvtQOZGu7yUJpQaRjuCAbxvJnNMUZIbIQWywiSjx5h3KvtUPQJxu2MDT/W8ifV/B5DO5g9ktqPCwsDwShuQjso3fetzwUtXJ9dBzO+FXTe/L4k1RbEp4H9UL/xHRwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bZxu2RY0E/EJ931hUzLmGMVydr9zoWLk2VgTaGhtAT8=; b=XtdlMxtgIPcfuvWVPLx8jby3PYmAXxNRQqGXsUow983y0dWnVY1r1+xVtXkZnYmWnt+C2Ah5bCfP3yaMfEzc/Hck6V3gooS7aKOTt2rWfu4PdZiumE3q7cdmm1TdcyVebUTEAksdSLEDK8M9BnGujbLpi2eCS/O8bLUeXSDofF7Gn8+pGxzqfdf543c92KbO1zYFpSBIMe5/5Q4wFVlSTiD5dM7FIWPSZd9awAJGcXtQns/6pwIaR+tKUBzJgxn6TsD3K+ALiLHHvhqPUxBn1pr6tdvVUmPi90daM4sVUL4fRXwGXoFBU73GyuNPzjolWOYO7Dw66gdecl+iOzuRww== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3127.namprd12.prod.outlook.com (2603:10b6:a03:d8::33) by BL3PR12MB6473.namprd12.prod.outlook.com (2603:10b6:208:3b9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.36; Mon, 3 Apr 2023 21:20:55 +0000 Received: from BYAPR12MB3127.namprd12.prod.outlook.com ([fe80::ebc5:c372:d99a:fdb5]) by BYAPR12MB3127.namprd12.prod.outlook.com ([fe80::ebc5:c372:d99a:fdb5%5]) with mapi id 15.20.6254.033; Mon, 3 Apr 2023 21:20:55 +0000 Message-ID: Date: Mon, 3 Apr 2023 14:20:53 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Content-Language: en-US To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, jiri@nvidia.com, andrew@lunn.ch, f.fainelli@gmail.com, mkubecek@suse.cz, mlxsw@nvidia.com, idosch@nvidia.com, Danielle Ratson From: Andy Roulin Subject: [PATCH net v2] ethtool: reset #lanes when lanes is omitted X-ClientProxiedBy: SJ0PR03CA0077.namprd03.prod.outlook.com (2603:10b6:a03:331::22) To BYAPR12MB3127.namprd12.prod.outlook.com (2603:10b6:a03:d8::33) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB3127:EE_|BL3PR12MB6473:EE_ X-MS-Office365-Filtering-Correlation-Id: b22e48da-a58f-43e8-c1fc-08db34894f99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ezU4zBpoKId43Y4PBdtqYsUyGo+4/WiJJqoH+bmgh+QzAiAZ1pMS++ADZLcbBxv4OyPikaiz8hLbpLUfAWPWtEoOCpwalh/EVrpel9Quh5/5o0L6eZUyMAHwwNYl0DGty6N6U2ofW5hCtuKkrJmkjXE9X2cpbPgOTzY/e0E1ZHKwgaQs0FUhvRyB3FanI2Gl1RF9wCPJoy5vxTFnDJlwJNeS04m5XUPucqJyNu2iYGbPL30XrIVC+BTmphTxYJKlt3E2VfZVBKDtBRkroPm8xAVvk1XgyrrXyoQ3WSovmt1wzQW+EwDinbnFSvZAFaTxAz2bixvGhfVqwKwBcLa+PgsrNSX9TyfiFTnQ6URY/PObAEmDSGbKuWdLLfE+NuGyCSCQYi6IKRjpIL7nSzNzZ0DitniuV0AGzktCow/tcamd8i1aVd5DD9CE9h1t0+byH8edFlFuNvwencHPr3QS9TSswxm15uodods0y0hEdJeEpackbcR6Ln3VKehvHW87ZMlvU+hyb/QHmJnAaXu0m7iRf5YkX0+ni1E9I8Qr5pBBlpnft1jTk03Jcy7htJGVRZHEXe4bLb4jXu9/Vkdk7rIysuD4qTa3YWFYellJv8q2RoWlxy+QXFEVpkYHXD20wRS1Qta3YhRPB7VBnvgjvg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3127.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(376002)(39860400002)(136003)(346002)(396003)(451199021)(31686004)(6486002)(8676002)(6916009)(4326008)(66556008)(66946007)(66476007)(41300700001)(316002)(31696002)(36756003)(86362001)(2616005)(6512007)(6506007)(107886003)(83380400001)(8936002)(2906002)(5660300002)(478600001)(38100700002)(186003)(26005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?yKIpoeAblGEct8YqH9ES2fyZ3pp/?= =?utf-8?q?x2wVxgncCRws+gbUkdFT8B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oRo/RLsaKN3lG3H+B5BHnEDdabzYDPibDM7K8V1ZQXHpzMtEAsFzQ?= =?utf-8?q?lU3LwDb8/mgBcyplYe7ojQx5n0sgO3AfGED5A8HWeXTl64+RcU3O7CsmqvQOxD1bx?= =?utf-8?q?NaBd3ejeEAmQcmyGaoOmfv7c40qCUcCRb+dC2eJwBr9BUsEwuutWZ8cJX//YJsbLb?= =?utf-8?q?o/l6wfmpYni7TNmt969bCq4kc5c7r3UI+B0P2I9WadV9nwAttUXKPNYaQ/RmEOWz0?= =?utf-8?q?Mhug4OBHVxsJ3i/ArGgIDJFis7EYk6oL4FUeH8zxX2fx/3Fgp9YZyTQBs9QDscqli?= =?utf-8?q?LWfEhtLy3bqdWrBDkof2r4KVhgldKLpT7rdgDMme1MV5fz6rcvk119gpLp7QGxxAY?= =?utf-8?q?k3rw13ZHpN+hwBWxVH14vnJY055/uyDy7hQFmAbRos9npLZHuhKYZvb+yfuuWGPwb?= =?utf-8?q?Ih2rMxXRmWgCMEhDtG9SFidq/r4ecxSVv49Kb5G4ZdOgGZ5EUdN0m/hZu/xyHUGX2?= =?utf-8?q?RSYF64+iAKMIlXmdq3qrquD0pz8jYoMY2+f1aUfRS84v4gqkZ/jvL/HK6MNBuWDwX?= =?utf-8?q?ukjlvLAHKlSnX/5d2MVFQH8X6w6f7MZ+ssik34IcYw7RZAC/7Ucqbiz5zUfnb74+y?= =?utf-8?q?g9bxIm7d+ZSG?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b22e48da-a58f-43e8-c1fc-08db34894f99 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3127.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 21:20:55.5336 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mTOpvDT5VhYR8yXmY64ewmbfKkHJyILOWn+guXKXIv++OwmLCIg78LhnB2/JxQ6at+er5VeGOPLwk0pvSLtIXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6473 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If the number of lanes was forced and then subsequently the user omits this parameter, the ksettings->lanes is reset. The driver should then reset the number of lanes to the device's default for the specified speed. However, although the ksettings->lanes is set to 0, the mod variable is not set to true to indicate the driver and userspace should be notified of the changes. The consequence is that the same ethtool operation will produce different results based on the initial state. If the initial state is: $ ethtool swp1 | grep -A 3 'Speed: ' Speed: 500000Mb/s Lanes: 2 Duplex: Full Auto-negotiation: on then executing 'ethtool -s swp1 speed 50000 autoneg off' will yield: $ ethtool swp1 | grep -A 3 'Speed: ' Speed: 500000Mb/s Lanes: 2 Duplex: Full Auto-negotiation: off While if the initial state is: $ ethtool swp1 | grep -A 3 'Speed: ' Speed: 500000Mb/s Lanes: 1 Duplex: Full Auto-negotiation: off executing the same 'ethtool -s swp1 speed 50000 autoneg off' results in: $ ethtool swp1 | grep -A 3 'Speed: ' Speed: 500000Mb/s Lanes: 1 Duplex: Full Auto-negotiation: off This patch fixes this behavior. Omitting lanes will always results in the driver choosing the default lane width for the chosen speed. In this scenario, regardless of the initial state, the end state will be, e.g., $ ethtool swp1 | grep -A 3 'Speed: ' Speed: 500000Mb/s Lanes: 2 Duplex: Full Auto-negotiation: off Fixes: 012ce4dd3102 ("ethtool: Extend link modes settings uAPI with lanes") Signed-off-by: Andy Roulin Reviewed-by: Danielle Ratson Reviewed-by: Ido Schimmel --- Notes: v2: add before/after examples in the commit message net/ethtool/linkmodes.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/ethtool/linkmodes.c b/net/ethtool/linkmodes.c index fab66c169b9f..20165e07ef90 100644 --- a/net/ethtool/linkmodes.c +++ b/net/ethtool/linkmodes.c @@ -270,11 +270,12 @@ static int ethnl_update_linkmodes(struct genl_info *info, struct nlattr **tb, "lanes configuration not supported by device"); return -EOPNOTSUPP; } - } else if (!lsettings->autoneg) { - /* If autoneg is off and lanes parameter is not passed from user, - * set the lanes parameter to 0. + } else if (!lsettings->autoneg && ksettings->lanes) { + /* If autoneg is off and lanes parameter is not passed from user but + * it was defined previously then set the lanes parameter to 0. */ ksettings->lanes = 0; + *mod = true; } ret = ethnl_update_bitset(ksettings->link_modes.advertising,