From patchwork Sun Feb 19 13:53:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp867692wrn; Sun, 19 Feb 2023 06:20:34 -0800 (PST) X-Google-Smtp-Source: AK7set8X4pw+DE8Kj6qGVp79tzmpWiwJPoXn6CiX9p+a25bo0jnLi+Zn5w2qQ1p+Z5vfpif02bRm X-Received: by 2002:a05:6a20:b290:b0:bc:d05e:c667 with SMTP id ei16-20020a056a20b29000b000bcd05ec667mr6862426pzb.29.1676816433838; Sun, 19 Feb 2023 06:20:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676816433; cv=pass; d=google.com; s=arc-20160816; b=iEgEd5Q2t/NkejI+aXMMiFzVF8YPpkjG+goJOIYbP0rbUGz83IMvrGmpfVSzSusjH7 zv6jkLNohUC5XstHVkzL98hWRRHnQBgzAVuj/B1U++hqC/qs75P8NwXlFyegjJjP2H2s MZ8JFtUb+3TLoy8p1ORzBXRuP3KA41+RjaDzZVBkM67yIMA+8Tijl/zEsyvk4BEwAcBp t6C53KpwaFlSw2RHg6goyJLR5kDAMgN8DYRZZCHSd/coJkTuPJ3D0DS/WD/xSJkReRxx 8o+wdEmzdM6wiGbYqnIH03TzRGldZDuwZmEKToGs7eedUSJqnDKOO26HsUZJEOniD7Lg V6VQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=knxDSXXbyoJv/0vvC/G3NE1Qp+zteBCa6Ip6NcPFFV4=; b=h+L8YzROwKM9OI6SPzDErm58VMka/IXCFFQEnbNIexQUhn47EfTqdiULHMEMRTLQdJ e1OeDrPqD8qExrzmUi1CaC8M5Yut1OX1BCI5EhhGf9noC+jfokwXJeNfqE5fBqs2NtJ1 dUZ4kdL74QuFrk+NqKxPj/WzWyhudiH3CQKCIUeXKNetmFdn6eVuUw9356BubXZ/nfBH nuW4plkZDi//EbYdunhaHUSGfqSVWU6F1Y2r+B0VrdRtmidbsXNEeZASZFe5oPvjFPbv 90HNev0IcYDPHlCG2hajMEe+B3URvknUokKajK09g7COaXURAj+MyqZU2mNGYGkxUOGd 83+g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=CLxkB7wP; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i13-20020a63584d000000b004fbba63b116si10127632pgm.548.2023.02.19.06.20.20; Sun, 19 Feb 2023 06:20:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=CLxkB7wP; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230038AbjBSNzv (ORCPT + 99 others); Sun, 19 Feb 2023 08:55:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230062AbjBSNzj (ORCPT ); Sun, 19 Feb 2023 08:55:39 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2084.outbound.protection.outlook.com [40.107.14.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B16EE1166D; Sun, 19 Feb 2023 05:55:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gBm2wW3xx1ID90E3XAlggZIJRSy/U6F+Ooo7gbmTlkslWkujEfN9FRQKYYqd3lvKc3f0VoCWwLttKgXTyHaviRYorE6kGzkhrq8spzJEtTiGM79lxXDs6R4tPacVx2/PvdbqJEmD3S8hMjcDKCcUcB0tkz8wiCtu9g+yPUuuJpbw+cW2Edrc+YUlxZy3aDHViWUcBGgESeNyN0nlyqqnPi+h1z3nXubt6XxOEPHx+vwkqCL4WRIUeV8HZTXd1u0m3iQMwPMV48rYUDdEd6kan+m8Mx1+FiXVP/4rkjA63gOv4lccemCu0V/GqVv5zErzHFzbhv6mj2L3QS7fTbMlHA== 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=knxDSXXbyoJv/0vvC/G3NE1Qp+zteBCa6Ip6NcPFFV4=; b=UIxXQ2R8uyZsz6xRzZADNHZO8U/hLZ3rQvWVDe0++uZBnoUAyW2uztLIJHnYxlZoDZvRF8hcMo8+Mrmu4CiXNn+8XOtXarCep9K5CLblxIzhSAf2HPKp+Vog47m03TKFD5KGY53OS0fS4mGcI98m6ShXvzuMmGZaPZmK2d8rgkmmAhlyIPeAUJQCJAWpm5UbcWgF0cP8pnTM+SVBfFlWJ35ay3k/cmf8TQCbLsMXpRW/IyM5pItLzsnpO2cv5qXcoxcJ7qCKQbrF1SZqc4D6/iGkMqAYkeEr6sYKeqw/D3KScgqeXTNwTDYXJeGVJywixjSrzW7Gu1O1YxjIqgvLSA== 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=knxDSXXbyoJv/0vvC/G3NE1Qp+zteBCa6Ip6NcPFFV4=; b=CLxkB7wP3phZEw9UM9X9dZzJ5gUtv2ZfYj8GFGR8KrtG0+MD0kTIjtFQ1o7Dr0zpqYoUgPr2coTdLs/CkgNT48HMirkg8bTBdfw9Bk7iNlPa7GxOC6Knhcak2zwsnGuHVMjzeV1wGV1T7vjxxRHlkld7n+oNsjI/zCluOXm7Xb4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PAXPR04MB8238.eurprd04.prod.outlook.com (2603:10a6:102:1bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.17; Sun, 19 Feb 2023 13:54:01 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.018; Sun, 19 Feb 2023 13:54:01 +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 , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , linux-kernel@vger.kernel.org, Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Wong Vee Khee , Michael Sit Wei Hong , Jacob Keller Subject: [PATCH v2 net-next 12/12] net: enetc: add support for preemptible traffic classes Date: Sun, 19 Feb 2023 15:53:08 +0200 Message-Id: <20230219135309.594188-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230219135309.594188-1-vladimir.oltean@nxp.com> References: <20230219135309.594188-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0136.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::6) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8238:EE_ X-MS-Office365-Filtering-Correlation-Id: 3bdeaec7-ecf3-4bde-f55e-08db1280c133 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MPOjGp52WVf/DGonI2X/5thaJUOAfRqslqL5c+qcCqYpPLsfwiNG6jcDcJsLKS1P3Xaa/w9YWX/01bnME6+YelaGUWCAomjTauUi+hwrEGjjWTuGqJuGL547jTMyORZy7Npc0yjrsy8wP0HWEa8FSzEEc+yHwSDvJEXml3WVy7AQbaRWDnyW9MZt/FYtO7e7dCSIIoDLv/kQkpBrCNG/VXSjRc+fKV8vfUwk3bwNcVC59hXAeZXlOsfwISFz468ijNulabSGkMmTZtYw3FxpOiniKFA/b2Lwx3A7b0obglU3CYY37Kf7mKXMfn7UiSGWvrbKUSk+RX+oVa5tSEPwQTfk6U2kLyhykUYgmHwDkz//jlBnoxb+1BKpDUmsTOlMT+ip7e9M2NDU4kSalf4YdTAkcDHKg1vF7MfK1olwfITRb8VGTz02oLwqCkOu9TsEOA8VXukfxCcNtdLD9zjXC0vp1mJJQ++oAMVumc3TEYZFBZBOPx9+20Wdvhl2Uo/Og2YOYHS+qNy/lh+XszmR5ufQSOxrFJIj3d+W1lvcpH4MVGgjA/ZMQ6FWs2SQEjZuWk17gOyzjfDFgovjNF/a4CZnrPqKYSxHz2pjYmnjp9N9OpOuzrIAqV5gUXR8rdzOgD85kAo0zQxBmbIe2dG88B3pbeP72awv7q6xQo7CcXED2177xyYFpeA18AxbgwR1od++R6MPpCu1AsLA36PT7w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(396003)(346002)(136003)(39860400002)(366004)(376002)(451199018)(8676002)(66556008)(66946007)(66476007)(5660300002)(7416002)(4326008)(8936002)(41300700001)(6916009)(44832011)(86362001)(38100700002)(38350700002)(6512007)(6506007)(186003)(26005)(2616005)(83380400001)(52116002)(6486002)(478600001)(1076003)(36756003)(316002)(54906003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aACVf/2hmLj/M/8n2HsK5z2xn0puVLrAkuYclXIwTKl32vAEGTffOtoh8jbfIJEPDfbu7xYJzh8hR67cJCsRy4a3wU9skfDmHDoTfgzc0vkY395GDJyWRj3xNHLI1lxy18h8Qi0o9FcIptpbrTmnkltCSw04ruJg6crP4OJeVKsxPq6xDQo8MT0RnEKc4x1DO4yAl/EyAgxZPVjsbmltmUjj9rdjGpYtb32qoc14HVXtl6VmJyLmC4iYCbpNBgJwrKLQwek7oYzzHUzxHQ9IGUdz81OQ/eowv/pzkwzoojrmsagV3mLAGQoHDKRdloeggIjx4/6SyvGAihH9pl+a5giIiHA1Rz9uQg7p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N14wi0vn/Wgi7jkO1ygESts3nOJnpo+4vU4mNjEGYD4OlBkl3YIzG6l6sYCcNTp3RiYX7YoqgFZhnROImNZ5CEQ0Aie7LJ9AOSCN8Cbq9Xa2KvAUUyzJKnbtmw+sJedD1Sc0FL+n6bFPTSG8UZ51YQh0SyUqMLL0cqkgWFJqs5mxsQTYvRnSYCNYsvw0wT7eMEzQiA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3bdeaec7-ecf3-4bde-f55e-08db1280c133 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2023 13:54:01.2547 (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: YARr60V9KyXNVRFZjsLzsYPNNrXdp4SP+wy6P2EUcmItrV+6sVrCf4fvXXZKID1KZxyWUk6w2KDD34s/2VT44g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8238 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758269468999913290?= X-GMAIL-MSGID: =?utf-8?q?1758269468999913290?= 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 --- v1->v2: 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)