From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 82C4BA0096 for ; Wed, 10 Apr 2019 18:44:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 71B5A1B105; Wed, 10 Apr 2019 18:44:50 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 713521B105 for ; Wed, 10 Apr 2019 18:44:49 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D532F30BB340; Wed, 10 Apr 2019 16:44:48 +0000 (UTC) Received: from rh.redhat.com (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 613DA5D962; Wed, 10 Apr 2019 16:44:45 +0000 (UTC) From: Kevin Traynor To: Tiwei Bie Cc: Maxime Coquelin , dpdk stable Date: Wed, 10 Apr 2019 17:43:28 +0100 Message-Id: <20190410164411.10546-20-ktraynor@redhat.com> In-Reply-To: <20190410164411.10546-1-ktraynor@redhat.com> References: <20190410164411.10546-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 10 Apr 2019 16:44:48 +0000 (UTC) Subject: [dpdk-stable] patch 'net/virtio: fix in-order Tx path for split ring' has been queued to LTS release 18.11.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 04/16/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Kevin Traynor --- >From 8cc891643229266c99063c1da606e6438ac9d9bd Mon Sep 17 00:00:00 2001 From: Tiwei Bie Date: Tue, 19 Feb 2019 18:59:48 +0800 Subject: [PATCH] net/virtio: fix in-order Tx path for split ring [ upstream commit e788032aaca7193a107ca3fcfb71b0f0ba6c3db5 ] When IN_ORDER feature is negotiated, device may just write out a single used ring entry for a batch of buffers: """ Some devices always use descriptors in the same order in which they have been made available. These devices can offer the VIRTIO_F_IN_ORDER feature. If negotiated, this knowledge allows devices to notify the use of a batch of buffers to the driver by only writing out a single used ring entry with the id corresponding to the head entry of the descriptor chain describing the last buffer in the batch. The device then skips forward in the ring according to the size of the batch. Accordingly, it increments the used idx by the size of the batch. The driver needs to look up the used id and calculate the batch size to be able to advance to where the next used ring entry will be written by the device. """ Currently, the in-order Tx path in split ring can't handle this. With this patch, driver will allocate desc_extra[] based on the index in avail/used ring instead of the index in descriptor table. And driver can just relay on the used->idx written by device to reclaim the descriptors and Tx buffers. Fixes: e5f456a98d3c ("net/virtio: support in-order Rx and Tx") Signed-off-by: Tiwei Bie Reviewed-by: Maxime Coquelin --- drivers/net/virtio/virtio_rxtx.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index eb891433e..7e035130f 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -193,5 +193,5 @@ static void virtio_xmit_cleanup_inorder(struct virtqueue *vq, uint16_t num) { - uint16_t i, used_idx, desc_idx = 0, last_idx; + uint16_t i, idx = vq->vq_used_cons_idx; int16_t free_cnt = 0; struct vq_desc_extra *dxp = NULL; @@ -201,13 +201,6 @@ virtio_xmit_cleanup_inorder(struct virtqueue *vq, uint16_t num) for (i = 0; i < num; i++) { - struct vring_used_elem *uep; - - used_idx = vq->vq_used_cons_idx & (vq->vq_nentries - 1); - uep = &vq->vq_ring.used->ring[used_idx]; - desc_idx = (uint16_t)uep->id; - - dxp = &vq->vq_descx[desc_idx]; - vq->vq_used_cons_idx++; - + dxp = &vq->vq_descx[idx++ & (vq->vq_nentries - 1)]; + free_cnt += dxp->ndescs; if (dxp->cookie != NULL) { rte_pktmbuf_free(dxp->cookie); @@ -216,10 +209,6 @@ virtio_xmit_cleanup_inorder(struct virtqueue *vq, uint16_t num) } - last_idx = desc_idx + dxp->ndescs - 1; - free_cnt = last_idx - vq->vq_desc_tail_idx; - if (free_cnt <= 0) - free_cnt += vq->vq_nentries; - - vq_ring_free_inorder(vq, last_idx, free_cnt); + vq->vq_free_cnt += free_cnt; + vq->vq_used_cons_idx = idx; } @@ -422,5 +411,5 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq, while (i < num) { idx = idx & (vq->vq_nentries - 1); - dxp = &vq->vq_descx[idx]; + dxp = &vq->vq_descx[vq->vq_avail_idx & (vq->vq_nentries - 1)]; dxp->cookie = (void *)cookies[i]; dxp->ndescs = 1; @@ -473,5 +462,8 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie, head_idx = vq->vq_desc_head_idx; idx = head_idx; - dxp = &vq->vq_descx[idx]; + if (in_order) + dxp = &vq->vq_descx[vq->vq_avail_idx & (vq->vq_nentries - 1)]; + else + dxp = &vq->vq_descx[idx]; dxp->cookie = (void *)cookie; dxp->ndescs = needed; -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2019-04-10 14:06:09.565312586 +0100 +++ 0020-net-virtio-fix-in-order-Tx-path-for-split-ring.patch 2019-04-10 14:06:07.837294862 +0100 @@ -1,8 +1,10 @@ -From e788032aaca7193a107ca3fcfb71b0f0ba6c3db5 Mon Sep 17 00:00:00 2001 +From 8cc891643229266c99063c1da606e6438ac9d9bd Mon Sep 17 00:00:00 2001 From: Tiwei Bie Date: Tue, 19 Feb 2019 18:59:48 +0800 Subject: [PATCH] net/virtio: fix in-order Tx path for split ring +[ upstream commit e788032aaca7193a107ca3fcfb71b0f0ba6c3db5 ] + When IN_ORDER feature is negotiated, device may just write out a single used ring entry for a batch of buffers: @@ -30,7 +32,6 @@ reclaim the descriptors and Tx buffers. Fixes: e5f456a98d3c ("net/virtio: support in-order Rx and Tx") -Cc: stable@dpdk.org Signed-off-by: Tiwei Bie Reviewed-by: Maxime Coquelin @@ -39,17 +40,17 @@ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c -index b07ceac6d..407f58bce 100644 +index eb891433e..7e035130f 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c -@@ -280,5 +280,5 @@ static void +@@ -193,5 +193,5 @@ static void virtio_xmit_cleanup_inorder(struct virtqueue *vq, uint16_t num) { - uint16_t i, used_idx, desc_idx = 0, last_idx; + uint16_t i, idx = vq->vq_used_cons_idx; int16_t free_cnt = 0; struct vq_desc_extra *dxp = NULL; -@@ -288,13 +288,6 @@ virtio_xmit_cleanup_inorder(struct virtqueue *vq, uint16_t num) +@@ -201,13 +201,6 @@ virtio_xmit_cleanup_inorder(struct virtqueue *vq, uint16_t num) for (i = 0; i < num; i++) { - struct vring_used_elem *uep; @@ -65,7 +66,7 @@ + free_cnt += dxp->ndescs; if (dxp->cookie != NULL) { rte_pktmbuf_free(dxp->cookie); -@@ -303,10 +296,6 @@ virtio_xmit_cleanup_inorder(struct virtqueue *vq, uint16_t num) +@@ -216,10 +209,6 @@ virtio_xmit_cleanup_inorder(struct virtqueue *vq, uint16_t num) } - last_idx = desc_idx + dxp->ndescs - 1; @@ -78,14 +79,14 @@ + vq->vq_used_cons_idx = idx; } -@@ -557,5 +546,5 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq, +@@ -422,5 +411,5 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq, while (i < num) { idx = idx & (vq->vq_nentries - 1); - dxp = &vq->vq_descx[idx]; + dxp = &vq->vq_descx[vq->vq_avail_idx & (vq->vq_nentries - 1)]; dxp->cookie = (void *)cookies[i]; dxp->ndescs = 1; -@@ -709,5 +698,8 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie, +@@ -473,5 +462,8 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie, head_idx = vq->vq_desc_head_idx; idx = head_idx; - dxp = &vq->vq_descx[idx];