[v4] net/virtio: packed ring notification data feature support
Checks
Commit Message
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 <Cheng1.jiang@intel.com>
---
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(-)
Comments
On 1/13/20 4:31 AM, Cheng Jiang wrote:
> 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 <Cheng1.jiang@intel.com>
> ---
>
> 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(-)
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
On 1/13/20 4:31 AM, Cheng Jiang wrote:
> 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 <Cheng1.jiang@intel.com>
> ---
>
> 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(-)
Applied to dpdk-next-virtio/master
Thanks,
Maxime
@@ -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 | \
@@ -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 = {
@@ -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