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 53258A0093 for ; Fri, 21 Oct 2022 10:16:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 46E2D42BB8; Fri, 21 Oct 2022 10:16:14 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 2C08A4281C for ; Fri, 21 Oct 2022 10:16:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666340171; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DeJNCDIsMRw8H9Mm2IrNPW9+aI472a2kZ3lXZZfr6Es=; b=cV/oyBP9yG6s/XTPLlRCP3ChBq25KwVeWJ4h6jv4Zr+Cp/T823zS8G9lEUWDSGo/ZEUL+k VbiwquHCGCQS8YivEoF//EjFW+j3WAMzxK09R7ves75BbIB/uqB/IhlR2GyYiaSxRrQLcE r7WYxLAAFl6wRfG/MaxHcrTODG4V+OI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-42-FEr-hzShP3uBV4s8aiJ5kA-1; Fri, 21 Oct 2022 04:16:07 -0400 X-MC-Unique: FEr-hzShP3uBV4s8aiJ5kA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 059F5101A5AD; Fri, 21 Oct 2022 08:16:07 +0000 (UTC) Received: from [10.39.208.30] (unknown [10.39.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 14A1E1121333; Fri, 21 Oct 2022 08:16:04 +0000 (UTC) Message-ID: <1240d2b7-d07d-9861-248e-d7d915f9f89a@redhat.com> Date: Fri, 21 Oct 2022 10:16:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH v2 1/2] vhost: fix descs count in async vhost packed ring To: Cheng Jiang , chenbo.xia@intel.com Cc: dev@dpdk.org, jiayu.hu@intel.com, xuan.ding@intel.com, wenwux.ma@intel.com, yuanx.wang@intel.com, yvonnex.yang@intel.com, xingguang.he@intel.com, stable@dpdk.org References: <20220822043126.19340-1-cheng1.jiang@intel.com> <20221011030803.16746-1-cheng1.jiang@intel.com> <20221011030803.16746-2-cheng1.jiang@intel.com> From: Maxime Coquelin In-Reply-To: <20221011030803.16746-2-cheng1.jiang@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 10/11/22 05:08, Cheng Jiang wrote: > When vhost receive packets from the front-end using packed virtqueue, it receives > might use multiple descriptors for one packet, so we need calculate and to calculate > record the descriptor number for each packet to update available > descriptor counter and used descriptor counter, and rollback when DMA > ring is full. > > Fixes: fe8477ebbd94 ("vhost: support async packed ring dequeue") > Cc: stable@dpdk.org > > Signed-off-by: Cheng Jiang > --- > lib/vhost/virtio_net.c | 24 +++++++++++++++--------- > 1 file changed, 15 insertions(+), 9 deletions(-) > > diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c > index 8f4d0f0502..457ac2e92a 100644 > --- a/lib/vhost/virtio_net.c > +++ b/lib/vhost/virtio_net.c > @@ -3548,14 +3548,15 @@ virtio_dev_tx_async_split_compliant(struct virtio_net *dev, > } > > static __rte_always_inline void > -vhost_async_shadow_dequeue_single_packed(struct vhost_virtqueue *vq, uint16_t buf_id) > +vhost_async_shadow_dequeue_single_packed(struct vhost_virtqueue *vq, > + uint16_t buf_id, uint16_t count) > { > struct vhost_async *async = vq->async; > uint16_t idx = async->buffer_idx_packed; > > async->buffers_packed[idx].id = buf_id; > async->buffers_packed[idx].len = 0; > - async->buffers_packed[idx].count = 1; > + async->buffers_packed[idx].count = count; > > async->buffer_idx_packed++; > if (async->buffer_idx_packed >= vq->size) > @@ -3576,6 +3577,8 @@ virtio_dev_tx_async_single_packed(struct virtio_net *dev, > uint16_t nr_vec = 0; > uint32_t buf_len; > struct buf_vector buf_vec[BUF_VECTOR_MAX]; > + struct vhost_async *async = vq->async; > + struct async_inflight_info *pkts_info = async->pkts_info; > static bool allocerr_warned; > > if (unlikely(fill_vec_buf_packed(dev, vq, vq->last_avail_idx, &desc_count, > @@ -3604,8 +3607,12 @@ virtio_dev_tx_async_single_packed(struct virtio_net *dev, > return -1; > } > > + pkts_info[slot_idx].descs = desc_count; > + > /* update async shadow packed ring */ > - vhost_async_shadow_dequeue_single_packed(vq, buf_id); > + vhost_async_shadow_dequeue_single_packed(vq, buf_id, desc_count); > + > + vq_inc_last_avail_packed(vq, desc_count); > > return err; > } > @@ -3644,9 +3651,6 @@ virtio_dev_tx_async_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, > } > > pkts_info[slot_idx].mbuf = pkt; > - > - vq_inc_last_avail_packed(vq, 1); > - > } > > n_xfer = vhost_async_dma_transfer(dev, vq, dma_id, vchan_id, async->pkts_idx, > @@ -3657,6 +3661,8 @@ virtio_dev_tx_async_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, > pkt_err = pkt_idx - n_xfer; > > if (unlikely(pkt_err)) { > + uint16_t descs_err = 0; > + > pkt_idx -= pkt_err; > > /** > @@ -3673,10 +3679,10 @@ virtio_dev_tx_async_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, > } > > /* recover available ring */ > - if (vq->last_avail_idx >= pkt_err) { > - vq->last_avail_idx -= pkt_err; > + if (vq->last_avail_idx >= descs_err) { > + vq->last_avail_idx -= descs_err; > } else { > - vq->last_avail_idx += vq->size - pkt_err; > + vq->last_avail_idx += vq->size - descs_err; > vq->avail_wrap_counter ^= 1; > } > } If only the commit message typos need to be fixed, maybe no need to send a new version. Reviewed-by: Maxime Coquelin Thanks, Maxime