From patchwork Mon Nov 7 18:54:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16643 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2234384wru; Mon, 7 Nov 2022 11:02:48 -0800 (PST) X-Google-Smtp-Source: AMsMyM6Kr4ch0rmMJMxVEIulg0oeJPZQ1P719elHMbPU4JYSNyKMbcnlhDNtCBo9Ek1QoMO1qrHT X-Received: by 2002:a17:90b:4d87:b0:212:d62a:8612 with SMTP id oj7-20020a17090b4d8700b00212d62a8612mr71373120pjb.35.1667847768182; Mon, 07 Nov 2022 11:02:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847768; cv=none; d=google.com; s=arc-20160816; b=c8dgsgEhi2PBk5aXAu3Y30oAciNE6WXaJ9TE88YDV1f3P4zJHQWrSFord8QEaZBbhT A7SGCJ6wZyppp7ILOPiv2Jrr2v/ujjitHH+VxgO4dPvccTF5BStYDKrPTVEDjKPz5Lrp /zhUB/IS/sJZYGgbnZH1kKBYKr50JgLDgi4soPJBDxOOvAmzi55OHAD3tAoDCyo/iAUi F8thXq+YtKc042h3faKvdyeLLDbYBk/BwBMqRf8wxiejACSlTvaMrStvT9iUj8hjMQIs vXBibBzqgw0no9X683nA+TpxmIkbHOFcZDUWxRqrgzmW/mMGoE87Rt9tNBMIosXtSdaI g/Mw== 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=YLg5pPiZ4SgYBGCUeq6yCCCPL/wr+lr6XSx1WcECfek=; b=pz3Q0kJDmTXL8qNdIjpSeXEwJIEWqoZR7NUWWI9Vuc5q4ldCCvpxTX0frfllWgtCA5 R3hPO7tJ3G6aCB4hDO+HtXftj36044dVjHQP7ilX45wF3DoAv7oe1CEKCnjQlLTYcO0m WxFC9nJG1hmJNBW/Mup1wPui04GtuyDwBYupIzZz8gIPWJui4P/EBjRh2jEbcXFAXtRN Koq3uXCW76czd1QjAS5tOwvncD2jYGDMaFKOajafiOBxawLzfj/xjPIg/pCDrTvWYmmB L1ThrhCkdo7P87PLse3N90lAt7tc5HZ7OHal9YzlzLmFW8GnQ7jOceKGOknLTUuec9MP cmsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=WvQqD0JZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mu10-20020a17090b388a00b00203246e4383si11583494pjb.145.2022.11.07.11.02.33; Mon, 07 Nov 2022 11:02:48 -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=fail header.i=@nbd.name header.s=20160729 header.b=WvQqD0JZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233075AbiKGSzi (ORCPT + 99 others); Mon, 7 Nov 2022 13:55:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233009AbiKGSzf (ORCPT ); Mon, 7 Nov 2022 13:55:35 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2BE31139; Mon, 7 Nov 2022 10:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=YLg5pPiZ4SgYBGCUeq6yCCCPL/wr+lr6XSx1WcECfek=; b=WvQqD0JZD+cMdUTfMcVWB+LWE1 ZWQnp0lAdw3j1H4rZxowkxQDZLm3kjQOSPCFhPuNjFYi5DtCBfXlU2P3X/FZxGiJkQH58cgLJEUmW 8rnGn2i110PtwhvyiByPWYQuvKPyVse2oAq9MrCU3n1u+B0O2VO8UBx7Qq9RKDwogaCE=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7H8-000LCc-LA; Mon, 07 Nov 2022 19:55:14 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/14] net: ethernet: mtk_eth_soc: account for vlan in rx header length Date: Mon, 7 Nov 2022 19:54:39 +0100 Message-Id: <20221107185452.90711-1-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748865141382137426?= X-GMAIL-MSGID: =?utf-8?q?1748865141382137426?= This may be needed for correct MTU settings on devices using DSA Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 589f27ddc401..dcf2a0d5da33 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -29,7 +29,7 @@ #define MTK_TX_DMA_BUF_LEN_V2 0xffff #define MTK_DMA_SIZE 512 #define MTK_MAC_COUNT 2 -#define MTK_RX_ETH_HLEN (ETH_HLEN + ETH_FCS_LEN) +#define MTK_RX_ETH_HLEN (VLAN_ETH_HLEN + ETH_HLEN + ETH_FCS_LEN) #define MTK_RX_HLEN (NET_SKB_PAD + MTK_RX_ETH_HLEN + NET_IP_ALIGN) #define MTK_DMA_DUMMY_DESC 0xffffffff #define MTK_DEFAULT_MSG_ENABLE (NETIF_MSG_DRV | \ From patchwork Mon Nov 7 18:54:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16640 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2234190wru; Mon, 7 Nov 2022 11:02:30 -0800 (PST) X-Google-Smtp-Source: AMsMyM6lXtJeIkHtQ09uUP21m5dF3n9IlMIiuwraZ5TcmUUknOp4eho96xsHx2WGtAQHOEsbWrOf X-Received: by 2002:a17:90b:3886:b0:213:5ccc:973b with SMTP id mu6-20020a17090b388600b002135ccc973bmr70003826pjb.193.1667847750456; Mon, 07 Nov 2022 11:02:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847750; cv=none; d=google.com; s=arc-20160816; b=SCrkRSRIHVPFrC6EMRBhOwSazNtiqaz9ib/lhZTqqeWzT2b3qKvMOIVGmOxH4Du0Ws ApLkk7uMXCv2+xuY3Xm56I5zU3yn4skmSKuGZ9q76/SOYkOENcEBSY053650ytnc1oSv PHELAaufaZxizSoFxCH6JRt1tL/XPyL5mcLqI8d4XZ6G5Y3QjT/5nGDzSNPqmsrRNnvS cEZLkzxHKi3fvuGxw0uCWIO6dI5vNUzN1gngvpglAFjS3S+bZAs5yyBLJtJz08tPEoLZ geA5F6LVmhV155DytEjrOLVRMOO7yqTcQykjjuyuWFD93Mjv36he/XoCCVxoUuO1ohPp 3m0A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t1MneiO2MHxf3bvI/A88HGLNRJjJfzE0JDlHHbyEsc4=; b=LRrNDNn1UYLlmkDGI2SwMcVT6xTE20N8iWOvKKvwbviGEEys55vDMbDUPuHCNousyF VRbtJ6t4cUzKvjEn7Fbwjv4o1hFJJlsXPo5UNg9/ItAuLjO0QGtHmtcI0/k33ykh4JEq Jgs/4pk/fBza/jwfWlk9VAXHvzApObLSbsk1Lxbp6kFIWKAfB6+vB+PmnKfNevLGvCU7 kQFTdPMkPHiPN/TNy0YwThQnhA18xATPn5A+0PBRHB93hiMjkpOX5MP9CfbxKiunesXW 8UDhbxBVy9D4K0jmNID2hYmMY0bF0k9HAr/HNt3iEFctT/ar+goUhw7XKnEo/Dq/QjOt 7ojg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=L68KhROG; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f15-20020a65550f000000b0046ec05ccbe8si11247882pgr.380.2022.11.07.11.02.03; Mon, 07 Nov 2022 11:02:30 -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=fail header.i=@nbd.name header.s=20160729 header.b=L68KhROG; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233011AbiKGSz4 (ORCPT + 99 others); Mon, 7 Nov 2022 13:55:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232008AbiKGSzh (ORCPT ); Mon, 7 Nov 2022 13:55:37 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2175623BCB; Mon, 7 Nov 2022 10:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=t1MneiO2MHxf3bvI/A88HGLNRJjJfzE0JDlHHbyEsc4=; b=L68KhROGIGy73wrusqkzx0qppL N1187+C1Lh7YYTXexcokVYKowIucDX3pkeGd3h1p8LlhN7LdW1k0Ep4cBai3k5gCMsfB4ARgQ+sY9 TYFNe9Kx2F0Wl5mqA/b9mJoQLrr3HwMc7ZDM9+ZIX0yZv3Nl/D865EWDTNyvzcrICJRY=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7H9-000LCc-DU; Mon, 07 Nov 2022 19:55:15 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/14] net: ethernet: mtk_eth_soc: increase tx ring side for QDMA devices Date: Mon, 7 Nov 2022 19:54:40 +0100 Message-Id: <20221107185452.90711-2-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748865122608438122?= X-GMAIL-MSGID: =?utf-8?q?1748865122608438122?= In order to use the hardware traffic shaper feature, a larger tx ring is needed, especially for the scratch ring, which the hardware shaper uses to reorder packets. Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 38 ++++++++++++--------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 789268b15106..02a57729db28 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -938,7 +938,7 @@ static int mtk_init_fq_dma(struct mtk_eth *eth) { const struct mtk_soc_data *soc = eth->soc; dma_addr_t phy_ring_tail; - int cnt = MTK_DMA_SIZE; + int cnt = MTK_QDMA_RING_SIZE; dma_addr_t dma_addr; int i; @@ -2202,19 +2202,25 @@ static int mtk_tx_alloc(struct mtk_eth *eth) struct mtk_tx_ring *ring = ð->tx_ring; int i, sz = soc->txrx.txd_size; struct mtk_tx_dma_v2 *txd; + int ring_size; - ring->buf = kcalloc(MTK_DMA_SIZE, sizeof(*ring->buf), + if (MTK_HAS_CAPS(soc->caps, MTK_QDMA)) + ring_size = MTK_QDMA_RING_SIZE; + else + ring_size = MTK_DMA_SIZE; + + ring->buf = kcalloc(ring_size, sizeof(*ring->buf), GFP_KERNEL); if (!ring->buf) goto no_tx_mem; - ring->dma = dma_alloc_coherent(eth->dma_dev, MTK_DMA_SIZE * sz, + ring->dma = dma_alloc_coherent(eth->dma_dev, ring_size * sz, &ring->phys, GFP_KERNEL); if (!ring->dma) goto no_tx_mem; - for (i = 0; i < MTK_DMA_SIZE; i++) { - int next = (i + 1) % MTK_DMA_SIZE; + for (i = 0; i < ring_size; i++) { + int next = (i + 1) % ring_size; u32 next_ptr = ring->phys + next * sz; txd = ring->dma + i * sz; @@ -2234,22 +2240,22 @@ static int mtk_tx_alloc(struct mtk_eth *eth) * descriptors in ring->dma_pdma. */ if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { - ring->dma_pdma = dma_alloc_coherent(eth->dma_dev, MTK_DMA_SIZE * sz, + ring->dma_pdma = dma_alloc_coherent(eth->dma_dev, ring_size * sz, &ring->phys_pdma, GFP_KERNEL); if (!ring->dma_pdma) goto no_tx_mem; - for (i = 0; i < MTK_DMA_SIZE; i++) { + for (i = 0; i < ring_size; i++) { ring->dma_pdma[i].txd2 = TX_DMA_DESP2_DEF; ring->dma_pdma[i].txd4 = 0; } } - ring->dma_size = MTK_DMA_SIZE; - atomic_set(&ring->free_count, MTK_DMA_SIZE - 2); + ring->dma_size = ring_size; + atomic_set(&ring->free_count, ring_size - 2); ring->next_free = ring->dma; ring->last_free = (void *)txd; - ring->last_free_ptr = (u32)(ring->phys + ((MTK_DMA_SIZE - 1) * sz)); + ring->last_free_ptr = (u32)(ring->phys + ((ring_size - 1) * sz)); ring->thresh = MAX_SKB_FRAGS; /* make sure that all changes to the dma ring are flushed before we @@ -2261,14 +2267,14 @@ static int mtk_tx_alloc(struct mtk_eth *eth) mtk_w32(eth, ring->phys, soc->reg_map->qdma.ctx_ptr); mtk_w32(eth, ring->phys, soc->reg_map->qdma.dtx_ptr); mtk_w32(eth, - ring->phys + ((MTK_DMA_SIZE - 1) * sz), + ring->phys + ((ring_size - 1) * sz), soc->reg_map->qdma.crx_ptr); mtk_w32(eth, ring->last_free_ptr, soc->reg_map->qdma.drx_ptr); mtk_w32(eth, (QDMA_RES_THRES << 8) | QDMA_RES_THRES, soc->reg_map->qdma.qtx_cfg); } else { mtk_w32(eth, ring->phys_pdma, MT7628_TX_BASE_PTR0); - mtk_w32(eth, MTK_DMA_SIZE, MT7628_TX_MAX_CNT0); + mtk_w32(eth, ring_size, MT7628_TX_MAX_CNT0); mtk_w32(eth, 0, MT7628_TX_CTX_IDX0); mtk_w32(eth, MT7628_PST_DTX_IDX0, soc->reg_map->pdma.rst_idx); } @@ -2286,7 +2292,7 @@ static void mtk_tx_clean(struct mtk_eth *eth) int i; if (ring->buf) { - for (i = 0; i < MTK_DMA_SIZE; i++) + for (i = 0; i < ring->dma_size; i++) mtk_tx_unmap(eth, &ring->buf[i], NULL, false); kfree(ring->buf); ring->buf = NULL; @@ -2294,14 +2300,14 @@ static void mtk_tx_clean(struct mtk_eth *eth) if (ring->dma) { dma_free_coherent(eth->dma_dev, - MTK_DMA_SIZE * soc->txrx.txd_size, + ring->dma_size * soc->txrx.txd_size, ring->dma, ring->phys); ring->dma = NULL; } if (ring->dma_pdma) { dma_free_coherent(eth->dma_dev, - MTK_DMA_SIZE * soc->txrx.txd_size, + ring->dma_size * soc->txrx.txd_size, ring->dma_pdma, ring->phys_pdma); ring->dma_pdma = NULL; } @@ -2821,7 +2827,7 @@ static void mtk_dma_free(struct mtk_eth *eth) netdev_reset_queue(eth->netdev[i]); if (eth->scratch_ring) { dma_free_coherent(eth->dma_dev, - MTK_DMA_SIZE * soc->txrx.txd_size, + MTK_QDMA_RING_SIZE * soc->txrx.txd_size, eth->scratch_ring, eth->phy_scratch_ring); eth->scratch_ring = NULL; eth->phy_scratch_ring = 0; diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index dcf2a0d5da33..7c0b6c0c05d8 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -27,6 +27,7 @@ #define MTK_MAX_RX_LENGTH_2K 2048 #define MTK_TX_DMA_BUF_LEN 0x3fff #define MTK_TX_DMA_BUF_LEN_V2 0xffff +#define MTK_QDMA_RING_SIZE 2048 #define MTK_DMA_SIZE 512 #define MTK_MAC_COUNT 2 #define MTK_RX_ETH_HLEN (VLAN_ETH_HLEN + ETH_HLEN + ETH_FCS_LEN) From patchwork Mon Nov 7 18:54:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2234756wru; Mon, 7 Nov 2022 11:03:21 -0800 (PST) X-Google-Smtp-Source: AMsMyM5IP10ePkoAxTqCVzq8k9vwt7+1FuQpLrSzn/GPcJgQIW8BvlEvpCCgkNzU5+QFBHUJXo2c X-Received: by 2002:a50:d5d5:0:b0:461:a30b:67a2 with SMTP id g21-20020a50d5d5000000b00461a30b67a2mr52539969edj.104.1667847800980; Mon, 07 Nov 2022 11:03:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847800; cv=none; d=google.com; s=arc-20160816; b=IwT6ceRMxCB5E9ihp1jyZWw26E7mP89k7Jp4Pong+qbiFprC+RiyVwYRfOML/1lCY6 cJf4zuhUXN+ZAirRLfGmKpNuNcXrMH0JNLlSQmqdHTP59vp1Pr99M8HWShMEF4ak261n wMeA4nx5gjtw2bLSPkiJADll4cN/Tdv2zvCQosJ+sZL/YsImCMvRKqP4AZ9fE8GhDvvF CS7fjuhYNjbHMbauMaLpAxqK5TuUflpzhIFOCkDYE++GEDbPHASmwzsI/hkuNW4cxBDa WH7ILgOuegnsas7SSDBnZ/PRf8p0+bKOQ/ge+tCA2l0OrL1sLE3sbi96C8nEQQCzzBXb HETQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R2N+jSfSlY43TnrF1h50zfC2H3h4TDeeUUxvXDObycg=; b=Nal5g+Gp9Fyj2nD+woiU9f9VFQ8uMHb9pYriBo0GlG9FKQHe9iuYGuOHDbstL7Svwi U6hXhAWMIenRAgWRfZYWTR5J2RNnqRZ+ndV1K0zNJSRCMKZ8jCuI6xyF2UkIlEAvZc6n tU0gALgCgP2dev/CXM+TPPZmhaCFEu+u1qPbrEVw6w2IA34D/dbha9W1WcXCvVr0N0DE K/z3t+ZNwN3fAhkvcY/iMpSp/Sgjbeg/qd6UEqRBAIycENaQu62qsRPOze+DLS7PR9UR bV4qrLHDmYQk9MZxD7UFWAyA27OxPe2Bubs3TjRfafNnd6CDTGlLLrk2Yzrvo56JKAXu OXIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=C7Bjul4L; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hw9-20020a170907a0c900b0078df24be362si9970031ejc.496.2022.11.07.11.02.56; Mon, 07 Nov 2022 11:03: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=fail header.i=@nbd.name header.s=20160729 header.b=C7Bjul4L; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232187AbiKGS4L (ORCPT + 99 others); Mon, 7 Nov 2022 13:56:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232942AbiKGSzn (ORCPT ); Mon, 7 Nov 2022 13:55:43 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69B1B24953; Mon, 7 Nov 2022 10:55:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=R2N+jSfSlY43TnrF1h50zfC2H3h4TDeeUUxvXDObycg=; b=C7Bjul4L+uZ5OTJN4pEVSnqlbL qxyo4As8AlXPlDIoxFGL6JtZIC9DUnL/tZB6t9okWkqhDmncnwapQ626TBPm0Dz0MUDeEqhd6hBbb EU5heDXhPmbjEPt2KSK7tCs5w0nEpSdt9f0WnPmiV/Vd4yssvCnNedGvHg5vdVYP+9OI=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HA-000LCc-5E; Mon, 07 Nov 2022 19:55:16 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/14] net: ethernet: mtk_eth_soc: avoid port_mg assignment on MT7622 and newer Date: Mon, 7 Nov 2022 19:54:41 +0100 Message-Id: <20221107185452.90711-3-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748865175842416083?= X-GMAIL-MSGID: =?utf-8?q?1748865175842416083?= On newer chips, this field is unused and contains some bits related to queue assignment. Initialize it to 0 in those cases. Fix offload_version on MT7621 and MT7623, which still need the previous value. Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++-- drivers/net/ethernet/mediatek/mtk_ppe.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 02a57729db28..9f607c80f49c 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -4243,7 +4243,7 @@ static const struct mtk_soc_data mt7621_data = { .hw_features = MTK_HW_FEATURES, .required_clks = MT7621_CLKS_BITMAP, .required_pctl = false, - .offload_version = 2, + .offload_version = 1, .hash_offset = 2, .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { @@ -4282,7 +4282,7 @@ static const struct mtk_soc_data mt7623_data = { .hw_features = MTK_HW_FEATURES, .required_clks = MT7623_CLKS_BITMAP, .required_pctl = true, - .offload_version = 2, + .offload_version = 1, .hash_offset = 2, .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c index 2d8ca99f2467..3ee2bf53f9e5 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c @@ -175,6 +175,8 @@ int mtk_foe_entry_prepare(struct mtk_eth *eth, struct mtk_foe_entry *entry, val = FIELD_PREP(MTK_FOE_IB2_DEST_PORT_V2, pse_port) | FIELD_PREP(MTK_FOE_IB2_PORT_AG_V2, 0xf); } else { + int port_mg = eth->soc->offload_version > 1 ? 0 : 0x3f; + val = FIELD_PREP(MTK_FOE_IB1_STATE, MTK_FOE_STATE_BIND) | FIELD_PREP(MTK_FOE_IB1_PACKET_TYPE, type) | FIELD_PREP(MTK_FOE_IB1_UDP, l4proto == IPPROTO_UDP) | @@ -182,7 +184,7 @@ int mtk_foe_entry_prepare(struct mtk_eth *eth, struct mtk_foe_entry *entry, entry->ib1 = val; val = FIELD_PREP(MTK_FOE_IB2_DEST_PORT, pse_port) | - FIELD_PREP(MTK_FOE_IB2_PORT_MG, 0x3f) | + FIELD_PREP(MTK_FOE_IB2_PORT_MG, port_mg) | FIELD_PREP(MTK_FOE_IB2_PORT_AG, 0x1f); } From patchwork Mon Nov 7 18:54:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2234780wru; Mon, 7 Nov 2022 11:03:22 -0800 (PST) X-Google-Smtp-Source: AMsMyM7aFyJTqAuEQd5K01sIdDVOKYfg5+Z6JNszNFKP+8iKYtq752ZPm8d/mQ3mVB5n0S49KKQp X-Received: by 2002:a05:6402:294a:b0:461:b661:d903 with SMTP id ed10-20020a056402294a00b00461b661d903mr51445555edb.407.1667847802496; Mon, 07 Nov 2022 11:03:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847802; cv=none; d=google.com; s=arc-20160816; b=rX/u8j0/swnyLCCDJjmp3EjBr7Vny9bnJuMmNzWRXuoO7GNLqT1nnfXR1tTlLb6ndg 30w+aMw7H906v/BBn382TKKW1v69W/BrUd1dPgIC2WANm2snGDPTId0lgPUkcINmfuKZ VG43r4vpM9BwT3l5icNFfP/W3v7Naw+TsZKg+C8TKcd+izPXtIv0aRaRAx+bDy8Ed4Q4 ydyvJo0/dpYCqGGG/Y39S65QP36vpf4YQC4dBxPctls5mJth/bs4z1Zf/73EK7YwFlo9 L5KFnTmdzdQMdWT8DBLeR+PYic/01kAUSw5jdyb2JT/2OS5o/fELi71/F0mFqld4+F4U iJig== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yJboVBY/0rriTqwKSvfpq30xjjZJ+AE8w28NMDqC30Y=; b=QBPMYPyP0aqTr+3QUh1+EFAtI0qDfQF9PfjN6/wQpDMD97gGG3GAgG8k/Zjx3dYDEt 2b92JsRtP8S69PKFpcNwz9FJjLq5+2oWNXgALg0kK5jDl0wcOdvGnzVzni1Sb1qmxmcM 9qC586ESNILG0vUYCvcgHb1lI5Cl0ZZb3xyAkDd5OSZrnkGEu7EN4UPIyKfoAm8pHxFr PO8SjbABz3bsVNlLh6UCNY/axKxmw2/Sj3ecOEwnYoN5hDVjZsEHGjmOIBt52IzMmUl8 jChGIqD4uQybe2AHPIKBuHfaXnoTLIazsTiDtLNr9glD5/R+wcW5El9O3qFgw17monBw 4jKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=OQJizdvT; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp14-20020a170906c14e00b007ad8140c60asi12019843ejc.492.2022.11.07.11.02.58; Mon, 07 Nov 2022 11:03:22 -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=fail header.i=@nbd.name header.s=20160729 header.b=OQJizdvT; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232417AbiKGS4O (ORCPT + 99 others); Mon, 7 Nov 2022 13:56:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233106AbiKGSzs (ORCPT ); Mon, 7 Nov 2022 13:55:48 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F08D28E37; Mon, 7 Nov 2022 10:55:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=yJboVBY/0rriTqwKSvfpq30xjjZJ+AE8w28NMDqC30Y=; b=OQJizdvTBzJMO4nI8YjXlNBWgr srfuJST3kGE8Nd7TxlgZl6r/yi4gk6ZtdXVzq28Fs/LUldHBOYGuAU06cpIHAFNl0voX75A3uat6h D6hxe+SvE9YxS3hOmz3Dfe3hAcgoi/WTiJjYCOhVV/gQiM8MnEgId0i6+wjBd35bkloI=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HB-000LCc-52; Mon, 07 Nov 2022 19:55:17 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Russell King Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/14] net: ethernet: mtk_eth_soc: implement multi-queue support for per-port queues Date: Mon, 7 Nov 2022 19:54:42 +0100 Message-Id: <20221107185452.90711-4-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748865177566401962?= X-GMAIL-MSGID: =?utf-8?q?1748865177566401962?= When sending traffic to multiple ports with different link speeds, queued packets to one port can drown out tx to other ports. In order to better handle transmission to multiple ports, use the hardware shaper feature to implement weighted fair queueing between ports. Weight and maximum rate are automatically adjusted based on the link speed of the port. The first 3 queues are unrestricted and reserved for non-DSA direct tx on GMAC ports. The following queues are automatically assigned by the MTK DSA tag driver based on the target port number. The PPE offload code configures the queues for offloaded traffic in the same way. This feature is only supported on devices supporting QDMA. All queues still share the same DMA ring and descriptor pool. Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 282 ++++++++++++++++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 26 +- 2 files changed, 259 insertions(+), 49 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 9f607c80f49c..ab31dda2cd66 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -54,6 +54,7 @@ static const struct mtk_reg_map mtk_reg_map = { }, .qdma = { .qtx_cfg = 0x1800, + .qtx_sch = 0x1804, .rx_ptr = 0x1900, .rx_cnt_cfg = 0x1904, .qcrx_ptr = 0x1908, @@ -61,6 +62,7 @@ static const struct mtk_reg_map mtk_reg_map = { .rst_idx = 0x1a08, .delay_irq = 0x1a0c, .fc_th = 0x1a10, + .tx_sch_rate = 0x1a14, .int_grp = 0x1a20, .hred = 0x1a44, .ctx_ptr = 0x1b00, @@ -113,6 +115,7 @@ static const struct mtk_reg_map mt7986_reg_map = { }, .qdma = { .qtx_cfg = 0x4400, + .qtx_sch = 0x4404, .rx_ptr = 0x4500, .rx_cnt_cfg = 0x4504, .qcrx_ptr = 0x4508, @@ -130,6 +133,7 @@ static const struct mtk_reg_map mt7986_reg_map = { .fq_tail = 0x4724, .fq_count = 0x4728, .fq_blen = 0x472c, + .tx_sch_rate = 0x4798, }, .gdm1_cnt = 0x1c00, .gdma_to_ppe = 0x3333, @@ -613,6 +617,75 @@ static void mtk_mac_link_down(struct phylink_config *config, unsigned int mode, mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id)); } +static void mtk_set_queue_speed(struct mtk_eth *eth, unsigned int idx, + int speed) +{ + const struct mtk_soc_data *soc = eth->soc; + u32 ofs, val; + + if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) + return; + + val = MTK_QTX_SCH_MIN_RATE_EN | + /* minimum: 10 Mbps */ + FIELD_PREP(MTK_QTX_SCH_MIN_RATE_MAN, 1) | + FIELD_PREP(MTK_QTX_SCH_MIN_RATE_EXP, 4) | + MTK_QTX_SCH_LEAKY_BUCKET_SIZE; + if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) + val |= MTK_QTX_SCH_LEAKY_BUCKET_EN; + + if (IS_ENABLED(CONFIG_SOC_MT7621)) { + switch (speed) { + case SPEED_10: + val |= MTK_QTX_SCH_MAX_RATE_EN | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_MAN, 103) | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_EXP, 2) | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_WEIGHT, 1); + break; + case SPEED_100: + val |= MTK_QTX_SCH_MAX_RATE_EN | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_MAN, 103) | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_EXP, 3); + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_WEIGHT, 1); + break; + case SPEED_1000: + val |= MTK_QTX_SCH_MAX_RATE_EN | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_MAN, 105) | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_EXP, 4) | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_WEIGHT, 10); + break; + default: + break; + } + } else { + switch (speed) { + case SPEED_10: + val |= MTK_QTX_SCH_MAX_RATE_EN | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_MAN, 1) | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_EXP, 4) | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_WEIGHT, 1); + break; + case SPEED_100: + val |= MTK_QTX_SCH_MAX_RATE_EN | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_MAN, 1) | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_EXP, 5); + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_WEIGHT, 1); + break; + case SPEED_1000: + val |= MTK_QTX_SCH_MAX_RATE_EN | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_MAN, 10) | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_EXP, 5) | + FIELD_PREP(MTK_QTX_SCH_MAX_RATE_WEIGHT, 10); + break; + default: + break; + } + } + + ofs = MTK_QTX_OFFSET * idx; + mtk_w32(eth, val, soc->reg_map->qdma.qtx_sch + ofs); +} + static void mtk_mac_link_up(struct phylink_config *config, struct phy_device *phy, unsigned int mode, phy_interface_t interface, @@ -638,6 +711,8 @@ static void mtk_mac_link_up(struct phylink_config *config, break; } + mtk_set_queue_speed(mac->hw, mac->id, speed); + /* Configure duplex */ if (duplex == DUPLEX_FULL) mcr |= MAC_MCR_FORCE_DPX; @@ -1099,7 +1174,8 @@ static void mtk_tx_set_dma_desc_v1(struct net_device *dev, void *txd, WRITE_ONCE(desc->txd1, info->addr); - data = TX_DMA_SWC | TX_DMA_PLEN0(info->size); + data = TX_DMA_SWC | TX_DMA_PLEN0(info->size) | + FIELD_PREP(TX_DMA_PQID, info->qid); if (info->last) data |= TX_DMA_LS0; WRITE_ONCE(desc->txd3, data); @@ -1133,9 +1209,6 @@ static void mtk_tx_set_dma_desc_v2(struct net_device *dev, void *txd, data |= TX_DMA_LS0; WRITE_ONCE(desc->txd3, data); - if (!info->qid && mac->id) - info->qid = MTK_QDMA_GMAC2_QID; - data = (mac->id + 1) << TX_DMA_FPORT_SHIFT_V2; /* forward port */ data |= TX_DMA_SWC_V2 | QID_BITS_V2(info->qid); WRITE_ONCE(desc->txd4, data); @@ -1179,11 +1252,12 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, .gso = gso, .csum = skb->ip_summed == CHECKSUM_PARTIAL, .vlan = skb_vlan_tag_present(skb), - .qid = skb->mark & MTK_QDMA_TX_MASK, + .qid = skb_get_queue_mapping(skb), .vlan_tci = skb_vlan_tag_get(skb), .first = true, .last = !skb_is_nonlinear(skb), }; + struct netdev_queue *txq; struct mtk_mac *mac = netdev_priv(dev); struct mtk_eth *eth = mac->hw; const struct mtk_soc_data *soc = eth->soc; @@ -1191,8 +1265,10 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, struct mtk_tx_dma *itxd_pdma, *txd_pdma; struct mtk_tx_buf *itx_buf, *tx_buf; int i, n_desc = 1; + int queue = skb_get_queue_mapping(skb); int k = 0; + txq = netdev_get_tx_queue(dev, queue); itxd = ring->next_free; itxd_pdma = qdma_to_pdma(ring, itxd); if (itxd == ring->last_free) @@ -1241,7 +1317,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, memset(&txd_info, 0, sizeof(struct mtk_tx_dma_desc_info)); txd_info.size = min_t(unsigned int, frag_size, soc->txrx.dma_max_len); - txd_info.qid = skb->mark & MTK_QDMA_TX_MASK; + txd_info.qid = queue; txd_info.last = i == skb_shinfo(skb)->nr_frags - 1 && !(frag_size - txd_info.size); txd_info.addr = skb_frag_dma_map(eth->dma_dev, frag, @@ -1280,7 +1356,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, txd_pdma->txd2 |= TX_DMA_LS1; } - netdev_sent_queue(dev, skb->len); + netdev_tx_sent_queue(txq, skb->len); skb_tx_timestamp(skb); ring->next_free = mtk_qdma_phys_to_virt(ring, txd->txd2); @@ -1292,8 +1368,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, wmb(); if (MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { - if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || - !netdev_xmit_more()) + if (netif_xmit_stopped(txq) || !netdev_xmit_more()) mtk_w32(eth, txd->txd2, soc->reg_map->qdma.ctx_ptr); } else { int next_idx; @@ -1362,7 +1437,7 @@ static void mtk_wake_queue(struct mtk_eth *eth) for (i = 0; i < MTK_MAC_COUNT; i++) { if (!eth->netdev[i]) continue; - netif_wake_queue(eth->netdev[i]); + netif_tx_wake_all_queues(eth->netdev[i]); } } @@ -1386,7 +1461,7 @@ static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) tx_num = mtk_cal_txd_req(eth, skb); if (unlikely(atomic_read(&ring->free_count) <= tx_num)) { - netif_stop_queue(dev); + netif_tx_stop_all_queues(dev); netif_err(eth, tx_queued, dev, "Tx Ring full when queue awake!\n"); spin_unlock(ð->page_lock); @@ -1412,7 +1487,7 @@ static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) goto drop; if (unlikely(atomic_read(&ring->free_count) <= ring->thresh)) - netif_stop_queue(dev); + netif_tx_stop_all_queues(dev); spin_unlock(ð->page_lock); @@ -1579,10 +1654,12 @@ static int mtk_xdp_submit_frame(struct mtk_eth *eth, struct xdp_frame *xdpf, struct skb_shared_info *sinfo = xdp_get_shared_info_from_frame(xdpf); const struct mtk_soc_data *soc = eth->soc; struct mtk_tx_ring *ring = ð->tx_ring; + struct mtk_mac *mac = netdev_priv(dev); struct mtk_tx_dma_desc_info txd_info = { .size = xdpf->len, .first = true, .last = !xdp_frame_has_frags(xdpf), + .qid = mac->id, }; int err, index = 0, n_desc = 1, nr_frags; struct mtk_tx_buf *htx_buf, *tx_buf; @@ -1632,6 +1709,7 @@ static int mtk_xdp_submit_frame(struct mtk_eth *eth, struct xdp_frame *xdpf, memset(&txd_info, 0, sizeof(struct mtk_tx_dma_desc_info)); txd_info.size = skb_frag_size(&sinfo->frags[index]); txd_info.last = index + 1 == nr_frags; + txd_info.qid = mac->id; data = skb_frag_address(&sinfo->frags[index]); index++; @@ -1986,8 +2064,46 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, return done; } +struct mtk_poll_state { + struct netdev_queue *txq; + unsigned int total; + unsigned int done; + unsigned int bytes; +}; + +static void +mtk_poll_tx_done(struct mtk_eth *eth, struct mtk_poll_state *state, u8 mac, + struct sk_buff *skb) +{ + struct netdev_queue *txq; + struct net_device *dev; + unsigned int bytes = skb->len; + + state->total++; + eth->tx_packets++; + eth->tx_bytes += bytes; + + dev = eth->netdev[mac]; + if (!dev) + return; + + txq = netdev_get_tx_queue(dev, skb_get_queue_mapping(skb)); + if (state->txq == txq) { + state->done++; + state->bytes += bytes; + return; + } + + if (state->txq) + netdev_tx_completed_queue(state->txq, state->done, state->bytes); + + state->txq = txq; + state->done = 1; + state->bytes = bytes; +} + static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget, - unsigned int *done, unsigned int *bytes) + struct mtk_poll_state *state) { const struct mtk_reg_map *reg_map = eth->soc->reg_map; struct mtk_tx_ring *ring = ð->tx_ring; @@ -2019,12 +2135,9 @@ static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget, break; if (tx_buf->data != (void *)MTK_DMA_DUMMY_DESC) { - if (tx_buf->type == MTK_TYPE_SKB) { - struct sk_buff *skb = tx_buf->data; + if (tx_buf->type == MTK_TYPE_SKB) + mtk_poll_tx_done(eth, state, mac, tx_buf->data); - bytes[mac] += skb->len; - done[mac]++; - } budget--; } mtk_tx_unmap(eth, tx_buf, &bq, true); @@ -2043,7 +2156,7 @@ static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget, } static int mtk_poll_tx_pdma(struct mtk_eth *eth, int budget, - unsigned int *done, unsigned int *bytes) + struct mtk_poll_state *state) { struct mtk_tx_ring *ring = ð->tx_ring; struct mtk_tx_buf *tx_buf; @@ -2061,12 +2174,8 @@ static int mtk_poll_tx_pdma(struct mtk_eth *eth, int budget, break; if (tx_buf->data != (void *)MTK_DMA_DUMMY_DESC) { - if (tx_buf->type == MTK_TYPE_SKB) { - struct sk_buff *skb = tx_buf->data; - - bytes[0] += skb->len; - done[0]++; - } + if (tx_buf->type == MTK_TYPE_SKB) + mtk_poll_tx_done(eth, state, 0, tx_buf->data); budget--; } mtk_tx_unmap(eth, tx_buf, &bq, true); @@ -2088,26 +2197,15 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget) { struct mtk_tx_ring *ring = ð->tx_ring; struct dim_sample dim_sample = {}; - unsigned int done[MTK_MAX_DEVS]; - unsigned int bytes[MTK_MAX_DEVS]; - int total = 0, i; - - memset(done, 0, sizeof(done)); - memset(bytes, 0, sizeof(bytes)); + struct mtk_poll_state state = {}; if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) - budget = mtk_poll_tx_qdma(eth, budget, done, bytes); + budget = mtk_poll_tx_qdma(eth, budget, &state); else - budget = mtk_poll_tx_pdma(eth, budget, done, bytes); + budget = mtk_poll_tx_pdma(eth, budget, &state); - for (i = 0; i < MTK_MAC_COUNT; i++) { - if (!eth->netdev[i] || !done[i]) - continue; - netdev_completed_queue(eth->netdev[i], done[i], bytes[i]); - total += done[i]; - eth->tx_packets += done[i]; - eth->tx_bytes += bytes[i]; - } + if (state.txq) + netdev_tx_completed_queue(state.txq, state.done, state.bytes); dim_update_sample(eth->tx_events, eth->tx_packets, eth->tx_bytes, &dim_sample); @@ -2117,7 +2215,7 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget) (atomic_read(&ring->free_count) > ring->thresh)) mtk_wake_queue(eth); - return total; + return state.total; } static void mtk_handle_status_irq(struct mtk_eth *eth) @@ -2203,6 +2301,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth) int i, sz = soc->txrx.txd_size; struct mtk_tx_dma_v2 *txd; int ring_size; + u32 ofs, val; if (MTK_HAS_CAPS(soc->caps, MTK_QDMA)) ring_size = MTK_QDMA_RING_SIZE; @@ -2270,8 +2369,25 @@ static int mtk_tx_alloc(struct mtk_eth *eth) ring->phys + ((ring_size - 1) * sz), soc->reg_map->qdma.crx_ptr); mtk_w32(eth, ring->last_free_ptr, soc->reg_map->qdma.drx_ptr); - mtk_w32(eth, (QDMA_RES_THRES << 8) | QDMA_RES_THRES, - soc->reg_map->qdma.qtx_cfg); + + for (i = 0, ofs = 0; i < MTK_QDMA_NUM_QUEUES; i++) { + val = (QDMA_RES_THRES << 8) | QDMA_RES_THRES; + mtk_w32(eth, val, soc->reg_map->qdma.qtx_cfg + ofs); + + val = MTK_QTX_SCH_MIN_RATE_EN | + /* minimum: 10 Mbps */ + FIELD_PREP(MTK_QTX_SCH_MIN_RATE_MAN, 1) | + FIELD_PREP(MTK_QTX_SCH_MIN_RATE_EXP, 4) | + MTK_QTX_SCH_LEAKY_BUCKET_SIZE; + if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) + val |= MTK_QTX_SCH_LEAKY_BUCKET_EN; + mtk_w32(eth, val, soc->reg_map->qdma.qtx_sch + ofs); + ofs += MTK_QTX_OFFSET; + } + val = MTK_QDMA_TX_SCH_MAX_WFQ | (MTK_QDMA_TX_SCH_MAX_WFQ << 16); + mtk_w32(eth, val, soc->reg_map->qdma.tx_sch_rate); + if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) + mtk_w32(eth, val, soc->reg_map->qdma.tx_sch_rate + 4); } else { mtk_w32(eth, ring->phys_pdma, MT7628_TX_BASE_PTR0); mtk_w32(eth, ring_size, MT7628_TX_MAX_CNT0); @@ -2936,7 +3052,7 @@ static int mtk_start_dma(struct mtk_eth *eth) if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) val |= MTK_MUTLI_CNT | MTK_RESV_BUF | MTK_WCOMP_EN | MTK_DMAD_WR_WDONE | - MTK_CHK_DDONE_EN; + MTK_CHK_DDONE_EN | MTK_LEAKY_BUCKET_EN; else val |= MTK_RX_BT_32DWORDS; mtk_w32(eth, val, reg_map->qdma.glo_cfg); @@ -2982,6 +3098,45 @@ static void mtk_gdm_config(struct mtk_eth *eth, u32 config) mtk_w32(eth, 0, MTK_RST_GL); } +static int mtk_device_event(struct notifier_block *n, unsigned long event, void *ptr) +{ + struct mtk_mac *mac = container_of(n, struct mtk_mac, device_notifier); + struct mtk_eth *eth = mac->hw; + struct net_device *dev = netdev_notifier_info_to_dev(ptr); + struct ethtool_link_ksettings s; + struct net_device *ldev; + struct list_head *iter; + struct dsa_port *dp; + + if (event != NETDEV_CHANGE) + return NOTIFY_DONE; + + netdev_for_each_lower_dev(dev, ldev, iter) { + if (netdev_priv(ldev) == mac) + goto found; + } + + return NOTIFY_DONE; + +found: + if (!dsa_slave_dev_check(dev)) + return NOTIFY_DONE; + + if (__ethtool_get_link_ksettings(dev, &s)) + return NOTIFY_DONE; + + if (s.base.speed == 0 || s.base.speed == ((__u32)-1)) + return NOTIFY_DONE; + + dp = dsa_port_from_netdev(dev); + if (dp->index >= MTK_QDMA_NUM_QUEUES) + return NOTIFY_DONE; + + mtk_set_queue_speed(eth, dp->index + 3, s.base.speed); + + return NOTIFY_DONE; +} + static int mtk_open(struct net_device *dev) { struct mtk_mac *mac = netdev_priv(dev); @@ -3022,7 +3177,8 @@ static int mtk_open(struct net_device *dev) refcount_inc(ð->dma_refcnt); phylink_start(mac->phylink); - netif_start_queue(dev); + netif_tx_start_all_queues(dev); + return 0; } @@ -3538,8 +3694,12 @@ static int mtk_unreg_dev(struct mtk_eth *eth) int i; for (i = 0; i < MTK_MAC_COUNT; i++) { + struct mtk_mac *mac; if (!eth->netdev[i]) continue; + mac = netdev_priv(eth->netdev[i]); + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) + unregister_netdevice_notifier(&mac->device_notifier); unregister_netdev(eth->netdev[i]); } @@ -3755,6 +3915,24 @@ static int mtk_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) return ret; } +static u16 mtk_select_queue(struct net_device *dev, struct sk_buff *skb, + struct net_device *sb_dev) +{ + struct mtk_mac *mac = netdev_priv(dev); + unsigned int queue = 0; + + if (netdev_uses_dsa(dev)) + queue = skb_get_queue_mapping(skb); + + if (!queue) + queue = mac->id; + + if (queue >= dev->num_tx_queues) + queue = 0; + + return queue; +} + static const struct ethtool_ops mtk_ethtool_ops = { .get_link_ksettings = mtk_get_link_ksettings, .set_link_ksettings = mtk_set_link_ksettings, @@ -3790,6 +3968,7 @@ static const struct net_device_ops mtk_netdev_ops = { .ndo_setup_tc = mtk_eth_setup_tc, .ndo_bpf = mtk_xdp, .ndo_xdp_xmit = mtk_xdp_xmit, + .ndo_select_queue = mtk_select_queue, }; static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) @@ -3799,6 +3978,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) struct phylink *phylink; struct mtk_mac *mac; int id, err; + int txqs = 1; if (!_id) { dev_err(eth->dev, "missing mac id\n"); @@ -3816,7 +3996,10 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) return -EINVAL; } - eth->netdev[id] = alloc_etherdev(sizeof(*mac)); + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) + txqs = MTK_QDMA_NUM_QUEUES; + + eth->netdev[id] = alloc_etherdev_mqs(sizeof(*mac), txqs, 1); if (!eth->netdev[id]) { dev_err(eth->dev, "alloc_etherdev failed\n"); return -ENOMEM; @@ -3913,6 +4096,11 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) else eth->netdev[id]->max_mtu = MTK_MAX_RX_LENGTH_2K - MTK_RX_ETH_HLEN; + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { + mac->device_notifier.notifier_call = mtk_device_event; + register_netdevice_notifier(&mac->device_notifier); + } + return 0; free_netdev: diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 7c0b6c0c05d8..8123a646ba0a 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -22,6 +22,7 @@ #include #include "mtk_ppe.h" +#define MTK_QDMA_NUM_QUEUES 16 #define MTK_QDMA_PAGE_SIZE 2048 #define MTK_MAX_RX_LENGTH 1536 #define MTK_MAX_RX_LENGTH_2K 2048 @@ -203,8 +204,26 @@ #define MTK_RING_MAX_AGG_CNT_H ((MTK_HW_LRO_MAX_AGG_CNT >> 6) & 0x3) /* QDMA TX Queue Configuration Registers */ +#define MTK_QTX_OFFSET 0x10 #define QDMA_RES_THRES 4 +/* QDMA Tx Queue Scheduler Configuration Registers */ +#define MTK_QTX_SCH_TX_SEL BIT(31) +#define MTK_QTX_SCH_TX_SEL_V2 GENMASK(31, 30) + +#define MTK_QTX_SCH_LEAKY_BUCKET_EN BIT(30) +#define MTK_QTX_SCH_LEAKY_BUCKET_SIZE GENMASK(29, 28) +#define MTK_QTX_SCH_MIN_RATE_EN BIT(27) +#define MTK_QTX_SCH_MIN_RATE_MAN GENMASK(26, 20) +#define MTK_QTX_SCH_MIN_RATE_EXP GENMASK(19, 16) +#define MTK_QTX_SCH_MAX_RATE_WEIGHT GENMASK(15, 12) +#define MTK_QTX_SCH_MAX_RATE_EN BIT(11) +#define MTK_QTX_SCH_MAX_RATE_MAN GENMASK(10, 4) +#define MTK_QTX_SCH_MAX_RATE_EXP GENMASK(3, 0) + +/* QDMA TX Scheduler Rate Control Register */ +#define MTK_QDMA_TX_SCH_MAX_WFQ BIT(15) + /* QDMA Global Configuration Register */ #define MTK_RX_2B_OFFSET BIT(31) #define MTK_RX_BT_32DWORDS (3 << 11) @@ -223,6 +242,7 @@ #define MTK_WCOMP_EN BIT(24) #define MTK_RESV_BUF (0x40 << 16) #define MTK_MUTLI_CNT (0x4 << 12) +#define MTK_LEAKY_BUCKET_EN BIT(11) /* QDMA Flow Control Register */ #define FC_THRES_DROP_MODE BIT(20) @@ -251,8 +271,6 @@ #define MTK_STAT_OFFSET 0x40 /* QDMA TX NUM */ -#define MTK_QDMA_TX_NUM 16 -#define MTK_QDMA_TX_MASK (MTK_QDMA_TX_NUM - 1) #define QID_BITS_V2(x) (((x) & 0x3f) << 16) #define MTK_QDMA_GMAC2_QID 8 @@ -282,6 +300,7 @@ #define TX_DMA_PLEN0(x) (((x) & eth->soc->txrx.dma_max_len) << eth->soc->txrx.dma_len_offset) #define TX_DMA_PLEN1(x) ((x) & eth->soc->txrx.dma_max_len) #define TX_DMA_SWC BIT(14) +#define TX_DMA_PQID GENMASK(3, 0) /* PDMA on MT7628 */ #define TX_DMA_DONE BIT(31) @@ -940,6 +959,7 @@ struct mtk_reg_map { } pdma; struct { u32 qtx_cfg; /* tx queue configuration */ + u32 qtx_sch; /* tx queue scheduler configuration */ u32 rx_ptr; /* rx base pointer */ u32 rx_cnt_cfg; /* rx max count configuration */ u32 qcrx_ptr; /* rx cpu pointer */ @@ -957,6 +977,7 @@ struct mtk_reg_map { u32 fq_tail; /* fq tail pointer */ u32 fq_count; /* fq free page count */ u32 fq_blen; /* fq free page buffer length */ + u32 tx_sch_rate; /* tx scheduler rate control registers */ } qdma; u32 gdm1_cnt; u32 gdma_to_ppe; @@ -1148,6 +1169,7 @@ struct mtk_mac { __be32 hwlro_ip[MTK_MAX_LRO_IP_CNT]; int hwlro_ip_cnt; unsigned int syscfg0; + struct notifier_block device_notifier; }; /* the struct describing the SoC. these are declared in the soc_xyz.c files */ From patchwork Mon Nov 7 18:54:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2234390wru; Mon, 7 Nov 2022 11:02:48 -0800 (PST) X-Google-Smtp-Source: AMsMyM7niQNUXkwyucabvrRFFJaxwcmUZO0fI2Qf6AYgiP6b/msSIb8eGH8LLThuWcfp84vBrPk5 X-Received: by 2002:a63:2221:0:b0:43b:f4a3:80cc with SMTP id i33-20020a632221000000b0043bf4a380ccmr43950868pgi.367.1667847768414; Mon, 07 Nov 2022 11:02:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847768; cv=none; d=google.com; s=arc-20160816; b=zwlUFnktqZ5uOwCqRMGn9cXS9Bb/Mmh5W9/KsW8zHZEichK5ylUNuVWn/Hl4dcnHVE dydqk9/yTHLnQ4YcacLiwG+Bh/mX9pNkgX/3HahRyS5g9PN21WYsYcvPvX+RnX3E9lpC cJegukVgAh2hneySN+e/j6CFutcHzHBVH7a395J9MAB6vMDLbzUsgAKKcE1MScGO4Dcm jpV81YUuoXGWt1FHJr4MbO7zUk7BlK8ghRBclg5jO1w6FSEKKcEe1uHjKkodiLj5FxFy vunRDEmQCnsFdnua85CG/UyOW7b/tgC1x9BfkGhiQ/x9KLDlINFgbgwdG9VkfetGIHn9 Kk1Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NK0vwwMtxTTinLUgl7QN7r2/pgagKlFgwncSbFJ9IGE=; b=nwMExM+h7CTU6jWss+2ah3eIxzmcVbn03x4JHS2McMd9/p7h13HptRnBv6beFs7WSn gvBs7OzD4nRV2p7yZTapiXoL9A1O5xexU2hSvPWsfZQy3AspDdgG+76khtdXH9+ekBis Mjlgax/va5t7oxYLyx0/G/PRV1oEqJ9Ei9Z/Yz4o/EDO+haQ5pibnRL22AoUUakR+rdt DFCYj2kyj5KlBY6zPijzNNFSnrtNf7I9VEKYZoYcbdWhMeNqa4UroBQLYqBe/NevrRqr BOovZvZEHyu3cJnv+l/5HF0EiVHlvrAKK4D9WxWx8Hkw+O+t5nCf3H5s/ArkfrhzmppV yKSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=sJ+LgM5z; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ng17-20020a17090b1a9100b00213f1db312esi12408342pjb.111.2022.11.07.11.02.28; Mon, 07 Nov 2022 11:02:48 -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=fail header.i=@nbd.name header.s=20160729 header.b=sJ+LgM5z; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233192AbiKGSzu (ORCPT + 99 others); Mon, 7 Nov 2022 13:55:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233014AbiKGSzg (ORCPT ); Mon, 7 Nov 2022 13:55:36 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17F9825C6C; Mon, 7 Nov 2022 10:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=NK0vwwMtxTTinLUgl7QN7r2/pgagKlFgwncSbFJ9IGE=; b=sJ+LgM5ziaaaPM0CuCZo65AOfB HWLCQirev7CCzYmWCu8yMaIDJkFWFYjnfRDENxFFebEFSfHE41tnx5PNJsn7BiQBCZNHdeaGk8wSV BRjEiGZ6x8IycT9E6tyxeE6o8u+sqnS+f3TAaYN+t8ZyEcg/W2zo8HVBgU+eJLTsAO8I=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HB-000LCc-Td; Mon, 07 Nov 2022 19:55:18 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, Sean Wang , Landen Chao , DENG Qingfang , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/14] net: dsa: tag_mtk: assign per-port queues Date: Mon, 7 Nov 2022 19:54:43 +0100 Message-Id: <20221107185452.90711-5-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748865141519672660?= X-GMAIL-MSGID: =?utf-8?q?1748865141519672660?= Keeps traffic sent to the switch within link speed limits Signed-off-by: Felix Fietkau --- net/dsa/tag_mtk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index 415d8ece242a..445d6113227f 100644 --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c @@ -25,6 +25,9 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb, u8 xmit_tpid; u8 *mtk_tag; + /* Reserve the first three queues for packets not passed through DSA */ + skb_set_queue_mapping(skb, 3 + dp->index); + /* Build the special tag after the MAC Source Address. If VLAN header * is present, it's required that VLAN header and special tag is * being combined. Only in this way we can allow the switch can parse From patchwork Mon Nov 7 18:54:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2235092wru; Mon, 7 Nov 2022 11:03:56 -0800 (PST) X-Google-Smtp-Source: AMsMyM53phd2bzdCgkBcDn2euiIIZnbV9WyxSQFo79FGjyWnw7BWDwx31BO/iMx2Rb/wzDu9dxDk X-Received: by 2002:a05:6a00:1a0f:b0:56e:32a2:abcf with SMTP id g15-20020a056a001a0f00b0056e32a2abcfmr26674984pfv.35.1667847836628; Mon, 07 Nov 2022 11:03:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847836; cv=none; d=google.com; s=arc-20160816; b=ZnxQ7y2Ul6Qnw9xIfa5ran8IXXXIhYyvzbWf4gcICoCZuPYtyAzCZuwa6FirWRt6XG zV+WaG76Lgsr3P+INwSNQyVilzm8Yne247aye8rE9FydWz1IJGz2W9yxaTgU28Wgl29t XKZxcgobP2hWJnHtRpUxdM6aLRr9ToN7JeiY8QzWOnHHK1QqbVz9s9ZI2THwR2YBuFXA KpTHVgye/GIfQLC5PjDif9fvAOqd4I/BP52G9W9tW6i2T6I9icxW3Pv8Z9R6ibbajCOy 4sFdsfj9cZPHa6D8TsvJSnDqIOtbIJbS1r1F9qPbAwPAejOxm+X7afcPq4nqIWpE8nra UhJA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/rqSZTPHTzjvgQiKEtydX5Kmlo97LMyPbAHh98dxziY=; b=EmEn9hGYM/HK1c1JRxu67Aq+AQHFTCFzhG05DLdVWC8CVaNP3pV4844fJCu/AOl50Q s+Mz8ZZYVuaMvypo0AZ373bil3edRrM6PQLhTXdUDVBMgxRKCGLW40wpgDF1W3ed9uOp GPVhuYUTQVvXpFPngErFih07FnQe8JMYPp7m+DGE4rjPVrNBstDlQsApqy25mx03kub2 8iTXyvX1UltXyaOXt4V3YpeLAL3Jq8358zspclP9ojuCw3W8uMsQREahiryFERzB0CQG 2yJcV9t2+y1PDSafLBtwpCKwrBAW8J1XRZCaeUaTjlmLVAc492mK7yK1e4n7Kf1deSi7 nUYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=QiNJ9y0C; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u22-20020a056a00159600b0056da577864fsi11562574pfk.241.2022.11.07.11.03.43; Mon, 07 Nov 2022 11:03:56 -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=fail header.i=@nbd.name header.s=20160729 header.b=QiNJ9y0C; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232288AbiKGS4E (ORCPT + 99 others); Mon, 7 Nov 2022 13:56:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233008AbiKGSzh (ORCPT ); Mon, 7 Nov 2022 13:55:37 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 219E625C46; Mon, 7 Nov 2022 10:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/rqSZTPHTzjvgQiKEtydX5Kmlo97LMyPbAHh98dxziY=; b=QiNJ9y0CU7S6HdL+LIYEMgWcTJ 9JXq+skySFZKj3nCqLYdcXlmbpMTWN/f/v1DfSDA3vEvK2QyTTaJ7j5K3f1BZQLo6LyOLqRq+g2cJ 0m3pX8BBmsN/ccKmiS3Yp3Qd8O2kbfP7ANA0v6vnxJNir1PVjS6qf23bS4o6aSaZpo04=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HC-000LCc-Ol; Mon, 07 Nov 2022 19:55:18 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/14] net: ethernet: mediatek: ppe: assign per-port queues for offloaded traffic Date: Mon, 7 Nov 2022 19:54:44 +0100 Message-Id: <20221107185452.90711-6-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748865213119707338?= X-GMAIL-MSGID: =?utf-8?q?1748865213119707338?= Keeps traffic sent to the switch within link speed limits Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_ppe.c | 18 ++++++++++++++++++ drivers/net/ethernet/mediatek/mtk_ppe.h | 4 ++++ .../net/ethernet/mediatek/mtk_ppe_offload.c | 12 +++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c index 3ee2bf53f9e5..96ad0a9b79b4 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c @@ -399,6 +399,24 @@ int mtk_foe_entry_set_wdma(struct mtk_eth *eth, struct mtk_foe_entry *entry, return 0; } +int mtk_foe_entry_set_queue(struct mtk_eth *eth, struct mtk_foe_entry *entry, + unsigned int queue) +{ + u32 *ib2 = mtk_foe_entry_ib2(eth, entry); + + if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { + *ib2 &= ~MTK_FOE_IB2_QID_V2; + *ib2 |= FIELD_PREP(MTK_FOE_IB2_QID_V2, queue); + *ib2 |= MTK_FOE_IB2_PSE_QOS_V2; + } else { + *ib2 &= ~MTK_FOE_IB2_QID; + *ib2 |= FIELD_PREP(MTK_FOE_IB2_QID, queue); + *ib2 |= MTK_FOE_IB2_PSE_QOS; + } + + return 0; +} + static bool mtk_flow_entry_match(struct mtk_eth *eth, struct mtk_flow_entry *entry, struct mtk_foe_entry *data) diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.h b/drivers/net/ethernet/mediatek/mtk_ppe.h index 0b7a67a958e4..be635864bb96 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe.h +++ b/drivers/net/ethernet/mediatek/mtk_ppe.h @@ -68,7 +68,9 @@ enum { #define MTK_FOE_IB2_DSCP GENMASK(31, 24) /* CONFIG_MEDIATEK_NETSYS_V2 */ +#define MTK_FOE_IB2_QID_V2 GENMASK(6, 0) #define MTK_FOE_IB2_PORT_MG_V2 BIT(7) +#define MTK_FOE_IB2_PSE_QOS_V2 BIT(8) #define MTK_FOE_IB2_DEST_PORT_V2 GENMASK(12, 9) #define MTK_FOE_IB2_MULTICAST_V2 BIT(13) #define MTK_FOE_IB2_WDMA_WINFO_V2 BIT(19) @@ -350,6 +352,8 @@ int mtk_foe_entry_set_pppoe(struct mtk_eth *eth, struct mtk_foe_entry *entry, int sid); int mtk_foe_entry_set_wdma(struct mtk_eth *eth, struct mtk_foe_entry *entry, int wdma_idx, int txq, int bss, int wcid); +int mtk_foe_entry_set_queue(struct mtk_eth *eth, struct mtk_foe_entry *entry, + unsigned int queue); int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); void mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); int mtk_foe_entry_idle_time(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); diff --git a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c index 28bbd1df3e30..81afd5ee3fbf 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c @@ -188,7 +188,7 @@ mtk_flow_set_output_device(struct mtk_eth *eth, struct mtk_foe_entry *foe, int *wed_index) { struct mtk_wdma_info info = {}; - int pse_port, dsa_port; + int pse_port, dsa_port, queue; if (mtk_flow_get_wdma_info(dev, dest_mac, &info) == 0) { mtk_foe_entry_set_wdma(eth, foe, info.wdma_idx, info.queue, @@ -212,8 +212,6 @@ mtk_flow_set_output_device(struct mtk_eth *eth, struct mtk_foe_entry *foe, } dsa_port = mtk_flow_get_dsa_port(&dev); - if (dsa_port >= 0) - mtk_foe_entry_set_dsa(eth, foe, dsa_port); if (dev == eth->netdev[0]) pse_port = 1; @@ -222,6 +220,14 @@ mtk_flow_set_output_device(struct mtk_eth *eth, struct mtk_foe_entry *foe, else return -EOPNOTSUPP; + if (dsa_port >= 0) { + mtk_foe_entry_set_dsa(eth, foe, dsa_port); + queue = 3 + dsa_port; + } else { + queue = pse_port - 1; + } + mtk_foe_entry_set_queue(eth, foe, queue); + out: mtk_foe_entry_set_pse_port(eth, foe, pse_port); From patchwork Mon Nov 7 18:54:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2234228wru; Mon, 7 Nov 2022 11:02:33 -0800 (PST) X-Google-Smtp-Source: AMsMyM49gh9oSVz9/wMRyllwTVa5YFJTnOVFO6gq4Is6vrHV7IDCrw2d0Z6eiJe6pSABnFrfq5DV X-Received: by 2002:a05:6a02:207:b0:46f:53ca:cab8 with SMTP id bh7-20020a056a02020700b0046f53cacab8mr43166157pgb.242.1667847753221; Mon, 07 Nov 2022 11:02:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847753; cv=none; d=google.com; s=arc-20160816; b=hrDn4xepZHhMQp3Sr3w8AH6pi4XZou6ZvO3VvPUO7XjUD08aZIcAN4DvO3Mxx5n/rl IbuY3ChcfxiqbKyKKD1eVA1na6uGme5HEv+DZfkp1nAhwcUoFnfecPl1UxBnpvYwgyxH Xpl8IwS+OgWg/oc52oKWNtpwwpBsQN+sFQMYMFLiECTULU/wI/WBxpjqX0LjDiDGJvij zGpCCNAuWKBjgo7GFGsRGLOSGdDU1NHe9yTpneNM2DtCe1+teT2oezRzGMfEJeLvRU6c jzagmKz0SD/FiBWAQZmcFcS5+cgBcPCrFR1kDVwyPBsiOSOCLLyC/F9iXzOkCCTgPfIr qJLw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MIPw6Fj4eUcqK2lXqmxVDqLdzLAH3cHlKhsCRY7ov/c=; b=nRh5yUiEaUckIWeEx8vKQfyKyNoLC+Lx1fqPC3OKAXE32rx4kfI2ZM4qadkvySb0mQ D+lOI3lIuY9Q5Uefx5JdkMJ81CwTG7bteRfC4fGethZcr25C5kLjxj3edAy2I4SCX5eQ Lr8Uo35KC+RG76cbz+O7RdgoE2Yu5hrMw+pmWdmjOmBslwmfhHoY0NN6/r8Bas5g+dPd 6aiajAo9/8sAa9nj1RLibg4pXU5n8oBF5bl70KwIMqFzYtf/cRXPrcmCECSzABLllg86 zCdkZAac5vuT5U5T4zLjCl3obyxhChjdZ4Jf/mrBwGipJhzZFY95h9kvPEyYHc2d/8Kl Dhiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=IxaTc7l7; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k14-20020a170902c40e00b0017d9b373175si13961724plk.415.2022.11.07.11.02.08; Mon, 07 Nov 2022 11:02: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=fail header.i=@nbd.name header.s=20160729 header.b=IxaTc7l7; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233176AbiKGSz7 (ORCPT + 99 others); Mon, 7 Nov 2022 13:55:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233038AbiKGSzg (ORCPT ); Mon, 7 Nov 2022 13:55:36 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23192717A; Mon, 7 Nov 2022 10:55:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=MIPw6Fj4eUcqK2lXqmxVDqLdzLAH3cHlKhsCRY7ov/c=; b=IxaTc7l7M1626+mMfOlWwYXuxi LnHo0KamGTSoQ1smd59tNgKlLBEBJwpdhCMCudyffzOcVE/IKehIjoFmppTg28GSXX5Z5h2fksoMe UpsTQh0KlLbwv3qIsltPHgqGQGbYJGBg7fgNKYj0C7OOVAmL+E5EJpMyBHQ71PFqNdfY=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HD-000LCc-G5; Mon, 07 Nov 2022 19:55:19 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/14] net: ethernet: mtk_eth_soc: compile out netsys v2 code on mt7621 Date: Mon, 7 Nov 2022 19:54:45 +0100 Message-Id: <20221107185452.90711-7-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748865125440681040?= X-GMAIL-MSGID: =?utf-8?q?1748865125440681040?= Avoid some branches in the hot path on low-end devices with limited CPU power, and reduce code size Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 8123a646ba0a..e09b2483c70c 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -905,7 +905,13 @@ enum mkt_eth_capabilities { #define MTK_MUX_GMAC12_TO_GEPHY_SGMII \ (MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII | MTK_MUX) -#define MTK_HAS_CAPS(caps, _x) (((caps) & (_x)) == (_x)) +#ifdef CONFIG_SOC_MT7621 +#define MTK_CAP_MASK MTK_NETSYS_V2 +#else +#define MTK_CAP_MASK 0 +#endif + +#define MTK_HAS_CAPS(caps, _x) (((caps) & (_x) & ~(MTK_CAP_MASK)) == (_x)) #define MT7621_CAPS (MTK_GMAC1_RGMII | MTK_GMAC1_TRGMII | \ MTK_GMAC2_RGMII | MTK_SHARED_INT | \ From patchwork Mon Nov 7 18:54:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16642 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2234289wru; Mon, 7 Nov 2022 11:02:40 -0800 (PST) X-Google-Smtp-Source: AMsMyM5Llu7GhsNlgpytaxpVPfgk29this4h9/180ds4cAamOHNNQZ2P3CZXTPVtUYY8JQj+LI+J X-Received: by 2002:a17:902:74c3:b0:182:57fa:b9c4 with SMTP id f3-20020a17090274c300b0018257fab9c4mr52297768plt.104.1667847760099; Mon, 07 Nov 2022 11:02:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847760; cv=none; d=google.com; s=arc-20160816; b=nRmv6+bLwu1OmeVLV3ZaY29zdic6jj0uKRqniHX6GiUZw4NBCDVDVCFCmca/HNikym K/UyA0FGsPHzsCcDX30PNOqwO5MfzEpPK9U1k4pelW9TIFi3DZzeiNiLIaSQQvYY8qN4 PtejmHMWu07t85i5WntMYEGXJi1YD9eajtj4xpe9qdL/JvjW3r8elK4iEP/61sT6f6gb 7TFfJY70cHXf6h5QydbZJHWAcToTlaJH8dZWwLeG+uhK3C+DWkuPdoh9Q5FjctANP45p /uJ2HVTxO8vYa1UV0JG3JQur0XDaLqd4MUMa+lsN4OjVy67xlaiPXOXgaVZ1HyCz3NLT P4Iw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rEqDOzrzv1cA6N1C5HIe09p8JEcexs62RmH77rmkVQs=; b=glFyq6m+G2XayF3fH1vTYaSlbdbDsAukbboEx7kWi3wivEjxBhlNFdFWcxtqfijzd0 zzeKlhhV624TECfN0OKTjCyDvzDFkOR3vlphfMdL+IcT9DRqlWIRWfYKiDc4wi0Iv2zD tk4f0dN58XJ0aPdqr0+s01NFa/6NrmvGxUQMkXb+gRC7VfGaI7lHSdrOzzQ72pyjeReS dY7VyKnXAUx7qX7r88aGpHvEGFdCANSU327thfn4AjvLK5OcF5aP8RTNMGVZxurCKoOA T3HgfxuvqQdbRyAmRsW6fUy2O6LF0Wx1QuvxsafoynTbWBtiLvUuPfbGxGFb3/+z41gB ExQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=IWCk0ao9; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a10-20020a17090abe0a00b002119e6aa0casi9588089pjs.43.2022.11.07.11.02.16; Mon, 07 Nov 2022 11:02:40 -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=fail header.i=@nbd.name header.s=20160729 header.b=IWCk0ao9; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232952AbiKGSzc (ORCPT + 99 others); Mon, 7 Nov 2022 13:55:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231426AbiKGSza (ORCPT ); Mon, 7 Nov 2022 13:55:30 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A295E1139; Mon, 7 Nov 2022 10:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=rEqDOzrzv1cA6N1C5HIe09p8JEcexs62RmH77rmkVQs=; b=IWCk0ao9veAQ5SBFD7O1oI/aTQ GbtUnG5IY6yzXmxO80j7/qvUBvKANFx+UwIqk1AfavoCvx+IqEkX2WhxEQOFtScwjsRR7iLO1Ff0t ebQVzDPNmEdZ9cbPfjYABI16FwypzAgvh2lXtSyakE/kbFZXPYxxnQ1OscuWonR+iRsY=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HE-000LCc-0p; Mon, 07 Nov 2022 19:55:20 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org Subject: [PATCH 08/14] net: vlan: remove invalid VLAN protocol warning Date: Mon, 7 Nov 2022 19:54:46 +0100 Message-Id: <20221107185452.90711-8-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748865132692295865?= X-GMAIL-MSGID: =?utf-8?q?1748865132692295865?= On MTK SoC ethernet, using NETIF_F_HW_VLAN_CTAG_RX in combination with hardware special tag parsing can pass the special tag port metadata as VLAN protocol ID. When the results is added as a skb hwaccel VLAN tag, it triggers a warning from vlan_do_receive before calling the DSA tag receive function. Remove this warning in order to properly pass the tag to the DSA receive function, which will parse and clear it. Signed-off-by: Felix Fietkau --- net/8021q/vlan.h | 1 - 1 file changed, 1 deletion(-) diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h index 5eaf38875554..3f9c0406b266 100644 --- a/net/8021q/vlan.h +++ b/net/8021q/vlan.h @@ -44,7 +44,6 @@ static inline int vlan_proto_idx(__be16 proto) case htons(ETH_P_8021AD): return VLAN_PROTO_8021AD; default: - WARN(1, "invalid VLAN protocol: 0x%04x\n", ntohs(proto)); return -EINVAL; } } From patchwork Mon Nov 7 18:54:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16638 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2233706wru; Mon, 7 Nov 2022 11:01:42 -0800 (PST) X-Google-Smtp-Source: AMsMyM7vTw2NTEUYsDmyliShw9njUZEHkG/gb8iw1o4P0Eday/dYlSiZs8WcKwQDl7KzoO1y4KG9 X-Received: by 2002:a63:5d0b:0:b0:464:bb2b:9b0e with SMTP id r11-20020a635d0b000000b00464bb2b9b0emr43412926pgb.583.1667847701774; Mon, 07 Nov 2022 11:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847701; cv=none; d=google.com; s=arc-20160816; b=gv0pDYc6Usvl1w+fcouLE8Z2BXoA63XsL/2xutLH5p8CgAjXTdCgt0Ua8ifS3VX6jY ExT3ZTyVyoxe7HT1NZSmRK3A5CiznnhvQORK7BCmNXJv8zllPfDJfpkPVFjIJmPxkZHZ QT6bWO7b0elfxf1R5Z/C7Rl1PK3lsJjCWusGC0/ZUQ/e+7QsHoyIxygHCE/Ac/ddwgNe eG5QNOdmNEhtOWm0GfTUFwie9f/fXbaMV6V78mDjQkVHUEARNd3KFzhnmN2DHQD+iNOi YzA9wut9JMbSmOo8iNx4eHDkVKTNFD0nylZ/FNY7b+z7t3FfafAVgDK2AykaxVZN1zoB zAww== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=itzNjPSgtI5YQ3ZzVEgPaMFuJJoHJB+VuPcGUc7XBPA=; b=Nun3holaGACJ9JzK9ct81gAtK2mpixXc1115yIG6RCjBWB3EcvLHUH5TVfj4bUD7vH vBrGBuT0DzgkGgcZNAP0kHWVlEASXelvmzXT0YBHUJcujHZ/ac4qqpOHcqdd6c0rpe2V LofnlGt3om2FX/sqwlWq8pQkZ6VX1wsU8n7F9ujsdR4TJyIR5ZxX9KUmy/V2U+ptw8Na GynACTuQHImqq6njVTs65EQmYWJ53a6tp3R5t0HukInJ+JzG21xXXO0Qs5zanrac8yOW MA8c3vbSy2w8XHFELvFV4ZXw/Xhul6JX0DbmRmPLOd1ibq85zlFqEk+mTu+cQKoQMUUt DHmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=TvI9XFrP; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 1-20020a621701000000b005668645daebsi9887495pfx.111.2022.11.07.11.01.08; Mon, 07 Nov 2022 11:01:41 -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=fail header.i=@nbd.name header.s=20160729 header.b=TvI9XFrP; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233016AbiKGSzg (ORCPT + 99 others); Mon, 7 Nov 2022 13:55:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232105AbiKGSza (ORCPT ); Mon, 7 Nov 2022 13:55:30 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA0F821E2B; Mon, 7 Nov 2022 10:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=itzNjPSgtI5YQ3ZzVEgPaMFuJJoHJB+VuPcGUc7XBPA=; b=TvI9XFrPBGbzQWNayCtd/QHfzC c+nStyV96uynxPWlvUEeHDMR8U/pZ1cMjcW1n8KF5LGoD5/zjioGbXaAPOXGpVL467XaV+/7yZY9W vmA5sPiVfmJvbuCirrUKlLOGeZ7yablPwQuT6B68IM2Ha+Nw+hgBL9Ta4puijo45e8Bs=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HE-000LCc-Hs; Mon, 07 Nov 2022 19:55:20 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org Subject: [PATCH 09/14] flow_dissector: detect DSA using skb->protocol even when VLAN tag is present Date: Mon, 7 Nov 2022 19:54:47 +0100 Message-Id: <20221107185452.90711-9-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748865071870559418?= X-GMAIL-MSGID: =?utf-8?q?1748865071870559418?= Fixes flow dissection with ethernet devices that can combine VLAN rx hwaccel with DSA, since skb->protocol is set to htons(ETH_P_XDSA) by the network stack. Signed-off-by: Felix Fietkau --- net/core/flow_dissector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 25cd35f5922e..43f6bbca7447 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -970,7 +970,7 @@ bool __skb_flow_dissect(const struct net *net, hlen = skb_headlen(skb); #if IS_ENABLED(CONFIG_NET_DSA) if (unlikely(skb->dev && netdev_uses_dsa(skb->dev) && - proto == htons(ETH_P_XDSA))) { + skb->protocol == htons(ETH_P_XDSA))) { const struct dsa_device_ops *ops; int offset = 0; From patchwork Mon Nov 7 18:54:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2235154wru; Mon, 7 Nov 2022 11:04:02 -0800 (PST) X-Google-Smtp-Source: AMsMyM7xlCXhp0ZQHKhDT9S1+g6ZlSjDUctcoTqgBfyNh1NLJwEvWad5vAhwZC14XRFfKZBvEtn9 X-Received: by 2002:a17:90b:1b01:b0:213:ccc6:87ea with SMTP id nu1-20020a17090b1b0100b00213ccc687eamr47667663pjb.135.1667847842167; Mon, 07 Nov 2022 11:04:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667847842; cv=none; d=google.com; s=arc-20160816; b=kWageNXTW5ch+Ivl5Z2E72OQctSGBtyjpVhpxlnHWdrXEcf3gib0MUAsoOW7JzGzGA M4B+/aTQeSdfQOUkfaJsMQ4cV55d9K1Y7EC8C9fn0G5hGorfyGiOH0AiYlyzLL6BAw42 uaVdfXOvNpxooAZ1T+QD8BnLwPDJQ1hmXljLHSpVkE53D5MbxfGWcvIDMwAm4Gmh8P91 IBvkEHWOIC4WQGEDvDCtTUA3qKfRpDkOq9bH3KhZjlUSE3KjmtwYs5GQd5t1cA7ouNmb oO2wKmJ7KRP2UW1dBZ1ByRNoXsT30hBl+tprrvrPQSlSeRTMl5USFJLntvaUvhQML9gL 8BkQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Qys05PG22fbxdWm5s8ByJ0wPdOueN+diTukAKqcYoqA=; b=zYlg/suJ732te3Q1aRaOUHAjIsI4Lyz5vFV2ej55mByOOAK8eJrSkd/tdTSmbYX8K/ 48PvNtIUW1xgWoqs15OS0J2jN8g8MBMquEEqP7hbOBnKyGYtLIHCoGPe4eCPk50aupZ7 nOCx3l4y5k/K0Bp4AdlF3TOsh624FwWKo86Y0SKxf96zcrd41HcpDAY3sHHTub1tjb5b eLxEUQZ108EN+o1nNzjMmLzZ6DU9MfWSL5nY9jYRZbCORGQy+iMJy+cugGupTdjKOkuR zHJlFBufEiGOZAx60dPuiwNLrnx+nVRjMmFXtOBk/banKdAd3Ev4cPhJsO8Q834yo0jj mceA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=FxYpLAUU; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a63b304000000b0043ab83b731asi12189471pgf.689.2022.11.07.11.03.47; Mon, 07 Nov 2022 11:04:02 -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=fail header.i=@nbd.name header.s=20160729 header.b=FxYpLAUU; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232630AbiKGS4I (ORCPT + 99 others); Mon, 7 Nov 2022 13:56:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232105AbiKGSzh (ORCPT ); Mon, 7 Nov 2022 13:55:37 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 508BF25E96; Mon, 7 Nov 2022 10:55:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Qys05PG22fbxdWm5s8ByJ0wPdOueN+diTukAKqcYoqA=; b=FxYpLAUUzZ0MezR3P4pPCvkz2p /RYuPhe0ELtcVlsyntSnLU/zmxETClklGmsfqVpQIdY0+hM+lS07kJrd/7+XniM7QNEyUlKZGFC+N 6wKJjv6SCdI4vdLSRQfStoVeLpLj4cpnvQk6E9QmauVKZ+Uy2JAPOi0HZU51jBVmFT+k=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HF-000LCc-A1; Mon, 07 Nov 2022 19:55:21 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, Sean Wang , Landen Chao , DENG Qingfang , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/14] net: dsa: tag_mtk: parse hwaccel VLAN tags Date: Mon, 7 Nov 2022 19:54:48 +0100 Message-Id: <20221107185452.90711-10-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748865218844356356?= X-GMAIL-MSGID: =?utf-8?q?1748865218844356356?= Pull the port information from the VLAN protocol ID field Signed-off-by: Felix Fietkau --- net/dsa/tag_mtk.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index 445d6113227f..0dfa2354f77d 100644 --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c @@ -73,13 +73,18 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev) if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN))) return NULL; - phdr = dsa_etype_header_pos_rx(skb); - hdr = ntohs(*phdr); + if (skb_vlan_tag_present(skb)) { + hdr = ntohs(skb->vlan_proto); + __vlan_hwaccel_clear_tag(skb); + } else { + phdr = dsa_etype_header_pos_rx(skb); + hdr = ntohs(*phdr); - /* Remove MTK tag and recalculate checksum. */ - skb_pull_rcsum(skb, MTK_HDR_LEN); + /* Remove MTK tag and recalculate checksum. */ + skb_pull_rcsum(skb, MTK_HDR_LEN); - dsa_strip_etype_header(skb, MTK_HDR_LEN); + dsa_strip_etype_header(skb, MTK_HDR_LEN); + } /* Get source port information */ port = (hdr & MTK_HDR_RECV_SOURCE_PORT_MASK); @@ -93,11 +98,22 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev) return skb; } +static void mtk_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto, + int *offset) +{ + if (!skb_vlan_tag_present(skb)) + return dsa_tag_generic_flow_dissect(skb, proto, offset); + + *offset = 0; + *proto = ((__be16 *)skb->data)[-1]; +} + static const struct dsa_device_ops mtk_netdev_ops = { .name = "mtk", .proto = DSA_TAG_PROTO_MTK, .xmit = mtk_tag_xmit, .rcv = mtk_tag_rcv, + .flow_dissect = mtk_tag_flow_dissect, .needed_headroom = MTK_HDR_LEN, }; From patchwork Mon Nov 7 18:54:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2260858wru; Mon, 7 Nov 2022 11:57:40 -0800 (PST) X-Google-Smtp-Source: AMsMyM4YN88CoMc+402GgZocK6Lrh4MkAWNufYEGBACnEiCjyNctAyV0qpRJSdNExvaLir5T9ult X-Received: by 2002:a17:906:3111:b0:7ad:a7fc:f3e8 with SMTP id 17-20020a170906311100b007ada7fcf3e8mr47966821ejx.518.1667851060705; Mon, 07 Nov 2022 11:57:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667851060; cv=none; d=google.com; s=arc-20160816; b=ChT25Xhtz38GYcdA9zt/1ldUJoMMwmaHzrqiRmn8rFuZXF7OBwSitVBHKAvIuz593K 6jTa26izNaspGaxNxjBdd2feE+RAy2bIBnIWll+YWMAGHbcG3KqrNbQ9kmDJRmxqaiub SS9GFwuJdWEBNYOPSCZqN8DsWVbfd4rlFbJpPzLxB6oYSiPVrC525TvGvT0aHfcvwtbY Jg/oZUuTDtRgSRcmr8lPF1KcCrUZTEloXcZ/uU1+LZcsKonrmjvmaTCAwDB1UnZNdPsB wX3yVoR0eip4FfKaZgL3Tv5Efd26N3X2YKHf5TqAt0/KT5ukVKnjdT3TQH4LybDy0LbL TvGw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aHSyFTkNYm0tEzpG0WqScLtRJ9ZnJG0fH9+cS4+pKn4=; b=kFAAo32EZUnn4jYRdEAwolwMlbGocH5u9PtDOXqT3Rt+X4SqTYayHZzgbihxTacVSA pemQCCd6XtTpRer84eL8npmP3jxI6m7C9NtzPF6eiTSeaEAWOHZf3/epExiKb4yAQgtV gYkhm6KERbnYFGEmbpGdvpoyX3Onjp3la4f4V4WMMN1EHU6lnaTu0g22xhL7hcbN7530 /0F+d74siABZ9a8/Wkv0IG2ms7iwf8FhJe2yyLGhlzruQQ8byQdPJWQKY9SBGezlSx89 Z2Hlh2Lq4qnyr5LRX3R8E0SIPXbAOy9nnLPpjRnBD1mT2PwISjzXXyaVS7zWrOOiZZ/e 3shg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=rP9cFhzD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q10-20020a056402518a00b00461bde34a12si12397308edd.627.2022.11.07.11.57.16; Mon, 07 Nov 2022 11:57:40 -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=fail header.i=@nbd.name header.s=20160729 header.b=rP9cFhzD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232112AbiKGTW4 (ORCPT + 99 others); Mon, 7 Nov 2022 14:22:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiKGTWz (ORCPT ); Mon, 7 Nov 2022 14:22:55 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F33629C9D; Mon, 7 Nov 2022 11:22:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=aHSyFTkNYm0tEzpG0WqScLtRJ9ZnJG0fH9+cS4+pKn4=; b=rP9cFhzDH0gSdDaqcJG8luNTWT VqaA1Po/WM5NiWcWoKWwNBsJe0xDAFNuDqpZA4UKEHsUb1yeCrG6qwfVT27dQ0zjYUyKEmfLW0qVH 8vBWCa9eFYx07hV2Q3NAp8u0i6rN7KdTOuEWpMM07W9+FLFM0QudxR09RI/z1wLd3MjE=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HG-000LCc-AH; Mon, 07 Nov 2022 19:55:22 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Russell King Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/14] net: ethernet: mtk_eth_soc: fix VLAN rx hardware acceleration Date: Mon, 7 Nov 2022 19:54:49 +0100 Message-Id: <20221107185452.90711-11-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748868593372269795?= X-GMAIL-MSGID: =?utf-8?q?1748868593372269795?= - enable VLAN untagging for PDMA rx - make it possible to disable the feature via ethtool - pass VLAN tag to the DSA driver - untag special tag on PDMA only if no non-DSA devices are in use - disable special tag untagging on 7986 for now, since it's not working yet Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 36 +++++++++++++-------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 3 ++ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index ab31dda2cd66..3b8995a483aa 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2015,16 +2015,9 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, htons(RX_DMA_VPID(trxd.rxd4)), RX_DMA_VID(trxd.rxd4)); } else if (trxd.rxd2 & RX_DMA_VTAG) { - __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), + __vlan_hwaccel_put_tag(skb, htons(RX_DMA_VPID(trxd.rxd3)), RX_DMA_VID(trxd.rxd3)); } - - /* If the device is attached to a dsa switch, the special - * tag inserted in VLAN field by hw switch can * be offloaded - * by RX HW VLAN offload. Clear vlan info. - */ - if (netdev_uses_dsa(netdev)) - __vlan_hwaccel_clear_tag(skb); } skb_record_rx_queue(skb, 0); @@ -2847,15 +2840,17 @@ static netdev_features_t mtk_fix_features(struct net_device *dev, static int mtk_set_features(struct net_device *dev, netdev_features_t features) { - int err = 0; - - if (!((dev->features ^ features) & NETIF_F_LRO)) - return 0; + struct mtk_mac *mac = netdev_priv(dev); + struct mtk_eth *eth = mac->hw; + netdev_features_t diff = dev->features ^ features; - if (!(features & NETIF_F_LRO)) + if ((diff & NETIF_F_LRO) && !(features & NETIF_F_LRO)) mtk_hwlro_netdev_disable(dev); - return err; + /* Set RX VLAN offloading */ + mtk_w32(eth, !!(features & NETIF_F_HW_VLAN_CTAG_RX), MTK_CDMP_EG_CTRL); + + return 0; } /* wait for DMA to finish whatever it is doing before we start using it again */ @@ -3176,6 +3171,15 @@ static int mtk_open(struct net_device *dev) else refcount_inc(ð->dma_refcnt); + /* Hardware special tag parsing needs to be disabled if at least + * one MAC does not use DSA. + */ + if (!netdev_uses_dsa(dev)) { + u32 val = mtk_r32(eth, MTK_CDMP_IG_CTRL); + val &= ~MTK_CDMP_STAG_EN; + mtk_w32(eth, val, MTK_CDMP_IG_CTRL); + } + phylink_start(mac->phylink); netif_tx_start_all_queues(dev); @@ -3469,6 +3473,10 @@ static int mtk_hw_init(struct mtk_eth *eth) */ val = mtk_r32(eth, MTK_CDMQ_IG_CTRL); mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL); + if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { + val = mtk_r32(eth, MTK_CDMP_IG_CTRL); + mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL); + } /* Enable RX VLan Offloading */ mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index e09b2483c70c..26b2323185ef 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -93,6 +93,9 @@ #define MTK_CDMQ_IG_CTRL 0x1400 #define MTK_CDMQ_STAG_EN BIT(0) +/* CDMQ Exgress Control Register */ +#define MTK_CDMQ_EG_CTRL 0x1404 + /* CDMP Ingress Control Register */ #define MTK_CDMP_IG_CTRL 0x400 #define MTK_CDMP_STAG_EN BIT(0) From patchwork Mon Nov 7 18:54:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2247846wru; Mon, 7 Nov 2022 11:30:02 -0800 (PST) X-Google-Smtp-Source: AMsMyM7hh4/Y0EA1omo2zMEeCVgEVjyy/PhIcKg+BbRIXJCNGVyW68DX7KTZCZrOuVGGbKfXIize X-Received: by 2002:a17:907:2cd7:b0:7ad:ef1e:3b72 with SMTP id hg23-20020a1709072cd700b007adef1e3b72mr34100649ejc.449.1667849402584; Mon, 07 Nov 2022 11:30:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667849402; cv=none; d=google.com; s=arc-20160816; b=O5ttrvtpVBXJo8DLcxtac0MRpOWxmM9QsmnEjEN5YLLCgtTujqJ7ce5UBpahX9YzGZ qiBkxHUqIsl4R3zGdyr3GU02fgFFATKKd7oBlNFgbmG4mBVmR9uPoGIHoksj6fuKvi95 RmIJ7Gz2qxDZhf+GaOb5uAc5PNUJ10Q6f+MzBr3xnY2f9TkaCD1IpaNfV7TMEr6Be+OZ OeWmI4P0ELBOD3Iuhy/UhFVCqohKKqHPa++WdOKoUc93vECBlcTSJhwoPVen/Dt7GkDU szDxJMdY+gKD88Tva100YbMff+MvrEeNAKc4oWBNE8vfmnaLOMkRde6Bi7Nv0r0f8IfF EzBA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xCr45UuzrLNIeKdnQROVOgewNl0be/E8YvRAW/QU3O4=; b=Iu+8WXUHRawPYmFhRIBSuaq3/m6rJPr7vTFJZQHH3hZH0+7AZsDSd+H9EAQtilvwgT x74yJL1Y04BIbqrwsl6J3gPsvySkAzDH3tn+IUAFcPgR20BrcXqBzU8s7BExgJ+7WbhT e9u4OQezTRdrZBlI0Yscy8MjY3RxfY/RxlC9CY+AbDvbeunmWMX/O3MuiWWX3uPWg3hY bLEi/Rk/JGd6Jsc11P3EXhCCVqqXpbgWPT0jQyaRxAdSKt830oiTDsVQ0WMPWHYr7fU9 BRfOFkKD7jYmB9xrNW7cbVH0bPpKSLATNk2HqfJjWMf/2y1hGDe2hrFGbSvNOwPq1Stc e+/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=A8NmC8uy; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h3-20020a056402280300b0046329e2724dsi12734594ede.86.2022.11.07.11.29.39; Mon, 07 Nov 2022 11:30:02 -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=fail header.i=@nbd.name header.s=20160729 header.b=A8NmC8uy; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231627AbiKGTZg (ORCPT + 99 others); Mon, 7 Nov 2022 14:25:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232167AbiKGTZc (ORCPT ); Mon, 7 Nov 2022 14:25:32 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F57C286EC; Mon, 7 Nov 2022 11:25:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=xCr45UuzrLNIeKdnQROVOgewNl0be/E8YvRAW/QU3O4=; b=A8NmC8uyAFNHwtnVUx1Qg7EzE/ Iia6sjNBFsbKq34UUC19vohNFhU7am+FpMSYWIA2OfmGK66c8ECVwH3nHo4ppZcr3N+ba2bZ/xYyq Kzj6VV21d+Q/KQj0xs2PNzZ3IJisJNXILxTddQSNTUcLc6OV49Ngjqdg0WSQSvWpBiJQ=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HH-000LCc-5a; Mon, 07 Nov 2022 19:55:23 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/14] net: ethernet: mtk_eth_soc: work around issue with sending small fragments Date: Mon, 7 Nov 2022 19:54:50 +0100 Message-Id: <20221107185452.90711-12-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748866855085889106?= X-GMAIL-MSGID: =?utf-8?q?1748866855085889106?= When frames are sent with very small fragments, the DMA engine appears to lock up and transmit attempts time out. Fix this by detecting the presence of small fragments and use skb_gso_segment + skb_linearize to deal with them Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 36 +++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 3b8995a483aa..50756c8aa871 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1441,12 +1441,28 @@ static void mtk_wake_queue(struct mtk_eth *eth) } } +static bool mtk_skb_has_small_frag(struct sk_buff *skb) +{ + int min_size = 16; + int i; + + if (skb_headlen(skb) < min_size) + return true; + + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) + if (skb_frag_size(&skb_shinfo(skb)->frags[i]) < min_size) + return true; + + return false; +} + static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct mtk_mac *mac = netdev_priv(dev); struct mtk_eth *eth = mac->hw; struct mtk_tx_ring *ring = ð->tx_ring; struct net_device_stats *stats = &dev->stats; + struct sk_buff *segs, *next; bool gso = false; int tx_num; @@ -1468,6 +1484,17 @@ static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_BUSY; } + if (skb_is_gso(skb) && mtk_skb_has_small_frag(skb)) { + segs = skb_gso_segment(skb, dev->features & ~NETIF_F_ALL_TSO); + if (IS_ERR(segs)) + goto drop; + + if (segs) { + consume_skb(skb); + skb = segs; + } + } + /* TSO: fill MSS info in tcp checksum field */ if (skb_is_gso(skb)) { if (skb_cow_head(skb, 0)) { @@ -1483,8 +1510,13 @@ static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) } } - if (mtk_tx_map(skb, dev, tx_num, ring, gso) < 0) - goto drop; + skb_list_walk_safe(skb, skb, next) { + if ((mtk_skb_has_small_frag(skb) && skb_linearize(skb)) || + mtk_tx_map(skb, dev, tx_num, ring, gso) < 0) { + stats->tx_dropped++; + dev_kfree_skb_any(skb); + } + } if (unlikely(atomic_read(&ring->free_count) <= ring->thresh)) netif_tx_stop_all_queues(dev); From patchwork Mon Nov 7 18:54:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16658 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2248884wru; Mon, 7 Nov 2022 11:32:01 -0800 (PST) X-Google-Smtp-Source: AMsMyM4MU9atnZWS4I7tBY2k98qwuiu5u23qpepbLMJPOdS9lU8NNNhZBXHiqv7K324Ubh1sezkq X-Received: by 2002:a17:907:97ca:b0:791:644c:491e with SMTP id js10-20020a17090797ca00b00791644c491emr49310034ejc.555.1667849521219; Mon, 07 Nov 2022 11:32:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667849521; cv=none; d=google.com; s=arc-20160816; b=GMQiY+m3uuatT9uNOtziCpxjP2Xu6mHFxmc2N3spKiMLVL0g1JI4rGZHKheJjsmJW8 f+FKiEi8bPZZyAjlxc8M+JaGJdOjX7ziB5VhoKYW8nHtXWkfHq7ieqGlcrGzMJxb6eoI qJxJc5QZjqG3G8Q/OsnZcip1ViZfFca0U6B44vFOymCxvH4A+oZuGCdBzrES5s7huoJ+ n2/O1Bp2G5Y7zRIjVfVP0xAhuncqkSj2bDG8OtHJwMsaV8Mb2Y03sgH4AflYGq8dBGSF iTI1fvZ5KyEBq6JkoOPsMW/Dv9aDjLa4gmv0rYyP4hSpZCLZTDtCluciwg0TLfmCHRXL c5AA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6IYI4p300dG70msn+7q2b2hGBMt0NQzYvJdzq6aVpFo=; b=x1w/JxpbbXVttNpYndCvguWD7fgwvSB8G+Q5Wfds3UP530udHTdV+D7lz4XBmQPMaP xTcubwp0kSWYkS1wRYnV5lWDuDpFcezpRgNTAeSmlT24GeZ3niUPM5HwtR8FJZWUeKUJ sYVYm9k5uiZFvMP9Uk8t99wkmnQdzsiHAMAQ5DOQcAlk41QO1zRd4U+RTZvj2nHtXak7 SqYQehgP8fO3rodtxPjWOGKBxekKH2Fnz8AiRUE8DzufoeZ7NWgZQWgy2MdbBYG+5PNA SlycIhdfmpi/XT0iz+8xTBqr6msvooIC+K7hGR473IVqutgW1g1NWOTpWqHzseCiwIMS u46Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=flLecCoc; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa12-20020a170907868c00b0079194d8b1f6si11186304ejc.892.2022.11.07.11.31.36; Mon, 07 Nov 2022 11:32:01 -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=fail header.i=@nbd.name header.s=20160729 header.b=flLecCoc; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231997AbiKGTZ5 (ORCPT + 99 others); Mon, 7 Nov 2022 14:25:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232154AbiKGTZu (ORCPT ); Mon, 7 Nov 2022 14:25:50 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16BF42AE02; Mon, 7 Nov 2022 11:25:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=6IYI4p300dG70msn+7q2b2hGBMt0NQzYvJdzq6aVpFo=; b=flLecCocMLB6pb9ZXLmN4mEnk+ pK9o1To5LtMyJeRHHQuP8GK1v+MMpglN0sLlqCEwW0kmh0PiRyaY000+ol0A4q+K3zwf47vCSMZ6i fy+ap0P6FbHDSoySQgYMti2AYYM+4XP5ewAGqQgf9bqRjoZBWOVJ7Rc/VWgpuyh/TGPQ=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HH-000LCc-R6; Mon, 07 Nov 2022 19:55:23 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/14] net: ethernet: mtk_eth_soc: set NETIF_F_ALL_TSO Date: Mon, 7 Nov 2022 19:54:51 +0100 Message-Id: <20221107185452.90711-13-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748866979990768771?= X-GMAIL-MSGID: =?utf-8?q?1748866979990768771?= Significantly improves performance by avoiding unnecessary segmentation Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 26b2323185ef..bf8c7d11df9f 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -46,8 +46,7 @@ NETIF_F_RXCSUM | \ NETIF_F_HW_VLAN_CTAG_TX | \ NETIF_F_HW_VLAN_CTAG_RX | \ - NETIF_F_SG | NETIF_F_TSO | \ - NETIF_F_TSO6 | \ + NETIF_F_SG | NETIF_F_ALL_TSO | \ NETIF_F_IPV6_CSUM |\ NETIF_F_HW_TC) #define MTK_HW_FEATURES_MT7628 (NETIF_F_SG | NETIF_F_RXCSUM) From patchwork Mon Nov 7 18:54:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 16656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2247070wru; Mon, 7 Nov 2022 11:28:40 -0800 (PST) X-Google-Smtp-Source: AMsMyM53PsUW2VwJBis8NSWdmct6Vz+9GdFsa6pnjz5L5i7Gctq3J8UQVdKoR5FAhhJZMjHc0InG X-Received: by 2002:a17:90b:4c07:b0:213:44f5:6073 with SMTP id na7-20020a17090b4c0700b0021344f56073mr53174671pjb.184.1667849319842; Mon, 07 Nov 2022 11:28:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667849319; cv=none; d=google.com; s=arc-20160816; b=txGeLjdCMmit5XzCUTg6qnXHlk6zzjTqv2gMk8Rm/Ptc20g5zHSMtF9zzeLATHfG5Z w5U0XiRTq0IP8UWjSqeMfmEYDOMP2sw66alRfqgNuO1pn0LIFYFbkfC0r1h5iWmojEDQ mQVOL3/S/qfeg0OjuOIFbNe4s0hSIn1Rg/HPMf5zokVOn+AeUdq5apdeghxRbKETq6NA gTR7+0YSQnGDfMTbwlWvyiqySJyANlDnhTk2WBOaHhmhvcvP8P3srwtaq3YpIduwd2Jw EukbKg1lgKJGjAwJarpflVtNrSq/Lznvl7gV4FACvlY1TF2HFFnfiVJy7OCP8N4Pr4dc Xkig== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5ieiAxhifSMyQ4MxSnOsIKCi9Eh84IdHGfPjBjh2Hno=; b=jlSNZ0n+183Yofi3afE7SBzAD46zvMKXkWVLUxuT0qkpgbU1wjsdmiGinBwCY1G8pK iLJ25HHdKKPVWKu5QIZbUydO40fhFMievND3rNseplPA4iTrIFULlVBtmXMSj/pYSJDZ AfKOEIHa/dOiY9em0YeKyc1fq5FzYp7jdWrL9K3xs7MjXRyryvwTL8OPlbo2oGBEbH/m uNQIZAh9F335uBvnPxg1zxelvLZkpzNJPA/jk19VxDtMzaQpXA4II0AtJ4hEQQ73SplV MZLOAJPpqpMXjlv26utRwAz8CohHkLaA73TO+N16Pk7/AJgnbMqXW64u6t5ISUoB8HbX EOGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=fh+rYeK1; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a17090a708100b00213de6fbf91si13539144pjk.183.2022.11.07.11.28.21; Mon, 07 Nov 2022 11:28:39 -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=fail header.i=@nbd.name header.s=20160729 header.b=fh+rYeK1; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231705AbiKGT0I (ORCPT + 99 others); Mon, 7 Nov 2022 14:26:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232601AbiKGTZz (ORCPT ); Mon, 7 Nov 2022 14:25:55 -0500 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB46E2AC73; Mon, 7 Nov 2022 11:25:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=5ieiAxhifSMyQ4MxSnOsIKCi9Eh84IdHGfPjBjh2Hno=; b=fh+rYeK17i703PklQYs1GnZj8Y f5vZfagQdzCt9wXjqfxtHNlZIdAM53JDmm+IwWUapnaFa4G6gsdpTOpbgj6ZtC11spai+rqg8ir6l jNiDa95qAoAoe/9Ydlgi2YCvzf8hPn5twSqDAP+MxbLGHFG63nzZ9/RTqm8v68cWJXHU=; Received: from p200300daa72ee1007849d74f78949f6c.dip0.t-ipconnect.de ([2003:da:a72e:e100:7849:d74f:7894:9f6c] helo=Maecks.lan) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1os7HI-000LCc-Ht; Mon, 07 Nov 2022 19:55:24 +0100 From: Felix Fietkau To: netdev@vger.kernel.org, John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/14] net: ethernet: mtk_eth_soc: drop packets to WDMA if the ring is full Date: Mon, 7 Nov 2022 19:54:52 +0100 Message-Id: <20221107185452.90711-14-nbd@nbd.name> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221107185452.90711-1-nbd@nbd.name> References: <20221107185452.90711-1-nbd@nbd.name> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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?1748866767989033609?= X-GMAIL-MSGID: =?utf-8?q?1748866767989033609?= Improves handling of DMA ring overflow. Clarify other WDMA drop related comment. Signed-off-by: Felix Fietkau --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 5 ++++- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 50756c8aa871..4bd06ab1a2b5 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -3529,9 +3529,12 @@ static int mtk_hw_init(struct mtk_eth *eth) mtk_w32(eth, 0x21021000, MTK_FE_INT_GRP); if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { - /* PSE should not drop port8 and port9 packets */ + /* PSE should not drop port8 and port9 packets from WDMA Tx */ mtk_w32(eth, 0x00000300, PSE_DROP_CFG); + /* PSE should drop packets to port 8/9 on WDMA Rx ring full */ + mtk_w32(eth, 0x00000300, PSE_PPE0_DROP); + /* PSE Free Queue Flow Control */ mtk_w32(eth, 0x01fa01f4, PSE_FQFC_CFG2); diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index bf8c7d11df9f..226022346369 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -124,6 +124,7 @@ #define PSE_FQFC_CFG1 0x100 #define PSE_FQFC_CFG2 0x104 #define PSE_DROP_CFG 0x108 +#define PSE_PPE0_DROP 0x110 /* PSE Input Queue Reservation Register*/ #define PSE_IQ_REV(x) (0x140 + (((x) - 1) << 2))