From patchwork Mon Jan 13 03:31:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jiang, Cheng1" X-Patchwork-Id: 64501 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 8BC55A04F0; Mon, 13 Jan 2020 04:36:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 170721D427; Mon, 13 Jan 2020 04:36:22 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id C20F91D426 for ; Mon, 13 Jan 2020 04:36:19 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jan 2020 19:36:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,427,1571727600"; d="scan'208";a="424181052" Received: from dpdk-jiangcheng.sh.intel.com ([10.67.119.194]) by fmsmga006.fm.intel.com with ESMTP; 12 Jan 2020 19:36:17 -0800 From: Cheng Jiang To: maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com, yong.liu@intel.com Cc: dev@dpdk.org, Cheng Jiang Date: Mon, 13 Jan 2020 03:31:33 +0000 Message-Id: <20200113033133.55731-1-Cheng1.jiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191223051543.41579-1-Cheng1.jiang@intel.com> References: <20191223051543.41579-1-Cheng1.jiang@intel.com> Subject: [dpdk-dev] [PATCH v4] net/virtio: packed ring notification data feature support 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 supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications, expanding the notifications to include the avail index and avail wrap counter. Signed-off-by: Cheng Jiang Reviewed-by: Maxime Coquelin --- v4: * Replaced used_wrap_counter with avail_wrap_counter. v3: * Modified the commit log to make it more detailed. * Modified the shift mode of notify_data to make it more intuitive. v2: * Removed rte_unused attribute in *hw. * Added some comments on notify_data. drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.c | 29 +++++++++++++++++++++++++++-- drivers/net/virtio/virtio_pci.h | 6 ++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h index a10111758..cd8947656 100644 --- a/drivers/net/virtio/virtio_ethdev.h +++ b/drivers/net/virtio/virtio_ethdev.h @@ -36,7 +36,8 @@ 1ULL << VIRTIO_F_IN_ORDER | \ 1ULL << VIRTIO_F_RING_PACKED | \ 1ULL << VIRTIO_F_IOMMU_PLATFORM | \ - 1ULL << VIRTIO_F_ORDER_PLATFORM) + 1ULL << VIRTIO_F_ORDER_PLATFORM | \ + 1ULL << VIRTIO_F_NOTIFICATION_DATA) #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \ (VIRTIO_PMD_DEFAULT_GUEST_FEATURES | \ diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 4468e89cb..29a354bf7 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -416,9 +416,34 @@ modern_del_queue(struct virtio_hw *hw, struct virtqueue *vq) } static void -modern_notify_queue(struct virtio_hw *hw __rte_unused, struct virtqueue *vq) +modern_notify_queue(struct virtio_hw *hw, struct virtqueue *vq) { - rte_write16(vq->vq_queue_index, vq->notify_addr); + uint32_t notify_data; + + if (!vtpci_with_feature(hw, VIRTIO_F_NOTIFICATION_DATA)) { + rte_write16(vq->vq_queue_index, vq->notify_addr); + return; + } + + if (vtpci_with_feature(hw, VIRTIO_F_RING_PACKED)) { + /* + * Bit[0:15]: vq queue index + * Bit[16:30]: avail index + * Bit[31]: avail wrap counter + */ + notify_data = ((uint32_t)(!!(vq->vq_packed.cached_flags & + VRING_PACKED_DESC_F_AVAIL)) << 31) | + ((uint32_t)vq->vq_avail_idx << 16) | + vq->vq_queue_index; + } else { + /* + * Bit[0:15]: vq queue index + * Bit[16:31]: avail index + */ + notify_data = ((uint32_t)vq->vq_avail_idx << 16) | + vq->vq_queue_index; + } + rte_write32(notify_data, vq->notify_addr); } const struct virtio_pci_ops modern_ops = { diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index a38cb45ad..7433d2f08 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -135,6 +135,12 @@ struct virtnet_ctl; */ #define VIRTIO_F_ORDER_PLATFORM 36 +/* + * This feature indicates that the driver passes extra data (besides + * identifying the virtqueue) in its device notifications. + */ +#define VIRTIO_F_NOTIFICATION_DATA 38 + /* The Guest publishes the used index for which it expects an interrupt * at the end of the avail ring. Host should ignore the avail->flags field. */ /* The Host publishes the avail index for which it expects a kick