From patchwork Sun Dec 6 00:00:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 11953531 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=-14.2 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_SANE_1 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 BC3AEC4361B for ; Sun, 6 Dec 2020 00:01:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CAA72313C for ; Sun, 6 Dec 2020 00:01:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbgLFABp (ORCPT ); Sat, 5 Dec 2020 19:01:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725270AbgLFABo (ORCPT ); Sat, 5 Dec 2020 19:01:44 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 455E9C0613D1 for ; Sat, 5 Dec 2020 16:01:04 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id a6so8422144wmc.2 for ; Sat, 05 Dec 2020 16:01:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=xtDjSEBnDzgEG2Ay8lke047Uz/3kwjxeikZsv3A5YPE=; b=tR1AIUXOe7tDi7vfIgIHYisONxh17V9sh6c/6Y69SBeNcQjZtQKclLvBnW2y+MU0r4 XUo8h49Knq5BM/NUwJh72HYQC5gO3lVoKBwBoV4ocdX88i3ss4ZwVxV1llcXkCpzcq9b qzMkSqN6tbICx5XvBWj2MGTifT14o29rlGqslfZTgEtOebQCipI8WuG46CAOUTxirn/L x+apb20UvxJil4Iqn0is7xa49cOA6N0mCfem4V8gcJQL55Tz8gWNUVpdCWEJ1zhgce4x ST+vZoAQOzrcxagGbzsYLrkzj/RWiq0qUkd44aRVQhCqeVEAJDeSVgiJOdPgfXPmbLFM fSXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=xtDjSEBnDzgEG2Ay8lke047Uz/3kwjxeikZsv3A5YPE=; b=IAHf5A+Itt6w/db4zsrWxN8WGn0Lxq2IuL3ly3QeAZV7MfJeIvPHHBiQx5tIAmD7Ue sQNPKEraWByN47SYAZcq3aqnBwP21qXl0sIRTHlWLzJUhP+YB+ssoKgyW8UQTwH8yzOU kc+fbgTTI7Ba2EhP9uRJDQcYyuW05t/Q1A6/qBBj5InwuB6nJGoL0p7IoPuSs2B5kvp2 KkmAfcwg9lUreWFkb+y+2brhZkqCq/z2c4NBols8nm0iO6yeQkEtFfw+qHSjRj5bkFn5 wSKeDBKmH2GwE1dSWhea/1kur0hTEU5MxzY03bmqOu/FKmp7iLXaSnVywMVMuKINFl1B +XyQ== X-Gm-Message-State: AOAM530A9aWRZURyu3YRUeT8LXXOMKhMBQfVOf11fAplWUQoaxi1tBHC HAg4kszzgTuavaosPysP1srivqsRFu0= X-Google-Smtp-Source: ABdhPJy90qcwvGl64iq3XxVfcR7mxzjw5m5gT7/tEtMcKDb1bwOuH3fQnUd46Cah2LDDuxx4UbYM+w== X-Received: by 2002:a1c:730c:: with SMTP id d12mr11161992wmb.3.1607212862772; Sat, 05 Dec 2020 16:01:02 -0800 (PST) Received: from ?IPv6:2003:ea:8f2e:e00:6845:f25a:bfd1:6598? (p200300ea8f2e0e006845f25abfd16598.dip0.t-ipconnect.de. [2003:ea:8f2e:e00:6845:f25a:bfd1:6598]) by smtp.googlemail.com with ESMTPSA id h98sm9753973wrh.69.2020.12.05.16.01.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 05 Dec 2020 16:01:02 -0800 (PST) Subject: [PATCH net-next 1/2] r8169: improve rtl_rx From: Heiner Kallweit To: Jakub Kicinski , David Miller , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: Message-ID: <1ede7930-0018-49dc-b63a-7c77dd4b367b@gmail.com> Date: Sun, 6 Dec 2020 01:00:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There's no need to check min(budget, NUM_RX_DESC). At first budget (NAPI_POLL_WEIGHT = 64) is less then NUM_RX_DESC (256). And more important: Even in case of budget > NUM_RX_DESC we could safely continue processing descriptors as long as they are owned by the CPU. In addition replace rx_left with a normal counter variable, this allows to simplify the code. Last but not least there's no need any longer to pass the budget as an u32. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 3ef1b31c9..3ea27a657 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -4415,15 +4415,13 @@ static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1) skb_checksum_none_assert(skb); } -static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget) +static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, int budget) { - unsigned int cur_rx, rx_left, count; struct device *d = tp_to_dev(tp); + int count; - cur_rx = tp->cur_rx; - - for (rx_left = min(budget, NUM_RX_DESC); rx_left > 0; rx_left--, cur_rx++) { - unsigned int pkt_size, entry = cur_rx % NUM_RX_DESC; + for (count = 0; count < budget; count++, tp->cur_rx++) { + unsigned int pkt_size, entry = tp->cur_rx % NUM_RX_DESC; struct RxDesc *desc = tp->RxDescArray + entry; struct sk_buff *skb; const void *rx_buf; @@ -4500,9 +4498,6 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget rtl8169_mark_to_asic(desc); } - count = cur_rx - tp->cur_rx; - tp->cur_rx = cur_rx; - return count; } @@ -4561,7 +4556,7 @@ static int rtl8169_poll(struct napi_struct *napi, int budget) struct net_device *dev = tp->dev; int work_done; - work_done = rtl_rx(dev, tp, (u32) budget); + work_done = rtl_rx(dev, tp, budget); rtl_tx(dev, tp, budget); From patchwork Sun Dec 6 00:00:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 11953533 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=-14.2 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_SANE_1 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 5007EC4361B for ; Sun, 6 Dec 2020 00:02:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13B3423136 for ; Sun, 6 Dec 2020 00:02:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727148AbgLFABw (ORCPT ); Sat, 5 Dec 2020 19:01:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725270AbgLFABv (ORCPT ); Sat, 5 Dec 2020 19:01:51 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9081AC0613D4 for ; Sat, 5 Dec 2020 16:01:05 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id h21so10297985wmb.2 for ; Sat, 05 Dec 2020 16:01:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=XhypvLhjLjgPJLi+sFOljhwXZxv/PXDgkLN+nebBmD0=; b=t0/B0io+oHAvDcsX82vtNSqwUZsUL8rcZ6IXJxPkVOz5eH4zHkaQNm+OBhwq4rcDtx y8cr3zJLSrTBJw/rYbEgX918m1aYotTRBGSdzuxu1otaY5wGIGpk/CwQ7QL7vy3VXFSm QXzIOqV0+gYqYQxc2jsRDuM97meEOlxpcUFHeCFX/LmiiDfNlLW7Po79fF3n4tOVugzM A0ikq6LXLgsdqhca4Eud3nzbuBtr7qKxoWsCpaGHuaDMMCDnh475qC/vt1ciWUdyiX3m FSd6jTi1mlzR+J9Pgr7VVTDSBS+IJxW+XsYz050JqG0Bp6cvw6dBN7uWQjYLPvX1ZY2Z ViMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=XhypvLhjLjgPJLi+sFOljhwXZxv/PXDgkLN+nebBmD0=; b=sFLXxMe6NkqDpzC2rDZIOoRLw2Dw/kWLa8UX6La6F7hITbAJPCGl4kGUfrRMt7tRGs zqHPxv+Kua1elUiCFzpXF5ESripBVq3UF746ztTEoTCb0HLZAVf4vabMfY4f79OPFfe9 XstoD3NF4UAd0SgiXyrcpHW4XoFEYUa4cI93yXaTJ9uATqAHtGNLb9t4dUEQe0ipooz4 0gQE4HVGw4htXotNyxjf4po2a3WXNIcm8ZAue51WbEUq8bGBztAYtCQq7b82BsSP8oBE 0xGPxPZzdNEpjmYXqhwPbr3yKwg70t92ZIElI0eVVtMY+4mJVhQxbV6p5mTBDsOL1CNY aNwQ== X-Gm-Message-State: AOAM532KZRxy+voXpK4Ur78GXXFI4LF/KXld/ex+fnK2XWPKRtVmmmdG zGZPn0OvhMhAbNYbFtECOPg5HRqJ638= X-Google-Smtp-Source: ABdhPJxNsIlDmmrawUIUBYBrsX3bwvTOeViSGZdHOctudecwH1cEJwUrVWNmgRWt37GQ9iobfcuRcQ== X-Received: by 2002:a1c:9d8b:: with SMTP id g133mr11277572wme.189.1607212864103; Sat, 05 Dec 2020 16:01:04 -0800 (PST) Received: from ?IPv6:2003:ea:8f2e:e00:6845:f25a:bfd1:6598? (p200300ea8f2e0e006845f25abfd16598.dip0.t-ipconnect.de. [2003:ea:8f2e:e00:6845:f25a:bfd1:6598]) by smtp.googlemail.com with ESMTPSA id z3sm3459348wrn.59.2020.12.05.16.01.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 05 Dec 2020 16:01:03 -0800 (PST) Subject: [PATCH net-next 2/2] r8169: make NUM_RX_DESC a signed int From: Heiner Kallweit To: Jakub Kicinski , David Miller , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: Message-ID: Date: Sun, 6 Dec 2020 01:00:54 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org After recent changes there's no need any longer to define NUM_RX_DESC as an unsigned value. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 3ea27a657..46d8510b2 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -68,7 +68,7 @@ #define R8169_REGS_SIZE 256 #define R8169_RX_BUF_SIZE (SZ_16K - 1) #define NUM_TX_DESC 256 /* Number of Tx descriptor registers */ -#define NUM_RX_DESC 256U /* Number of Rx descriptor registers */ +#define NUM_RX_DESC 256 /* Number of Rx descriptor registers */ #define R8169_TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc)) #define R8169_RX_RING_BYTES (NUM_RX_DESC * sizeof(struct RxDesc)) @@ -3844,7 +3844,7 @@ static struct page *rtl8169_alloc_rx_data(struct rtl8169_private *tp, static void rtl8169_rx_clear(struct rtl8169_private *tp) { - unsigned int i; + int i; for (i = 0; i < NUM_RX_DESC && tp->Rx_databuff[i]; i++) { dma_unmap_page(tp_to_dev(tp), @@ -3859,7 +3859,7 @@ static void rtl8169_rx_clear(struct rtl8169_private *tp) static int rtl8169_rx_fill(struct rtl8169_private *tp) { - unsigned int i; + int i; for (i = 0; i < NUM_RX_DESC; i++) { struct page *data;