Changes in uspace/drv/nic/e1k/e1k.c [b7fd2a0:f300523] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/e1k/e1k.c
rb7fd2a0 rf300523 179 179 FIBRIL_MUTEX_INITIALIZE(irq_reg_mutex); 180 180 181 static errno_t e1000_get_address(e1000_t *, nic_address_t *);181 static int e1000_get_address(e1000_t *, nic_address_t *); 182 182 static void e1000_eeprom_get_address(e1000_t *, nic_address_t *); 183 static errno_t e1000_set_addr(ddf_fun_t *, const nic_address_t *);184 185 static errno_t e1000_defective_get_mode(ddf_fun_t *, uint32_t *);186 static errno_t e1000_defective_set_mode(ddf_fun_t *, uint32_t);187 188 static errno_t e1000_get_cable_state(ddf_fun_t *, nic_cable_state_t *);189 static errno_t e1000_get_device_info(ddf_fun_t *, nic_device_info_t *);190 static errno_t e1000_get_operation_mode(ddf_fun_t *, int *,183 static int e1000_set_addr(ddf_fun_t *, const nic_address_t *); 184 185 static int e1000_defective_get_mode(ddf_fun_t *, uint32_t *); 186 static int e1000_defective_set_mode(ddf_fun_t *, uint32_t); 187 188 static int e1000_get_cable_state(ddf_fun_t *, nic_cable_state_t *); 189 static int e1000_get_device_info(ddf_fun_t *, nic_device_info_t *); 190 static int e1000_get_operation_mode(ddf_fun_t *, int *, 191 191 nic_channel_mode_t *, nic_role_t *); 192 static errno_t e1000_set_operation_mode(ddf_fun_t *, int,192 static int e1000_set_operation_mode(ddf_fun_t *, int, 193 193 nic_channel_mode_t, nic_role_t); 194 static errno_t e1000_autoneg_enable(ddf_fun_t *, uint32_t);195 static errno_t e1000_autoneg_disable(ddf_fun_t *);196 static errno_t e1000_autoneg_restart(ddf_fun_t *);197 198 static errno_t e1000_vlan_set_tag(ddf_fun_t *, uint16_t, bool, bool);194 static int e1000_autoneg_enable(ddf_fun_t *, uint32_t); 195 static int e1000_autoneg_disable(ddf_fun_t *); 196 static int e1000_autoneg_restart(ddf_fun_t *); 197 198 static int e1000_vlan_set_tag(ddf_fun_t *, uint16_t, bool, bool); 199 199 200 200 /** Network interface options for E1000 card driver */ … … 219 219 static ddf_dev_ops_t e1000_dev_ops; 220 220 221 static errno_t e1000_dev_add(ddf_dev_t *);221 static int e1000_dev_add(ddf_dev_t *); 222 222 223 223 /** Basic driver operations for E1000 driver */ … … 233 233 234 234 /* The default implementation callbacks */ 235 static errno_t e1000_on_activating(nic_t *);236 static errno_t e1000_on_stopping(nic_t *);235 static int e1000_on_activating(nic_t *); 236 static int e1000_on_stopping(nic_t *); 237 237 static void e1000_send_frame(nic_t *, void *, size_t); 238 238 … … 288 288 * 289 289 */ 290 static errno_t e1000_get_device_info(ddf_fun_t *dev, nic_device_info_t *info)290 static int e1000_get_device_info(ddf_fun_t *dev, nic_device_info_t *info) 291 291 { 292 292 assert(dev); … … 316 316 * 317 317 */ 318 static errno_t e1000_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)318 static int e1000_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state) 319 319 { 320 320 e1000_t *e1000 = DRIVER_DATA_FUN(fun); … … 335 335 * 336 336 */ 337 static errno_t e1000_get_operation_mode(ddf_fun_t *fun, int *speed,337 static int e1000_get_operation_mode(ddf_fun_t *fun, int *speed, 338 338 nic_channel_mode_t *duplex, nic_role_t *role) 339 339 { … … 386 386 * 387 387 */ 388 static errno_t e1000_set_operation_mode(ddf_fun_t *fun, int speed,388 static int e1000_set_operation_mode(ddf_fun_t *fun, int speed, 389 389 nic_channel_mode_t duplex, nic_role_t role) 390 390 { … … 434 434 * 435 435 */ 436 static errno_t e1000_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)436 static int e1000_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement) 437 437 { 438 438 e1000_t *e1000 = DRIVER_DATA_FUN(fun); … … 462 462 * 463 463 */ 464 static errno_t e1000_autoneg_disable(ddf_fun_t *fun)464 static int e1000_autoneg_disable(ddf_fun_t *fun) 465 465 { 466 466 e1000_t *e1000 = DRIVER_DATA_FUN(fun); … … 490 490 * 491 491 */ 492 static errno_t e1000_autoneg_restart(ddf_fun_t *dev)492 static int e1000_autoneg_restart(ddf_fun_t *dev) 493 493 { 494 494 return e1000_autoneg_enable(dev, 0); … … 501 501 * 502 502 */ 503 static errno_t e1000_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)503 static int e1000_defective_get_mode(ddf_fun_t *fun, uint32_t *mode) 504 504 { 505 505 e1000_t *e1000 = DRIVER_DATA_FUN(fun); … … 522 522 * 523 523 */ 524 static errno_t e1000_defective_set_mode(ddf_fun_t *fun, uint32_t mode)524 static int e1000_defective_set_mode(ddf_fun_t *fun, uint32_t mode) 525 525 { 526 526 e1000_t *e1000 = DRIVER_DATA_FUN(fun); 527 errno_t rc = EOK;527 int rc = EOK; 528 528 529 529 fibril_mutex_lock(&e1000->rx_lock); … … 827 827 * 828 828 */ 829 static errno_t e1000_on_multicast_mode_change(nic_t *nic, nic_multicast_mode_t mode,829 static int e1000_on_multicast_mode_change(nic_t *nic, nic_multicast_mode_t mode, 830 830 const nic_address_t *addr, size_t addr_cnt) 831 831 { 832 832 e1000_t *e1000 = DRIVER_DATA_NIC(nic); 833 errno_t rc = EOK;833 int rc = EOK; 834 834 835 835 fibril_mutex_lock(&e1000->rx_lock); … … 881 881 * 882 882 */ 883 static errno_t e1000_on_unicast_mode_change(nic_t *nic, nic_unicast_mode_t mode,883 static int e1000_on_unicast_mode_change(nic_t *nic, nic_unicast_mode_t mode, 884 884 const nic_address_t *addr, size_t addr_cnt) 885 885 { 886 886 e1000_t *e1000 = DRIVER_DATA_NIC(nic); 887 errno_t rc = EOK;887 int rc = EOK; 888 888 889 889 fibril_mutex_lock(&e1000->rx_lock); … … 937 937 * 938 938 */ 939 static errno_t e1000_on_broadcast_mode_change(nic_t *nic, nic_broadcast_mode_t mode)939 static int e1000_on_broadcast_mode_change(nic_t *nic, nic_broadcast_mode_t mode) 940 940 { 941 941 e1000_t *e1000 = DRIVER_DATA_NIC(nic); 942 errno_t rc = EOK;942 int rc = EOK; 943 943 944 944 fibril_mutex_lock(&e1000->rx_lock); … … 1048 1048 * 1049 1049 */ 1050 static errno_t e1000_vlan_set_tag(ddf_fun_t *fun, uint16_t tag, bool add,1050 static int e1000_vlan_set_tag(ddf_fun_t *fun, uint16_t tag, bool add, 1051 1051 bool strip) 1052 1052 { … … 1259 1259 * @param nic Driver data 1260 1260 * 1261 * @param[out] handle IRQ capability handle if the handler was registered 1262 * 1263 * @return An error code otherwise 1264 * 1265 */ 1266 inline static errno_t e1000_register_int_handler(nic_t *nic, cap_handle_t *handle) 1261 * @return IRQ capability handle if the handler was registered 1262 * @return Negative error code otherwise 1263 * 1264 */ 1265 inline static int e1000_register_int_handler(nic_t *nic) 1267 1266 { 1268 1267 e1000_t *e1000 = DRIVER_DATA_NIC(nic); … … 1275 1274 e1000_irq_code.cmds[2].addr = e1000->reg_base_phys + E1000_IMC; 1276 1275 1277 errno_t rc= register_interrupt_handler(nic_get_ddf_dev(nic), e1000->irq,1278 e1000_interrupt_handler, &e1000_irq_code , handle);1276 int cap = register_interrupt_handler(nic_get_ddf_dev(nic), e1000->irq, 1277 e1000_interrupt_handler, &e1000_irq_code); 1279 1278 1280 1279 fibril_mutex_unlock(&irq_reg_mutex); 1281 return rc;1280 return cap; 1282 1281 } 1283 1282 … … 1319 1318 * 1320 1319 */ 1321 static errno_t e1000_poll_mode_change(nic_t *nic, nic_poll_mode_t mode,1320 static int e1000_poll_mode_change(nic_t *nic, nic_poll_mode_t mode, 1322 1321 const struct timeval *period) 1323 1322 { … … 1370 1369 * 1371 1370 * @return EOK if succeed 1372 * @return Anerror code otherwise1373 * 1374 */ 1375 static errno_t e1000_initialize_rx_structure(nic_t *nic)1371 * @return Negative error code otherwise 1372 * 1373 */ 1374 static int e1000_initialize_rx_structure(nic_t *nic) 1376 1375 { 1377 1376 e1000_t *e1000 = DRIVER_DATA_NIC(nic); … … 1379 1378 1380 1379 e1000->rx_ring_virt = AS_AREA_ANY; 1381 errno_t rc = dmamem_map_anonymous(1380 int rc = dmamem_map_anonymous( 1382 1381 E1000_RX_FRAME_COUNT * sizeof(e1000_rx_descriptor_t), 1383 1382 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, … … 1524 1523 * 1525 1524 * @return EOK if succeed 1526 * @return Anerror code otherwise1525 * @return Negative error code otherwise 1527 1526 * 1528 1527 */ … … 1567 1566 * 1568 1567 */ 1569 static errno_t e1000_initialize_tx_structure(e1000_t *e1000)1568 static int e1000_initialize_tx_structure(e1000_t *e1000) 1570 1569 { 1571 1570 size_t i; … … 1579 1578 e1000->tx_frame_virt = NULL; 1580 1579 1581 errno_t rc = dmamem_map_anonymous(1580 int rc = dmamem_map_anonymous( 1582 1581 E1000_TX_FRAME_COUNT * sizeof(e1000_tx_descriptor_t), 1583 1582 DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, … … 1718 1717 * 1719 1718 */ 1720 static errno_t e1000_reset(nic_t *nic)1719 static int e1000_reset(nic_t *nic) 1721 1720 { 1722 1721 e1000_t *e1000 = DRIVER_DATA_NIC(nic); … … 1749 1748 * 1750 1749 */ 1751 static errno_t e1000_on_activating(nic_t *nic)1750 static int e1000_on_activating(nic_t *nic) 1752 1751 { 1753 1752 assert(nic); … … 1761 1760 e1000_enable_interrupts(e1000); 1762 1761 1763 errno_t rc = hw_res_enable_interrupt(e1000->parent_sess, e1000->irq);1762 int rc = hw_res_enable_interrupt(e1000->parent_sess, e1000->irq); 1764 1763 if (rc != EOK) { 1765 1764 e1000_disable_interrupts(e1000); … … 1795 1794 * 1796 1795 */ 1797 static errno_t e1000_on_down_unlocked(nic_t *nic)1796 static int e1000_on_down_unlocked(nic_t *nic) 1798 1797 { 1799 1798 e1000_t *e1000 = DRIVER_DATA_NIC(nic); … … 1826 1825 * 1827 1826 */ 1828 static errno_t e1000_on_down(nic_t *nic)1827 static int e1000_on_down(nic_t *nic) 1829 1828 { 1830 1829 e1000_t *e1000 = DRIVER_DATA_NIC(nic); … … 1834 1833 fibril_mutex_lock(&e1000->ctrl_lock); 1835 1834 1836 errno_t rc = e1000_on_down_unlocked(nic);1835 int rc = e1000_on_down_unlocked(nic); 1837 1836 1838 1837 fibril_mutex_unlock(&e1000->ctrl_lock); … … 1851 1850 * 1852 1851 */ 1853 static errno_t e1000_on_stopping(nic_t *nic)1852 static int e1000_on_stopping(nic_t *nic) 1854 1853 { 1855 1854 e1000_t *e1000 = DRIVER_DATA_NIC(nic); … … 1859 1858 fibril_mutex_lock(&e1000->ctrl_lock); 1860 1859 1861 errno_t rc = e1000_on_down_unlocked(nic);1860 int rc = e1000_on_down_unlocked(nic); 1862 1861 if (rc == EOK) 1863 1862 rc = e1000_reset(nic); … … 1940 1939 * 1941 1940 * @return EOK if succeed 1942 * @return Anerror code otherwise1943 * 1944 */ 1945 static errno_t e1000_fill_resource_info(ddf_dev_t *dev,1941 * @return Negative error code otherwise 1942 * 1943 */ 1944 static int e1000_fill_resource_info(ddf_dev_t *dev, 1946 1945 const hw_res_list_parsed_t *hw_resources) 1947 1946 { … … 1965 1964 * 1966 1965 * @return EOK if succeed 1967 * @return Anerror code otherwise1968 * 1969 */ 1970 static errno_t e1000_get_resource_info(ddf_dev_t *dev)1966 * @return Negative error code otherwise 1967 * 1968 */ 1969 static int e1000_get_resource_info(ddf_dev_t *dev) 1971 1970 { 1972 1971 assert(dev != NULL); … … 1977 1976 1978 1977 /* Get hw resources form parent driver */ 1979 errno_t rc = nic_get_resources(NIC_DATA_DEV(dev), &hw_res_parsed);1978 int rc = nic_get_resources(NIC_DATA_DEV(dev), &hw_res_parsed); 1980 1979 if (rc != EOK) 1981 1980 return rc; … … 1993 1992 * 1994 1993 * @return EOK if succeed 1995 * @return Anerror code otherwise1996 * 1997 */ 1998 static errno_t e1000_device_initialize(ddf_dev_t *dev)1994 * @return Negative error code otherwise 1995 * 1996 */ 1997 static int e1000_device_initialize(ddf_dev_t *dev) 1999 1998 { 2000 1999 /* Allocate driver data for the device. */ … … 2012 2011 2013 2012 /* Obtain and fill hardware resources info */ 2014 errno_t rc = e1000_get_resource_info(dev);2013 int rc = e1000_get_resource_info(dev); 2015 2014 if (rc != EOK) { 2016 2015 ddf_msg(LVL_ERROR, "Cannot obtain hardware resources"); … … 2107 2106 * 2108 2107 * @return EOK if successed 2109 * @return Anerror code otherwise2110 * 2111 */ 2112 static errno_t e1000_pio_enable(ddf_dev_t *dev)2108 * @return Negative error code otherwise 2109 * 2110 */ 2111 static int e1000_pio_enable(ddf_dev_t *dev) 2113 2112 { 2114 2113 e1000_t *e1000 = DRIVER_DATA_DEV(dev); 2115 2114 2116 errno_t rc = pio_enable(e1000->reg_base_phys, 8 * PAGE_SIZE,2115 int rc = pio_enable(e1000->reg_base_phys, 8 * PAGE_SIZE, 2117 2116 &e1000->reg_base_virt); 2118 2117 if (rc != EOK) … … 2127 2126 * 2128 2127 */ 2129 errno_t e1000_dev_add(ddf_dev_t *dev)2128 int e1000_dev_add(ddf_dev_t *dev) 2130 2129 { 2131 2130 ddf_fun_t *fun; 2132 2131 2133 2132 /* Initialize device structure for E1000 */ 2134 errno_t rc = e1000_device_initialize(dev);2133 int rc = e1000_device_initialize(dev); 2135 2134 if (rc != EOK) 2136 2135 return rc; … … 2165 2164 ddf_fun_set_ops(fun, &e1000_dev_ops); 2166 2165 2167 int irq_cap ;2168 rc = e1000_register_int_handler(nic, &irq_cap);2169 if (rc != EOK) {2166 int irq_cap = e1000_register_int_handler(nic); 2167 if (irq_cap < 0) { 2168 rc = irq_cap; 2170 2169 goto err_fun_create; 2171 2170 } … … 2255 2254 * 2256 2255 * @return EOK if succeed 2257 * @return Anerror code otherwise2258 * 2259 */ 2260 static errno_t e1000_get_address(e1000_t *e1000, nic_address_t *address)2256 * @return Negative error code otherwise 2257 * 2258 */ 2259 static int e1000_get_address(e1000_t *e1000, nic_address_t *address) 2261 2260 { 2262 2261 fibril_mutex_lock(&e1000->rx_lock); … … 2289 2288 * 2290 2289 * @return EOK if succeed 2291 * @return Anerror code otherwise2292 */ 2293 static errno_t e1000_set_addr(ddf_fun_t *fun, const nic_address_t *addr)2290 * @return Negative error code otherwise 2291 */ 2292 static int e1000_set_addr(ddf_fun_t *fun, const nic_address_t *addr) 2294 2293 { 2295 2294 nic_t *nic = NIC_DATA_FUN(fun); … … 2299 2298 fibril_mutex_lock(&e1000->tx_lock); 2300 2299 2301 errno_t rc = nic_report_address(nic, addr);2300 int rc = nic_report_address(nic, addr); 2302 2301 if (rc == EOK) 2303 2302 e1000_write_receive_address(e1000, 0, addr, false);
Note:
See TracChangeset
for help on using the changeset viewer.