Changeset 7943c43 in mainline for uspace/lib/nic/src/nic_impl.c


Ignore:
Timestamp:
2012-01-16T22:45:38Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
32817cc, 3fe58d3c
Parents:
9117ef9b (diff), 3ea725e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/nic/src/nic_impl.c

    r9117ef9b r7943c43  
    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.