From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by mail.toke.dk (Postfix) with ESMTPS id 1D7FEAF6E5A for ; Tue, 04 Feb 2025 01:50:33 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=c9oa/IdQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738630234; x=1770166234; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I34wLFfDKiKppl9dNuTu7winWO1kua0VyXa1LB4IcCk=; b=c9oa/IdQmrqMWVhZAewdsRUBdSmrio3IMJCJA0EMedcm8mNRhVDXbty+ 4phsHVkfwMzZj1Ki9WiGtJ/98KpwM4/BgmrnQBHztLXO1bgJVwHrztm9X 68BSk1VDuamJqgFPV0PUrj2OtTWHpRvrLf6vNRqffnJfxHChExZ5h+hEE XUg/3kyd0WuZDVIrkrYMZMnQvE48qSd6+H0oURYbj/1TyKvow/kPsgMV+ FRwK95zvddnDIsZ/89yeO2L8uhfv77RPg6ab2Glga1iCHYYG9H5ad7G/y E67AAnIc0s/tFLzHOzNY1fnQkoTWfQD6DMV+e9KY150PtNUnZl+QnBt+e g==; X-CSE-ConnectionGUID: SoB1qZPNTAajUAHMWfhdeQ== X-CSE-MsgGUID: BXhCLXKvRfmxGNZ8m0uC1w== X-IronPort-AV: E=McAfee;i="6700,10204,11335"; a="39296598" X-IronPort-AV: E=Sophos;i="6.13,257,1732608000"; d="scan'208";a="39296598" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2025 16:50:32 -0800 X-CSE-ConnectionGUID: 5PFqK48GQBa3ivuaNH/6NQ== X-CSE-MsgGUID: SbvIf5rIQrSmuhOx1Q+D/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="115605701" Received: from p12ill20yoongsia.png.intel.com ([10.88.227.38]) by orviesa005.jf.intel.com with ESMTP; 03 Feb 2025 16:50:19 -0800 From: Song Yoong Siang To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Willem de Bruijn , Florian Bezdeka , Donald Hunter , Jonathan Corbet , Bjorn Topel , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Andrew Lunn , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Joe Damato , Stanislav Fomichev , Xuan Zhuo , Mina Almasry , Daniel Jurgens , Song Yoong Siang , Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Hao Luo , Jiri Olsa , Shuah Khan , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Tony Nguyen , Przemek Kitszel , Faizal Rahim , Choong Yong Liang , Bouska Zdenek Date: Tue, 4 Feb 2025 08:49:06 +0800 Message-Id: <20250204004907.789330-5-yoong.siang.song@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250204004907.789330-1-yoong.siang.song@intel.com> References: <20250204004907.789330-1-yoong.siang.song@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: O2VMU4N7NFRX3PYHETUFZD5SBPAHSRB6 X-Message-ID-Hash: O2VMU4N7NFRX3PYHETUFZD5SBPAHSRB6 X-MailFrom: yoong.siang.song@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, intel-wired-lan@lists.osuosl.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.10 Precedence: list Subject: [xdp-hints] [PATCH bpf-next v7 4/5] igc: Refactor empty packet insertion into a reusable function List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Refactor the code for inserting an empty packet into a new function igc_insert_empty_packet(). This change extracts the logic for inserting an empty packet from igc_xmit_frame_ring() into a separate function, allowing it to be reused in future implementations, such as the XDP zero copy transmit function. This patch introduces no functional changes. Signed-off-by: Song Yoong Siang --- drivers/net/ethernet/intel/igc/igc_main.c | 42 ++++++++++++----------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 56a35d58e7a6..c3edd8bcf633 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -1566,6 +1566,26 @@ static bool igc_request_tx_tstamp(struct igc_adapter *adapter, struct sk_buff *s return false; } +static void igc_insert_empty_packet(struct igc_ring *tx_ring) +{ + struct igc_tx_buffer *empty_info; + struct sk_buff *empty; + void *data; + + empty_info = &tx_ring->tx_buffer_info[tx_ring->next_to_use]; + empty = alloc_skb(IGC_EMPTY_FRAME_SIZE, GFP_ATOMIC); + if (!empty) + return; + + data = skb_put(empty, IGC_EMPTY_FRAME_SIZE); + memset(data, 0, IGC_EMPTY_FRAME_SIZE); + + igc_tx_ctxtdesc(tx_ring, 0, false, 0, 0, 0); + + if (igc_init_tx_empty_descriptor(tx_ring, empty, empty_info) < 0) + dev_kfree_skb_any(empty); +} + static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb, struct igc_ring *tx_ring) { @@ -1603,26 +1623,8 @@ static netdev_tx_t igc_xmit_frame_ring(struct sk_buff *skb, skb->tstamp = ktime_set(0, 0); launch_time = igc_tx_launchtime(tx_ring, txtime, &first_flag, &insert_empty); - if (insert_empty) { - struct igc_tx_buffer *empty_info; - struct sk_buff *empty; - void *data; - - empty_info = &tx_ring->tx_buffer_info[tx_ring->next_to_use]; - empty = alloc_skb(IGC_EMPTY_FRAME_SIZE, GFP_ATOMIC); - if (!empty) - goto done; - - data = skb_put(empty, IGC_EMPTY_FRAME_SIZE); - memset(data, 0, IGC_EMPTY_FRAME_SIZE); - - igc_tx_ctxtdesc(tx_ring, 0, false, 0, 0, 0); - - if (igc_init_tx_empty_descriptor(tx_ring, - empty, - empty_info) < 0) - dev_kfree_skb_any(empty); - } + if (insert_empty) + igc_insert_empty_packet(tx_ring); done: /* record the location of the first descriptor for this packet */ -- 2.34.1