net/virtio: support packed ring notification data
[dpdk.git] / drivers / net / virtio / virtio_pci.c
index 4468e89..29a354b 100644 (file)
@@ -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 = {