Changeset 0180c67 in mainline
- Timestamp:
- 2018-05-22T19:06:50Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7bf16b7e
- Parents:
- eda41a9e
- git-author:
- Jakub Jermar <jakub@…> (2018-05-19 19:27:18)
- git-committer:
- Jakub Jermar <jakub@…> (2018-05-22 19:06:50)
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/virtio-net/virtio-net.c
reda41a9e r0180c67 99 99 } 100 100 101 rc = virtio_virtq_setup(vdev, RECVQ1, RECVQ_SIZE, 1500, 102 VIRTQ_DESC_F_WRITE); 101 rc = virtio_virtq_setup(vdev, RECVQ1, RECVQ_SIZE); 103 102 if (rc != EOK) 104 103 goto fail; 105 rc = virtio_virtq_setup(vdev, TRANSQ1, TRANSQ_SIZE , 1500, 0);104 rc = virtio_virtq_setup(vdev, TRANSQ1, TRANSQ_SIZE); 106 105 if (rc != EOK) 107 106 goto fail; 108 rc = virtio_virtq_setup(vdev, CTRLQ1, CTRLQ_SIZE , 512, 0);107 rc = virtio_virtq_setup(vdev, CTRLQ1, CTRLQ_SIZE); 109 108 if (rc != EOK) 110 109 goto fail; -
uspace/lib/virtio/virtio-pci.h
reda41a9e r0180c67 144 144 virtq_used_t *used; 145 145 146 /**147 * Queue-size-sized array of virtual addresses of the atcual DMA148 * buffers.149 */150 void **buffers;151 152 146 /** Address of the queue's notification register */ 153 147 ioport16_t *notify; … … 180 174 } virtio_dev_t; 181 175 182 extern errno_t virtio_virtq_setup(virtio_dev_t *, uint16_t, uint16_t, size_t, 183 uint16_t); 176 extern errno_t virtio_virtq_setup(virtio_dev_t *, uint16_t, uint16_t); 184 177 extern void virtio_virtq_teardown(virtio_dev_t *, uint16_t); 185 178 -
uspace/lib/virtio/virtio.c
reda41a9e r0180c67 38 38 #include <ddf/log.h> 39 39 40 errno_t virtio_virtq_setup(virtio_dev_t *vdev, uint16_t num, uint16_t size, 41 size_t buf_size, uint16_t buf_flags) 40 errno_t virtio_virtq_setup(virtio_dev_t *vdev, uint16_t num, uint16_t size) 42 41 { 43 42 virtq_t *q = &vdev->queues[num]; … … 52 51 ddf_msg(LVL_NOTE, "Virtq %u: %u buffers", num, (unsigned) size); 53 52 54 /* Allocate array to hold virtual addresses of DMA buffers */55 void **buffers = calloc(sizeof(void *), size);56 if (!buffers)57 return ENOMEM;58 59 53 size_t avail_offset = 0; 60 54 size_t used_offset = 0; 61 size_t buffers_offset = 0;62 55 63 56 /* … … 74 67 mem_size += sizeof(virtq_used_t) + sizeof(virtq_used_elem_t[size]) + 75 68 sizeof(ioport16_t); 76 buffers_offset = mem_size;77 mem_size += size * buf_size;78 69 79 70 /* 80 * Allocate DMA memory for the virtqueues and the buffers71 * Allocate DMA memory for the virtqueues 81 72 */ 82 73 q->virt = AS_AREA_ANY; … … 84 75 AS_AREA_READ | AS_AREA_WRITE, 0, &q->phys, &q->virt); 85 76 if (rc != EOK) { 86 free(buffers);87 77 q->virt = NULL; 88 78 return rc; … … 94 84 q->avail = q->virt + avail_offset; 95 85 q->used = q->virt + used_offset; 96 q->buffers = buffers;97 86 98 87 memset(q->virt, 0, q->size); 99 88 100 89 /* 101 * Initialize the descriptor table and the buffers array90 * Initialize the descriptor table 102 91 */ 103 92 for (unsigned i = 0; i < size; i++) { 104 q->desc[i].addr = q->phys + buffers_offset + i * buf_size; 105 q->desc[i].len = buf_size; 106 q->desc[i].flags = buf_flags; 107 108 q->buffers[i] = q->virt + buffers_offset + i * buf_size; 93 q->desc[i].addr = 0; 94 q->desc[i].len = 0; 95 q->desc[i].flags = 0; 109 96 } 110 97 … … 133 120 if (q->size) 134 121 dmamem_unmap_anonymous(q->virt); 135 if (q->buffers)136 free(q->buffers);137 122 } 138 123
Note:
See TracChangeset
for help on using the changeset viewer.