From patchwork Tue Oct 12 19:46:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12553621 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 901ECC433EF for ; Tue, 12 Oct 2021 19:48:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FEA660C40 for ; Tue, 12 Oct 2021 19:48:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233803AbhJLTuK (ORCPT ); Tue, 12 Oct 2021 15:50:10 -0400 Received: from mail-vi1eur05on2087.outbound.protection.outlook.com ([40.107.21.87]:55521 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232145AbhJLTuJ (ORCPT ); Tue, 12 Oct 2021 15:50:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eYoDbN7ON5+YIE9Tktc/WeFq1Y51WS25P0UgIoHRbnpXR1E1/IuRg2Yw70UGPEYjTfog9mPw8dfG/7R2Mus4tQLyKHSVwzAugjrbn+JkZAVGYoi6EnxkJ0Hy/n4/rNa8+Cqqqhdyema6hf4aDaNuY5iVvye6t1AVuARYCPFVwwZe4SnWqXRamVXEOoEL7cHCdTOXnK4M4vf1OvYYO4EnrLzKKOKqcSdNiG29WvZkWeKnoYwJsVRXauQl/yrhZdFybn43QQqhQ/+/mog45e1Ejsn/I1kSVWWGULpethqEsBEauR5/PdzXWijF73NASRzksyNo9Lcb5jj2gghfUqHzGA== 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=38tFKZKxE/lndsWX5QV1DW4NOSCtd9vlmeTTyLRutbU=; b=L9yohJNNAbq72jMGmTF8EyxJEO3hZ1+HENZHiDiVF2R2rCPjzHN3ypcfqVR3quPLNUXVx9/0xiGsczeY7QLGUa4IiyVZg9Y0h2f0BSJ79kGDaMe/jItFGE2SVL9E+1cATlkyo+TxJVSCbmX1iY+YagNnz9dQQkPf04PM0VbD6eUIl+87dmwHE+ZuOBVe9Q6hemffONCEAflLABOINDcsBbKeAp+UFAFMvzbF2pZW09Gb0Wne3kFZewhENrjyveLWOSZYzLLtmlZLK9P0UFI76pZ3hMzGDpk8crTAibIjChCw9/MDMR9ygoIlBvHlBsLkx5EF/6ZhlDFoaFx2JMsPIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=38tFKZKxE/lndsWX5QV1DW4NOSCtd9vlmeTTyLRutbU=; b=AIRzq7xUfs7xUUMBXvaR1F6qi+56GmgxsClt6yp3MvyEaLC3cx1arg2w0of3BK07cTPP+xqoZ4vIFyAjFOhfUD2E5zlxnrFWR1uu9shurOMcAqhxl61ixFrVOZ7O1u1mgqn1gK6cvv0BKxjvyhUH4ENj6Lr2sxIn+6bnoSVuAZ8= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7513.eurprd03.prod.outlook.com (2603:10a6:10:22a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 12 Oct 2021 19:48:05 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 19:48:05 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski Cc: Claudiu Beznea , Nicolas Ferre , Antoine Tenart , Russell King , Sean Anderson Subject: [PATCH v3 1/2] net: macb: Allow SGMII only if we are a GEM in mac_validate Date: Tue, 12 Oct 2021 15:46:43 -0400 Message-Id: <20211012194644.3182475-1-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: MN2PR19CA0021.namprd19.prod.outlook.com (2603:10b6:208:178::34) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR19CA0021.namprd19.prod.outlook.com (2603:10b6:208:178::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24 via Frontend Transport; Tue, 12 Oct 2021 19:48:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b992d5fb-6baa-4c05-fb6f-08d98db93573 X-MS-TrafficTypeDiagnostic: DB9PR03MB7513: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H8IWpxPFRdv4pLsoeLvmEPwDKiq8PiLQXgccyVTV5FQefKba/0lUrzmMZYu7fcETCJlR+/sSU8aPAAuKj+4I9aVtyu5oyRQAaLgkXiJVt7OjejP4vr/uGPYJ7G89yhX+ldavqlWUfYjjrV6IFSFiF0MrJVZJUzbbfI+u99orqkofHN0VI6PDrKegGvCTHPMaI7ME46UdEUzIATf52a97E6oQuiQzd86j8I5L6DPxPcyN/lYhHsP4nI7JL4XLJgKl7LIWlu77h6WkJ+Y3oV4LuJ9ZFhQsNSx/lY9zuiVWl0cUkRQzJLwQpCn+tH0EUkQsqetULSJ+8esqdhuJIeLCfR4QAtHsOF+uq2Vw8FIuxHC9BrQ9TUDMjObThBHqHvSJ5nWcKuGpYXvgE07vJ1ZbllXDog6hg+/wZWIXhiXJHv0mq4vKGh2dR8n9CBli85BIfMSexymwXiE7coBcfPUfH8tTp805jlCxsEl1dLzuWePZz4RHjblG79fAtoonZwhWm5xNgUnl8FD3NtxK8YGrVhLrilSmLLywj3GoqNX7FqjHLGlUOCxXFxM28U5o9UxMs8RNuPDqJaT2bXZSJ3Q+jqlEWd/EE6XeupUKv6FSuGrJT8A5Q9JiT1ANy40IGXhdZ0Y+uAPO2e7tlUg2vzHnxEFpXH2XBjEaKLJpDY5CScsgQKk6y7fzmP8Kz2NpTJv67MO9sWyJWfQaiBZffvxkKQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(4744005)(44832011)(2906002)(2616005)(5660300002)(107886003)(83380400001)(38100700002)(38350700002)(86362001)(956004)(508600001)(4326008)(6486002)(66946007)(6506007)(6512007)(110136005)(36756003)(26005)(8936002)(8676002)(186003)(52116002)(316002)(6666004)(1076003)(66556008)(66476007)(54906003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LrMz+ETweoDKe3nlQhrU12ItqbnhBr8ymIGMoVZC90n7t8iX609PCKW648dOEdoLIvHwlSfRRkgH0kA0rOlWs/d7Vf1mK19ofvBUaRwCXAMOPEU4mlrfm1vB3piqsOGLxWEqqI75scBa3sw5Se+8Jr9fS1FvbwcDUtlhsHCpCs/+2QmLPq8zK682HpXVOMGQLqQXpawjMQbNtcCC/2CS6p8XNf/YkohXuQKXW8q+dZdPI9Rt/UEVB3QsHvEETngQo0OdyQUpS5jASxBv7pXbo9BmWZVeLj1kxXClO/q4uUo/QfDqzX90P2V0t7ECeUJV1kCaSFQ20iDTcgSrl0i2Ix1OCUoEerl6+XjnqBfsFLJE304Cs8jmVagN5r54UiaSUGRGHaao4LiBk0/QJHWO+6ICpSD1ZPjhfh2MIJ3DoG728B8BPmdEIXXnNHTwInTSmhwh7vU2AoOAzMoHBvmxfXmHP8SGi/B+KAKa1HcgVT4uRZ6FPK6ileQ1eAPDf3+OF5XT+aQ9lp8nBG2mh0zCy/t3rs5nTBbTzhwfuz9aJt7qjnGeieHhTvrqhZAgHc9+7H4uWav5ypH8ox4oE54TbOUjHR+D1thjPz0OBDbF/YdTpXs+VipPsu9QcYLwx8wnlQgwBRvjeQ9LlQI5xezhim3UXfJqMR/3lGqO1fu86qTnAhZPYisGspKyijVw3wjzpFhx6tq4ca9yxt/yOjGSwXhfOKuRwG8JsX3iz4QtOrojo2cgwW3reo5IkAfn8npnwdXrK3GWkN/tqaMpCljadWdg0p/dj9c2vIZln0RhNV93jAeRnUP0H0g0GMwJMHv7D28yN4UE8Is79j7/Xc4yRv+lScCNNyPYdhxgXh7z92qJtt4E0QtMbYM1z0EQaWAci5azsxFvHxD+TeZqoVsWPZ1JmrKqZCWlfDeu67xi1O+VnxVfc46SUSCvfo7GC3KRP7B1DbFvvoAgXTDAJ/xFw5/GKDnDVYG6jBZKDi9a1eUOscWdLY/cNd/uQxPDodSytczsMMOYXQmOf26YAL/bZfQXcawJpyILqK6uEd/UMFY8xd5RAqtgZTe07SnR1qIsGBNBCCUi8uXr56dvk5yRmCLuEEc9M43ktzp5cT591FFdWbvMiqZ6RoGMWM5hqhUf1LUDVF+1Al1lU5Ppty93UXJ5gH+Vmltj+mRnQNRzk2FrF3QxLxGeWsS/tDiLuWTtZcE7/tSlelmRRU4/5HkX6RBK7TzpQSFLmmR5UPwlMJbU+cFt6QEJ40ofqxSohqNQ2FFwY1CAdderWWpcYckkH7DHx5jiBOnbJn9aW+7wHY9pdAE/VL2YjpwlB9dtIYaR X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: b992d5fb-6baa-4c05-fb6f-08d98db93573 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 19:48:05.6944 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sftPyiV7xuh3l8OoWTE46Jr5UZrcjmdexHQFzD9IlMM/AKTtY69o1ylabgDnSbOoj9Nd4hH3Q/EgTPugulT8UA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7513 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This aligns mac_validate with mac_config. In mac_config, SGMII is only enabled if macb_is_gem. Validate should care if the mac is a gem as well. Fixes: 7897b071ac3b ("net: macb: convert to phylink") Signed-off-by: Sean Anderson --- Changes in v3: - Order bugfix patch first Changes in v2: - New drivers/net/ethernet/cadence/macb_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 683f14665c2c..cb0f86544955 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -528,6 +528,7 @@ static void macb_validate(struct phylink_config *config, if (!macb_is_gem(bp) && (state->interface == PHY_INTERFACE_MODE_GMII || + state->interface == PHY_INTERFACE_MODE_SGMII || phy_interface_mode_is_rgmii(state->interface))) { bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); return; From patchwork Tue Oct 12 19:46:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12553623 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BCA2C433F5 for ; Tue, 12 Oct 2021 19:48:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81548610A2 for ; Tue, 12 Oct 2021 19:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233892AbhJLTuL (ORCPT ); Tue, 12 Oct 2021 15:50:11 -0400 Received: from mail-vi1eur05on2087.outbound.protection.outlook.com ([40.107.21.87]:55521 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233465AbhJLTuL (ORCPT ); Tue, 12 Oct 2021 15:50:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QXBtizYU4ftBg4u1U8xOfGtO80IxcLs2gkI54QDaNnouIqPVnOWwEclwlLJloqUs5GrTzgmQ07g5NljnuV7cGgSLfPeCoR+y+2YGwdAJnmp31ZkjnY0+fUI7FMPRjE85598KnC51LJOBn+kpH8M7/cbdHdM5KcTvcbb6AHebSxkPDzspyDMips05ZvINNOhQUkuUZKuM0HTdvaVrzkoG10u+dRt1uUd6tGvFWKRq3V4Vc0K4ZByhWsgY8qkIwNLcmj9pYUHXxo6LgURzlyRb7XHbe/IgMsF3de1zjl10F703EQfuDJiy0B5jgPzNMt7LM2a5epG/UjOMLSqaM65oxQ== 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=gr8FqXiIsekp6EXmr+dTkQ+bkO+Wp5uofsKCYzoTvAY=; b=Cs8IkSuenFOhuuwBXV2MQJt4fONViFAeVEDwR/jdPN6VQd4KCAF4vcYvhJiKY7OciPWdLH9J0hPphV/lfeE6Fn28W/UzNj6c7VCf8jYkM/bIngz84gPQcHwJQ+FgJn1SkkGDZpGrq0VKGs/G1yyHrY9h+n5tv/9OGfi+g+tNMrq/+eIbFPn50P1a8oMTFh4ujEntFnd8rd9epqGR5VDXAIwpb+F3FXu3N7ZTT35MCxq8TuZfTcd0b8oyyp67gedwUwmHXpNaDZGcsaoNNURUomzIAYM0ajj1JCyWF2RMssyrD+967MwfK5f4gRUXro28tdBO3EKGocHtV3fx7iDTCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gr8FqXiIsekp6EXmr+dTkQ+bkO+Wp5uofsKCYzoTvAY=; b=fpjlY2oNbDjRYmssPYNJGKA7J2Tow/h1hmSbU25V78YSahsXe9Yruqol+Iq7qpEHW+C6vTo3Qg4Apd5hfRTJJJyCL0wJBUKtdhFs3tVfV+Ync7DfXFJg1t6Haua126d+u42DXLbBB3Vw5Tt8M40yNgfssIxp9nLEJvhoEa1281k= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB9PR03MB7513.eurprd03.prod.outlook.com (2603:10a6:10:22a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 12 Oct 2021 19:48:07 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 19:48:07 +0000 From: Sean Anderson To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski Cc: Claudiu Beznea , Nicolas Ferre , Antoine Tenart , Russell King , Sean Anderson Subject: [PATCH v3 2/2] net: macb: Clean up macb_validate Date: Tue, 12 Oct 2021 15:46:44 -0400 Message-Id: <20211012194644.3182475-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012194644.3182475-1-sean.anderson@seco.com> References: <20211012194644.3182475-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR19CA0021.namprd19.prod.outlook.com (2603:10b6:208:178::34) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR19CA0021.namprd19.prod.outlook.com (2603:10b6:208:178::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24 via Frontend Transport; Tue, 12 Oct 2021 19:48:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2eb63efa-4a4c-45fd-ba21-08d98db93673 X-MS-TrafficTypeDiagnostic: DB9PR03MB7513: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tnWAHgttnRrF8nKeobjOKzyBy/CTbGkmOvRht94vrzFkmFIMosZQzz98HibxzWxrPaVg6o/w9W3y5zWOwn3S3mg88VFZ8l1TLr9M/rlgG0RtUYUdP+NASuEmORBgWDu5r5YOTJfZ/5zdrAc/WXa0DgbopPSePWTBq4DeXgOSuF9vHGdZ3cwO5fo1e0w2T0l2pBA257nWbAxiEYq3iu5N+v2I5JqgYtzv7wv6K/dL8ioHuBQAa+QF+k0vnbfsE9bfGBLjuokTvWMlZtZ3orwNf8xRhJZX/aE43RKEwHzbXL9cYsUkjZNXjt6jjGMBA+KEPqgrv3yvkKtCEVl24ranXnWUPfVebhKxFoyARNriHkx0pbC5DyEO3w0AJb+QHM9KCBVYN3pXEj/7I7IRWDNKlQ/NSKvq5hzIeK1dCE25xdFWuwwZ/7smBoldlDbWBFPYnU6bDUmO9QHXmPFbQgpUvQVBMryXaumJQ+7ziyJ0RwDzk/wf8tiiJyNd2rmio4tlqaoa/nweJKiKtFSBTV7slypQOw6BBk2OuwXrLNFn5zw5b+0gAbtcN0UTX2XxD6X75Sfr7gPT0LLyHTTtwMU4Ek8Z2lZFwTSdx/ac6YDJcmgTO6nPKtz5AFOaKKzfgRfbWIBPsTYg4Z1y3KSP/wzbY00CjpVVZDzf8zqJbbUsYyochP0nXNoCLRPP4CHG5iqdTwWia9/wXta0hJqv0bRpL9PnQgiDJK1/rXLrE5Vf8qjUnjKZS74pPweU/dHHkjQ7BmUT2FpW/oAgM7TN15cToJFNROWyr0FzSRRDxFqvulU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(44832011)(2906002)(2616005)(5660300002)(107886003)(83380400001)(38100700002)(38350700002)(86362001)(956004)(508600001)(4326008)(6486002)(966005)(66946007)(6506007)(6512007)(110136005)(36756003)(26005)(8936002)(8676002)(186003)(52116002)(316002)(6666004)(1076003)(66556008)(66476007)(54906003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KIULWOgwMgFYESl2+uMqUZ/P8UdT+g53WQCydhDxGVKEmt7LbSFOJK3tOi5IOxEJNKylYPzyR7NRGBKj6YWPbjvDXJ/mWPDgA5LGxS3Jwj5p832f9asx306X5JXGzNoMfeMA4Vn/OlJfWMStf00XVtNeK/uQthJ0UtAS/IFo0VblVpu6WyYTBjzc8g5Ux+fDWw5/x6SYxqzx3aimIfPEyBln4Z5TmnGmf/VlimrHJYrgBlnGmcpJy/PzQrsaXMqXWqU4eGyAcj0e0q41Y8GpWEOiwXEVH+3vukhkaKWj0WXEJ3HylsD6lgEwnvBsgzPA7vreZW+SnqoEpDN9YUUgaD9fASUQPh/iw9UqLqET+yRdjLWafuqDpkiFaKTxBYFvoIOGwiY0Tg+Vm3aQgGgGRAuPbWYbcCampqcXDE8ji1dDHd1m60QbUcbtmYkeKXBEgOX8zaD5TgSFyths1ebzXc/wJkZRExzdXgQ9tLS8mLoR4r5SH1nqTxdLrjKb8qnPorJZbAi6HsBy0MAZ45dbE6zmwLPWmvO8ZbFJf0DADVsc/l2sVT2RG6965puQuGSiPpdy1HUlFoCFbldmLY8Ov3fB0jnkJ+sA/izHUWfwJLpc7ZOUm3V6PGOa/fGi3A7No5Alki/gGMKPg1et18jgUwquA/uSqVyLEiO8QIrKFzlwTQqJmqRHmMn7O7bLf+1oSlyDaAXZU8xUJqfOYEzb482VuvqZymI6XU+xQAfhubSDY7jzE19mygYGorf9M2OblDHYonAVft/A2K4qpckVvFFl4QlILITMrITXDi8tgD7QnRdWN4kzIrVLwwmV8qeWg4n/psMbwS41cR4YLonDLkAaOwfZ/bKuwYyUJG6tsFi2UIvRdHiCttIlT3JYtcecZpZri+yaSQ1yjg3mFxmBLReED4NGIIHfgWFxCPny8vE94Q622wnSA+HXMcoMoclLCUUpoNmF99fdToairpP+LL0ucjAiB9WAdxJsmD8tyg8FKSbJJvuSlxAEl2C2+IEieRVeAO5x/yyie1C/IDnVoKVRvMbwTpzTMgFALmkDhXserZlzN3CLJvYY9RtQdhWZUrMjqWzPfuuWbTPsCIpEhDXXrEEljGIIXxKc0JFg+rDCYXalGAXl45GilwS1+jtcrZpMQVCZVgCdRDyXMlR/W6bgeS2qaYzzZe+yUo6XXthkZgf6K15qMWPyYLYIdIKltP8GkqjBlEDmRu/ktuukDZemPjYqZkoRkYn19LCp5SZkvsRUZDKZOEdTfJwYg0ujULIBvRkH64LLk3JwT1vTs1Za306Wl7EwlKrh82J7BUmEtfCWu5NXqt1Ic+fjFmLI X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2eb63efa-4a4c-45fd-ba21-08d98db93673 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 19:48:07.2675 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pHCOzYpZOxL5MJK0SHUx/EQw5lvw7rdltB2fEn5WQrC563wl6DD9MqrL1RERpb4Sps47A5AjqsrdRBs8/JlLhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR03MB7513 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org As the number of interfaces grows, the number of if statements grows ever more unweildy. Clean everything up a bit by using a switch statement. This reduces the number of if statements, and the number of times the same condition is checked. No functional change intended. Signed-off-by: Sean Anderson --- This patch was originally submitted as [1]. There is another approach which could be used here. We could do something like macb_set_mode(bp, mask, iface) { switch (iface) { case 10GBASER: if (...) phylink_set_10g_modes(mask); else return -EINVAL; break; case GMII: /* etc etc */ } return 0; } macb_validate(...) { if (state->interface == PHY_INTERFACE_MODE_NA) { macb_set_mode(bp, mask, PHY_INTERFACE_MODE_10GBASER); macb_set_mode(bp, mask, PHY_INTERFACE_MODE_GMII); macb_set_mode(bp, mask, PHY_INTERFACE_MODE_MII); } else if (macb_set_mode(bp, mask, state->interface)) { bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); return; } /* etc etc */ } which has the advantage of much cleaner logic in the switch statement. [1] https://lore.kernel.org/netdev/20211004191527.1610759-9-sean.anderson@seco.com/ Changes in v3: - Remove labels/gotos in favor of explicit zeroing. Hopefully this better illustrates the "linear" flow of the logic. - Add comment with overview of the flow of the logic. Changes in v2: - Fix polarity of `one` being inverted - Only set gigabit modes for NA if macb_is_gem() drivers/net/ethernet/cadence/macb_main.c | 105 ++++++++++++----------- 1 file changed, 55 insertions(+), 50 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index cb0f86544955..9b2173c37edb 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -510,33 +510,65 @@ static void macb_validate(struct phylink_config *config, unsigned long *supported, struct phylink_link_state *state) { + bool one = state->interface != PHY_INTERFACE_MODE_NA; struct net_device *ndev = to_net_dev(config->dev); __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; struct macb *bp = netdev_priv(ndev); - /* We only support MII, RMII, GMII, RGMII & SGMII. */ - if (state->interface != PHY_INTERFACE_MODE_NA && - state->interface != PHY_INTERFACE_MODE_MII && - state->interface != PHY_INTERFACE_MODE_RMII && - state->interface != PHY_INTERFACE_MODE_GMII && - state->interface != PHY_INTERFACE_MODE_SGMII && - state->interface != PHY_INTERFACE_MODE_10GBASER && - !phy_interface_mode_is_rgmii(state->interface)) { - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); - return; - } - - if (!macb_is_gem(bp) && - (state->interface == PHY_INTERFACE_MODE_GMII || - state->interface == PHY_INTERFACE_MODE_SGMII || - phy_interface_mode_is_rgmii(state->interface))) { - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); - return; - } - - if (state->interface == PHY_INTERFACE_MODE_10GBASER && - !(bp->caps & MACB_CAPS_HIGH_SPEED && - bp->caps & MACB_CAPS_PCS)) { + /* There are three major types of interfaces we support: + * - (R)MII supporting 10/100 Mbit/s + * - GMII, RGMII, and SGMII supporting 10/100/1000 Mbit/s + * - 10GBASER supporting 10 Gbit/s only + * Because GMII and MII both support 10/100, GMII falls through to MII. + * + * If we can't support an interface mode, we just clear the supported + * mask and return. The major complication is that if we get + * PHY_INTERFACE_MODE_NA, we must return all modes we support. Because + * of this, NA starts at the top of the switch and falls all the way to + * the bottom, and doesn't return early if we don't support a + * particular mode. + */ + switch (state->interface) { + case PHY_INTERFACE_MODE_NA: + case PHY_INTERFACE_MODE_10GBASER: + if (bp->caps & MACB_CAPS_HIGH_SPEED && + bp->caps & MACB_CAPS_PCS && + bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE) { + phylink_set_10g_modes(mask); + phylink_set(mask, 10000baseKR_Full); + } else if (one) { + bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); + return; + } + if (one) + break; + fallthrough; + case PHY_INTERFACE_MODE_GMII: + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_TXID: + case PHY_INTERFACE_MODE_SGMII: + if (macb_is_gem(bp)) { + if (bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE) { + phylink_set(mask, 1000baseT_Full); + phylink_set(mask, 1000baseX_Full); + if (!(bp->caps & MACB_CAPS_NO_GIGABIT_HALF)) + phylink_set(mask, 1000baseT_Half); + } + } else if (one) { + bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); + return; + } + fallthrough; + case PHY_INTERFACE_MODE_MII: + case PHY_INTERFACE_MODE_RMII: + phylink_set(mask, 10baseT_Half); + phylink_set(mask, 10baseT_Full); + phylink_set(mask, 100baseT_Half); + phylink_set(mask, 100baseT_Full); + break; + default: bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); return; } @@ -544,33 +576,6 @@ static void macb_validate(struct phylink_config *config, phylink_set_port_modes(mask); phylink_set(mask, Autoneg); phylink_set(mask, Asym_Pause); - - if (bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE && - (state->interface == PHY_INTERFACE_MODE_NA || - state->interface == PHY_INTERFACE_MODE_10GBASER)) { - phylink_set_10g_modes(mask); - phylink_set(mask, 10000baseKR_Full); - if (state->interface != PHY_INTERFACE_MODE_NA) - goto out; - } - - phylink_set(mask, 10baseT_Half); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Half); - phylink_set(mask, 100baseT_Full); - - if (bp->caps & MACB_CAPS_GIGABIT_MODE_AVAILABLE && - (state->interface == PHY_INTERFACE_MODE_NA || - state->interface == PHY_INTERFACE_MODE_GMII || - state->interface == PHY_INTERFACE_MODE_SGMII || - phy_interface_mode_is_rgmii(state->interface))) { - phylink_set(mask, 1000baseT_Full); - phylink_set(mask, 1000baseX_Full); - - if (!(bp->caps & MACB_CAPS_NO_GIGABIT_HALF)) - phylink_set(mask, 1000baseT_Half); - } -out: bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); bitmap_and(state->advertising, state->advertising, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);