Changeset 0180c67 in mainline


Ignore:
Timestamp:
2018-05-22T19:06:50Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
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)
Message:

Separate buffers from virtqueues

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/virtio-net/virtio-net.c

    reda41a9e r0180c67  
    9999        }
    100100
    101         rc = virtio_virtq_setup(vdev, RECVQ1, RECVQ_SIZE, 1500,
    102             VIRTQ_DESC_F_WRITE);
     101        rc = virtio_virtq_setup(vdev, RECVQ1, RECVQ_SIZE);
    103102        if (rc != EOK)
    104103                goto fail;
    105         rc = virtio_virtq_setup(vdev, TRANSQ1, TRANSQ_SIZE, 1500, 0);
     104        rc = virtio_virtq_setup(vdev, TRANSQ1, TRANSQ_SIZE);
    106105        if (rc != EOK)
    107106                goto fail;
    108         rc = virtio_virtq_setup(vdev, CTRLQ1, CTRLQ_SIZE, 512, 0);
     107        rc = virtio_virtq_setup(vdev, CTRLQ1, CTRLQ_SIZE);
    109108        if (rc != EOK)
    110109                goto fail;
  • uspace/lib/virtio/virtio-pci.h

    reda41a9e r0180c67  
    144144        virtq_used_t *used;
    145145
    146         /**
    147          * Queue-size-sized array of virtual addresses of the atcual DMA
    148          * buffers.
    149          */
    150         void **buffers;
    151 
    152146        /** Address of the queue's notification register */
    153147        ioport16_t *notify;
     
    180174} virtio_dev_t;
    181175
    182 extern errno_t virtio_virtq_setup(virtio_dev_t *, uint16_t, uint16_t, size_t,
    183     uint16_t);
     176extern errno_t virtio_virtq_setup(virtio_dev_t *, uint16_t, uint16_t);
    184177extern void virtio_virtq_teardown(virtio_dev_t *, uint16_t);
    185178
  • uspace/lib/virtio/virtio.c

    reda41a9e r0180c67  
    3838#include <ddf/log.h>
    3939
    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)
     40errno_t virtio_virtq_setup(virtio_dev_t *vdev, uint16_t num, uint16_t size)
    4241{
    4342        virtq_t *q = &vdev->queues[num];
     
    5251        ddf_msg(LVL_NOTE, "Virtq %u: %u buffers", num, (unsigned) size);
    5352
    54         /* Allocate array to hold virtual addresses of DMA buffers */
    55         void **buffers = calloc(sizeof(void *), size);
    56         if (!buffers)
    57                 return ENOMEM;
    58 
    5953        size_t avail_offset = 0;
    6054        size_t used_offset = 0;
    61         size_t buffers_offset = 0;
    6255
    6356        /*
     
    7467        mem_size += sizeof(virtq_used_t) + sizeof(virtq_used_elem_t[size]) +
    7568            sizeof(ioport16_t);
    76         buffers_offset = mem_size;
    77         mem_size += size * buf_size;
    7869
    7970        /*
    80          * Allocate DMA memory for the virtqueues and the buffers
     71         * Allocate DMA memory for the virtqueues
    8172         */
    8273        q->virt = AS_AREA_ANY;
     
    8475            AS_AREA_READ | AS_AREA_WRITE, 0, &q->phys, &q->virt);
    8576        if (rc != EOK) {
    86                 free(buffers);
    8777                q->virt = NULL;
    8878                return rc;
     
    9484        q->avail = q->virt + avail_offset;
    9585        q->used = q->virt + used_offset;
    96         q->buffers = buffers;
    9786
    9887        memset(q->virt, 0, q->size);
    9988
    10089        /*
    101          * Initialize the descriptor table and the buffers array
     90         * Initialize the descriptor table
    10291         */
    10392        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;
    10996        }
    11097
     
    133120        if (q->size)
    134121                dmamem_unmap_anonymous(q->virt);
    135         if (q->buffers)
    136                 free(q->buffers);
    137122}
    138123
Note: See TracChangeset for help on using the changeset viewer.