From patchwork Sun May 8 18:53:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12842532 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32D24C433F5 for ; Sun, 8 May 2022 19:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5pv8wt+QMf2E/ZA99NUUnuN41HxovfMVatcpYWgUGAw=; b=lD+ul2F8ALRSzQ HVMlnuI3jzHPZ2xx+Zg5z7fX054qNCM3gpwKYcx+tn+RPG6tmU1aoxyKSFDo2gZw6rB0vqGb/S2JM QRL4eN3nu9koamtvOB64bX2alr6DyAqF+Yemkl+ycGG1b+i1mbv57FDmaylGhVsLq4lMRgSdMd2rr zyzkDLqZY+Xky4mODwJW3qAXrYwMwd9dxa50qiWtlM/Qp+LnXfRodp09wqmwcKJ4WNjinFAQi9B1y uZZXfX83f+L1QRw+bnyeLSB/2fT472vs9SvUqdXJz14OZuIw/GIBtIjBJOskgZXSOHNzq36hv5inc rw+0oISGhdnchopZBssA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnmBf-00AzgL-0Y; Sun, 08 May 2022 19:03:23 +0000 Received: from mail-co1nam11on20731.outbound.protection.outlook.com ([2a01:111:f400:7eab::731] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnm2i-00Aw5X-Ff for linux-arm-kernel@lists.infradead.org; Sun, 08 May 2022 18:54:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CmSCxyH6SAKFowbNHvTzujO3kOpPdQ97h1LQBMubWaLJu6zSYJOXMF1ZBm0mouSbA6huUJZ9iBGKlHdBacUcqMBhtDrRKADACbt0uLj82ETz6gYGzMkNE+2W9i0sXCtiVyvNvcfkqUuG0xSfB8n2AhabL8niuK8VpmN0+ckPyXmcjEmfMtjhXp1D2+3+DnIuvCV+1h/PdXoz3dg8GNYzjG32U72ojxTZczBQQvq/RrEGtHypbi0ciCy4CZhI2HSWNJ1BxQvO2FdPgWwc7XDyxCzJLMVfST3daX5h8fOOzMNcc9DtuKdQ5vF1yN2aG9/6RIJexOcMj0uGF3psW5Y07w== 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=tCWAhC6QRoHQ/yJ+qJzgN3nd8Njt4/Dh5tMExpj7Ch0=; b=G+iHqWmc5DuYFloPeIfFJVCw/jutPj0eTdY8Rv+9q3McsbJLmWBLBgaT/rQkv1l8zSM7Fsfi3Y33SdccaYUKVSG54gK8dvzlQ+i62fib+0EwLpHXeIYHWPkCdsWX7ImazLvkXQDrqhmXDrMS1LpUzOK5ShojNx7zLclXhus18Pk/InPDbBmBf50OKxJG5XQKHSE3O2I3eLzQbxqvl7qO8ZGBQKYuzSS1FUVMYe2G7QQkfH4n2eb9gbPEkROJytzn/aR01rg2zHzIIs2jgxqLQfxuw7GJNshU0q+bKfb1s/2jHLb9RN0Cq6usczqv+Csed1A3RyGQxLe1g6YpBRjrHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tCWAhC6QRoHQ/yJ+qJzgN3nd8Njt4/Dh5tMExpj7Ch0=; b=VFsgmw+mObROryC2WCfhLBxXTz1SFJeHNQ6tqHnDgJXkHGL0QOyNpvC2hYxA8EfrPBPNG93p00L07FvboHCSG6qHBeBVVIOhh8lkAdi7oPaVxCi3y7srcWtJS/x0jk3cqHzm/DCI3vTHGSgXm1ltpRuktWB88QuKE6zayDHblV8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by SJ0PR10MB5672.namprd10.prod.outlook.com (2603:10b6:a03:3ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.18; Sun, 8 May 2022 18:54:06 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::4581:787c:1a7a:873e]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::4581:787c:1a7a:873e%3]) with mapi id 15.20.5227.020; Sun, 8 May 2022 18:54:06 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org Cc: Terry Bowman , Wolfram Sang , Andy Shevchenko , Steen Hegelund , Lars Povlsen , Linus Walleij , Russell King , Heiner Kallweit , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Florian Fainelli , Vivien Didelot , Andrew Lunn , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean , Lee Jones Subject: [RFC v8 net-next 16/16] net: dsa: ocelot: utilize phylink_generic_validate Date: Sun, 8 May 2022 11:53:13 -0700 Message-Id: <20220508185313.2222956-17-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220508185313.2222956-1-colin.foster@in-advantage.com> References: <20220508185313.2222956-1-colin.foster@in-advantage.com> X-ClientProxiedBy: SJ0PR03CA0045.namprd03.prod.outlook.com (2603:10b6:a03:33e::20) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fa5037e0-1617-4e36-3660-08da312420d4 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5672:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ma2jcAIxKTs+pGDH12EmsuFa0XWhrlEuSKsTyNCFRh1zSyBacMIQozDXGUdTv4sYJ0Ujw1rHakX1m9zmT9TzEL/sD3dx0TSYTmNRnYg0zX7l242z4/tLMTt/g/ph2zdosUfDIes8nr9ks6N09JJbSUkOKDQM46iMCLTopHeMhLjdeVt+WQ3/p4cYe1V46TD2VLf8pz2OHTsyKkgz0uzY6QmfKlwGKZplGFgRxbRJMrvaZM2XKoYC9tSNJb50983YWDkbpNy1f5CaACDgNQ8eWhfi23oMwlcYsne38XL/kH5jI43UMvr6NuP2a48LhhCDMlD9WM0oeQQmIcIcwH7gQlbZORgonMKMQDK29QwO8hiPakC2XpdGC/lbocCprqTHJkA86DGNMe8PWDyb+A6rWp7nrjJMUjCVN265Tuz/bh2Id3IfI/gxKHBDCyhpp7PCCJDfPvC0Hzt69Wc++NQ/+qD4OH1oPnNmElSzDrvCnK5HK2fvuf4bx/krm4bkR/YyfNzEwidvkgQ6ZJ7pBax+hIidhQ8Js4WlLQiKDNhIl9gyHbzvE1gxZKOyZW2djWpyzLDl/yHECuK3QvgdJmZMImHW40G051kCCUvLH10hqoRSRgFnyGDEMPxfVUG6G56Anxa/HGKQsgu6yO+2y9CdFOwdJCUueAySsaiDdxLJh/iKbTJmMazqUo3hmB11GeySS6M6BHexFjqm+QIep+C2vMv8GIwZC8mQj8ZN9lnPnMo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(396003)(39840400004)(366004)(346002)(376002)(136003)(6506007)(6666004)(6512007)(2906002)(8676002)(7416002)(52116002)(8936002)(4326008)(36756003)(5660300002)(86362001)(44832011)(66556008)(66476007)(26005)(2616005)(66946007)(6486002)(508600001)(38350700002)(1076003)(38100700002)(54906003)(186003)(316002)(83380400001)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IJnnNJ8n1EVk0hU37BRH0t8EpYvtCtkWkFe7I0RsCtCxB7NqqerZgqhIEPKVGr87zkZvWaLX13+7w5XWlTO7RJoZhFnm6kgkI9c4VJfEe5AiJuBFO1qZ3sk9NuM8bm5N+oPtTuEKwevWdAnBEIotyU17m9c1JNM+vLglLQHOHS9kJUc8yES4D63sUst7s0HozkM2zr+LwJCFy72WtNMzD4YR0JKosriPRzLmkqlhqHx30+uDRQxI9lUAbcH6eB0OLpVGq2FTANlhDdFxQS4Fl12bKflWAcnqw1oCLeJWBRf0QjdJKwqpD7Et8/HmHVNxiBcXfgCOaOFNllcN+bnoHglUAzkmR54lXcViLa2Tz160/b1no8adymRIDzJ1b8i8drYYTTu/1y+FhM2xs/rtw/2tY5xzVf2Tcx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dPpBMcaK6+Oh7y9kSxBYR5+WhhQL3YtxyRn+w3SRLd2LSf5ivb/I1/G2o6hQdBSyJOaaJ9+369xXd5HGgymYAAqWsqa8RqcR9aMp7NH29na8my1J662e2Xjs9R56+HKEQIg0rKELhyvuFbUjPHW2M3ER1ASyOkD0HIQoZS85U0AaKUgIji/z7tCMyqV+U+MpNYxaGEXsc+j8l0yDtT+34ZfrG/h2XOAOaK2H9N2oDIWcnplJoZd7yFnmd4cH00t88tWqyhhqpqJawzBcLwPhjV8yvfS141KMCEWhX7xTJd66oHZ X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa5037e0-1617-4e36-3660-08da312420d4 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2022 18:54:06.7895 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jS3wv6iAeli+5bj+77iTvoc6MpckfMVri4IsKjYRtj7GArX7LqVmlbh9gTv8mcMOUpyjkBBv3L7V5Ah1R/LQYfObEXJS3KTrlvOKRLefuQ4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5672 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220508_115408_583147_3260FA28 X-CRM114-Status: GOOD ( 13.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Utilize the phylink_generic_validate function to validate port interfaces and speeds. Signed-off-by: Colin Foster --- drivers/net/dsa/ocelot/ocelot_ext.c | 42 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/net/dsa/ocelot/ocelot_ext.c b/drivers/net/dsa/ocelot/ocelot_ext.c index ba924f6b8d12..21a85e95c217 100644 --- a/drivers/net/dsa/ocelot/ocelot_ext.c +++ b/drivers/net/dsa/ocelot/ocelot_ext.c @@ -215,31 +215,28 @@ static void ocelot_ext_phylink_validate(struct ocelot *ocelot, int port, unsigned long *supported, struct phylink_link_state *state) { - struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct felix *felix = ocelot_to_felix(ocelot); + struct dsa_switch *ds = felix->ds; + struct phylink_config *pl_config; + struct dsa_port *dp; - __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; + dp = dsa_to_port(ds, port); + pl_config = &dp->pl_config; - if (state->interface != PHY_INTERFACE_MODE_NA && - state->interface != ocelot_port->phy_mode) { - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); - return; - } + phylink_generic_validate(pl_config, supported, state); +} + +static void ocelot_ext_phylink_get_caps(struct ocelot *ocelot, int port, + struct phylink_config *pl_config) +{ + struct felix *felix = ocelot_to_felix(ocelot); + + if (felix->info->port_modes[port] & OCELOT_PORT_MODE_INTERNAL) + __set_bit(PHY_INTERFACE_MODE_INTERNAL, + pl_config->supported_interfaces); - phylink_set_port_modes(mask); - - phylink_set(mask, Pause); - phylink_set(mask, Autoneg); - phylink_set(mask, Asym_Pause); - phylink_set(mask, 10baseT_Half); - phylink_set(mask, 10baseT_Full); - phylink_set(mask, 100baseT_Half); - phylink_set(mask, 100baseT_Full); - phylink_set(mask, 1000baseT_Half); - phylink_set(mask, 1000baseT_Full); - - bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); - bitmap_and(state->advertising, state->advertising, mask, - __ETHTOOL_LINK_MODE_MASK_NBITS); + pl_config->mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | MAC_10 | + MAC_100 | MAC_1000FD; } static struct regmap *ocelot_ext_regmap_init(struct ocelot *ocelot, @@ -262,6 +259,7 @@ static const struct felix_info vsc7512_info = { .phylink_validate = ocelot_ext_phylink_validate, .port_modes = vsc7512_port_modes, .init_regmap = ocelot_ext_regmap_init, + .phylink_get_caps = ocelot_ext_phylink_get_caps, }; static int ocelot_ext_probe(struct platform_device *pdev)