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