From patchwork Tue Nov 16 06:23:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12692686 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 C5103C433FE for ; Tue, 16 Nov 2021 06:26:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9191663240 for ; Tue, 16 Nov 2021 06:26:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9191663240 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=in-advantage.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=La1mBpXHb4EHbJql2KxROp85YkveN5CLAI8HwVhqLqA=; b=Ar3uQc6/S0MHC4 QDynUoIpGh/oFQpFADpVcSLXj+hhYsY907rmB3lvPB1KeZz6R7V3RWn7W3Fpdkkt+W39v0cWOZyyk ckqy41aRHOS/P3/TdebzhngP6nMckCnVvpCUSC5YpA1uDneQpgXPHg4H6HD2ntnwaKEtFNc/EVM/y 3TUY959tejVZZojHCo6wVns4HR2QwJBzXsKIf9iv73saVD6JLBrXWi3qAZtULpBoqi42ZYvLxCWHh iiPmoff85mqwlNDo6kEicYxToP9bLeRmu6fZwaDFmvMOtFQuewk611B5rQUE5V2p9F48KjyNmfERt wN/fViFxci7AfP4MT4PA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmrtY-000O7q-OY; Tue, 16 Nov 2021 06:24:41 +0000 Received: from mail-bn8nam12on2108.outbound.protection.outlook.com ([40.107.237.108] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmrsl-000Npu-Ga for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 06:23:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFRP4cu4rB7i6bxfeF+mK+x8GXs7mvjhzpIbWJbF+FXMr5FoLbmIh8uf+fuUvISiOP9vinlGOeIQJrHQ+YoJcZ0tlJue7JQgvFTXVhOZ+VchmOrSP0XLcCvSticiRqgBVIf5iRv5a47SckRxPZNgX7T8MWz0hci6/K7lK75ht0CYtc3hEvrN+8Txrr0RzB6Ob3dvhWVOjKzQXh+r8/u0H0R/s01hySHk36EkF8SCZgY79BaehaAGwtXdYs7Nwbz/2WkPgKeMO51DNiNDejLNY5Iu/+C7aDjdKn1Ksb/16oNPPq9kVP5/9wl6XzwItnyN2PF4ExrbPS4EYebE3E4hWA== 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=q3Fc3IRCTa7wuJ4BPfx1/ga3Gse8KsZ+tjKMWhSG/qU=; b=AEB0fqQePdRkv9A8uaUmpJF+lDhjRSi42nlfEenBS3bhBlbLhzqcgc5e7bwg1gupooYtcPqwEn2bC9ZW/0E1vcza1KSj7/v1EkGB9DLkCDbo/a5oyr+PfQzzbaJ/kNAdw28p8hMsVj0sNr2ZNzgKtF1FYhj7W626Nu0WyB7QAlaibgYkX76nPu3+7DTII3Ozff9+EMHWKuC60s+8+EJyiqN687bHIsFI6TONEIuFaEnksn1hOqcQo2g5GyG4GGnHQmn2UrKT5+n/nWtwFVh73f4NwIsKIZlNjlRxPCIO4HH7aXz22ofaAQkPVfHTvbjtRlwqme0y1VSWXMxGGJiTAQ== 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=q3Fc3IRCTa7wuJ4BPfx1/ga3Gse8KsZ+tjKMWhSG/qU=; b=IJtNxUTuIwEysddiuIK48pRm6/vVI7mVQd2I2MmP0dPydmnysEIiATdVYezqAbzSNVuoGV/Pe2zN76q+Ou+JPS6KeORmD85TyTcjAmsMNaiqib8bIMMcsjS0tRzmbYMW/6Gwa3O/7Bw3pxXZuKdjUlq/WldHceaKNoP7GtTKjpw= 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 CO1PR10MB4722.namprd10.prod.outlook.com (2603:10b6:303:9e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Tue, 16 Nov 2021 06:23:48 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f%5]) with mapi id 15.20.4690.026; Tue, 16 Nov 2021 06:23:47 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , Ioana Ciornei , Heiner Kallweit , Russell King , Lars Povlsen , Steen Hegelund , Linus Walleij , Philipp Zabel , Heikki Krogerus , Andy Shevchenko Subject: [RFC PATCH v4 net-next 07/23] net: dsa: ocelot: felix: add per-device-per-port quirks Date: Mon, 15 Nov 2021 22:23:12 -0800 Message-Id: <20211116062328.1949151-8-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116062328.1949151-1-colin.foster@in-advantage.com> References: <20211116062328.1949151-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR11CA0028.namprd11.prod.outlook.com (2603:10b6:300:115::14) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 Received: from localhost.localdomain (67.185.175.147) by MWHPR11CA0028.namprd11.prod.outlook.com (2603:10b6:300:115::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26 via Frontend Transport; Tue, 16 Nov 2021 06:23:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c1aad6e7-c7ee-4452-5080-08d9a8c9a5e6 X-MS-TrafficTypeDiagnostic: CO1PR10MB4722: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3F5e969X3sbnOvpsHIB3STZlQcwQidZKBQoPFaOzv01ek9bUzECRcB0hNEGSVhmq7VJpGxEpw2h5POW2qHfVgt2VNP2qVm5GVcWCIigm2vbB0b0AtAq5JB65FzfvNRf/l+D8CQ98rPaVsB9e9IQSLmCMNd9U4Wx6troMhdUEbnHMksjbTgN/mQu8Dt+i8U85sGIJ2v1+oCqOhCtnQP//L1rOcRbAn/gEVrXV2YVNMhOz6Wxb0e7ZE72pxUTQxYVOLNdLFz7bP9VFsNn6rwCv2rbO2h3f84mZVzd3Z4A6qt95Nzmm+oBBd4AlqzPYoBWkBk3b/l1Oj65VUH4NJIU2hhyE+vyCzePD/SfQdWCTKOsPhe69/KIJLD+XkTWk4BC2S7JhVLT1SibHlIfp4eMMj2R8MhdLpYWZvop+yHqmEpmJFoXWz2NliNXkYS4GBG7KGjfpOjMtpMo36IcOnzakQj78616SlEeylLHDhB7ZgTEQXzNkJGh/6T0C+lm5EW6QfWuw0iFOjHdnUPwmdZe0YV6H/GVx84pt000rdI8lF75h4dIFc5x44jbcklo2ysmudUA5fSlEvAlOSjKOaPaFTE+3rOEVJP5+ST7BFcdhrSau4BMa+Y5ppim+uhrrkKoP/gjG4R4VOZsnnSu+xLCwZf9pKXT09/SBtKYYLHh7G8eT7LQlQZd/wix4uVunEgwRoYKptVG4q2Xxf6V1HALrYw== 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:(376002)(136003)(366004)(396003)(39830400003)(346002)(83380400001)(6666004)(54906003)(5660300002)(2906002)(7416002)(6486002)(44832011)(956004)(86362001)(2616005)(4326008)(316002)(508600001)(8676002)(186003)(6512007)(38100700002)(38350700002)(1076003)(8936002)(52116002)(26005)(6506007)(36756003)(66556008)(66476007)(66946007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-M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d7hSV1DkSGVKyyUFbMozPA8FZbwyiZ6nOhPy+Nyf3f/t5fy205JDxOIJ/pWagEOhNFhrtFoy+zqo5gboWpAzM7ynbGmFNyLd6Zf/JLAntB/f0aHNvRDIUTQvocThZU3AMm9hYqltjH2FaN1LBRhnPclPVSgKyohhqAkshWgOyDdeLrAVC2i4HHpB0fyuOTlcbYlHyXQSNdrk4y2UMNeKdNn1QIXNCqsCwisCM4Tt5Ik39rhGmJVGpU/jfEv/W91FZGpiu9mKTHHOJfFwQLkPiwpiz6+Y7GrDR3E0A/ICeiCMGdRtEnDoMaUcdcu6apyEhCwy1Nmyuv8zj0OQ3GgIpg7G+J8agpzwrlz+cTghCyUz5vuwr4VWJWDq0xUiqu2P28VwESN1GFulVctRWrHTeG9nX06e3RPvEfwyKJiZOYqGBUF/hVdNkC7LggwrK8MI7qZkq6Xp5S/XMJNF9xCSuqpFa8IgEjZ9adza3sSzncOd/4yhOWtA7AZe0FW9Pd6NYL0PSFqrXH2xTG5mMNBwXIcmXc0SNLRom8z7E3MwEo3dt2WL/3bzC+8LdsOU6pNoqqtay9cBD21MocBKttYS4dXfZS4SMUAVdj69XelwiRRb4tVdakU+n6V/y1j+vATnhd5A= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1aad6e7-c7ee-4452-5080-08d9a8c9a5e6 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 06:23:47.6522 (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: /7JNxto0BcrqIKMeCRZFTtZ1rPlHnkTa2ISRKtBiTNtGJCXnYL3KTztwISDLXE84PZ0s67yf+aIU5k0fqzK2xPz1agJKv4Gbbh5iPZgZXIc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4722 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211115_222351_626972_20447675 X-CRM114-Status: GOOD ( 16.50 ) 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 Initial Felix-driver products (VSC9959 and VSC9953) both had quirks where the PCS was in charge of rate adaptation. In the case of the VSC7512 there is a differnce in that some ports (ports 0-3) don't have a PCS and others might have different quirks based on how they are configured. This adds a generic method by which any port can have any quirks that are handled by each device's driver. Signed-off-by: Colin Foster --- drivers/net/dsa/ocelot/felix.c | 20 +++++++++++++++++--- drivers/net/dsa/ocelot/felix.h | 4 ++++ drivers/net/dsa/ocelot/felix_vsc9959.c | 1 + drivers/net/dsa/ocelot/seville_vsc9953.c | 1 + 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 615f6b84c688..f53db233148d 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -824,14 +824,25 @@ static void felix_phylink_mac_config(struct dsa_switch *ds, int port, phylink_set_pcs(dp->pl, &felix->pcs[port]->pcs); } +unsigned long felix_quirks_have_rate_adaptation(struct ocelot *ocelot, + int port) +{ + return FELIX_MAC_QUIRKS; +} +EXPORT_SYMBOL(felix_quirks_have_rate_adaptation); + static void felix_phylink_mac_link_down(struct dsa_switch *ds, int port, unsigned int link_an_mode, phy_interface_t interface) { struct ocelot *ocelot = ds->priv; + unsigned long quirks; + struct felix *felix; + felix = ocelot_to_felix(ocelot); + quirks = felix->info->get_quirk_for_port(ocelot, port); ocelot_phylink_mac_link_down(ocelot, port, link_an_mode, interface, - FELIX_MAC_QUIRKS); + quirks); } static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port, @@ -842,11 +853,14 @@ static void felix_phylink_mac_link_up(struct dsa_switch *ds, int port, bool tx_pause, bool rx_pause) { struct ocelot *ocelot = ds->priv; - struct felix *felix = ocelot_to_felix(ocelot); + unsigned long quirks; + struct felix *felix; + felix = ocelot_to_felix(ocelot); + quirks = felix->info->get_quirk_for_port(ocelot, port); ocelot_phylink_mac_link_up(ocelot, port, phydev, link_an_mode, interface, speed, duplex, tx_pause, rx_pause, - FELIX_MAC_QUIRKS); + quirks); if (felix->info->port_sched_speed_set) felix->info->port_sched_speed_set(ocelot, port, speed); diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h index 81a86bd60f03..b5fa5b7325b1 100644 --- a/drivers/net/dsa/ocelot/felix.h +++ b/drivers/net/dsa/ocelot/felix.h @@ -48,6 +48,7 @@ struct felix_info { u32 speed); struct regmap *(*init_regmap)(struct ocelot *ocelot, struct resource *res); + unsigned long (*get_quirk_for_port)(struct ocelot *ocelot, int port); }; extern const struct dsa_switch_ops felix_switch_ops; @@ -68,4 +69,7 @@ struct felix { struct net_device *felix_port_to_netdev(struct ocelot *ocelot, int port); int felix_netdev_to_port(struct net_device *dev); +unsigned long felix_quirks_have_rate_adaptation(struct ocelot *ocelot, + int port); + #endif diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 789e1ff0d13b..5056f39dc47e 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1368,6 +1368,7 @@ static const struct felix_info felix_info_vsc9959 = { .port_setup_tc = vsc9959_port_setup_tc, .port_sched_speed_set = vsc9959_sched_speed_set, .init_regmap = ocelot_regmap_init, + .get_quirk_for_port = felix_quirks_have_rate_adaptation, }; static irqreturn_t felix_irq_handler(int irq, void *data) diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c index 47da279a8ff7..362ba66401d8 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -1088,6 +1088,7 @@ static const struct felix_info seville_info_vsc9953 = { .phylink_validate = vsc9953_phylink_validate, .prevalidate_phy_mode = vsc9953_prevalidate_phy_mode, .init_regmap = ocelot_regmap_init, + .get_quirk_for_port = felix_quirks_have_rate_adaptation, }; static int seville_probe(struct platform_device *pdev)