Changeset a35b458 in mainline for uspace/lib/nic/src/nic_driver.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_driver.c
r3061bc1 ra35b458 68 68 nic_globals.frame_cache_size = 0; 69 69 fibril_mutex_initialize(&nic_globals.lock); 70 70 71 71 char buffer[256]; 72 72 snprintf(buffer, 256, "drv/" DEVICE_CATEGORY_NIC "/%s", name); 73 73 74 74 return EOK; 75 75 } … … 247 247 ddf_dev_t *dev = nic_data->dev; 248 248 async_sess_t *parent_sess; 249 249 250 250 /* Connect to the parent's driver. */ 251 251 parent_sess = ddf_dev_parent_sess_get(dev); 252 252 if (parent_sess == NULL) 253 253 return EIO; 254 254 255 255 return hw_res_get_list_parsed(parent_sess, resources, 0); 256 256 } … … 277 277 if (!frame) 278 278 return NULL; 279 279 280 280 link_initialize(&frame->link); 281 281 } … … 327 327 nic_frame_list_t *frames; 328 328 fibril_mutex_lock(&nic_globals.lock); 329 329 330 330 if (nic_globals.frame_list_cache_size > 0) { 331 331 frames = … … 338 338 } else { 339 339 fibril_mutex_unlock(&nic_globals.lock); 340 340 341 341 frames = malloc(sizeof (nic_frame_list_t)); 342 342 if (frames != NULL) 343 343 list_initialize(frames); 344 344 } 345 345 346 346 return frames; 347 347 } … … 426 426 { 427 427 assert(nic_data); 428 428 429 429 if (address->address[0] & 1) 430 430 return EINVAL; 431 431 432 432 fibril_rwlock_write_lock(&nic_data->main_lock); 433 433 434 434 /* Notify NIL layer (and uppper) if bound - not in add_device */ 435 435 if (nic_data->client_session != NULL) { … … 442 442 } 443 443 } 444 444 445 445 fibril_rwlock_write_lock(&nic_data->rxc_lock); 446 446 447 447 /* 448 448 * The initial address (all zeroes) shouldn't be … … 452 452 errno_t rc = nic_rxc_set_addr(&nic_data->rx_control, 453 453 &nic_data->mac, address); 454 454 455 455 /* For the first time also record the default MAC */ 456 456 if (MAC_IS_ZERO(nic_data->default_mac.address)) { … … 458 458 memcpy(&nic_data->default_mac, address, sizeof(nic_address_t)); 459 459 } 460 460 461 461 fibril_rwlock_write_unlock(&nic_data->rxc_lock); 462 462 463 463 if ((rc != EOK) && (rc != ENOENT)) { 464 464 fibril_rwlock_write_unlock(&nic_data->main_lock); 465 465 return rc; 466 466 } 467 467 468 468 memcpy(&nic_data->mac, address, sizeof(nic_address_t)); 469 469 470 470 fibril_rwlock_write_unlock(&nic_data->main_lock); 471 471 472 472 return EOK; 473 473 } … … 593 593 if (nic_data == NULL) 594 594 return NULL; 595 595 596 596 /* Force zero to all uninitialized fields (e.g. added in future) */ 597 597 if (nic_rxc_init(&nic_data->rx_control) != EOK) { 598 598 return NULL; 599 599 } 600 600 601 601 if (nic_wol_virtues_init(&nic_data->wol_virtues) != EOK) { 602 602 return NULL; 603 603 } 604 604 605 605 nic_data->dev = NULL; 606 606 nic_data->fun = NULL; … … 614 614 nic_data->on_stopping = NULL; 615 615 nic_data->specific = NULL; 616 616 617 617 fibril_rwlock_initialize(&nic_data->main_lock); 618 618 fibril_rwlock_initialize(&nic_data->stats_lock); 619 619 fibril_rwlock_initialize(&nic_data->rxc_lock); 620 620 fibril_rwlock_initialize(&nic_data->wv_lock); 621 621 622 622 memset(&nic_data->mac, 0, sizeof(nic_address_t)); 623 623 memset(&nic_data->default_mac, 0, sizeof(nic_address_t)); 624 624 memset(&nic_data->stats, 0, sizeof(nic_device_stats_t)); 625 625 626 626 return nic_data; 627 627 } … … 642 642 if (!nic_data) 643 643 return NULL; 644 644 645 645 nic_data->dev = device; 646 646 647 647 return nic_data; 648 648 } … … 943 943 if (count == 0) 944 944 return; 945 945 946 946 fibril_rwlock_write_lock(&nic_data->stats_lock); 947 947 nic_data->stats.send_errors += count; … … 1079 1079 } 1080 1080 async_usleep(wait); 1081 1081 1082 1082 /* Check if the period was not reset */ 1083 1083 if (info->run != run) 1084 1084 break; 1085 1085 } 1086 1086 1087 1087 /* Provide polling if the period finished */ 1088 1088 fibril_rwlock_read_lock(&nic->main_lock);
Note:
See TracChangeset
for help on using the changeset viewer.