Changeset 6d8455d in mainline for uspace/lib/nic


Ignore:
Timestamp:
2012-01-14T11:07:34Z (14 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/lib/nic
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.