X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fvirtio%2Fvirtqueue.h;h=ca9d8e6e3ca705e9bdda31047bf6d58ce8eb739c;hb=4b058fdd27ceac277aa715df6f6bb0f7b37b150b;hp=53aeac238ae8b3fb7006ca4a1dbbad790515cf04;hpb=cc827f83595643da3b716712c2117d63752276f3;p=dpdk.git diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h index 53aeac238a..ca9d8e6e3c 100644 --- a/drivers/net/virtio/virtqueue.h +++ b/drivers/net/virtio/virtqueue.h @@ -19,15 +19,40 @@ struct rte_mbuf; /* - * Per virtio_config.h in Linux. + * Per virtio_ring.h in Linux. * For virtio_pci on SMP, we don't need to order with respect to MMIO * accesses through relaxed memory I/O windows, so smp_mb() et al are * sufficient. * + * For using virtio to talk to real devices (eg. vDPA) we do need real + * barriers. */ -#define virtio_mb() rte_smp_mb() -#define virtio_rmb() rte_smp_rmb() -#define virtio_wmb() rte_smp_wmb() +static inline void +virtio_mb(uint8_t weak_barriers) +{ + if (weak_barriers) + rte_smp_mb(); + else + rte_mb(); +} + +static inline void +virtio_rmb(uint8_t weak_barriers) +{ + if (weak_barriers) + rte_smp_rmb(); + else + rte_cio_rmb(); +} + +static inline void +virtio_wmb(uint8_t weak_barriers) +{ + if (weak_barriers) + rte_smp_wmb(); + else + rte_cio_wmb(); +} #ifdef RTE_PMD_PACKET_PREFETCH #define rte_packet_prefetch(p) rte_prefetch1(p) @@ -267,7 +292,6 @@ desc_is_used(struct vring_packed_desc *desc, struct virtqueue *vq) return avail == used && used == vq->used_wrap_counter; } - static inline void vring_desc_init_packed(struct virtqueue *vq, int n) { @@ -323,9 +347,8 @@ virtqueue_enable_intr_packed(struct virtqueue *vq) { uint16_t *event_flags = &vq->ring_packed.driver_event->desc_event_flags; - if (vq->event_flags_shadow == RING_EVENT_FLAGS_DISABLE) { - virtio_wmb(); + virtio_wmb(vq->hw->weak_barriers); vq->event_flags_shadow = RING_EVENT_FLAGS_ENABLE; *event_flags = vq->event_flags_shadow; } @@ -391,7 +414,7 @@ void vq_ring_free_inorder(struct virtqueue *vq, uint16_t desc_idx, static inline void vq_update_avail_idx(struct virtqueue *vq) { - virtio_wmb(); + virtio_wmb(vq->hw->weak_barriers); vq->vq_ring.avail->idx = vq->vq_avail_idx; } @@ -419,7 +442,7 @@ virtqueue_kick_prepare(struct virtqueue *vq) * Ensure updated avail->idx is visible to vhost before reading * the used->flags. */ - virtio_mb(); + virtio_mb(vq->hw->weak_barriers); return !(vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY); } @@ -431,7 +454,7 @@ virtqueue_kick_prepare_packed(struct virtqueue *vq) /* * Ensure updated data is visible to vhost before reading the flags. */ - virtio_mb(); + virtio_mb(vq->hw->weak_barriers); flags = vq->ring_packed.device_event->desc_event_flags; return flags != RING_EVENT_FLAGS_DISABLE;