From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0E6ACA0C47 for ; Mon, 26 Jul 2021 15:54:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 05A99410F1; Mon, 26 Jul 2021 15:54:41 +0200 (CEST) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mails.dpdk.org (Postfix) with ESMTP id 9F196410F0 for ; Mon, 26 Jul 2021 15:54:38 +0200 (CEST) Received: by mail-wr1-f41.google.com with SMTP id g15so11220798wrd.3 for ; Mon, 26 Jul 2021 06:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lfGNVRlUIgaoJfSO1bMU20pBV3qP1q0BgJFSMcaXRpU=; b=rG9Xb1uX/ck8gdQb2v27cnllg+7kmtHm9R/Kogsu63EnrtpGuClvW/LjmNTvVRMVvc 5A61nn0HkNiECoiX1CF9jIJPDkJrHdNNfk0cwWbawBnJ16jwxdsozrTxl9U7wei47T+A gkC8ve0m93olp69aIhsak6ano/nbqjkE+RqvmZEvQbgml36rwgqaCl2UF35bTA2vRW1K mC+O4zNqP9AEPbX1yJErNLz2StP9T+pE/HZv4EvlkKggdOGyLcOYbVvQYlpDG1zoM2tu CCFejjsWX4nU1nr2KV1fmdXy3w+SoNl5II6AoJRQOL2OQ+JW8x85qUt6SusgwerbcH+O tyzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lfGNVRlUIgaoJfSO1bMU20pBV3qP1q0BgJFSMcaXRpU=; b=jR4K49howvzqagRJaTckfrk31pJQclv5cP42rl+kAnBFJSyZopYMzKjD4lVUj9LHAu wsXe/6E9akL2iJCYJlwMkd61w3uAJE7I4w2nUC3Cm2BjLGBQA94itcSy6uRUEkVHawFh kfsU69LtpH3z+ayxk1uF96jm0KTzvsPKcDG5vkYTvw1h3ow8xbnKvNSvgBXzxnMLzSD1 /PrvIWv0RpKvnhEXkfe6QVI9LCb8GZHgy8mITvlQgB4tpfMgwPCKDRGmWwNXTVn/tPSz dOsGfbcO5q7eC786QCMbA/cKtFT7OghueiGW8A4mFcSsNIHL+ewBgL5YR2EWvpZF128l gBww== X-Gm-Message-State: AOAM532qIzS9ilXBGvG7MB4LBg/YTbsh0Q8Zp7IhWuu4EHHXfoQO5xug 3/tuQ4Pa+jufFRwiJ0XXpDI= X-Google-Smtp-Source: ABdhPJy3l753JF1m+pQ1CE3OFS2gvcKyJcP5DE2tkNUfc6x6JMsKG2nfoV6NZTX97noG7z2vmej3NA== X-Received: by 2002:adf:d219:: with SMTP id j25mr6004948wrh.82.1627307678449; Mon, 26 Jul 2021 06:54:38 -0700 (PDT) Received: from localhost ([137.220.125.106]) by smtp.gmail.com with ESMTPSA id w1sm6188562wmc.19.2021.07.26.06.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 06:54:38 -0700 (PDT) From: luca.boccassi@gmail.com To: Cheng Jiang Cc: Marvin Liu , Maxime Coquelin , dpdk stable Date: Mon, 26 Jul 2021 14:52:46 +0100 Message-Id: <20210726135322.149850-23-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210726135322.149850-1-luca.boccassi@gmail.com> References: <20210712130551.2462159-1-luca.boccassi@gmail.com> <20210726135322.149850-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/virtio: fix refill order in packed ring datapath' has been queued to stable release 20.11.3 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 stable release 20.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/28/21. 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. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/12e277dee62c9ecf129351cfe3d4393297abe6cb Thanks. Luca Boccassi --- >From 12e277dee62c9ecf129351cfe3d4393297abe6cb Mon Sep 17 00:00:00 2001 From: Cheng Jiang Date: Thu, 8 Jul 2021 09:58:01 +0000 Subject: [PATCH] net/virtio: fix refill order in packed ring datapath [ upstream commit 2d91b28730a945def257bc372a525c9b5dbf181c ] The front-end should refill the descriptor with the mbuf indicated by the buff_id rather then the index of used descriptor. Back-end may return buffers out of order if async copy mode is enabled. When initializing rxq, refill the descriptors in order as buff_id is not available at that time. Fixes: a76290c8f1cf ("net/virtio: implement Rx path for packed queues") Signed-off-by: Cheng Jiang Signed-off-by: Marvin Liu Reviewed-by: Maxime Coquelin --- drivers/net/virtio/virtio_rxtx.c | 72 +++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 77934e8c58..393d4e9f84 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -333,13 +333,35 @@ virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf **cookie, return 0; } -static inline int -virtqueue_enqueue_recv_refill_packed(struct virtqueue *vq, - struct rte_mbuf **cookie, uint16_t num) +static inline void +virtqueue_refill_single_packed(struct virtqueue *vq, + struct vring_packed_desc *dp, + struct rte_mbuf *cookie) { - struct vring_packed_desc *start_dp = vq->vq_packed.ring.desc; uint16_t flags = vq->vq_packed.cached_flags; struct virtio_hw *hw = vq->hw; + + dp->addr = cookie->buf_iova + + RTE_PKTMBUF_HEADROOM - hw->vtnet_hdr_size; + dp->len = cookie->buf_len - + RTE_PKTMBUF_HEADROOM + hw->vtnet_hdr_size; + + virtqueue_store_flags_packed(dp, flags, + hw->weak_barriers); + + if (++vq->vq_avail_idx >= vq->vq_nentries) { + vq->vq_avail_idx -= vq->vq_nentries; + vq->vq_packed.cached_flags ^= + VRING_PACKED_DESC_F_AVAIL_USED; + flags = vq->vq_packed.cached_flags; + } +} + +static inline int +virtqueue_enqueue_recv_refill_packed_init(struct virtqueue *vq, + struct rte_mbuf **cookie, uint16_t num) +{ + struct vring_packed_desc *start_dp = vq->vq_packed.ring.desc; struct vq_desc_extra *dxp; uint16_t idx; int i; @@ -355,24 +377,34 @@ virtqueue_enqueue_recv_refill_packed(struct virtqueue *vq, dxp->cookie = (void *)cookie[i]; dxp->ndescs = 1; - start_dp[idx].addr = VIRTIO_MBUF_ADDR(cookie[i], vq) + - RTE_PKTMBUF_HEADROOM - hw->vtnet_hdr_size; - start_dp[idx].len = cookie[i]->buf_len - RTE_PKTMBUF_HEADROOM - + hw->vtnet_hdr_size; + virtqueue_refill_single_packed(vq, &start_dp[idx], cookie[i]); + } + vq->vq_free_cnt = (uint16_t)(vq->vq_free_cnt - num); + return 0; +} - vq->vq_desc_head_idx = dxp->next; - if (vq->vq_desc_head_idx == VQ_RING_DESC_CHAIN_END) - vq->vq_desc_tail_idx = vq->vq_desc_head_idx; +static inline int +virtqueue_enqueue_recv_refill_packed(struct virtqueue *vq, + struct rte_mbuf **cookie, uint16_t num) +{ + struct vring_packed_desc *start_dp = vq->vq_packed.ring.desc; + struct vq_desc_extra *dxp; + uint16_t idx, did; + int i; - virtqueue_store_flags_packed(&start_dp[idx], flags, - hw->weak_barriers); + if (unlikely(vq->vq_free_cnt == 0)) + return -ENOSPC; + if (unlikely(vq->vq_free_cnt < num)) + return -EMSGSIZE; - if (++vq->vq_avail_idx >= vq->vq_nentries) { - vq->vq_avail_idx -= vq->vq_nentries; - vq->vq_packed.cached_flags ^= - VRING_PACKED_DESC_F_AVAIL_USED; - flags = vq->vq_packed.cached_flags; - } + for (i = 0; i < num; i++) { + idx = vq->vq_avail_idx; + did = start_dp[idx].id; + dxp = &vq->vq_descx[did]; + dxp->cookie = (void *)cookie[i]; + dxp->ndescs = 1; + + virtqueue_refill_single_packed(vq, &start_dp[idx], cookie[i]); } vq->vq_free_cnt = (uint16_t)(vq->vq_free_cnt - num); return 0; @@ -748,7 +780,7 @@ virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev, uint16_t queue_idx) /* Enqueue allocated buffers */ if (vtpci_packed_queue(vq->hw)) - error = virtqueue_enqueue_recv_refill_packed(vq, + error = virtqueue_enqueue_recv_refill_packed_init(vq, &m, 1); else error = virtqueue_enqueue_recv_refill(vq, -- 2.30.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-07-26 13:53:17.050079266 +0100 +++ 0023-net-virtio-fix-refill-order-in-packed-ring-datapath.patch 2021-07-26 13:53:15.841292454 +0100 @@ -1 +1 @@ -From 2d91b28730a945def257bc372a525c9b5dbf181c Mon Sep 17 00:00:00 2001 +From 12e277dee62c9ecf129351cfe3d4393297abe6cb Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 2d91b28730a945def257bc372a525c9b5dbf181c ] + @@ -14 +15,0 @@ -Cc: stable@dpdk.org @@ -24 +25 @@ -index 34108fb946..f70644b0b7 100644 +index 77934e8c58..393d4e9f84 100644 @@ -27 +28 @@ -@@ -328,13 +328,35 @@ virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf **cookie, +@@ -333,13 +333,35 @@ virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf **cookie, @@ -67 +68 @@ -@@ -350,24 +372,34 @@ virtqueue_enqueue_recv_refill_packed(struct virtqueue *vq, +@@ -355,24 +377,34 @@ virtqueue_enqueue_recv_refill_packed(struct virtqueue *vq, @@ -71,4 +72,4 @@ -- start_dp[idx].addr = cookie[i]->buf_iova + -- RTE_PKTMBUF_HEADROOM - hw->vtnet_hdr_size; -- start_dp[idx].len = cookie[i]->buf_len - -- RTE_PKTMBUF_HEADROOM + hw->vtnet_hdr_size; +- start_dp[idx].addr = VIRTIO_MBUF_ADDR(cookie[i], vq) + +- RTE_PKTMBUF_HEADROOM - hw->vtnet_hdr_size; +- start_dp[idx].len = cookie[i]->buf_len - RTE_PKTMBUF_HEADROOM +- + hw->vtnet_hdr_size; @@ -117 +118 @@ -@@ -740,7 +772,7 @@ virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev, uint16_t queue_idx) +@@ -748,7 +780,7 @@ virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev, uint16_t queue_idx) @@ -120 +121 @@ - if (virtio_with_packed_queue(vq->hw)) + if (vtpci_packed_queue(vq->hw))