Changes in uspace/drv/nic/rtl8139/driver.c [6d8455d:f0b74b2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/rtl8139/driver.c
r6d8455d rf0b74b2 389 389 static int rtl8139_on_activated(nic_t *nic_data); 390 390 static int rtl8139_on_stopped(nic_t *nic_data); 391 static void rtl8139_ send_frame(nic_t *nic_data, void *data, size_t size);391 static void rtl8139_write_packet(nic_t *nic_data, packet_t *packet); 392 392 393 393 /** Check if the transmit buffer is busy */ … … 399 399 * 400 400 * @param nic_data The nic driver data structure 401 * @param data Frame data 402 * @param size Frame size in bytes 401 * @param packet The packet to send 403 402 * 404 403 * @return EOK if succeed, error code in the case of error 405 404 */ 406 static void rtl8139_ send_frame(nic_t *nic_data, void *data, size_t size)405 static void rtl8139_write_packet(nic_t *nic_data, packet_t *packet) 407 406 { 408 407 assert(nic_data); … … 410 409 rtl8139_t *rtl8139 = nic_get_specific(nic_data); 411 410 assert(rtl8139); 412 ddf_msg(LVL_DEBUG, "Sending frame"); 413 414 if (size > RTL8139_PACKET_MAX_LENGTH) { 415 ddf_msg(LVL_ERROR, "Send frame: frame too long, %zu bytes", 416 size); 411 ddf_msg(LVL_DEBUG, "Sending packet"); 412 413 /* Get the packet data and check if it can be send */ 414 size_t packet_length = packet_get_data_length(packet); 415 void *packet_data = packet_get_data(packet); 416 417 assert(packet_data); 418 419 if ((packet_length > RTL8139_PACKET_MAX_LENGTH) || !packet_data) { 420 ddf_msg(LVL_ERROR, "Write packet length error: data %p, length %z", 421 packet_data, packet_length); 417 422 nic_report_send_error(rtl8139->nic_data, NIC_SEC_OTHER, 1); 418 423 goto err_size; 419 424 } 420 425 421 assert(( size & TSD_SIZE_MASK) == size);426 assert((packet_length & TSD_SIZE_MASK) == packet_length); 422 427 423 428 /* Lock transmitter structure for obtaining next buffer */ … … 444 449 assert(!rtl8139_tbuf_busy(tsd)); 445 450 446 /* Write framedata to the buffer, set the size to TSD and clear OWN bit */447 memcpy(buf_addr, data, size);451 /* Write packet data to the buffer, set the size to TSD and clear OWN bit */ 452 memcpy(buf_addr, packet_data, packet_length); 448 453 449 454 /* Set size of the data to send */ 450 455 uint32_t tsd_value = pio_read_32(tsd); 451 tsd_value = rtl8139_tsd_set_size(tsd_value, size);456 tsd_value = rtl8139_tsd_set_size(tsd_value, packet_length); 452 457 pio_write_32(tsd, tsd_value); 453 458 … … 457 462 tsd_value &= ~(uint32_t)TSD_OWN; 458 463 pio_write_32(tsd, tsd_value); 464 nic_release_packet(nic_data, packet); 459 465 return; 460 466 461 467 err_busy_no_inc: 462 468 err_size: 469 nic_release_packet(nic_data, packet); 463 470 return; 464 471 }; … … 1015 1022 rtl8139->nic_data = nic_data; 1016 1023 nic_set_specific(nic_data, rtl8139); 1017 nic_set_ send_frame_handler(nic_data, rtl8139_send_frame);1024 nic_set_write_packet_handler(nic_data, rtl8139_write_packet); 1018 1025 nic_set_state_change_handlers(nic_data, 1019 1026 rtl8139_on_activated, NULL, rtl8139_on_stopped);
Note:
See TracChangeset
for help on using the changeset viewer.