From patchwork Mon Feb 20 12:23:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59417 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1283546wrn; Mon, 20 Feb 2023 04:40:20 -0800 (PST) X-Google-Smtp-Source: AK7set+Yf9wg484ShrlTsQ0nE0oF6mmaA2OqOSdeJFT9IvhHYOMY5rqFJDMvmPbf5s9zUJu6R6TE X-Received: by 2002:a17:903:187:b0:196:5d8d:2d6f with SMTP id z7-20020a170903018700b001965d8d2d6fmr3544386plg.13.1676896820636; Mon, 20 Feb 2023 04:40:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676896820; cv=pass; d=google.com; s=arc-20160816; b=lBIUSGSpgdHooZdbDd5jWvmibS0+UzP3lrik3+wxnHRQ4Un7RObdlI9X5M5Dv2XB6B iYsx2cLjdbigq9PDdWxsOQX63ui/PtnClVIL/TtPcCq5Poh8VtNxFQNJT4qnkWhyjRFD dIUm+RBOOvTdffRCPl5fxGzwoTro6w6yd1oJYDnNhehfC30qFWCgc5OFNyU9OZHMh2z2 smiDYhWiHSzkyknsWBFHOUC8NLHRWV4ZjlPkQt8KtZ0f8zvd09SnwLYvkbH6BrDvWkm+ XOttOthbKNgOgeRtSXdy3E6bk3+F5ckKQHokbhh3uuBxjVaHFJeAbEs2A4WQAGQbGhyY sQ6w== 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=+LAxh0ndzKgSmev7VvnyhN4M8QLpSBeUVLWwrsOu23I=; b=Sl9Z9aL8ZtTp47AQXyLXYCdYoKsCO7rm1y0wG77SHF9itDk8eszIPLOywm1TVkpcyh dzvS1oxAwMGBpLLfzNzKM+U7fFDBYNvrsFVqS2BbTrdM+ofdEltPWbzPOwyma58gO1mC dACh6+tWbILIk0BYkWCk8MQst1Gz2VmuTT5ublZwuZQ6nisd/5YarodxfqHgB2thb+Hw Ub1t2wNXPgHVtuPKzRkplzjTjdrXbuan1sXUfe0J5945GWMSo8sRzKJNwQj7vJQgr4Ef pzmI6CEQH9nmaj5tVlJz/1Agr5k9uWdOFvAeaA+FatH3UIPe01tPqvhgHXX822oENwNA ARqA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=k2dPio+f; 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 q16-20020a170902dad000b001991d6f3cadsi3912352plx.206.2023.02.20.04.40.07; Mon, 20 Feb 2023 04:40:20 -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=k2dPio+f; 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 S231925AbjBTM3R (ORCPT + 99 others); Mon, 20 Feb 2023 07:29:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231820AbjBTM3P (ORCPT ); Mon, 20 Feb 2023 07:29:15 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on062d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C26C91C5AA; Mon, 20 Feb 2023 04:28:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iLceoOUCpdBOPdPXO6M/eZ0Tv/8enoosumyaNKu0PbkmcaSmedpfE3OABaZ3BhWOZ3gpu7SOQNaHEuADXPsiqnabx9R64GsmG2UA1H4Iu9sI12xsTioY08D51+Ydxi18cR3DfzShVYP550i9sA+19916SKLy4QR4pZ+brdy7Y4Vq/M0jRonSATyxozPMcPO2JIsVKa2w67nl8wvMEsXhg6nygbtVzYt4Tagkev+jw09gL0CVfnsphlCkICsfT3KP+xUViM7AXViJcKkK7SWs6ok9HjqzoTVlqbVPcsaAUOoK9S+j+KB15xcVQ6Jea3/j8yXg58Ag1fH26Pv9d0khnQ== 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=+LAxh0ndzKgSmev7VvnyhN4M8QLpSBeUVLWwrsOu23I=; b=bk7iGEVMGEiV1MBTMAblX/eM4O8R5YFdfuizOlk/aIb05VoB8b8YcGO0ckS+5GfTtfTxvnG4r8UgiiiPYRwkNKzBKjmux5OQPe2dkN2KSsoSXW5V6i4c93AiPka5vVRYpNFxarEe7xezCCyUn4MjX4JnL8m+SUfqoqhDG0DMCXaCyueo+E4PqGzuXrf0WQ/7J2h+xED8Bi9DjLkgsmzYV/XOJMTt4OxnZrHXG1OKXQkUtpTpzfSfcuBBeMylkrmDE9gLRvRBAa7lLHU/w3wPX3+wr3/uPm7NtateU1N8wfET4YROcvyVUIDF3WC4H5t2jbZ4eSZR79LbiYpjA1u0DA== 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=+LAxh0ndzKgSmev7VvnyhN4M8QLpSBeUVLWwrsOu23I=; b=k2dPio+fBlVt0nBS+361grm5XASV3CP2MuFK6icX3LdPEYpl3EdZrikXKmmv9YeOIHFfg3v3uaiqXwWMNIZR4KgeaN0qffVcpmwBMQ5uQSeyZ/o2hCBCwyNiaujEUF9OR3eRX5slLBuJIxBmV9vRj/avlv7rj5U6qmDPUE08UmM= 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 PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:27 +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.019; Mon, 20 Feb 2023 12:24:27 +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 , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 13/13] net: enetc: add support for preemptible traffic classes Date: Mon, 20 Feb 2023 14:23:43 +0200 Message-Id: <20230220122343.1156614-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 860b3c1e-4069-41ce-f1e3-08db133d686a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jM40lqdUZzbpwjqKvGJd6km3stxo0O36/TgC02oEbt5hyRFK+sV/vPKaoI4zghCsHBwR7ApUD76/HrzbEoRpCzlLgcblzuVpNa6Hl5KAxqm+/D1XKCZOrFE9rReGCXAX/MPABrK/fPP2AU6IgzwYk8yGE3E++raLWrPDTZ1eDw7G1QJhe1uVQaDS0EIhZdArHKVGPB/saCd1aWdmktH3jTeHeSUCet5imA6XxVOjM3XoqS1PUkhqRjYQA1Z69xOnPlaKIcN+RciCBt83UdY7+9CMMK4hyVYi8sHf/0eqJTeeidCcxkwaztKTnuN4ITYgD7Ctl784TDiCEWBrC/Dqk7Yj5cbOTS8D3hrWZBSHzqaMOXU9Bzs7KddPY4ZwLspZtKVhpANsVH+wkWTENF4YXkYNkd+Wr9CKdRUuKqiNiqW556G2rH6aAQThCDIMDgyqdDb2d0S55g876bQ0zNNHFE0RZ3eZzlch14rRVLUbHsU57vbQfZOEMdpRjK2drXfYYR+f1BiyEXrtOAyQ06pKxFeublLzxPj6a7rMPDASDovTz5mupRZ+wM90Ifpbl98USilhubdytSUC8WnPkdgO6XoIt7dP4D1MD2PVZX2ulqQWgZ19AunlYORPpM+MYMPZlVQwRc16mibbIe3XFZ5Zni7EIIepJbzHWWYsGdCrKjW6s0OK27Es7k9ntIrWlBILoHUDYe9P7HijIt6uYKGRrQ== 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)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BBfB9GcWa1SmDP3Fd9ldT+TJfSArfQLJh+Rq1J9MVz6snzzsm8owDDMRqFMH9emU9xj9QKC0bKmXo+EPrd7NUaKGb5dk52hlWlOo7Rt1ebkK3vRahZnG/f+ZNTsRXOSY0yXebKNwNAdLi/7imedtwJYKHBanzwlIstX8n8UkOhnSaJpa7vZ1GvdlCuMipluvGVmkJXaDD+F7wH6WHej/naODXuSbjpaOicxa+F0J1BuRmO/GPfQqWt1badNoXadtIE0Ya5lDYgwLtt1vXzgphqqmMqsVeowfFKL2jgdybZTyaN4aesxTcTQxVRmq3EpeJ1GUAhLYqcBn0jUvUPmrE0EXsQw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QCFba5sEPgsvMYNTwCW/S7JS/r0/tKjB8/Wiwav3TWNvgLHGVGrUBph8OzAEp91JLzAV4Z075bGU5PSFiQWB5krWFE1D3BHQsyXrYmZP9rHcLKnQkKL9h2U5owMLeAVZmw9qVHFsda4wWg6oKLAQ5VBE0iAQJ2/fBg7FJXgF/aOaEYg+UZbMqtbhEFtEG/XvVsknJeaA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 860b3c1e-4069-41ce-f1e3-08db133d686a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:27.0860 (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: 65xC9put//WGBywqFocEX1nVy/uAu0SWVUkgMqju41d2Hk/sm70Jc60K7sUbPp9J9vr8Ffsi1F33D3kOR/PZIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,SPF_HELO_PASS, T_SPF_PERMERROR autolearn=no 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?1758353760391284888?= X-GMAIL-MSGID: =?utf-8?q?1758353760391284888?= 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 --- v1->v3: 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)