From patchwork Sat Apr 15 17:05:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13212591 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 BCF28C77B73 for ; Sat, 15 Apr 2023 17:06:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230130AbjDORGP (ORCPT ); Sat, 15 Apr 2023 13:06:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230097AbjDORGN (ORCPT ); Sat, 15 Apr 2023 13:06:13 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2051.outbound.protection.outlook.com [40.107.105.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D347F30C6; Sat, 15 Apr 2023 10:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PoEzDPcpb6zybCbGCVRxDDAv7/Vyy7RquR9WgF/rvVdeunp/nha9xYWwwtWg3vNG3bRPdzdRLPgqVCD+ZlcILHi5VmMI17zrZVq6t8LE6+Wd0ChZ2WmLyfSDQH1qL1LqqcbzHBVysBgR/F91Kktp2lEIrVM5/It7PmYt56hhlJoG1nqfSk6sIeNQdmJX+/BNcEdkKCuaXqblbwXvWKffG2jJPeN+xO+KqCKOxAPE/+Tv9jb5GjJ7EEFjOhlvzyOBubCpZsgYwHVcnp9RoTdGkP4kUFSQqlZCBff+JRARZgPYG6QsonIuOwBVTNu75CMR31kdQMGM7G12DcbTr5HkUg== 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=uWkntbgXSv/6lj/Hl4WkY8QQTPipH9GuKxcfWo6w8PY=; b=hbTcrbJM2+wAm2XevH/0VqxzUqBGTOWOnvQzWUftk0eFDUsU5y8dHoy0U/BTJsiAJkI+VYokuW0ZSbbjr4rVo/kKcRR/Ed84Qud+sDMmpWfUWqompGQy0UiYMvqJvrns1rGeqzb2eH/nPTDHhQkO8l8rikBFoSEtdS3mRnDPpBLRKoGDpLZ/nuY5Fd2p3bTuNcan25er2KFYu4qOGe6Ob0u3f6IY8sxmfmDkzFSwiaLUKNKhIjCZAnHWScLOSPDv+sBWAWcr4XORaJ8WGRB81+SxOM6c8/DVl/rmSq7Z2GuWBfmv6bf15xbVpt2ckL4/7oNYJXwEZAwATVSM3fxH+Q== 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=uWkntbgXSv/6lj/Hl4WkY8QQTPipH9GuKxcfWo6w8PY=; b=PGn2xXeLt4rO1fc5VGBM0As9tti9C4TD2p3TIGW5bg9nxqT24FvWyxbVLmQ5/unIlfvgmMc6ZIJJNq6GHJ+qfXUTxChQNFYUdBGjbZ//BJS5B4MwkOaPAzlmTDSsbNkIDh0I5JpdpfyQJHH5D4Gu6COTVu5ilPzSOFuh5DLXDdI= 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 PAXPR04MB8158.eurprd04.prod.outlook.com (2603:10a6:102:1c3::6) 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:06:04 +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:06:04 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Xiaoliang Yang , linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/7] net: mscc: ocelot: export a single ocelot_mm_irq() Date: Sat, 15 Apr 2023 20:05:45 +0300 Message-Id: <20230415170551.3939607-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230415170551.3939607-1-vladimir.oltean@nxp.com> References: <20230415170551.3939607-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0100.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::6) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8158:EE_ X-MS-Office365-Filtering-Correlation-Id: caa91a49-87d7-4c78-52e8-08db3dd3b242 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MkOfBtsZ5qAtDl5I7SPkEy/9QRAu9IQ8sPswk+JUapUXie155BL/s7raZQi1DlHwYJc14XTsnQNm4CcuwOyL+Gns9+Pv0IBHK8PfPfGEXvg26E67sxYv6Y+RDTor6TZCDRm+sldS4jTQmw9gVV7s1q94dLzDY7s2EOmjTX6mzDrM81hFsL61m4ok0af2AzO24IeEZb7jjLnGNcXLckWtDYKu8Zq1fZAX7P2+Y/4h6+bo+3jegocuLLqmhQiwbqjsRpQoTFnVbZWd9GdPa/YjOdQbYr9LGr6pAycg0dfaOeQem8KAsVwbxFlB+iFb0QAaIz0YUY3sO68xgfGPXF6m/B1UEnyrSOp+d9aH46NTAVf7UFMWpS+TCvs1aYrfl14/289qhbxj31irzoubOrvIxKsu46kw0d2ph/L8nae797IbUIfdVM95cXrhHFWCNjsQPyxpXlcN/jPl07oN2ZMttnVqkRTVGmT3QUyJZGrb/hb3RYFqD1Tg6F0RBAE5Kx4uY5V56uvPOjoucKyb6NKotmxOkbzcHPcxoqEf6x3dMEYUeG0TpF49iXNdubXLLX0rRMvqQpmQ6UAiNvaAwBpszx42xo7t+M6G218EWyYITcroYrmnCOUdiF9IuYfEXHvt 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)(366004)(39860400002)(376002)(346002)(396003)(451199021)(316002)(4326008)(38100700002)(38350700002)(6916009)(66556008)(66946007)(66476007)(5660300002)(44832011)(2616005)(6666004)(52116002)(36756003)(86362001)(6486002)(41300700001)(54906003)(1076003)(186003)(6506007)(26005)(6512007)(2906002)(8676002)(7416002)(8936002)(83380400001)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xtb2jnmEp4j8Qtm5+w4KRepmBjJSqOjQJvUlZQ1n3WINX5VYPZE7XXGM+BOYqDoXu49lkn/zk4pmvMb+zKzMnTDnFDKMsbuCFmN5yCYHHvEp8ugSXRY6a/gHpJSkAFbpipgsyw3ZpMGtSNAysq60YEtNLPxMTxf4W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Iuk7woXk4zx+nI5LSyNGM2UHXf7BPrz0rtGMEQhTY5rlDattmtfFx4PW8VzZQUwNRsHYXOCUvT6l5Ahw5oQqpEhjz77ND4nQdxh+ND0bhxpxciHTTtaYcytGy3KytTEXcgd5tjl9xbtzAyV7TLuNReoOsE0S8VPt0Eh/nnpttYmIF2szUDNimIb+LERjYitP0xHzk+3FpNCV/p979ZmfIBSK4jVP41hiGhzet1cDXaS8M3F4PJBvKWEwxgQCv5TlSiTtvbwvOoAacb3pG92fTlwvlMIvAnygh9PBV5eUIge1qsyF0gQ8A2hvcJCgGcxiNQ1nt2N+ThaZbskTVe8+o5xmd00oDa59xUFZzGMKKxpjgx2JQcE7dSsaNS2VQxDtPmug== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: caa91a49-87d7-4c78-52e8-08db3dd3b242 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:06:04.3436 (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: kbuJD2bI3iiFTw6wSzFAcsEz9HqNBiRl82h9ZmXyye6dmIbZhMarwRxFOkqKOQI0ASKTt6LBfY/xcUm848wqiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8158 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When the switch emits an IRQ, we don't know what caused it, and we iterate through all ports to check the MAC Merge status. Move that iteration inside the ocelot lib; we will change the locking in a future change and it would be good to encapsulate that lock completely within the ocelot lib. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman Reviewed-by: Florian Fainelli --- Diff: patch is new. drivers/net/dsa/ocelot/felix_vsc9959.c | 5 +---- drivers/net/ethernet/mscc/ocelot_mm.c | 12 ++++++++++-- include/soc/mscc/ocelot.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index dddb28984bdf..478893c06f56 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -2610,12 +2610,9 @@ static const struct felix_info felix_info_vsc9959 = { static irqreturn_t felix_irq_handler(int irq, void *data) { struct ocelot *ocelot = (struct ocelot *)data; - int port; ocelot_get_txtstamp(ocelot); - - for (port = 0; port < ocelot->num_phys_ports; port++) - ocelot_port_mm_irq(ocelot, port); + ocelot_mm_irq(ocelot); return IRQ_HANDLED; } diff --git a/drivers/net/ethernet/mscc/ocelot_mm.c b/drivers/net/ethernet/mscc/ocelot_mm.c index 0a8f21ae23f0..ddaf1fb05e48 100644 --- a/drivers/net/ethernet/mscc/ocelot_mm.c +++ b/drivers/net/ethernet/mscc/ocelot_mm.c @@ -49,7 +49,7 @@ static enum ethtool_mm_verify_status ocelot_mm_verify_status(u32 val) } } -void ocelot_port_mm_irq(struct ocelot *ocelot, int port) +static void ocelot_mm_update_port_status(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; struct ocelot_mm_state *mm = &ocelot->mm[port]; @@ -91,7 +91,15 @@ void ocelot_port_mm_irq(struct ocelot *ocelot, int port) mutex_unlock(&mm->lock); } -EXPORT_SYMBOL_GPL(ocelot_port_mm_irq); + +void ocelot_mm_irq(struct ocelot *ocelot) +{ + int port; + + for (port = 0; port < ocelot->num_phys_ports; port++) + ocelot_mm_update_port_status(ocelot, port); +} +EXPORT_SYMBOL_GPL(ocelot_mm_irq); int ocelot_port_set_mm(struct ocelot *ocelot, int port, struct ethtool_mm_cfg *cfg, diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 277e6d1f2096..eb8e3935375d 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -1148,7 +1148,7 @@ int ocelot_vcap_policer_add(struct ocelot *ocelot, u32 pol_ix, struct ocelot_policer *pol); int ocelot_vcap_policer_del(struct ocelot *ocelot, u32 pol_ix); -void ocelot_port_mm_irq(struct ocelot *ocelot, int port); +void ocelot_mm_irq(struct ocelot *ocelot); int ocelot_port_set_mm(struct ocelot *ocelot, int port, struct ethtool_mm_cfg *cfg, struct netlink_ext_ack *extack); From patchwork Sat Apr 15 17:05:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13212590 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 8B43FC7619A for ; Sat, 15 Apr 2023 17:06:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230102AbjDORGO (ORCPT ); Sat, 15 Apr 2023 13:06:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbjDORGN (ORCPT ); Sat, 15 Apr 2023 13:06:13 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2052.outbound.protection.outlook.com [40.107.8.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B56930C1; Sat, 15 Apr 2023 10:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MWlgtE0pPGJjQz9xW2hFxCvsLi1z60ROIiDlw1kBJyiE8LEltB2V6UZjI2wf/anrZDRqY+zJp8LSLt2icvOflnfDga77LIvPl5eRS+joldtCl/Kjx01WrOvx9xQbpdR1GgoEm+YsPKVSGpZwk8MZI6lWup3CjpUU8VkFupClWfsTJnpQ9swi2FVyTJ/zKlxRYvsG1TZUHlDD8TelyfkNSfoPfpJGGRRjPFmOXrZ+I4jgKAgF6ZlVS49oyK69P6C0JM6zTpFBLMihbJNMn/vwkFuhhQtNeEEBHv6UhNvN3IJ4x2/dtvnrQ2nJXWxKQLqZu4S3lZAGZ2KaV2s3ULMKJw== 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=bppP70At0MbklMKoGSAcgyzNzS3CHZbdqmc6OBpaO5w=; b=dxcWWKwTx+Ce9WVmOREVDp3PnVeGeK7fCSCSvUt28yM9g86REaWzh+EP26MWFR5UYyANvEL/qdtGSU2laFq2N8MKDFv3B/xlkNW+xAhhRyBIKzdmsbGojhHlR/lK4AcDpSVIraLxPMqmf7UX0SFZK3GmrZw9Iy/qez1tg6v69Sx6UHqi7T+bYG7zY0Y8SeZ7N6BKizvXFkrdO3nX1x6RdAMq8GHh6Proc/PFeKiA1+25uVcCXdEtkOg8D/pJXIgm7aMmeh/M58oIkfK63VjmWpF4z3kB1/3WtnNNlYnwX/Dz5E12lU2M4fItbHleH/FUf2gcihnkcSt4l6X2Bkxnag== 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=bppP70At0MbklMKoGSAcgyzNzS3CHZbdqmc6OBpaO5w=; b=bETW4OT6fn2LqEuiVdpdZO7B7jx5nYvIiAeeg2jIOkIhh6LDLVAkTY4Ts7nW31IToDAjAdksBXi2ySRUFDrGD51VvNtJOkrBNytQFZQZfh24DGpNDIN3Z4z8FYgvDK0tUsCw0DouQQWdvw/0YzFwOMnzUNH9BJCaiG0o++UV8zg= 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 PAXPR04MB8158.eurprd04.prod.outlook.com (2603:10a6:102:1c3::6) 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:06:05 +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:06:05 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Xiaoliang Yang , linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/7] net: mscc: ocelot: remove struct ocelot_mm_state :: lock Date: Sat, 15 Apr 2023 20:05:46 +0300 Message-Id: <20230415170551.3939607-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230415170551.3939607-1-vladimir.oltean@nxp.com> References: <20230415170551.3939607-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0100.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::6) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8158:EE_ X-MS-Office365-Filtering-Correlation-Id: 91838f5a-7c4c-4caf-851b-08db3dd3b2d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6+i2nL9SYfPdSsZCpC613Y8kfL0kDLuTfPDRKcxNApgFNG9sFlNpc6gO1ATBekCeFO2BGd/cxvUZRVG5bSMFyYdlwD8DaztapIDqlBbTJ5YPuUxJZrhRmUGUGUAYBMwxrx1ztGWC8PLykeynDfG1zkqAG6bEEmyJsFz95fUNo5xOavcmva0o42iEtjTsHx/YvkK8kRuErGKfvkhcOoPP5ul5oqzsC4WFSoL6hknEuFpmQImclYh9NriofpeDOTciSLvq8pWveUwsGhKL06i+UPTJ/7lWtNjK6uewaShOwWGPAciavSaDTMI5cdX8Wlkph6pUIJE67ovrMvOv73r2hgjsbod8V2Vyi4WVCQXR6bKbaL3znCVL/U3NJhU/HgURYvNr5QY3DfLkz4Q96872GcLCJvTQOnI5TrKz6CJ93hN+8STyb9F1jLzeQMSAx4CCB7UAUWYNmKrcyW3Dn85BGtzMRR60z/Lf6F16TZ+x4lba9wFyGOJdHQLs8BW1zq7CHB0uw1G9U0uQNilw6htoXKaP4Zw1LNH78XPBN2rIDvFg6XdvnbxfVYxiu2n0If8uKxCl2NjrSoYpiFeSlek+QDXmGyaWRR1bMr2UiLqCSV3n3nBU3SSbcFiHSB3J+NmC 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)(366004)(39860400002)(376002)(346002)(396003)(451199021)(316002)(4326008)(38100700002)(38350700002)(6916009)(66556008)(66946007)(66476007)(5660300002)(44832011)(2616005)(6666004)(52116002)(36756003)(86362001)(6486002)(41300700001)(54906003)(1076003)(186003)(6506007)(26005)(6512007)(2906002)(8676002)(7416002)(8936002)(83380400001)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: P2ugV9ipetwg1WndQcRIgnzR9CTmOwzk/ITeEM74/9Z9SL7Ew4nT8vIdNEpdvem+pIew9wto2YbvugJ9VK/ypP0SdUw3fe/z1mPRUTswQXYQjjfWV1LJlogtNM+UVWR55ThpNt4lzO6/Hj/TKIZGtV0ajX2fGlRhzj9LKh+wnyTiZVPid8htHdiT4W4PJ3P7uZgtwE1O4CAD9Fw7teAWCmwyLfwIrCLZkLPKTGWZCfnL0z10cM13d/kPMXAn3em+mbPdbaSbPMgsaTF4rifj2oqkzSmm3LgRomsofIjFiwi7bZaILmRsqIPOuCieRz/ewxihNENqjAJ2BHacYL5W34kl5+Chsmb8dP22FDUyZAJcOFJ2rUmE6WMoAZr9g2Jl99DcUTsCjIhrZNOCSTXaDCbSR7tYZ7SakqBW6qztPtLJQm13Rfa73WoDqclvxEJb+xYd7v7ndBDMxncUzy7DTHcniTzMfbBDggBV2lCZFwVZdBWgcliBrlGbEVqIha9etH0HWfd+2zTCaEOsStzWMc/xw9cWPKypOPB/TlBuuuqEqWbpz5zyz049NVM/7nvaaflLDRcn6nsHPxNDrfzSDjVUupUBWMP4H4GqjVpWJtW1cWFp9J0a8052Rlmt6VcEyaPtPv5TBjlciZ5VOB1aOAZ2G449esh4+3kjCjb3VNkDvl8Y8pg1o3SW6hWUV8ty1VU0RYN39dE+9eoK8gES/eQfsgpzF0ADEN/LcNh+PvSLEXu8OiCK9D5z4L215giVVtYRpC+BT+joG9nuK9bpEP9wDTRIifphwOALt3aq8tvGkr1jClyHHlIfYxxNB6HARb2+zB8uKCNQne/WvNuPsiXqvcgSkim5a/KOdcWaWxi6Ou6eWbBaY+xhxe7/sZtzzlxYDa5Oc8E7FcLbmzpPK+8ApPgsATLl0nCeBTrjjPAB/UeHGuRPs4kXeENOHry6Qez60VcK0UOJ9ccnGGtGy437x0UtZ0A8EhteEOdKrFQmrDMZeXJgzDLmJYSYPpT+R4eSYtr7W32nEwBSpfl3JpzlspHLpFeAfge8jHFuP00J8r+ey1Lq/HAltcWhhG+BJwx/6slQeNKxODLUKqTX8dr1s0SnFSnCG4ueUue3mjBK86hp9SoS4lAFic2+vQaIkvvzGBheCl+MSmdKDIoWVRHyK2vyKOmyIUJ1CNUQZuxI4gsgOtEjwXcx2iZvNoiB/V/cx3nKAIWCAMkhZcyCPQlec+PJv46+xGgwFnWNB7+9c00DXhmjugCRgRCBdNUpWVAlrH5Srg8eR7oPA1Q8at5MP78uDF9bQsvN4Sg+kd3McvzQh3wBe9xT2w1ZmvedqCTJmnTGhmkj/775iY7ytrycLGdC+G+ggdj9NXCgdgSA0sGlo6d/tBOxZN7i6A7H9j2f3FeKgtDSJlPHX18M1tF02sjlnzc5FBPjM0y+JCR+HXC9Qf2qvWDINy2WPgvyJL/8WXECNVUnsL51tuYk9pWLJkojIhDcvh/zlCVVNShuVIqSyo7N5O/SNqd0r0+DO0VQS9Bm0921gh+qF5T33luHYZSBKSO+gLCEHwVNJpQEuaLXUZCcx7DbN1bG2645GYYWBH+QkPNuXJvKzJTPbA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91838f5a-7c4c-4caf-851b-08db3dd3b2d8 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:06:05.2751 (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: iWjyO6MyGhAcGf0V4NVOYof1GbKhItGTD5Am9BxUF/owh8h/KipFMsy9ap0niduJvrXPePAFgGVk9goSVqsQGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8158 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Unfortunately, the workarounds for the hardware bugs make it pointless to keep fine-grained locking for the MAC Merge state of each port. Our vsc9959_cut_through_fwd() implementation requires ocelot->fwd_domain_lock to be held, in order to serialize with changes to the bridging domains and to port speed changes (which affect which ports can be cut-through). Simultaneously, the traffic classes which can be cut-through cannot be preemptible at the same time, and this will depend on the MAC Merge layer state (which changes from threaded interrupt context). Since vsc9959_cut_through_fwd() would have to hold the mm->lock of all ports for a correct and race-free implementation with respect to ocelot_mm_irq(), in practice it means that any time a port's mm->lock is held, it would potentially block holders of ocelot->fwd_domain_lock. In the interest of simple locking rules, make all MAC Merge layer state changes (and preemptible traffic class changes) be serialized by the ocelot->fwd_domain_lock. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman Reviewed-by: Florian Fainelli --- Diff: patch is new. drivers/net/ethernet/mscc/ocelot_mm.c | 20 ++++++++------------ include/soc/mscc/ocelot.h | 1 - 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_mm.c b/drivers/net/ethernet/mscc/ocelot_mm.c index ddaf1fb05e48..d2df47e6f8f6 100644 --- a/drivers/net/ethernet/mscc/ocelot_mm.c +++ b/drivers/net/ethernet/mscc/ocelot_mm.c @@ -56,8 +56,6 @@ static void ocelot_mm_update_port_status(struct ocelot *ocelot, int port) enum ethtool_mm_verify_status verify_status; u32 val; - mutex_lock(&mm->lock); - val = ocelot_port_readl(ocelot_port, DEV_MM_STATUS); verify_status = ocelot_mm_verify_status(val); @@ -88,16 +86,18 @@ static void ocelot_mm_update_port_status(struct ocelot *ocelot, int port) } ocelot_port_writel(ocelot_port, val, DEV_MM_STATUS); - - mutex_unlock(&mm->lock); } void ocelot_mm_irq(struct ocelot *ocelot) { int port; + mutex_lock(&ocelot->fwd_domain_lock); + for (port = 0; port < ocelot->num_phys_ports; port++) ocelot_mm_update_port_status(ocelot, port); + + mutex_unlock(&ocelot->fwd_domain_lock); } EXPORT_SYMBOL_GPL(ocelot_mm_irq); @@ -107,14 +107,11 @@ int ocelot_port_set_mm(struct ocelot *ocelot, int port, { struct ocelot_port *ocelot_port = ocelot->ports[port]; u32 mm_enable = 0, verify_disable = 0, add_frag_size; - struct ocelot_mm_state *mm; int err; if (!ocelot->mm_supported) return -EOPNOTSUPP; - mm = &ocelot->mm[port]; - err = ethtool_mm_frag_size_min_to_add(cfg->tx_min_frag_size, &add_frag_size, extack); if (err) @@ -129,7 +126,7 @@ int ocelot_port_set_mm(struct ocelot *ocelot, int port, if (!cfg->verify_enabled) verify_disable = DEV_MM_CONFIG_VERIF_CONFIG_PRM_VERIFY_DIS; - mutex_lock(&mm->lock); + mutex_lock(&ocelot->fwd_domain_lock); ocelot_port_rmwl(ocelot_port, mm_enable, DEV_MM_CONFIG_ENABLE_CONFIG_MM_TX_ENA | @@ -148,7 +145,7 @@ int ocelot_port_set_mm(struct ocelot *ocelot, int port, QSYS_PREEMPTION_CFG, port); - mutex_unlock(&mm->lock); + mutex_unlock(&ocelot->fwd_domain_lock); return 0; } @@ -166,7 +163,7 @@ int ocelot_port_get_mm(struct ocelot *ocelot, int port, mm = &ocelot->mm[port]; - mutex_lock(&mm->lock); + mutex_lock(&ocelot->fwd_domain_lock); val = ocelot_port_readl(ocelot_port, DEV_MM_ENABLE_CONFIG); state->pmac_enabled = !!(val & DEV_MM_CONFIG_ENABLE_CONFIG_MM_RX_ENA); @@ -185,7 +182,7 @@ int ocelot_port_get_mm(struct ocelot *ocelot, int port, state->verify_status = mm->verify_status; state->tx_active = mm->tx_active; - mutex_unlock(&mm->lock); + mutex_unlock(&ocelot->fwd_domain_lock); return 0; } @@ -209,7 +206,6 @@ int ocelot_mm_init(struct ocelot *ocelot) u32 val; mm = &ocelot->mm[port]; - mutex_init(&mm->lock); ocelot_port = ocelot->ports[port]; /* Update initial status variable for the diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index eb8e3935375d..9599be6a0a39 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -744,7 +744,6 @@ struct ocelot_mirror { }; struct ocelot_mm_state { - struct mutex lock; enum ethtool_mm_verify_status verify_status; bool tx_active; }; From patchwork Sat Apr 15 17:05:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13212592 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 5F6A8C7619A for ; Sat, 15 Apr 2023 17:06:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230188AbjDORGb (ORCPT ); Sat, 15 Apr 2023 13:06:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230114AbjDORGO (ORCPT ); Sat, 15 Apr 2023 13:06:14 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2052.outbound.protection.outlook.com [40.107.8.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E40530D5; Sat, 15 Apr 2023 10:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M4xnY2W2lac+68Oc+zq+ZN8E8joQ9kdHtFEF9M93Efz4mSow5cLP/KB0JA/nm7ke3WmTdwtcu/Hpu70QsSegbh10xTFG73Hvbtl3E4vMWnhDIRSmIO++1XUKC4r4DEacJQ+5cGINTzojmm3WENjRBoO/g+bmrc0oBCBfMg1LPkM/53aTOgOcVVTYE25BDCTKV/PVumUyC2+YOYkk3XEYfVGfCHUR5ny9nf4LEgiKJZRHMgQ92TUw7tphuHjdDgFJTF+96xLkn06GtS/0ysAzkZTv6Mq6D30+XF6GPMhEVPMGi7JmCLJ6P9ypWo3JTpoofsMeXGvfiUJ8SOWk5XvV6w== 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=JHYWICrN++t+4NDeVIhoNCgLnsjyZGWOvhLKRK1tvuc=; b=DK9hj2XT4o2cknVQj3VDeDnpmjdXdq7Am8T48blHv4BsOkW9z8bxFI4y2vk5z2eJXm0PlxIZb5oXPVGSObUL/k1kLgAo6/8zvtodPDqVM4LLOOLCucnxtbWlz3KTSwfkagDg8NknRYOfgupoPjIR3NNx01teTP7xelP/1rSBdPJtd95o+50m5lHerqzP3WBVVs2OUdPsIx1h5JUXdQT4jyr+qjnIMJzpxwv//bx3bMCBBqVnjTIKBS776RUzf9sVrDm0VRomlia1P+v75zQ7HT8YUZgWLzDUllcoYdXkEcDjFsgs6A37FTn2BPT+AJc7NMyWEW7G9mhG3P1sTXgxHg== 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=JHYWICrN++t+4NDeVIhoNCgLnsjyZGWOvhLKRK1tvuc=; b=bw+nXiTMs94CwZgcSxReRwfi3JZulM+2ksC8pJv0Ig60dTKBaCAAscsw1jGYYiNvXQqECaccwKNoL8WSq9+3etBenC/87lmcL5wf8XQPT+5emkXfW1dbWkfp3EOUULO5NxloxurnjucWGbxehVHKShgGnXOfgQAYG+d2VT8dXUQ= 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 PAXPR04MB8158.eurprd04.prod.outlook.com (2603:10a6:102:1c3::6) 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:06:06 +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:06:06 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Xiaoliang Yang , linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/7] net: mscc: ocelot: optimize ocelot_mm_irq() Date: Sat, 15 Apr 2023 20:05:47 +0300 Message-Id: <20230415170551.3939607-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230415170551.3939607-1-vladimir.oltean@nxp.com> References: <20230415170551.3939607-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0100.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::6) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8158:EE_ X-MS-Office365-Filtering-Correlation-Id: 1964630c-6ecf-40f2-9070-08db3dd3b367 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O2DxOi4cqodzgocdt+CkfNTRejsYb55gEhnM6MnF+iWU2s24Rkiy2l+COlB1EaXay5xPCgiSvXLMdLLzc4+gaou6OYO2+oTyDsV64dJOteGiIXbT5KYsMZ86m+AK0LENrekI7w3bAflnFT5fN1PSERanP1qrJSmOnk1xK7DP2lue2mFiXgYOiGoXsN3L48h/6Wv+w/a8F9GxXcxuOx4KLLRoMe0+0vJiBsA4oQkMnj/Apw4MfQygnDq93CPa0WpzaQYQTSYqSCWMAhztAbBkOhzDbjDIA+z8TPIlQG97nwi/AR6B00aUGM7VMZZrBpK4mQNdfURn7XBa422rIEjctdogQBfW5s2f2eRDEwtP8ZsTpUSzNFKh4R8Z2KpDFpwCCOaUopsmWWAb7oZS/Qeu1nXExmUUV+UrH7A39fpRa0NWcbALj6+fznZ14Ip/6C8uKTOgAtvKj+O43UEMRuuXIe6lrafvf49vFZTNAEI9HdvEQ3pNiCKGccmjRFunxQQ//Gal9iEbkQ0Z0d/wwz3KXwUl+BYh0isDwZCiweJFCanrEeLnjD64ROMnC1DeTVAC2FkwRCA74tcY6oalRXPknmVLPSzbx3fv4zYpsrEa1l/0LwnNAgFlrm6oeBNKEfEU 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)(366004)(39860400002)(376002)(346002)(396003)(451199021)(316002)(4326008)(38100700002)(38350700002)(6916009)(66556008)(66946007)(66476007)(5660300002)(44832011)(2616005)(6666004)(52116002)(36756003)(86362001)(6486002)(41300700001)(54906003)(1076003)(186003)(6506007)(26005)(6512007)(2906002)(8676002)(7416002)(8936002)(83380400001)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-Chun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GWMIQXRwiKAcGuXItlr0RSQ8Y5frpEu0wL3dD18j3n37tWAf2uSUW7f5PgO6rUaXVaTZckP3bfB1Q+bqalFrrdVYt7/Cirz4AylKO9LNDDZM1n5ZEobHOs2RUEFjWLOFdUPOC0VOUE5q8D4pJQcLwjVcJi/lYHIX0LDNDWqOTCiJzTAAIR+bet2M4o/08aSb1sCgzPbW1uqumQOlTvBvuU+/dp1y25N+avUWHMTn3L0za7mnfViAKQF+QAnR96Dvz+Qf32wfcxNnLXP3mOSNlIj2BEKU8q6aKkwg25cGDCbT+uNGKBvTibgcBYwv2/u9P7ryrtRpuYKnlwJF64nnRNCTxHQ+zynJ4XwMWiOQoKMdtATcbiFT0OT2K4MQyULtJu2qNEunM59JLKxGPloonX78cgcuUr5UkuA3Jkv6wclBoGQhjABYTsMpkYdsb/hltUsfcf7loX+NpKioKu50+nEp7FR22eMrj5mB+5zAX7LXMLu52wIcrKsztHH/2caX7jlthuBqrqX03glLPffWv6e4h6NY0VOGor52X6kziQXjIcHlBGXivYIw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1964630c-6ecf-40f2-9070-08db3dd3b367 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:06:06.2274 (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: EpUNu+osm/wurnvX0BU4653BeH08X+2A1IfuH/xAsLecSmz3UbPFDz+8xqepo9N++sKqy+4fmYV3nd27uDa+kQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8158 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The MAC Merge IRQ of all ports is shared with the PTP TX timestamp IRQ of all ports, which means that currently, when a PTP TX timestamp is generated, felix_irq_handler() also polls for the MAC Merge layer status of all ports, looking for changes. This makes the kernel do more work, and under certain circumstances may make ptp4l require a tx_timestamp_timeout argument higher than before. Changes to the MAC Merge layer status are only to be expected under certain conditions - its TX direction needs to be enabled - so we can check early if that is the case, and omit register access otherwise. Make ocelot_mm_update_port_status() skip register access if mm->tx_enabled is unset, and also call it once more, outside IRQ context, from ocelot_port_set_mm(), when mm->tx_enabled transitions from true to false, because an IRQ is also expected in that case. Also, a port may have its MAC Merge layer enabled but it may not have generated the interrupt. In that case, there's no point in writing to DEV_MM_STATUS to acknowledge that IRQ. We can reduce the number of register writes per port with MM enabled by keeping an "ack" variable which writes the "write-one-to-clear" bits. Those are 3 in number: PRMPT_ACTIVE_STICKY, UNEXP_RX_PFRM_STICKY and UNEXP_TX_PFRM_STICKY. The other fields in DEV_MM_STATUS are read-only and it doesn't matter what is written to them, so writing zero is just fine. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman Reviewed-by: Florian Fainelli --- Diff: patch is new. drivers/net/ethernet/mscc/ocelot_mm.c | 30 +++++++++++++++++++++++++-- include/soc/mscc/ocelot.h | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_mm.c b/drivers/net/ethernet/mscc/ocelot_mm.c index d2df47e6f8f6..ce6429d46814 100644 --- a/drivers/net/ethernet/mscc/ocelot_mm.c +++ b/drivers/net/ethernet/mscc/ocelot_mm.c @@ -54,7 +54,10 @@ static void ocelot_mm_update_port_status(struct ocelot *ocelot, int port) struct ocelot_port *ocelot_port = ocelot->ports[port]; struct ocelot_mm_state *mm = &ocelot->mm[port]; enum ethtool_mm_verify_status verify_status; - u32 val; + u32 val, ack = 0; + + if (!mm->tx_enabled) + return; val = ocelot_port_readl(ocelot_port, DEV_MM_STATUS); @@ -71,21 +74,28 @@ static void ocelot_mm_update_port_status(struct ocelot *ocelot, int port) dev_dbg(ocelot->dev, "Port %d TX preemption %s\n", port, mm->tx_active ? "active" : "inactive"); + + ack |= DEV_MM_STAT_MM_STATUS_PRMPT_ACTIVE_STICKY; } if (val & DEV_MM_STAT_MM_STATUS_UNEXP_RX_PFRM_STICKY) { dev_err(ocelot->dev, "Unexpected P-frame received on port %d while verification was unsuccessful or not yet verified\n", port); + + ack |= DEV_MM_STAT_MM_STATUS_UNEXP_RX_PFRM_STICKY; } if (val & DEV_MM_STAT_MM_STATUS_UNEXP_TX_PFRM_STICKY) { dev_err(ocelot->dev, "Unexpected P-frame requested to be transmitted on port %d while verification was unsuccessful or not yet verified, or MM_TX_ENA=0\n", port); + + ack |= DEV_MM_STAT_MM_STATUS_UNEXP_TX_PFRM_STICKY; } - ocelot_port_writel(ocelot_port, val, DEV_MM_STATUS); + if (ack) + ocelot_port_writel(ocelot_port, ack, DEV_MM_STATUS); } void ocelot_mm_irq(struct ocelot *ocelot) @@ -107,11 +117,14 @@ int ocelot_port_set_mm(struct ocelot *ocelot, int port, { struct ocelot_port *ocelot_port = ocelot->ports[port]; u32 mm_enable = 0, verify_disable = 0, add_frag_size; + struct ocelot_mm_state *mm; int err; if (!ocelot->mm_supported) return -EOPNOTSUPP; + mm = &ocelot->mm[port]; + err = ethtool_mm_frag_size_min_to_add(cfg->tx_min_frag_size, &add_frag_size, extack); if (err) @@ -145,6 +158,19 @@ int ocelot_port_set_mm(struct ocelot *ocelot, int port, QSYS_PREEMPTION_CFG, port); + /* The switch will emit an IRQ when TX is disabled, to notify that it + * has become inactive. We optimize ocelot_mm_update_port_status() to + * not bother processing MM IRQs at all for ports with TX disabled, + * but we need to ACK this IRQ now, while mm->tx_enabled is still set, + * otherwise we get an IRQ storm. + */ + if (mm->tx_enabled && !cfg->tx_enabled) { + ocelot_mm_update_port_status(ocelot, port); + WARN_ON(mm->tx_active); + } + + mm->tx_enabled = cfg->tx_enabled; + mutex_unlock(&ocelot->fwd_domain_lock); return 0; diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 9599be6a0a39..ee8d43dc5c06 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -745,6 +745,7 @@ struct ocelot_mirror { struct ocelot_mm_state { enum ethtool_mm_verify_status verify_status; + bool tx_enabled; bool tx_active; }; From patchwork Sat Apr 15 17:05:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13212593 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 8A104C77B78 for ; Sat, 15 Apr 2023 17:06:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230221AbjDORGd (ORCPT ); Sat, 15 Apr 2023 13:06:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230145AbjDORGQ (ORCPT ); Sat, 15 Apr 2023 13:06:16 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2051.outbound.protection.outlook.com [40.107.105.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A88B30C6; Sat, 15 Apr 2023 10:06:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GgGpYkWVzmYwabqg/1WYzdhPwqfyRVQNArLDwF60u05x2dHsaC41Eb+NclXiymJ5AcgqSZR1TWJclmJDuSSfOgZSSHn8csBXfEsLmJh1T5IT80lPR2RHjc5CE73s31t+gX55vWedaIpz3PAVzTcE8gYTYl7dp8mwXaMGXkELki8Z5IE0lXM+9Jr2JZw9/fKbDYbJLEm403dgEwFY1/dQx8b4QJSsRtcEhk5ms785Fukg7ejN/PLlAtXHZhjID8efd0OVi1Ej3Vf3KSygrL5eHAX+z+MyvJ++37Z/REZpYPfLz2jMGbrn3xJ/KrBeFRmvKuEppgN+MmjlV8pHlBQXpg== 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=o7XO6Vv3Pdc+N+MCXSftnkk0NDi/KSFwnsmEPh6i+7A=; b=muG0TLHQlxUGhekyU60PPL33uzJQpp1L5ddJ7Mn6uJxOfB28hLqG2KLJ1yOR9/l2EJdBN42zU3MBnUb1myx+J6hnEjgnNFVcCXu9IM8F4oIf/1fuQmo22oApcPAquXtDvcpJOvsbGX+0be4BZrqd1rukQ8tHqrDJcn+WwDm5BCZwpg56ulo0ud+v+eEyVBeAfU7Wr5SzusZuZaPt1+thfLfAIad5OiALNoVtN7XWqz7D3xfZqEU2IA2a4xvr/DW97nqNJdO5UBWSsl3Hp3y5JMOGUme8qLoAGcUL+kUR5VdViLTTH+YX7/J1C+hAqhUOQg+/iVT5FDEBNA60B9pu/w== 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=o7XO6Vv3Pdc+N+MCXSftnkk0NDi/KSFwnsmEPh6i+7A=; b=OTlUpyO4OEVWyqbA1ZJguYyBlVoj4geH+JTZMwdmZxvmPllpPbSbEnVO3ImP96dWBnst+VGNwBPBnMoE7J57wuM6ecZZs24gP8+29RKn1RBOSC6wByoWArmfIPNSkDyAA6T9CwLiloPZU/2y55jQL1hpu2vZhdlJC1GY1HghNyQ= 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 PAXPR04MB8158.eurprd04.prod.outlook.com (2603:10a6:102:1c3::6) 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:06:07 +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:06:07 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Xiaoliang Yang , linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/7] net: mscc: ocelot: don't rely on cached verify_status in ocelot_port_get_mm() Date: Sat, 15 Apr 2023 20:05:48 +0300 Message-Id: <20230415170551.3939607-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230415170551.3939607-1-vladimir.oltean@nxp.com> References: <20230415170551.3939607-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0100.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::6) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8158:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f5aeac5-eba5-41f7-605b-08db3dd3b3fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VBrHHg/eUkVh/WCtBwtKNRiFlCCQqxLa4uX/PkyItxjL6a7mBwZuCqF84P0SAZUDhVF9pfl+rWgv7BLgmIVhDN7w6iSMLlqnVcY0LLI0/Qt/c3RJsm5xSyW9WkZKepnI2/+rTl2edDqXqGMdDa09wuL61ybXhjn6kwEHlCzZQnxI7efc3NLkixyROrloy0KXs+fQZJnfThASUAtm7UJ3i3o50VgX4axDxoDyIe8042aNb++9oaMhfMzLLmCSvmKpNkyuJSeXYeP8YoDr2QbnCwEkJm6lfr43YWCcmMxZwNvVGeOWZunVb/jV3mirAIJQCiTQhsTBk04YYvQT2vabG9B87nqXEWgYyeKDdMZCal13TDxuurleTbWV1kaH4suKixOeIBVFbYRgVh4N8Ls5PHcpfHJmwxPSS4GfpyMsX2PenGpe/HsdZcgQL/GR83nNHP861yjJgJUZmjz953FKD5cBM4pmCDDLLKCdzuPHuhdnwaMWwvpdfEEHN3VURKvEUx5cjC9Vrt8XOnzWIknPFuZQ789Zyzp1WRF6B/ZKTKN1ishESqeh0FsfNQ4jlPgz7+BlhT2nG067CpzwC7SUrfjU4SGTEbWcJDMyvaF3GNgq4YDaMJ/Jw1yg/q5wIV4d 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)(366004)(39860400002)(376002)(346002)(396003)(451199021)(316002)(4326008)(38100700002)(38350700002)(6916009)(66556008)(66946007)(66476007)(5660300002)(44832011)(2616005)(6666004)(52116002)(36756003)(86362001)(6486002)(41300700001)(54906003)(1076003)(186003)(6506007)(26005)(6512007)(66899021)(2906002)(8676002)(7416002)(8936002)(83380400001)(15650500001)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-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v6vZ6w2HdfoZdBVOixs1uZPNmcp50cFfA734mBm9JFzw+Z44JCTtTJd2Bm1Jp7Nav0d7XoKjKF7gja+m83Hc+60mhzEICFRhtJs26MP5T7iVAzy9i94fqQ+OYbRWeTQdjinRqqBqRMes2QDWSqQT5lxk1Fqp/WfCPTrJQBWVec9NXqosijXkOi0+wYsDC4BAYiXCymm2cEsQEabnWr+G9/WTjxXkGEi9eJpO0m/dR9km3HLoISz3GHVmj/MuYsBmq7bdaHJTWFWl31DNhVllI2bwinB911lmz3EOJXgFxRG1F0DS17nBPZNMQYSXfS4ydJnD62+AOuDkcqocw0nkmRV4y2xCGIZpXfugRTAyU/m1Fs262yEf+Mt33Kjv25eDmm1zRX1z4Wp9c5LcUGHK7BDAH7uoKV8axSCG4bZHrKMbVXIhFAE1/zsZ4ha1QRptY6XTqb1fqybeSOj3SRyQBmu3whBc7NAN4RltSp4epN15fdeo6esEbHoP6FvL4qUWgVBW7OMqQ0re0qvAuirfY0p/NKdEQvWJdVNBuU6WYVtM3WGMxsbqbcXLb8bXsyPNfZCGa80sKQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f5aeac5-eba5-41f7-605b-08db3dd3b3fb 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:06:07.1686 (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: 8h1JB32CE59SiZ4ttXjyZcESPbbldgJmqqheqEYwx+3oP2YNSdq1N1v+MpR7aYkyttYwyZdIVtsSvWaaj3xtPQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8158 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org ocelot_mm_update_port_status() updates mm->verify_status, but when the verification state of a port changes, an IRQ isn't emitted, but rather, only when the verification state reaches one of the final states (like DISABLED, FAILED, SUCCEEDED) - things that would affect mm->tx_active, which is what the IRQ *is* actually emitted for. That is to say, user space may miss reports of an intermediary MAC Merge verification state (like from INITIAL to VERIFYING), unless there was an IRQ notifying the driver of the change in mm->tx_active as well. This is not a huge deal, but for reliable reporting to user space, let's call ocelot_mm_update_port_status() synchronously from ocelot_port_get_mm(), which makes user space see the current MM status. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli Reviewed-by: Simon Horman --- Diff: patch is new. drivers/net/ethernet/mscc/ocelot_mm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/mscc/ocelot_mm.c b/drivers/net/ethernet/mscc/ocelot_mm.c index ce6429d46814..3e458f72f645 100644 --- a/drivers/net/ethernet/mscc/ocelot_mm.c +++ b/drivers/net/ethernet/mscc/ocelot_mm.c @@ -205,6 +205,7 @@ int ocelot_port_get_mm(struct ocelot *ocelot, int port, state->tx_min_frag_size = ethtool_mm_frag_size_add_to_min(add_frag_size); state->rx_min_frag_size = ETH_ZLEN; + ocelot_mm_update_port_status(ocelot, port); state->verify_status = mm->verify_status; state->tx_active = mm->tx_active; From patchwork Sat Apr 15 17:05:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13212594 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 B1272C77B70 for ; Sat, 15 Apr 2023 17:06:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbjDORGg (ORCPT ); Sat, 15 Apr 2023 13:06:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbjDORGa (ORCPT ); Sat, 15 Apr 2023 13:06:30 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2052.outbound.protection.outlook.com [40.107.8.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7A324699; Sat, 15 Apr 2023 10:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tp0/HPH1EM0r0/jySbR6FeV5JMnCcZTbk0NTRKJY4pTd2IJ2YejGZrhVQzjAAaou4BhmfP2guA7HvBMXd9BQR1cAFyM55ogVhmCdMnxGSgDRSXeyak6Assntog52VvlB+tni34vVreEJMO9XpId5i5zwzyiz1aLKekAboQ4PQiKb+CiS3QkAVcx4nnNibznOQ7//tvtNdoe9onWNfk3Rm1ACpF00DWds+YXWoOQoCkPKY02JdPUjvPzmluGm0hOxb2Ay2Gr105mqM9W2EpLvfKMSBxl7iC+zo93UKR4LnWferNdvoHESjD0HUIkguvgbgP0NQ+LKj7jnc2tEWOSjkg== 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=qgCyOYQFmM9Np22IINUAmAgxSSN36eM9uT4IG84zlGQ=; b=AWeHpuqRs1hlIy+IHx9G8w+SqdWWIM5LC8jhBLOL2RZaC4S1tiWW+QxZJeUXRlnSRKAJKo+WYdFo/ygTnKXWqaZFWTBm1xymGKF9R9nWmbLBqHJugGPlPGxqOn9bOsAuziDAR2RsnOyRuVMm0Z4cylh9SnmIYSAwwzHQQmxDijPgq9q6AP9S4Dw2Q3nLXC4wkQTXaqZTxUgZjZ4kjxWYMkJ379GyLIbIbpVffEFSs4XOEbjH75sG1bsg8GOfsAq1MvUvEiCcf05qWjOThiIpl1iszNVqvroyn4tjgjfL0RIx8r+sIjIFOK14fvR8iSlayYJ5q+H1hekcVnHY7rNFSg== 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=qgCyOYQFmM9Np22IINUAmAgxSSN36eM9uT4IG84zlGQ=; b=ahJaEUS+vLPDynvkVTprg3uOxTrZXNAjMPM3t1RMBM+W3hNv87vm8YYrgkQ+RK7PdLmjnS75ni2Npj0bu1nxUUSVYVQZgQaKBoY1tXR+/dHkgST1CQI3frI4qHBn/c3Gg7bjLPfznbv8MEorzbPxRlBY7JjYyzbgJVOMr9QPRG8= 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 PAXPR04MB8158.eurprd04.prod.outlook.com (2603:10a6:102:1c3::6) 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:06:08 +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:06:08 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Xiaoliang Yang , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Subject: [PATCH net-next 5/7] net: mscc: ocelot: add support for mqprio offload Date: Sat, 15 Apr 2023 20:05:49 +0300 Message-Id: <20230415170551.3939607-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230415170551.3939607-1-vladimir.oltean@nxp.com> References: <20230415170551.3939607-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0100.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::6) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8158:EE_ X-MS-Office365-Filtering-Correlation-Id: 53eb5c32-c312-4484-574a-08db3dd3b496 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JocOFekizOhj6F79a4r1sZFncBc/uehgiMOM8Spv72Wq0QoKV41MvbxiUz1eE7ffUuE7pIbm20su/MzoGTuB7Ve8utkXofc+8iGU3saZW5FRqRRastyYKZgHZ6Ucagx6+O6JNR7akStY38md+nswXf4BbVjIYKKXI4V8x9/EBIhFJ2+KrPXhxRbvsYN+CPR9RQLStc4pj15rRz4O2ktkJ8k3hVdUm0cNi73/+E3vJcQrh7+Ybf/a2PMICS/VPhAAEShh/YY8M7/nFL9AfK6HLB4lo+04D029hyBSvY1aNDF7H17eQ+pfHD3rGy2CHH/o981r2M0yfiSOSdA00//9A7nJPYxsHxzUBuQzsoY/JUAzMUmIWlFpon3B36i8PxoHn9r9WpfScosU6KKOS/7sTyUZFF0B4F57S9ZWGPGEsL2+rgcbitqVFfJPC9KVe9FXYk0K5VI8deutDBhyFdLYoY+bGv6kfDyjlYw4EF27Tif8E/sBhCfedineFmqTgM5JSPgZeObUqVxKUUnZdRIDeH84mHD4Ck1FgbOEnhNRhGWuiky1AuB2R1WetHeoIa/yOXjhO6B1wktbB58nmAKGAxf8mXFpWN6besmOkapx7Ik= 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)(366004)(39860400002)(376002)(346002)(396003)(451199021)(316002)(4326008)(38100700002)(38350700002)(6916009)(66556008)(66946007)(66476007)(5660300002)(44832011)(2616005)(6666004)(52116002)(36756003)(86362001)(6486002)(966005)(41300700001)(54906003)(1076003)(186003)(6506007)(26005)(6512007)(2906002)(8676002)(7416002)(8936002)(83380400001)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e6q71KhNoVcsh2y2I0BZEXrs/cQ+7XGM5PpSdggBcrv141MQW/keksZzF1Mx1NrCHz5EgEnH/TyddpnjMErXxFHWR+DKaLenATX/XrCTlHaOShrmMdaNkvWa/iZCNB+4RoIvSvAxSeEIlImaQvpYpTEMWu9ZKhxsmJ+lUI7iE82Ec6crs9HSGq9OriD6ibth9gEF2/DHAXlRnGr+jEQ45gBuHJPwbp2aojK9aSQPC1v7z4GskEcqoVmUC7c/7EoI4J3i3Tvv8f0fWurzLm51af2Vd9U2rGHSHJqR6XWFy2y8UPJtKL5oFqJhkSxl5zyF4tXfZEZhp8UCdRD3lfH7t2RrH6D54mX6SON0jq+4JNzQtf0PvYm+Z9A8iXdz17iYPlN+D2ZCTkaS0nVhGENlxmrHJBtJtuEFsWV/7MzbLrlOjaL637svmuEgAd1sSG5r7YA02rWixM0Pm3gmMtM9101z00xqTqLoxarsAwJ8EU41TAbwqwonNd4jt9+pJ3cQNVybcUeDlmFFgDTmd3/UwVJHPCJZ8Ry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qfWm1qpyX65VJkQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53eb5c32-c312-4484-574a-08db3dd3b496 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:06:08.2549 (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: zCCg1w/q3l7foMaXNNCb0CROXMnUanr2YdfaJ642f7CPSRNG0IVtfQ+W3C9BbrhkKagJTjRHh8aYzTRO10hKsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8158 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This doesn't apply anything to hardware and in general doesn't do anything that the software variant doesn't do, except for checking that there isn't more than 1 TXQ per TC (TXQs for a DSA switch are a dubious concept anyway). The reason we add this is to be able to parse one more field added to struct tc_mqprio_qopt_offload, namely preemptible_tcs. Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes Reviewed-by: Simon Horman Reviewed-by: Florian Fainelli --- Diff vs https://lore.kernel.org/netdev/20230220122343.1156614-11-vladimir.oltean@nxp.com/: none. drivers/net/dsa/ocelot/felix_vsc9959.c | 9 +++++ drivers/net/ethernet/mscc/ocelot.c | 50 ++++++++++++++++++++++++++ include/soc/mscc/ocelot.h | 4 +++ 3 files changed, 63 insertions(+) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 478893c06f56..66ec2740e3cb 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1612,6 +1612,13 @@ static int vsc9959_qos_port_cbs_set(struct dsa_switch *ds, int port, static int vsc9959_qos_query_caps(struct tc_query_caps_base *base) { switch (base->type) { + case TC_SETUP_QDISC_MQPRIO: { + struct tc_mqprio_caps *caps = base->caps; + + caps->validate_queue_counts = true; + + return 0; + } case TC_SETUP_QDISC_TAPRIO: { struct tc_taprio_caps *caps = base->caps; @@ -1635,6 +1642,8 @@ static int vsc9959_port_setup_tc(struct dsa_switch *ds, int port, return vsc9959_qos_query_caps(type_data); case TC_SETUP_QDISC_TAPRIO: return vsc9959_qos_port_tas_set(ocelot, port, type_data); + case TC_SETUP_QDISC_MQPRIO: + return ocelot_port_mqprio(ocelot, port, type_data); case TC_SETUP_QDISC_CBS: return vsc9959_qos_port_cbs_set(ds, port, type_data); default: diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 1502bb2c8ea7..8dc5fb1bc61b 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include "ocelot.h" @@ -2699,6 +2700,55 @@ void ocelot_port_mirror_del(struct ocelot *ocelot, int from, bool ingress) } EXPORT_SYMBOL_GPL(ocelot_port_mirror_del); +static void ocelot_port_reset_mqprio(struct ocelot *ocelot, int port) +{ + struct net_device *dev = ocelot->ops->port_to_netdev(ocelot, port); + + netdev_reset_tc(dev); +} + +int ocelot_port_mqprio(struct ocelot *ocelot, int port, + struct tc_mqprio_qopt_offload *mqprio) +{ + struct net_device *dev = ocelot->ops->port_to_netdev(ocelot, port); + struct netlink_ext_ack *extack = mqprio->extack; + struct tc_mqprio_qopt *qopt = &mqprio->qopt; + int num_tc = qopt->num_tc; + int tc, err; + + if (!num_tc) { + ocelot_port_reset_mqprio(ocelot, port); + return 0; + } + + err = netdev_set_num_tc(dev, num_tc); + if (err) + return err; + + for (tc = 0; tc < num_tc; tc++) { + if (qopt->count[tc] != 1) { + NL_SET_ERR_MSG_MOD(extack, + "Only one TXQ per TC supported"); + return -EINVAL; + } + + err = netdev_set_tc_queue(dev, tc, 1, qopt->offset[tc]); + if (err) + goto err_reset_tc; + } + + err = netif_set_real_num_tx_queues(dev, num_tc); + if (err) + goto err_reset_tc; + + return 0; + +err_reset_tc: + ocelot_port_reset_mqprio(ocelot, port); + return err; +} +EXPORT_SYMBOL_GPL(ocelot_port_mqprio); + void ocelot_init_port(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index ee8d43dc5c06..9596c79e9223 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -11,6 +11,8 @@ #include #include +struct tc_mqprio_qopt_offload; + /* Port Group IDs (PGID) are masks of destination ports. * * For L2 forwarding, the switch performs 3 lookups in the PGID table for each @@ -1154,6 +1156,8 @@ int ocelot_port_set_mm(struct ocelot *ocelot, int port, struct netlink_ext_ack *extack); int ocelot_port_get_mm(struct ocelot *ocelot, int port, struct ethtool_mm_state *state); +int ocelot_port_mqprio(struct ocelot *ocelot, int port, + struct tc_mqprio_qopt_offload *mqprio); #if IS_ENABLED(CONFIG_BRIDGE_MRP) int ocelot_mrp_add(struct ocelot *ocelot, int port, From patchwork Sat Apr 15 17:05:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13212595 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 EA7C8C77B73 for ; Sat, 15 Apr 2023 17:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbjDORGi (ORCPT ); Sat, 15 Apr 2023 13:06:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229630AbjDORGa (ORCPT ); Sat, 15 Apr 2023 13:06:30 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2051.outbound.protection.outlook.com [40.107.105.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50CFF46BC; Sat, 15 Apr 2023 10:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KsihMWmnnZjwJ2Xpre8S/u3a5Cx1b3fhdA3Hawo+kY27fjk1q0dtVB1gGP6NhfqX3JrCWX+XEgg/88ixuCpy/CmK5X1qLS6aTika4rVuYOONRuw0WawgoKdjKp82qHzBNCvjrOYZWvqQ1x/gP+XFuPcdMRB6XpnaZ6gK6eIsEnLi4efAtDdbZJwDaLximnO5uq8TLLMKvQZIGmWcUS6NB7H8cnitXntzckVKqxwBJmz+Ka9gTArOo8ftJBRu0xOcSSSa+r22ELpARwLiCrZtEXg8yeCoze00Nv5KNJ2YCYxXp6a85+LLejICp6GBp6AfeZwBkiBpDqDnGDvnbIp05A== 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=1TIe18DGAVW1oSl4hweCgt6ZFYXuzJddgRPT2/nE8Fw=; b=dbErm1HhNOA4NszI1AQLXryiHeFd3KloomTuBoik9Wuv0RqaFXi1tl+Dm8fAbQzDCoABMiSJuanl5EdW8IqC7AIFN/KxlnBPEY21mJaSxW9uZ17X4PiYi81SbjkP5bgT5lgocpjsy1uU+Pz1ytXFn4HmNdutgUU2Of1/n/x0G1J8HWgbU194wdmvEEb6omCYc3g/sGDdqITlxbmFede7KboO/MfDoYYFBxqaddDVtwwGO7N1IopjUN04p+Sj8vq6fs2iXVG4G6nUm4XOxs23l7zRZ4RZzp+tQAaXt7FLogVGChXvO+1/yFpAJvEWk2BuO50Z1GfhNXVZ7anzWlmF8A== 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=1TIe18DGAVW1oSl4hweCgt6ZFYXuzJddgRPT2/nE8Fw=; b=eWStsXaAtKg1II1dFAMdDo4cG6NS2zqVpIfcjPdX2qhWFV2aGYUxYBFBQx2Z11ny6OsiomV1Ld35gAB1me0YO5jNA/pLTO2W4RTGFu1qLzjl6ED0H6SJazZBH27mHtNa6CEpxnbxHBYeBqNgiPvHdMamVxR2snA2bKov4LAhBq4= 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 PAXPR04MB8158.eurprd04.prod.outlook.com (2603:10a6:102:1c3::6) 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:06:09 +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:06:09 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Xiaoliang Yang , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Subject: [PATCH net-next 6/7] net: dsa: felix: act upon the mqprio qopt in taprio offload Date: Sat, 15 Apr 2023 20:05:50 +0300 Message-Id: <20230415170551.3939607-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230415170551.3939607-1-vladimir.oltean@nxp.com> References: <20230415170551.3939607-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0100.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::6) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8158:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e3ff0c3-f056-4d75-2556-08db3dd3b549 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MgblMzVNNuD4gfnltgwY5c4aoxQk8q6GPJ7TlmvkNoIh5+bDwgPtc93jimtcRBjczMSN44lGxpUtvIcJ9l5bftL/wLJt+kX8PWye26IWjduM0BUvxNma9w1HNnlGsnBS4O7tRko96DRMq2PGFH0aVkGMGcCoxKdclrTLmFKGqWb78kT6YBOsviX/8AboIJ4AnxKmOFWOGT4AObeQ5STfrKiOl8cz6Fd45Bzqctwp8cXn6mkoHYFtVCGf+HJ8T+kEctgY6NaSKROAyTzDdhKIEle80YGWrrowV1DqwIwQ9qx5ldZm6nS3Vq5SmMJrMZtTDAUGAtEUv/h2rWqSv+m83pD3aPFXhCR8aj6vVz5eu+lZzKkxtJT0/dCoWFLD5yjAh/f2usHUHv+xpc4eE4nm8UDTgzB2LXsEFSIrgwjGKOiR3e0sIhJB9hr7Pp6VZUiZmyqE+Pw2TLiYT3F0kXrns9/9ga16HVSUmx+qsA9LvxwESnJLJOSWjhSopekrSRrJjV2nCKCzQYeGew9TKM+6ZJfJq+D2amIapY1DGeOnwHAzXfi7CSYbyreQF2W5xX2eW5olzUGMES0zYs6i6MSK1OvwATqnSp9WWZtAuzqDGXs= 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)(366004)(39860400002)(376002)(346002)(396003)(451199021)(316002)(4326008)(38100700002)(38350700002)(6916009)(66556008)(66946007)(66476007)(5660300002)(44832011)(2616005)(6666004)(52116002)(36756003)(86362001)(6486002)(966005)(41300700001)(54906003)(1076003)(186003)(6506007)(26005)(6512007)(2906002)(8676002)(7416002)(8936002)(83380400001)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +md8sdp2tUPUO7YkkNsThEzn+14ar2fnd75L/xr/Kr6DhJO7H2xiENa4Sl9XRDUTXYKMkBYOr69nmQPgK96rI6tE6ix4y8V5AU9LtdzkFlRDS315aCjC9HLOenQE6EMHMTYOoGdpJPFJMCwWKRIoy/kPAa0Ic4Wi6FJCDMYu7fug5fiI0O7PMTBKB4T8TF5JE7vsoqvljbgIbPnMDwmtQUbjanzGznKmPpeOlZiFmaSNCYNxakom17FgVArDNZvSra4LSVtak+uK2Cf9EVxNfd+VwLW5UyuDXsIXvZsi7Ll+TGnuUy79pIPDxUMn44TtzaNyd+7NO7HigDljx/79Omg3jnWwvU4FC/TbUI07pWMC97z2hkOo0khXU9lQrRI13kpUHYlReV/aKswq4JhQy8U0h3DGZcbG75WeXaOhSk53Y9ikh9pDu5Jsl/VoGDQ2C0DUL6vwPyt+yjQ63DPCmcnblt9BXjS/OEAbf5DMmDhbug7LBNVfKsEp1OwXWxgoX5RqVO8uS7maFl2xVD2SboSE1CYOY/48GAI6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ginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e3ff0c3-f056-4d75-2556-08db3dd3b549 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:06:09.3976 (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: xNLQvlWDsleaUQPXw4N1RvAUGhWpIQAiQUoosJuiME4Pq4ChMjqnDVx3UmcZG0nQIUkVVY/7SGOflRhQIz2Ywg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8158 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The mqprio queue configuration can appear either through TC_SETUP_QDISC_MQPRIO or through TC_SETUP_QDISC_TAPRIO. Make sure both are treated in the same way. Code does nothing new for now (except for rejecting multiple TXQs per TC, which is a useless concept with DSA switches). Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes Reviewed-by: Simon Horman Reviewed-by: Florian Fainelli --- Diff vs https://lore.kernel.org/netdev/20230220122343.1156614-12-vladimir.oltean@nxp.com/: none drivers/net/dsa/ocelot/felix_vsc9959.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 66ec2740e3cb..e055b3980ccc 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1424,6 +1424,7 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, mutex_lock(&ocelot->tas_lock); if (!taprio->enable) { + ocelot_port_mqprio(ocelot, port, &taprio->mqprio); ocelot_rmw_rix(ocelot, 0, QSYS_TAG_CONFIG_ENABLE, QSYS_TAG_CONFIG, port); @@ -1436,15 +1437,19 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, return 0; } + ret = ocelot_port_mqprio(ocelot, port, &taprio->mqprio); + if (ret) + goto err_unlock; + if (taprio->cycle_time > NSEC_PER_SEC || taprio->cycle_time_extension >= NSEC_PER_SEC) { ret = -EINVAL; - goto err; + goto err_reset_tc; } if (taprio->num_entries > VSC9959_TAS_GCL_ENTRY_MAX) { ret = -ERANGE; - goto err; + goto err_reset_tc; } /* Enable guard band. The switch will schedule frames without taking @@ -1468,7 +1473,7 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, val = ocelot_read(ocelot, QSYS_PARAM_STATUS_REG_8); if (val & QSYS_PARAM_STATUS_REG_8_CONFIG_PENDING) { ret = -EBUSY; - goto err; + goto err_reset_tc; } ocelot_rmw_rix(ocelot, @@ -1503,12 +1508,19 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, !(val & QSYS_TAS_PARAM_CFG_CTRL_CONFIG_CHANGE), 10, 100000); if (ret) - goto err; + goto err_reset_tc; ocelot_port->taprio = taprio_offload_get(taprio); vsc9959_tas_guard_bands_update(ocelot, port); -err: + mutex_unlock(&ocelot->tas_lock); + + return 0; + +err_reset_tc: + taprio->mqprio.qopt.num_tc = 0; + ocelot_port_mqprio(ocelot, port, &taprio->mqprio); +err_unlock: mutex_unlock(&ocelot->tas_lock); return ret; From patchwork Sat Apr 15 17:05:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13212596 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 BE06FC77B70 for ; Sat, 15 Apr 2023 17:06:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230213AbjDORGl (ORCPT ); Sat, 15 Apr 2023 13:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbjDORGa (ORCPT ); Sat, 15 Apr 2023 13:06:30 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2052.outbound.protection.outlook.com [40.107.8.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0021F30FF; Sat, 15 Apr 2023 10:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XEOU9ahuddSxx8jCAGjAVMJBNAXtPrXKBC6isK3YxbEjfMS6iVEU7jZ/OY/pv5PrkhfzUUZhygELcBHJlfWUG1585Ajp45e0XwWcv/RK+4PUHEyX6izqJ3oCV1bYD+L3X50hboDeSdQeoBr14i2hj2F/qa6IQXTRceMcBDFJk0Wd5/FI6MmS6fK4+q2MhCm0YhVyL15WVqMgASaE96NeqRz3jyM9caVM2vailNkljKzyZ+UEUuOOONd+JtNtJ2EHSDflOUAhlk8ZMNAKcVu1LiOSUy1Fqdd8EkLNsH7kbr39Yxk6R8llwT/1Mj1Su/1hgjjU9b/jRmaw6AcI/gzT+Q== 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=MKKvJOlM4rnzpUvjC+Fbg4PE+j+tCBd+KEfJqGHZHFE=; b=SRk22bf9wK8HECI+rbDFa3rTmcZWFZ4a/PtJMf1KMrhIgtqhQaSq2yjUwSqNM4DeW6PJR4wCPUgTKrxtg/PgAEaPHvLRCz/NBTxbn+Al96kx8W1e3DXj/B92Hg9LfyN5hL000Sak+6HKPnEcn59kYbGisEebNDX2rJFqRu7G0uDOp24zLxLGzQANSIX4MvNtmnHhRNvIfWs38LFkp06CFjCogJfScsSCxHWvfRsXrAcDyliOUeqsqspOoR4z2Z3nGQDaLMstx+Me687EnTUt53vff1049kp4tQ4afqq+Eepf6gKfffAhNgrwqUU6trhYVJDckzlA3Fgsz3EYAT9SDg== 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=MKKvJOlM4rnzpUvjC+Fbg4PE+j+tCBd+KEfJqGHZHFE=; b=afcuN0V8rDRlZTiefXKHUOhwF1ZXfRHbRj5oyLY4sz1f4T8s2OYizkJY4rtVf/5eQxQk62hWyRCztW8LPKqmIqRJHJb5ZM3KlQCZP58cfuFq8Pn2xIEV1BsyS1J3rtRIXXK+0Lg5h4+VW2CLJai86ZIOG/YHhO2N5CVPrleSKzU= 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 PAXPR04MB8158.eurprd04.prod.outlook.com (2603:10a6:102:1c3::6) 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:06:10 +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:06:10 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Xiaoliang Yang , linux-kernel@vger.kernel.org, Simon Horman Subject: [PATCH net-next 7/7] net: mscc: ocelot: add support for preemptible traffic classes Date: Sat, 15 Apr 2023 20:05:51 +0300 Message-Id: <20230415170551.3939607-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230415170551.3939607-1-vladimir.oltean@nxp.com> References: <20230415170551.3939607-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0100.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a9::6) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8158:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e5367ed-2f33-4946-b9f3-08db3dd3b5e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: prWAJPNuX2LPBjoIVogSxxjAexwEa7fB3rXR6P9+9ufYf09LYDU6L/7msElNGi3LW+tCCoXMtSBSfVMX1A5HonYp6BYMPFfrvNH+rn4LWBfIetldIYXb1DPZC5EVZRuEdVs/oWvXSzYh1pWcyRtFk3wOde6bmbLD3ekSHjNT1/n0EMMSleRt4KiqQmhs2gW8gjfmycKQE6vmH5zTdaAwTHPmefYpQ3nBf91cwUwtyksxJY15pYnL/CNfLmEdQX4v6K7wFWz5if2TPOXQzjpZBRfEgouom4wa/tnGbV9W8cmX2GMYT4sEzHqFEawMnK9WkzxidMNuxGJrqxFjEi0TdCTuc+RxxAp7J+OjXibSELtHCHqHupisvRny72jtO4e3sFnUlMkvnq8W5Br5I5n3C8S+FS7P5O8NAzyH2tbl+dJFB26GdikR5RlXLbRTpGwlbmFycj1KVwq6L1FRjO+C0NBqTXLeDqgj8Y7uZ6eD7mY+LXnFluv3TbtGJMvDvuZcqh4VKXjioJcKTS9MGZNBPS1Ya2KDe+ONCQJ69rWJT6WDJgleEPPhnsDVYtEjhy3ixrwVq3nar/hAvqVlzCHtzkpjJ93fxPdmtpxR2vXEScQ= 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)(366004)(39860400002)(376002)(346002)(396003)(451199021)(316002)(4326008)(38100700002)(38350700002)(6916009)(66556008)(66946007)(66476007)(5660300002)(44832011)(2616005)(6666004)(52116002)(36756003)(86362001)(6486002)(966005)(41300700001)(54906003)(1076003)(186003)(6506007)(26005)(6512007)(2906002)(8676002)(7416002)(8936002)(83380400001)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eAiFeqHdHB0CUfSw0qwMExFRRfLeqjQb2ODhLIm5Xa8ROdRH0XVpRd7uE49+tDjChpreX85b6eoFwffHqwNB0tz5Fq3B3Y1B5JLMH3rYIOBU2EP0URiIH0CFkGTkd8ezlaoIy5c6u7Gk826/H2aCMnJPKn5f0M6CQpc2TTnfndrCH6wyBJZeWezpA5Lmb0jiYqbqE6t/qzxt0Mlym1M4sUnQHDQ4qton+/P4P9dfhB8UHHwCznZdsa5jClzgeRrbsdOB6S+EIOSdU4Ml8vZw7W7O64UKBXZOoFcoeyRXllj1Nn0AVZN5/gFEhVY2egNQi5nESJWem+mGuCTFL5WDGUELQepY7GWVHKCgi7Lud/gUTTG/sXGjNxOEwVp1ZhTidW2qsQyY4P8ccrz12czC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TimeK2h+sZSRiP5X1oWUxIy9CCgYh4F9pVM+ZZqgBTJqWSQ1Cf15oA6PVlvR+/LP0zOGlH6sNqWjvb3ZY8H8jCRixR2/DiS9qP+skrHn1wAR1QCYezA41Z25QrGB/W6OJiU2d3/QtJczw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e5367ed-2f33-4946-b9f3-08db3dd3b5e1 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:06:10.3578 (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: KhjfJH8F0cbKoyLJF1XGeaR/skwdxo8duJ1u1cEUx4RG58Pcpb743+NWTIte51gelfen9+d4LDiSUAkQYwyH8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8158 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In order to not transmit (preemptible) frames which will be received by the link partner as corrupted (because it doesn't support FP), the hardware requires the driver to program the QSYS_PREEMPTION_CFG_P_QUEUES register only after the MAC Merge layer becomes active (verification succeeds, or was disabled). There are some cases when FP is known (through experimentation) to be broken. Give priority to FP over cut-through switching, and disable FP for known broken link modes. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman --- Diff vs https://lore.kernel.org/netdev/20230220122343.1156614-13-vladimir.oltean@nxp.com/: - keep track of active_preemptible_tcs separately from preemptible_tcs - simplified locking, now using just ocelot->fwd_domain_lock - updating active preemptable TCs directly based on mm->tx_active rather than based on verification state - added some debugging prints drivers/net/dsa/ocelot/felix_vsc9959.c | 7 +++- drivers/net/ethernet/mscc/ocelot.c | 10 ++++- drivers/net/ethernet/mscc/ocelot.h | 3 ++ drivers/net/ethernet/mscc/ocelot_mm.c | 54 ++++++++++++++++++++++++++ include/soc/mscc/ocelot.h | 3 ++ 5 files changed, 74 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index e055b3980ccc..cfb3faeaa5bf 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -2519,6 +2519,7 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot) for (port = 0; port < ocelot->num_phys_ports; port++) { struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct ocelot_mm_state *mm = &ocelot->mm[port]; int min_speed = ocelot_port->speed; unsigned long mask = 0; u32 tmp, val = 0; @@ -2559,10 +2560,12 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot) /* Enable cut-through forwarding for all traffic classes that * don't have oversized dropping enabled, since this check is - * bypassed in cut-through mode. + * bypassed in cut-through mode. Also exclude preemptible + * traffic classes, since these would hang the port for some + * reason, if sent as cut-through. */ if (ocelot_port->speed == min_speed) { - val = GENMASK(7, 0); + val = GENMASK(7, 0) & ~mm->active_preemptible_tcs; for (tc = 0; tc < OCELOT_NUM_TC; tc++) if (vsc9959_port_qmaxsdu_get(ocelot, port, tc)) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 8dc5fb1bc61b..1f5f00b30441 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1006,7 +1006,12 @@ void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port, */ if (ocelot->ops->cut_through_fwd) { mutex_lock(&ocelot->fwd_domain_lock); - ocelot->ops->cut_through_fwd(ocelot); + /* Workaround for hardware bug - FP doesn't work + * at all link speeds for all PHY modes. The function + * below also calls ocelot->ops->cut_through_fwd(), + * so we don't need to do it twice. + */ + ocelot_port_update_active_preemptible_tcs(ocelot, port); mutex_unlock(&ocelot->fwd_domain_lock); } @@ -2705,6 +2710,7 @@ static void ocelot_port_reset_mqprio(struct ocelot *ocelot, int port) struct net_device *dev = ocelot->ops->port_to_netdev(ocelot, port); netdev_reset_tc(dev); + ocelot_port_change_fp(ocelot, port, 0); } int ocelot_port_mqprio(struct ocelot *ocelot, int port, @@ -2741,6 +2747,8 @@ int ocelot_port_mqprio(struct ocelot *ocelot, int port, if (err) goto err_reset_tc; + ocelot_port_change_fp(ocelot, port, mqprio->preemptible_tcs); + return 0; err_reset_tc: diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index d920ca930690..14440a3b04c3 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -119,6 +119,9 @@ int ocelot_stats_init(struct ocelot *ocelot); void ocelot_stats_deinit(struct ocelot *ocelot); int ocelot_mm_init(struct ocelot *ocelot); +void ocelot_port_change_fp(struct ocelot *ocelot, int port, + unsigned long preemptible_tcs); +void ocelot_port_update_active_preemptible_tcs(struct ocelot *ocelot, int port); extern struct notifier_block ocelot_netdevice_nb; extern struct notifier_block ocelot_switchdev_nb; diff --git a/drivers/net/ethernet/mscc/ocelot_mm.c b/drivers/net/ethernet/mscc/ocelot_mm.c index 3e458f72f645..fb3145118d68 100644 --- a/drivers/net/ethernet/mscc/ocelot_mm.c +++ b/drivers/net/ethernet/mscc/ocelot_mm.c @@ -49,6 +49,59 @@ static enum ethtool_mm_verify_status ocelot_mm_verify_status(u32 val) } } +void ocelot_port_update_active_preemptible_tcs(struct ocelot *ocelot, int port) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct ocelot_mm_state *mm = &ocelot->mm[port]; + u32 val = 0; + + lockdep_assert_held(&ocelot->fwd_domain_lock); + + /* Only commit preemptible TCs when MAC Merge is active. + * On NXP LS1028A, when using QSGMII, the port hangs if transmitting + * preemptible frames at any other link speed than gigabit, so avoid + * preemption at lower speeds in this PHY mode. + */ + if ((ocelot_port->phy_mode != PHY_INTERFACE_MODE_QSGMII || + ocelot_port->speed == SPEED_1000) && mm->tx_active) + val = mm->preemptible_tcs; + + /* Cut through switching doesn't work for preemptible priorities, + * so first make sure it is disabled. + */ + mm->active_preemptible_tcs = val; + ocelot->ops->cut_through_fwd(ocelot); + + dev_dbg(ocelot->dev, + "port %d %s/%s, MM TX %s, preemptible TCs 0x%x, active 0x%x\n", + port, phy_modes(ocelot_port->phy_mode), + phy_speed_to_str(ocelot_port->speed), + mm->tx_active ? "active" : "inactive", mm->preemptible_tcs, + mm->active_preemptible_tcs); + + ocelot_rmw_rix(ocelot, QSYS_PREEMPTION_CFG_P_QUEUES(val), + QSYS_PREEMPTION_CFG_P_QUEUES_M, + QSYS_PREEMPTION_CFG, port); +} + +void ocelot_port_change_fp(struct ocelot *ocelot, int port, + unsigned long preemptible_tcs) +{ + struct ocelot_mm_state *mm = &ocelot->mm[port]; + + mutex_lock(&ocelot->fwd_domain_lock); + + if (mm->preemptible_tcs == preemptible_tcs) + goto out_unlock; + + mm->preemptible_tcs = preemptible_tcs; + + ocelot_port_update_active_preemptible_tcs(ocelot, port); + +out_unlock: + mutex_unlock(&ocelot->fwd_domain_lock); +} + static void ocelot_mm_update_port_status(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; @@ -74,6 +127,7 @@ static void ocelot_mm_update_port_status(struct ocelot *ocelot, int port) dev_dbg(ocelot->dev, "Port %d TX preemption %s\n", port, mm->tx_active ? "active" : "inactive"); + ocelot_port_update_active_preemptible_tcs(ocelot, port); ack |= DEV_MM_STAT_MM_STATUS_PRMPT_ACTIVE_STICKY; } diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 9596c79e9223..cb8fbb241879 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -749,6 +749,8 @@ struct ocelot_mm_state { enum ethtool_mm_verify_status verify_status; bool tx_enabled; bool tx_active; + u8 preemptible_tcs; + u8 active_preemptible_tcs; }; struct ocelot_port; @@ -1158,6 +1160,7 @@ int ocelot_port_get_mm(struct ocelot *ocelot, int port, struct ethtool_mm_state *state); int ocelot_port_mqprio(struct ocelot *ocelot, int port, struct tc_mqprio_qopt_offload *mqprio); +void ocelot_port_update_preemptible_tcs(struct ocelot *ocelot, int port); #if IS_ENABLED(CONFIG_BRIDGE_MRP) int ocelot_mrp_add(struct ocelot *ocelot, int port,