From patchwork Thu Apr 22 04:09: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: 12217553 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 BC804C43460 for ; Thu, 22 Apr 2021 04:09:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9495B61424 for ; Thu, 22 Apr 2021 04:09:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231284AbhDVEKR (ORCPT ); Thu, 22 Apr 2021 00:10:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbhDVEKN (ORCPT ); Thu, 22 Apr 2021 00:10:13 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F360C06138B; Wed, 21 Apr 2021 21:09:39 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id s20so7004082plr.13; Wed, 21 Apr 2021 21:09:39 -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=Krf+iJf9arTXsWfbO65KruQYlFPyL1W/a7QWL02To8JtHLLrm20hPSip5Kw2GYq1hg 3JDjnW6092g1/mOdXD/KN06D96oRcuH52oVcY57hYBD66+TCVJrR7xfG7phe8ZmD4OEo BZ1wV6M9t6HSDZZqJdH2dm99RTbOTKaqDGU9Ro0oeEtmAh+tOV2EdGnEpHw0u+B/EVlH f3ZD4Syu54p1lxdzbPr6nLnvpktbP7H6quaEgdtYftzfwitW+x5WwHFBUMQM6RfQ4ZRb ouh4k1jXB7rDkA0uo7zRPHS+iPSLvlcucPcW5e0rK6rzK62duM4YriwkoBYfEF25oBiJ GvYg== 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=tsiOMJxRXSgQs9OmNSpgRA1LH6FAc4B2btpi40yg/zxnV/uQ8k7lSkCrEHYrv88KWq s6yjM9zZ9mWbGGHED5cni6dOTC6jPwkNYXpdP0suvOwGTxnEHwsdqPl9A0rTEJo5PEha x2SM6SBXbb2BXummvqFiuaD3HKi9TuvQ5xO50Yq04FHnSU4P6i7ZFrNyCOqzwTAN3QSW PAZM18n8prJttzQ+MbIN3braeeI2/Mg882k/EvFXXH8DyDZaDTItiSg0V/JZKN7+0v3N CfVh4J8omuQwu+ERliXFgJr+f2tHo9m/LAHIiNsGPhutdqV4LAg4mjgmHNPCiFMeeeiE RCuQ== X-Gm-Message-State: AOAM530DjlHrmfxAsjRORCaa/d/YkkjAmWUFf+szEsPGb70LwY/XdCm5 grKAB7dOzDcix5BhZVH2XFo= X-Google-Smtp-Source: ABdhPJyTYQJ83qyCIAcrBlJUUq7yf3pUtZkYMy14r3Ds24vk5PH8rQcWHhpel40s381fjFRfb8hXbw== X-Received: by 2002:a17:902:109:b029:ec:9f64:c53d with SMTP id 9-20020a1709020109b02900ec9f64c53dmr1408533plb.83.1619064578591; Wed, 21 Apr 2021 21:09:38 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:38 -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 01/14] net: ethernet: mtk_eth_soc: fix RX VLAN offload Date: Wed, 21 Apr 2021 21:09:01 -0700 Message-Id: <20210422040914.47788-2-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 Thu Apr 22 04:09: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: 12217557 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 15237C43461 for ; Thu, 22 Apr 2021 04:09:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6416613FB for ; Thu, 22 Apr 2021 04:09:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234735AbhDVEKW (ORCPT ); Thu, 22 Apr 2021 00:10:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbhDVEKP (ORCPT ); Thu, 22 Apr 2021 00:10:15 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2AE6C06138C; Wed, 21 Apr 2021 21:09:39 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id p16so18887391plf.12; Wed, 21 Apr 2021 21:09:39 -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=Qk50RbXnIUW3ik6C9BPq9pGE/g7IPmSF/zub/U4v6eFD9JYzpDwkpMh2dWa4LYF0Lz 54kiRiI1+SrUhtd1xZEMQIF/luZ56IJBvynQzQgOFLegROKwyJWKS040JzeiMUEzbDq4 hEGRAI3JbZclg1+zCKkPbE9gdEKnOg91hFQmkTDhHA09FRWQwq1lGwvV4yorElKuwCsY bq+foLDZHdCbyB8+XvO5L/qh0q2rbIUy0DgHc+V08aIdUkQSBZ0QRktS3BatdlhT7Q23 l8Ih/fNd+vWMy2OweWy31wcVjSlqLxpR6vcmHFznz5eouZnqPHeRFi7uMYP56ZduOVm0 JOvg== 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=mwEIRCNEwAD2EP7Hp+VeCyCLbfXycbtE4Nc/VI6s41/jcCki4mMrP6fpwyT/Iw5vws PrirzmHTCWVgZFXi5akiSaJdt3u1HhD6ZAFX7jQKBFqQTrt7bMMuFSvyezu8Y6U0aC1G 1PW+q+7EB1cTShNQH/nad1dofdbwvECly+7C3FTk0Y7m2LwSDb2reRTnX+RG3u8vReah EAPnsQOxkb5UdihZ1Q5k8Ofev/3RnR+/6nNOUNdOgZBZFepB4rZZzXptunyzwPB/t9lB 7CnUDmtcUhOEWwOqOtoKQTPLmyjYFqTFJh1hxrjJgHKxCLbjw2BhTa9FpP26BXDt7ajP G2jA== X-Gm-Message-State: AOAM5333oxYoR9pEJNbnGFukN1IbZNa49hae5npcwbUaSF/LQyE2GdEc H2B4QwWo6rgeo5KzIh4elQA= X-Google-Smtp-Source: ABdhPJzg3V/PbtiIRa3CF472CaR81Ax8xdtPWol7R5JM+E25Dw25nASa8kWgFBbWcDd0jFjpUa+sLg== X-Received: by 2002:a17:902:8693:b029:eb:53f:1336 with SMTP id g19-20020a1709028693b02900eb053f1336mr1466781plo.52.1619064579325; Wed, 21 Apr 2021 21:09:39 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:39 -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 02/14] net: ethernet: mtk_eth_soc: unmap RX data before calling build_skb Date: Wed, 21 Apr 2021 21:09:02 -0700 Message-Id: <20210422040914.47788-3-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 Thu Apr 22 04:09: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: 12217555 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 BDC49C433ED for ; Thu, 22 Apr 2021 04:09:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CA486142B for ; Thu, 22 Apr 2021 04:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232796AbhDVEKU (ORCPT ); Thu, 22 Apr 2021 00:10:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbhDVEKO (ORCPT ); Thu, 22 Apr 2021 00:10:14 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B334C06174A; Wed, 21 Apr 2021 21:09:40 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id f6-20020a17090a6546b029015088cf4a1eso240191pjs.2; Wed, 21 Apr 2021 21:09:40 -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=KCCRAcZRH2q9WePwudcJa7IRn0oj+Hd4SYQlaLwHq3erd6z/UEgaXA0VjZeMEqrIb+ Q8X+3nvCXsOfPr8nkzGciE8Qer9C3ZMOgUtKoqsebyt8sVkU+sCble0rLFQs7N4yi4uB 3/VeMjw44NhnRdpvm0GZ/15WBaCM4nf97qah/8NLY+JDxPvVxFma5tF2CQNpPXLCc2Lk FNY3+3OziJcva+chnYgwMTneBff5PLp257aFpmSb/HEDus3rUrw8XZ+UASTZcppghyVa +97lDFhnWmWG9icoVNkz6om+a07b07Ai1W4qQX0M4NuJd+o07N/spwuzwN+9qdSoae3e qtzw== 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=AirwF58CrBdSCfuqzKSbGrp+KDPflh1DUqB3KuC/oWGO6XmPcp1JP7uoWZBSP/VxRU yM4vQgXz4rUvlU+jk+N3Klf1VLghuEZP+p17aRMBrDf2DiK6BQWWB/222E950+nbyZg3 DCtfR0Y1cUc5JwSMcTmLFr9+zXl4lBGn4l9+Sjs6y+9/mQLUiMPi9kDydm6bfKMqNIM1 aKxyKDBGVhbd7iXOtvLJwu9mur/L2WxzuRl7BadgdXFdaNzChqddaAtxQjQa8yPsi7jr u1yKxJqsDc+eJFI25neETYNRAXfMlZqXPLS3Xxjq7+hl6j3FOxyRP9z12W/t/5Yhwj2B RUJA== X-Gm-Message-State: AOAM533JNGFB8sbL2Hhtgo83j0Aud6rlkmnkQQ4esQ7AqRyPlfM9498L TvrglHxqPRadLEFYyc+sIWg= X-Google-Smtp-Source: ABdhPJwm/HPuAW+zUXQgRnrXd/od7i7maE9NkKmpXPunzRtlbKEr3GPxchy0RmpvN8P7icTmsyIBTA== X-Received: by 2002:a17:902:7788:b029:e9:11:5334 with SMTP id o8-20020a1709027788b02900e900115334mr1405530pll.70.1619064580121; Wed, 21 Apr 2021 21:09:40 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:39 -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 03/14] net: ethernet: mtk_eth_soc: fix build_skb cleanup Date: Wed, 21 Apr 2021 21:09:03 -0700 Message-Id: <20210422040914.47788-4-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 Thu Apr 22 04:09: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: 12217565 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 735E4C43461 for ; Thu, 22 Apr 2021 04:09:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5519161450 for ; Thu, 22 Apr 2021 04:09:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234886AbhDVEKb (ORCPT ); Thu, 22 Apr 2021 00:10:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230361AbhDVEKQ (ORCPT ); Thu, 22 Apr 2021 00:10:16 -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 53C09C06174A; Wed, 21 Apr 2021 21:09:41 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id e2so18529065plh.8; Wed, 21 Apr 2021 21:09:41 -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=OC1c6YzvFa23FAL/pDrjpfiIHhd4LbVftEgeZu10htyxa3D2HLXIcV/IK2zjfuGkQ0 p7qs0zFMFgEH4GD0lO21HSL3aNG716uIKTiBehI4t0T3kRMzZ9FTC8ARTTtdjmdkLEly kcTsgYbQR/nl7odAWxFVm0X2+KgrzZST/HsxFxJMIVJwXyAU9EKP/Dso8FlpCPodUPiF xNJ0cbpnoq+XPExtBEocFtJ5bWaAMIQRiJY7bT1nV4v1ujzii/B/O0sRUbFQtugvbALs uzdr5n0sU2oDeSfGjqAPH1PTrldw7/7zaVuiSftGPnjUZLFl11E8LmgM+mO9kOj0LmTm 1S0w== 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=mCOCuSnT18TBYf9aPMREvpykSL0OzaYDpCUaZ39ln7D/XnfkQ1lKsRKAMfGJuRKbEB OrF/aNPi/Yv7Khg7glivYFmxntMXtG5P+JlMVp2ENfk9B8M8pZTKvZeytLI+0zGTDTjd A3H19H/98ZnYGPU6Mv9r2MkfK3EHH6adPqcd12XFgUPw/2qziMVfyjuXfDEd/XpzlGIL IHTvwMD27DvkCPVGrBol0VliLArgrabSfyPNVrYdNEieqWAztR78wfmzw3FIMrbSKyEI a67zU7C9d6dkeHSaUaeghihckgMjR7t7qGilpf6MvptCtdvVhoWquvgrtcrsOKRQ/GWr aHRg== X-Gm-Message-State: AOAM532YC9bgjZgPRj3Du9EPIS3M1GiIIfdP7OjD9zshvUsFMcVT/wvq Am2q+k33fmt2vSmJ3npJPJM= X-Google-Smtp-Source: ABdhPJxd4KNi/Xrd2gMVsnisMzoprD9mj//cMmuHvr1XiE3yzrkkSh+87wCc4+casFD6zSp4KEAxUQ== X-Received: by 2002:a17:902:9886:b029:e6:2bc6:b74 with SMTP id s6-20020a1709029886b02900e62bc60b74mr1404270plp.13.1619064580913; Wed, 21 Apr 2021 21:09:40 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:40 -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 04/14] net: ethernet: mtk_eth_soc: use napi_consume_skb Date: Wed, 21 Apr 2021 21:09:04 -0700 Message-Id: <20210422040914.47788-5-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 Thu Apr 22 04:09: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: 12217559 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 1A8CFC43462 for ; Thu, 22 Apr 2021 04:09:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E545A61424 for ; Thu, 22 Apr 2021 04:09:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234772AbhDVEKX (ORCPT ); Thu, 22 Apr 2021 00:10:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbhDVEKQ (ORCPT ); Thu, 22 Apr 2021 00:10:16 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 123D4C06138B; Wed, 21 Apr 2021 21:09:42 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id f11-20020a17090a638bb02901524d3a3d48so245538pjj.3; Wed, 21 Apr 2021 21:09:42 -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=BqG+zTglnF7bDNQlesivFzezPjfS1NU3z80UalF/S6Y=; b=XIw7qzdmjjv0XsqmEg2M6245uhywBxRrA+GaJEsytTxoss5nmoS7Jjxnb0uvvC2eNb 9PerPXO3noS0Fyb0AXyAkRimWmhdvX0pEHjJIlGdWfdABzP1SgdpjmvgKn5xDwfgm1J/ hcDYEJQ7iEY+/4KMfcDOz38ecA/RC2pXfpUs+C1NOWIehj8T3bQW1f58v2LiALKZ4kMb 9/1SYZEXtSxJNjtrWMhpN4H+pFql5CtFjgJsgNSrlkCD5HWaqDXEKZ4/cWovRVcfYnqC T1iL8QN9M1xEmVfnOnUr/RXCOSfIpZdZyXfgOf0oEkz9Ffj4yimeIdAiWHZ+AC0pfP0/ IB7w== 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=BqG+zTglnF7bDNQlesivFzezPjfS1NU3z80UalF/S6Y=; b=Xi8s3ZyxX9G1mVk42+RjImo7ExFiB6NfIW5G6QXFv+k9+pcDCm8ATK7nGQFneG3ZUk ew28vagGoZKjE0zXUZzMQo4LkYDMjtYci/XaIfrYn1IYfW654DxXpDk6CfZNIw7S3LHd pSRdRIUV8kCx0/jecM3S+cqdLXLxSy8up5iQ0SYp2GFlPAeWSqXbOTHuYS+Igrw3nL1o nGp44AUOaEjBN/gB3+OBseast6J4lzv1XF4V1HaiTeL/dUMZ1Fx5Z/83iQGSTzSPlj6R OFnoXD0VXapj6y6zD5BsX+JlP881icSS1LcHwschzay72T4DFcb5JBxDafdFc6V8D9uB o9kg== X-Gm-Message-State: AOAM530lgbJ8dSYOl+nihTWF++ImyQaxaUtp2Y1mefaZQpz/6Uf5JYlv GowtKC5FHLhsnlKZEalARIQ= X-Google-Smtp-Source: ABdhPJyXEesIOVFoSTI8GDvHdygln2zE5LDKv0dytmwT9xBB8YiKt6cpGaU8lBrUMOCkCPl6DIUf/Q== X-Received: by 2002:a17:902:a585:b029:e7:3d46:660d with SMTP id az5-20020a170902a585b02900e73d46660dmr1326944plb.12.1619064581626; Wed, 21 Apr 2021 21:09:41 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:41 -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 05/14] net: ethernet: mtk_eth_soc: reduce MDIO bus access latency Date: Wed, 21 Apr 2021 21:09:05 -0700 Message-Id: <20210422040914.47788-6-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 udelay via readx_poll_timeout_atomic, since the MDIO access does not take much time Signed-off-by: Felix Fietkau [Ilya: use readx_poll_timeout_atomic instead of cond_resched] Signed-off-by: Ilya Lipnitskiy Reviewed-by: Andrew Lunn --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 18 ++++++++---------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 5cf64de3ddf8..a3958e99a29f 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -79,18 +79,16 @@ static u32 mtk_m32(struct mtk_eth *eth, u32 mask, u32 set, unsigned reg) static int mtk_mdio_busy_wait(struct mtk_eth *eth) { - unsigned long t_start = jiffies; + int ret; + u32 val; - while (1) { - if (!(mtk_r32(eth, MTK_PHY_IAC) & PHY_IAC_ACCESS)) - return 0; - if (time_after(jiffies, t_start + PHY_IAC_TIMEOUT)) - break; - usleep_range(10, 20); - } + ret = readx_poll_timeout_atomic(__raw_readl, eth->base + MTK_PHY_IAC, + val, !(val & PHY_IAC_ACCESS), + 5, PHY_IAC_TIMEOUT_US); + if (ret) + dev_err(eth->dev, "mdio: MDIO timeout\n"); - dev_err(eth->dev, "mdio: MDIO timeout\n"); - return -1; + return ret; } static u32 _mtk_mdio_write(struct mtk_eth *eth, u32 phy_addr, diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 875e67b41561..989342a7ae4a 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -327,7 +327,7 @@ #define PHY_IAC_START BIT(16) #define PHY_IAC_ADDR_SHIFT 20 #define PHY_IAC_REG_SHIFT 25 -#define PHY_IAC_TIMEOUT HZ +#define PHY_IAC_TIMEOUT_US 1000000 #define MTK_MAC_MISC 0x1000c #define MTK_MUX_TO_ESW BIT(0) From patchwork Thu Apr 22 04:09: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: 12217563 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 33B48C433ED for ; Thu, 22 Apr 2021 04:09:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DFCC61450 for ; Thu, 22 Apr 2021 04:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234853AbhDVEK3 (ORCPT ); Thu, 22 Apr 2021 00:10:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231539AbhDVEKS (ORCPT ); Thu, 22 Apr 2021 00:10:18 -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 C38D9C06138C; Wed, 21 Apr 2021 21:09:42 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id lr7so4455537pjb.2; Wed, 21 Apr 2021 21:09:42 -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=mpHFvhVstRat21oM0gV+xZuTGkFLULz7ukrF5iEyIK0=; b=PnrB1ws8mNHmD5BVxLJuU6qLG9r7t5ta+3Ni6Wf3OeJnmyznhMtLE3gvDqHKIyHkVz KdG5FCaNorsqk+1Lk26cuTsNMI2MEhAdWhk07+ul4DTUwNQIjuPXiNJ5lmqRz3wiRZ6P SJziggGOJFWqmfJNEqZA0C57yQo5uqc7ZfWoIQ0yufqd9CRGlCH7kAVioi9Nc3PIscMF LLqL8egeN2TpZymJgpf99bfY/UytmdTb0Zi8ai/AJEprzxMyxcvEC/ny3HqJQzO0PBIY ZfU9gTgUcfaamT1VNm4MbmmgoviZP4BSiYh4WS2J6YQyD9YuIhdV2ps0Kl5Scnb75Gin 92bQ== 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=mpHFvhVstRat21oM0gV+xZuTGkFLULz7ukrF5iEyIK0=; b=b44MNQiZvGua9/0RWdqrOOkzmUNKysE6l5E4NyI3PpS+jOsB1ZmsyQ1KIswGQzO6w0 nlCuSw5w/dsKd33TaHwaj4MY6a2b8Zm0m02nos3Wdq815sy3W0EaHJ+adnwqY5AJx9W2 YQYm6z/Fy3BtCqtQiAUI/oWNQBp6TkjOOz1jIZ8KhnjI7+QGooYu2vJ7SqH6kAX7bPfd kQanWUUMla1IUlbuiNeYqOzfUcbnW0OjlKnR7eiW6eMbrcXZ8fcr3V5Duqo5EhQKeTxj ia0aB+QShEypFj7wpRdPzTwDv+aIVupub7RX5oKYe6sm6Jl1x6iDzgDXzWoXqBHFCLDh BmFw== X-Gm-Message-State: AOAM531aPFxCiii3fRnJlaDoyENLr7gV00I5QEmzPSDkvoCxfFxHZ+FR D8jTVn5Y6jzJAoY5KOPQpAo= X-Google-Smtp-Source: ABdhPJzk8BBXtqx6sgT1iSsBur7XCwAiWjZh+FiVyRUmlXzRCA+5kxsrggTByS1Hev/9WK83MS/HCQ== X-Received: by 2002:a17:902:b18f:b029:ec:7ac0:fd1a with SMTP id s15-20020a170902b18fb02900ec7ac0fd1amr1414045plr.84.1619064582317; Wed, 21 Apr 2021 21:09:42 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:42 -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 06/14] net: ethernet: mtk_eth_soc: remove unnecessary TX queue stops Date: Wed, 21 Apr 2021 21:09:06 -0700 Message-Id: <20210422040914.47788-7-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 a3958e99a29f..223131645a37 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1129,17 +1129,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); @@ -1160,7 +1149,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); @@ -1186,7 +1175,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 Thu Apr 22 04:09: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: 12217561 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 3C97DC43460 for ; Thu, 22 Apr 2021 04:09:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11EB36142B for ; Thu, 22 Apr 2021 04:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234810AbhDVEKZ (ORCPT ); Thu, 22 Apr 2021 00:10:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231442AbhDVEKR (ORCPT ); Thu, 22 Apr 2021 00:10:17 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8728DC06138E; Wed, 21 Apr 2021 21:09:43 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id u14-20020a17090a1f0eb029014e38011b09so240630pja.5; Wed, 21 Apr 2021 21:09:43 -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=XaeFpP4NyPNpT7feooMHSBOAhXY5/vqZy8Ostkjc59Q=; b=hfi2TcPIsk6W4BIHeinsfsPsQP897tqjtp+z6BngIvDmr5Mr1Iz70jkxspEeoXNQKC kgOh8ndlSIRk4O9LWEBeyMysynYTqy9EzGYsvI49aRynODdJ/GILzsgReEDmWfWUnfP7 mf69N56PkshimlU0N4S97VOauuR1V4HXmKY1Vtncmw7tyEDCVOrXLU0uulLdC341Hr/z 6NdyCozWKQijnbBFXU74ubUr0p1NxwSB8DpE3QrMx4NlYpN9XO4YZKqCvpK5QbrDEfcU OO3fbWobjgX6ZlY9NWBU0r6npAfp9Yha9qcakETlybuYTWaL4VHOYcOXH6XF0G9LpldN /A2Q== 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=XaeFpP4NyPNpT7feooMHSBOAhXY5/vqZy8Ostkjc59Q=; b=f8fJ4QBeV7wtlrbUqYbAWuaRgyWP7JRgPhJcpn3sx5S3YrfGGdUPSrWOTL/47kuouf t+5xG6nDC54IHcEZapFF3nA/uYTaYUrOAiU6oZtY07N9lf8jPffQ4qWOM1Ln5726LEFT 8sSDZR9Wo6HpWr6XF+FtG5AYtWLl2KNlB880VHDoxtiAU4ogm64c00i/KUwaZCsWC20J lfR10cV9ZiJgKPAaZGx3jq7YcRned3DK4Vs5wL/6h89L2D6DMqHmOxwGjj1V2tzkaIcH I4dt24tvSj+r8fhPggWPSysINylzMulT6VpVjKlECpSAGfOcnesAxSuseoqmocU/U7FR gdcA== X-Gm-Message-State: AOAM5334ELD/kbTiFTXG2ON6RjoiLuqCtiI6nQIE+OF6Z4VtUK3Jrt/T vBoWaIm/Dxbjg8SlA3chr54= X-Google-Smtp-Source: ABdhPJwQQeHlhMyirN59DawShgsPiF1tWB8tRGdQUATxeztZ1cCHj1TO/tCxi6vHsEAz2NwgKMU0iQ== X-Received: by 2002:a17:903:4106:b029:e9:244f:9aca with SMTP id r6-20020a1709034106b02900e9244f9acamr1644202pld.58.1619064583049; Wed, 21 Apr 2021 21:09:43 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:42 -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 07/14] net: ethernet: mtk_eth_soc: use larger burst size for QDMA TX Date: Wed, 21 Apr 2021 21:09:07 -0700 Message-Id: <20210422040914.47788-8-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 223131645a37..5a67bbe9bd90 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2191,7 +2191,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 989342a7ae4a..039c39d750e0 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 Thu Apr 22 04:09: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: 12217567 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 33F0BC433ED for ; Thu, 22 Apr 2021 04:10:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 086E1613FB for ; Thu, 22 Apr 2021 04:10:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234922AbhDVEKf (ORCPT ); Thu, 22 Apr 2021 00:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231631AbhDVEKS (ORCPT ); Thu, 22 Apr 2021 00:10:18 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40C09C06138F; Wed, 21 Apr 2021 21:09:44 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id u11so16942680pjr.0; Wed, 21 Apr 2021 21:09:44 -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=afUBNnLCnALHd7nnFx3FLIxkkAO2cCALl7BKYrqLlkY=; b=NYPusNMiIJkw5Pdj0XLU0ZWAtBJ0PRpny5fTeVCaCzLnmSQcEDHAq7Vi7RNZjCpNTQ I5AampDypMlwhKH63+UIQ9Rqo0b/ucLYFYhkqmpcZsvN0/tElVkYsN0c4svAcDAHxaZH 4y8FzJ9y1M2kNkuLvnfpGPkgqxcOJ2VAIjBdBcHb7mwcpCShQdGbUKnHrJtWkteMN4IT w0NS/kGQzmcUKU0MKLeAUh/x0Bih+w1G8WEM+2c3MmDaYDJKoJvqrQ0XUsWFC6iBdpKw TcVeoTYNjvy5iMlkQjl2/duH/+wQRLDvC3YQMzrCLRGU004SfgDZs4LUh6xvY9khhGJY 89PQ== 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=afUBNnLCnALHd7nnFx3FLIxkkAO2cCALl7BKYrqLlkY=; b=I90iVXO2t0Ycaeyc0YJE2nZj0Cc+XiNYBsaPIB7J4W/LXK72Xkk0XMue73tdl8ZANT J/gFP8rT3gIcJLNLiyqucG8CM0DM6J0wKmZzST/ubZ7J0NdjkK567Xxhv7aEevMxYERe venZwMYzL4L8lprSYHQVggGCR2BN+os+akG0g7i9IhMU+Ib0p4sHyuMtqP4YsaocoF19 4VzIlZ2Nzmc1sghkxiGooynweSlUtl4i/7Y3+DqOAKxxbIc4q1Pc16tD4EDChNj9NtWJ Vyy6spQFl2ORZmprrkAFGDw/dmTi0mDzxcuPwibwVKrEIqqFEwlYa4rMf/RKmGwf2pjF kzxQ== X-Gm-Message-State: AOAM531nV7vDvsdT0n5t+/XVVZPGHdXvR66apTeqkjgWMRDYe87QV/59 2GcV6hQ1ghlUszQoPu2EUhM= X-Google-Smtp-Source: ABdhPJyT3tO2UDDnQGbg/SV0FqbB8c0SOkNZA3M1yGxzusU3coNCVsdmTqvxDM6990gfNcEuqYSXXg== X-Received: by 2002:a17:902:e34b:b029:ec:9a57:9cba with SMTP id p11-20020a170902e34bb02900ec9a579cbamr1505555plc.56.1619064583871; Wed, 21 Apr 2021 21:09:43 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:43 -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 08/14] net: ethernet: mtk_eth_soc: increase DMA ring sizes Date: Wed, 21 Apr 2021 21:09:08 -0700 Message-Id: <20210422040914.47788-9-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 039c39d750e0..4999f8123180 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 Thu Apr 22 04:09:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12217569 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 A19EDC433B4 for ; Thu, 22 Apr 2021 04:10:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7949761453 for ; Thu, 22 Apr 2021 04:10:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234962AbhDVEKj (ORCPT ); Thu, 22 Apr 2021 00:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234645AbhDVEKU (ORCPT ); Thu, 22 Apr 2021 00:10:20 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2EDEC061346; Wed, 21 Apr 2021 21:09:45 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id u7so21031959plr.6; Wed, 21 Apr 2021 21:09:45 -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=LeGN1TIsHoTlnNDOMwFfeD11Nj0rbSCDk8ueVuxEr88=; b=XIG86n4D2xFHlkDV3DZy1psGU+CGPH6veAipUmMg41/cibcBYQxDajZK4wzfBji9ID NVRw2A2M9M4Jh7fBPXqLKWL1tOSp3GEq01j+qb+1lHD8S4JA6NanuYZjJK5+NU5H4H/n wcCdRq837aKGKHpK5OeSn9RxMbdpROsX0gz1AiLM2IK1i49IdRogRDwcSjjrdfh9slfu try2qMLl9JHXY+Ki5SBBPoOY2ZtiwxwLxv0PLLmUaDhYB37+2TIldaWOPL9PkKtqWHWY 52O5KtfPJi1OuTObgV0NmDi35CBO7dmeXqSaKwHtSkse2eB/sxyzKO2bCDx9YaqD+QZo SSDQ== 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=LeGN1TIsHoTlnNDOMwFfeD11Nj0rbSCDk8ueVuxEr88=; b=WkWh5xPKtgmS3j6DOK3CT8J5SWgT9u2BtWj/OtTq7oX8mYCVaGUngVwmEX9VQ0vWjb BnXBsMzSV5F3uqs32j7ChSESkfA56kL8d6dt4JDypoYEdOrSsqz3YmKqzekVBWLSPH1s 1mgozX4pNFlOJa0PWs8A5hwh5qNwbmvOBkz5awZJhK2/KeT8t8UFUtu9nD4KCmYoH2A6 ceQQItFxqP7hEvc7DZBbCyJus+xWQjtsGazGSDhjHuFInY3uQgSihRYoj4nWO10KGHzu F2xKiQuCj0zs5KMoRFEs0+x/afTRhHZnmub1gCVks+fylKsuHh4rTy+QNcXYY+j2ZT4B j7FQ== X-Gm-Message-State: AOAM530RcLwO1xBGpBBg2W+lb1MJjZSTnrB8Urm7PdJuv4jXYgU9zXmn yxlf7zWSVk10H+zIHzVyI/E= X-Google-Smtp-Source: ABdhPJxjRgQf2k8PaCcPaM/QTjOWWMn7i1PDQmqEGIEEb4tYvev5okFJp7JF/VKhCYqdyaKiQPzf/w== X-Received: by 2002:a17:90a:cd06:: with SMTP id d6mr1752435pju.91.1619064585218; Wed, 21 Apr 2021 21:09:45 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:44 -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 09/14] net: ethernet: mtk_eth_soc: implement dynamic interrupt moderation Date: Wed, 21 Apr 2021 21:09:09 -0700 Message-Id: <20210422040914.47788-10-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 5a67bbe9bd90..043ab5446524 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1231,12 +1231,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; @@ -1310,6 +1311,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)) @@ -1342,6 +1344,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; } @@ -1434,6 +1442,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; @@ -1451,8 +1460,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); @@ -2127,6 +2142,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); @@ -2139,6 +2155,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); @@ -2323,6 +2340,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); @@ -2375,6 +2395,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; @@ -2396,9 +2474,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); @@ -2437,11 +2512,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); @@ -2976,6 +3051,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 4999f8123180..a8d388b02558 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 Thu Apr 22 04:09:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12217571 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 DD1DCC433B4 for ; Thu, 22 Apr 2021 04:10:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B89AC613FB for ; Thu, 22 Apr 2021 04:10:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234780AbhDVEKp (ORCPT ); Thu, 22 Apr 2021 00:10:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234670AbhDVEKV (ORCPT ); Thu, 22 Apr 2021 00:10:21 -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 58AA1C061347; Wed, 21 Apr 2021 21:09:46 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id nm3-20020a17090b19c3b029014e1bbf6c60so240563pjb.4; Wed, 21 Apr 2021 21:09:46 -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=Smtj4gwdxb0ZLZIeEWGZNPNrgYDMaUuIXb1nAA+jADw=; b=m2/PbzI84d6d9OgipdUa6ooqlmZ1yTJHHypRkqQkG2bpVUy3ScKdKsanBUcLcxPxe1 49Kl7GHhccN4bfMUvm5TbmHyZOKAy0qg1/Lkgd4NpuXTRdVO447y3T1pUIZNBFe+LkVB X2sHi/hwQvHU3pJJ8ahjC6omiel2gEdz77r1GYe90YLzLabr0xm7vqS7hBAison6UqOv 1BUr3umNN7qJe3cJGP4m7zsIIndBNxgYdCrODgwC1Lwzkt4BXbwzaPs9/jhbmsg2+mM8 0dH7Ab68oGanlDKPvEZLj18t06rr10OH3gBzdHJghF7LbzlSlKd2MXyLZtPiVMow5lUH T4dA== 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=Smtj4gwdxb0ZLZIeEWGZNPNrgYDMaUuIXb1nAA+jADw=; b=dWwCPWHPZC+zVB/Cfy0uZq2+3/Iz/4eCadYp1ImiHq++ElecbPXYpCLRNnTH7D5r1H zk4LXHIBWsE6lmwKfg/IKZ4DpLr/MrQOOjan/wWHnxlJJcY1J6vF4EdAvS5B46+HIVPH qvyNQEUnoXXPaqP139sH9w5JscTZqN+g5+jMvWHzxM+ah4zpZGQlwZCIHtLFtTgqeKat xG+skpY3qwC0Lgk4CKjWBvprA/Ty/IFsEcGm5TosF3X2ihb0rA5prW/7zbehMWEfWyzb lhQFBCnXJ104BUqnqGI9IHO1sQgOMmwuWiUiJQlLJN9LRIBx7twsRNCoVfl9/ortA/3f 0csg== X-Gm-Message-State: AOAM532jhHNAvJBqUYROVFw4jhcESLBct+7HCo4uBOiMdIqKJ+Fcapc9 1OajAhwFV8JGAo3J0AY7aOY= X-Google-Smtp-Source: ABdhPJw/RJBg5z72O0mNnzutjMCrzGHJDTgHgizsfQ9xv1oCCJjoF/x/bDrceXqjOabCBFD3JsC4ew== X-Received: by 2002:a17:902:edc4:b029:eb:159f:32b7 with SMTP id q4-20020a170902edc4b02900eb159f32b7mr1461172plk.11.1619064585968; Wed, 21 Apr 2021 21:09:45 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:45 -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 10/14] net: ethernet: mtk_eth_soc: cache HW pointer of last freed TX descriptor Date: Wed, 21 Apr 2021 21:09:10 -0700 Message-Id: <20210422040914.47788-11-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 043ab5446524..01ad10c76d53 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1362,7 +1362,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); @@ -1396,6 +1396,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; @@ -1596,6 +1597,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 @@ -1609,9 +1611,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 a8d388b02558..214da569e869 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 Thu Apr 22 04:09:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12217573 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 7C75AC433B4 for ; Thu, 22 Apr 2021 04:10:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4ECA3613FB for ; Thu, 22 Apr 2021 04:10:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235064AbhDVEK4 (ORCPT ); Thu, 22 Apr 2021 00:10:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234679AbhDVEKV (ORCPT ); Thu, 22 Apr 2021 00:10:21 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77881C06174A; Wed, 21 Apr 2021 21:09:47 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id a12so30780617pfc.7; Wed, 21 Apr 2021 21:09:47 -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=4KIdtN06FgF/t+etJxyiKFbFDdfz1IAmwoqjnTRUY1Q=; b=ekE6yKJ21GS2BTKeAlc+gBcCC1y9VzR7QBm1Rwve24KFcJ+0jNVnyEwmOwJl0lc/ho HyceoJIh+MUMTQjmMu4LScm0ubkQ0jjL01eKuoW4G65UuUYJ1l8W/0POGR2Deva/KspM G3jSY2RBu6FnW+ZPTIBOWgWnL7o7oHdYT5xTeTDJfQXG0rvU9U+Idr4pObH7IGrVtfe8 7Dv9p0Z0i2BNeI382eLt+dvGT49vhsadMXHj7k4uzcHgaLigpt65RnT7/x/sucLZaoRD hlWse+uINeiHf2fiDhFmH0kqG+jmLHxbt57wz1a+kX923t/lX3ZHkr106Egkia+d9Wrj Du0A== 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=4KIdtN06FgF/t+etJxyiKFbFDdfz1IAmwoqjnTRUY1Q=; b=VuXGE0OF63DgvxWSEH2Cfgc6DGKMpuObiQ5keXbJQP5nM9nPxYmQom89hP5H2LQ6tN EscH+wtVqEOJcJ8Tk++T7fM59qt0HTl0yAD9OhfsMDp2hukx//DTBMRcfwVyUUOHsyZH EHG+6ao99K4A3VI1jmGRYEQXGMIP3V+ERpciPqx5mJMI5H41DhIWYK8Q3oG2BXp1ERKD SpMtd0zi32kaXyk7BbJrRzLRtntlXyUg5wq75/j3szKRQ3rSNRMXu7VcXGSz4jAYZzWv Z5OLLQY6r5QglA3O4xcNxZzc5zTOexNOsfGY7t+a3LXkwyiDwpzpmtRaESCsiZJ6zm/R b70A== X-Gm-Message-State: AOAM5314XO9NRz0Smv1TAI0UeuTpmUZlqe6xMIj5qShurOhPYlwntjjC q5BQBZKYA76DER4UaBpN0T8= X-Google-Smtp-Source: ABdhPJxj4FOHEJL6eLG9j3s9bhz2cI5WstGPCENCBwwWnpKmfpEhlE8pRtJ7/rs9B268HliKtl5R2w== X-Received: by 2002:a63:4f21:: with SMTP id d33mr1525579pgb.434.1619064587028; Wed, 21 Apr 2021 21:09:47 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:46 -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 11/14] net: ethernet: mtk_eth_soc: only read the full RX descriptor if DMA is done Date: Wed, 21 Apr 2021 21:09:11 -0700 Message-Id: <20210422040914.47788-12-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 01ad10c76d53..5a531bb83348 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -775,13 +775,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 */ @@ -1253,8 +1258,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 Thu Apr 22 04:09:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12217575 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 1BBDEC43460 for ; Thu, 22 Apr 2021 04:10:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F312561450 for ; Thu, 22 Apr 2021 04:10:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235110AbhDVELE (ORCPT ); Thu, 22 Apr 2021 00:11:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234686AbhDVEKW (ORCPT ); Thu, 22 Apr 2021 00:10:22 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CC25C06138B; Wed, 21 Apr 2021 21:09:48 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id em21-20020a17090b0155b029014e204a81e6so2020419pjb.1; Wed, 21 Apr 2021 21:09:48 -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=9BOejhcXoXhyXTSBmLuvv47XDq5x1HtwxwRsIb2foI0=; b=kXLXNAS45PBewZl46uLw8yvajpf7UbKUWcXnUL7NxHB1rIq7y4NE3XI+kwO9y5mIlr RFcLwrUkVE1FEoXGQ9mEy9cMIlCyCFFXVssKp7SbCTUr+Zwn7ROumRk88XmThh3lNj8E zmiYac46vrstHv+nl9kQ0eUJjTYTvTkE28VYEbN/Hx295dvNUAcJgZOINDnWx1CxcvvJ SWp845sDxxvOJIJQmKZcd0XUBr/HqiijzZLkKAU3gCuJbguTny1vspGg+up5NkSh2TPy IyJIfofltt2JleFHax76OlALlkddx/4UeMcD46q3mtt6v/MHccEkq9y7Uiz3ZjHOoToD qVVw== 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=9BOejhcXoXhyXTSBmLuvv47XDq5x1HtwxwRsIb2foI0=; b=Z8GwnZdDo6nqwMhiWUfSoGIooXMUZDMr+Lbe/oN69wMzVTFFn8OHIIQep86PCKUw7w QV6yM7SE4kyGLwPGb70jxO8Ac9OvWuJZ2rcfICfgi0aNISoClQ29LR2TcgNaUdUrfoDT WTX1TM4pP2xDmq3Y+SNVgxVflE7pj4/cJLRSNv4yHWNJXkpJblYHPQ3QsSH3eMrEWt8R PnXWFXzGd+yE8954WsBFR73ENgW5nOLL0STuMYwoTc0PjDew9p075wAtYYOhq7e2Gc0S pyfJAIZfLyQUzYfhXribZLi5i6YMgSC5lVahA8I0PmsrFZtcInNtFqv4+uiOf+9ORPgK 07Kg== X-Gm-Message-State: AOAM530wlrh7uKcN+izOtK5BeusaHM4SKLMwXXbvOHJS5M5q5fCfh76j zkdS0VjIxx5BDyGMbGZ6zpM= X-Google-Smtp-Source: ABdhPJz2F7ul6sPxW+us4a3mzFh33oXjK5llgy7v+IeTQIwQiGEmxWbOHVBvse0swyjBzk0X5z+UGA== X-Received: by 2002:a17:902:cec3:b029:eb:5441:9897 with SMTP id d3-20020a170902cec3b02900eb54419897mr1387610plg.48.1619064587945; Wed, 21 Apr 2021 21:09:47 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:47 -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 12/14] net: ethernet: mtk_eth_soc: reduce unnecessary interrupts Date: Wed, 21 Apr 2021 21:09:12 -0700 Message-Id: <20210422040914.47788-13-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 5a531bb83348..88a437f478fd 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1517,8 +1517,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; } @@ -1551,8 +1551,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 Thu Apr 22 04:09:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12217577 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 54E08C433B4 for ; Thu, 22 Apr 2021 04:10:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3188961450 for ; Thu, 22 Apr 2021 04:10:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbhDVELG (ORCPT ); Thu, 22 Apr 2021 00:11:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234739AbhDVEKX (ORCPT ); Thu, 22 Apr 2021 00:10:23 -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 054A3C06138C; Wed, 21 Apr 2021 21:09:49 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id p12so31918090pgj.10; Wed, 21 Apr 2021 21:09:49 -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=Z+GoIGK0ASypWzKq72OR9x8SOdqUZq5a0/koCWBmuF4=; b=AprUGNkG4iniX7gYV9sc0nkIUpaw4DobJ3++iTN7JS1NrwMyOKGGVaf1e30tNIa2fS 9Y6nYK+mNrT+XNGmGy7DRF+fGYtEm14LyCfV0Fx9FEO8gBU4ik38GOv1jcJuLGLXaD5F iBwjY25Oxbsp2K6ujWm3YM8eXHcTWlk2AuujaGh48a6d3DqDr5fTUpnwUTMpGHo9JZUk Ecc2BqqOrxpsAH4/ufHOPDgaeab6jBSNFcEBFh0epEuGDlNV2C6mkO5s871Ebdi9aq4V rekaU3kfYEudV5imStEtUGcGERNtIqjWQfL3JfUvfrGz/1x7gJWp2voSN6PItH0wgTEA wYFQ== 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=Z+GoIGK0ASypWzKq72OR9x8SOdqUZq5a0/koCWBmuF4=; b=e3LiU4sq4jFcWEXd5a4UaXh3lTM5InMNE7gEq/KOUJ/Gxb2tpQCDuVJxvx8xnmfeCU TqUoe8GtxBmO2c8QgJGSYdjwpIqBqW0QUxl2L+dC8dwweWpJEkLkp6thfK8GIWRnDf7n YvqR3fowdz7vi3W6DUwHXe7zmKbp3LHAmDgV41f0rG+gP7tkD8zwMVUad+hNPeg4D5nL yIORKMzMwRIaCrJ2lEIchgsK8QY9onpV6KwaHzU8fOWvXjNdC3GADBclFiT0afHCbgBQ nF/VTB+0E2DeEVRpZhinbVtaxdCKFdlHkz56qITW98ZcXtbWepQ7yI6qAy5d80freMiS pt7A== X-Gm-Message-State: AOAM530i2je5MPimEjQQnZSNRbnrr6mW1zI9RZuTdUIGjf9DhSGpi+pK j/+cat+LS2ebWvQ5GUq0AdY= X-Google-Smtp-Source: ABdhPJwdXfftitSkQgijuSk3gh09yZ8hWXEU9IIUiEfUBuPEVMliIZMb7ZvHXRb3o8qf6vA4R76wXw== X-Received: by 2002:a63:4866:: with SMTP id x38mr1518318pgk.135.1619064588652; Wed, 21 Apr 2021 21:09:48 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:48 -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 13/14] net: ethernet: mtk_eth_soc: set PPE flow hash as skb hash if present Date: Wed, 21 Apr 2021 21:09:13 -0700 Message-Id: <20210422040914.47788-14-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 88a437f478fd..8c863322587e 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" @@ -1248,6 +1249,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); @@ -1317,6 +1319,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 Thu Apr 22 04:09:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12217579 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 3A8F8C433ED for ; Thu, 22 Apr 2021 04:10:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D1656144A for ; Thu, 22 Apr 2021 04:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230319AbhDVELO (ORCPT ); Thu, 22 Apr 2021 00:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234797AbhDVEKZ (ORCPT ); Thu, 22 Apr 2021 00:10:25 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7388C06138E; Wed, 21 Apr 2021 21:09:49 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id f2-20020a17090a4a82b02900c67bf8dc69so247012pjh.1; Wed, 21 Apr 2021 21:09:49 -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=gTam4Dh4Exrox41UjgsTUAzDdF7hSjfRPYT1wQxzNIA=; b=h4Ws/FzzrLMIqrmOr0IySyYw5sQpcKQebJ4fr52tIz8OeJS0J18r+Kk3Yby02VwCZb lB0VnuYreH0/WBg432DwfJyANbzRXjq+RyqMjMV91avjh7P6AVWyD36N3taxcUivyk81 gRifTzGqz56xEmn2k6jtorxqr5N1vLDH+pPNDe+b83J928uzB0K9oz/QkVW18/V0NOEm PmNXRP4p7ocJ3OqSd75VYOZ622O3F6Tb2dKbCXDirHHasEkzg3neP8XRcwVvl6xSnCcV p6+FpUvxCPmYMV8eIuZjKOIvK1JtK9l7z/eVW37FaQEAOnPMN480/2GGvYDW3XruZYWi OurQ== 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=gTam4Dh4Exrox41UjgsTUAzDdF7hSjfRPYT1wQxzNIA=; b=YOJ22B4TCoKas1FzeX/4/E690QhwjseauqICd3gUSM0zIvkBcJI3uKSCeOLFK29rj3 n1nt4nG+4FtjZOUEoeBuGScC+6GjUl7yBRispxzKzgg4RxtqfKqZxMCIZVEwuWSJZgzl Ev2dparxe05HCv/uf8kV9TaU0ocq6H76Wn+I1t6q+0r4tyhmaJwmiMfb08kBIFOQY+6H nJa5niR8EOErHmNIm2N1bo4bEdfEiuJXahdMrWcUlhok79/tu9GPEgnwAYVhAcO/TqGs cBborCt/2onD38n/QtIaO8Tu1LdifW9PJb+2LBssUa6A1rnUlLlC+FXcrdnJKXtBAPWI PgVg== X-Gm-Message-State: AOAM530r0VAXqhwACUovjchccKIkwV4bznkRDEwrRgXc9hThFaTKlWKC fFqiDvad+PvW3FDjikAVdYU= X-Google-Smtp-Source: ABdhPJzmrEjvXUJJGC9Se3LcQu04Mdkl0aXOfVWFnghAJi2orXke+l4GVOKEPwHkQQLbn8xZTwi3fw== X-Received: by 2002:a17:902:778f:b029:ec:d04d:4556 with SMTP id o15-20020a170902778fb02900ecd04d4556mr1407386pll.43.1619064589415; Wed, 21 Apr 2021 21:09:49 -0700 (PDT) Received: from z640-arch.lan ([2602:61:7344:f100::678]) by smtp.gmail.com with ESMTPSA id i17sm635354pfd.84.2021.04.21.21.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 21:09:49 -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 14/14] net: ethernet: mtk_eth_soc: use iopoll.h macro for DMA init Date: Wed, 21 Apr 2021 21:09:14 -0700 Message-Id: <20210422040914.47788-15-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210422040914.47788-1-ilya.lipnitskiy@gmail.com> References: <20210422040914.47788-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 8c863322587e..720d73d0c007 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2037,25 +2037,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; + u32 val; + int ret; + unsigned int reg; - 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 214da569e869..2e4356ccf778 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