Changes in uspace/drv/nic/ne2k/dp8390.c [a88a6eac:80099c19] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/ne2k/dp8390.c
ra88a6eac r80099c19 59 59 #include <stdio.h> 60 60 #include <libarch/ddi.h> 61 #include <net/packet.h> 62 #include <packet_client.h> 61 63 #include "dp8390.h" 62 64 … … 74 76 uint8_t status; 75 77 76 /** Pointer to next frame*/78 /** Pointer to next packet */ 77 79 uint8_t next; 78 80 … … 140 142 static void ne2k_upload(ne2k_t *ne2k, void *buf, size_t addr, size_t size) 141 143 { 142 size_t esize_ru = (size + 1) & ~1;143 144 size_t esize = size & ~1; 144 145 145 pio_write_8(ne2k->port + DP_RBCR0, esize _ru& 0xff);146 pio_write_8(ne2k->port + DP_RBCR1, (esize _ru>> 8) & 0xff);146 pio_write_8(ne2k->port + DP_RBCR0, esize & 0xff); 147 pio_write_8(ne2k->port + DP_RBCR1, (esize >> 8) & 0xff); 147 148 pio_write_8(ne2k->port + DP_RSAR0, addr & 0xff); 148 149 pio_write_8(ne2k->port + DP_RSAR1, (addr >> 8) & 0xff); … … 391 392 /* 392 393 * Reset the transmit ring. If we were transmitting a frame, 393 * we pretend that the frameis processed. Higher layers will394 * retransmit if the framewasn't actually sent.394 * we pretend that the packet is processed. Higher layers will 395 * retransmit if the packet wasn't actually sent. 395 396 */ 396 397 ne2k->sq.dirty = false; … … 402 403 * 403 404 * @param[in,out] ne2k Network interface structure. 404 * @param[in] data Pointer to frame data 405 * @param[in] size Frame size in bytes 406 * 407 */ 408 void ne2k_send(nic_t *nic_data, void *data, size_t size) 405 * @param[in] packet Frame to be sent. 406 * 407 */ 408 void ne2k_send(nic_t *nic_data, packet_t *packet) 409 409 { 410 410 ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data); … … 418 418 fibril_condvar_wait(&ne2k->sq_cv, &ne2k->sq_mutex); 419 419 } 420 void *buf = packet_get_data(packet); 421 size_t size = packet_get_data_length(packet); 420 422 421 423 if ((size < ETH_MIN_PACK_SIZE) || (size > ETH_MAX_PACK_SIZE_TAGGED)) { … … 425 427 426 428 /* Upload the frame to the ethernet card */ 427 ne2k_upload(ne2k, data, ne2k->sq.page * DP_PAGE, size);429 ne2k_upload(ne2k, buf, ne2k->sq.page * DP_PAGE, size); 428 430 ne2k->sq.dirty = true; 429 431 ne2k->sq.size = size; … … 435 437 pio_write_8(ne2k->port + DP_CR, CR_TXP | CR_STA); 436 438 fibril_mutex_unlock(&ne2k->sq_mutex); 439 440 /* Relase packet */ 441 nic_release_packet(nic_data, packet); 437 442 } 438 443 … … 446 451 return NULL; 447 452 448 bzero(frame->data, length); 453 void *buf = packet_suffix(frame->packet, length); 454 bzero(buf, length); 449 455 uint8_t last = page + length / DP_PAGE; 450 456 … … 452 458 size_t left = (ne2k->stop_page - page) * DP_PAGE 453 459 - sizeof(recv_header_t); 454 ne2k_download(ne2k, frame->data, page * DP_PAGE + sizeof(recv_header_t),460 ne2k_download(ne2k, buf, page * DP_PAGE + sizeof(recv_header_t), 455 461 left); 456 ne2k_download(ne2k, frame->data+ left, ne2k->start_page * DP_PAGE,462 ne2k_download(ne2k, buf + left, ne2k->start_page * DP_PAGE, 457 463 length - left); 458 464 } else { 459 ne2k_download(ne2k, frame->data, page * DP_PAGE + sizeof(recv_header_t),465 ne2k_download(ne2k, buf, page * DP_PAGE + sizeof(recv_header_t), 460 466 length); 461 467 } … … 538 544 * Update the boundary pointer 539 545 * to the value of the page 540 * prior to the next frameto546 * prior to the next packet to 541 547 * be processed. 542 548 */ … … 581 587 fibril_mutex_lock(&ne2k->sq_mutex); 582 588 if (ne2k->sq.dirty) { 583 /* Prepare the buffer for next frame*/589 /* Prepare the buffer for next packet */ 584 590 ne2k->sq.dirty = false; 585 591 ne2k->sq.size = 0;
Note:
See TracChangeset
for help on using the changeset viewer.