Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp6018700rdb; Mon, 18 Sep 2023 01:05:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEF1qXSMd3FXPPfpKexqOCCOYD5YdIkByz3pwKB7x4LSExCbTc60dYFdMtxFc8DlZjTQY2B X-Received: by 2002:a54:4719:0:b0:3a7:44da:d5e6 with SMTP id k25-20020a544719000000b003a744dad5e6mr9834501oik.38.1695024320085; Mon, 18 Sep 2023 01:05:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695024320; cv=none; d=google.com; s=arc-20160816; b=XAlsnvzRjhmTmg/n1bQO3dpJoWHOlhsu6DUG3r8ZCthvP8vNgTI0Y34scgSsWY+6s7 CBBSSGvlx6+P2VOL1AJ9zUsvs1id7xxDEtJ8nWwI4Gr15oICcdDNrx1LIk3IwSRcr+nK 3JjkXto1LAp2MprT7fJS7U7OB/1Mn9U6QK9EfyW7U7T2/VxRWHSDQrUCWtomauXPZMk1 y6dcgzN1lOrrJ7yCcC1KvWgF9LwpGwoJdKPf2L0maQmXkSAGOobNQ8tydO7LblcsrrDM njeBvLUD0eHpF8wnfWvQQ3QpIpjdQ/ywd6Ht5v13sZg1M4zTJbPq/Fr7AKIiU2UW30Fb LC8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=SMkIfpx0vksN9dAGQOT7NMaFs/bCzepSeVNJ7IyJUBI=; fh=ihIYiilCZXBu9x8WrnA4PYm4Oe+ipaGNn90/3600c/4=; b=mq4mDVnZw5TAD47OOBNvwuDOiAQH2oc4NO9XOE5uz5d/p9tLwhvAsjSiU6Dp0urWFs Nz/UyQ6REonTG7ZAmNGlPe/hnhQPgKBaClo1v6WVJqQ2UtvigGZ1ZsuOY+UAHaW0eEbt zU7HNgpRfvMYiP73nKYYvO80nw8jqCTjP0dlyR1xgHN15QjdWl5ckR/tlTofRz0Tor2R zYcgCm1inXnXr/I/u1dBZA39ddgjqfM/WngQeG15WmWxyyW3esKI/+JS2f46tagPDOBO rB7qaYhG/eCFD+pJri0f9Rw20T2Veo/NiNlxSxYDcin+u9bBAwLnZkx5X5bbrIVVDqc1 sWlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id c5-20020a17090a8d0500b00274dc876792si2883884pjo.98.2023.09.18.01.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 01:05:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 014E0808D6B8; Mon, 18 Sep 2023 01:03:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238333AbjIRICq (ORCPT + 99 others); Mon, 18 Sep 2023 04:02:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240725AbjIRIC3 (ORCPT ); Mon, 18 Sep 2023 04:02:29 -0400 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88ABF10DC; Mon, 18 Sep 2023 00:43:12 -0700 (PDT) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 38I7gYKd91835289, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.92/5.92) with ESMTPS id 38I7gYKd91835289 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Sep 2023 15:42:34 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Mon, 18 Sep 2023 15:42:31 +0800 Received: from fc38.localdomain (172.22.228.98) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 18 Sep 2023 15:42:30 +0800 From: Hayes Wang To: , CC: , , , , , , , Hayes Wang Subject: [PATCH net-next resend 1/2] r8152: remove queuing rx packets in driver Date: Mon, 18 Sep 2023 15:42:00 +0800 Message-ID: <20230918074202.2461-427-nic_swsd@realtek.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230918074202.2461-426-nic_swsd@realtek.com> References: <20230918074202.2461-426-nic_swsd@realtek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [172.22.228.98] X-ClientProxiedBy: RTEXH36505.realtek.com.tw (172.21.6.25) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-KSE-ServerInfo: RTEXMBS04.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 01:03:18 -0700 (PDT) The original way would process all rx and queue the rx packets in the driver. Now, the process would be broken if the budget is exhausted. And the remained list would be queue back to rx_done for next schedule. Signed-off-by: Hayes Wang --- drivers/net/usb/r8152.c | 52 ++++++++++++----------------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 0c13d9950cd8..ae46e7e46e39 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -871,7 +871,7 @@ struct r8152 { struct tx_agg tx_info[RTL8152_MAX_TX]; struct list_head rx_info, rx_used; struct list_head rx_done, tx_free; - struct sk_buff_head tx_queue, rx_queue; + struct sk_buff_head tx_queue; spinlock_t rx_lock, tx_lock; struct delayed_work schedule, hw_phy_work; struct mii_if_info mii; @@ -2031,7 +2031,6 @@ static int alloc_all_mem(struct r8152 *tp) INIT_LIST_HEAD(&tp->tx_free); INIT_LIST_HEAD(&tp->rx_done); skb_queue_head_init(&tp->tx_queue); - skb_queue_head_init(&tp->rx_queue); atomic_set(&tp->rx_count, 0); for (i = 0; i < RTL8152_MAX_RX; i++) { @@ -2431,24 +2430,6 @@ static int rx_bottom(struct r8152 *tp, int budget) int ret = 0, work_done = 0; struct napi_struct *napi = &tp->napi; - if (!skb_queue_empty(&tp->rx_queue)) { - while (work_done < budget) { - struct sk_buff *skb = __skb_dequeue(&tp->rx_queue); - struct net_device *netdev = tp->netdev; - struct net_device_stats *stats = &netdev->stats; - unsigned int pkt_len; - - if (!skb) - break; - - pkt_len = skb->len; - napi_gro_receive(napi, skb); - work_done++; - stats->rx_packets++; - stats->rx_bytes += pkt_len; - } - } - if (list_empty(&tp->rx_done)) goto out1; @@ -2484,10 +2465,6 @@ static int rx_bottom(struct r8152 *tp, int budget) unsigned int pkt_len, rx_frag_head_sz; struct sk_buff *skb; - /* limit the skb numbers for rx_queue */ - if (unlikely(skb_queue_len(&tp->rx_queue) >= 1000)) - break; - pkt_len = le32_to_cpu(rx_desc->opts1) & RX_LEN_MASK; if (pkt_len < ETH_ZLEN) break; @@ -2525,14 +2502,10 @@ static int rx_bottom(struct r8152 *tp, int budget) skb->protocol = eth_type_trans(skb, netdev); rtl_rx_vlan_tag(rx_desc, skb); - if (work_done < budget) { - work_done++; - stats->rx_packets++; - stats->rx_bytes += skb->len; - napi_gro_receive(napi, skb); - } else { - __skb_queue_tail(&tp->rx_queue, skb); - } + work_done++; + stats->rx_packets++; + stats->rx_bytes += skb->len; + napi_gro_receive(napi, skb); find_next_rx: rx_data = rx_agg_align(rx_data + pkt_len + ETH_FCS_LEN); @@ -2562,16 +2535,24 @@ static int rx_bottom(struct r8152 *tp, int budget) urb->actual_length = 0; list_add_tail(&agg->list, next); } + + /* Break if budget is exhausted. */ + if (work_done >= budget) + break; } + /* Splice the remained list back to rx_done */ if (!list_empty(&rx_queue)) { spin_lock_irqsave(&tp->rx_lock, flags); - list_splice_tail(&rx_queue, &tp->rx_done); + list_splice(&rx_queue, &tp->rx_done); spin_unlock_irqrestore(&tp->rx_lock, flags); } out1: - return work_done; + if (work_done > budget) + return budget; + else + return work_done; } static void tx_bottom(struct r8152 *tp) @@ -2992,9 +2973,6 @@ static int rtl_stop_rx(struct r8152 *tp) list_splice(&tmp_list, &tp->rx_info); spin_unlock_irqrestore(&tp->rx_lock, flags); - while (!skb_queue_empty(&tp->rx_queue)) - dev_kfree_skb(__skb_dequeue(&tp->rx_queue)); - return 0; } -- 2.41.0