Commit b240491b authored by Stefano Garzarella's avatar Stefano Garzarella Committed by Michael S. Tsirkin

vdpa_sim: set vringh notify callback

Instead of calling the vq callback directly, we can leverage the
vringh_notify() function, adding vdpasim_vq_notify() and setting it
in the vringh notify callback.
Suggested-by: default avatarJason Wang <jasowang@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20201215144256.155342-15-sgarzare@redhat.comSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent c124a95e
...@@ -131,6 +131,17 @@ static struct vdpasim *dev_to_sim(struct device *dev) ...@@ -131,6 +131,17 @@ static struct vdpasim *dev_to_sim(struct device *dev)
return vdpa_to_sim(vdpa); return vdpa_to_sim(vdpa);
} }
static void vdpasim_vq_notify(struct vringh *vring)
{
struct vdpasim_virtqueue *vq =
container_of(vring, struct vdpasim_virtqueue, vring);
if (!vq->cb)
return;
vq->cb(vq->private);
}
static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
{ {
struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx];
...@@ -142,6 +153,8 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) ...@@ -142,6 +153,8 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
(uintptr_t)vq->driver_addr, (uintptr_t)vq->driver_addr,
(struct vring_used *) (struct vring_used *)
(uintptr_t)vq->device_addr); (uintptr_t)vq->device_addr);
vq->vring.notify = vdpasim_vq_notify;
} }
static void vdpasim_vq_reset(struct vdpasim *vdpasim, static void vdpasim_vq_reset(struct vdpasim *vdpasim,
...@@ -155,6 +168,8 @@ static void vdpasim_vq_reset(struct vdpasim *vdpasim, ...@@ -155,6 +168,8 @@ static void vdpasim_vq_reset(struct vdpasim *vdpasim,
vq->private = NULL; vq->private = NULL;
vringh_init_iotlb(&vq->vring, vdpasim->dev_attr.supported_features, vringh_init_iotlb(&vq->vring, vdpasim->dev_attr.supported_features,
VDPASIM_QUEUE_MAX, false, NULL, NULL, NULL); VDPASIM_QUEUE_MAX, false, NULL, NULL, NULL);
vq->vring.notify = NULL;
} }
static void vdpasim_reset(struct vdpasim *vdpasim) static void vdpasim_reset(struct vdpasim *vdpasim)
...@@ -231,10 +246,10 @@ static void vdpasim_net_work(struct work_struct *work) ...@@ -231,10 +246,10 @@ static void vdpasim_net_work(struct work_struct *work)
smp_wmb(); smp_wmb();
local_bh_disable(); local_bh_disable();
if (txq->cb) if (vringh_need_notify_iotlb(&txq->vring) > 0)
txq->cb(txq->private); vringh_notify(&txq->vring);
if (rxq->cb) if (vringh_need_notify_iotlb(&rxq->vring) > 0)
rxq->cb(rxq->private); vringh_notify(&rxq->vring);
local_bh_enable(); local_bh_enable();
if (++pkts > 4) { if (++pkts > 4) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment