Changes in uspace/drv/nic/rtl8169/driver.c [f300523:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/rtl8169/driver.c
rf300523 rb7fd2a0 30 30 #include <async.h> 31 31 #include <errno.h> 32 #include <str_error.h> 32 33 #include <align.h> 33 34 #include <byteorder.h> … … 51 52 FIBRIL_MUTEX_INITIALIZE(irq_reg_lock); 52 53 53 static int rtl8169_set_addr(ddf_fun_t *fun, const nic_address_t *addr);54 static int rtl8169_get_device_info(ddf_fun_t *fun, nic_device_info_t *info);55 static int rtl8169_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state);56 static int rtl8169_get_operation_mode(ddf_fun_t *fun, int *speed,54 static errno_t rtl8169_set_addr(ddf_fun_t *fun, const nic_address_t *addr); 55 static errno_t rtl8169_get_device_info(ddf_fun_t *fun, nic_device_info_t *info); 56 static errno_t rtl8169_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state); 57 static errno_t rtl8169_get_operation_mode(ddf_fun_t *fun, int *speed, 57 58 nic_channel_mode_t *duplex, nic_role_t *role); 58 static int rtl8169_set_operation_mode(ddf_fun_t *fun, int speed,59 static errno_t rtl8169_set_operation_mode(ddf_fun_t *fun, int speed, 59 60 nic_channel_mode_t duplex, nic_role_t role); 60 static int rtl8169_pause_get(ddf_fun_t *fun, nic_result_t *we_send,61 static errno_t rtl8169_pause_get(ddf_fun_t *fun, nic_result_t *we_send, 61 62 nic_result_t *we_receive, uint16_t *time); 62 static int rtl8169_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive,63 static errno_t rtl8169_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive, 63 64 uint16_t time); 64 static int rtl8169_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement);65 static int rtl8169_autoneg_disable(ddf_fun_t *fun);66 static int rtl8169_autoneg_probe(ddf_fun_t *fun, uint32_t *advertisement,65 static errno_t rtl8169_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement); 66 static errno_t rtl8169_autoneg_disable(ddf_fun_t *fun); 67 static errno_t rtl8169_autoneg_probe(ddf_fun_t *fun, uint32_t *advertisement, 67 68 uint32_t *their_adv, nic_result_t *result, nic_result_t *their_result); 68 static int rtl8169_autoneg_restart(ddf_fun_t *fun);69 static int rtl8169_defective_get_mode(ddf_fun_t *fun, uint32_t *mode);70 static int rtl8169_defective_set_mode(ddf_fun_t *fun, uint32_t mode);71 static int rtl8169_on_activated(nic_t *nic_data);72 static int rtl8169_on_stopped(nic_t *nic_data);69 static errno_t rtl8169_autoneg_restart(ddf_fun_t *fun); 70 static errno_t rtl8169_defective_get_mode(ddf_fun_t *fun, uint32_t *mode); 71 static errno_t rtl8169_defective_set_mode(ddf_fun_t *fun, uint32_t mode); 72 static errno_t rtl8169_on_activated(nic_t *nic_data); 73 static errno_t rtl8169_on_stopped(nic_t *nic_data); 73 74 static void rtl8169_send_frame(nic_t *nic_data, void *data, size_t size); 74 75 static void rtl8169_irq_handler(ipc_call_t *icall, ddf_dev_t *dev); 75 static inline int rtl8169_register_int_handler(nic_t *nic_data);76 static inline errno_t rtl8169_register_int_handler(nic_t *nic_data, cap_handle_t *handle); 76 77 static inline void rtl8169_get_hwaddr(rtl8169_t *rtl8169, nic_address_t *addr); 77 78 static inline void rtl8169_set_hwaddr(rtl8169_t *rtl8169, const nic_address_t *addr); 78 79 79 80 static void rtl8169_reset(rtl8169_t *rtl8169); 80 static int rtl8169_get_resource_info(ddf_dev_t *dev);81 static int rtl8169_fill_resource_info(ddf_dev_t *dev, const hw_res_list_parsed_t *hw_resources);81 static errno_t rtl8169_get_resource_info(ddf_dev_t *dev); 82 static errno_t rtl8169_fill_resource_info(ddf_dev_t *dev, const hw_res_list_parsed_t *hw_resources); 82 83 static rtl8169_t *rtl8169_create_dev_data(ddf_dev_t *dev); 83 84 84 static int rtl8169_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,85 static errno_t rtl8169_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode, 85 86 const nic_address_t *, size_t); 86 static int rtl8169_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,87 static errno_t rtl8169_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode, 87 88 const nic_address_t *addr, size_t addr_count); 88 static int rtl8169_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode);89 static errno_t rtl8169_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode); 89 90 90 91 static uint16_t rtl8169_mii_read(rtl8169_t *rtl8169, uint8_t addr); … … 160 161 static ddf_dev_ops_t rtl8169_dev_ops; 161 162 162 static int rtl8169_dev_add(ddf_dev_t *dev);163 static errno_t rtl8169_dev_add(ddf_dev_t *dev); 163 164 164 165 /** Basic driver operations for RTL8169 driver */ … … 173 174 }; 174 175 175 static int rtl8169_get_resource_info(ddf_dev_t *dev)176 static errno_t rtl8169_get_resource_info(ddf_dev_t *dev) 176 177 { 177 178 assert(dev); … … 184 185 185 186 /* Get hw resources form parent driver */ 186 int rc = nic_get_resources(nic_data, &hw_res_parsed);187 errno_t rc = nic_get_resources(nic_data, &hw_res_parsed); 187 188 if (rc != EOK) 188 189 return rc; 189 190 190 191 /* Fill resources information to the device */ 191 int ret = rtl8169_fill_resource_info(dev, &hw_res_parsed);192 errno_t ret = rtl8169_fill_resource_info(dev, &hw_res_parsed); 192 193 hw_res_list_parsed_clean(&hw_res_parsed); 193 194 … … 195 196 } 196 197 197 static int rtl8169_fill_resource_info(ddf_dev_t *dev, const hw_res_list_parsed_t198 static errno_t rtl8169_fill_resource_info(ddf_dev_t *dev, const hw_res_list_parsed_t 198 199 *hw_resources) 199 200 { … … 228 229 } 229 230 230 static int rtl8169_allocate_buffers(rtl8169_t *rtl8169)231 { 232 int rc;231 static errno_t rtl8169_allocate_buffers(rtl8169_t *rtl8169) 232 { 233 errno_t rc; 233 234 234 235 ddf_msg(LVL_DEBUG, "Allocating DMA buffer rings"); … … 333 334 } 334 335 335 static int rtl8169_dev_initialize(ddf_dev_t *dev)336 { 337 int ret;336 static errno_t rtl8169_dev_initialize(ddf_dev_t *dev) 337 { 338 errno_t ret; 338 339 339 340 rtl8169_t *rtl8169 = rtl8169_create_dev_data(dev); … … 359 360 } 360 361 361 inline static int rtl8169_register_int_handler(nic_t *nic_data)362 inline static errno_t rtl8169_register_int_handler(nic_t *nic_data, cap_handle_t *handle) 362 363 { 363 364 rtl8169_t *rtl8169 = nic_get_specific(nic_data); … … 367 368 rtl8169_irq_code.cmds[2].addr = rtl8169->regs + ISR; 368 369 rtl8169_irq_code.cmds[3].addr = rtl8169->regs + IMR; 369 int irq_cap= register_interrupt_handler(nic_get_ddf_dev(nic_data),370 rtl8169->irq, rtl8169_irq_handler, &rtl8169_irq_code );371 372 return irq_cap;373 } 374 375 static int rtl8169_dev_add(ddf_dev_t *dev)370 errno_t rc = register_interrupt_handler(nic_get_ddf_dev(nic_data), 371 rtl8169->irq, rtl8169_irq_handler, &rtl8169_irq_code, handle); 372 373 return rc; 374 } 375 376 static errno_t rtl8169_dev_add(ddf_dev_t *dev) 376 377 { 377 378 ddf_fun_t *fun; 378 379 nic_address_t nic_addr; 379 int rc;380 errno_t rc; 380 381 381 382 assert(dev); … … 427 428 goto err_pio; 428 429 429 int irq_cap = rtl8169_register_int_handler(nic_data);430 if (irq_cap < 0) {431 rc = irq_cap;432 ddf_msg(LVL_ERROR, "Failed to register IRQ handler (% d)", rc);430 int irq_cap; 431 rc = rtl8169_register_int_handler(nic_data, &irq_cap); 432 if (rc != EOK) { 433 ddf_msg(LVL_ERROR, "Failed to register IRQ handler (%s)", str_error_name(rc)); 433 434 goto err_irq; 434 435 } … … 480 481 } 481 482 482 static int rtl8169_set_addr(ddf_fun_t *fun, const nic_address_t *addr)483 static errno_t rtl8169_set_addr(ddf_fun_t *fun, const nic_address_t *addr) 483 484 { 484 485 nic_t *nic_data = nic_get_from_ddf_fun(fun); 485 486 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 486 int rc;487 errno_t rc; 487 488 488 489 fibril_mutex_lock(&rtl8169->rx_lock); … … 501 502 } 502 503 503 static int rtl8169_get_device_info(ddf_fun_t *fun, nic_device_info_t *info)504 static errno_t rtl8169_get_device_info(ddf_fun_t *fun, nic_device_info_t *info) 504 505 { 505 506 nic_t *nic_data = nic_get_from_ddf_fun(fun); … … 527 528 } 528 529 529 static int rtl8169_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)530 static errno_t rtl8169_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state) 530 531 { 531 532 rtl8169_t *rtl8169 = nic_get_specific(nic_get_from_ddf_fun(fun)); … … 540 541 } 541 542 542 static int rtl8169_get_operation_mode(ddf_fun_t *fun, int *speed,543 static errno_t rtl8169_get_operation_mode(ddf_fun_t *fun, int *speed, 543 544 nic_channel_mode_t *duplex, nic_role_t *role) 544 545 { … … 562 563 } 563 564 564 static int rtl8169_set_operation_mode(ddf_fun_t *fun, int speed,565 static errno_t rtl8169_set_operation_mode(ddf_fun_t *fun, int speed, 565 566 nic_channel_mode_t duplex, nic_role_t role) 566 567 { … … 593 594 } 594 595 595 static int rtl8169_pause_get(ddf_fun_t *fun, nic_result_t *we_send,596 static errno_t rtl8169_pause_get(ddf_fun_t *fun, nic_result_t *we_send, 596 597 nic_result_t *we_receive, uint16_t *time) 597 598 { … … 599 600 } 600 601 601 static int rtl8169_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive,602 static errno_t rtl8169_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive, 602 603 uint16_t time) 603 604 { … … 605 606 } 606 607 607 static int rtl8169_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)608 static errno_t rtl8169_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement) 608 609 { 609 610 rtl8169_t *rtl8169 = nic_get_specific(nic_get_from_ddf_fun(fun)); … … 629 630 } 630 631 631 static int rtl8169_autoneg_disable(ddf_fun_t *fun)632 static errno_t rtl8169_autoneg_disable(ddf_fun_t *fun) 632 633 { 633 634 rtl8169_t *rtl8169 = nic_get_specific(nic_get_from_ddf_fun(fun)); … … 640 641 } 641 642 642 static int rtl8169_autoneg_probe(ddf_fun_t *fun, uint32_t *advertisement,643 static errno_t rtl8169_autoneg_probe(ddf_fun_t *fun, uint32_t *advertisement, 643 644 uint32_t *their_adv, nic_result_t *result, nic_result_t *their_result) 644 645 { … … 646 647 } 647 648 648 static int rtl8169_autoneg_restart(ddf_fun_t *fun)649 static errno_t rtl8169_autoneg_restart(ddf_fun_t *fun) 649 650 { 650 651 rtl8169_t *rtl8169 = nic_get_specific(nic_get_from_ddf_fun(fun)); … … 656 657 } 657 658 658 static int rtl8169_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)659 { 660 return EOK; 661 } 662 663 static int rtl8169_defective_set_mode(ddf_fun_t *fun, uint32_t mode)659 static errno_t rtl8169_defective_get_mode(ddf_fun_t *fun, uint32_t *mode) 660 { 661 return EOK; 662 } 663 664 static errno_t rtl8169_defective_set_mode(ddf_fun_t *fun, uint32_t mode) 664 665 { 665 666 return EOK; … … 690 691 } 691 692 692 static int rtl8169_on_activated(nic_t *nic_data)693 { 694 int rc;693 static errno_t rtl8169_on_activated(nic_t *nic_data) 694 { 695 errno_t rc; 695 696 uint64_t tmp; 696 697 … … 706 707 rc = rtl8169_allocate_buffers(rtl8169); 707 708 if (rc != EOK) { 708 ddf_msg(LVL_ERROR, "Error allocating buffers: % d", rc);709 ddf_msg(LVL_ERROR, "Error allocating buffers: %s", str_error_name(rc)); 709 710 return 0; 710 711 } … … 752 753 } 753 754 754 static int rtl8169_on_stopped(nic_t *nic_data)755 static errno_t rtl8169_on_stopped(nic_t *nic_data) 755 756 { 756 757 ddf_msg(LVL_NOTE, "Stopping device"); … … 818 819 } 819 820 820 static int rtl8169_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,821 static errno_t rtl8169_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode, 821 822 const nic_address_t *addr, size_t addr_count) 822 823 { … … 870 871 } 871 872 872 static int rtl8169_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,873 static errno_t rtl8169_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode, 873 874 const nic_address_t *addr, size_t addr_count) 874 875 { … … 914 915 } 915 916 916 static int rtl8169_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode)917 static errno_t rtl8169_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode) 917 918 { 918 919 rtl8169_t *rtl8169 = nic_get_specific(nic_data); … … 1207 1208 int main(void) 1208 1209 { 1209 int rc = nic_driver_init(NAME);1210 errno_t rc = nic_driver_init(NAME); 1210 1211 if (rc != EOK) 1211 1212 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.