From patchwork Thu Oct 1 10:11:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 79412 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F261DA04B5; Thu, 1 Oct 2020 12:12:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 53FE01DAD7; Thu, 1 Oct 2020 12:12:11 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id 16F7C1DAD2 for ; Thu, 1 Oct 2020 12:12:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601547127; 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=tkCMYcJxPPdDdhRhddMOzRN3LznzZqdglScsrtstOD4=; b=i7y40KUOK2nHp+IDZ4JwyX4ln1lbVvy5Vnzbm5Xq3ND4euTRyZ0b9oYXVbLVtKyGQjG1Yg iE0zez8Oug3aX2OxPDyoQuy+Fou+pilI5pjCGyAf4wv1EpCXXBv/qqctYWWwmvwwHufh/a a7qSmXCTcGsjHBEHNSmBscVRjgCUwig= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-441-9Q8UZ4KgO1ecgLC6cJ7XdA-1; Thu, 01 Oct 2020 06:12:05 -0400 X-MC-Unique: 9Q8UZ4KgO1ecgLC6cJ7XdA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B0A6109106D; Thu, 1 Oct 2020 10:12:04 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0759E60DA0; Thu, 1 Oct 2020 10:12:02 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, yong.liu@intel.com Cc: Maxime Coquelin , stable@dpdk.org Date: Thu, 1 Oct 2020 12:11:54 +0200 Message-Id: <20201001101155.206237-2-maxime.coquelin@redhat.com> In-Reply-To: <20201001101155.206237-1-maxime.coquelin@redhat.com> References: <20201001101155.206237-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 1/2] vhost: fix Virtio-net header len with packed ring 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" In case packed ring layout has been negotiated, but neither Version 1 nor mergeable buffers, the Virtio-net header len is assigned to the legacy devices value, which is wrong. This patch fixes this with using the proper len as devices using packed ring are not legacy devices. Fixes: a922401f35cc ("vhost: add Rx support for packed ring") Fixes: ae999ce49dcb ("vhost: add Tx support for packed ring") Cc: stable@dpdk.org Reported-by: Marvin Liu Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- lib/librte_vhost/vhost_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 4deceb3e00..5d1fb9e863 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -341,7 +341,9 @@ vhost_user_set_features(struct virtio_net **pdev, struct VhostUserMsg *msg, dev->features = features; if (dev->features & - ((1 << VIRTIO_NET_F_MRG_RXBUF) | (1ULL << VIRTIO_F_VERSION_1))) { + ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | + (1ULL << VIRTIO_F_VERSION_1) | + (1ULL << VIRTIO_F_RING_PACKED))) { dev->vhost_hlen = sizeof(struct virtio_net_hdr_mrg_rxbuf); } else { dev->vhost_hlen = sizeof(struct virtio_net_hdr); From patchwork Thu Oct 1 10:11:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 79413 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 045F8A04B5; Thu, 1 Oct 2020 12:12:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 097B11DAE6; Thu, 1 Oct 2020 12:12:13 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id 9314E1DADD for ; Thu, 1 Oct 2020 12:12:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601547129; 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=XRekJUAncc/jaGPaAsHfVHLu99I2xrzrjFjeu+7d5hw=; b=Mqxt7KMIii/Wwgqr7ejNkF2wfx6EOMs8ddQEWyXl7xL29qwiJoDXT/jHru6weOiyfEMZIS pVq0349RZqPlHL/wlC/bYyJ+g/x4JaRoeYTVHCGQZ/4iJewdQhRiHU6htWnxjBGbHT7Xpc 8VKO6DUvz6WexbfjbKSzTjJkNvtT54E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-379-61s3xOYpMCO6cDRO0nqYiQ-1; Thu, 01 Oct 2020 06:12:07 -0400 X-MC-Unique: 61s3xOYpMCO6cDRO0nqYiQ-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4CB1885C707; Thu, 1 Oct 2020 10:12:06 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.110.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 183F860DA0; Thu, 1 Oct 2020 10:12:04 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, yong.liu@intel.com Cc: Maxime Coquelin Date: Thu, 1 Oct 2020 12:11:55 +0200 Message-Id: <20201001101155.206237-3-maxime.coquelin@redhat.com> In-Reply-To: <20201001101155.206237-1-maxime.coquelin@redhat.com> References: <20201001101155.206237-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 2/2] vhost: use fixed Virtio-net header len packed ring 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 small optimization uses static the Virtio-net header len in packed datapath, since Virtio-net header cannot be the legacy one in case of packed ring. Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- lib/librte_vhost/virtio_net.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 0a0bea1a5a..5865fa5f65 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -1147,7 +1147,7 @@ vhost_enqueue_single_packed(struct virtio_net *dev, uint16_t buf_id = 0; uint32_t len = 0; uint16_t desc_count; - uint32_t size = pkt->pkt_len + dev->vhost_hlen; + uint32_t size = pkt->pkt_len + sizeof(struct virtio_net_hdr_mrg_rxbuf); uint16_t num_buffers = 0; uint32_t buffer_len[vq->size]; uint16_t buffer_buf_id[vq->size]; @@ -1262,7 +1262,7 @@ virtio_dev_rx_batch_packed(struct virtio_net *dev, uint16_t avail_idx = vq->last_avail_idx; uint64_t desc_addrs[PACKED_BATCH_SIZE]; struct virtio_net_hdr_mrg_rxbuf *hdrs[PACKED_BATCH_SIZE]; - uint32_t buf_offset = dev->vhost_hlen; + uint32_t buf_offset = sizeof(struct virtio_net_hdr_mrg_rxbuf); uint64_t lens[PACKED_BATCH_SIZE]; uint16_t ids[PACKED_BATCH_SIZE]; uint16_t i; @@ -1308,7 +1308,8 @@ virtio_dev_rx_batch_packed(struct virtio_net *dev, rte_prefetch0((void *)(uintptr_t)desc_addrs[i]); hdrs[i] = (struct virtio_net_hdr_mrg_rxbuf *) (uintptr_t)desc_addrs[i]; - lens[i] = pkts[i]->pkt_len + dev->vhost_hlen; + lens[i] = pkts[i]->pkt_len + + sizeof(struct virtio_net_hdr_mrg_rxbuf); } vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) @@ -2277,7 +2278,7 @@ vhost_reserve_avail_batch_packed(struct virtio_net *dev, struct virtio_net_hdr *hdr; uint64_t lens[PACKED_BATCH_SIZE]; uint64_t buf_lens[PACKED_BATCH_SIZE]; - uint32_t buf_offset = dev->vhost_hlen; + uint32_t buf_offset = sizeof(struct virtio_net_hdr_mrg_rxbuf); uint16_t flags, i; if (unlikely(avail_idx & PACKED_BATCH_MASK)) @@ -2354,7 +2355,7 @@ virtio_dev_tx_batch_packed(struct virtio_net *dev, struct rte_mbuf **pkts) { uint16_t avail_idx = vq->last_avail_idx; - uint32_t buf_offset = dev->vhost_hlen; + uint32_t buf_offset = sizeof(struct virtio_net_hdr_mrg_rxbuf); uintptr_t desc_addrs[PACKED_BATCH_SIZE]; uint16_t ids[PACKED_BATCH_SIZE]; uint16_t i;