From patchwork Wed Jun 5 08:10:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 54379 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A88A91B9AC; Wed, 5 Jun 2019 10:10:25 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 4AE6A1B96B; Wed, 5 Jun 2019 10:10:21 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE1343001814; Wed, 5 Jun 2019 08:10:20 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-53.ams2.redhat.com [10.36.112.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE5B45F7C0; Wed, 5 Jun 2019 08:10:17 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, ybrustin@cisco.com, tiwei.bie@intel.com, jfreimann@redhat.com Cc: stable@dpdk.org, Maxime Coquelin Date: Wed, 5 Jun 2019 10:10:02 +0200 Message-Id: <20190605081005.15716-2-maxime.coquelin@redhat.com> In-Reply-To: <20190605081005.15716-1-maxime.coquelin@redhat.com> References: <20190605081005.15716-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 05 Jun 2019 08:10:20 +0000 (UTC) Subject: [dpdk-dev] [PATCH v2 1/4] net/virtio: fix segmented packet issue in in-order Rx path X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" After having dequeued a burst of descriptors, there may be a need to dequeue a few more if the last packet was segmented and not complete. When it happens, the extra segments were not properly attached to the mbuf chain, and so were lost. Also, head segment data_len field is wrongly summed with the length of all the segments of the chain. This patch fixes both the mbuf chaining and head segment's data_len field. Fixes: e5f456a98d3c ("net/virtio: support in-order Rx and Tx") Cc: stable@dpdk.org Reported-by: Yaroslav Brustinov Signed-off-by: Maxime Coquelin Reviewed-by: David Marchand --- drivers/net/virtio/virtio_rxtx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 1de28540cd..6b3baf0423 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -1424,7 +1424,7 @@ virtio_recv_pkts_inorder(void *rx_queue, struct virtqueue *vq = rxvq->vq; struct virtio_hw *hw = vq->hw; struct rte_mbuf *rxm; - struct rte_mbuf *prev; + struct rte_mbuf *prev = NULL; uint16_t nb_used, num, nb_rx; uint32_t len[VIRTIO_MBUF_BURST_SZ]; struct rte_mbuf *rcv_pkts[VIRTIO_MBUF_BURST_SZ]; @@ -1516,7 +1516,6 @@ virtio_recv_pkts_inorder(void *rx_queue, rxm->data_len = (uint16_t)(len[i]); rx_pkts[nb_rx]->pkt_len += (uint32_t)(len[i]); - rx_pkts[nb_rx]->data_len += (uint16_t)(len[i]); if (prev) prev->next = rxm; @@ -1536,7 +1535,6 @@ virtio_recv_pkts_inorder(void *rx_queue, uint16_t rcv_cnt = RTE_MIN((uint16_t)seg_res, VIRTIO_MBUF_BURST_SZ); - prev = rcv_pkts[nb_rx]; if (likely(VIRTQUEUE_NUSED(vq) >= rcv_cnt)) { virtio_rmb(hw->weak_barriers); num = virtqueue_dequeue_rx_inorder(vq, rcv_pkts, len, From patchwork Wed Jun 5 08:10:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 54380 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CE0891B9B5; Wed, 5 Jun 2019 10:10:27 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 46DFE1B99B; Wed, 5 Jun 2019 10:10:23 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0D887EBDC; Wed, 5 Jun 2019 08:10:22 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-53.ams2.redhat.com [10.36.112.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C7C860A35; Wed, 5 Jun 2019 08:10:20 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, ybrustin@cisco.com, tiwei.bie@intel.com, jfreimann@redhat.com Cc: stable@dpdk.org, Maxime Coquelin Date: Wed, 5 Jun 2019 10:10:03 +0200 Message-Id: <20190605081005.15716-3-maxime.coquelin@redhat.com> In-Reply-To: <20190605081005.15716-1-maxime.coquelin@redhat.com> References: <20190605081005.15716-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 05 Jun 2019 08:10:22 +0000 (UTC) Subject: [dpdk-dev] [PATCH v2 2/4] net/virtio: fix segmented packet issue in mergeable Rx path X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" After having dequeued a burst of descriptors, there may be a need to dequeue a few more if the last packet was segmented and not complete. When it happens, the extra segments were not properly attached to the mbuf chain, and so were lost. Also, head segment data_len field is wrongly summed with the length of all the segments of the chain. This patch fixes both the mbuf chaining and head segment's data_len field Fixes: bcac5aa207f8 ("net/virtio: improve batching in mergeable path") Cc: stable@dpdk.org Reported-by: Yaroslav Brustinov Signed-off-by: Maxime Coquelin Reviewed-by: David Marchand --- drivers/net/virtio/virtio_rxtx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 6b3baf0423..9469ecb743 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -1614,7 +1614,7 @@ virtio_recv_mergeable_pkts(void *rx_queue, struct virtqueue *vq = rxvq->vq; struct virtio_hw *hw = vq->hw; struct rte_mbuf *rxm; - struct rte_mbuf *prev; + struct rte_mbuf *prev = NULL; uint16_t nb_used, num, nb_rx = 0; uint32_t len[VIRTIO_MBUF_BURST_SZ]; struct rte_mbuf *rcv_pkts[VIRTIO_MBUF_BURST_SZ]; @@ -1721,7 +1721,6 @@ virtio_recv_mergeable_pkts(void *rx_queue, uint16_t rcv_cnt = RTE_MIN((uint16_t)seg_res, VIRTIO_MBUF_BURST_SZ); - prev = rcv_pkts[nb_rx]; if (likely(VIRTQUEUE_NUSED(vq) >= rcv_cnt)) { virtio_rmb(hw->weak_barriers); num = virtqueue_dequeue_burst_rx(vq, rcv_pkts, len, @@ -1738,7 +1737,6 @@ virtio_recv_mergeable_pkts(void *rx_queue, prev->next = rxm; prev = rxm; rx_pkts[nb_rx]->pkt_len += len[extra_idx]; - rx_pkts[nb_rx]->data_len += len[extra_idx]; extra_idx += 1; }; seg_res -= rcv_cnt; From patchwork Wed Jun 5 08:10:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 54381 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 720351B9BA; Wed, 5 Jun 2019 10:10:29 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 405C61B9A6; Wed, 5 Jun 2019 10:10:25 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA970B2DD3; Wed, 5 Jun 2019 08:10:24 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-53.ams2.redhat.com [10.36.112.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FC925F7C0; Wed, 5 Jun 2019 08:10:22 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, ybrustin@cisco.com, tiwei.bie@intel.com, jfreimann@redhat.com Cc: stable@dpdk.org, Maxime Coquelin Date: Wed, 5 Jun 2019 10:10:04 +0200 Message-Id: <20190605081005.15716-4-maxime.coquelin@redhat.com> In-Reply-To: <20190605081005.15716-1-maxime.coquelin@redhat.com> References: <20190605081005.15716-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 05 Jun 2019 08:10:24 +0000 (UTC) Subject: [dpdk-dev] [PATCH v2 3/4] net/virtio: fix segment data len in mergeable packed Rx path X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Head segment data_len field is wrongly summed with the length of all the segments of the chain, whereas it should be the length of of the first segment only. Fixes: a76290c8f1cf ("net/virtio: implement Rx path for packed queues") Cc: stable@dpdk.org Reported-by: Yaroslav Brustinov Signed-off-by: Maxime Coquelin Reviewed-by: David Marchand --- drivers/net/virtio/virtio_rxtx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 9469ecb743..33dbc78906 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -1914,7 +1914,6 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue, prev->next = rxm; prev = rxm; rx_pkts[nb_rx]->pkt_len += len[extra_idx]; - rx_pkts[nb_rx]->data_len += len[extra_idx]; extra_idx += 1; } seg_res -= rcv_cnt; From patchwork Wed Jun 5 08:10:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 54382 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4C1851B9C4; Wed, 5 Jun 2019 10:10:31 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 42A371B9B0; Wed, 5 Jun 2019 10:10:27 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ADFCE4DB10; Wed, 5 Jun 2019 08:10:26 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-53.ams2.redhat.com [10.36.112.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D7BE5F7C0; Wed, 5 Jun 2019 08:10:24 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, ybrustin@cisco.com, tiwei.bie@intel.com, jfreimann@redhat.com Cc: stable@dpdk.org, Maxime Coquelin Date: Wed, 5 Jun 2019 10:10:05 +0200 Message-Id: <20190605081005.15716-5-maxime.coquelin@redhat.com> In-Reply-To: <20190605081005.15716-1-maxime.coquelin@redhat.com> References: <20190605081005.15716-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 05 Jun 2019 08:10:26 +0000 (UTC) Subject: [dpdk-dev] [PATCH v2 4/4] net/virtio: remove useless pointers checks X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch removes uses checks on 'prev' pointer, as it is always set before with a valid value. Signed-off-by: Maxime Coquelin Reviewed-by: David Marchand --- drivers/net/virtio/virtio_rxtx.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 33dbc78906..fabd2e31d5 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -1517,9 +1517,7 @@ virtio_recv_pkts_inorder(void *rx_queue, rx_pkts[nb_rx]->pkt_len += (uint32_t)(len[i]); - if (prev) - prev->next = rxm; - + prev->next = rxm; prev = rxm; seg_res -= 1; } @@ -1703,9 +1701,7 @@ virtio_recv_mergeable_pkts(void *rx_queue, rx_pkts[nb_rx]->pkt_len += (uint32_t)(len[i]); rx_pkts[nb_rx]->data_len += (uint16_t)(len[i]); - if (prev) - prev->next = rxm; - + prev->next = rxm; prev = rxm; seg_res -= 1; } @@ -1879,9 +1875,7 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue, rx_pkts[nb_rx]->pkt_len += (uint32_t)(len[i]); rx_pkts[nb_rx]->data_len += (uint16_t)(len[i]); - if (prev) - prev->next = rxm; - + prev->next = rxm; prev = rxm; seg_res -= 1; } @@ -1924,8 +1918,7 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue, } else { PMD_RX_LOG(ERR, "No enough segments for packet."); - if (prev) - virtio_discard_rxbuf(vq, prev); + virtio_discard_rxbuf(vq, prev); rxvq->stats.errors++; break; }