Changeset cbcb34c in mainline for uspace/drv/nic/virtio-net/virtio-net.c
- Timestamp:
- 2018-05-22T19:06:50Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 341df5f
- Parents:
- 1c53d93
- git-author:
- Jakub Jermar <jakub@…> (2018-05-05 14:43:51)
- git-committer:
- Jakub Jermar <jakub@…> (2018-05-22 19:06:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/virtio-net/virtio-net.c
r1c53d93 rcbcb34c 43 43 #define NAME "virtio-net" 44 44 45 #define VIRTIO_NET_NUM_QUEUES 3 46 47 #define RECVQ1 0 48 #define TRANSQ1 1 49 #define CTRLQ1 2 50 51 #define RECVQ_SIZE 8 52 #define TRANSQ_SIZE 8 53 #define CTRLQ_SIZE 4 54 45 55 static errno_t virtio_net_initialize(ddf_dev_t *dev) 46 56 { … … 61 71 return rc; 62 72 73 virtio_dev_t *vdev = &virtio_net->virtio_dev; 63 74 virtio_pci_common_cfg_t *cfg = virtio_net->virtio_dev.common_cfg; 64 75 virtio_net_cfg_t *netcfg = virtio_net->virtio_dev.device_cfg; … … 86 97 87 98 ddf_msg(LVL_NOTE, "offered features %x", features); 88 features &= (1U << VIRTIO_NET_F_MAC) ;99 features &= (1U << VIRTIO_NET_F_MAC) | (1U << VIRTIO_NET_F_CTRL_VQ); 89 100 90 101 if (!features) { … … 96 107 pio_write_32(&cfg->driver_feature_select, VIRTIO_NET_F_SELECT_PAGE_0); 97 108 pio_write_32(&cfg->driver_feature, features); 109 110 ddf_msg(LVL_NOTE, "accepted features %x", features); 98 111 99 112 /* 5. Set FEATURES_OK */ … … 109 122 110 123 /* 7. Perform device-specific setup */ 124 125 /* 126 * Discover and configure the virtqueues 127 */ 128 uint16_t num_queues = pio_read_16(&cfg->num_queues); 129 if (num_queues != VIRTIO_NET_NUM_QUEUES) { 130 ddf_msg(LVL_NOTE, "Unsupported number of virtqueues: %u", 131 num_queues); 132 goto fail; 133 } 134 135 vdev->queues = calloc(sizeof(virtq_t), num_queues); 136 if (!vdev->queues) { 137 rc = ENOMEM; 138 goto fail; 139 } 140 141 rc = virtio_virtq_setup(vdev, RECVQ1, RECVQ_SIZE, 1500, 142 VIRTQ_DESC_F_WRITE); 143 if (rc != EOK) 144 goto fail; 145 rc = virtio_virtq_setup(vdev, TRANSQ1, TRANSQ_SIZE, 1500, 0); 146 if (rc != EOK) 147 goto fail; 148 rc = virtio_virtq_setup(vdev, CTRLQ1, CTRLQ_SIZE, 512, 0); 149 if (rc != EOK) 150 goto fail; 151 152 /* 153 * Read the MAC address 154 */ 111 155 nic_address_t nic_addr; 112 156 for (unsigned i = 0; i < 6; i++) 113 nic_addr.address[i] = netcfg->mac[i];157 nic_addr.address[i] = pio_read_8(&netcfg->mac[i]); 114 158 rc = nic_report_address(nic_data, &nic_addr); 115 159 if (rc != EOK)
Note:
See TracChangeset
for help on using the changeset viewer.