mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 06:43:09 +00:00
vdpa_sim: factor out buffer completion logic
Wrap up common buffer completion logic in to vdpasim_net_complete Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Gautam Dawar <gdawar@xilinx.com> Message-Id: <20220330180436.24644-18-gdawar@xilinx.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
05b6976212
commit
ec103d983b
@ -31,6 +31,22 @@
|
|||||||
|
|
||||||
#define VDPASIM_NET_VQ_NUM 2
|
#define VDPASIM_NET_VQ_NUM 2
|
||||||
|
|
||||||
|
static void vdpasim_net_complete(struct vdpasim_virtqueue *vq, size_t len)
|
||||||
|
{
|
||||||
|
/* Make sure data is wrote before advancing index */
|
||||||
|
smp_wmb();
|
||||||
|
|
||||||
|
vringh_complete_iotlb(&vq->vring, vq->head, len);
|
||||||
|
|
||||||
|
/* Make sure used is visible before rasing the interrupt. */
|
||||||
|
smp_wmb();
|
||||||
|
|
||||||
|
local_bh_disable();
|
||||||
|
if (vringh_need_notify_iotlb(&vq->vring) > 0)
|
||||||
|
vringh_notify(&vq->vring);
|
||||||
|
local_bh_enable();
|
||||||
|
}
|
||||||
|
|
||||||
static void vdpasim_net_work(struct work_struct *work)
|
static void vdpasim_net_work(struct work_struct *work)
|
||||||
{
|
{
|
||||||
struct vdpasim *vdpasim = container_of(work, struct vdpasim, work);
|
struct vdpasim *vdpasim = container_of(work, struct vdpasim, work);
|
||||||
@ -78,21 +94,8 @@ static void vdpasim_net_work(struct work_struct *work)
|
|||||||
total_write += write;
|
total_write += write;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure data is wrote before advancing index */
|
vdpasim_net_complete(txq, 0);
|
||||||
smp_wmb();
|
vdpasim_net_complete(rxq, total_write);
|
||||||
|
|
||||||
vringh_complete_iotlb(&txq->vring, txq->head, 0);
|
|
||||||
vringh_complete_iotlb(&rxq->vring, rxq->head, total_write);
|
|
||||||
|
|
||||||
/* Make sure used is visible before rasing the interrupt. */
|
|
||||||
smp_wmb();
|
|
||||||
|
|
||||||
local_bh_disable();
|
|
||||||
if (vringh_need_notify_iotlb(&txq->vring) > 0)
|
|
||||||
vringh_notify(&txq->vring);
|
|
||||||
if (vringh_need_notify_iotlb(&rxq->vring) > 0)
|
|
||||||
vringh_notify(&rxq->vring);
|
|
||||||
local_bh_enable();
|
|
||||||
|
|
||||||
if (++pkts > 4) {
|
if (++pkts > 4) {
|
||||||
schedule_work(&vdpasim->work);
|
schedule_work(&vdpasim->work);
|
||||||
|
Loading…
Reference in New Issue
Block a user