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
3131
3232 #define VDPASIM_NET_VQ_NUM 2
3333
34+static 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+
3450 static void vdpasim_net_work(struct work_struct *work)
3551 {
3652 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
7894 total_write += write;
7995 }
8096
81− /* Make sure data is wrote before advancing index */
82− smp_wmb();
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();
97+ vdpasim_net_complete(txq, 0);
98+ vdpasim_net_complete(rxq, total_write);
9699
97100 if (++pkts > 4) {
98101 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