Changeset 211b17a1 in mainline
- Timestamp:
- 2018-05-28T20:49:51Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0a087ae
- Parents:
- b085bbaa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/virtio-net/virtio-net.c
rb085bbaa r211b17a1 55 55 #define CT_BUF_SIZE BUFFER_SIZE 56 56 57 static ddf_dev_ops_t virtio_net_dev_ops; 58 59 static errno_t virtio_net_dev_add(ddf_dev_t *dev); 60 61 static driver_ops_t virtio_net_driver_ops = { 62 .dev_add = virtio_net_dev_add 63 }; 64 65 static driver_t virtio_net_driver = { 66 .name = NAME, 67 .driver_ops = &virtio_net_driver_ops 68 }; 57 69 58 70 static errno_t virtio_net_setup_bufs(unsigned int buffers, size_t size, … … 227 239 } 228 240 241 static void virtio_net_uninitialize(ddf_dev_t *dev) 242 { 243 nic_t *nic = ddf_dev_data_get(dev); 244 virtio_net_t *virtio_net = (virtio_net_t *) nic_get_specific(nic); 245 246 virtio_net_teardown_bufs(virtio_net->rx_buf); 247 virtio_net_teardown_bufs(virtio_net->tx_buf); 248 virtio_net_teardown_bufs(virtio_net->ct_buf); 249 250 virtio_device_setup_fail(&virtio_net->virtio_dev); 251 virtio_pci_dev_cleanup(&virtio_net->virtio_dev); 252 } 253 229 254 static errno_t virtio_net_dev_add(ddf_dev_t *dev) 230 255 { … … 236 261 return rc; 237 262 238 return ENOTSUP; 239 } 240 241 static ddf_dev_ops_t virtio_net_dev_ops; 242 243 static driver_ops_t virtio_net_driver_ops = { 244 .dev_add = virtio_net_dev_add 245 }; 246 247 static driver_t virtio_net_driver = { 248 .name = NAME, 249 .driver_ops = &virtio_net_driver_ops 250 }; 263 ddf_fun_t *fun = ddf_fun_create(dev, fun_exposed, "port0"); 264 if (fun == NULL) { 265 rc = ENOMEM; 266 goto error; 267 } 268 nic_t *nic = ddf_dev_data_get(dev); 269 nic_set_ddf_fun(nic, fun); 270 ddf_fun_set_ops(fun, &virtio_net_dev_ops); 271 272 rc = ddf_fun_bind(fun); 273 if (rc != EOK) { 274 ddf_msg(LVL_ERROR, "Failed binding device function"); 275 goto uninitialize; 276 } 277 278 rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC); 279 if (rc != EOK) { 280 ddf_msg(LVL_ERROR, "Failed adding function to category"); 281 goto unbind; 282 } 283 284 ddf_msg(LVL_NOTE, "The %s device has been successfully initialized.", 285 ddf_dev_get_name(dev)); 286 287 return EOK; 288 289 unbind: 290 ddf_fun_unbind(fun); 291 uninitialize: 292 virtio_net_uninitialize(dev); 293 error: 294 return rc; 295 } 251 296 252 297 static nic_iface_t virtio_net_nic_iface;
Note:
See TracChangeset
for help on using the changeset viewer.