History

vdpa_sim: factor out buffer completion logic

Wrap up common buffer completion logic in to vdpasim_net_complete

Gautam Dawar committed 4 years ago

Commit ec103d91 parent 05b69761 file · +18 −15Browse files

Unified · Split

drivers/vdpa/vdpa_sim/vdpa_sim_net.c+18−15
@@ -31,6 +31,22 @@ · 30 unmodified lines
31 31
32#define VDPASIM_NET_VQ_NUM 232#define VDPASIM_NET_VQ_NUM 2
33 33
34static void vdpasim_net_complete(struct vdpasim_virtqueue *vq, size_t len)
35{
36 /* Make sure data is wrote before advancing index */
37 smp_wmb();
38
39 vringh_complete_iotlb(&vq->vring, vq->head, len);
40
41 /* Make sure used is visible before rasing the interrupt. */
42 smp_wmb();
43
44 local_bh_disable();
45 if (vringh_need_notify_iotlb(&vq->vring) > 0)
46 vringh_notify(&vq->vring);
47 local_bh_enable();
48}
49
34static void vdpasim_net_work(struct work_struct *work)50static void vdpasim_net_work(struct work_struct *work)
35{51{
36 struct vdpasim *vdpasim = container_of(work, struct vdpasim, work);52 struct vdpasim *vdpasim = container_of(work, struct vdpasim, work);
@@ -78,21 +94,8 @@ static void vdpasim_net_work(struct work_struct *work) · 41 unmodified lines
78 total_write += write;94 total_write += write;
79 }95 }
80 96
81 /* Make sure data is wrote before advancing index */97 vdpasim_net_complete(txq, 0);
82 smp_wmb();98 vdpasim_net_complete(rxq, total_write);
83
84 vringh_complete_iotlb(&txq->vring, txq->head, 0);
85 vringh_complete_iotlb(&rxq->vring, rxq->head, total_write);
86
87 /* Make sure used is visible before rasing the interrupt. */
88 smp_wmb();
89
90 local_bh_disable();
91 if (vringh_need_notify_iotlb(&txq->vring) > 0)
92 vringh_notify(&txq->vring);
93 if (vringh_need_notify_iotlb(&rxq->vring) > 0)
94 vringh_notify(&rxq->vring);
95 local_bh_enable();
96 99
97 if (++pkts > 4) {100 if (++pkts > 4) {
98 schedule_work(&vdpasim->work);101 schedule_work(&vdpasim->work);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t