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 DA1A3A0C4D; Fri, 20 Aug 2021 14:48:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A67B74126D; Fri, 20 Aug 2021 14:48:00 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 7788941259; Fri, 20 Aug 2021 14:47:59 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 41D407F6D1; Fri, 20 Aug 2021 15:47:59 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 26B607F4FD; Fri, 20 Aug 2021 15:47:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 26B607F4FD Authentication-Results: shelob.oktetlabs.ru/26B607F4FD; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Maxime Coquelin , Chenbo Xia , Jianfeng Tan , Huawei Xie Cc: dev@dpdk.org, Ivan Ilchenko , stable@dpdk.org Date: Fri, 20 Aug 2021 15:47:52 +0300 Message-Id: <20210820124752.3522683-1-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] net/virtio: turn SW RxQ size to that of split vec. virtqueue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Ivan Ilchenko Descriptors number may be set less than queue size for split queue vectorized Rx path. Pointers to mbufs for received packets are obtained from SW ring, that is initially filled with them in the end of queue setup in virtio_dev_rx_queue_setup_finish(). The begin of the SW ring filled up to the size of descriptors number. At queue size offset from the begin of the SW ring pointers to some fake mbuf are also set for wrapping purpose. So the ring may contains the hole of invalid pointers from descriptors number offset to queue size offset, and split vectorized Rx routines could write to the invalid addresses since they use the ring up to the queue size. Fix this by setting descriptors number to queue size on Rx queue setup. Fixes: fc3d66212fed ("virtio: add vector Rx") Cc: stable@dpdk.org Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko --- drivers/net/virtio/virtio_rxtx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 18f03c9fc9..97ed69596a 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -706,8 +706,14 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, } vq->vq_free_thresh = rx_free_thresh; - if (nb_desc > vq->vq_nentries) + /* + * For split ring vectorized path descriptors number must be + * equal to the ring size. + */ + if (nb_desc > vq->vq_nentries || + (!virtio_with_packed_queue(hw) && hw->use_vec_rx)) { nb_desc = vq->vq_nentries; + } vq->vq_free_cnt = RTE_MIN(vq->vq_free_cnt, nb_desc); rxvq = &vq->rxq; -- 2.30.2