From patchwork Tue Apr 11 18:01:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13208006 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 DD441C76196 for ; Tue, 11 Apr 2023 18:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230305AbjDKSDn (ORCPT ); Tue, 11 Apr 2023 14:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230142AbjDKSD1 (ORCPT ); Tue, 11 Apr 2023 14:03:27 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC8036EA7; Tue, 11 Apr 2023 11:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dK77XLcMC827j4A/P6VufF6T0veZTdtxZBC9JBvFa/ydzK05gPMdB4HRXlYMfsWnDJVL4q9ckXI19zURZgFZrgYwsL/I7bqBCkwwSg2jGuyfT75xjSx188dY/le5PjdC2h2H7guJtsBiI9PQqTMS4Zuhu3AaSL7sS+mUYWT4btjp3m4NBfKLIG7OM/y5yjomG/DbR5f9O/xTUJ8QBw1lptTVioIPp8SmKsqN57jtaRIqMwkAmrIwbtYxEcKz7LNGHVcwckpKJyxr64SiBkvgp8qOEzzPq8MkraNTb3STK4qja9eIpTKSlxwieZfpfeAF2KE45mLfJu9hQiQtjWZFwA== 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=0N/dWuSF87eveOxh8QCSo2VOz8UBVReAh/8tIVl5dnA=; b=EAoGlhY1oeuVcCVJpblvaOvH3OnACHysf3nPgLMYj/dIzO3E/yIuaeX67ZuPUBnfKzXMHzz6O7/bLtufgiH9vml74BmBP/t5mAIOwpU9yR09P0bSyH44l2H2yUuAZSFQQeN23+NbommghLqLLipalvwq0eHlwLnoa8JDr5XUUJ5S75JQhfRgZxY0XHwa0l3XJZTGfqhZ3GMMLQuMUWxIMWMo6suerZiTWPuelqbly0/GcTyxXDJgf6WmhginPiaoV3Svlbp4ESyIfqSr5dNAqI0tM6/sXkMPl0eHUE9FTylQ6jtMxEBaH+APhrLkJQbYLCt2u9wKwQvYtKHyExC37w== 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=0N/dWuSF87eveOxh8QCSo2VOz8UBVReAh/8tIVl5dnA=; b=T7PfuwMzsyymwH8cou3Fvo39j7LnTuEvJolMFiDXYAtQlo/2UhRHm4nxKY3p+TdzeKmku3nDWR4sa6aUmaoHuzPNSUTc5rRc0FsgDBjcjZHcxAgtqyNOvdSSl/lkkxTBkLgpDjRQx1Jb1W3Ujaz9Rd2hkDOxnkwoXDxOF33Z8Cg= 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 AS8PR04MB7829.eurprd04.prod.outlook.com (2603:10a6:20b:2a7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 18:02:35 +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; Tue, 11 Apr 2023 18:02:35 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Subject: [PATCH v5 net-next 9/9] net: enetc: add support for preemptible traffic classes Date: Tue, 11 Apr 2023 21:01:57 +0300 Message-Id: <20230411180157.1850527-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411180157.1850527-1-vladimir.oltean@nxp.com> References: <20230411180157.1850527-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0186.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::20) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: cddf9702-73e1-44c4-48c4-08db3ab6edbc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /LhkmNdJazOHt2QThu1MEHDmFXmuU0ndVS3xdcLbsMm0XcWD31C8ELHHZgGOaep2ncw/rOoV5sAcZIMsaVrXObcg2sh6LWAxD4Tt4foo+sZhR1oDTNcv0YsiX1iKpaC1TmV0P8FhTbhAoHb/5t6CtjkhTD34QvRUW0Q3tvrcF7GxjeuEmQRjYTW2/AMir8k1gXISLjKGpbqSCfTeILY3UZ7gNL/pXtoAkX7hymQEuYc8XsOx0iknj0Tcv+bMIBLfuQ6RP33qrd6HUfVPsy3B54cLlcyUXCOXAoBCDlRCqyE3GPW51h1wGjvJd4iwfFLbkaeOnVgsCQAZCM4SeQQXZEeQc1CTMo9fbre/79grb7n3Zg/pD9dvcEvr2H7oOyRGNU/8mKHnD0zEcGOXMnNDi0WRLgcCodWUZPBLWzCnOozEBNf4q+YNPyEq1eJ9XTbHs89PuKb+Ur4Qpp1wwq51LDt8OR7Y2Jg9KCDMuFORC+XGp6cW+TeuWZ3Roztkg+Bv0GpjBSX8JMDrdplWJJdEEw4PSXgNOLUeJQ6gU3oPB81ISL0qEh4ntXluIJC5ZoVoH9ajJrxzokizPPMBegfhAA5lwbJegIEqgGGpHr8AD0sk+GvivADHf/fr4c7ZMcA4 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)(396003)(366004)(136003)(346002)(39860400002)(376002)(451199021)(41300700001)(478600001)(86362001)(316002)(54906003)(8676002)(52116002)(6916009)(66946007)(66556008)(4326008)(66476007)(8936002)(6486002)(5660300002)(7416002)(44832011)(2616005)(186003)(36756003)(38100700002)(38350700002)(26005)(6506007)(6512007)(1076003)(83380400001)(2906002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /zU8r+Qsbnt58hT3jTD5g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NCP9fjKgt1WdQmSUtPSY+KbFJSSTqx8fDMWZ5HOCezyDlqxeqhiMu2V462im0NNjQp8bi157qJ4XVsiAMuyjsT+mBOSfIhmZ9wx9In6psY3KYIAqIgUQi29kWuz0Y9OCNZSeWLbHoZyVDkesGQ0TfRjeiJ6uvRyIoiHFORLLJHOkK5E7p4Hm/eYeJkCCcyVuSAZPAT6FdBhF1c2TsTiaSy02/hOp7kecjV68Y1hbBdvKshSaW2fwjK31NONFyZN06HFKZuY/xd9Xm/pS9QyaTkWAr04vvf06wWRQp4zFhgndu97bcerX39drigLVsUFa5AwPdk2IsaL6OGzsx9ozQIchaUAap0D6t4ty35BDW5EGCubeiGfF5NaxSBS+nYgbovtN6VKXf2/dXZ8ca1505QnVGQGDskCcWbeuSmqejiOHcZ6fo25UPjstPEnDdrjS8hpvCAR2m1eKHsnmNJtUeXc35R3r3AjFMGTI8fazHycfdvaHS5JwbtvpA7u/Fw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cddf9702-73e1-44c4-48c4-08db3ab6edbc X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 18:02:35.1965 (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: MpPvov5XJLAGuyMyG83X3pkQCA46zCtMHCJnbUMDcktVEWpLSV4uugSZDfqSRdruJhZzfyDhjuVjQYLRaXWwZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7829 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org PFs which support the MAC Merge layer also have a set of 8 registers called "Port traffic class N frame preemption register (PTC0FPR - PTC7FPR)". Through these, a traffic class (group of TX rings of same dequeue priority) can be mapped to the eMAC or to the pMAC. There's nothing particularly spectacular here. We should probably only commit the preemptible TCs to hardware once the MAC Merge layer became active, but unlike Felix, we don't have an IRQ that notifies us of that. We'd have to sleep for up to verifyTime (127 ms) to wait for a resolution coming from the verification state machine; not only from the ndo_setup_tc() code path, but also from enetc_mm_link_state_update(). Since it's relatively complicated and has a relatively small benefit, I'm not doing it. Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes Reviewed-by: Simon Horman --- v1->v5: none drivers/net/ethernet/freescale/enetc/enetc.c | 22 +++++++++++++++++++ drivers/net/ethernet/freescale/enetc/enetc.h | 1 + .../net/ethernet/freescale/enetc/enetc_hw.h | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index e0207b01ddd6..41c194c1672d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -25,6 +25,24 @@ void enetc_port_mac_wr(struct enetc_si *si, u32 reg, u32 val) } EXPORT_SYMBOL_GPL(enetc_port_mac_wr); +void enetc_set_ptcfpr(struct enetc_hw *hw, unsigned long preemptible_tcs) +{ + u32 val; + int tc; + + for (tc = 0; tc < 8; tc++) { + val = enetc_port_rd(hw, ENETC_PTCFPR(tc)); + + if (preemptible_tcs & BIT(tc)) + val |= ENETC_PTCFPR_FPE; + else + val &= ~ENETC_PTCFPR_FPE; + + enetc_port_wr(hw, ENETC_PTCFPR(tc), val); + } +} +EXPORT_SYMBOL_GPL(enetc_set_ptcfpr); + static int enetc_num_stack_tx_queues(struct enetc_ndev_priv *priv) { int num_tx_rings = priv->num_tx_rings; @@ -2640,6 +2658,8 @@ static void enetc_reset_tc_mqprio(struct net_device *ndev) } enetc_debug_tx_ring_prios(priv); + + enetc_set_ptcfpr(hw, 0); } int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) @@ -2694,6 +2714,8 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) enetc_debug_tx_ring_prios(priv); + enetc_set_ptcfpr(hw, mqprio->preemptible_tcs); + return 0; err_reset_tc: diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 8010f31cd10d..143078a9ef16 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -486,6 +486,7 @@ static inline void enetc_cbd_free_data_mem(struct enetc_si *si, int size, void enetc_reset_ptcmsdur(struct enetc_hw *hw); void enetc_set_ptcmsdur(struct enetc_hw *hw, u32 *queue_max_sdu); +void enetc_set_ptcfpr(struct enetc_hw *hw, unsigned long preemptible_tcs); #ifdef CONFIG_FSL_ENETC_QOS int enetc_qos_query_caps(struct net_device *ndev, void *type_data); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index de2e0ee8cdcb..36bb2d6d5658 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -965,6 +965,10 @@ static inline u32 enetc_usecs_to_cycles(u32 usecs) return (u32)div_u64(usecs * ENETC_CLK, 1000000ULL); } +/* Port traffic class frame preemption register */ +#define ENETC_PTCFPR(n) (0x1910 + (n) * 4) /* n = [0 ..7] */ +#define ENETC_PTCFPR_FPE BIT(31) + /* port time gating control register */ #define ENETC_PTGCR 0x11a00 #define ENETC_PTGCR_TGE BIT(31)