From patchwork Tue Feb 4 00:49:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Song, Yoong Siang" X-Patchwork-Id: 13958481 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 402E227456; Tue, 4 Feb 2025 00:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738630235; cv=none; b=mS8GyIsVAh1PvLMZsKkUizb99bt3lFxoaJwSA0+oHEr6j255tSiZ8TFx4/M7Yt8lxn3F9pnWWCR9K8W8KyZhToWL+YTnQMnZnIus/CdRrAh4m8M2dZ/eCpK3ncvHOEGcqe27muKwXwAwYo2ANv03Is9XB+9+XXy2DUQ9PqsSBGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738630235; c=relaxed/simple; bh=I34wLFfDKiKppl9dNuTu7winWO1kua0VyXa1LB4IcCk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q2l/HnHdcmlUyYGwb1JEn9fPJMN8fWlk2bFMB+a5nmF/BNHu20lBhJD7TSe1QtgaDExzpqbiNV2Klz2rksk5L/ICAvkgzQbfWFM5tsCq8WfxPyf50VrrST78u6N3y1jtOXNVENuc/FUdTfrcqHV1CpwbP055aR9CVM46orSgexc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VMbDAoxp; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VMbDAoxp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738630233; x=1770166233; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I34wLFfDKiKppl9dNuTu7winWO1kua0VyXa1LB4IcCk=; b=VMbDAoxpacw7GmkOs+N41S+Q7M9eLIRLOnw7biOvF0rNmOw9pTu+vgHJ Le7QF802w1aXwGfVu+Mnbl2wWehJ0ZL71r1e8D9K3rHQy51GL7FozBj0v uGvoUjt+0SgsmLtAZgKVHqz6sOK554sDUtH0sId513ff7fhfyb0VDV7ut ybjdyCR62xG+zY2aH4Qncy7C3m6sRUmoGorsZymhVSfIlR+ufuynubxcK RT46BtSumhgnWST8YUHKIq4QByMI6yl/6DZZiVqQg/3+65i4CdTml5VAS tOg19nHIIbNUV0dWk6nUm620yB5A0unazd27pQoHRytfEh2Jfe6bwcLdc g==; X-CSE-ConnectionGUID: icLZKovwT825aFdl1ol7Pw== X-CSE-MsgGUID: Wk/ogrfLR0C1ywGlHwapEg== X-IronPort-AV: E=McAfee;i="6700,10204,11335"; a="39296585" X-IronPort-AV: E=Sophos;i="6.13,257,1732608000"; d="scan'208";a="39296585" 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 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 Subject: [PATCH bpf-next v7 4/5] igc: Refactor empty packet insertion into a reusable function 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> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Faizal Rahim --- 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 */