Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ea788701 in mainline


Ignore:
Timestamp:
2012-01-19T18:14:48Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
321052f7
Parents:
d8da56b
Message:

Remove use of packet_t in NIC framework.

Location:
uspace
Files:
5 edited

Legend:

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

    rd8da56b rea788701  
    4242#include <async.h>
    4343#include <nic.h>
    44 #include <packet_client.h>
    4544
    4645#define NAME  "lo"
     
    6160static void lo_send_frame(nic_t *nic_data, void *data, size_t size)
    6261{
    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 
    7462        nic_report_send_ok(nic_data, 1, size);
    75         nic_received_noneth_packet(nic_data, packet);
     63        nic_received_noneth_frame(nic_data, data, size);
    7664}
    7765
  • uspace/drv/nic/ne2k/dp8390.h

    rd8da56b rea788701  
    264264extern void ne2k_send(nic_t *, void *, size_t);
    265265extern void ne2k_interrupt(nic_t *, uint8_t, uint8_t);
    266 extern packet_t *ne2k_alloc_packet(nic_t *, size_t);
    267266
    268267extern void ne2k_set_accept_mcast(ne2k_t *, int);
  • uspace/lib/nic/include/nic.h

    rd8da56b rea788701  
    4242#include <ddf/driver.h>
    4343#include <device/hw_res_parsed.h>
    44 #include <net/packet.h>
    4544#include <ops/nic.h>
    4645
     
    7271
    7372/**
    74  * Handler for writing packet data to the NIC device.
    75  * The function is responsible for releasing the packet.
     73 * Handler for writing frame data to the NIC device.
     74 * The function is responsible for releasing the frame.
    7675 * It does not return anything, if some error is detected the function just
    7776 * silently fails (logging on debug level is suggested).
     
    159158 * @return ENOTSUP      If this filter cannot work on this NIC (e.g. the NIC
    160159 *                                      cannot run in promiscuous node or the limit of WOL
    161  *                                      packets' specifications was reached).
     160 *                                      frames' specifications was reached).
    162161 * @return ELIMIT       If this filter must implemented in HW but currently the
    163162 *                                      limit of these HW filters was reached.
     
    234233extern int nic_report_poll_mode(nic_t *, nic_poll_mode_t, struct timeval *);
    235234extern void nic_query_address(nic_t *, nic_address_t *);
    236 extern void nic_received_noneth_packet(nic_t *, packet_t *);
     235extern void nic_received_noneth_frame(nic_t *, void *, size_t);
    237236extern void nic_received_frame(nic_t *, nic_frame_t *);
    238237extern void nic_received_frame_list(nic_t *, nic_frame_list_t *);
     
    248247extern void nic_report_collisions(nic_t *, unsigned);
    249248
    250 /* Packet / frame / frame list allocation and deallocation */
    251 extern packet_t *nic_alloc_packet(nic_t *, size_t);
    252 extern void nic_release_packet(nic_t *, packet_t *);
     249/* Frame / frame list allocation and deallocation */
    253250extern nic_frame_t *nic_alloc_frame(nic_t *, size_t);
    254251extern nic_frame_list_t *nic_alloc_frame_list(void);
     
    275272extern void nic_sw_period_stop(nic_t *);
    276273
    277 /* Packet DMA lock */
    278 extern int nic_dma_lock_packet(packet_t *, size_t, void **);
    279 extern int nic_dma_unlock_packet(packet_t *, size_t);
    280 
    281274#endif // __NIC_H__
    282275
  • uspace/lib/nic/include/nic_rx_control.h

    rd8da56b rea788701  
    4646#include <fibril_synch.h>
    4747#include <net/device.h>
    48 #include <net/packet_header.h>
    4948
    5049#include "nic_addr_db.h"
  • uspace/lib/nic/src/nic_driver.c

    rd8da56b rea788701  
    5151#include <net_interface.h>
    5252#include <ops/nic.h>
    53 #include <packet_client.h>
    54 #include <packet_remote.h>
    55 #include <net/packet_header.h>
    5653#include <errno.h>
    5754
     
    6461
    6562/**
    66  * Initializes libraries required for NIC framework - logger, packet manager
     63 * Initializes libraries required for NIC framework - logger
    6764 *
    6865 * @param name  Name of the device/driver (used in logging)
     
    7976        snprintf(buffer, 256, "drv/" DEVICE_CATEGORY_NIC "/%s", name);
    8077       
    81         /* Initialize packet manager */
    82         return pm_init();
     78        return EOK;
    8379}
    8480
     
    162158
    163159/**
    164  * Setup write packet handler. This MUST be called in the add_device handler
     160 * Setup send frame handler. This MUST be called in the add_device handler
    165161 * if the nic_send_message_impl function is used for sending messages (filled
    166162 * as send_message member of the nic_iface_t structure). The function must not
     
    270266}
    271267
    272 /**
    273  * Just a wrapper over the packet_get_1_remote function
    274  */
    275 packet_t *nic_alloc_packet(nic_t *nic_data, size_t data_size)
    276 {
    277         return packet_get_1_remote(nic_data->net_session, data_size);
    278 }
    279 
    280 
    281 /**
    282  * Just a wrapper over the pq_release_remote function
    283  */
    284 void nic_release_packet(nic_t *nic_data, packet_t *packet)
    285 {
    286         pq_release_remote(nic_data->net_session, packet_get_id(packet));
    287 }
    288 
    289 /** Allocate frame and packet
     268/** Allocate frame
    290269 *
    291270 *  @param nic_data     The NIC driver data
     
    607586
    608587/**
    609  * The busy flag can be set to 1 only in the write_packet handler, to 0 it can
     588 * The busy flag can be set to 1 only in the send_frame handler, to 0 it can
    610589 * be set anywhere.
    611590 *
     
    616595{
    617596        /*
    618          * When the function is called in write_packet handler the main lock is
     597         * When the function is called in send_frame handler the main lock is
    619598         * locked so no race can happen.
    620599         * Otherwise, when it is unexpectedly set to 0 (even with main lock held
     
    635614{
    636615        /* Note: this function must not lock main lock, because loopback driver
    637          *               calls it inside write_packet handler (with locked main lock) */
     616         *               calls it inside send_frame handler (with locked main lock) */
    638617        fibril_rwlock_read_lock(&nic_data->rxc_lock);
    639618        nic_frame_type_t frame_type;
     
    643622        /* Update statistics */
    644623        fibril_rwlock_write_lock(&nic_data->stats_lock);
    645         /* Both sending message up and releasing packet are atomic IPC calls */
     624
    646625        if (nic_data->state == NIC_STATE_ACTIVE && check) {
    647626                nic_data->stats.receive_packets++;
     
    679658/**
    680659 * This function is to be used only in the loopback driver. It's workaround
    681  * for the situation when the packet does not contain ethernet address.
     660 * for the situation when the frame does not contain ethernet address.
    682661 * The filtering is therefore not applied here.
    683662 *
    684663 * @param nic_data
    685  * @param packet
    686  */
    687 void nic_received_noneth_packet(nic_t *nic_data, packet_t *packet)
     664 * @param data          Frame data
     665 * @param size          Frame size in bytes
     666 */
     667void nic_received_noneth_frame(nic_t *nic_data, void *data, size_t size)
    688668{
    689669        fibril_rwlock_write_lock(&nic_data->stats_lock);
    690670        nic_data->stats.receive_packets++;
    691         nic_data->stats.receive_bytes += packet_get_data_length(packet);
     671        nic_data->stats.receive_bytes += size;
    692672        fibril_rwlock_write_unlock(&nic_data->stats_lock);
    693673       
    694674        nil_received_msg(nic_data->nil_session, nic_data->device_id,
    695             packet_get_data(packet), packet_get_data_length(packet));
    696 }
    697 
    698 /**
    699  * Some NICs can receive multiple packets during single interrupt. These can
     675            data, size);
     676}
     677
     678/**
     679 * Some NICs can receive multiple frames during single interrupt. These can
    700680 * send them in whole list of frames (actually nic_frame_t structures), then
    701  * the list is deallocated and each packet is passed to the
     681 * the list is deallocated and each frame is passed to the
    702682 * nic_received_packet function.
    703683 *
     
    13151295}
    13161296
    1317 /** Lock packet for DMA usage
    1318  *
    1319  * @param packet
    1320  * @return physical address of packet
    1321  */
    1322 int nic_dma_lock_packet(packet_t *packet, size_t size, void **phys)
    1323 {
    1324         return dmamem_map(packet, SIZE2PAGES(size), 0, 0, phys);
    1325 }
    1326 
    1327 /** Unlock packet after DMA usage
    1328  *
    1329  * @param packet
    1330  */
    1331 int nic_dma_unlock_packet(packet_t *packet, size_t size)
    1332 {
    1333         return dmamem_unmap(packet, size);
    1334 }
    1335 
    13361297/** @}
    13371298 */
Note: See TracChangeset for help on using the changeset viewer.