Changeset 69927fa in mainline
- Timestamp:
- 2018-05-22T19:06:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 00192cde
- Parents:
- e07257e
- git-author:
- Jakub Jermar <jakub@…> (2018-04-09 16:40:20)
- git-committer:
- Jakub Jermar <jakub@…> (2018-05-22 19:06:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/virtio-net/virtio-net.c
re07257e r69927fa 28 28 29 29 #include <stdio.h> 30 #include <stdint.h> 30 31 31 32 #include <ddf/driver.h> 32 33 #include <ddf/log.h> 33 34 #include <ops/nic.h> 35 #include <pci_dev_iface.h> 34 36 35 37 #include <nic.h> … … 37 39 #define NAME "virtio-net" 38 40 41 #define VIRTIO_PCI_CAP_TYPE(c) ((c) + 3) 42 #define VIRTIO_PCI_CAP_BAR(c) ((c) + 4) 43 #define VIRTIO_PCI_CAP_OFFSET(c) ((c) + 8) 44 #define VIRTIO_PCI_CAP_LENGTH(c) ((c) + 12) 45 46 #define VIRTIO_PCI_CAP_COMMON_CFG 1 47 #define VIRTIO_PCI_CAP_NOTIFY_CFG 2 48 #define VIRTIO_PCI_CAP_ISR_CFG 3 49 #define VIRTIO_PCI_CAP_DEVICE_CFG 4 50 #define VIRTIO_PCI_CAP_PCI_CFG 5 51 39 52 static errno_t virtio_net_dev_add(ddf_dev_t *dev) 40 53 { 41 54 ddf_msg(LVL_NOTE, "%s %s (handle = %zu)", __func__, 42 55 ddf_dev_get_name(dev), ddf_dev_get_handle(dev)); 56 57 async_sess_t *pci_sess = ddf_dev_parent_sess_get(dev); 58 if (!pci_sess) 59 return ENOENT; 60 61 /* 62 * Find the VIRTIO PCI Capabilities 63 */ 64 errno_t rc; 65 uint8_t c; 66 uint8_t id; 67 for (rc = pci_config_space_cap_first(pci_sess, &c, &id); 68 (rc == EOK) && c; 69 rc = pci_config_space_cap_next(pci_sess, &c, &id)) { 70 if (id == PCI_CAP_VENDORSPECID) { 71 uint8_t type; 72 73 rc = pci_config_space_read_8(pci_sess, 74 VIRTIO_PCI_CAP_TYPE(c), &type); 75 if (rc != EOK) 76 return rc; 77 78 switch (type) { 79 case VIRTIO_PCI_CAP_COMMON_CFG: 80 break; 81 case VIRTIO_PCI_CAP_NOTIFY_CFG: 82 break; 83 case VIRTIO_PCI_CAP_ISR_CFG: 84 break; 85 case VIRTIO_PCI_CAP_DEVICE_CFG: 86 break; 87 case VIRTIO_PCI_CAP_PCI_CFG: 88 break; 89 default: 90 break; 91 } 92 } 93 } 94 if (rc != EOK) 95 return rc; 43 96 44 97 return ENOTSUP;
Note:
See TracChangeset
for help on using the changeset viewer.