Changeset b7fd2a0 in mainline for uspace/lib/nic/src
- Timestamp:
- 2018-01-13T03:10:29Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a53ed3a
- Parents:
- 36f0738
- Location:
- uspace/lib/nic/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_addr_db.c
r36f0738 rb7fd2a0 120 120 * @return ENOMEM If there was not enough memory to initialize the storage 121 121 */ 122 int nic_addr_db_init(nic_addr_db_t *db, size_t addr_len)122 errno_t nic_addr_db_init(nic_addr_db_t *db, size_t addr_len) 123 123 { 124 124 assert(db); … … 168 168 * @return EEXIST If this adress already is in the db 169 169 */ 170 int nic_addr_db_insert(nic_addr_db_t *db, const uint8_t *addr)170 errno_t nic_addr_db_insert(nic_addr_db_t *db, const uint8_t *addr) 171 171 { 172 172 assert(db && addr); … … 200 200 * @return ENOENT If there is no address 201 201 */ 202 int nic_addr_db_remove(nic_addr_db_t *db, const uint8_t *addr)202 errno_t nic_addr_db_remove(nic_addr_db_t *db, const uint8_t *addr) 203 203 { 204 204 assert(db && addr); -
uspace/lib/nic/src/nic_driver.c
r36f0738 rb7fd2a0 61 61 * @param name Name of the device/driver (used in logging) 62 62 */ 63 int nic_driver_init(const char *name)63 errno_t nic_driver_init(const char *name) 64 64 { 65 65 list_initialize(&nic_globals.frame_list_cache); … … 243 243 * @return EOK or an error code 244 244 */ 245 int nic_get_resources(nic_t *nic_data, hw_res_list_parsed_t *resources)245 errno_t nic_get_resources(nic_t *nic_data, hw_res_list_parsed_t *resources) 246 246 { 247 247 ddf_dev_t *dev = nic_data->dev; … … 399 399 * @return EINVAL 400 400 */ 401 int nic_report_poll_mode(nic_t *nic_data, nic_poll_mode_t mode,401 errno_t nic_report_poll_mode(nic_t *nic_data, nic_poll_mode_t mode, 402 402 struct timeval *period) 403 403 { 404 int rc = EOK;404 errno_t rc = EOK; 405 405 fibril_rwlock_write_lock(&nic_data->main_lock); 406 406 nic_data->poll_mode = mode; … … 423 423 * 424 424 */ 425 int nic_report_address(nic_t *nic_data, const nic_address_t *address)425 errno_t nic_report_address(nic_t *nic_data, const nic_address_t *address) 426 426 { 427 427 assert(nic_data); … … 434 434 /* Notify NIL layer (and uppper) if bound - not in add_device */ 435 435 if (nic_data->client_session != NULL) { 436 int rc = nic_ev_addr_changed(nic_data->client_session,436 errno_t rc = nic_ev_addr_changed(nic_data->client_session, 437 437 address); 438 438 … … 450 450 * calls this should not happen. 451 451 */ 452 int rc = nic_rxc_set_addr(&nic_data->rx_control,452 errno_t rc = nic_rxc_set_addr(&nic_data->rx_control, 453 453 &nic_data->mac, address); 454 454 … … 808 808 * @return ENOENT 809 809 */ 810 int nic_query_vlan_mask(const nic_t *nic_data, nic_vlan_mask_t *mask)810 errno_t nic_query_vlan_mask(const nic_t *nic_data, nic_vlan_mask_t *mask) 811 811 { 812 812 assert(mask); … … 1039 1039 * @return 0, never reached 1040 1040 */ 1041 static int period_fibril_fun(void *data)1041 static errno_t period_fibril_fun(void *data) 1042 1042 { 1043 1043 nic_t *nic = data; -
uspace/lib/nic/src/nic_ev.c
r36f0738 rb7fd2a0 42 42 43 43 /** Device address changed. */ 44 int nic_ev_addr_changed(async_sess_t *sess, const nic_address_t *addr)44 errno_t nic_ev_addr_changed(async_sess_t *sess, const nic_address_t *addr) 45 45 { 46 46 async_exch_t *exch = async_exchange_begin(sess); … … 48 48 ipc_call_t answer; 49 49 aid_t req = async_send_0(exch, NIC_EV_ADDR_CHANGED, &answer); 50 int retval = async_data_write_start(exch, addr,50 errno_t retval = async_data_write_start(exch, addr, 51 51 sizeof(nic_address_t)); 52 52 … … 63 63 64 64 /** Device state changed. */ 65 int nic_ev_device_state(async_sess_t *sess, sysarg_t state)65 errno_t nic_ev_device_state(async_sess_t *sess, sysarg_t state) 66 66 { 67 int rc;67 errno_t rc; 68 68 69 69 async_exch_t *exch = async_exchange_begin(sess); … … 75 75 76 76 /** Frame received. */ 77 int nic_ev_received(async_sess_t *sess, void *data, size_t size)77 errno_t nic_ev_received(async_sess_t *sess, void *data, size_t size) 78 78 { 79 79 async_exch_t *exch = async_exchange_begin(sess); … … 81 81 ipc_call_t answer; 82 82 aid_t req = async_send_0(exch, NIC_EV_RECEIVED, &answer); 83 int retval = async_data_write_start(exch, data, size);83 errno_t retval = async_data_write_start(exch, data, size); 84 84 85 85 async_exchange_end(exch); -
uspace/lib/nic/src/nic_impl.c
r36f0738 rb7fd2a0 52 52 * @return EOK always. 53 53 */ 54 int nic_get_state_impl(ddf_fun_t *fun, nic_device_state_t *state)54 errno_t nic_get_state_impl(ddf_fun_t *fun, nic_device_state_t *state) 55 55 { 56 56 nic_t *nic_data = nic_get_from_ddf_fun(fun); … … 72 72 * @return EINVAL If the state cannot be changed 73 73 */ 74 int nic_set_state_impl(ddf_fun_t *fun, nic_device_state_t state)74 errno_t nic_set_state_impl(ddf_fun_t *fun, nic_device_state_t state) 75 75 { 76 76 if (state >= NIC_STATE_MAX) { … … 108 108 } 109 109 if (event_handler != NULL) { 110 int rc = event_handler(nic_data);110 errno_t rc = event_handler(nic_data); 111 111 if (rc != EOK) { 112 112 fibril_rwlock_write_unlock(&nic_data->main_lock); … … 117 117 if (state == NIC_STATE_STOPPED) { 118 118 /* Notify upper layers that we are reseting the MAC */ 119 int rc = nic_ev_addr_changed(nic_data->client_session,119 errno_t rc = nic_ev_addr_changed(nic_data->client_session, 120 120 &nic_data->default_mac); 121 121 nic_data->poll_mode = nic_data->default_poll_mode; … … 168 168 * @return EBUSY If the device is not in state when the frame can be sent. 169 169 */ 170 int nic_send_frame_impl(ddf_fun_t *fun, void *data, size_t size)170 errno_t nic_send_frame_impl(ddf_fun_t *fun, void *data, size_t size) 171 171 { 172 172 nic_t *nic_data = nic_get_from_ddf_fun(fun); … … 191 191 * @return EOK On success, or an error code. 192 192 */ 193 int nic_callback_create_impl(ddf_fun_t *fun)193 errno_t nic_callback_create_impl(ddf_fun_t *fun) 194 194 { 195 195 nic_t *nic = nic_get_from_ddf_fun(fun); … … 216 216 * @return ELIMIT If the buffer is too short 217 217 */ 218 int nic_get_address_impl(ddf_fun_t *fun, nic_address_t *address)218 errno_t nic_get_address_impl(ddf_fun_t *fun, nic_address_t *address) 219 219 { 220 220 assert(address); … … 235 235 * @return EOK (cannot fail) 236 236 */ 237 int nic_get_stats_impl(ddf_fun_t *fun, nic_device_stats_t *stats)237 errno_t nic_get_stats_impl(ddf_fun_t *fun, nic_device_stats_t *stats) 238 238 { 239 239 nic_t *nic_data = nic_get_from_ddf_fun(fun); … … 257 257 * @return EOK 258 258 */ 259 int nic_unicast_get_mode_impl(ddf_fun_t *fun, nic_unicast_mode_t *mode,259 errno_t nic_unicast_get_mode_impl(ddf_fun_t *fun, nic_unicast_mode_t *mode, 260 260 size_t max_count, nic_address_t *addr_list, size_t *addr_count) 261 261 { … … 281 281 * @return ENOMEM 282 282 */ 283 int nic_unicast_set_mode_impl(ddf_fun_t *fun,283 errno_t nic_unicast_set_mode_impl(ddf_fun_t *fun, 284 284 nic_unicast_mode_t mode, const nic_address_t *addr_list, size_t addr_count) 285 285 { … … 294 294 nic_t *nic_data = nic_get_from_ddf_fun(fun); 295 295 fibril_rwlock_write_lock(&nic_data->rxc_lock); 296 int rc = ENOTSUP;296 errno_t rc = ENOTSUP; 297 297 if (nic_data->on_unicast_mode_change) { 298 298 rc = nic_data->on_unicast_mode_change(nic_data, … … 324 324 * @return EOK 325 325 */ 326 int nic_multicast_get_mode_impl(ddf_fun_t *fun, nic_multicast_mode_t *mode,326 errno_t nic_multicast_get_mode_impl(ddf_fun_t *fun, nic_multicast_mode_t *mode, 327 327 size_t max_count, nic_address_t *addr_list, size_t *addr_count) 328 328 { … … 348 348 * @return ENOMEM 349 349 */ 350 int nic_multicast_set_mode_impl(ddf_fun_t *fun, nic_multicast_mode_t mode,350 errno_t nic_multicast_set_mode_impl(ddf_fun_t *fun, nic_multicast_mode_t mode, 351 351 const nic_address_t *addr_list, size_t addr_count) 352 352 { … … 361 361 nic_t *nic_data = nic_get_from_ddf_fun(fun); 362 362 fibril_rwlock_write_lock(&nic_data->rxc_lock); 363 int rc = ENOTSUP;363 errno_t rc = ENOTSUP; 364 364 if (nic_data->on_multicast_mode_change) { 365 365 rc = nic_data->on_multicast_mode_change(nic_data, mode, addr_list, addr_count); … … 381 381 * @return EOK 382 382 */ 383 int nic_broadcast_get_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t *mode)383 errno_t nic_broadcast_get_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t *mode) 384 384 { 385 385 nic_t *nic_data = nic_get_from_ddf_fun(fun); … … 401 401 * @return ENOMEM 402 402 */ 403 int nic_broadcast_set_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t mode)403 errno_t nic_broadcast_set_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t mode) 404 404 { 405 405 nic_t *nic_data = nic_get_from_ddf_fun(fun); 406 406 fibril_rwlock_write_lock(&nic_data->rxc_lock); 407 int rc = ENOTSUP;407 errno_t rc = ENOTSUP; 408 408 if (nic_data->on_broadcast_mode_change) { 409 409 rc = nic_data->on_broadcast_mode_change(nic_data, mode); … … 427 427 * @return EOK 428 428 */ 429 int nic_blocked_sources_get_impl(ddf_fun_t *fun,429 errno_t nic_blocked_sources_get_impl(ddf_fun_t *fun, 430 430 size_t max_count, nic_address_t *addr_list, size_t *addr_count) 431 431 { … … 450 450 * @return ENOMEM 451 451 */ 452 int nic_blocked_sources_set_impl(ddf_fun_t *fun,452 errno_t nic_blocked_sources_set_impl(ddf_fun_t *fun, 453 453 const nic_address_t *addr_list, size_t addr_count) 454 454 { … … 458 458 nic_data->on_blocked_sources_change(nic_data, addr_list, addr_count); 459 459 } 460 int rc = nic_rxc_blocked_sources_set(&nic_data->rx_control,460 errno_t rc = nic_rxc_blocked_sources_set(&nic_data->rx_control, 461 461 addr_list, addr_count); 462 462 fibril_rwlock_write_unlock(&nic_data->rxc_lock); … … 473 473 * @return ENOENT If the mask is not set 474 474 */ 475 int nic_vlan_get_mask_impl(ddf_fun_t *fun, nic_vlan_mask_t *mask)475 errno_t nic_vlan_get_mask_impl(ddf_fun_t *fun, nic_vlan_mask_t *mask) 476 476 { 477 477 nic_t *nic_data = nic_get_from_ddf_fun(fun); 478 478 fibril_rwlock_read_lock(&nic_data->rxc_lock); 479 int rc = nic_rxc_vlan_get_mask(&nic_data->rx_control, mask);479 errno_t rc = nic_rxc_vlan_get_mask(&nic_data->rx_control, mask); 480 480 fibril_rwlock_read_unlock(&nic_data->rxc_lock); 481 481 return rc; … … 491 491 * @return ENOMEM 492 492 */ 493 int nic_vlan_set_mask_impl(ddf_fun_t *fun, const nic_vlan_mask_t *mask)493 errno_t nic_vlan_set_mask_impl(ddf_fun_t *fun, const nic_vlan_mask_t *mask) 494 494 { 495 495 nic_t *nic_data = nic_get_from_ddf_fun(fun); 496 496 fibril_rwlock_write_lock(&nic_data->rxc_lock); 497 int rc = nic_rxc_vlan_set_mask(&nic_data->rx_control, mask);497 errno_t rc = nic_rxc_vlan_set_mask(&nic_data->rx_control, mask); 498 498 if (rc == EOK && nic_data->on_vlan_mask_change) { 499 499 nic_data->on_vlan_mask_change(nic_data, mask); … … 518 518 * @return ENOMEM If there was not enough memory to complete the operation 519 519 */ 520 int nic_wol_virtue_add_impl(ddf_fun_t *fun, nic_wv_type_t type,520 errno_t nic_wol_virtue_add_impl(ddf_fun_t *fun, nic_wv_type_t type, 521 521 const void *data, size_t length, nic_wv_id_t *new_id) 522 522 { … … 560 560 } 561 561 /* Call the user-defined add callback */ 562 int rc = nic_data->on_wol_virtue_add(nic_data, virtue);562 errno_t rc = nic_data->on_wol_virtue_add(nic_data, virtue); 563 563 if (rc != EOK) { 564 564 free(virtue->data); … … 593 593 * @return ENOENT If the virtue identifier is not valid. 594 594 */ 595 int nic_wol_virtue_remove_impl(ddf_fun_t *fun, nic_wv_id_t id)595 errno_t nic_wol_virtue_remove_impl(ddf_fun_t *fun, nic_wv_id_t id) 596 596 { 597 597 nic_t *nic_data = nic_get_from_ddf_fun(fun); … … 629 629 * @return ENOMEM If there was not enough memory to complete the operation 630 630 */ 631 int nic_wol_virtue_probe_impl(ddf_fun_t *fun, nic_wv_id_t id,631 errno_t nic_wol_virtue_probe_impl(ddf_fun_t *fun, nic_wv_id_t id, 632 632 nic_wv_type_t *type, size_t max_length, void *data, size_t *length) 633 633 { … … 667 667 * @return ENOMEM If there was not enough memory to complete the operation 668 668 */ 669 int nic_wol_virtue_list_impl(ddf_fun_t *fun, nic_wv_type_t type,669 errno_t nic_wol_virtue_list_impl(ddf_fun_t *fun, nic_wv_type_t type, 670 670 size_t max_count, nic_wv_id_t *id_list, size_t *id_count) 671 671 { 672 672 nic_t *nic_data = nic_get_from_ddf_fun(fun); 673 673 fibril_rwlock_read_lock(&nic_data->wv_lock); 674 int rc = nic_wol_virtues_list(&nic_data->wol_virtues, type,674 errno_t rc = nic_wol_virtues_list(&nic_data->wol_virtues, type, 675 675 max_count, id_list, id_count); 676 676 fibril_rwlock_read_unlock(&nic_data->wv_lock); … … 688 688 * @return EOK If the operation was successfully completed 689 689 */ 690 int nic_wol_virtue_get_caps_impl(ddf_fun_t *fun, nic_wv_type_t type, int *count)690 errno_t nic_wol_virtue_get_caps_impl(ddf_fun_t *fun, nic_wv_type_t type, int *count) 691 691 { 692 692 nic_t *nic_data = nic_get_from_ddf_fun(fun); … … 710 710 * @return EPARTY Error in communication protocol 711 711 */ 712 int nic_poll_get_mode_impl(ddf_fun_t *fun,712 errno_t nic_poll_get_mode_impl(ddf_fun_t *fun, 713 713 nic_poll_mode_t *mode, struct timeval *period) 714 714 { … … 733 733 * @return EPARTY Error in communication protocol 734 734 */ 735 int nic_poll_set_mode_impl(ddf_fun_t *fun,735 errno_t nic_poll_set_mode_impl(ddf_fun_t *fun, 736 736 nic_poll_mode_t mode, const struct timeval *period) 737 737 { … … 754 754 } 755 755 fibril_rwlock_write_lock(&nic_data->main_lock); 756 int rc = nic_data->on_poll_mode_change(nic_data, mode, period);756 errno_t rc = nic_data->on_poll_mode_change(nic_data, mode, period); 757 757 assert(rc == EOK || rc == ENOTSUP || rc == EINVAL); 758 758 if (rc == ENOTSUP && (nic_data->on_poll_request != NULL) && … … 783 783 * @return EINVAL If the NIC is not in state where it allows on demand polling 784 784 */ 785 int nic_poll_now_impl(ddf_fun_t *fun) {785 errno_t nic_poll_now_impl(ddf_fun_t *fun) { 786 786 nic_t *nic_data = nic_get_from_ddf_fun(fun); 787 787 fibril_rwlock_read_lock(&nic_data->main_lock); … … 821 821 * @return EOK always. 822 822 */ 823 int nic_open_impl(ddf_fun_t *fun)823 errno_t nic_open_impl(ddf_fun_t *fun) 824 824 { 825 825 return EOK; -
uspace/lib/nic/src/nic_rx_control.c
r36f0738 rb7fd2a0 52 52 * @return EINVAL Internal error, should not happen 53 53 */ 54 int nic_rxc_init(nic_rxc_t *rxc)54 errno_t nic_rxc_init(nic_rxc_t *rxc) 55 55 { 56 56 memset(rxc, 0, sizeof(nic_rxc_t)); 57 int rc;57 errno_t rc; 58 58 rc = nic_addr_db_init(&rxc->blocked_sources, ETH_ADDR); 59 59 if (rc != EOK) { … … 84 84 * @param filters 85 85 */ 86 int nic_rxc_clear(nic_rxc_t *rxc)86 errno_t nic_rxc_clear(nic_rxc_t *rxc) 87 87 { 88 88 nic_addr_db_destroy(&rxc->unicast_addrs); … … 103 103 * 104 104 */ 105 int nic_rxc_set_addr(nic_rxc_t *rxc, const nic_address_t *prev_addr,105 errno_t nic_rxc_set_addr(nic_rxc_t *rxc, const nic_address_t *prev_addr, 106 106 const nic_address_t *curr_addr) 107 107 { 108 108 if (prev_addr != NULL) { 109 int rc = nic_addr_db_remove(&rxc->unicast_addrs,109 errno_t rc = nic_addr_db_remove(&rxc->unicast_addrs, 110 110 (const uint8_t *) &prev_addr->address); 111 111 if (rc != EOK) … … 173 173 * @return ENOMEM If there was not enough memory 174 174 */ 175 int nic_rxc_unicast_set_mode(nic_rxc_t *rxc, nic_unicast_mode_t mode,175 errno_t nic_rxc_unicast_set_mode(nic_rxc_t *rxc, nic_unicast_mode_t mode, 176 176 const nic_address_t *address_list, size_t address_count) 177 177 { … … 188 188 size_t i; 189 189 for (i = 0; i < address_count; ++i) { 190 int rc = nic_addr_db_insert(&rxc->unicast_addrs,190 errno_t rc = nic_addr_db_insert(&rxc->unicast_addrs, 191 191 (const uint8_t *) &address_list[i].address); 192 192 if (rc == ENOMEM) { … … 237 237 * @return ENOMEM If there was not enough memory 238 238 */ 239 int nic_rxc_multicast_set_mode(nic_rxc_t *rxc, nic_multicast_mode_t mode,239 errno_t nic_rxc_multicast_set_mode(nic_rxc_t *rxc, nic_multicast_mode_t mode, 240 240 const nic_address_t *address_list, size_t address_count) 241 241 { … … 251 251 size_t i; 252 252 for (i = 0; i < address_count; ++i) { 253 int rc = nic_addr_db_insert(&rxc->multicast_addrs,253 errno_t rc = nic_addr_db_insert(&rxc->multicast_addrs, 254 254 (const uint8_t *)&address_list[i].address); 255 255 if (rc == ENOMEM) { … … 279 279 * @return EOK On success 280 280 */ 281 int nic_rxc_broadcast_set_mode(nic_rxc_t *rxc, nic_broadcast_mode_t mode)281 errno_t nic_rxc_broadcast_set_mode(nic_rxc_t *rxc, nic_broadcast_mode_t mode) 282 282 { 283 283 rxc->broadcast_mode = mode; … … 320 320 * @return ENOMEM If there was not enough memory 321 321 */ 322 int nic_rxc_blocked_sources_set(nic_rxc_t *rxc,322 errno_t nic_rxc_blocked_sources_set(nic_rxc_t *rxc, 323 323 const nic_address_t *address_list, size_t address_count) 324 324 { … … 330 330 size_t i; 331 331 for (i = 0; i < address_count; ++i) { 332 int rc = nic_addr_db_insert(&rxc->blocked_sources,332 errno_t rc = nic_addr_db_insert(&rxc->blocked_sources, 333 333 (const uint8_t *) &address_list[i].address); 334 334 if (rc == ENOMEM) { … … 348 348 * @return ENOENT 349 349 */ 350 int nic_rxc_vlan_get_mask(const nic_rxc_t *rxc, nic_vlan_mask_t *mask)350 errno_t nic_rxc_vlan_get_mask(const nic_rxc_t *rxc, nic_vlan_mask_t *mask) 351 351 { 352 352 if (rxc->vlan_mask == NULL) { … … 366 366 * @return ENOMEM 367 367 */ 368 int nic_rxc_vlan_set_mask(nic_rxc_t *rxc, const nic_vlan_mask_t *mask)368 errno_t nic_rxc_vlan_set_mask(nic_rxc_t *rxc, const nic_vlan_mask_t *mask) 369 369 { 370 370 if (mask == NULL) { -
uspace/lib/nic/src/nic_wol_virtues.c
r36f0738 rb7fd2a0 71 71 * @return ENOMEM On not enough memory 72 72 */ 73 int nic_wol_virtues_init(nic_wol_virtues_t *wvs)73 errno_t nic_wol_virtues_init(nic_wol_virtues_t *wvs) 74 74 { 75 75 memset(wvs, 0, sizeof(nic_wol_virtues_t)); … … 124 124 * @return ENOTSUP This type is unknown 125 125 */ 126 int nic_wol_virtues_verify(nic_wv_type_t type, const void *data, size_t length)126 errno_t nic_wol_virtues_verify(nic_wv_type_t type, const void *data, size_t length) 127 127 { 128 128 switch (type) { … … 160 160 * @return ENOMEM Not enough memory to activate the virtue 161 161 */ 162 int nic_wol_virtues_add(nic_wol_virtues_t *wvs, nic_wol_virtue_t *virtue)162 errno_t nic_wol_virtues_add(nic_wol_virtues_t *wvs, nic_wol_virtue_t *virtue) 163 163 { 164 164 if (!nic_wv_is_multi(virtue->type) && … … 247 247 * @return EINVAL If the filter type is invalid 248 248 */ 249 int nic_wol_virtues_list(const nic_wol_virtues_t *wvs, nic_wv_type_t type,249 errno_t nic_wol_virtues_list(const nic_wol_virtues_t *wvs, nic_wv_type_t type, 250 250 size_t max_count, nic_wv_id_t *id_list, size_t *id_count) 251 251 {
Note:
See TracChangeset
for help on using the changeset viewer.