Changeset 3bacee1 in mainline for uspace/lib/nic/src/nic_impl.c
- Timestamp:
- 2018-04-12T16:27:17Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3cf22f9
- Parents:
- 76d0981d
- git-author:
- Jiri Svoboda <jiri@…> (2018-04-11 19:25:33)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-04-12 16:27:17)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_impl.c
r76d0981d r3bacee1 118 118 /* Notify upper layers that we are reseting the MAC */ 119 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; 122 122 memcpy(&nic_data->poll_period, &nic_data->default_poll_period, 123 sizeof(struct timeval));123 sizeof(struct timeval)); 124 124 if (rc != EOK) { 125 125 /* We have already ran the on stopped handler, even if we … … 136 136 /* Reinsert device's default MAC */ 137 137 nic_rxc_set_addr(&nic_data->rx_control, NULL, 138 138 &nic_data->default_mac); 139 139 fibril_rwlock_write_unlock(&nic_data->rxc_lock); 140 140 memcpy(&nic_data->mac, &nic_data->default_mac, sizeof (nic_address_t)); … … 258 258 */ 259 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 { 262 262 nic_t *nic_data = nic_get_from_ddf_fun(fun); 263 263 fibril_rwlock_read_lock(&nic_data->rxc_lock); 264 264 nic_rxc_unicast_get_mode(&nic_data->rx_control, mode, max_count, 265 265 addr_list, addr_count); 266 266 fibril_rwlock_read_unlock(&nic_data->rxc_lock); 267 267 return EOK; … … 282 282 */ 283 283 errno_t nic_unicast_set_mode_impl(ddf_fun_t *fun, 284 285 { 286 assert((addr_count == 0 && addr_list == NULL) 287 ||(addr_count != 0 && addr_list != NULL));284 nic_unicast_mode_t mode, const nic_address_t *addr_list, size_t addr_count) 285 { 286 assert((addr_count == 0 && addr_list == NULL) || 287 (addr_count != 0 && addr_list != NULL)); 288 288 size_t i; 289 289 for (i = 0; i < addr_count; ++i) { … … 297 297 if (nic_data->on_unicast_mode_change) { 298 298 rc = nic_data->on_unicast_mode_change(nic_data, 299 299 mode, addr_list, addr_count); 300 300 } 301 301 if (rc == EOK) { 302 302 rc = nic_rxc_unicast_set_mode(&nic_data->rx_control, mode, 303 303 addr_list, addr_count); 304 304 /* After changing the mode the addr db gets cleared, therefore we have 305 305 * to reinsert also the physical address of NIC. … … 325 325 */ 326 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 { 329 329 nic_t *nic_data = nic_get_from_ddf_fun(fun); 330 330 fibril_rwlock_read_lock(&nic_data->rxc_lock); 331 331 nic_rxc_multicast_get_mode(&nic_data->rx_control, mode, max_count, 332 332 addr_list, addr_count); 333 333 fibril_rwlock_read_unlock(&nic_data->rxc_lock); 334 334 return EOK; … … 349 349 */ 350 350 errno_t nic_multicast_set_mode_impl(ddf_fun_t *fun, nic_multicast_mode_t mode, 351 352 { 353 assert((addr_count == 0 && addr_list == NULL) 354 ||(addr_count != 0 && addr_list != NULL));351 const nic_address_t *addr_list, size_t addr_count) 352 { 353 assert((addr_count == 0 && addr_list == NULL) || 354 (addr_count != 0 && addr_list != NULL)); 355 355 size_t i; 356 356 for (i = 0; i < addr_count; ++i) { … … 367 367 if (rc == EOK) { 368 368 rc = nic_rxc_multicast_set_mode(&nic_data->rx_control, mode, 369 369 addr_list, addr_count); 370 370 } 371 371 fibril_rwlock_write_unlock(&nic_data->rxc_lock); … … 428 428 */ 429 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 { 432 432 nic_t *nic_data = nic_get_from_ddf_fun(fun); 433 433 fibril_rwlock_read_lock(&nic_data->rxc_lock); 434 434 nic_rxc_blocked_sources_get(&nic_data->rx_control, 435 435 max_count, addr_list, addr_count); 436 436 fibril_rwlock_read_unlock(&nic_data->rxc_lock); 437 437 return EOK; … … 451 451 */ 452 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 { 455 455 nic_t *nic_data = nic_get_from_ddf_fun(fun); … … 459 459 } 460 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); 463 463 return rc; … … 519 519 */ 520 520 errno_t nic_wol_virtue_add_impl(ddf_fun_t *fun, nic_wv_type_t type, 521 522 { 523 nic_t *nic_data = nic_get_from_ddf_fun(fun); 524 if (nic_data->on_wol_virtue_add == NULL 525 ||nic_data->on_wol_virtue_remove == NULL) {521 const void *data, size_t length, nic_wv_id_t *new_id) 522 { 523 nic_t *nic_data = nic_get_from_ddf_fun(fun); 524 if (nic_data->on_wol_virtue_add == NULL || 525 nic_data->on_wol_virtue_remove == NULL) { 526 526 return ENOTSUP; 527 527 } … … 555 555 } 556 556 if ((int) nic_data->wol_virtues.lists_sizes[type] >= 557 557 nic_data->wol_virtues.caps_max[type]) { 558 558 fibril_rwlock_write_unlock(&nic_data->wv_lock); 559 559 return ELIMIT; … … 596 596 { 597 597 nic_t *nic_data = nic_get_from_ddf_fun(fun); 598 if (nic_data->on_wol_virtue_add == NULL 599 ||nic_data->on_wol_virtue_remove == NULL) {598 if (nic_data->on_wol_virtue_add == NULL || 599 nic_data->on_wol_virtue_remove == NULL) { 600 600 return ENOTSUP; 601 601 } 602 602 fibril_rwlock_write_lock(&nic_data->wv_lock); 603 603 nic_wol_virtue_t *virtue = 604 604 nic_wol_virtues_remove(&nic_data->wol_virtues, id); 605 605 if (virtue == NULL) { 606 606 fibril_rwlock_write_unlock(&nic_data->wv_lock); … … 630 630 */ 631 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 { 634 634 nic_t *nic_data = nic_get_from_ddf_fun(fun); 635 635 fibril_rwlock_read_lock(&nic_data->wv_lock); 636 636 const nic_wol_virtue_t *virtue = 637 637 nic_wol_virtues_find(&nic_data->wol_virtues, id); 638 638 if (virtue == NULL) { 639 639 *type = NIC_WV_NONE; … … 668 668 */ 669 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 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); 677 677 return rc; … … 692 692 nic_t *nic_data = nic_get_from_ddf_fun(fun); 693 693 fibril_rwlock_read_lock(&nic_data->wv_lock); 694 *count = nic_data->wol_virtues.caps_max[type] 695 -(int) nic_data->wol_virtues.lists_sizes[type];694 *count = nic_data->wol_virtues.caps_max[type] - 695 (int) nic_data->wol_virtues.lists_sizes[type]; 696 696 fibril_rwlock_read_unlock(&nic_data->wv_lock); 697 697 return EOK; … … 711 711 */ 712 712 errno_t nic_poll_get_mode_impl(ddf_fun_t *fun, 713 713 nic_poll_mode_t *mode, struct timeval *period) 714 714 { 715 715 nic_t *nic_data = nic_get_from_ddf_fun(fun); 716 716 fibril_rwlock_read_lock(&nic_data->main_lock); 717 717 *mode = nic_data->poll_mode; 718 memcpy(period, &nic_data->poll_period, sizeof 718 memcpy(period, &nic_data->poll_period, sizeof(struct timeval)); 719 719 fibril_rwlock_read_unlock(&nic_data->main_lock); 720 720 return EOK; … … 734 734 */ 735 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 { 738 738 nic_t *nic_data = nic_get_from_ddf_fun(fun); … … 757 757 assert(rc == EOK || rc == ENOTSUP || rc == EINVAL); 758 758 if (rc == ENOTSUP && (nic_data->on_poll_request != NULL) && 759 (mode == NIC_POLL_PERIODIC || mode == NIC_POLL_SOFTWARE_PERIODIC) 759 (mode == NIC_POLL_PERIODIC || mode == NIC_POLL_SOFTWARE_PERIODIC)) { 760 760 761 761 rc = nic_data->on_poll_mode_change(nic_data, NIC_POLL_ON_DEMAND, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.