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: 13345598 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E0D9C001B0 for ; Tue, 8 Aug 2023 02:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Iv0edAPkiQDSXkQjTgxkyViOyou8XRNN26M94O0ZOXk=; b=rr0xsvzJlObzJk 1DNRFTpzNPkT2W4m7HsvWVCDV4Ocd47crViHbqhTV2SP/63igZpnE7VxVkxKKMTaFRdGYBvyfwj3v VkMnOEpedyq2UEzd3TNwxS1snlDTXMQB2eQC/QbbmS8ma7ECXP7jDbEtghj+BrQ1jp/9gWnjYO4oA HVkMCimt2AsKTF9COKc4s+88WRhr/CqUar/m5N6nd1pAIN9uM4tFibsIHlMWGvxqYG2k22IrKWGhD E80IdMMrZtsR3fzOcJbgRDuezi4RTBPiylg7IjNDk/GWZFkcipcDqEATcr8DwYw9HwC4g8Km4u/NH JcRznSjMaRC+ozdX36Vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qTCKD-001XKZ-2P; Tue, 08 Aug 2023 02:19:57 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qTCKB-001XJI-0T for linux-arm-kernel@lists.infradead.org; Tue, 08 Aug 2023 02:19:56 +0000 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3a44cccbd96so3583948b6e.3 for ; 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=e1ctyn0S1/qO8uvdl8uj/h2PQEDICsyIEKlsq9wKb7zxYFGmF2akXLgocGanxTyyjR 8f4phS6bO7I/EwJh0KMHJ4CtcVWaGExbHBrmbW30nTEwDXY9FC0bjLuQDHATO8dvEN3w s0RjZgDWuR1xN1/jFUsy4Db4N9eGxar76RgJzto3h/8eRb0vshZLMdenQIWpuXCMw0uS EGcfNpDGFDCSjH95UI4uy6UwR7UO4fLVPJE//7HQTU42CFYmmlSWKzArN7KrlB3Prw5Y asmkJRmTS9pNKJEsvk39tSCO45rczXkHOzCAM6P+SmQvv1UGTi+juHfPkwjmi/Z8IcjH kwKA== X-Gm-Message-State: AOJu0Yzsg13YJHwVkBemk/FBqdokOwTFZKTC8M7RtAWczaTGsbc15ac7 Apmi5MAg4UcTdtMEsqkCdHE= X-Google-Smtp-Source: AGHT+IGH/g0JdiGrMleuVRrFWy33FO4h64b4qozK/olV66uDrtE31E68FjW4XEcWo7kvtPQnHeG1BQ== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230807_191955_188513_6ED2A629 X-CRM114-Status: GOOD ( 15.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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,