From patchwork Wed Feb 5 02:41:15 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: 13960459 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 10A15212D8B; Wed, 5 Feb 2025 02:42:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738723333; cv=none; b=YwyeiEq2ap6m9Qr7DtKjsSmt4UVPkFNXh+OfLhViJDv3ia9RoIxJ7x6kMEXrMezbmDpQnyEv6EGPtH6x37Qgd5yZL2979V+nEWSZYcmQey1lAjo+6DYp0EqU2kXVe+2ikkq5mbrExwcmW+Vvh6qul7Cvx66i9BOV9WFaFq721s0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738723333; c=relaxed/simple; bh=Utj1UJhD/A+1VjVQheCreoYgsb9L8I5I4wm7q1juvCU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=inyI1Kxbww6gI5sxp33+c12X5EN2NDCh1eD7C58VmDuFCsLTmvUZzMUFF5PEG20VurJHQzoHJvLV9iQkuS0UE9Yv9tZzWrdtg+kxmomU8Y9E5nMrr4lLJT7ar3XWFbM+b++GXt//DBZ5nOysJz3/hdwNqvW75aMHsqxdmAGqcco= 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=gf1fUbVr; arc=none smtp.client-ip=198.175.65.17 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="gf1fUbVr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1738723332; x=1770259332; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Utj1UJhD/A+1VjVQheCreoYgsb9L8I5I4wm7q1juvCU=; b=gf1fUbVrCf1DaFM5hyQSb7tFM+4dqultICh69hURElxxE6v7q2Zi9qjY cVhMHrJNnErygjldJuNdTDuWcy109f2p8pehn2jqbWgsIH1Tk6WXrJFmA fNmHjNjuWKNytJIbFWNB93flyw4r+PwS7UjGcALdes8RhvSzEtdMZHc9v cbzIjWM2R1MoyiiVCUQY+iIFOPPBMMcN4GPyFZCyPHDvOHWjzpX7YjNFE weH0fvDTYuhhZKcg9zrS4cUMNFgmvcXs/ohQ0Ziwm0WmrvsUjfm7ZRik/ nlDXEPmdISfPrfJgoMXz1xDS7Iq1xWHW7biVWhD/p4y5+tRs75czJwc6S w==; X-CSE-ConnectionGUID: lJms2Ea8Re+EKRb3t+iakA== X-CSE-MsgGUID: /y9rfCFeSVy39lRafs3yKA== X-IronPort-AV: E=McAfee;i="6700,10204,11336"; a="39303921" X-IronPort-AV: E=Sophos;i="6.13,260,1732608000"; d="scan'208";a="39303921" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Feb 2025 18:42:11 -0800 X-CSE-ConnectionGUID: 6gh2BosHSB6Cim6S+Sj9AA== X-CSE-MsgGUID: +b9HroD5R5i5dhekZCM9VQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,260,1732608000"; d="scan'208";a="110666604" Received: from p12ill20yoongsia.png.intel.com ([10.88.227.38]) by fmviesa007.fm.intel.com with ESMTP; 04 Feb 2025 18:42:00 -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 v8 4/5] igc: Refactor empty packet insertion into a reusable function Date: Wed, 5 Feb 2025 10:41:15 +0800 Message-Id: <20250205024116.798862-5-yoong.siang.song@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250205024116.798862-1-yoong.siang.song@intel.com> References: <20250205024116.798862-1-yoong.siang.song@intel.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net 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 21f318f12a8d..553d6d82af0d 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 */