Changeset 6d8455d in mainline


Ignore:
Timestamp:
2012-01-14T11:07:34Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f302586
Parents:
f991b6b
Message:

Eliminate packet_t from sending direction of NIC interface.

Location:
uspace
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/e1k/e1k.c

    rf991b6b r6d8455d  
    6767#define E1000_RECEIVE_ADDRESS  16
    6868
     69/** Maximum sending packet size */
     70#define E1000_MAX_SEND_FRAME_SIZE  2048
    6971/** Maximum receiving packet size */
    7072#define E1000_MAX_RECEIVE_PACKET_SIZE  2048
     
    125127        void *tx_ring_virt;
    126128       
    127         /** Packets in tx ring  */
    128         packet_t **tx_ring_packets;
     129        /** Ring of TX frames, physical address */
     130        void **tx_frame_phys;
     131        /** Ring of TX frames, virtual address */
     132        void **tx_frame_virt;
    129133       
    130134        /** Physical rx ring address */
     
    223227static int e1000_on_activating(nic_t *);
    224228static int e1000_on_stopping(nic_t *);
    225 static void e1000_write_packet(nic_t *, packet_t *);
     229static void e1000_send_frame(nic_t *, void *, size_t);
    226230
    227231/** Commands to deal with interrupt
     
    11261130            (e1000->tx_ring_virt + offset * sizeof(e1000_tx_descriptor_t));
    11271131       
    1128         if (tx_descriptor->length) {
    1129                 packet_t *old_packet = *(e1000->tx_ring_packets + offset);
    1130                 if (old_packet)
    1131                         nic_release_packet(nic, old_packet);
    1132         }
    1133        
    11341132        tx_descriptor->phys_addr = 0;
    11351133        tx_descriptor->length = 0;
     
    15221520static int e1000_initialize_tx_structure(e1000_t *e1000)
    15231521{
     1522        size_t i;
     1523       
    15241524        fibril_mutex_lock(&e1000->tx_lock);
     1525       
     1526        e1000->tx_ring_phys = NULL;
     1527        e1000->tx_ring_virt = NULL;
     1528        e1000->tx_frame_phys = NULL;
     1529        e1000->tx_frame_virt = NULL;
    15251530       
    15261531        int rc = dmamem_map_anonymous(
     
    15291534            &e1000->tx_ring_virt);
    15301535        if (rc != EOK)
    1531                 return rc;
     1536                goto error;
    15321537       
    15331538        bzero(e1000->tx_ring_virt,
    15341539            E1000_TX_PACKETS_COUNT * sizeof(e1000_tx_descriptor_t));
     1540       
     1541        e1000->tx_frame_phys = calloc(E1000_TX_PACKETS_COUNT, sizeof(void *));
     1542        e1000->tx_frame_virt = calloc(E1000_TX_PACKETS_COUNT, sizeof(void *));
     1543
     1544        if (e1000->tx_frame_phys == NULL || e1000->tx_frame_virt == NULL) {
     1545                rc = ENOMEM;
     1546                goto error;
     1547        }
     1548       
     1549        for (i = 0; i < E1000_TX_PACKETS_COUNT; i++) {
     1550                rc = dmamem_map_anonymous(
     1551                    E1000_MAX_SEND_FRAME_SIZE, AS_AREA_READ | AS_AREA_WRITE,
     1552                    0, &e1000->tx_frame_phys[i], &e1000->tx_frame_virt[i]);
     1553                if (rc != EOK)
     1554                        goto error;
     1555        }
    15351556       
    15361557        E1000_REG_WRITE(e1000, E1000_TDBAH,
     
    15391560            (uint32_t) PTR_TO_U64(e1000->tx_ring_phys));
    15401561       
    1541         e1000->tx_ring_packets =
    1542             malloc(E1000_TX_PACKETS_COUNT * sizeof(packet_t *));
    1543         // FIXME: Check return value
    1544        
    15451562        e1000_initialize_tx_registers(e1000);
    15461563       
    15471564        fibril_mutex_unlock(&e1000->tx_lock);
    15481565        return EOK;
     1566       
     1567error:
     1568        if (e1000->tx_ring_virt != NULL) {
     1569                dmamem_unmap_anonymous(e1000->tx_ring_virt);
     1570                e1000->tx_ring_virt = NULL;
     1571        }
     1572       
     1573        if (e1000->tx_frame_phys != NULL && e1000->tx_frame_virt != NULL) {
     1574                for (i = 0; i < E1000_TX_PACKETS_COUNT; i++) {
     1575                        if (e1000->tx_frame_virt[i] != NULL) {
     1576                                dmamem_unmap_anonymous(e1000->tx_frame_virt[i]);
     1577                                e1000->tx_frame_virt[i] = NULL;
     1578                                e1000->tx_frame_phys[i] = NULL;
     1579                        }
     1580                }
     1581        }
     1582       
     1583        if (e1000->tx_frame_phys != NULL) {
     1584                free(e1000->tx_frame_phys);
     1585                e1000->tx_frame_phys = NULL;
     1586        }
     1587       
     1588        if (e1000->tx_frame_virt != NULL) {
     1589                free(e1000->tx_frame_virt);
     1590                e1000->tx_frame_phys = NULL;
     1591        }
     1592       
     1593        return rc;
    15491594}
    15501595
     
    15561601static void e1000_uninitialize_tx_structure(e1000_t *e1000)
    15571602{
    1558         free(e1000->tx_ring_packets);
     1603        size_t i;
     1604       
     1605        for (i = 0; i < E1000_TX_PACKETS_COUNT; i++) {
     1606                dmamem_unmap_anonymous(e1000->tx_frame_virt[i]);
     1607                e1000->tx_frame_virt[i] = NULL;
     1608                e1000->tx_frame_phys[i] = NULL;
     1609        }
     1610       
     1611        if (e1000->tx_frame_phys != NULL) {
     1612                free(e1000->tx_frame_phys);
     1613                e1000->tx_frame_phys = NULL;
     1614        }
     1615       
     1616        if (e1000->tx_frame_virt != NULL) {
     1617                free(e1000->tx_frame_virt);
     1618                e1000->tx_frame_phys = NULL;
     1619        }
    15591620        dmamem_unmap_anonymous(e1000->tx_ring_virt);
    15601621}
     
    17711832       
    17721833        nic_set_specific(nic, e1000);
    1773         nic_set_write_packet_handler(nic, e1000_write_packet);
     1834        nic_set_send_frame_handler(nic, e1000_send_frame);
    17741835        nic_set_state_change_handlers(nic, e1000_on_activating,
    17751836            e1000_on_down, e1000_on_stopping);
     
    21902251}
    21912252
    2192 /** Send packet
     2253/** Send frame
    21932254 *
    21942255 * @param nic    NIC driver data structure
    2195  * @param packet Packet to send
     2256 * @param data   Frame data
     2257 * @param size   Frame size in bytes
    21962258 *
    21972259 * @return EOK if succeed
     
    21992261 *
    22002262 */
    2201 static void e1000_write_packet(nic_t *nic, packet_t *packet)
     2263static void e1000_send_frame(nic_t *nic, void *data, size_t size)
    22022264{
    22032265        assert(nic);
     
    22172279       
    22182280        /* Descriptor done */
    2219         if (tx_descriptor_addr->status & TXDESCRIPTOR_STATUS_DD) {
     2281        if (tx_descriptor_addr->status & TXDESCRIPTOR_STATUS_DD)
    22202282                descriptor_available = true;
    2221                 packet_t *old_packet = *(e1000->tx_ring_packets + tdt);
    2222                 if (old_packet) {
    2223                         size_t old_packet_size = packet_get_data_length(old_packet);
    2224                         nic_dma_unlock_packet(old_packet, old_packet_size);
    2225                         nic_release_packet(nic, old_packet);
    2226                 }
    2227         }
    22282283       
    22292284        if (!descriptor_available) {
     
    22332288        }
    22342289       
    2235         size_t packet_size = packet_get_data_length(packet);
    2236        
    2237         void *phys;
    2238         int rc = nic_dma_lock_packet(packet, packet_size, &phys);
    2239         if (rc != EOK) {
    2240                 fibril_mutex_unlock(&e1000->tx_lock);
    2241                 return;
    2242         }
    2243        
    2244         *(e1000->tx_ring_packets + tdt) = packet;
    2245        
    2246         tx_descriptor_addr->phys_addr =
    2247             PTR_TO_U64(phys + packet->data_start);
    2248         tx_descriptor_addr->length = packet_size;
     2290        memcpy(e1000->tx_frame_virt[tdt], data, size);
     2291       
     2292        tx_descriptor_addr->phys_addr = PTR_TO_U64(e1000->tx_frame_phys[tdt]);
     2293        tx_descriptor_addr->length = size;
    22492294       
    22502295        /*
  • uspace/drv/nic/lo/lo.c

    rf991b6b r6d8455d  
    5959};
    6060
    61 static void lo_write_packet(nic_t *nic_data, packet_t *packet)
     61static void lo_send_frame(nic_t *nic_data, void *data, size_t size)
    6262{
    63         nic_report_send_ok(nic_data, 1, packet_get_data_length(packet));
     63        packet_t *packet;
     64        int rc;
     65
     66        packet = nic_alloc_packet(nic_data, size);
     67        if (packet == NULL)
     68                return;
     69
     70        rc = packet_copy_data(packet, data, size);
     71        if (rc != EOK)
     72                return;
     73
     74        nic_report_send_ok(nic_data, 1, size);
    6475        nic_received_noneth_packet(nic_data, packet);
    6576}
     
    8899       
    89100        dev->driver_data = nic_data;
    90         nic_set_write_packet_handler(nic_data, lo_write_packet);
     101        nic_set_send_frame_handler(nic_data, lo_send_frame);
    91102       
    92103        int rc = nic_connect_to_services(nic_data);
  • uspace/drv/nic/ne2k/dp8390.c

    rf991b6b r6d8455d  
    404404 *
    405405 * @param[in,out] ne2k   Network interface structure.
    406  * @param[in]     packet Frame to be sent.
    407  *
    408  */
    409 void ne2k_send(nic_t *nic_data, packet_t *packet)
     406 * @param[in]     data   Pointer to frame data
     407 * @param[in]     size   Frame size in bytes
     408 *
     409 */
     410void ne2k_send(nic_t *nic_data, void *data, size_t size)
    410411{
    411412        ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
     
    419420                fibril_condvar_wait(&ne2k->sq_cv, &ne2k->sq_mutex);
    420421        }
    421         void *buf = packet_get_data(packet);
    422         size_t size = packet_get_data_length(packet);
    423422       
    424423        if ((size < ETH_MIN_PACK_SIZE) || (size > ETH_MAX_PACK_SIZE_TAGGED)) {
     
    428427
    429428        /* Upload the frame to the ethernet card */
    430         ne2k_upload(ne2k, buf, ne2k->sq.page * DP_PAGE, size);
     429        ne2k_upload(ne2k, data, ne2k->sq.page * DP_PAGE, size);
    431430        ne2k->sq.dirty = true;
    432431        ne2k->sq.size = size;
     
    438437        pio_write_8(ne2k->port + DP_CR, CR_TXP | CR_STA);
    439438        fibril_mutex_unlock(&ne2k->sq_mutex);
    440 
    441         /* Relase packet */
    442         nic_release_packet(nic_data, packet);
    443439}
    444440
  • uspace/drv/nic/ne2k/dp8390.h

    rf991b6b r6d8455d  
    262262extern int ne2k_up(ne2k_t *);
    263263extern void ne2k_down(ne2k_t *);
    264 extern void ne2k_send(nic_t *, packet_t *);
     264extern void ne2k_send(nic_t *, void *, size_t);
    265265extern void ne2k_interrupt(nic_t *, uint8_t, uint8_t);
    266266extern packet_t *ne2k_alloc_packet(nic_t *, size_t);
  • uspace/drv/nic/ne2k/ne2k.c

    rf991b6b r6d8455d  
    343343                return ENOMEM;
    344344       
    345         nic_set_write_packet_handler(nic_data, ne2k_send);
     345        nic_set_send_frame_handler(nic_data, ne2k_send);
    346346        nic_set_state_change_handlers(nic_data,
    347347                ne2k_on_activating, NULL, ne2k_on_stopping);
  • uspace/drv/nic/rtl8139/driver.c

    rf991b6b 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);
  • uspace/lib/c/generic/device/nic.c

    rf991b6b r6d8455d  
    4444#include <ipc/services.h>
    4545
    46 /** Send a packet through the device
    47  *
    48  * @param[in] dev_sess
    49  * @param[in] packet_id Id of the sent packet
    50  *
    51  * @return EOK If the operation was successfully completed
    52  *
    53  */
    54 int nic_send_message(async_sess_t *dev_sess, packet_id_t packet_id)
    55 {
    56         async_exch_t *exch = async_exchange_begin(dev_sess);
    57         int rc = async_req_2_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    58             NIC_SEND_MESSAGE, packet_id);
    59         async_exchange_end(exch);
    60        
    61         return rc;
     46/** Send frame from NIC
     47 *
     48 * @param[in] dev_sess
     49 * @param[in] data     Frame data
     50 * @param[in] size     Frame size in bytes
     51 *
     52 * @return EOK If the operation was successfully completed
     53 *
     54 */
     55int nic_send_frame(async_sess_t *dev_sess, void *data, size_t size)
     56{
     57        async_exch_t *exch = async_exchange_begin(dev_sess);
     58       
     59        ipc_call_t answer;
     60        aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     61            NIC_SEND_MESSAGE, &answer);
     62        sysarg_t retval = async_data_write_start(exch, data, size);
     63       
     64        async_exchange_end(exch);
     65       
     66        if (retval != EOK) {
     67                async_wait_for(req, NULL);
     68                return retval;
     69        }
     70
     71        async_wait_for(req, &retval);
     72        return retval;
    6273}
    6374
  • uspace/lib/c/include/device/nic.h

    rf991b6b r6d8455d  
    8585} nic_funcs_t;
    8686
    87 extern int nic_send_message(async_sess_t *, packet_id_t);
     87extern int nic_send_frame(async_sess_t *, void *, size_t);
    8888extern int nic_connect_to_nil(async_sess_t *, services_t, nic_device_id_t);
    8989extern int nic_get_state(async_sess_t *, nic_device_state_t *);
  • uspace/lib/drv/generic/remote_nic.c

    rf991b6b r6d8455d  
    3939#include <errno.h>
    4040#include <ipc/services.h>
    41 #include <adt/measured_strings.h>
    4241#include <sys/time.h>
    4342#include "ops/nic.h"
    4443
    45 static void remote_nic_send_message(ddf_fun_t *dev, void *iface,
    46     ipc_callid_t callid, ipc_call_t *call)
    47 {
    48         nic_iface_t *nic_iface = (nic_iface_t *) iface;
    49         assert(nic_iface->send_message);
    50        
    51         packet_id_t packet_id = (packet_id_t) IPC_GET_ARG2(*call);
    52        
    53         int rc = nic_iface->send_message(dev, packet_id);
    54         async_answer_0(callid, rc);
     44static void remote_nic_send_frame(ddf_fun_t *dev, void *iface,
     45    ipc_callid_t callid, ipc_call_t *call)
     46{
     47        nic_iface_t *nic_iface = (nic_iface_t *) iface;
     48        assert(nic_iface->send_frame);
     49       
     50        void *data;
     51        size_t size;
     52        int rc;
     53       
     54        rc = async_data_write_accept(&data, false, 0, 0, 0, &size);
     55        if (rc != EOK) {
     56                async_answer_0(callid, EINVAL);
     57                return;
     58        }
     59       
     60        rc = nic_iface->send_frame(dev, data, size);
     61        async_answer_0(callid, rc);
     62        free(data);
    5563}
    5664
     
    11941202 */
    11951203static remote_iface_func_ptr_t remote_nic_iface_ops[] = {
    1196         &remote_nic_send_message,
     1204        &remote_nic_send_frame,
    11971205        &remote_nic_connect_to_nil,
    11981206        &remote_nic_get_state,
  • uspace/lib/drv/include/ops/nic.h

    rf991b6b r6d8455d  
    3737#define LIBDRV_OPS_NIC_H_
    3838
    39 #include <net/packet.h>
    4039#include <ipc/services.h>
    4140#include <net/device.h>
     
    4645typedef struct nic_iface {
    4746        /** Mandatory methods */
    48         int (*send_message)(ddf_fun_t *, packet_id_t);
     47        int (*send_frame)(ddf_fun_t *, void *, size_t);
    4948        int (*connect_to_nil)(ddf_fun_t *, services_t, nic_device_id_t);
    5049        int (*get_state)(ddf_fun_t *, nic_device_state_t *);
  • uspace/lib/nic/include/nic.h

    rf991b6b r6d8455d  
    7777 *
    7878 * @param nic_data
    79  * @param packet        Pointer to the packet to be sent
    80  */
    81 typedef void (*write_packet_handler)(nic_t *, packet_t *);
     79 * @param data          Pointer to frame data
     80 * @param size          Size of frame data in bytes
     81 */
     82typedef void (*send_frame_handler)(nic_t *, void *, size_t);
    8283/**
    8384 * The handler for transitions between driver states.
     
    206207extern int nic_get_resources(nic_t *, hw_res_list_parsed_t *);
    207208extern void nic_set_specific(nic_t *, void *);
    208 extern void nic_set_write_packet_handler(nic_t *, write_packet_handler);
     209extern void nic_set_send_frame_handler(nic_t *, send_frame_handler);
    209210extern void nic_set_state_change_handlers(nic_t *,
    210211        state_change_handler, state_change_handler, state_change_handler);
  • uspace/lib/nic/include/nic_driver.h

    rf991b6b r6d8455d  
    134134         * Called with the main_lock locked for reading.
    135135         */
    136         write_packet_handler write_packet;
     136        send_frame_handler send_frame;
    137137        /**
    138138         * Event handler called when device goes to the ACTIVE state.
  • uspace/lib/nic/include/nic_impl.h

    rf991b6b r6d8455d  
    4848
    4949extern int nic_get_address_impl(ddf_fun_t *dev_fun, nic_address_t *address);
    50 extern int nic_send_message_impl(ddf_fun_t *dev_fun, packet_id_t packet_id);
     50extern int nic_send_frame_impl(ddf_fun_t *dev_fun, void *data, size_t size);
    5151extern int nic_connect_to_nil_impl(ddf_fun_t *dev_fun, services_t nil_service,
    5252        int device_id);
  • uspace/lib/nic/src/nic_driver.c

    rf991b6b r6d8455d  
    114114                if (!iface->set_state)
    115115                        iface->set_state = nic_set_state_impl;
    116                 if (!iface->send_message)
    117                         iface->send_message = nic_send_message_impl;
     116                if (!iface->send_frame)
     117                        iface->send_frame = nic_send_frame_impl;
    118118                if (!iface->connect_to_nil)
    119119                        iface->connect_to_nil = nic_connect_to_nil_impl;
     
    168168 *
    169169 * @param nic_data
    170  * @param wpfunc                Function handling the write_packet request
    171  */
    172 void nic_set_write_packet_handler(nic_t *nic_data, write_packet_handler wpfunc)
    173 {
    174         nic_data->write_packet = wpfunc;
     170 * @param sffunc        Function handling the send_frame request
     171 */
     172void nic_set_send_frame_handler(nic_t *nic_data, send_frame_handler sffunc)
     173{
     174        nic_data->send_frame = sffunc;
    175175}
    176176
     
    765765        nic_data->poll_mode = NIC_POLL_IMMEDIATE;
    766766        nic_data->default_poll_mode = NIC_POLL_IMMEDIATE;
    767         nic_data->write_packet = NULL;
     767        nic_data->send_frame = NULL;
    768768        nic_data->on_activating = NULL;
    769769        nic_data->on_going_down = NULL;
  • uspace/lib/nic/src/nic_impl.c

    rf991b6b r6d8455d  
    3939#include <ipc/services.h>
    4040#include <ns.h>
    41 #include <packet_client.h>
    42 #include <packet_remote.h>
    4341#include "nic_driver.h"
    4442#include "nic_impl.h"
     
    159157
    160158/**
    161  * Default implementation of the send_message method.
     159 * Default implementation of the send_frame method.
    162160 * Send messages to the network.
    163161 *
    164162 * @param       fun
    165  * @param       packet_id       ID of the first packet in a queue of sent packets
     163 * @param       data    Frame data
     164 * @param       size    Frame size in bytes
    166165 *
    167166 * @return EOK          If the message was sent
    168  * @return EBUSY        If the device is not in state when the packet can be set.
    169  * @return EINVAL       If the packet ID is invalid
    170  */
    171 int nic_send_message_impl(ddf_fun_t *fun, packet_id_t packet_id)
    172 {
    173         nic_t *nic_data = (nic_t *) fun->driver_data;
    174         packet_t *packet, *next;
     167 * @return EBUSY        If the device is not in state when the frame can be sent.
     168 */
     169int nic_send_frame_impl(ddf_fun_t *fun, void *data, size_t size)
     170{
     171        nic_t *nic_data = (nic_t *) fun->driver_data;
    175172
    176173        fibril_rwlock_read_lock(&nic_data->main_lock);
    177174        if (nic_data->state != NIC_STATE_ACTIVE || nic_data->tx_busy) {
    178175                fibril_rwlock_read_unlock(&nic_data->main_lock);
    179                 pq_release_remote(nic_data->net_session, packet_id);
    180176                return EBUSY;
    181177        }
    182178
    183         int rc = packet_translate_remote(nic_data->net_session, &packet, packet_id);
    184 
    185         if (rc != EOK) {
    186                 fibril_rwlock_read_unlock(&nic_data->main_lock);
    187                 return EINVAL;
    188         }
    189 
    190         /*
    191          * Process the packet queue. Each sent packet must be detached from the
    192          * queue and destroyed. This is why the cycle differs from loopback's
    193          * cycle, where the packets are immediately used in upper layers and
    194          * therefore they must not be destroyed (released).
    195          */
    196         assert(nic_data->write_packet != NULL);
    197         do {
    198                 next = pq_detach(packet);
    199                 nic_data->write_packet(nic_data, packet);
    200                 packet = next;
    201         } while (packet);
    202         fibril_rwlock_read_unlock(&nic_data->main_lock);
     179        nic_data->send_frame(nic_data, data, size);
    203180        return EOK;
    204181}
  • uspace/srv/net/nil/eth/eth.c

    rf991b6b r6d8455d  
    802802                        next = tmp;
    803803                } else {
     804                        nic_send_frame(device->sess, packet_get_data(next),
     805                            packet_get_data_length(next));
    804806                        next = pq_next(next);
    805807                }
    806808        } while (next);
    807809       
    808         /* Send packet queue */
    809         if (packet)
    810                 nic_send_message(device->sess, packet_get_id(packet));
     810        pq_release_remote(eth_globals.net_sess, packet_get_id(packet));
    811811       
    812812        fibril_rwlock_read_unlock(&eth_globals.devices_lock);
  • uspace/srv/net/nil/nildummy/nildummy.c

    rf991b6b r6d8455d  
    345345    services_t sender)
    346346{
     347        packet_t *p;
     348       
    347349        fibril_rwlock_read_lock(&nildummy_globals.devices_lock);
    348350       
     
    354356        }
    355357       
    356         /* Send packet queue */
    357         if (packet)
    358                 nic_send_message(device->sess, packet_get_id(packet));
     358        p = packet;
     359        do {
     360                nic_send_frame(device->sess, packet_get_data(p),
     361                    packet_get_data_length(p));
     362                p = pq_next(p);
     363        } while (p != NULL);
     364       
     365        pq_release_remote(nildummy_globals.net_sess, packet_get_id(packet));
    359366       
    360367        fibril_rwlock_read_unlock(&nildummy_globals.devices_lock);
Note: See TracChangeset for help on using the changeset viewer.