From patchwork Tue Jan 16 09:43:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xuan Zhuo X-Patchwork-Id: 13520625 X-Patchwork-Delegate: kuba@kernel.org Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) (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 E9E6018B04; Tue, 16 Jan 2024 09:43:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R691e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0W-lmy6k_1705398203; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0W-lmy6k_1705398203) by smtp.aliyun-inc.com; Tue, 16 Jan 2024 17:43:24 +0800 From: Xuan Zhuo To: netdev@vger.kernel.org Cc: "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , virtualization@lists.linux.dev, bpf@vger.kernel.org Subject: [PATCH net-next 09/17] virtio_net: xsk: tx: free the unused xsk buffer Date: Tue, 16 Jan 2024 17:43:05 +0800 Message-Id: <20240116094313.119939-10-xuanzhuo@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20240116094313.119939-1-xuanzhuo@linux.alibaba.com> References: <20240116094313.119939-1-xuanzhuo@linux.alibaba.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Git-Hash: 1913ebd4ae28 X-Patchwork-Delegate: kuba@kernel.org virtnet_sq_free_unused_buf() check xsk buffer. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drivers/net/virtio/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/main.c b/drivers/net/virtio/main.c index cb0a1ea712de..e64d52e7d95b 100644 --- a/drivers/net/virtio/main.c +++ b/drivers/net/virtio/main.c @@ -4081,10 +4081,12 @@ void virtnet_sq_free_unused_bufs(struct virtqueue *vq) while ((buf = virtqueue_detach_unused_buf_dma(vq, dma)) != NULL) { virtnet_sq_unmap_buf(sq, dma); - if (!virtnet_is_xdp_frame(buf)) + if (virtnet_is_skb_ptr(buf)) dev_kfree_skb(buf); - else + else if (virtnet_is_xdp_frame(buf)) xdp_return_frame(virtnet_ptr_to_xdp(buf)); + else + xsk_tx_completed(sq->xsk.pool, 1); } }