From patchwork Mon Sep 18 07:42:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hayes Wang X-Patchwork-Id: 141284 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2494341vqi; Mon, 18 Sep 2023 00:58:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFp8lxdI/iP8+VgE9HnkV5jELSDJxBAQVuDp09vXlZCRXdyC8PqbSWsfU+DyA9L0FgmkWxd X-Received: by 2002:a05:6870:fb8a:b0:1bf:51f2:94bd with SMTP id kv10-20020a056870fb8a00b001bf51f294bdmr10726144oab.18.1695023937667; Mon, 18 Sep 2023 00:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695023937; cv=none; d=google.com; s=arc-20160816; b=T1R3PYFl1dxv2eKKtlpeYvaXCazZd9hU1hEKZ5oP+8CWjsjdP1bBKMFpcUoRhr4gW/ wbk78lw9L2UiXeEmZtgu6zchApflKbDTi0xkEMk/1QYOfjBSBPMQ7DY4cO9W/lamuLXQ JmSyhs48hC4RQf/YyIYbWU2/YR2SQLT8LqS+YHaN9R3JamgYnL1VAEg2b+T6XD5H3s4Z asi3IQwRSlZQuxXzHzl0Opf9V0UMH73r3H70KuulYjCYjGPfIW6HSIp3f1tPPH60s6r6 HPYKo6dpFsRZ0Pfxwq4iVKaoSCHo/9Y1VfsakgvZjx59JepZgq4J9RvldB/Bjah5sg0n OIOg== 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=q02icPeIbwrl9ACqr53cyUW+QyArt3JBrhdTBTXQv9g=; fh=ihIYiilCZXBu9x8WrnA4PYm4Oe+ipaGNn90/3600c/4=; b=Ja0qC4mZHtI4GNwzkEtcwX+RAHqZ1dOcNBOXIQzr402n6Uy1A3w8wix71SxUeSj/bE K2YGWPCAJvmScjLDFr7qg3LGu2PGnz87zke7im5MDUlUuYZyvNGzny2fYY+L37BDcXy5 IwAtCPHwGxDLIZDPHVYGGv5PHK9FHnE3EWupxop2MpVrxIHen7bP4+xxUlqF6om3R1yr D2os+Fsy+iMUsRgaEs/NtJkMZT3LRE/gkp3M+RwZa/nA4PkNyDcbwZDP347yfZ0ZA+8P pGD0s9pp6dbNlpKf09cmvW/qNJvIKDSveipkPXUnfCKG486bwcDOs5yOfy6aYPy2lXJe 5KtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id ot16-20020a17090b3b5000b0026830486bdasi8083401pjb.118.2023.09.18.00.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 00:58:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 305DB812A625; Mon, 18 Sep 2023 00:45:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240213AbjIRHpS (ORCPT + 27 others); Mon, 18 Sep 2023 03:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240338AbjIRHoq (ORCPT ); Mon, 18 Sep 2023 03:44:46 -0400 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8599C10DB; Mon, 18 Sep 2023 00:43:12 -0700 (PDT) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 38I7gXqV51835290, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.92/5.92) with ESMTPS id 38I7gXqV51835290 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Sep 2023 15:42:33 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.32; 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 2/2] r8152: use napi_gro_frags Date: Mon, 18 Sep 2023 15:42:01 +0800 Message-ID: <20230918074202.2461-428-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 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-KSE-ServerInfo: RTEXH36505.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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 00:45:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777361420521154867 X-GMAIL-MSGID: 1777361420521154867 Use napi_gro_frags() for the skb of fragments. Signed-off-by: Hayes Wang --- drivers/net/usb/r8152.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index ae46e7e46e39..d872fbb5b6ff 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -2462,8 +2462,9 @@ static int rx_bottom(struct r8152 *tp, int budget) while (urb->actual_length > len_used) { struct net_device *netdev = tp->netdev; struct net_device_stats *stats = &netdev->stats; - unsigned int pkt_len, rx_frag_head_sz; + unsigned int pkt_len; struct sk_buff *skb; + bool use_frags; pkt_len = le32_to_cpu(rx_desc->opts1) & RX_LEN_MASK; if (pkt_len < ETH_ZLEN) @@ -2477,35 +2478,40 @@ static int rx_bottom(struct r8152 *tp, int budget) rx_data += sizeof(struct rx_desc); if (!agg_free || tp->rx_copybreak > pkt_len) - rx_frag_head_sz = pkt_len; + use_frags = false; else - rx_frag_head_sz = tp->rx_copybreak; + use_frags = true; + + if (use_frags) + skb = napi_get_frags(napi); + else + skb = napi_alloc_skb(napi, pkt_len); - skb = napi_alloc_skb(napi, rx_frag_head_sz); if (!skb) { stats->rx_dropped++; goto find_next_rx; } skb->ip_summed = r8152_rx_csum(tp, rx_desc); - memcpy(skb->data, rx_data, rx_frag_head_sz); - skb_put(skb, rx_frag_head_sz); - pkt_len -= rx_frag_head_sz; - rx_data += rx_frag_head_sz; - if (pkt_len) { + rtl_rx_vlan_tag(rx_desc, skb); + + if (use_frags) { skb_add_rx_frag(skb, 0, agg->page, agg_offset(agg, rx_data), pkt_len, SKB_DATA_ALIGN(pkt_len)); get_page(agg->page); + napi_gro_frags(napi); + } else { + memcpy(skb->data, rx_data, pkt_len); + skb_put(skb, pkt_len); + skb->protocol = eth_type_trans(skb, netdev); + napi_gro_receive(napi, skb); } - skb->protocol = eth_type_trans(skb, netdev); - rtl_rx_vlan_tag(rx_desc, skb); work_done++; stats->rx_packets++; - stats->rx_bytes += skb->len; - napi_gro_receive(napi, skb); + stats->rx_bytes += pkt_len; find_next_rx: rx_data = rx_agg_align(rx_data + pkt_len + ETH_FCS_LEN);