Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/rtl8139/driver.c

    rf0b74b2 r6d8455d  
    389389static int rtl8139_on_activated(nic_t *nic_data);
    390390static int rtl8139_on_stopped(nic_t *nic_data);
    391 static void rtl8139_write_packet(nic_t *nic_data, packet_t *packet);
     391static void rtl8139_send_frame(nic_t *nic_data, void *data, size_t size);
    392392
    393393/** Check if the transmit buffer is busy */
     
    399399 *
    400400 * @param nic_data  The nic driver data structure
    401  * @param packet    The packet to send
     401 * @param data      Frame data
     402 * @param size      Frame size in bytes
    402403 *
    403404 * @return EOK if succeed, error code in the case of error
    404405 */
    405 static void rtl8139_write_packet(nic_t *nic_data, packet_t *packet)
     406static void rtl8139_send_frame(nic_t *nic_data, void *data, size_t size)
    406407{
    407408        assert(nic_data);
     
    409410        rtl8139_t *rtl8139 = nic_get_specific(nic_data);
    410411        assert(rtl8139);
    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);
     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);
    422417                nic_report_send_error(rtl8139->nic_data, NIC_SEC_OTHER, 1);
    423418                goto err_size;
    424419        }
    425420
    426         assert((packet_length & TSD_SIZE_MASK) == packet_length);
     421        assert((size & TSD_SIZE_MASK) == size);
    427422
    428423        /* Lock transmitter structure for obtaining next buffer */
     
    449444        assert(!rtl8139_tbuf_busy(tsd));
    450445
    451         /* Write packet data to the buffer, set the size to TSD and clear OWN bit */
    452         memcpy(buf_addr, packet_data, packet_length);
     446        /* Write frame data to the buffer, set the size to TSD and clear OWN bit */
     447        memcpy(buf_addr, data, size);
    453448
    454449        /* Set size of the data to send */
    455450        uint32_t tsd_value = pio_read_32(tsd);
    456         tsd_value = rtl8139_tsd_set_size(tsd_value, packet_length);
     451        tsd_value = rtl8139_tsd_set_size(tsd_value, size);
    457452        pio_write_32(tsd, tsd_value);
    458453
     
    462457        tsd_value &= ~(uint32_t)TSD_OWN;
    463458        pio_write_32(tsd, tsd_value);
    464         nic_release_packet(nic_data, packet);
    465459        return;
    466460
    467461err_busy_no_inc:
    468462err_size:
    469         nic_release_packet(nic_data, packet);
    470463        return;
    471464};
     
    10221015        rtl8139->nic_data = nic_data;
    10231016        nic_set_specific(nic_data, rtl8139);
    1024         nic_set_write_packet_handler(nic_data, rtl8139_write_packet);
     1017        nic_set_send_frame_handler(nic_data, rtl8139_send_frame);
    10251018        nic_set_state_change_handlers(nic_data,
    10261019                rtl8139_on_activated, NULL, rtl8139_on_stopped);
Note: See TracChangeset for help on using the changeset viewer.