From patchwork Tue Aug 8 02:19:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Furong Xu <0x1207@gmail.com> X-Patchwork-Id: 132501 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1853097vqr; Mon, 7 Aug 2023 20:25:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElQynqM07jrYwkQOE4qhjFlrHj/odYLol4rBZmh91ufzVk9VEiBjGrzZqKjqs2wYgfJbgS X-Received: by 2002:a05:6402:294:b0:523:3e7e:451b with SMTP id l20-20020a056402029400b005233e7e451bmr2318229edv.37.1691465138577; Mon, 07 Aug 2023 20:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691465138; cv=none; d=google.com; s=arc-20160816; b=zi0orXeiUkW9ymt2AzbeWra9/9UO69Ff+3wZbWJZLzmDle6mEbh0FIefXQjhcXFq/w VZgIK6MOqZjgAwEPqjMlHI61F3Z89ooAqfOU1Ojl1gPEGV07w+CsIE71gqe+RZbhKM3K 6OSilHsjgMP7gg2yN611NZsUW9o6tIofa8U3cUNL8SxSsxiFC0ez7MQmjenzuUNmvw1i N6GkWuV0Hm0muvewVWLlu8kd25roCq3YE5dPlyjHwv1N2eBlWMDmGSiBiHwAKFqTQPo3 66wU7rSBZ2o2hLgT2AMwP/TmoEZpQOzlMa2WKlA9ty673OGPubIINF7YW0VbPblAdh5b I6MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=w2SLqdPoc24r3SU7DATTJAeepTTgjgASEEH+wJbfp+8=; fh=fzDUatE4vWSZQzpCC3yWwNUrDJw6Sh3VoYLyOOwpGMY=; b=vJE/bqCyohOXMvLuHrZAyIdHVLCHQeCPTph9EmfaBets4k6ISJaxpleFQ+C3Par0Fu 9Ume0dw3eIyoHywkRrnwPcXMAcXSPX3J2Md8PeVVtOexyRjrsDRwr8bgyrwzAeelBZoY Liu3Cm2SXYsUCh94aiwvYzZY23VKMIPZqKLXoRSdKR7x6ygoIgW14RBEdELx3ZUxa3Xc bGa8eVhpA46w0hQobEs9X9FkOrhuIMcr09agwpmRuAAdfRKZbE6FmyyoOHnMcC2mOq9y SnOgragKZjoqsp7p0Ca9o0zamFQ/fqdeMv1wbRdqVOKlD0vZvwffU++Lxn2vXOG5OGyh WR4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=riVngxdT; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc23-20020a056402205700b0052228fd2325si6244424edb.267.2023.08.07.20.25.13; Mon, 07 Aug 2023 20:25:38 -0700 (PDT) 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=@gmail.com header.s=20221208 header.b=riVngxdT; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbjHHCT4 (ORCPT + 99 others); Mon, 7 Aug 2023 22:19:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjHHCTx (ORCPT ); Mon, 7 Aug 2023 22:19:53 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5E8D1705; Mon, 7 Aug 2023 19:19:52 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3a37909a64eso3595516b6e.1; Mon, 07 Aug 2023 19:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691461192; x=1692065992; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=w2SLqdPoc24r3SU7DATTJAeepTTgjgASEEH+wJbfp+8=; b=riVngxdTKsSRf7zXfXSL+qD0Y9DVtBRjJKYvZ/v+RGrtoKt2jqRdWIGY1s1cEYR/qX mnMqz8NnTPAca/wgd3qX9s+/2HRmdijpDagu7AOB+NXdafhI/WATpb6oFJjBeU9TI5hd jYynNZSw2+jSjtfEA+KpBodE2c5qagBxcR40d4hzGZ6m2FXk2i/9ePzEi+wEHpqNveJA wS9m4UybfB/LsIsiFllnIm1fByZs2aGe+6i63UN7+kXgX6JXzLLIPwNhdgAV5u9iGYGU XYZq+mXmuobQKRH3+VWUU2BZd7AGZZxu+6LzzE+pe58UPKcIY+vpP2nGPF7MhiSyuW8f gtnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691461192; x=1692065992; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=w2SLqdPoc24r3SU7DATTJAeepTTgjgASEEH+wJbfp+8=; b=VPnhKGRVgL0Z5rQ+wq6OY0YKHYg9FB9y6mRVErZIMYOzrrgf9jpq0+YyqFRIeM9Brx 3hfi6Ap6V+54b0yXqvNKcSx4/IoVRZug4d0eNvQTDSkiYjtGrUrmyeDph6SxOgzDf2QE fdIB3gC6mgk/+wfZDYE2PVvrEHQKBOWRhageft84EdJd3mHvb5u4/QEjqj54Lk9E2pes ueZu/gwrHmrKBmHiv4QCo3OkFY6sVq2xfYlaRY8LYFqaKxHP/Pw3eVcH+6ifYMoL9+rS y22nxiFRGjkQhgbX5Jb1R0LK9MZN/w7b3M+4I6JkOf58rvhqW60LKQ7wyc4rbx1wC8ps t3jQ== X-Gm-Message-State: AOJu0YzEF0V1UqExXhmD7xmaaSw/JZD1y4hcKDy7blgtrjwj341uQELB sTaap8rZjpTnnHCj2jLfyZg= X-Received: by 2002:a05:6808:17aa:b0:3a7:7bd3:7a7d with SMTP id bg42-20020a05680817aa00b003a77bd37a7dmr15663696oib.23.1691461191836; Mon, 07 Aug 2023 19:19:51 -0700 (PDT) Received: from localhost.localdomain ([198.211.45.220]) by smtp.googlemail.com with ESMTPSA id p18-20020aa78612000000b006871dad3e74sm6849000pfn.65.2023.08.07.19.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 19:19:51 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: "David S. Miller" , Alexandre Torgue , Jose Abreu , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Joao Pinto , Simon Horman Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, xfr@outlook.com, rock.xu@nio.com, Furong Xu <0x1207@gmail.com> Subject: [PATCH net-next v2 1/1] net: stmmac: xgmac: RX queue routing configuration Date: Tue, 8 Aug 2023 10:19:06 +0800 Message-Id: <20230808021906.1120889-1-0x1207@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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: INBOX X-GMAIL-THRID: 1773588672174431500 X-GMAIL-MSGID: 1773629749070034624 Commit abe80fdc6ee6 ("net: stmmac: RX queue routing configuration") introduced RX queue routing to DWMAC4 core. This patch extend the support to XGMAC2 core. Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Simon Horman --- Changes in v2: - Convert the shift ops to FIELD_PREP --- .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 14 ++++++++ .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 34 +++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h index 1913385df685..a2498da7406b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -74,8 +74,22 @@ #define XGMAC_RXQEN(x) GENMASK((x) * 2 + 1, (x) * 2) #define XGMAC_RXQEN_SHIFT(x) ((x) * 2) #define XGMAC_RXQ_CTRL1 0x000000a4 +#define XGMAC_AVCPQ GENMASK(31, 28) +#define XGMAC_AVCPQ_SHIFT 28 +#define XGMAC_PTPQ GENMASK(27, 24) +#define XGMAC_PTPQ_SHIFT 24 +#define XGMAC_TACPQE BIT(23) +#define XGMAC_TACPQE_SHIFT 23 +#define XGMAC_DCBCPQ GENMASK(19, 16) +#define XGMAC_DCBCPQ_SHIFT 16 +#define XGMAC_MCBCQEN BIT(15) +#define XGMAC_MCBCQEN_SHIFT 15 +#define XGMAC_MCBCQ GENMASK(11, 8) +#define XGMAC_MCBCQ_SHIFT 8 #define XGMAC_RQ GENMASK(7, 4) #define XGMAC_RQ_SHIFT 4 +#define XGMAC_UPQ GENMASK(3, 0) +#define XGMAC_UPQ_SHIFT 0 #define XGMAC_RXQ_CTRL2 0x000000a8 #define XGMAC_RXQ_CTRL3 0x000000ac #define XGMAC_PSRQ(x) GENMASK((x) * 8 + 7, (x) * 8) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index a0c2ef8bb0ac..38782662ff98 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -127,6 +127,36 @@ static void dwxgmac2_tx_queue_prio(struct mac_device_info *hw, u32 prio, writel(value, ioaddr + reg); } +static void dwxgmac2_rx_queue_routing(struct mac_device_info *hw, + u8 packet, u32 queue) +{ + void __iomem *ioaddr = hw->pcsr; + u32 value; + + static const struct stmmac_rx_routing dwxgmac2_route_possibilities[] = { + { XGMAC_AVCPQ, XGMAC_AVCPQ_SHIFT }, + { XGMAC_PTPQ, XGMAC_PTPQ_SHIFT }, + { XGMAC_DCBCPQ, XGMAC_DCBCPQ_SHIFT }, + { XGMAC_UPQ, XGMAC_UPQ_SHIFT }, + { XGMAC_MCBCQ, XGMAC_MCBCQ_SHIFT }, + }; + + value = readl(ioaddr + XGMAC_RXQ_CTRL1); + + /* routing configuration */ + value &= ~dwxgmac2_route_possibilities[packet - 1].reg_mask; + value |= (queue << dwxgmac2_route_possibilities[packet - 1].reg_shift) & + dwxgmac2_route_possibilities[packet - 1].reg_mask; + + /* some packets require extra ops */ + if (packet == PACKET_AVCPQ) + value |= FIELD_PREP(XGMAC_TACPQE, 1); + else if (packet == PACKET_MCBCQ) + value |= FIELD_PREP(XGMAC_MCBCQEN, 1); + + writel(value, ioaddr + XGMAC_RXQ_CTRL1); +} + static void dwxgmac2_prog_mtl_rx_algorithms(struct mac_device_info *hw, u32 rx_alg) { @@ -1463,7 +1493,7 @@ const struct stmmac_ops dwxgmac210_ops = { .rx_queue_enable = dwxgmac2_rx_queue_enable, .rx_queue_prio = dwxgmac2_rx_queue_prio, .tx_queue_prio = dwxgmac2_tx_queue_prio, - .rx_queue_routing = NULL, + .rx_queue_routing = dwxgmac2_rx_queue_routing, .prog_mtl_rx_algorithms = dwxgmac2_prog_mtl_rx_algorithms, .prog_mtl_tx_algorithms = dwxgmac2_prog_mtl_tx_algorithms, .set_mtl_tx_queue_weight = dwxgmac2_set_mtl_tx_queue_weight, @@ -1524,7 +1554,7 @@ const struct stmmac_ops dwxlgmac2_ops = { .rx_queue_enable = dwxlgmac2_rx_queue_enable, .rx_queue_prio = dwxgmac2_rx_queue_prio, .tx_queue_prio = dwxgmac2_tx_queue_prio, - .rx_queue_routing = NULL, + .rx_queue_routing = dwxgmac2_rx_queue_routing, .prog_mtl_rx_algorithms = dwxgmac2_prog_mtl_rx_algorithms, .prog_mtl_tx_algorithms = dwxgmac2_prog_mtl_tx_algorithms, .set_mtl_tx_queue_weight = dwxgmac2_set_mtl_tx_queue_weight,