From patchwork Fri Apr 23 05:20:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219561 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30A01C43461 for ; Fri, 23 Apr 2021 05:21:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 145F9613F2 for ; Fri, 23 Apr 2021 05:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240449AbhDWFWB (ORCPT ); Fri, 23 Apr 2021 01:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240419AbhDWFVz (ORCPT ); Fri, 23 Apr 2021 01:21:55 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7765FC061574; Thu, 22 Apr 2021 22:21:18 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id cu16so20506743pjb.4; Thu, 22 Apr 2021 22:21:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M+UkxRcksnApyVs6XRntELHRkRUhOfWnYDnO1ZqRoWc=; b=YqR5wBCEG4LdcLo0lZg6cH+tcklWyskvWaWbqu3+m41OjiOI0vJfgBt8WaINceHnHp FyU+z+yV8z6xoqI++d8hQxrn2BQRnF0Y/1jqkBP9miOh28YC9KpipS3bkSPuce6xDvYg /Lyf+fM6U9AE0wjboQyGDvrSAgRqgL8PfTA3DCD/JPO3wLZwurni51LBzh3/SFygeGPB 2Y8/q/NVfGeScdqCN7s+CpIYqaYw+/RP3YawQueSHLhJt+j//ecPbtNd4+27FX6tTvHg bBqiKmamHW3XgihuVB4P0t4EqDgrOkMjoMS0Ayb+Of0uKKHYIYb5lYJDhurCt1TBjlx3 aTMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M+UkxRcksnApyVs6XRntELHRkRUhOfWnYDnO1ZqRoWc=; b=pyH5u5aAmilnp4QGpaeb8sxq5fED9eA1FvXwnSkoCeYwXFTfn1VD5Nps8Hu4eHPRSN PrquivD1HK3ytK2lTxttl2TEv2QIroZzIfUSW7pcCoXtpKb3sfcNZErYhFsqWEfN9vjs 9zjpvjp+kWdG6WNwF5mWiviEZJ1KmuhUY5w0QosUbfbiEzYdk4O/h98XdhkUY8gn2odZ P1grs20IBD2WEJ8dESM+I0XD8SXhohmwucaqzsoRxez+SpFGEa3dJONb/pSVrlMOVN0n vY0K611v6v4sNwJ2kI6OtYld9x1jFMKh5llg1K0Dpl4GpX/+df+OLEQBT5IE3aFaIFvn /Wbg== X-Gm-Message-State: AOAM530v+ACXvtD54AYmixvfsJM546GfqkmDJdgQWQ9WzSMSB99cj+HK kHtVbALIik9cWwjPCIlTsrQ= X-Google-Smtp-Source: ABdhPJwQ6kWQAIGJ3oAZPqiZa98jRvYL+nHMV0pr0QOfpb87dPhNaXXKFCC4UGF13r43UlsVmHXS3Q== X-Received: by 2002:a17:902:dac9:b029:eb:732:d914 with SMTP id q9-20020a170902dac9b02900eb0732d914mr2058741plx.85.1619155277945; Thu, 22 Apr 2021 22:21:17 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:17 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 01/15] net: ethernet: mtk_eth_soc: fix RX VLAN offload Date: Thu, 22 Apr 2021 22:20:54 -0700 Message-Id: <20210423052108.423853-2-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau The VLAN ID in the rx descriptor is only valid if the RX_DMA_VTAG bit is set. Fixes frames wrongly marked with VLAN tags. Signed-off-by: Felix Fietkau [Ilya: fix commit message] Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 6b00c12c6c43..b2175ec451ab 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1319,7 +1319,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, skb->protocol = eth_type_trans(skb, netdev); if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX && - RX_DMA_VID(trxd.rxd3)) + (trxd.rxd2 & RX_DMA_VTAG)) __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), RX_DMA_VID(trxd.rxd3)); skb_record_rx_queue(skb, 0); diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 1a6750c08bb9..875e67b41561 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -301,6 +301,7 @@ #define RX_DMA_LSO BIT(30) #define RX_DMA_PLEN0(_x) (((_x) & 0x3fff) << 16) #define RX_DMA_GET_PLEN0(_x) (((_x) >> 16) & 0x3fff) +#define RX_DMA_VTAG BIT(15) /* QDMA descriptor rxd3 */ #define RX_DMA_VID(_x) ((_x) & 0xfff) From patchwork Fri Apr 23 05:20:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219559 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C070C433ED for ; Fri, 23 Apr 2021 05:21:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EAC08613E6 for ; Fri, 23 Apr 2021 05:21:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240467AbhDWFV6 (ORCPT ); Fri, 23 Apr 2021 01:21:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240403AbhDWFVz (ORCPT ); Fri, 23 Apr 2021 01:21:55 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B49FC06174A; Thu, 22 Apr 2021 22:21:19 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id y22-20020a17090a8b16b0290150ae1a6d2bso645966pjn.0; Thu, 22 Apr 2021 22:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IhMuV7pk/e6sV7VUIyv8mgUtfEot/XwuLzvlzQOD9tE=; b=lmLheeEPGFQgitLGJY+wsWubJP+ggaguhY3vmRN+E82W0DBWsuLaZKiNy3fmbngytR Pp3iI++8Zg3h+6LP2O7TM9U1qa+026qhc6tLnH/B76oY9dZ02r9FCb2Zdi0VkY/mINPV XiFhil4oCVGQtkdjqIz79VZbID0LOje6s0D9WYcyR9Ht4ZbEVZV4O3RIqqiksMenfRRJ Q45783Y63qzCXFiC9RwC0E3mZOUAl9ivHiYjzA71FySr0PGEnJzkTLaWbDsR8VReLrcy wQjwpYjSr3/N0cfiOuDlQfvt/CsgreHvG4Uaii1WWbKNVVIV34jKa7BJVuztyA23YTAy MYjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IhMuV7pk/e6sV7VUIyv8mgUtfEot/XwuLzvlzQOD9tE=; b=lq3kXnPBJEvDzaK7KoR4+eOgHg8zKOm7O0QR1W8Lhg55QTYXb2EolqtWlhyvuCUHo1 O2hk8LWbJg3YF2UmrrKykBqRcBvcFYvzXdjpLs2jNEgG4SzG2a/RyOaL6B5vIEPO5lhS 0XO8Xz940PPG9t2JB8tQukQCfuDuDXBejOJJ5He8yju1nZgc+tuhicw+7geKMc4sO9K+ PqANgGyuW50ryBBG4qj1sPvDgGWjWNiyKID5puFjz4UXespeV5+P3Lh2OYVThLLK7Cgg N4L0lBdYSn0DZRNba7GkHUJH8ld8PlxI5+10UYldRMIWwB3I4fZh25MUk6x3vx6grQYI EFng== X-Gm-Message-State: AOAM5314AJFg+hqkWmseobs5D7V0Y5NmheK4jYnD7qX0WkKcEsUewRjC iwWMWlVzumT5eV/ki6wqNBAi972e98Isv02M X-Google-Smtp-Source: ABdhPJxlQhY9hZBU8DSNJ2pRRuIJvNc1Qgl1KnYHabKy5rGCRe0QNGaaH6fat8apwejStrcwnpD5Iw== X-Received: by 2002:a17:90a:1190:: with SMTP id e16mr2497504pja.110.1619155278782; Thu, 22 Apr 2021 22:21:18 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:18 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 02/15] net: ethernet: mtk_eth_soc: unmap RX data before calling build_skb Date: Thu, 22 Apr 2021 22:20:55 -0700 Message-Id: <20210423052108.423853-3-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau Since build_skb accesses the data area (for initializing shinfo), dma unmap needs to happen before that call Signed-off-by: Felix Fietkau [Ilya: split build_skb cleanup fix into a separate commit] Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index b2175ec451ab..540003f3fcb8 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1298,6 +1298,9 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, goto release_desc; } + dma_unmap_single(eth->dev, trxd.rxd1, + ring->buf_size, DMA_FROM_DEVICE); + /* receive data */ skb = build_skb(data, ring->frag_size); if (unlikely(!skb)) { @@ -1307,8 +1310,6 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, } skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN); - dma_unmap_single(eth->dev, trxd.rxd1, - ring->buf_size, DMA_FROM_DEVICE); pktlen = RX_DMA_GET_PLEN0(trxd.rxd2); skb->dev = netdev; skb_put(skb, pktlen); From patchwork Fri Apr 23 05:20:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219563 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCF91C433B4 for ; Fri, 23 Apr 2021 05:21:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94C1B613F2 for ; Fri, 23 Apr 2021 05:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240594AbhDWFWD (ORCPT ); Fri, 23 Apr 2021 01:22:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240437AbhDWFV5 (ORCPT ); Fri, 23 Apr 2021 01:21:57 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AD01C06138B; Thu, 22 Apr 2021 22:21:21 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id e2so20355368plh.8; Thu, 22 Apr 2021 22:21:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HlVoF4WBd28mr16LsVXI69/qoWczDKwnY5ulmKa3JqU=; b=PJqw7qbCVerNFMqSHMZJzZ+oDBUc8T1s4RQIMW64itnCYPn5unf5oOv9h5yu4Tv80a e1PEbJY4tA4JypLmdonjfmuV92iSNxIZiEfeLwgsjYsBBDq3nG6rWkKTJNIwTZAcCRpX /n4i//CxaXnSkPlW4l5365q/tShaCQswbt0Fs0/h4x+dDnGprpxCccXJbISBjtSIqCzS S032twqbKbFTD6jmzp4E4db8WyOnFKEIGhKQ+cTmEPH7Bg/pz+E9JrTj2Ca9WhDHFeQp Ro1FaVrnmMf71olrDnUNLHHaee+6dRtHpgS8O4aBHVHQpcO906KVNgmRx9ePq4/roMSn YwXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HlVoF4WBd28mr16LsVXI69/qoWczDKwnY5ulmKa3JqU=; b=MrwQiYKLWchXIyKVEsnjTJRn25aktGGA/zM+rWI9EFjG0Bxep1R+aDrEEkn0lF+P9r tP795N5WanbgLasrae7zf7FqVvBYyJ0KYuHMVK1rsMh2M2mecH3SSiM+FQ5BBVRMm72G If309/SxgXwyxySZBm+7ftEYm/CfxxLT3po+DAqFOlGlFgwKAuNjrccgGfd9zlK5Yi08 wr32Q+97lrwXPzNSfdbBBwHZwU6I1ytH+EmDhnRbHBtdKs5iab3xss7S5OfrmnPBzUhd OKVFNmmZbz5+Jb5tSQujn+HrzIBd2Qok7vDmIiBjxxrPSviPLXofJPwxB+ySMfRS7EIb uUMQ== X-Gm-Message-State: AOAM53392D03e+6wUaF3FbXvCTDlxbgmTkN0LjM3ZhcktTbtSrwdw1wK qJdXcMvPzBiNtMz0sgdCiDM= X-Google-Smtp-Source: ABdhPJxfR910IzfiJ+sHCtn/47cz6QgVT8Cwpw1BicgmMT5qd/MKnS0aDxdWUSWwkQH3YllxqCDcNQ== X-Received: by 2002:a17:90a:fb87:: with SMTP id cp7mr3818203pjb.78.1619155280763; Thu, 22 Apr 2021 22:21:20 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:20 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 03/15] net: ethernet: mtk_eth_soc: fix build_skb cleanup Date: Thu, 22 Apr 2021 22:20:56 -0700 Message-Id: <20210423052108.423853-4-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In case build_skb fails, call skb_free_frag on the correct pointer. Also update the DMA structures with the new mapping before exiting, because the mapping was successful Suggested-by: Felix Fietkau Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 540003f3fcb8..07daa5de8bec 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1304,9 +1304,9 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, /* receive data */ skb = build_skb(data, ring->frag_size); if (unlikely(!skb)) { - skb_free_frag(new_data); + skb_free_frag(data); netdev->stats.rx_dropped++; - goto release_desc; + goto skip_rx; } skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN); @@ -1326,6 +1326,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, skb_record_rx_queue(skb, 0); napi_gro_receive(napi, skb); +skip_rx: ring->data[idx] = new_data; rxd->rxd1 = (unsigned int)dma_addr; From patchwork Fri Apr 23 05:20:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219565 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60CAEC433ED for ; Fri, 23 Apr 2021 05:21:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 343B260FF1 for ; Fri, 23 Apr 2021 05:21:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240627AbhDWFWG (ORCPT ); Fri, 23 Apr 2021 01:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240451AbhDWFV5 (ORCPT ); Fri, 23 Apr 2021 01:21:57 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17A1CC06138D; Thu, 22 Apr 2021 22:21:22 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id y32so34429111pga.11; Thu, 22 Apr 2021 22:21:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VddRnX0bE97CmvaALzam+ApYpCJ5QzcFqH5F34H/Njg=; b=joV3J9h1Tn+aV8SS5MNFC/VGzBuKjiBRrMggkam1ZnBX6VW1YfhMIYGe9j6VsyClqk 3kGCcITNUb2WQxv8k0UzIv7s+r70pZ0MQ/nNpHF0ivP2NA15IsKmx7vrkbAxDB84yAL9 sEiYi55+jLK1NbaL7LHlqUHOEP3j5lHJ03hRDcLF6X3qhBhaOu0wFzYmFl0DRzCOgwvr LcWgzDf0pVeU0m2iltwEEsWtshqZ0NEmCQ46wflAazkL6l2xjJFUgbhbu/m5X3nB/FOj x00rhsyeMQzmjMI5lxarCgHUcPrZNSTUEg7ORrIIaZb7gesP8kbUtYxNuo3bnNP52b8b r2Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VddRnX0bE97CmvaALzam+ApYpCJ5QzcFqH5F34H/Njg=; b=jXdmtFafSCLSWij/fzTGnfspHnTZRePpTnIJloPzgzkQY5Nt68mcHxIJwzJtCK1pip 8dKNJiL/8Xqzmggh0yg4IbEVcLh9vYdnocHXttKtsrciqL5aOjYIhx4VxebXGAvd07Aa 7hlWR7mlM5uW9YuQcF4L2fij9+F9P0WMVnBm9ebHDwsrxmY0cxnBkxKwZKtQKVJ7Ev9R JZUP/LzecCJSjP0qvw+kspe9o0U5GC64Jruhf6CM9UNNRLjGkoX4HuawYzbqYb8hPH8P iAFsoC8TEMTVXFI8eP7WEdhnO5tU8Th2c1pS05fUU8eu6Hji1xgutECKF8Z3LMhs/e8E nZUw== X-Gm-Message-State: AOAM532pISu5w+l7jj7TwGYheyHPgxT2q2UjNjkHfknfo054hoLTiUnN ciUDra33mQjsWS0R51UV40Q= X-Google-Smtp-Source: ABdhPJzvwQj5389BqDSDkiHBaH24ca03aWG0rJvfV0xgiI9wYJxOtUVDhmwwNFLi+bcqrW0T8d0Pxg== X-Received: by 2002:a63:344:: with SMTP id 65mr2186120pgd.24.1619155281653; Thu, 22 Apr 2021 22:21:21 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:21 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 04/15] net: ethernet: mtk_eth_soc: use napi_consume_skb Date: Thu, 22 Apr 2021 22:20:57 -0700 Message-Id: <20210423052108.423853-5-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau Should improve performance, since it can use bulk free Signed-off-by: Felix Fietkau Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 07daa5de8bec..5cf64de3ddf8 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -858,7 +858,8 @@ static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma) return ((void *)dma - (void *)ring->dma) / sizeof(*dma); } -static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf) +static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf, + bool napi) { if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { if (tx_buf->flags & MTK_TX_FLAGS_SINGLE0) { @@ -890,8 +891,12 @@ static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf) tx_buf->flags = 0; if (tx_buf->skb && - (tx_buf->skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC)) - dev_kfree_skb_any(tx_buf->skb); + (tx_buf->skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC)) { + if (napi) + napi_consume_skb(tx_buf->skb, napi); + else + dev_kfree_skb_any(tx_buf->skb); + } tx_buf->skb = NULL; } @@ -1069,7 +1074,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, tx_buf = mtk_desc_to_tx_buf(ring, itxd); /* unmap dma */ - mtk_tx_unmap(eth, tx_buf); + mtk_tx_unmap(eth, tx_buf, false); itxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) @@ -1388,7 +1393,7 @@ static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget, done[mac]++; budget--; } - mtk_tx_unmap(eth, tx_buf); + mtk_tx_unmap(eth, tx_buf, true); ring->last_free = desc; atomic_inc(&ring->free_count); @@ -1425,7 +1430,7 @@ static int mtk_poll_tx_pdma(struct mtk_eth *eth, int budget, budget--; } - mtk_tx_unmap(eth, tx_buf); + mtk_tx_unmap(eth, tx_buf, true); desc = &ring->dma[cpu]; ring->last_free = desc; @@ -1627,7 +1632,7 @@ static void mtk_tx_clean(struct mtk_eth *eth) if (ring->buf) { for (i = 0; i < MTK_DMA_SIZE; i++) - mtk_tx_unmap(eth, &ring->buf[i]); + mtk_tx_unmap(eth, &ring->buf[i], false); kfree(ring->buf); ring->buf = NULL; } From patchwork Fri Apr 23 05:20:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219571 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D02EC433B4 for ; Fri, 23 Apr 2021 05:21:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 699DB611AE for ; Fri, 23 Apr 2021 05:21:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240759AbhDWFWP (ORCPT ); Fri, 23 Apr 2021 01:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240530AbhDWFWB (ORCPT ); Fri, 23 Apr 2021 01:22:01 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B2BC06138E; Thu, 22 Apr 2021 22:21:22 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id u7so22860294plr.6; Thu, 22 Apr 2021 22:21:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oCguuBzXzGvGn2bpnQzkSyzGRllJCSh+eewGXVSf1rE=; b=MHMI7yDYGqn8zq/FZ4jyCKzBzBSGVUpLws/egw5RYREDUwNt1/5nibN5vsTSaK0mPJ 5XMBffQrNzw6+e9/43KdK9qgdT0sn5bob2n2/3b1ahrzQ5STCqZFqXHhrURRRn3AVZTf hE64u9uDhJNNcaTRAyo7FVGPM6M4a99+V1266y0wwrC7WfyVJsg4bmCGBnGQwd1Y1d4S 4+g8sNZ+cOIgY3E657sYN2VWja0DbyhJLommN264eB8JKGLfVIV+TBkR/UDOtwIIuU6h 2lAqU9L0iZAjoClMeQ0ac2cAFE8AYLuyaLWIPBEUTJq3htUUcHuQ9+aIXpfC9thWRjQI CL2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oCguuBzXzGvGn2bpnQzkSyzGRllJCSh+eewGXVSf1rE=; b=jkNDd8sM+sviAtrC+oegRcooct1dQRHHKfTxa6DUWMvdA/LBsVwBnMKtPauwEMpf+D oV4uDrQJ+dx3a8hP3HMcf/VfLvXOg19tAlfntzLVOc8QxOO4p78FztCm83p0TC2+qmI0 uOoqqQYtlwRq4qiy/1x7h7JvIogkAKNxeGnY8uDK4U11Y4KDFmMSOSdfDNrQMwvFYnyh abob57zBTelQDXUlsgQr0BBhwbVcBz1owfDwjSeW72VqpUp0brdPUpBWq0bYRNhwIecH bblInF+P6m2nVB4fN/XKq7KW7VDRq85bglhapibGjy5G8IIFAe8Us1pVdFY7qrhiaHrX cxfA== X-Gm-Message-State: AOAM533JwZzquIJ2qqTF/FxUzlVUQ8DZGi3S3rYbiUgnyIytU6kwX7+7 xGJU1acXwuN+TYlSbK4nG2w= X-Google-Smtp-Source: ABdhPJxXEwjA66TlNmzYlUZCuMfuAaRE+874S9Bqpa0e67m7LPYgUUhtbwPh1eTSX8cCwirlRy23Ag== X-Received: by 2002:a17:90a:2acb:: with SMTP id i11mr2381934pjg.131.1619155282437; Thu, 22 Apr 2021 22:21:22 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:22 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 05/15] net: ethernet: mtk_eth_soc: reduce MDIO bus access latency Date: Thu, 22 Apr 2021 22:20:58 -0700 Message-Id: <20210423052108.423853-6-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau usleep_range often ends up sleeping much longer than the 10-20us provided as a range here. This causes significant latency in mdio bus acceses, which easily adds multiple seconds to the boot time on MT7621 when polling DSA slave ports. Use cond_resched instead of usleep_range, since the MDIO access does not take much time Signed-off-by: Felix Fietkau Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 5cf64de3ddf8..d992d4f1f400 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -86,7 +86,7 @@ static int mtk_mdio_busy_wait(struct mtk_eth *eth) return 0; if (time_after(jiffies, t_start + PHY_IAC_TIMEOUT)) break; - usleep_range(10, 20); + cond_resched(); } dev_err(eth->dev, "mdio: MDIO timeout\n"); From patchwork Fri Apr 23 05:20:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219569 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA6B3C433B4 for ; Fri, 23 Apr 2021 05:21:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A742611C2 for ; Fri, 23 Apr 2021 05:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240710AbhDWFWL (ORCPT ); Fri, 23 Apr 2021 01:22:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240494AbhDWFV7 (ORCPT ); Fri, 23 Apr 2021 01:21:59 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B09BC06138F; Thu, 22 Apr 2021 22:21:23 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id m6-20020a17090a8586b02901507e1acf0fso622984pjn.3; Thu, 22 Apr 2021 22:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ETl9BH5g7aSjjPd9xSrYXQLCyVhrrpEc2i1Ck3dijOQ=; b=DWLaNz57Xo7Q8CmeyQcEYGngcqRDERgnjBO75qo/hNGHh82Ym0jvG+u4PkNZFf7l50 kPJMVS9bRA/LP/Rk0qRYekytRQD7yvrTn/FLRak7+qGpNPFvyVDjxWhNpbW+K8RDxsyy MlFV2wy+7offo5XcQxatZDQu2or2gJtdO4RYWcdfdMAEFak+UEhPyg6tt1mBD4TdSEDs 0mFId+SldNVJxIUc2G+WNwOc+SfG6Z+uP8c5fMc/I3iZwgvxi/DTeqsm89iVWvOJogLm WHnMd0J5sDETDzTKE7q9rn0swI6bFg6ZV/WmTz/3hl5zlYgDngWX0IN5nDAmV2Zmtj5m 3uXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ETl9BH5g7aSjjPd9xSrYXQLCyVhrrpEc2i1Ck3dijOQ=; b=tr/f2I4OyYybpg3Uroz7kDqlYODcFdsv4e4ilzrFqs9Yq6CaEHnxBsE6EdGWRNSROF EfpRKa4V6OcLvaRchFkEfmh/jtuVYxsSQ8P0wsGGfnHNhWLFc49hkAkOwdn2hwSzFSf4 azIx5zy6+JZxDULxStB3u2u1yBQZPL3vciqNuUjnIbK/7erxXBBYLl0C8yGqZ30wtoQ4 liCHEEt/hgHlyNb+LhnLqZHJ2E7IhfQ3ySAhMGDazPMDeGbSKygZogpj8ZpkhuT3fFj4 oc/I5LsCwntob7su2gmzg0XJOSCMZDi+7q7zVegv81aTErGbhRDd/4y9pn4bf25kYqO6 /8FQ== X-Gm-Message-State: AOAM532dZmbcTOW4ZL5otlj/70ZgMGWhsqWahNl81uOhx6bO39VDht/z yiPdgObZEVV2Pcy+YywobgI= X-Google-Smtp-Source: ABdhPJwlNRwofxQXQT8gDYyYbpa4g9JgJwom0b/sTOP/MIaP7DBJiX8ulLbceCJ7cCxSFTKLULDmdA== X-Received: by 2002:a17:90b:e8b:: with SMTP id fv11mr2499975pjb.66.1619155283170; Thu, 22 Apr 2021 22:21:23 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:22 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 06/15] net: ethernet: mtk_eth_soc: remove unnecessary TX queue stops Date: Thu, 22 Apr 2021 22:20:59 -0700 Message-Id: <20210423052108.423853-7-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau When running short on descriptors, only stop the queue for the netdev that tx was attempted for. By the time something tries to send on the other netdev, the ring might have some more room already. Signed-off-by: Felix Fietkau Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index d992d4f1f400..e6f832dde9a6 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1131,17 +1131,6 @@ static void mtk_wake_queue(struct mtk_eth *eth) } } -static void mtk_stop_queue(struct mtk_eth *eth) -{ - int i; - - for (i = 0; i < MTK_MAC_COUNT; i++) { - if (!eth->netdev[i]) - continue; - netif_stop_queue(eth->netdev[i]); - } -} - static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct mtk_mac *mac = netdev_priv(dev); @@ -1162,7 +1151,7 @@ static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) tx_num = mtk_cal_txd_req(skb); if (unlikely(atomic_read(&ring->free_count) <= tx_num)) { - mtk_stop_queue(eth); + netif_stop_queue(dev); netif_err(eth, tx_queued, dev, "Tx Ring full when queue awake!\n"); spin_unlock(ð->page_lock); @@ -1188,7 +1177,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)) - mtk_stop_queue(eth); + netif_stop_queue(dev); spin_unlock(ð->page_lock); From patchwork Fri Apr 23 05:21:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219567 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5956FC433B4 for ; Fri, 23 Apr 2021 05:21:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C53E611AE for ; Fri, 23 Apr 2021 05:21:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240645AbhDWFWI (ORCPT ); Fri, 23 Apr 2021 01:22:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240528AbhDWFWA (ORCPT ); Fri, 23 Apr 2021 01:22:00 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEDB3C061574; Thu, 22 Apr 2021 22:21:24 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id y22-20020a17090a8b16b0290150ae1a6d2bso646068pjn.0; Thu, 22 Apr 2021 22:21:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DV+kp1wpYcIFwJoJv9jeN6J03GSNSld+/Vb3IzRQLm0=; b=kGdqEK0YKXp9kFu3y7zjOBoYMHU5Ol8fp0zyDUkeJywlD5sRdudkYnSwLhfTLQMesg f2eNxWiHjMmZnLl4dtNbjrEmuIeoC4icA2Ao+ZxS9uvDSPiEl5vl2U2EXfeNaiJSS8Iz oR1wSsMucTUT+WIHKdKYamWygZMA6AzIPBqXNYOyskgT6Wecxs4+9rD6r6dHZDakFKSk L4zm5UDgCEOicAklt9AbQYH6M6Y1jrFRgu1mh1Rzeid5AIsMKXCxT5x3+2wUK/SSZ69C gElPReTCe2URmu5lepQRz+bOpUKGarsGeZJGHQvIZmIulnon8ZNFR6kbYzlzAJl71zvs 2jMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DV+kp1wpYcIFwJoJv9jeN6J03GSNSld+/Vb3IzRQLm0=; b=r7kOZkNOpdn+JG3CUqVjaeWU+ks4KkWTiG07Cj9BERQA40QlT2XUYEMDq2ruDEYdZe MSVokrvcRyvJnOYrrvzKxDJ4QVAocWcM0WyF/im8KeWHh0EyQ3OG6mEnjxOStguSs5AR 2klYYBu7iJHjoTRsg/Mw6EQSvH/Ne9kJNYQmUabfR5KkGXFnmHXmsYgtcb/a0W6NZ/99 6mTbyVtfK2P2jyu4Oc7cgHMB4hFu5uEMsbJT16WuE9XXgoAzjv6ZV2fA37QO1q6r4IWF NyApsCncYrc7quBFb0MiOQ+43SAsf9d/plYZsDxY4GYqjPrTU2i7HOJ5PHPRlYXRMAiG xyFQ== X-Gm-Message-State: AOAM533D0REJCVldB0MLi22PwN2U/GjdbopV6g0d4Pvxz7xaq14COj3S QDtJJXm1XTk1iOLDo5UH8ys= X-Google-Smtp-Source: ABdhPJwKi6H4kjc+Ur+ZaInetv6Q+x9mWcW2c/9xBF8znlsl3EvesadpGacIpglSKsHSuNgFUeehyA== X-Received: by 2002:a17:90b:2305:: with SMTP id mt5mr2562953pjb.198.1619155284334; Thu, 22 Apr 2021 22:21:24 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:23 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 07/15] net: ethernet: mtk_eth_soc: use larger burst size for QDMA TX Date: Thu, 22 Apr 2021 22:21:00 -0700 Message-Id: <20210423052108.423853-8-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau Improves tx performance Signed-off-by: Felix Fietkau Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index e6f832dde9a6..645360cfdfe9 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2193,7 +2193,7 @@ static int mtk_start_dma(struct mtk_eth *eth) if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { mtk_w32(eth, MTK_TX_WB_DDONE | MTK_TX_DMA_EN | - MTK_DMA_SIZE_16DWORDS | MTK_NDP_CO_PRO | + MTK_TX_BT_32DWORDS | MTK_NDP_CO_PRO | MTK_RX_DMA_EN | MTK_RX_2B_OFFSET | MTK_RX_BT_32DWORDS, MTK_QDMA_GLO_CFG); diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 875e67b41561..83883d86b881 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -203,7 +203,7 @@ #define MTK_RX_BT_32DWORDS (3 << 11) #define MTK_NDP_CO_PRO BIT(10) #define MTK_TX_WB_DDONE BIT(6) -#define MTK_DMA_SIZE_16DWORDS (2 << 4) +#define MTK_TX_BT_32DWORDS (3 << 4) #define MTK_RX_DMA_BUSY BIT(3) #define MTK_TX_DMA_BUSY BIT(1) #define MTK_RX_DMA_EN BIT(2) From patchwork Fri Apr 23 05:21:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219573 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53A26C43461 for ; Fri, 23 Apr 2021 05:21:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 291F8611AC for ; Fri, 23 Apr 2021 05:21:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240793AbhDWFWQ (ORCPT ); Fri, 23 Apr 2021 01:22:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240550AbhDWFWB (ORCPT ); Fri, 23 Apr 2021 01:22:01 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83B81C06174A; Thu, 22 Apr 2021 22:21:25 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id s20so8835927plr.13; Thu, 22 Apr 2021 22:21:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gg/rWc1cINoL2FH5CJEjCow0QyQU7jLI6ek3affIyww=; b=mVfonw9+g2aQXAAo6MdpHMUX05//o0mlrwM168LRxmOEU7Hj5nBFXMbwlFeS+XBWGG a6v3Qh91kRjJHP+9SKYN9FlBcqINPt+2vnqZlU27MJ4cLtIs17lYtUTptCoZtSdUFVRF A+wyQ2omVIrFTfBRjHgWXQbmG3+RSnBjjQIkVkekW8qoMIaTyw9KzKIF3ILq/kfBoz35 w3XphpbYiImmn2aEKJNlEg1cgzrtaXtFnkUsClO4Fq3uGv922YCYuLz0UNzLwxBeeVVg M0GslZ8/22jMbuz46w6tt1NVYRhQ0e/t7tObcDBeN2J/QYvULdb8cSsDoqvhFn4ur203 0TBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gg/rWc1cINoL2FH5CJEjCow0QyQU7jLI6ek3affIyww=; b=mEyoqEq5663PLV+n6PbqGK0bslFoYoqIhvS98YNO4Jck//a+AhM5xjPeVC1jjXHrWj GV3npnfLah9FY5bYkwbvyNvgKY/VDSQ+Y4kA8Uf+tHXuWFaXfyp9w2U/0hkypMg2ha/5 Rp6ZFo7PoQ6QHbLy7dGczFtPu8QLzvy/iNF1K+YPL349PYvu88wCsjJ7KopENn5anFVj uW/IWPMHr+x6cqLP/j9yagdt0wYHQ8Ld51S6rp2S99q6EU3T7TrnP0YjKzyxNWvBhayc V1ZpopXaZqRwXRILwYy1RhY5nlzo9Gcy8NNHWy537Cng/BYdIA5W2Ka/abQNzybcY65j Ux6A== X-Gm-Message-State: AOAM531UaPBSOnzdLrkxR2EVq6vdInMOvoKSgCkcOEKeWj3tWWfQjqQs jWzvllw5Z1zMOx2y/ghtx1I= X-Google-Smtp-Source: ABdhPJxAVghnaX081IZtbsM8hmJXe+URl3wx1vFIBP0POUNj0vLcd2sYlm6nrYC/A+GuYl8TXNLOyA== X-Received: by 2002:a17:902:109:b029:ec:9f64:c53d with SMTP id 9-20020a1709020109b02900ec9f64c53dmr2003503plb.83.1619155285132; Thu, 22 Apr 2021 22:21:25 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:24 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 08/15] net: ethernet: mtk_eth_soc: increase DMA ring sizes Date: Thu, 22 Apr 2021 22:21:01 -0700 Message-Id: <20210423052108.423853-9-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau 256 descriptors is not enough for multi-gigabit traffic under load on MT7622. Bump it to 512 to improve performance. Signed-off-by: Felix Fietkau Signed-off-by: Ilya Lipnitskiy --- 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 83883d86b881..540a5771b7bf 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -22,7 +22,7 @@ #define MTK_MAX_RX_LENGTH 1536 #define MTK_MAX_RX_LENGTH_2K 2048 #define MTK_TX_DMA_BUF_LEN 0x3fff -#define MTK_DMA_SIZE 256 +#define MTK_DMA_SIZE 512 #define MTK_NAPI_WEIGHT 64 #define MTK_MAC_COUNT 2 #define MTK_RX_ETH_HLEN (ETH_HLEN + ETH_FCS_LEN) From patchwork Fri Apr 23 05:21:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219575 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BE6FC433B4 for ; Fri, 23 Apr 2021 05:21:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FAC5611AC for ; Fri, 23 Apr 2021 05:21:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240649AbhDWFWS (ORCPT ); Fri, 23 Apr 2021 01:22:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240554AbhDWFWC (ORCPT ); Fri, 23 Apr 2021 01:22:02 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D279C061574; Thu, 22 Apr 2021 22:21:26 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id lr7so6368200pjb.2; Thu, 22 Apr 2021 22:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/tl544PHYxLi+N2i7ngnwlxcj+Rbz0d3P3L6WQG3naQ=; b=GOjQ0OHZYLLjEiYkTiDgdlMnTK78vt8I3utJmM2zyHkI4o7xSlIojkrXuIyN9qO2O2 Ep/6xGa59BzRMJ9XOsh7+PPhetOE1VUZcjUQpnvBP8QHkEay5MUJRMR3E8YTKHAx0nBb dFh7+AQAY4+vhpcjilfTE/CSyn+pS2piOtYi93GL2Uea+hv6UwzO1eVga2VbhYteaMTd DSHt/m8UvUuWnvdxGx70Y1JKzS7bvDG94X5bneEk3RalAiWbWJ9FyIqIn8Js6IWtbHYX vzbJk2hEkPl1DyhfINkCve1qUxoy1YHQ21f6POwb3GbQI2FAOHUC79TH/GeeIXyJYFM7 CUyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/tl544PHYxLi+N2i7ngnwlxcj+Rbz0d3P3L6WQG3naQ=; b=SIwRyyTS5rtb39rJGgN24dHG3BKtenaxs1WoBHEn/iHtzn5qyrR0/fnjIAbV7OTr3p 4KV/doTtMv4b2mxuNHTAmFnz70gBA5HQ5A3bRM0SDE1B1L6Xu+yqjtGV/XRHbs725ZFM 4Jh2zvwSFVIt0Ad7fV+hBz/8lWLLz7zBrJiLrvxWU4C2n/85X0dfhRMe1HAg9hN2KFoR TpSuDCkYm7jNr6fhZrO6V7Jp2veaP6LeBzdnGdWAwustf6ON9jZXlDDI9dcdsEJwe9XB PqNwHJN2+rJhB7zqfssZ638p63X/9dOfoF/ArK7BOoUU1s9VQ2WE+VFht1p7qyzgH4mJ a1gg== X-Gm-Message-State: AOAM531JiRl8NMV8UI7hMxuS7aOlasHd5rp9Wmz6qKLZqxfxMKTntj3O qM3juu27ofutQ6h2NsdyVyQ= X-Google-Smtp-Source: ABdhPJzdfQWrmsC3D6zO4OEsuhqIyOK7jwLdGIMNXbENFu6+NDyOTx4bErj8jVjJzGmKgVDYLFj78w== X-Received: by 2002:a17:902:b18f:b029:ec:7ac0:fd1a with SMTP id s15-20020a170902b18fb02900ec7ac0fd1amr2074284plr.84.1619155286073; Thu, 22 Apr 2021 22:21:26 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:25 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 09/15] net: ethernet: mtk_eth_soc: implement dynamic interrupt moderation Date: Thu, 22 Apr 2021 22:21:02 -0700 Message-Id: <20210423052108.423853-10-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau Reduces the number of interrupts under load Signed-off-by: Felix Fietkau [Ilya: add documentation for new struct fields] Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/Kconfig | 1 + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 96 +++++++++++++++++++-- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 41 +++++++-- 3 files changed, 124 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/mediatek/Kconfig b/drivers/net/ethernet/mediatek/Kconfig index 08c2e446d3d5..c357c193378e 100644 --- a/drivers/net/ethernet/mediatek/Kconfig +++ b/drivers/net/ethernet/mediatek/Kconfig @@ -11,6 +11,7 @@ config NET_MEDIATEK_SOC tristate "MediaTek SoC Gigabit Ethernet support" depends on NET_DSA || !NET_DSA select PHYLINK + select DIMLIB help This driver supports the gigabit ethernet MACs in the MediaTek SoC family. diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 645360cfdfe9..762e985fa294 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1233,12 +1233,13 @@ static void mtk_update_rx_cpu_idx(struct mtk_eth *eth) static int mtk_poll_rx(struct napi_struct *napi, int budget, struct mtk_eth *eth) { + struct dim_sample dim_sample = {}; struct mtk_rx_ring *ring; int idx; struct sk_buff *skb; u8 *data, *new_data; struct mtk_rx_dma *rxd, trxd; - int done = 0; + int done = 0, bytes = 0; while (done < budget) { struct net_device *netdev; @@ -1312,6 +1313,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, else skb_checksum_none_assert(skb); skb->protocol = eth_type_trans(skb, netdev); + bytes += pktlen; if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX && (trxd.rxd2 & RX_DMA_VTAG)) @@ -1344,6 +1346,12 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, mtk_update_rx_cpu_idx(eth); } + eth->rx_packets += done; + eth->rx_bytes += bytes; + dim_update_sample(eth->rx_events, eth->rx_packets, eth->rx_bytes, + &dim_sample); + net_dim(ð->rx_dim, dim_sample); + return done; } @@ -1436,6 +1444,7 @@ static int mtk_poll_tx_pdma(struct mtk_eth *eth, int budget, 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; @@ -1453,8 +1462,14 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget) continue; netdev_completed_queue(eth->netdev[i], done[i], bytes[i]); total += done[i]; + eth->tx_packets += done[i]; + eth->tx_bytes += bytes[i]; } + dim_update_sample(eth->tx_events, eth->tx_packets, eth->tx_bytes, + &dim_sample); + net_dim(ð->tx_dim, dim_sample); + if (mtk_queue_stopped(eth) && (atomic_read(&ring->free_count) > ring->thresh)) mtk_wake_queue(eth); @@ -2129,6 +2144,7 @@ static irqreturn_t mtk_handle_irq_rx(int irq, void *_eth) { struct mtk_eth *eth = _eth; + eth->rx_events++; if (likely(napi_schedule_prep(ð->rx_napi))) { __napi_schedule(ð->rx_napi); mtk_rx_irq_disable(eth, MTK_RX_DONE_INT); @@ -2141,6 +2157,7 @@ static irqreturn_t mtk_handle_irq_tx(int irq, void *_eth) { struct mtk_eth *eth = _eth; + eth->tx_events++; if (likely(napi_schedule_prep(ð->tx_napi))) { __napi_schedule(ð->tx_napi); mtk_tx_irq_disable(eth, MTK_TX_DONE_INT); @@ -2325,6 +2342,9 @@ static int mtk_stop(struct net_device *dev) napi_disable(ð->tx_napi); napi_disable(ð->rx_napi); + cancel_work_sync(ð->rx_dim.work); + cancel_work_sync(ð->tx_dim.work); + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) mtk_stop_dma(eth, MTK_QDMA_GLO_CFG); mtk_stop_dma(eth, MTK_PDMA_GLO_CFG); @@ -2377,6 +2397,64 @@ static int mtk_clk_enable(struct mtk_eth *eth) return ret; } +static void mtk_dim_rx(struct work_struct *work) +{ + struct dim *dim = container_of(work, struct dim, work); + struct mtk_eth *eth = container_of(dim, struct mtk_eth, rx_dim); + struct dim_cq_moder cur_profile; + u32 val, cur; + + cur_profile = net_dim_get_rx_moderation(eth->rx_dim.mode, + dim->profile_ix); + spin_lock_bh(ð->dim_lock); + + val = mtk_r32(eth, MTK_PDMA_DELAY_INT); + val &= MTK_PDMA_DELAY_TX_MASK; + val |= MTK_PDMA_DELAY_RX_EN; + + cur = min_t(u32, DIV_ROUND_UP(cur_profile.usec, 20), MTK_PDMA_DELAY_PTIME_MASK); + val |= cur << MTK_PDMA_DELAY_RX_PTIME_SHIFT; + + cur = min_t(u32, cur_profile.pkts, MTK_PDMA_DELAY_PINT_MASK); + val |= cur << MTK_PDMA_DELAY_RX_PINT_SHIFT; + + mtk_w32(eth, val, MTK_PDMA_DELAY_INT); + mtk_w32(eth, val, MTK_QDMA_DELAY_INT); + + spin_unlock_bh(ð->dim_lock); + + dim->state = DIM_START_MEASURE; +} + +static void mtk_dim_tx(struct work_struct *work) +{ + struct dim *dim = container_of(work, struct dim, work); + struct mtk_eth *eth = container_of(dim, struct mtk_eth, tx_dim); + struct dim_cq_moder cur_profile; + u32 val, cur; + + cur_profile = net_dim_get_tx_moderation(eth->tx_dim.mode, + dim->profile_ix); + spin_lock_bh(ð->dim_lock); + + val = mtk_r32(eth, MTK_PDMA_DELAY_INT); + val &= MTK_PDMA_DELAY_RX_MASK; + val |= MTK_PDMA_DELAY_TX_EN; + + cur = min_t(u32, DIV_ROUND_UP(cur_profile.usec, 20), MTK_PDMA_DELAY_PTIME_MASK); + val |= cur << MTK_PDMA_DELAY_TX_PTIME_SHIFT; + + cur = min_t(u32, cur_profile.pkts, MTK_PDMA_DELAY_PINT_MASK); + val |= cur << MTK_PDMA_DELAY_TX_PINT_SHIFT; + + mtk_w32(eth, val, MTK_PDMA_DELAY_INT); + mtk_w32(eth, val, MTK_QDMA_DELAY_INT); + + spin_unlock_bh(ð->dim_lock); + + dim->state = DIM_START_MEASURE; +} + static int mtk_hw_init(struct mtk_eth *eth) { int i, val, ret; @@ -2398,9 +2476,6 @@ static int mtk_hw_init(struct mtk_eth *eth) goto err_disable_pm; } - /* enable interrupt delay for RX */ - mtk_w32(eth, MTK_PDMA_DELAY_RX_DELAY, MTK_PDMA_DELAY_INT); - /* disable delay and normal interrupt */ mtk_tx_irq_disable(eth, ~0); mtk_rx_irq_disable(eth, ~0); @@ -2439,11 +2514,11 @@ static int mtk_hw_init(struct mtk_eth *eth) /* Enable RX VLan Offloading */ mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); - /* enable interrupt delay for RX */ - mtk_w32(eth, MTK_PDMA_DELAY_RX_DELAY, MTK_PDMA_DELAY_INT); + /* set interrupt delays based on current Net DIM sample */ + mtk_dim_rx(ð->rx_dim.work); + mtk_dim_tx(ð->tx_dim.work); /* disable delay and normal interrupt */ - mtk_w32(eth, 0, MTK_QDMA_DELAY_INT); mtk_tx_irq_disable(eth, ~0); mtk_rx_irq_disable(eth, ~0); @@ -2978,6 +3053,13 @@ static int mtk_probe(struct platform_device *pdev) spin_lock_init(ð->page_lock); spin_lock_init(ð->tx_irq_lock); spin_lock_init(ð->rx_irq_lock); + spin_lock_init(ð->dim_lock); + + eth->rx_dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; + INIT_WORK(ð->rx_dim.work, mtk_dim_rx); + + eth->tx_dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; + INIT_WORK(ð->tx_dim.work, mtk_dim_tx); if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) { eth->ethsys = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 540a5771b7bf..ceb5a4a661e6 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -16,6 +16,7 @@ #include #include #include +#include #include "mtk_ppe.h" #define MTK_QDMA_PAGE_SIZE 2048 @@ -137,13 +138,18 @@ /* PDMA Delay Interrupt Register */ #define MTK_PDMA_DELAY_INT 0xa0c +#define MTK_PDMA_DELAY_RX_MASK GENMASK(15, 0) #define MTK_PDMA_DELAY_RX_EN BIT(15) -#define MTK_PDMA_DELAY_RX_PINT 4 #define MTK_PDMA_DELAY_RX_PINT_SHIFT 8 -#define MTK_PDMA_DELAY_RX_PTIME 4 -#define MTK_PDMA_DELAY_RX_DELAY \ - (MTK_PDMA_DELAY_RX_EN | MTK_PDMA_DELAY_RX_PTIME | \ - (MTK_PDMA_DELAY_RX_PINT << MTK_PDMA_DELAY_RX_PINT_SHIFT)) +#define MTK_PDMA_DELAY_RX_PTIME_SHIFT 0 + +#define MTK_PDMA_DELAY_TX_MASK GENMASK(31, 16) +#define MTK_PDMA_DELAY_TX_EN BIT(31) +#define MTK_PDMA_DELAY_TX_PINT_SHIFT 24 +#define MTK_PDMA_DELAY_TX_PTIME_SHIFT 16 + +#define MTK_PDMA_DELAY_PINT_MASK 0x7f +#define MTK_PDMA_DELAY_PTIME_MASK 0xff /* PDMA Interrupt Status Register */ #define MTK_PDMA_INT_STATUS 0xa20 @@ -225,6 +231,7 @@ /* QDMA Interrupt Status Register */ #define MTK_QDMA_INT_STATUS 0x1A18 #define MTK_RX_DONE_DLY BIT(30) +#define MTK_TX_DONE_DLY BIT(28) #define MTK_RX_DONE_INT3 BIT(19) #define MTK_RX_DONE_INT2 BIT(18) #define MTK_RX_DONE_INT1 BIT(17) @@ -234,8 +241,7 @@ #define MTK_TX_DONE_INT1 BIT(1) #define MTK_TX_DONE_INT0 BIT(0) #define MTK_RX_DONE_INT MTK_RX_DONE_DLY -#define MTK_TX_DONE_INT (MTK_TX_DONE_INT0 | MTK_TX_DONE_INT1 | \ - MTK_TX_DONE_INT2 | MTK_TX_DONE_INT3) +#define MTK_TX_DONE_INT MTK_TX_DONE_DLY /* QDMA Interrupt grouping registers */ #define MTK_QDMA_INT_GRP1 0x1a20 @@ -849,6 +855,7 @@ struct mtk_sgmii { * @page_lock: Make sure that register operations are atomic * @tx_irq__lock: Make sure that IRQ register operations are atomic * @rx_irq__lock: Make sure that IRQ register operations are atomic + * @dim_lock: Make sure that Net DIM operations are atomic * @dummy_dev: we run 2 netdevs on 1 physical DMA ring and need a * dummy for NAPI to work * @netdev: The netdev instances @@ -867,6 +874,14 @@ struct mtk_sgmii { * @rx_ring_qdma: Pointer to the memory holding info about the QDMA RX ring * @tx_napi: The TX NAPI struct * @rx_napi: The RX NAPI struct + * @rx_events: Net DIM RX event counter + * @rx_packets: Net DIM RX packet counter + * @rx_bytes: Net DIM RX byte counter + * @rx_dim: Net DIM RX context + * @tx_events: Net DIM TX event counter + * @tx_packets: Net DIM TX packet counter + * @tx_bytes: Net DIM TX byte counter + * @tx_dim: Net DIM TX context * @scratch_ring: Newer SoCs need memory for a second HW managed TX ring * @phy_scratch_ring: physical address of scratch_ring * @scratch_head: The scratch memory that scratch_ring points to. @@ -911,6 +926,18 @@ struct mtk_eth { const struct mtk_soc_data *soc; + spinlock_t dim_lock; + + u32 rx_events; + u32 rx_packets; + u32 rx_bytes; + struct dim rx_dim; + + u32 tx_events; + u32 tx_packets; + u32 tx_bytes; + struct dim tx_dim; + u32 tx_int_mask_reg; u32 tx_int_status_reg; u32 rx_dma_l4_valid; From patchwork Fri Apr 23 05:21:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219583 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F213C433ED for ; Fri, 23 Apr 2021 05:21:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 139D5613E6 for ; Fri, 23 Apr 2021 05:21:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240986AbhDWFW3 (ORCPT ); Fri, 23 Apr 2021 01:22:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240634AbhDWFWH (ORCPT ); Fri, 23 Apr 2021 01:22:07 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C24C061756; Thu, 22 Apr 2021 22:21:27 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id v13so11081985ple.9; Thu, 22 Apr 2021 22:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WjE5MA7+4ZwCbbfRd+W09i2u6oXOwprynyvP1BlKeH0=; b=rvrdXEYt3aYj+BQSLJgMTnmz3tc0r1wUQy6VEvCfqjFf7givy59PpsJmNcNr0zDT69 Zv+4YNmRpL0ykgP/b256UnnKlEAQDaTIfyDFYJRIHn6wj/wooGmQyh7hXrA21H9lRECh fIwPLNvfyBEUcZvLofKnUNGNVwrr4TkigBMx9kB2Z65/uE1cph+JPJR8lXB0CG8ZS1Vu X0dJwoux8RrqrLUqQPTTXUOCV+BQ/MAssjz3u/XTAp9sRTXqDHbMNOmOGid1a5ehh8PJ afEC1GSVr9sN94utHBWywVaTOLwFi8hhnzB/nwUj4vj1NjC0X6s3RIVaJWd86or/6/du KnUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WjE5MA7+4ZwCbbfRd+W09i2u6oXOwprynyvP1BlKeH0=; b=hhXR6twsKIVFLNGB0S+tdAIZSVQY0oYA3SdIXbx2XLRni63K99ohVyz9AQskasd6fm uZdRat2HKgWIwAb6S9RIXe4XmSmcQ4EVGUXC20mwJgItyips2sBNqpsZkZZVHpLdT4a+ sxhKGoc7jUIT8sSzVB/9v8nVU4qA+CJGNmF7cTgFd4CfFoXRABn1YrdBz2+SDd2gRQ4Y tsaln6mqo1SX0/vnYCLuJmYlErBm/6vnUpAn6d6rSkSyUNQHJNim/z6r14wq/0Wu/WqB 57Rsa3oovGTMB7MN0zHg3ffdV2nbrOfRefo99GPhCmVfxKusg1uIKR18L5JYkvMJBSl/ jdtw== X-Gm-Message-State: AOAM532KYk0NfQlAG1pbPRiRJhiR5mwv1QDj6/5mxFKRAMV1jahdiIWf szlvU6Jlu1zmt3JGfT9xnE8= X-Google-Smtp-Source: ABdhPJyCaNlZckAPemEXQ82FX6NwJGUY7Fgm5nHIx1qKilOw/gQY1vokrG4/l7E6695NagFitzHsTw== X-Received: by 2002:a17:90b:2482:: with SMTP id nt2mr3805572pjb.13.1619155287083; Thu, 22 Apr 2021 22:21:27 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:26 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 10/15] net: ethernet: mtk_eth_soc: cache HW pointer of last freed TX descriptor Date: Thu, 22 Apr 2021 22:21:03 -0700 Message-Id: <20210423052108.423853-11-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau The value is only updated by the CPU, so it is cheaper to access from the ring data structure than from a hardware register. Signed-off-by: Felix Fietkau Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 8 ++++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 762e985fa294..6d23118b7a6c 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1364,7 +1364,7 @@ static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget, struct mtk_tx_buf *tx_buf; u32 cpu, dma; - cpu = mtk_r32(eth, MTK_QTX_CRX_PTR); + cpu = ring->last_free_ptr; dma = mtk_r32(eth, MTK_QTX_DRX_PTR); desc = mtk_qdma_phys_to_virt(ring, cpu); @@ -1398,6 +1398,7 @@ static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget, cpu = next_cpu; } + ring->last_free_ptr = cpu; mtk_w32(eth, cpu, MTK_QTX_CRX_PTR); return budget; @@ -1598,6 +1599,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth) atomic_set(&ring->free_count, MTK_DMA_SIZE - 2); ring->next_free = &ring->dma[0]; ring->last_free = &ring->dma[MTK_DMA_SIZE - 1]; + ring->last_free_ptr = (u32)(ring->phys + ((MTK_DMA_SIZE - 1) * sz)); ring->thresh = MAX_SKB_FRAGS; /* make sure that all changes to the dma ring are flushed before we @@ -1611,9 +1613,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth) mtk_w32(eth, ring->phys + ((MTK_DMA_SIZE - 1) * sz), MTK_QTX_CRX_PTR); - mtk_w32(eth, - ring->phys + ((MTK_DMA_SIZE - 1) * sz), - MTK_QTX_DRX_PTR); + mtk_w32(eth, ring->last_free_ptr, MTK_QTX_DRX_PTR); mtk_w32(eth, (QDMA_RES_THRES << 8) | QDMA_RES_THRES, MTK_QTX_CFG(0)); } else { diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index ceb5a4a661e6..6b92dd6c2cda 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -642,6 +642,7 @@ struct mtk_tx_buf { * @phys: The physical addr of tx_buf * @next_free: Pointer to the next free descriptor * @last_free: Pointer to the last free descriptor + * @last_free_ptr: Hardware pointer value of the last free descriptor * @thresh: The threshold of minimum amount of free descriptors * @free_count: QDMA uses a linked list. Track how many free descriptors * are present @@ -652,6 +653,7 @@ struct mtk_tx_ring { dma_addr_t phys; struct mtk_tx_dma *next_free; struct mtk_tx_dma *last_free; + u32 last_free_ptr; u16 thresh; atomic_t free_count; int dma_size; From patchwork Fri Apr 23 05:21:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219579 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F6FCC433ED for ; Fri, 23 Apr 2021 05:21:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40FF0611C2 for ; Fri, 23 Apr 2021 05:21:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240524AbhDWFWZ (ORCPT ); Fri, 23 Apr 2021 01:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240603AbhDWFWF (ORCPT ); Fri, 23 Apr 2021 01:22:05 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 559FBC06138B; Thu, 22 Apr 2021 22:21:28 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id em21-20020a17090b0155b029014e204a81e6so3890435pjb.1; Thu, 22 Apr 2021 22:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZjOoYVT7YenRNOA8qc+XyIjvt2WMHLDSuOV16uduX+U=; b=U3CLhQ7h0Dxhy+BHEyMa6zfMvJ1QXxRb+OUfRqHbNtc1NYbaDgTwPylzJd10DHemPK tgWtd/XNQy2NjW+hjsqDm0i1SQ2Xxp18zBvNSjOCJT+gVK1/N3e9xqszGy2w/QvEDCPV jbI7uyGCWysHHK1M6rVrHmh9QaOjHYrQhkRG28spyUgikNXbwXwGtTrm7G1DVa/1Tm3t v/LFb26rxLKf+u3Oe7aQcGUrtF5Wo6iJgxezNiAHiVPaIw52CGvzAsHrmqhbkZ1nj9Vg GP7J6xfG0yl8mPgav+RxuFbSCAXXbsgrPA7K/DvT1E0Y2DYpVEtj6oi2e3wPIIYUSfsi P8Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZjOoYVT7YenRNOA8qc+XyIjvt2WMHLDSuOV16uduX+U=; b=exCV7IOx3wkIy2k/27/noq1cWu8dYli9Lc4Z4gtqV2dqp/SiqaMg3jrW1gVuKALXLO ichk5+szs58IpWcM6/z9IHEhsN3QBVGJoq1wIcrBVhVamXUUOTk6KKhgu5dYHWREXIOg TYG3iQfp/rxTO0xqQksnCBvtVtu4D14k9qswGXw1azWo2oZQ4T5LIke/dORC249I0OZx qRrU23mwJPMSB/pk6xwrmitMDz9H8ggLxTlXjUmZ1g1LVKy/zN/PzouzBFFOr+AFAOie CnZchv2lt60QXIJI5OElt1q7FI1Wa8GopV9Hqo4Gtb18Gh48icQQk3lc3wCotr8r8a3X e6qw== X-Gm-Message-State: AOAM532i2emGCLi6wzg/f4eRk/8wxy+ysKfAP645QdNqSUrfjYxRL64n zenPSV5AHXdTLK2AWzjlGqSp5DYIGtcOtLz7 X-Google-Smtp-Source: ABdhPJwpbeLxgmvWdgaaDoj1/CFLwGXveStOfAhuLSfGsDI2iAwOKlTiAC7TMO1Pm1GYVNkff3cfVw== X-Received: by 2002:a17:902:4c:b029:ec:a39a:41ad with SMTP id 70-20020a170902004cb02900eca39a41admr2348006pla.52.1619155287923; Thu, 22 Apr 2021 22:21:27 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:27 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 11/15] net: ethernet: mtk_eth_soc: only read the full RX descriptor if DMA is done Date: Thu, 22 Apr 2021 22:21:04 -0700 Message-Id: <20210423052108.423853-12-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau Uncached memory access is expensive, and there is no need to access all descriptor words if we can't process them anyway Signed-off-by: Felix Fietkau Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 6d23118b7a6c..4735942ed283 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -777,13 +777,18 @@ static inline int mtk_max_buf_size(int frag_size) return buf_size; } -static inline void mtk_rx_get_desc(struct mtk_rx_dma *rxd, +static inline bool mtk_rx_get_desc(struct mtk_rx_dma *rxd, struct mtk_rx_dma *dma_rxd) { - rxd->rxd1 = READ_ONCE(dma_rxd->rxd1); rxd->rxd2 = READ_ONCE(dma_rxd->rxd2); + if (!(rxd->rxd2 & RX_DMA_DONE)) + return false; + + rxd->rxd1 = READ_ONCE(dma_rxd->rxd1); rxd->rxd3 = READ_ONCE(dma_rxd->rxd3); rxd->rxd4 = READ_ONCE(dma_rxd->rxd4); + + return true; } /* the qdma core needs scratch memory to be setup */ @@ -1255,8 +1260,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, rxd = &ring->dma[idx]; data = ring->data[idx]; - mtk_rx_get_desc(&trxd, rxd); - if (!(trxd.rxd2 & RX_DMA_DONE)) + if (!mtk_rx_get_desc(&trxd, rxd)) break; /* find out which mac the packet come from. values start at 1 */ From patchwork Fri Apr 23 05:21:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219577 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E10AC433B4 for ; Fri, 23 Apr 2021 05:21:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B5F4611C2 for ; Fri, 23 Apr 2021 05:21:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240745AbhDWFWV (ORCPT ); Fri, 23 Apr 2021 01:22:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240597AbhDWFWE (ORCPT ); Fri, 23 Apr 2021 01:22:04 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E3FCC06138C; Thu, 22 Apr 2021 22:21:29 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id y22-20020a17090a8b16b0290150ae1a6d2bso646149pjn.0; Thu, 22 Apr 2021 22:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gd2eeenzHzwxV4sfn08mWZUyZJLiTmgc3YKbWO6N3GU=; b=qH12pRVy93Bpwpu9grmZX/L/ts8gdwG8rLRbo6+mrLLehr1BCvFrMpf+YUOHiDYyXW p3TG8yP/iZIrQVa+VoYBMyaiSHb8prsVoMYBhgWQ4Sj7ZZmzAJjG4GbbSveS9WXYExFJ tfnj8xWDI69wTmaGqHq8NVxqBxcKPQF2+Zdq1hxsERD9tOqsymiaSA3Y5bkbK4Tf6P6+ 05kaVXqTtH6JA2NB0NqkqAme+F9DdohNa0fAuv/WNxuc3KYx9BxEf5J8cepxIgwwMjsr c1B5YPeIljm23GYN+CJfPHwxR1qygxc2GOA1jRNRKY0KpEr/BkhR44AIr/qO6giYqzUy ucqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gd2eeenzHzwxV4sfn08mWZUyZJLiTmgc3YKbWO6N3GU=; b=R1quE44qABIgr92cM16bzi+arI+62osAApKfy2wEugwfOID9jo94mRDMI44DwBBeP1 IteNLTp7gcxA9AxzJvwy65q97nE+lHJQY/kF9/mCIYaoYlngm9e9OqauUopliMCW5Tqu ygabSGF8Lwfc0+IumPei/TPhw+UGQQdqExI3Sm6SZHjunji6OBG+Zukwq5DyEaB/BG73 q2yq0gsEyGuxE/hcpz1cqDclQqKmTX4ELJ9vsGnC+hrQQyF5CYzUBKxgIKJuE6F4YeZi 3nQJj9DJskvfF6c7g7/MfKG818qPitDz56F4eJ4Xt8eBE+Z9N9OcLlg+XkQbcVx9Yt0l XcUA== X-Gm-Message-State: AOAM530FocZ5Jyxy0OeNggrKdpUzC07PYS/b6YL+oBBNej4+4uMoh1r6 lE8eNjLH7/tYB+6/dOl2Xm4= X-Google-Smtp-Source: ABdhPJzSMCg+HXa0Dmt7mvnI+vnZq8ce7m2ns7uSGSYbxV/thCTkhu7yKbJoA8wAJIdnkYkmDVrFwQ== X-Received: by 2002:a17:902:b68c:b029:eb:6c82:60da with SMTP id c12-20020a170902b68cb02900eb6c8260damr2410047pls.25.1619155288670; Thu, 22 Apr 2021 22:21:28 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:28 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 12/15] net: ethernet: mtk_eth_soc: reduce unnecessary interrupts Date: Thu, 22 Apr 2021 22:21:05 -0700 Message-Id: <20210423052108.423853-13-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau Avoid rearming interrupt if napi_complete returns false Signed-off-by: Felix Fietkau Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 4735942ed283..e1792ccaedc3 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1519,8 +1519,8 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget) if (status & MTK_TX_DONE_INT) return budget; - napi_complete(napi); - mtk_tx_irq_enable(eth, MTK_TX_DONE_INT); + if (napi_complete(napi)) + mtk_tx_irq_enable(eth, MTK_TX_DONE_INT); return tx_done; } @@ -1553,8 +1553,9 @@ static int mtk_napi_rx(struct napi_struct *napi, int budget) remain_budget -= rx_done; goto poll_again; } - napi_complete(napi); - mtk_rx_irq_enable(eth, MTK_RX_DONE_INT); + + if (napi_complete(napi)) + mtk_rx_irq_enable(eth, MTK_RX_DONE_INT); return rx_done + budget - remain_budget; } From patchwork Fri Apr 23 05:21:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219581 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58C53C43461 for ; Fri, 23 Apr 2021 05:21:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B6D8613DB for ; Fri, 23 Apr 2021 05:21:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240809AbhDWFW1 (ORCPT ); Fri, 23 Apr 2021 01:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240602AbhDWFWF (ORCPT ); Fri, 23 Apr 2021 01:22:05 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF37FC06138D; Thu, 22 Apr 2021 22:21:29 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id o16so11066563plg.5; Thu, 22 Apr 2021 22:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cVCvFP7FkhaoSFqQuRF6Qi4Ni9yogvujik129mGGQRY=; b=b8DQMctCJXEHiD048Y5scEAzRTZ7QYvWF0SxauygF7xjyqpaGVHJSji2oR+CngdSj/ vvS7D2kVSZtdUKViEdS0uSACqA5QM0IpxROAN41YOz8O9yNm4+RSTCa2GYpdTTZnGvA/ NrCPPzaCIkTwUEL+ftiCUwGmNEvco9FLYkjBz7WLg19cJk/cENK55WipKFnstSh1vyhm ldz7VUzgN1E782MgEVp44U7FVEY7gY2anAgw5F0BC7BUwMmHOuXyAkA3zUC0HUa58uxH MQo0nC9HZTuh+PjehkK4X4hHwiVBoTDa3ADj/945jPJatpfXrlT72yao2WwYMjrZRHn4 OeSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cVCvFP7FkhaoSFqQuRF6Qi4Ni9yogvujik129mGGQRY=; b=l+qbO7OMdFVJbdkLrWgIa9nbXET2ztOtCk+wawoLyr5TiDcEG8L5ZNz04xkXQ/3v3L TkISxKPuI31aMmLugVy9YmZsGaJtzHaTOMpGiYs1okxeFAB0Ta/zHJYHkPxDOsaK0IDo 3Ow2MONBOQ5UVJiC9wSXfTFlVY0DrjerQyRD33G/LB6yKcsWbbelJYQhFkPDm9zHGZOo KZsmr618otCzbMZzmazxwSb/wMCeWBCMdhZ2jow2XYJTiKoPE/BJuKaJGfg27Tcj0YqS Dc2PM6DLMK5YG2dotbqfpZ+hFqUPjYN03iQ/4xrSwdT46OtPfcAEwEMApvv934StUWyC Zcsw== X-Gm-Message-State: AOAM530CcQ+0s4FqKLDkxukGpQivtqcljlfzNkylCsow9msYnJ57JqKg zJAMgP5Jux3scNaD1Pg5Hew= X-Google-Smtp-Source: ABdhPJzlYQGDMbvjAhTMbiHqgzZgVDWONAAlUkjdJXUrpAtnk/pfi10MLR7qP/KayIypU4kejcy7TA== X-Received: by 2002:a17:90a:4f41:: with SMTP id w1mr3896776pjl.231.1619155289404; Thu, 22 Apr 2021 22:21:29 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:29 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 13/15] net: ethernet: mtk_eth_soc: rework NAPI callbacks Date: Thu, 22 Apr 2021 22:21:06 -0700 Message-Id: <20210423052108.423853-14-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Use napi_complete_done to communicate total TX and RX work done to NAPI. Count total RX work up instead of remaining work down for clarity. Remove unneeded local variables for clarity. Use do {} while instead of goto for clarity. Suggested-by: Jakub Kicinski Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 54 +++++++++------------ 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index e1792ccaedc3..8faf8fb1c83a 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1496,7 +1496,6 @@ static void mtk_handle_status_irq(struct mtk_eth *eth) static int mtk_napi_tx(struct napi_struct *napi, int budget) { struct mtk_eth *eth = container_of(napi, struct mtk_eth, tx_napi); - u32 status, mask; int tx_done = 0; if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) @@ -1505,21 +1504,19 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget) tx_done = mtk_poll_tx(eth, budget); if (unlikely(netif_msg_intr(eth))) { - status = mtk_r32(eth, eth->tx_int_status_reg); - mask = mtk_r32(eth, eth->tx_int_mask_reg); dev_info(eth->dev, - "done tx %d, intr 0x%08x/0x%x\n", - tx_done, status, mask); + "done tx %d, intr 0x%08x/0x%x\n", tx_done, + mtk_r32(eth, eth->tx_int_status_reg), + mtk_r32(eth, eth->tx_int_mask_reg)); } if (tx_done == budget) return budget; - status = mtk_r32(eth, eth->tx_int_status_reg); - if (status & MTK_TX_DONE_INT) + if (mtk_r32(eth, eth->tx_int_status_reg) & MTK_TX_DONE_INT) return budget; - if (napi_complete(napi)) + if (napi_complete_done(napi, tx_done)) mtk_tx_irq_enable(eth, MTK_TX_DONE_INT); return tx_done; @@ -1528,36 +1525,33 @@ static int mtk_napi_tx(struct napi_struct *napi, int budget) static int mtk_napi_rx(struct napi_struct *napi, int budget) { struct mtk_eth *eth = container_of(napi, struct mtk_eth, rx_napi); - u32 status, mask; - int rx_done = 0; - int remain_budget = budget; + int rx_done_total = 0; mtk_handle_status_irq(eth); -poll_again: - mtk_w32(eth, MTK_RX_DONE_INT, MTK_PDMA_INT_STATUS); - rx_done = mtk_poll_rx(napi, remain_budget, eth); + do { + int rx_done; - if (unlikely(netif_msg_intr(eth))) { - status = mtk_r32(eth, MTK_PDMA_INT_STATUS); - mask = mtk_r32(eth, MTK_PDMA_INT_MASK); - dev_info(eth->dev, - "done rx %d, intr 0x%08x/0x%x\n", - rx_done, status, mask); - } - if (rx_done == remain_budget) - return budget; + mtk_w32(eth, MTK_RX_DONE_INT, MTK_PDMA_INT_STATUS); + rx_done = mtk_poll_rx(napi, budget - rx_done_total, eth); + rx_done_total += rx_done; - status = mtk_r32(eth, MTK_PDMA_INT_STATUS); - if (status & MTK_RX_DONE_INT) { - remain_budget -= rx_done; - goto poll_again; - } + if (unlikely(netif_msg_intr(eth))) { + dev_info(eth->dev, + "done rx %d, intr 0x%08x/0x%x\n", rx_done, + mtk_r32(eth, MTK_PDMA_INT_STATUS), + mtk_r32(eth, MTK_PDMA_INT_MASK)); + } + + if (rx_done_total == budget) + return budget; + + } while (mtk_r32(eth, MTK_PDMA_INT_STATUS) & MTK_RX_DONE_INT); - if (napi_complete(napi)) + if (napi_complete_done(napi, rx_done_total)) mtk_rx_irq_enable(eth, MTK_RX_DONE_INT); - return rx_done + budget - remain_budget; + return rx_done_total; } static int mtk_tx_alloc(struct mtk_eth *eth) From patchwork Fri Apr 23 05:21:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219585 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26057C433B4 for ; Fri, 23 Apr 2021 05:22:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 080F0613F2 for ; Fri, 23 Apr 2021 05:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240815AbhDWFWe (ORCPT ); Fri, 23 Apr 2021 01:22:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240552AbhDWFWH (ORCPT ); Fri, 23 Apr 2021 01:22:07 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6D85C06174A; Thu, 22 Apr 2021 22:21:30 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id p2so18982865pgh.4; Thu, 22 Apr 2021 22:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1zBsYlQcq61seY0imZReAqd25ZKjbgbucT8yzndF0G8=; b=mXObVk0IL/7DFMTpyCRPZqGetBuk3drJ5M/Obl1C6xlK7NDyhWWCkl+KNYiQutboxo kW6NaspOYeE4qWwHpjbIUz5ErGST9GY4/eGwtQc2odt1wMZD2IcUhPqD7dBy4NkNPGp6 tLrU2REcLNeOdDmQFXDupVzyomCI8NOfpFEHRpNz4ig38eg/mrkEcIXxjnR0osGV2q0+ xDwo2ZK2B8OGp7uC4aJhP7+Udx313yhxFi88+DxnbG/lTvoUAMI1y+IIfQ540dy3P3I3 h2xF0CqSDfBDDUk1QwMwVSTt5nZm7ixz/P7ca/S9n6Ac0i6+Ji+RlmRQgNyh98fCyjxt /fsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1zBsYlQcq61seY0imZReAqd25ZKjbgbucT8yzndF0G8=; b=CcybcUWyC0HoCOZIElIdpJ7xMp4hnCZLn0OaJeEKtu6eaV96NzgU3RAeH13QLdDniE Pxz12kriK57YMkyckSoSL6dpAJ8kvDg+GiNGvtCkZVvUcXhJgLICbxbMNIegC+FoP2Li pS0hz2X+oQUZKBbFp88tvSHDqM+pAimpDk9abgWXL256rfM2kQUwVCaRVi05cv8FX5Eb Y/7PPUIsSO5wsoJ60sJuPbqp4pSnF1UCjQ4wrq6BK+BjsqVs27aDIRclUu9IoiPTvjEF aKV6dE1haOEeisM8spKdYOW+rv3+ThhVtXh//1Eyr17ZYrBEB54F0Xl4dcVuCyDkgt4q JwKg== X-Gm-Message-State: AOAM533wKyN+bx9u3Xk24gtn5aR1+Kv1AoCAY+GH9lsVm2yFUyE39NLC orLEdFdKufpXiw02A/WyJpk= X-Google-Smtp-Source: ABdhPJzYTtLTrv/HN8NBYaCqVRueYZcK2ZzzlX8xhlJjUZfD3Gdzp3iB1pwBdX68Cwy/NGXiEfx9FQ== X-Received: by 2002:a62:1b50:0:b029:257:da1e:837f with SMTP id b77-20020a621b500000b0290257da1e837fmr2066529pfb.57.1619155290331; Thu, 22 Apr 2021 22:21:30 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:29 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next v2 14/15] net: ethernet: mtk_eth_soc: set PPE flow hash as skb hash if present Date: Thu, 22 Apr 2021 22:21:07 -0700 Message-Id: <20210423052108.423853-15-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Felix Fietkau This improves GRO performance Signed-off-by: Felix Fietkau [Ilya: Use MTK_RXD4_FOE_ENTRY instead of GENMASK(13, 0)] Signed-off-by: Ilya Lipnitskiy --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 8faf8fb1c83a..37e50a2e7d0e 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "mtk_eth_soc.h" @@ -1250,6 +1251,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, struct net_device *netdev; unsigned int pktlen; dma_addr_t dma_addr; + u32 hash; int mac; ring = mtk_get_rx_ring(eth); @@ -1319,6 +1321,12 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, skb->protocol = eth_type_trans(skb, netdev); bytes += pktlen; + hash = trxd.rxd4 & MTK_RXD4_FOE_ENTRY; + if (hash != MTK_RXD4_FOE_ENTRY) { + hash = jhash_1word(hash, 0); + skb_set_hash(skb, hash, PKT_HASH_TYPE_L4); + } + if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX && (trxd.rxd2 & RX_DMA_VTAG)) __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), From patchwork Fri Apr 23 05:21:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12219587 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6737CC433ED for ; Fri, 23 Apr 2021 05:22:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B4AD613F2 for ; Fri, 23 Apr 2021 05:22:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240597AbhDWFWf (ORCPT ); Fri, 23 Apr 2021 01:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240661AbhDWFWI (ORCPT ); Fri, 23 Apr 2021 01:22:08 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9F8DC06138B; Thu, 22 Apr 2021 22:21:31 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id m12so13715098pgr.9; Thu, 22 Apr 2021 22:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+QE5ZWLQU/5/upbp8ywwYoobLbbRgh+EOZbhqiCaUrA=; b=emZgKFW/wnnHGbcgxGHvjMJSTTp41HMSrSfSNbAOHa0WoVcXkjQXL7pjJjWrjoGDTJ hId9J9+qWMR8KPl15pQDK/gvU0Kk0GRq39cfQ780+gtChTF0nt7G/WBxnSZ2EF+32EFZ lbnn4hpUJJaKZtnm+sx36zRpSyirj1HaDiVhjZb1tMkHCDajmwnCtEk+I6wjDWhUvh0g +MWMV/Nn7cGVcKJsMHN7SaYhbVswFRxbe5VOHn05kL7Iq83nG+zccmAfw6T9arFS5p+3 Vk+AJ7V0fr+Vieurmck8FixnwUU58va+9/nQZA+blGbLKb3/2cZ7Np7Qp74HwqyCk2A3 F09A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+QE5ZWLQU/5/upbp8ywwYoobLbbRgh+EOZbhqiCaUrA=; b=bltZ2R6C78wiWM4OTNw+8Nb1EfezfQNPRCynQLhqqeIoeUmrrMeJL179JlDT35MUtf nTaKpdYOM/6M1lfa4upgzZEnQrUCallE0RtFheaR/tzkdDy/wz84hRmbm1++zJHaSbt2 9+890+lMwwNF8Rrya9pJ/ur5O1zLGCEsnvp/a24DlFreuy7vkvHJGPH/oYI+rwYDhuiK /VRQmNBVDW7ywPxmc/YAS8kMGOoPTo6Tx0aTBVI7WlNK8b56QgZsxMfPvTYa/YrLGe2w FG/zlIuZUZS/kKe0OlM6WBGMo8CDLRHmDTIzsLuHhK/uJKMW0YLZ/bVryFGbP9GbdS67 sjgQ== X-Gm-Message-State: AOAM530BzA7aEpXB3e7D4HzFm6t7qeLHs3ZIwarE7EtaCaPjx2RGs+E3 oCJ+tC9aYjptxenWk9zYMSzKOOyJu2WvyA9x X-Google-Smtp-Source: ABdhPJynB6x3ngxSvlU0/QX4s3M24EdwHpWscDh8pUHB5agFFtw8uqjvYdoITIV4mCYf52er8fSdQg== X-Received: by 2002:a63:d755:: with SMTP id w21mr2221158pgi.400.1619155291309; Thu, 22 Apr 2021 22:21:31 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id y24sm6238825pjp.26.2021.04.22.22.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 22:21:30 -0700 (PDT) From: Ilya Lipnitskiy To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Ilya Lipnitskiy , Andrew Lunn Subject: [PATCH net-next v2 15/15] net: ethernet: mtk_eth_soc: use iopoll.h macro for DMA init Date: Thu, 22 Apr 2021 22:21:08 -0700 Message-Id: <20210423052108.423853-16-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> References: <20210423052108.423853-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Replace a tight busy-wait loop without a pause with a standard readx_poll_timeout_atomic routine with a 5 us poll period. Tested by booting a MT7621 device to ensure the driver initializes properly. Signed-off-by: Ilya Lipnitskiy Reviewed-by: Andrew Lunn --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 29 +++++++++------------ drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 37e50a2e7d0e..ed4eacef17ce 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2033,25 +2033,22 @@ static int mtk_set_features(struct net_device *dev, netdev_features_t features) /* wait for DMA to finish whatever it is doing before we start using it again */ static int mtk_dma_busy_wait(struct mtk_eth *eth) { - unsigned long t_start = jiffies; + unsigned int reg; + int ret; + u32 val; - while (1) { - if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { - if (!(mtk_r32(eth, MTK_QDMA_GLO_CFG) & - (MTK_RX_DMA_BUSY | MTK_TX_DMA_BUSY))) - return 0; - } else { - if (!(mtk_r32(eth, MTK_PDMA_GLO_CFG) & - (MTK_RX_DMA_BUSY | MTK_TX_DMA_BUSY))) - return 0; - } + if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) + reg = MTK_QDMA_GLO_CFG; + else + reg = MTK_PDMA_GLO_CFG; - if (time_after(jiffies, t_start + MTK_DMA_BUSY_TIMEOUT)) - break; - } + ret = readx_poll_timeout_atomic(__raw_readl, eth->base + reg, val, + !(val & (MTK_RX_DMA_BUSY | MTK_TX_DMA_BUSY)), + 5, MTK_DMA_BUSY_TIMEOUT_US); + if (ret) + dev_err(eth->dev, "DMA init timeout\n"); - dev_err(eth->dev, "DMA init timeout\n"); - return -1; + return ret; } static int mtk_dma_init(struct mtk_eth *eth) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 6b92dd6c2cda..11331b44ba07 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -214,7 +214,7 @@ #define MTK_TX_DMA_BUSY BIT(1) #define MTK_RX_DMA_EN BIT(2) #define MTK_TX_DMA_EN BIT(0) -#define MTK_DMA_BUSY_TIMEOUT HZ +#define MTK_DMA_BUSY_TIMEOUT_US 1000000 /* QDMA Reset Index Register */ #define MTK_QDMA_RST_IDX 0x1A08