Changeset 417aaafb in mainline
- Timestamp:
- 2018-06-25T21:37:48Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e3107e2
- Parents:
- ea6840d
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/virtio-net/virtio-net.c
rea6840d r417aaafb 155 155 uint16_t *head) 156 156 { 157 virtq_t *q = &vdev->queues[num]; 158 fibril_mutex_lock(&q->lock); 157 159 uint16_t descno = *head; 158 160 if (descno != (uint16_t) -1U) 159 161 *head = virtio_virtq_desc_get_next(vdev, num, descno); 162 fibril_mutex_unlock(&q->lock); 160 163 return descno; 161 164 } … … 171 174 uint16_t *head, uint16_t descno) 172 175 { 176 virtq_t *q = &vdev->queues[num]; 177 fibril_mutex_lock(&q->lock); 173 178 virtio_virtq_desc_set(vdev, num, descno, 0, 0, VIRTQ_DESC_F_NEXT, 174 179 *head); 175 180 *head = descno; 181 fibril_mutex_unlock(&q->lock); 176 182 } 177 183 -
uspace/lib/virtio/virtio-pci.h
rea6840d r417aaafb 36 36 #include <pci_dev_iface.h> 37 37 #include <ddi.h> 38 #include <fibril_synch.h> 38 39 39 40 #define VIRTIO_PCI_CAP_CAP_LEN(c) ((c) + 2) … … 131 132 size_t size; 132 133 134 /** Mutex protecting access to this virtqueue */ 135 fibril_mutex_t lock; 136 133 137 /** 134 138 * Size of the queue which determines the number of descriptors and -
uspace/lib/virtio/virtio.c
rea6840d r417aaafb 63 63 virtq_t *q = &vdev->queues[num]; 64 64 65 fibril_mutex_lock(&q->lock); 65 66 uint16_t idx = pio_read_le16(&q->avail->idx); 66 67 pio_write_le16(&q->avail->ring[idx % q->queue_size], descno); … … 69 70 write_barrier(); 70 71 pio_write_le16(q->notify, num); 72 fibril_mutex_unlock(&q->lock); 71 73 } 72 74 … … 76 78 virtq_t *q = &vdev->queues[num]; 77 79 80 fibril_mutex_lock(&q->lock); 78 81 uint16_t last_idx = q->used_last_idx % q->queue_size; 79 if (last_idx == (pio_read_le16(&q->used->idx) % q->queue_size)) 82 if (last_idx == (pio_read_le16(&q->used->idx) % q->queue_size)) { 83 fibril_mutex_unlock(&q->lock); 80 84 return false; 85 } 81 86 82 87 *descno = (uint16_t) pio_read_le32(&q->used->ring[last_idx].id); … … 84 89 85 90 q->used_last_idx++; 91 fibril_mutex_unlock(&q->lock); 86 92 87 93 return true; … … 132 138 } 133 139 140 fibril_mutex_initialize(&q->lock); 141 134 142 q->size = mem_size; 135 143 q->queue_size = size;
Note:
See TracChangeset
for help on using the changeset viewer.