Changeset 7a68fe5 in mainline for uspace/lib


Ignore:
Timestamp:
2011-10-10T06:58:55Z (14 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2ea6392
Parents:
e68c834 (diff), 80099c19 (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 with mainline

Location:
uspace/lib
Files:
20 added
3 deleted
44 edited
2 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    re68c834 r7a68fe5  
    6767        generic/devman.c \
    6868        generic/device/hw_res.c \
     69        generic/device/hw_res_parsed.c \
    6970        generic/device/char_dev.c \
     71        generic/device/nic.c \
    7072        generic/elf/elf_load.c \
    7173        generic/event.c \
     
    103105        generic/adt/list.c \
    104106        generic/adt/hash_table.c \
     107        generic/adt/hash_set.c \
    105108        generic/adt/dynamic_fifo.c \
    106109        generic/adt/measured_strings.c \
  • uspace/lib/c/generic/adt/hash_table.c

    re68c834 r7a68fe5  
    7676       
    7777        return true;
     78}
     79
     80/** Remove all elements from the hash table
     81 *
     82 * @param h Hash table to be cleared
     83 */
     84void hash_table_clear(hash_table_t *h)
     85{
     86        for (hash_count_t chain = 0; chain < h->entries; ++chain) {
     87                link_t *cur;
     88                link_t *next;
     89               
     90                for (cur = h->entry[chain].head.next;
     91                    cur != &h->entry[chain].head;
     92                    cur = next) {
     93                        next = cur->next;
     94                        list_remove(cur);
     95                        h->op->remove_callback(cur);
     96                }
     97        }
    7898}
    7999
     
    198218 */
    199219void hash_table_apply(hash_table_t *h, void (*f)(link_t *, void *), void *arg)
    200 {
    201         hash_index_t bucket;
    202        
    203         for (bucket = 0; bucket < h->entries; bucket++) {
    204                 list_foreach(h->entry[bucket], cur) {
     220{       
     221        for (hash_index_t bucket = 0; bucket < h->entries; bucket++) {
     222                link_t *cur;
     223                link_t *next;
     224
     225                for (cur = h->entry[bucket].head.next; cur != &h->entry[bucket].head;
     226                    cur = next) {
     227                        /*
     228                         * The next pointer must be stored prior to the functor
     229                         * call to allow using destructor as the functor (the
     230                         * free function could overwrite the cur->next pointer).
     231                         */
     232                        next = cur->next;
    205233                        f(cur, arg);
    206234                }
  • uspace/lib/c/generic/net/packet.c

    re68c834 r7a68fe5  
    3636 */
    3737
     38#include <assert.h>
    3839#include <malloc.h>
    3940#include <mem.h>
     
    4445#include <sys/mman.h>
    4546
    46 #include <adt/generic_field.h>
     47#include <adt/hash_table.h>
    4748#include <net/packet.h>
    4849#include <net/packet_header.h>
    4950
    50 /** Packet map page size. */
    51 #define PACKET_MAP_SIZE 100
    52 
    53 /** Returns the packet map page index.
    54  * @param[in] packet_id The packet identifier.
    55  */
    56 #define PACKET_MAP_PAGE(packet_id)      (((packet_id) - 1) / PACKET_MAP_SIZE)
    57 
    58 /** Returns the packet index in the corresponding packet map page.
    59  *  @param[in] packet_id The packet identifier.
    60  */
    61 #define PACKET_MAP_INDEX(packet_id)     (((packet_id) - 1) % PACKET_MAP_SIZE)
    62 
    63 /** Type definition of the packet map page. */
    64 typedef packet_t *packet_map_t[PACKET_MAP_SIZE];
    65 
    66 /** Packet map.
    67  * Maps packet identifiers to the packet references.
    68  * @see generic_field.h
    69  */
    70 GENERIC_FIELD_DECLARE(gpm, packet_map_t);
     51/** Packet hash table size. */
     52#define PACKET_HASH_TABLE_SIZE  128
    7153
    7254/** Packet map global data. */
     
    7557        fibril_rwlock_t lock;
    7658        /** Packet map. */
    77         gpm_t packet_map;
     59        hash_table_t packet_map;
     60        /** Packet map operations */
     61        hash_table_operations_t operations;
    7862} pm_globals;
    7963
    80 GENERIC_FIELD_IMPLEMENT(gpm, packet_map_t);
     64typedef struct {
     65        link_t link;
     66        packet_t *packet;
     67} pm_entry_t;
     68
     69/**
     70 * Hash function for the packet mapping hash table
     71 */
     72static hash_index_t pm_hash(unsigned long key[])
     73{
     74        return (hash_index_t) key[0] % PACKET_HASH_TABLE_SIZE;
     75}
     76
     77/**
     78 * Key compare function for the packet mapping hash table
     79 */
     80static int pm_compare(unsigned long key[], hash_count_t keys, link_t *link)
     81{
     82        pm_entry_t *entry = list_get_instance(link, pm_entry_t, link);
     83        return entry->packet->packet_id == key[0];
     84}
     85
     86/**
     87 * Remove callback for the packet mapping hash table
     88 */
     89static void pm_remove_callback(link_t *link)
     90{
     91        pm_entry_t *entry = list_get_instance(link, pm_entry_t, link);
     92        free(entry);
     93}
     94
     95/**
     96 * Wrapper used when destroying the whole table
     97 */
     98static void pm_free_wrapper(link_t *link, void *ignored)
     99{
     100        pm_entry_t *entry = list_get_instance(link, pm_entry_t, link);
     101        free(entry);
     102}
     103
    81104
    82105/** Initializes the packet map.
     
    87110int pm_init(void)
    88111{
    89         int rc;
     112        int rc = EOK;
    90113
    91114        fibril_rwlock_initialize(&pm_globals.lock);
    92115       
    93116        fibril_rwlock_write_lock(&pm_globals.lock);
    94         rc = gpm_initialize(&pm_globals.packet_map);
     117       
     118        pm_globals.operations.hash = pm_hash;
     119        pm_globals.operations.compare = pm_compare;
     120        pm_globals.operations.remove_callback = pm_remove_callback;
     121
     122        if (!hash_table_create(&pm_globals.packet_map, PACKET_HASH_TABLE_SIZE, 1,
     123            &pm_globals.operations))
     124                rc = ENOMEM;
     125       
    95126        fibril_rwlock_write_unlock(&pm_globals.lock);
    96127       
     
    100131/** Finds the packet mapping.
    101132 *
    102  * @param[in] packet_id The packet identifier to be found.
    103  * @return              The found packet reference.
    104  * @return              NULL if the mapping does not exist.
     133 * @param[in] packet_id Packet identifier to be found.
     134 *
     135 * @return The found packet reference.
     136 * @return NULL if the mapping does not exist.
     137 *
    105138 */
    106139packet_t *pm_find(packet_id_t packet_id)
    107140{
    108         packet_map_t *map;
    109         packet_t *packet;
    110 
    111141        if (!packet_id)
    112142                return NULL;
    113 
     143       
    114144        fibril_rwlock_read_lock(&pm_globals.lock);
    115         if (packet_id > PACKET_MAP_SIZE * gpm_count(&pm_globals.packet_map)) {
    116                 fibril_rwlock_read_unlock(&pm_globals.lock);
    117                 return NULL;
    118         }
    119         map = gpm_get_index(&pm_globals.packet_map, PACKET_MAP_PAGE(packet_id));
    120         if (!map) {
    121                 fibril_rwlock_read_unlock(&pm_globals.lock);
    122                 return NULL;
    123         }
    124         packet = (*map) [PACKET_MAP_INDEX(packet_id)];
     145       
     146        unsigned long key = packet_id;
     147        link_t *link = hash_table_find(&pm_globals.packet_map, &key);
     148       
     149        packet_t *packet;
     150        if (link != NULL) {
     151                pm_entry_t *entry =
     152                    hash_table_get_instance(link, pm_entry_t, link);
     153                packet = entry->packet;
     154        } else
     155                packet = NULL;
     156       
    125157        fibril_rwlock_read_unlock(&pm_globals.lock);
    126158        return packet;
     
    129161/** Adds the packet mapping.
    130162 *
    131  * @param[in] packet    The packet to be remembered.
    132  * @return              EOK on success.
    133  * @return              EINVAL if the packet is not valid.
    134  * @return              EINVAL if the packet map is not initialized.
    135  * @return              ENOMEM if there is not enough memory left.
     163 * @param[in] packet Packet to be remembered.
     164 *
     165 * @return EOK on success.
     166 * @return EINVAL if the packet is not valid.
     167 * @return ENOMEM if there is not enough memory left.
     168 *
    136169 */
    137170int pm_add(packet_t *packet)
    138171{
    139         packet_map_t *map;
    140         int rc;
    141 
    142172        if (!packet_is_valid(packet))
    143173                return EINVAL;
    144 
     174       
    145175        fibril_rwlock_write_lock(&pm_globals.lock);
    146 
    147         if (PACKET_MAP_PAGE(packet->packet_id) <
    148             gpm_count(&pm_globals.packet_map)) {
    149                 map = gpm_get_index(&pm_globals.packet_map,
    150                     PACKET_MAP_PAGE(packet->packet_id));
    151         } else {
    152                 do {
    153                         map = (packet_map_t *) malloc(sizeof(packet_map_t));
    154                         if (!map) {
    155                                 fibril_rwlock_write_unlock(&pm_globals.lock);
    156                                 return ENOMEM;
    157                         }
    158                         bzero(map, sizeof(packet_map_t));
    159                         rc = gpm_add(&pm_globals.packet_map, map);
    160                         if (rc < 0) {
    161                                 fibril_rwlock_write_unlock(&pm_globals.lock);
    162                                 free(map);
    163                                 return rc;
    164                         }
    165                 } while (PACKET_MAP_PAGE(packet->packet_id) >=
    166                     gpm_count(&pm_globals.packet_map));
     176       
     177        pm_entry_t *entry = malloc(sizeof(pm_entry_t));
     178        if (entry == NULL) {
     179                fibril_rwlock_write_unlock(&pm_globals.lock);
     180                return ENOMEM;
    167181        }
    168 
    169         (*map) [PACKET_MAP_INDEX(packet->packet_id)] = packet;
     182       
     183        entry->packet = packet;
     184       
     185        unsigned long key = packet->packet_id;
     186        hash_table_insert(&pm_globals.packet_map, &key, &entry->link);
     187       
    170188        fibril_rwlock_write_unlock(&pm_globals.lock);
     189       
    171190        return EOK;
    172191}
    173192
    174 /** Releases the packet map. */
     193/** Remove the packet mapping
     194 *
     195 * @param[in] packet The packet to be removed
     196 *
     197 */
     198void pm_remove(packet_t *packet)
     199{
     200        assert(packet_is_valid(packet));
     201       
     202        fibril_rwlock_write_lock(&pm_globals.lock);
     203       
     204        unsigned long key = packet->packet_id;
     205        hash_table_remove(&pm_globals.packet_map, &key, 1);
     206       
     207        fibril_rwlock_write_unlock(&pm_globals.lock);
     208}
     209
     210/** Release the packet map. */
    175211void pm_destroy(void)
    176212{
    177         int count;
    178         int index;
    179         packet_map_t *map;
    180         packet_t *packet;
    181 
    182213        fibril_rwlock_write_lock(&pm_globals.lock);
    183         count = gpm_count(&pm_globals.packet_map);
    184         while (count > 0) {
    185                 map = gpm_get_index(&pm_globals.packet_map, count - 1);
    186                 for (index = PACKET_MAP_SIZE - 1; index >= 0; --index) {
    187                         packet = (*map)[index];
    188                         if (packet_is_valid(packet))
    189                                 munmap(packet, packet->length);
    190                 }
    191         }
    192         gpm_destroy(&pm_globals.packet_map, free);
    193         /* leave locked */
     214        hash_table_apply(&pm_globals.packet_map, pm_free_wrapper, NULL);
     215        hash_table_destroy(&pm_globals.packet_map);
     216        /* Leave locked */
    194217}
    195218
     
    199222 * The packet is inserted right before the packets of the same order value.
    200223 *
    201  * @param[in,out] first The first packet of the queue. Sets the first packet of
    202  *                      the queue. The original first packet may be shifted by
    203  *                      the new packet.
    204  * @param[in] packet    The packet to be added.
    205  * @param[in] order     The packet order value.
    206  * @param[in] metric    The metric value of the packet.
    207  * @return              EOK on success.
    208  * @return              EINVAL if the first parameter is NULL.
    209  * @return              EINVAL if the packet is not valid.
     224 * @param[in,out] first First packet of the queue. Sets the first
     225 *                      packet of the queue. The original first packet
     226 *                      may be shifted by the new packet.
     227 * @param[in] packet    Packet to be added.
     228 * @param[in] order     Packet order value.
     229 * @param[in] metric    Metric value of the packet.
     230 *
     231 * @return EOK on success.
     232 * @return EINVAL if the first parameter is NULL.
     233 * @return EINVAL if the packet is not valid.
     234 *
    210235 */
    211236int pq_add(packet_t **first, packet_t *packet, size_t order, size_t metric)
    212237{
    213         packet_t *item;
    214 
    215         if (!first || !packet_is_valid(packet))
     238        if ((!first) || (!packet_is_valid(packet)))
    216239                return EINVAL;
    217 
     240       
    218241        pq_set_order(packet, order, metric);
    219242        if (packet_is_valid(*first)) {
    220                 item = * first;
     243                packet_t *cur = *first;
     244               
    221245                do {
    222                         if (item->order < order) {
    223                                 if (item->next) {
    224                                         item = pm_find(item->next);
    225                                 } else {
    226                                         item->next = packet->packet_id;
    227                                         packet->previous = item->packet_id;
     246                        if (cur->order < order) {
     247                                if (cur->next)
     248                                        cur = pm_find(cur->next);
     249                                else {
     250                                        cur->next = packet->packet_id;
     251                                        packet->previous = cur->packet_id;
     252                                       
    228253                                        return EOK;
    229254                                }
    230255                        } else {
    231                                 packet->previous = item->previous;
    232                                 packet->next = item->packet_id;
    233                                 item->previous = packet->packet_id;
    234                                 item = pm_find(packet->previous);
    235                                 if (item)
    236                                         item->next = packet->packet_id;
     256                                packet->previous = cur->previous;
     257                                packet->next = cur->packet_id;
     258                               
     259                                cur->previous = packet->packet_id;
     260                                cur = pm_find(packet->previous);
     261                               
     262                                if (cur)
     263                                        cur->next = packet->packet_id;
    237264                                else
    238265                                        *first = packet;
     266                               
    239267                                return EOK;
    240268                        }
    241                 } while (packet_is_valid(item));
     269                } while (packet_is_valid(cur));
    242270        }
     271       
    243272        *first = packet;
    244273        return EOK;
     
    312341
    313342        next = pm_find(packet->next);
    314         if (next) {
     343        if (next)
    315344                next->previous = packet->previous;
    316                 previous = pm_find(next->previous);
    317                 if (previous)
    318                         previous->next = next->packet_id;
    319         }
     345       
     346        previous = pm_find(packet->previous);
     347        if (previous)
     348                previous->next = packet->next ;
     349       
    320350        packet->previous = 0;
    321351        packet->next = 0;
  • uspace/lib/c/generic/ns.c

    re68c834 r7a68fe5  
    5454        if (!exch)
    5555                return NULL;
     56       
    5657        async_sess_t *sess =
    5758            async_connect_me_to(mgmt, exch, service, arg2, arg3);
    5859        async_exchange_end(exch);
    59 
     60       
    6061        if (!sess)
    6162                return NULL;
  • uspace/lib/c/include/adt/hash_table.h

    re68c834 r7a68fe5  
    8686extern bool hash_table_create(hash_table_t *, hash_count_t, hash_count_t,
    8787    hash_table_operations_t *);
     88extern void hash_table_clear(hash_table_t *);
    8889extern void hash_table_insert(hash_table_t *, unsigned long [], link_t *);
    8990extern link_t *hash_table_find(hash_table_t *, unsigned long []);
  • uspace/lib/c/include/ipc/dev_iface.h

    re68c834 r7a68fe5  
    3636typedef enum {
    3737        HW_RES_DEV_IFACE = 0,
     38        /** Character device interface */
    3839        CHAR_DEV_IFACE,
    39 
     40       
     41        /** Network interface controller interface */
     42        NIC_DEV_IFACE,
     43       
    4044        /** Interface provided by any PCI device. */
    4145        PCI_DEV_IFACE,
  • uspace/lib/c/include/ipc/devman.h

    re68c834 r7a68fe5  
    146146typedef enum {
    147147        DRIVER_DEV_ADD = IPC_FIRST_USER_METHOD,
     148        DRIVER_DEV_ADDED,
    148149        DRIVER_DEV_REMOVE,
    149150        DRIVER_DEV_GONE,
  • uspace/lib/c/include/ipc/il.h

    re68c834 r7a68fe5  
    5454        NET_IL_MTU_CHANGED,
    5555       
     56        /**
     57         * Device address changed message
     58         * @see il_addr_changed_msg()
     59         */
     60        NET_IL_ADDR_CHANGED,
     61
    5662        /** Packet received message.
    5763         * @see il_received_msg()
  • uspace/lib/c/include/ipc/net.h

    re68c834 r7a68fe5  
    277277 *
    278278 */
    279 #define IPC_GET_DEVICE(call)  ((device_id_t) IPC_GET_ARG1(call))
     279#define IPC_GET_DEVICE(call)  ((nic_device_id_t) IPC_GET_ARG1(call))
    280280
    281281/** Return the packet identifier message argument.
     
    298298 *
    299299 */
    300 #define IPC_GET_STATE(call)  ((device_state_t) IPC_GET_ARG2(call))
     300#define IPC_GET_STATE(call)  ((nic_device_state_t) IPC_GET_ARG2(call))
     301
     302/** Return the device handle argument
     303 *
     304 * @param[in] call Message call structure
     305 *
     306 */
     307#define IPC_GET_DEVICE_HANDLE(call) ((devman_handle_t) IPC_GET_ARG2(call))
     308
     309/** Return the device driver service message argument.
     310 *
     311 * @param[in] call Message call structure.
     312 *
     313 */
     314#define IPC_GET_SERVICE(call)  ((services_t) IPC_GET_ARG3(call))
     315
     316/** Return the target service message argument.
     317 *
     318 * @param[in] call Message call structure.
     319 *
     320 */
     321#define IPC_GET_TARGET(call)  ((services_t) IPC_GET_ARG3(call))
     322
     323/** Return the sender service message argument.
     324 *
     325 * @param[in] call Message call structure.
     326 *
     327 */
     328#define IPC_GET_SENDER(call)  ((services_t) IPC_GET_ARG3(call))
    301329
    302330/** Return the maximum transmission unit message argument.
     
    305333 *
    306334 */
    307 #define IPC_GET_MTU(call)  ((size_t) IPC_GET_ARG2(call))
    308 
    309 /** Return the device driver service message argument.
    310  *
    311  * @param[in] call Message call structure.
    312  *
    313  */
    314 #define IPC_GET_SERVICE(call)  ((services_t) IPC_GET_ARG3(call))
    315 
    316 /** Return the target service message argument.
    317  *
    318  * @param[in] call Message call structure.
    319  *
    320  */
    321 #define IPC_GET_TARGET(call)  ((services_t) IPC_GET_ARG3(call))
    322 
    323 /** Return the sender service message argument.
    324  *
    325  * @param[in] call Message call structure.
    326  *
    327  */
    328 #define IPC_GET_SENDER(call)  ((services_t) IPC_GET_ARG3(call))
     335#define IPC_GET_MTU(call)  ((size_t) IPC_GET_ARG3(call))
    329336
    330337/** Return the error service message argument.
  • uspace/lib/c/include/ipc/net_net.h

    re68c834 r7a68fe5  
    4343/** Networking subsystem central module messages. */
    4444typedef enum {
    45         /** Returns the general configuration
     45        /** Return general configuration
    4646         * @see net_get_conf_req()
    4747         */
    4848        NET_NET_GET_CONF = NET_FIRST,
    49         /** Returns the device specific configuration
     49        /** Return device specific configuration
    5050         * @see net_get_device_conf_req()
    5151         */
    5252        NET_NET_GET_DEVICE_CONF,
    53         /** Starts the networking stack. */
    54         NET_NET_STARTUP,
     53        /** Return number of mastered devices */
     54        NET_NET_GET_DEVICES_COUNT,
     55        /** Return names and device IDs of all devices */
     56        NET_NET_GET_DEVICES,
     57        /** Notify the networking service about a ready device */
     58        NET_NET_DRIVER_READY
    5559} net_messages;
    5660
  • uspace/lib/c/include/ipc/nil.h

    re68c834 r7a68fe5  
    7070         */
    7171        NET_NIL_BROADCAST_ADDR,
     72        /** Device has changed address
     73         * @see nil_addr_changed_msg()
     74         */
     75        NET_NIL_ADDR_CHANGED
    7276} nil_messages;
    7377
  • uspace/lib/c/include/ipc/services.h

    re68c834 r7a68fe5  
    4949        SERVICE_CLIPBOARD  = FOURCC('c', 'l', 'i', 'p'),
    5050        SERVICE_NETWORKING = FOURCC('n', 'e', 't', ' '),
    51         SERVICE_LO         = FOURCC('l', 'o', ' ', ' '),
    52         SERVICE_NE2000     = FOURCC('n', 'e', '2', 'k'),
    5351        SERVICE_ETHERNET   = FOURCC('e', 't', 'h', ' '),
    5452        SERVICE_NILDUMMY   = FOURCC('n', 'i', 'l', 'd'),
  • uspace/lib/c/include/net/device.h

    re68c834 r7a68fe5  
    11/*
    22 * Copyright (c) 2009 Lukas Mejdrech
     3 * Copyright (c) 2011 Radim Vansa
    34 * All rights reserved.
    45 *
     
    3940
    4041#include <adt/int_map.h>
     42#include <net/eth_phys.h>
     43#include <bool.h>
     44
     45/** Ethernet address length. */
     46#define ETH_ADDR  6
     47
     48/** MAC printing format */
     49#define PRIMAC  "%02x:%02x:%02x:%02x:%02x:%02x"
     50
     51/** MAC arguments */
     52#define ARGSMAC(__a) \
     53        (__a)[0], (__a)[1], (__a)[2], (__a)[3], (__a)[4], (__a)[5]
     54
     55/* Compare MAC address with specific value */
     56#define MAC_EQUALS_VALUE(__a, __a0, __a1, __a2, __a3, __a4, __a5) \
     57        ((__a)[0] == (__a0) && (__a)[1] == (__a1) && (__a)[2] == (__a2) \
     58        && (__a)[3] == (__a3) && (__a)[4] == (__a4) && (__a)[5] == (__a5))
     59
     60#define MAC_IS_ZERO(__x) \
     61        MAC_EQUALS_VALUE(__x, 0, 0, 0, 0, 0, 0)
    4162
    4263/** Device identifier to generic type map declaration. */
    43 #define DEVICE_MAP_DECLARE      INT_MAP_DECLARE
     64#define DEVICE_MAP_DECLARE  INT_MAP_DECLARE
    4465
    4566/** Device identifier to generic type map implementation. */
    46 #define DEVICE_MAP_IMPLEMENT    INT_MAP_IMPLEMENT
     67#define DEVICE_MAP_IMPLEMENT  INT_MAP_IMPLEMENT
     68
     69/** Max length of any hw nic address (currently only eth) */
     70#define NIC_MAX_ADDRESS_LENGTH  16
    4771
    4872/** Invalid device identifier. */
    49 #define DEVICE_INVALID_ID       (-1)
     73#define NIC_DEVICE_INVALID_ID  (-1)
     74
     75#define NIC_VENDOR_MAX_LENGTH         64
     76#define NIC_MODEL_MAX_LENGTH          64
     77#define NIC_PART_NUMBER_MAX_LENGTH    64
     78#define NIC_SERIAL_NUMBER_MAX_LENGTH  64
     79
     80/**
     81 * The bitmap uses single bit for each of the 2^12 = 4096 possible VLAN tags.
     82 * This means its size is 4096/8 = 512 bytes.
     83 */
     84#define NIC_VLAN_BITMAP_SIZE  512
     85
     86#define NIC_DEVICE_PRINT_FMT  "%x"
    5087
    5188/** Device identifier type. */
    52 typedef int device_id_t;
    53 
    54 /** Device state type. */
    55 typedef enum device_state device_state_t;
    56 
    57 /** Type definition of the device usage statistics.
    58  * @see device_stats
    59  */
    60 typedef struct device_stats device_stats_t;
     89typedef int nic_device_id_t;
     90
     91/**
     92 * Structure covering the MAC address.
     93 */
     94typedef struct nic_address {
     95        uint8_t address[ETH_ADDR];
     96} nic_address_t;
    6197
    6298/** Device state. */
    63 enum device_state {
    64         /** Device not present or not initialized. */
    65         NETIF_NULL = 0,
    66         /** Device present and stopped. */
    67         NETIF_STOPPED,
    68         /** Device present and active. */
    69         NETIF_ACTIVE,
    70         /** Device present but unable to transmit. */
    71         NETIF_CARRIER_LOST
    72 };
     99typedef enum nic_device_state {
     100        /**
     101         * Device present and stopped. Moving device to this state means to discard
     102         * all settings and WOL virtues, rebooting the NIC to state as if the
     103         * computer just booted (or the NIC was just inserted in case of removable
     104         * NIC).
     105         */
     106        NIC_STATE_STOPPED,
     107        /**
     108         * If the NIC is in this state no packets (frames) are transmitted nor
     109         * received. However, the settings are not restarted. You can use this state
     110         * to temporarily disable transmition/reception or atomically (with respect
     111         * to incoming/outcoming packets) change frames acceptance etc.
     112         */
     113        NIC_STATE_DOWN,
     114        /** Device is normally operating. */
     115        NIC_STATE_ACTIVE,
     116        /** Just a constant to limit the state numbers */
     117        NIC_STATE_MAX,
     118} nic_device_state_t;
     119
     120/**
     121 * Channel operating mode used on the medium.
     122 */
     123typedef enum {
     124        NIC_CM_UNKNOWN,
     125        NIC_CM_FULL_DUPLEX,
     126        NIC_CM_HALF_DUPLEX,
     127        NIC_CM_SIMPLEX
     128} nic_channel_mode_t;
     129
     130/**
     131 * Role for the device (used e.g. for 1000Gb ethernet)
     132 */
     133typedef enum {
     134        NIC_ROLE_UNKNOWN,
     135        NIC_ROLE_AUTO,
     136        NIC_ROLE_MASTER,
     137        NIC_ROLE_SLAVE
     138} nic_role_t;
     139
     140/**
     141 * Current state of the cable in the device
     142 */
     143typedef enum {
     144        NIC_CS_UNKNOWN,
     145        NIC_CS_PLUGGED,
     146        NIC_CS_UNPLUGGED
     147} nic_cable_state_t;
     148
     149/**
     150 * Result of the requested operation
     151 */
     152typedef enum {
     153        /** Successfully disabled */
     154        NIC_RESULT_DISABLED,
     155        /** Successfully enabled */
     156        NIC_RESULT_ENABLED,
     157        /** Not supported at all */
     158        NIC_RESULT_NOT_SUPPORTED,
     159        /** Temporarily not available */
     160        NIC_RESULT_NOT_AVAILABLE,
     161        /** Result extensions */
     162        NIC_RESULT_FIRST_EXTENSION
     163} nic_result_t;
    73164
    74165/** Device usage statistics. */
    75 struct device_stats {
    76         /** Total packets received. */
     166typedef struct nic_device_stats {
     167        /** Total packets received (accepted). */
    77168        unsigned long receive_packets;
    78169        /** Total packets transmitted. */
    79170        unsigned long send_packets;
    80         /** Total bytes received. */
     171        /** Total bytes received (accepted). */
    81172        unsigned long receive_bytes;
    82173        /** Total bytes transmitted. */
     
    86177        /** Packet transmition problems counter. */
    87178        unsigned long send_errors;
    88         /** No space in buffers counter. */
     179        /** Number of frames dropped due to insufficient space in RX buffers */
    89180        unsigned long receive_dropped;
    90         /** No space available counter. */
     181        /** Number of frames dropped due to insufficient space in TX buffers */
    91182        unsigned long send_dropped;
    92         /** Total multicast packets received. */
    93         unsigned long multicast;
     183        /** Total multicast packets received (accepted). */
     184        unsigned long receive_multicast;
     185        /** Total broadcast packets received (accepted). */
     186        unsigned long receive_broadcast;
    94187        /** The number of collisions due to congestion on the medium. */
    95188        unsigned long collisions;
     189        /** Unicast packets received but not accepted (filtered) */
     190        unsigned long receive_filtered_unicast;
     191        /** Multicast packets received but not accepted (filtered) */
     192        unsigned long receive_filtered_multicast;
     193        /** Broadcast packets received but not accepted (filtered) */
     194        unsigned long receive_filtered_broadcast;
    96195
    97196        /* detailed receive_errors */
     
    129228        /** Total compressed packet transmitted. */
    130229        unsigned long send_compressed;
    131 };
     230} nic_device_stats_t;
     231
     232/** Errors corresponding to those in the nic_device_stats_t */
     233typedef enum {
     234        NIC_SEC_BUFFER_FULL,
     235        NIC_SEC_ABORTED,
     236        NIC_SEC_CARRIER_LOST,
     237        NIC_SEC_FIFO_OVERRUN,
     238        NIC_SEC_HEARTBEAT,
     239        NIC_SEC_WINDOW_ERROR,
     240        /* Error encountered during TX but with other type of error */
     241        NIC_SEC_OTHER
     242} nic_send_error_cause_t;
     243
     244/** Errors corresponding to those in the nic_device_stats_t */
     245typedef enum {
     246        NIC_REC_BUFFER_FULL,
     247        NIC_REC_LENGTH,
     248        NIC_REC_BUFFER_OVERFLOW,
     249        NIC_REC_CRC,
     250        NIC_REC_FRAME_ALIGNMENT,
     251        NIC_REC_FIFO_OVERRUN,
     252        NIC_REC_MISSED,
     253        /* Error encountered during RX but with other type of error */
     254        NIC_REC_OTHER
     255} nic_receive_error_cause_t;
     256
     257/**
     258 * Information about the NIC that never changes - name, vendor, model,
     259 * capabilites and so on.
     260 */
     261typedef struct nic_device_info {
     262        /* Device identification */
     263        char vendor_name[NIC_VENDOR_MAX_LENGTH];
     264        char model_name[NIC_MODEL_MAX_LENGTH];
     265        char part_number[NIC_PART_NUMBER_MAX_LENGTH];
     266        char serial_number[NIC_SERIAL_NUMBER_MAX_LENGTH];
     267        uint16_t vendor_id;
     268        uint16_t device_id;
     269        uint16_t subsystem_vendor_id;
     270        uint16_t subsystem_id;
     271        /* Device capabilities */
     272        uint16_t ethernet_support[ETH_PHYS_LAYERS];
     273
     274        /** The mask of all modes which the device can advertise
     275         *
     276         *  see ETH_AUTONEG_ macros in net/eth_phys.h of libc
     277         */
     278        uint32_t autoneg_support;
     279} nic_device_info_t;
     280
     281/**
     282 * Type of the ethernet frame
     283 */
     284typedef enum nic_frame_type {
     285        NIC_FRAME_UNICAST,
     286        NIC_FRAME_MULTICAST,
     287        NIC_FRAME_BROADCAST
     288} nic_frame_type_t;
     289
     290/**
     291 * Specifies which unicast frames is the NIC receiving.
     292 */
     293typedef enum nic_unicast_mode {
     294        NIC_UNICAST_UNKNOWN,
     295        /** No unicast frames are received */
     296        NIC_UNICAST_BLOCKED,
     297        /** Only the frames with this NIC's MAC as destination are received */
     298        NIC_UNICAST_DEFAULT,
     299        /**
     300         * Both frames with this NIC's MAC and those specified in the list are
     301         * received
     302         */
     303        NIC_UNICAST_LIST,
     304        /** All unicast frames are received */
     305        NIC_UNICAST_PROMISC
     306} nic_unicast_mode_t;
     307
     308typedef enum nic_multicast_mode {
     309        NIC_MULTICAST_UNKNOWN,
     310        /** No multicast frames are received */
     311        NIC_MULTICAST_BLOCKED,
     312        /** Frames with multicast addresses specified in this list are received */
     313        NIC_MULTICAST_LIST,
     314        /** All multicast frames are received */
     315        NIC_MULTICAST_PROMISC
     316} nic_multicast_mode_t;
     317
     318typedef enum nic_broadcast_mode {
     319        NIC_BROADCAST_UNKNOWN,
     320        /** Broadcast frames are dropped */
     321        NIC_BROADCAST_BLOCKED,
     322        /** Broadcast frames are received */
     323        NIC_BROADCAST_ACCEPTED
     324} nic_broadcast_mode_t;
     325
     326/**
     327 * Structure covering the bitmap with VLAN tags.
     328 */
     329typedef struct nic_vlan_mask {
     330        uint8_t bitmap[NIC_VLAN_BITMAP_SIZE];
     331} nic_vlan_mask_t;
     332
     333/* WOL virtue identifier */
     334typedef unsigned int nic_wv_id_t;
     335
     336/**
     337 * Structure passed as argument for virtue NIC_WV_MAGIC_PACKET.
     338 */
     339typedef struct nic_wv_magic_packet_data {
     340        uint8_t password[6];
     341} nic_wv_magic_packet_data_t;
     342
     343/**
     344 * Structure passed as argument for virtue NIC_WV_DIRECTED_IPV4
     345 */
     346typedef struct nic_wv_ipv4_data {
     347        uint8_t address[4];
     348} nic_wv_ipv4_data_t;
     349
     350/**
     351 * Structure passed as argument for virtue NIC_WV_DIRECTED_IPV6
     352 */
     353typedef struct nic_wv_ipv6_data {
     354        uint8_t address[16];
     355} nic_wv_ipv6_data_t;
     356
     357/**
     358 * WOL virtue types defining the interpretation of data passed to the virtue.
     359 * Those tagged with S can have only single virtue active at one moment, those
     360 * tagged with M can have multiple ones.
     361 */
     362typedef enum nic_wv_type {
     363        /**
     364         * Used for deletion of the virtue - in this case the mask, data and length
     365         * arguments are ignored.
     366         */
     367        NIC_WV_NONE,
     368        /** S
     369         * Enabled <=> wakeup upon link change
     370         */
     371        NIC_WV_LINK_CHANGE,
     372        /** S
     373         * If this virtue is set up, wakeup can be issued by a magic packet frame.
     374         * If the data argument is not NULL, it must contain
     375         * nic_wv_magic_packet_data structure with the SecureOn password.
     376         */
     377        NIC_WV_MAGIC_PACKET,
     378        /** M
     379         * If the virtue is set up, wakeup can be issued by a frame targeted to
     380         * device with MAC address specified in data. The data must contain
     381         * nic_address_t structure.
     382         */
     383        NIC_WV_DESTINATION,
     384        /** S
     385         * Enabled <=> wakeup upon receiving broadcast frame
     386         */
     387        NIC_WV_BROADCAST,
     388        /** S
     389         * Enabled <=> wakeup upon receiving ARP Request
     390         */
     391        NIC_WV_ARP_REQUEST,
     392        /** M
     393         * If enabled, the wakeup is issued upon receiving frame with an IPv4 packet
     394         * with IPv4 address specified in data. The data must contain
     395         * nic_wv_ipv4_data structure.
     396         */
     397        NIC_WV_DIRECTED_IPV4,
     398        /** M
     399         * If enabled, the wakeup is issued upon receiving frame with an IPv4 packet
     400         * with IPv6 address specified in data. The data must contain
     401         * nic_wv_ipv6_data structure.
     402         */
     403        NIC_WV_DIRECTED_IPV6,
     404        /** M
     405         * First length/2 bytes in the argument are interpreted as mask, second
     406         * length/2 bytes are interpreted as content.
     407         * If enabled, the wakeup is issued upon receiving frame where the bytes
     408         * with non-zero value in the mask equal to those in the content.
     409         */
     410        NIC_WV_FULL_MATCH,
     411        /**
     412         * Dummy value, do not use.
     413         */
     414        NIC_WV_MAX
     415} nic_wv_type_t;
     416
     417/**
     418 * Specifies the interrupt/polling mode used by the driver and NIC
     419 */
     420typedef enum nic_poll_mode {
     421        /**
     422         * NIC issues interrupts upon events.
     423         */
     424        NIC_POLL_IMMEDIATE,
     425        /**
     426         * Some uspace app calls nic_poll_now(...) in order to check the NIC state
     427         * - no interrupts are received from the NIC.
     428         */
     429        NIC_POLL_ON_DEMAND,
     430        /**
     431         * The driver itself issues a poll request in a periodic manner. It is
     432         * allowed to use hardware timer if the NIC supports it.
     433         */
     434        NIC_POLL_PERIODIC,
     435        /**
     436         * The driver itself issued a poll request in a periodic manner. The driver
     437         * must create software timer, internal hardware timer of NIC must not be
     438         * used even if the NIC supports it.
     439         */
     440        NIC_POLL_SOFTWARE_PERIODIC
     441} nic_poll_mode_t;
     442
     443/**
     444 * Says if this virtue type is a multi-virtue (there can be multiple virtues of
     445 * this type at once).
     446 *
     447 * @param type
     448 *
     449 * @return true or false
     450 */
     451static inline int nic_wv_is_multi(nic_wv_type_t type) {
     452        switch (type) {
     453        case NIC_WV_FULL_MATCH:
     454        case NIC_WV_DESTINATION:
     455        case NIC_WV_DIRECTED_IPV4:
     456        case NIC_WV_DIRECTED_IPV6:
     457                return true;
     458        default:
     459                return false;
     460        }
     461}
     462
     463static inline const char *nic_device_state_to_string(nic_device_state_t state)
     464{
     465        switch (state) {
     466        case NIC_STATE_STOPPED:
     467                return "stopped";
     468        case NIC_STATE_DOWN:
     469                return "down";
     470        case NIC_STATE_ACTIVE:
     471                return "active";
     472        default:
     473                return "undefined";
     474        }
     475}
    132476
    133477#endif
  • uspace/lib/c/include/net/packet.h

    re68c834 r7a68fe5  
    3838#define LIBC_PACKET_H_
    3939
     40#include <sys/types.h>
     41
    4042/** Packet identifier type.
    4143 * Value zero is used as an invalid identifier.
    4244 */
    43 typedef int packet_id_t;
     45typedef sysarg_t packet_id_t;
    4446
    4547/** Type definition of the packet.
     
    5153 * @see packet_dimension
    5254 */
    53 typedef struct packet_dimension packet_dimension_t;
     55typedef struct packet_dimension packet_dimension_t;
    5456
    5557/** Packet dimension. */
     
    7173extern packet_t *pm_find(packet_id_t);
    7274extern int pm_add(packet_t *);
     75extern void pm_remove(packet_t *);
    7376extern int pm_init(void);
    7477extern void pm_destroy(void);
  • uspace/lib/c/include/net/packet_header.h

    re68c834 r7a68fe5  
    6161#define PACKET_MAGIC_VALUE      0x11227788
    6262
     63/** Maximum total length of the packet */
     64#define PACKET_MAX_LENGTH  65536
     65
    6366/** Packet header. */
    6467struct packet {
     
    8588         */
    8689        size_t length;
     90
     91        /** Offload info provided by the NIC */
     92        uint32_t offload_info;
     93
     94        /** Mask which bits in offload info are valid */
     95        uint32_t offload_mask;
    8796
    8897        /** Stored source and destination addresses length. */
  • uspace/lib/drv/Makefile

    re68c834 r7a68fe5  
    3939        generic/remote_hw_res.c \
    4040        generic/remote_char_dev.c \
     41        generic/remote_nic.c \
    4142        generic/remote_usb.c \
    4243        generic/remote_pci.c \
  • uspace/lib/drv/generic/dev_iface.c

    re68c834 r7a68fe5  
    4141#include "remote_hw_res.h"
    4242#include "remote_char_dev.h"
     43#include "remote_nic.h"
    4344#include "remote_usb.h"
    4445#include "remote_usbhc.h"
     
    5051                &remote_hw_res_iface,
    5152                &remote_char_dev_iface,
     53                &remote_nic_iface,
    5254                &remote_pci_iface,
    5355                &remote_usb_iface,
  • uspace/lib/drv/generic/driver.c

    re68c834 r7a68fe5  
    303303}
    304304
     305static void driver_dev_added(ipc_callid_t iid, ipc_call_t *icall)
     306{
     307        fibril_mutex_lock(&devices_mutex);
     308        ddf_dev_t *dev = driver_get_device(IPC_GET_ARG1(*icall));
     309        fibril_mutex_unlock(&devices_mutex);
     310       
     311        if (dev != NULL && driver->driver_ops->device_added != NULL)
     312                driver->driver_ops->device_added(dev);
     313}
     314
    305315static void driver_dev_remove(ipc_callid_t iid, ipc_call_t *icall)
    306316{
     
    450460                case DRIVER_DEV_ADD:
    451461                        driver_dev_add(callid, &call);
     462                        break;
     463                case DRIVER_DEV_ADDED:
     464                        async_answer_0(callid, EOK);
     465                        driver_dev_added(callid, &call);
    452466                        break;
    453467                case DRIVER_DEV_REMOVE:
  • uspace/lib/drv/include/ddf/driver.h

    re68c834 r7a68fe5  
    137137        /** Callback method for passing a new device to the device driver */
    138138        int (*add_device)(ddf_dev_t *);
     139        /**
     140         * Notification that the device was succesfully added.
     141         * The driver can do any blocking operation without
     142         * blocking the device manager.
     143         */
     144        void (*device_added)(ddf_dev_t *dev);
    139145        /** Ask driver to remove a device */
    140146        int (*dev_remove)(ddf_dev_t *);
  • uspace/lib/drv/include/remote_nic.h

    re68c834 r7a68fe5  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2011 Radim Vansa
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libnet
     29/** @addtogroup libdrv
    3030 * @{
    3131 */
     32/** @file
     33 */
    3234
    33 #ifndef LIBNET_NETIF_REMOTE_H_
    34 #define LIBNET_NETIF_REMOTE_H_
     35#ifndef LIBDRV_REMOTE_NIC_H_
     36#define LIBDRV_REMOTE_NIC_H_
    3537
    36 #include <ipc/services.h>
    37 #include <adt/measured_strings.h>
    38 #include <net/device.h>
    39 #include <net/packet.h>
    40 #include <async.h>
    41 
    42 extern int netif_get_addr_req(async_sess_t *, device_id_t, measured_string_t **,
    43     uint8_t **);
    44 extern int netif_probe_req(async_sess_t *, device_id_t, int, void *);
    45 extern int netif_send_msg(async_sess_t *, device_id_t, packet_t *, services_t);
    46 extern int netif_start_req(async_sess_t *, device_id_t);
    47 extern int netif_stop_req(async_sess_t *, device_id_t);
    48 extern int netif_stats_req(async_sess_t *, device_id_t, device_stats_t *);
    49 extern async_sess_t *netif_bind_service(services_t, device_id_t, services_t,
    50     async_client_conn_t);
     38extern remote_iface_t remote_nic_iface;
    5139
    5240#endif
    5341
    54 /** @}
     42/**
     43 * @}
    5544 */
  • uspace/lib/net/Makefile

    re68c834 r7a68fe5  
    4040        generic/protocol_map.c \
    4141        adt/module_map.c \
    42         netif/netif_remote.c \
    43         netif/netif_skel.c \
    4442        nil/nil_remote.c \
    4543        nil/nil_skel.c \
  • uspace/lib/net/generic/generic.c

    re68c834 r7a68fe5  
    5454 */
    5555int generic_device_state_msg_remote(async_sess_t *sess, sysarg_t message,
    56     device_id_t device_id, sysarg_t state, services_t target)
     56    nic_device_id_t device_id, sysarg_t state, services_t target)
    5757{
    5858        async_exch_t *exch = async_exchange_begin(sess);
     
    6868 * @param[in] message   Service specific message.
    6969 * @param[in] device_id Device identifier.
    70  * @param[in] arg2      Second argument of the message.
    7170 * @param[in] service   Device module service.
    7271 *
     
    7776 */
    7877int generic_device_req_remote(async_sess_t *sess, sysarg_t message,
    79     device_id_t device_id, sysarg_t arg2, services_t service)
    80 {
    81         async_exch_t *exch = async_exchange_begin(sess);
    82         int rc = async_req_3_0(exch, message, (sysarg_t) device_id,
    83             arg2, (sysarg_t) service);
     78    nic_device_id_t device_id, services_t service)
     79{
     80        async_exch_t *exch = async_exchange_begin(sess);
     81        int rc = async_req_3_0(exch, message, (sysarg_t) device_id, 0,
     82            (sysarg_t) service);
    8483        async_exchange_end(exch);
    8584       
     
    103102 */
    104103int generic_get_addr_req(async_sess_t *sess, sysarg_t message,
    105     device_id_t device_id, measured_string_t **address, uint8_t **data)
    106 {
    107         if ((!address) || (!data))
     104    nic_device_id_t device_id, uint8_t *address, size_t max_len)
     105{
     106        if (!address)
    108107                return EBADMEM;
    109108       
    110109        /* Request the address */
    111110        async_exch_t *exch = async_exchange_begin(sess);
    112         aid_t message_id = async_send_1(exch, message, (sysarg_t) device_id,
     111        aid_t aid = async_send_1(exch, message, (sysarg_t) device_id,
    113112            NULL);
    114         int rc = measured_strings_return(exch, address, data, 1);
     113        int rc = async_data_read_start(exch, address, max_len);
    115114        async_exchange_end(exch);
    116115       
    117116        sysarg_t result;
    118         async_wait_for(message_id, &result);
    119        
    120         /* If not successful */
    121         if ((rc == EOK) && (result != EOK)) {
    122                 /* Clear the data */
    123                 free(*address);
    124                 free(*data);
    125         }
     117        async_wait_for(aid, &result);
     118       
     119        if (rc != EOK)
     120                return rc;
    126121       
    127122        return (int) result;
     
    142137 */
    143138int generic_packet_size_req_remote(async_sess_t *sess, sysarg_t message,
    144     device_id_t device_id, packet_dimension_t *packet_dimension)
     139    nic_device_id_t device_id, packet_dimension_t *packet_dimension)
    145140{
    146141        if (!packet_dimension)
     
    179174 */
    180175int generic_received_msg_remote(async_sess_t *sess, sysarg_t message,
    181     device_id_t device_id, packet_id_t packet_id, services_t target,
     176    nic_device_id_t device_id, packet_id_t packet_id, services_t target,
    182177    services_t error)
    183178{
     
    210205 */
    211206int generic_send_msg_remote(async_sess_t *sess, sysarg_t message,
    212     device_id_t device_id, packet_id_t packet_id, services_t sender,
     207    nic_device_id_t device_id, packet_id_t packet_id, services_t sender,
    213208    services_t error)
    214209{
     
    251246 */
    252247int generic_translate_req(async_sess_t *sess, sysarg_t message,
    253     device_id_t device_id, services_t service,
     248    nic_device_id_t device_id, services_t service,
    254249    measured_string_t *configuration, size_t count,
    255250    measured_string_t **translation, uint8_t **data)
  • uspace/lib/net/generic/net_checksum.c

    re68c834 r7a68fe5  
    4040
    4141/** Big-endian encoding CRC divider. */
    42 #define CRC_DIVIDER_BE  0x04c11db7
     42#define CRC_DIVIDER_BE  0x04c11db7
    4343
    4444/** Little-endian encoding CRC divider. */
    45 #define CRC_DIVIDER_LE  0xedb88320
     45#define CRC_DIVIDER_LE  0xedb88320
     46
     47/** Polynomial used in multicast address hashing */
     48#define CRC_MCAST_POLYNOMIAL  0x04c11db6
    4649
    4750/** Compacts the computed checksum to the 16 bit number adding the carries.
     
    203206}
    204207
    205 /** Computes the ip header checksum.
     208/** Compute the IP header checksum.
    206209 *
    207210 * To compute the checksum of a new packet, the checksum header field must be
     
    221224}
    222225
     226/** Compute the standard hash from MAC
     227 *
     228 * Hashing MAC into 64 possible values and using the value as index to
     229 * 64bit number.
     230 *
     231 * The code is copied from qemu-0.13's implementation of ne2000 and rt8139
     232 * drivers, but according to documentation there it originates in FreeBSD.
     233 *
     234 * @param[in] addr The 6-byte MAC address to be hashed
     235 *
     236 * @return 64-bit number with only single bit set to 1
     237 *
     238 */
     239uint64_t multicast_hash(const uint8_t addr[6])
     240{
     241        uint32_t crc;
     242    int carry, i, j;
     243    uint8_t b;
     244
     245    crc = 0xffffffff;
     246    for (i = 0; i < 6; i++) {
     247        b = addr[i];
     248        for (j = 0; j < 8; j++) {
     249            carry = ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01);
     250            crc <<= 1;
     251            b >>= 1;
     252            if (carry)
     253                crc = ((crc ^ CRC_MCAST_POLYNOMIAL) | carry);
     254        }
     255    }
     256       
     257    uint64_t one64 = 1;
     258    return one64 << (crc >> 26);
     259}
     260
    223261/** @}
    224262 */
  • uspace/lib/net/generic/net_remote.c

    re68c834 r7a68fe5  
    3838#include <ipc/services.h>
    3939#include <ipc/net_net.h>
    40 
    4140#include <malloc.h>
    42 
     41#include <async.h>
     42#include <devman.h>
    4343#include <generic.h>
    4444#include <net/modules.h>
     
    9898    size_t count, uint8_t **data)
    9999{
    100         return generic_translate_req(sess, NET_NET_GET_DEVICE_CONF, 0, 0,
     100        return generic_translate_req(sess, NET_NET_GET_CONF, 0, 0,
    101101            *configuration, count, configuration, data);
    102102}
     
    124124 *
    125125 */
    126 int net_get_device_conf_req(async_sess_t *sess, device_id_t device_id,
     126int net_get_device_conf_req(async_sess_t *sess, nic_device_id_t device_id,
    127127    measured_string_t **configuration, size_t count, uint8_t **data)
    128128{
     
    131131}
    132132
     133int net_get_devices_req(async_sess_t *sess, measured_string_t **devices,
     134    size_t *count, uint8_t **data)
     135{
     136        if ((!devices) || (!count))
     137                return EBADMEM;
     138       
     139        async_exch_t *exch = async_exchange_begin(sess);
     140       
     141        int rc = async_req_0_1(exch, NET_NET_GET_DEVICES_COUNT, count);
     142        if (rc != EOK) {
     143                async_exchange_end(exch);
     144                return rc;
     145        }
     146       
     147        if (*count == 0) {
     148                async_exchange_end(exch);
     149                *data = NULL;
     150                return EOK;
     151        }
     152       
     153        aid_t message_id = async_send_0(exch, NET_NET_GET_DEVICES, NULL);
     154        rc = measured_strings_return(exch, devices, data, *count);
     155       
     156        async_exchange_end(exch);
     157       
     158        sysarg_t result;
     159        async_wait_for(message_id, &result);
     160       
     161        if ((rc == EOK) && (result != EOK)) {
     162                free(*devices);
     163                free(*data);
     164        }
     165       
     166        return (int) result;
     167}
     168
     169int net_driver_ready(async_sess_t *sess, devman_handle_t handle)
     170{
     171        async_exch_t *exch = async_exchange_begin(sess);
     172        int rc = async_req_1_0(exch, NET_NET_DRIVER_READY, handle);
     173        async_exchange_end(exch);
     174       
     175        return rc;
     176}
     177
    133178/** @}
    134179 */
  • uspace/lib/net/generic/packet_remote.c

    re68c834 r7a68fe5  
    115115       
    116116        *packet = pm_find(packet_id);
    117         if (!*packet) {
     117        if (*packet == NULL) {
    118118                async_exch_t *exch = async_exchange_begin(sess);
    119119                sysarg_t size;
     
    130130        }
    131131       
    132         if ((*packet)->next) {
     132        if ((*packet != NULL) && ((*packet)->next)) {
    133133                packet_t *next;
    134134                return packet_translate_remote(sess, &next, (*packet)->next);
  • uspace/lib/net/generic/protocol_map.c

    re68c834 r7a68fe5  
    5050        switch (nil) {
    5151        case SERVICE_ETHERNET:
    52         case SERVICE_NE2000:
     52        case SERVICE_NILDUMMY:
    5353                switch (il) {
    5454                case SERVICE_IP:
     
    7676        switch (nil) {
    7777        case SERVICE_ETHERNET:
    78         case SERVICE_NE2000:
     78        case SERVICE_NILDUMMY:
    7979                switch (protocol) {
    8080                case ETH_P_IP:
     
    139139        switch (nil) {
    140140        case SERVICE_ETHERNET:
    141         case SERVICE_NE2000:
    142141                return HW_ETHER;
    143142        default:
  • uspace/lib/net/il/arp_remote.c

    re68c834 r7a68fe5  
    8484 *
    8585 */
    86 int arp_clear_address_req(async_sess_t *sess, device_id_t device_id,
     86int arp_clear_address_req(async_sess_t *sess, nic_device_id_t device_id,
    8787    services_t protocol, measured_string_t *address)
    8888{
     
    108108 *
    109109 */
    110 int arp_clear_device_req(async_sess_t *sess, device_id_t device_id)
     110int arp_clear_device_req(async_sess_t *sess, nic_device_id_t device_id)
    111111{
    112112        async_exch_t *exch = async_exchange_begin(sess);
     
    143143 *
    144144 */
    145 int arp_device_req(async_sess_t *sess, device_id_t device_id,
     145int arp_device_req(async_sess_t *sess, nic_device_id_t device_id,
    146146    services_t protocol, services_t netif, measured_string_t *address)
    147147{
     
    177177 *
    178178 */
    179 int arp_translate_req(async_sess_t *sess, device_id_t device_id,
     179int arp_translate_req(async_sess_t *sess, nic_device_id_t device_id,
    180180    services_t protocol, measured_string_t *address,
    181181    measured_string_t **translation, uint8_t **data)
  • uspace/lib/net/il/il_remote.c

    re68c834 r7a68fe5  
    5555 *
    5656 */
    57 int il_device_state_msg(async_sess_t *sess, device_id_t device_id,
    58     device_state_t state, services_t target)
     57int il_device_state_msg(async_sess_t *sess, nic_device_id_t device_id,
     58    nic_device_state_t state, services_t target)
    5959{
    6060        return generic_device_state_msg_remote(sess, NET_IL_DEVICE_STATE,
     
    7373 *
    7474 */
    75 int il_received_msg(async_sess_t *sess, device_id_t device_id, packet_t *packet,
    76     services_t target)
     75int il_received_msg(async_sess_t *sess, nic_device_id_t device_id,
     76    packet_t *packet, services_t target)
    7777{
    7878        return generic_received_msg_remote(sess, NET_IL_RECEIVED, device_id,
     
    9191 *
    9292 */
    93 int il_mtu_changed_msg(async_sess_t *sess, device_id_t device_id, size_t mtu,
     93int il_mtu_changed_msg(async_sess_t *sess, nic_device_id_t device_id, size_t mtu,
    9494    services_t target)
    9595{
     
    9898}
    9999
     100/** Notify IL layer modules about address change (implemented by ARP)
     101 *
     102 */
     103int il_addr_changed_msg(async_sess_t *sess, nic_device_id_t device_id,
     104    size_t addr_len, const uint8_t *address)
     105{
     106        async_exch_t *exch = async_exchange_begin(sess);
     107       
     108        aid_t message_id = async_send_1(exch, NET_IL_ADDR_CHANGED,
     109                        (sysarg_t) device_id, NULL);
     110        int rc = async_data_write_start(exch, address, addr_len);
     111       
     112        async_exchange_end(exch);
     113       
     114        sysarg_t res;
     115    async_wait_for(message_id, &res);
     116    if (rc != EOK)
     117                return rc;
     118       
     119    return (int) res;
     120}
     121
    100122/** @}
    101123 */
  • uspace/lib/net/il/ip_remote.c

    re68c834 r7a68fe5  
    6262 *
    6363 */
    64 int ip_add_route_req_remote(async_sess_t *sess, device_id_t device_id,
     64int ip_add_route_req_remote(async_sess_t *sess, nic_device_id_t device_id,
    6565    in_addr_t address, in_addr_t netmask, in_addr_t gateway)
    6666{
     
    123123 *
    124124 */
    125 int ip_device_req_remote(async_sess_t *sess, device_id_t device_id,
     125int ip_device_req(async_sess_t *sess, nic_device_id_t device_id,
    126126    services_t service)
    127127{
    128         return generic_device_req_remote(sess, NET_IP_DEVICE, device_id, 0,
     128        return generic_device_req_remote(sess, NET_IP_DEVICE, device_id,
    129129            service);
    130130}
     
    144144int ip_get_route_req_remote(async_sess_t *sess, ip_protocol_t protocol,
    145145    const struct sockaddr *destination, socklen_t addrlen,
    146     device_id_t *device_id, void **header, size_t *headerlen)
     146    nic_device_id_t *device_id, void **header, size_t *headerlen)
    147147{
    148148        if ((!destination) || (addrlen == 0))
     
    196196 *
    197197 */
    198 int ip_packet_size_req_remote(async_sess_t *sess, device_id_t device_id,
     198int ip_packet_size_req_remote(async_sess_t *sess, nic_device_id_t device_id,
    199199    packet_dimension_t *packet_dimension)
    200200{
     
    216216 *
    217217 */
    218 int ip_received_error_msg_remote(async_sess_t *sess, device_id_t device_id,
     218int ip_received_error_msg_remote(async_sess_t *sess, nic_device_id_t device_id,
    219219    packet_t *packet, services_t target, services_t error)
    220220{
     
    240240 *
    241241 */
    242 int ip_send_msg_remote(async_sess_t *sess, device_id_t device_id,
     242int ip_send_msg_remote(async_sess_t *sess, nic_device_id_t device_id,
    243243    packet_t *packet, services_t sender, services_t error)
    244244{
     
    256256 *
    257257 */
    258 int ip_set_gateway_req_remote(async_sess_t *sess, device_id_t device_id,
     258int ip_set_gateway_req_remote(async_sess_t *sess, nic_device_id_t device_id,
    259259    in_addr_t gateway)
    260260{
  • uspace/lib/net/include/arp_interface.h

    re68c834 r7a68fe5  
    4646/*@{*/
    4747
    48 extern int arp_device_req(async_sess_t *, device_id_t, services_t, services_t,
     48extern int arp_device_req(async_sess_t *, nic_device_id_t, services_t, services_t,
    4949    measured_string_t *);
    50 extern int arp_translate_req(async_sess_t *, device_id_t, services_t,
     50extern int arp_translate_req(async_sess_t *, nic_device_id_t, services_t,
    5151    measured_string_t *, measured_string_t **, uint8_t **);
    52 extern int arp_clear_device_req(async_sess_t *, device_id_t);
    53 extern int arp_clear_address_req(async_sess_t *, device_id_t, services_t,
     52extern int arp_clear_device_req(async_sess_t *, nic_device_id_t);
     53extern int arp_clear_address_req(async_sess_t *, nic_device_id_t, services_t,
    5454    measured_string_t *);
    5555extern int arp_clean_cache_req(async_sess_t *);
  • uspace/lib/net/include/generic.h

    re68c834 r7a68fe5  
    4545
    4646extern int generic_device_state_msg_remote(async_sess_t *, sysarg_t,
    47     device_id_t, sysarg_t, services_t);
    48 extern int generic_device_req_remote(async_sess_t *, sysarg_t, device_id_t,
    49     sysarg_t, services_t);
    50 extern int generic_get_addr_req(async_sess_t *, sysarg_t, device_id_t,
    51     measured_string_t **, uint8_t **);
    52 extern int generic_packet_size_req_remote(async_sess_t *, sysarg_t, device_id_t,
    53     packet_dimension_t *);
    54 extern int generic_received_msg_remote(async_sess_t *, sysarg_t, device_id_t,
     47    nic_device_id_t, sysarg_t, services_t);
     48extern int generic_device_req_remote(async_sess_t *, sysarg_t, nic_device_id_t,
     49    services_t);
     50extern int generic_get_addr_req(async_sess_t *, sysarg_t, nic_device_id_t,
     51    uint8_t *address, size_t max_length);
     52extern int generic_packet_size_req_remote(async_sess_t *, sysarg_t,
     53    nic_device_id_t, packet_dimension_t *);
     54extern int generic_received_msg_remote(async_sess_t *, sysarg_t,
     55    nic_device_id_t, packet_id_t, services_t, services_t);
     56extern int generic_send_msg_remote(async_sess_t *, sysarg_t, nic_device_id_t,
    5557    packet_id_t, services_t, services_t);
    56 extern int generic_send_msg_remote(async_sess_t *, sysarg_t, device_id_t,
    57     packet_id_t, services_t, services_t);
    58 extern int generic_translate_req(async_sess_t *, sysarg_t, device_id_t,
     58extern int generic_translate_req(async_sess_t *, sysarg_t, nic_device_id_t,
    5959    services_t, measured_string_t *, size_t, measured_string_t **, uint8_t **);
    6060
  • uspace/lib/net/include/il_remote.h

    re68c834 r7a68fe5  
    5050/*@{*/
    5151
    52 extern int il_device_state_msg(async_sess_t *, device_id_t, device_state_t,
     52extern int il_device_state_msg(async_sess_t *, nic_device_id_t,
     53    nic_device_state_t, services_t);
     54extern int il_received_msg(async_sess_t *, nic_device_id_t, packet_t *,
    5355    services_t);
    54 extern int il_received_msg(async_sess_t *, device_id_t, packet_t *, services_t);
    55 extern int il_mtu_changed_msg(async_sess_t *, device_id_t, size_t, services_t);
     56extern int il_mtu_changed_msg(async_sess_t *, nic_device_id_t, size_t,
     57    services_t);
     58extern int il_addr_changed_msg(async_sess_t *, nic_device_id_t, size_t,
     59    const uint8_t *);
    5660
    5761/*@}*/
  • uspace/lib/net/include/ip_interface.h

    re68c834 r7a68fe5  
    4646#define ip_set_gateway_req     ip_set_gateway_req_remote
    4747#define ip_packet_size_req     ip_packet_size_req_remote
    48 #define ip_device_req          ip_device_req_remote
    4948#define ip_add_route_req       ip_add_route_req_remote
    5049#define ip_send_msg            ip_send_msg_remote
     
    6968 *
    7069 */
    71 typedef int (*tl_received_msg_t)(device_id_t device_id, packet_t *packet,
     70typedef int (*tl_received_msg_t)(nic_device_id_t device_id, packet_t *packet,
    7271    services_t receiver, services_t error);
    7372
  • uspace/lib/net/include/ip_remote.h

    re68c834 r7a68fe5  
    4343#include <async.h>
    4444
    45 extern int ip_set_gateway_req_remote(async_sess_t *, device_id_t, in_addr_t);
    46 extern int ip_packet_size_req_remote(async_sess_t *, device_id_t,
     45extern int ip_set_gateway_req_remote(async_sess_t *, nic_device_id_t, in_addr_t);
     46extern int ip_packet_size_req_remote(async_sess_t *, nic_device_id_t,
    4747    packet_dimension_t *);
    48 extern int ip_received_error_msg_remote(async_sess_t *, device_id_t, packet_t *,
     48extern int ip_received_error_msg_remote(async_sess_t *, nic_device_id_t, packet_t *,
    4949    services_t, services_t);
    50 extern int ip_device_req_remote(async_sess_t *, device_id_t, services_t);
    51 extern int ip_add_route_req_remote(async_sess_t *, device_id_t, in_addr_t,
     50extern int ip_device_req(async_sess_t *, nic_device_id_t, services_t);
     51extern int ip_add_route_req_remote(async_sess_t *, nic_device_id_t, in_addr_t,
    5252    in_addr_t, in_addr_t);
    53 extern int ip_send_msg_remote(async_sess_t *, device_id_t, packet_t *,
     53extern int ip_send_msg_remote(async_sess_t *, nic_device_id_t, packet_t *,
    5454    services_t, services_t);
    5555extern int ip_get_route_req_remote(async_sess_t *, ip_protocol_t,
    56     const struct sockaddr *, socklen_t, device_id_t *, void **, size_t *);
     56    const struct sockaddr *, socklen_t, nic_device_id_t *, void **, size_t *);
    5757
    5858#endif
  • uspace/lib/net/include/net_checksum.h

    re68c834 r7a68fe5  
    3030 * @{
    3131 */
    32 
    3332/** @file
    3433 * General CRC and checksum computation.
     
    4241
    4342/** IP checksum value for computed zero checksum.
     43 *
    4444 * Zero is returned as 0xFFFF (not flipped)
     45 *
    4546 */
    46 #define IP_CHECKSUM_ZERO        0xffffU
     47#define IP_CHECKSUM_ZERO  0xffffU
    4748
    48 #ifdef ARCH_IS_BIG_ENDIAN
     49#ifdef __BE__
     50
    4951#define compute_crc32(seed, data, length) \
    5052        compute_crc32_be(seed, (uint8_t *) data, length)
    51 #else
     53
     54#endif
     55
     56#ifdef __LE__
     57
    5258#define compute_crc32(seed, data, length) \
    5359        compute_crc32_le(seed, (uint8_t *) data, length)
     60
    5461#endif
    5562
     
    6067extern uint16_t flip_checksum(uint16_t);
    6168extern uint16_t ip_checksum(uint8_t *, size_t);
     69extern uint64_t multicast_hash(const uint8_t addr[6]);
    6270
    6371#endif
  • uspace/lib/net/include/net_interface.h

    re68c834 r7a68fe5  
    3535
    3636#include <ipc/services.h>
    37 
    3837#include <net/device.h>
    3938#include <adt/measured_strings.h>
    4039#include <async.h>
     40#include <devman.h>
    4141
    4242/** @name Networking module interface
     
    4545/*@{*/
    4646
    47 extern int net_get_device_conf_req(async_sess_t *, device_id_t,
     47extern int net_get_device_conf_req(async_sess_t *, nic_device_id_t,
    4848    measured_string_t **, size_t, uint8_t **);
    4949extern int net_get_conf_req(async_sess_t *, measured_string_t **, size_t,
    5050    uint8_t **);
    5151extern void net_free_settings(measured_string_t *, uint8_t *);
     52extern int net_get_devices_req(async_sess_t *, measured_string_t **, size_t *,
     53    uint8_t **);
     54extern int net_driver_ready(async_sess_t *, devman_handle_t);
    5255extern async_sess_t *net_connect_module(void);
    5356
  • uspace/lib/net/include/nil_remote.h

    re68c834 r7a68fe5  
    3434#define __NET_NIL_REMOTE_H__
    3535
    36 #include <ipc/services.h>
    3736#include <net/device.h>
    3837#include <net/packet.h>
     38#include <devman.h>
    3939#include <generic.h>
    4040#include <async.h>
     
    5858            packet_get_id(packet), sender, 0)
    5959
    60 #define nil_device_req(sess, device_id, mtu, netif_service) \
    61         generic_device_req_remote(sess, NET_NIL_DEVICE, device_id, mtu, \
    62             netif_service)
    63 
    64 extern int nil_device_state_msg(async_sess_t *, device_id_t, sysarg_t);
    65 extern int nil_received_msg(async_sess_t *, device_id_t, packet_t *,
    66     services_t);
     60extern int nil_device_req(async_sess_t *, nic_device_id_t, devman_handle_t,
     61    size_t);
     62extern int nil_device_state_msg(async_sess_t *, nic_device_id_t, sysarg_t);
     63extern int nil_received_msg(async_sess_t *, nic_device_id_t, packet_id_t);
     64extern int nil_addr_changed_msg(async_sess_t *, nic_device_id_t,
     65    const nic_address_t *);
    6766
    6867#endif
  • uspace/lib/net/include/nil_skel.h

    re68c834 r7a68fe5  
    7070 *
    7171 */
    72 extern int nil_device_state_msg_local(device_id_t device_id, sysarg_t state);
     72extern int nil_device_state_msg_local(nic_device_id_t device_id, sysarg_t state);
    7373
    7474/** Pass the packet queue to the network interface layer.
     
    8181 * @param[in] device_id Source device identifier.
    8282 * @param[in] packet    Received packet or the received packet queue.
    83  * @param[in] target    Target service. Ignored parameter.
    8483 *
    8584 * @return EOK on success.
     
    8887 *
    8988 */
    90 extern int nil_received_msg_local(device_id_t device_id, packet_t *packet,
    91     services_t target);
     89extern int nil_received_msg_local(nic_device_id_t device_id, packet_t *packet);
    9290
    9391/** Message processing function.
  • uspace/lib/net/include/tl_common.h

    re68c834 r7a68fe5  
    5252
    5353extern int tl_get_ip_packet_dimension(async_sess_t *, packet_dimensions_t *,
    54     device_id_t, packet_dimension_t **);
     54    nic_device_id_t, packet_dimension_t **);
    5555extern int tl_get_address_port(const struct sockaddr *, int, uint16_t *);
    56 extern int tl_update_ip_packet_dimension(packet_dimensions_t *, device_id_t,
     56extern int tl_update_ip_packet_dimension(packet_dimensions_t *, nic_device_id_t,
    5757    size_t);
    5858extern int tl_set_address_port(struct sockaddr *, int, uint16_t);
  • uspace/lib/net/include/tl_remote.h

    re68c834 r7a68fe5  
    5151/*@{*/
    5252
    53 extern int tl_received_msg(async_sess_t *, device_id_t, packet_t *, services_t,
    54     services_t);
     53extern int tl_received_msg(async_sess_t *, nic_device_id_t, packet_t *,
     54    services_t, services_t);
    5555
    5656/*@}*/
  • uspace/lib/net/nil/nil_remote.c

    re68c834 r7a68fe5  
    5454 *
    5555 */
    56 int nil_device_state_msg(async_sess_t *sess, device_id_t device_id,
     56int nil_device_state_msg(async_sess_t *sess, nic_device_id_t device_id,
    5757    sysarg_t state)
    5858{
     
    7676 *
    7777 */
    78 int nil_received_msg(async_sess_t *sess, device_id_t device_id,
    79     packet_t *packet, services_t target)
     78int nil_received_msg(async_sess_t *sess, nic_device_id_t device_id,
     79    packet_id_t packet_id)
    8080{
    8181        return generic_received_msg_remote(sess, NET_NIL_RECEIVED,
    82             device_id, packet_get_id(packet), target, 0);
     82            device_id, packet_id, 0, 0);
     83}
     84
     85/** Notify upper layers that device address has changed
     86 *
     87 */
     88int nil_addr_changed_msg(async_sess_t *sess, nic_device_id_t device_id,
     89    const nic_address_t *address)
     90{
     91        assert(sess);
     92       
     93        async_exch_t *exch = async_exchange_begin(sess);
     94       
     95        aid_t message_id = async_send_1(exch, NET_NIL_ADDR_CHANGED,
     96            (sysarg_t) device_id, NULL);
     97        int rc = async_data_write_start(exch, address, sizeof (nic_address_t));
     98       
     99        async_exchange_end(exch);
     100       
     101        sysarg_t res;
     102    async_wait_for(message_id, &res);
     103       
     104    if (rc != EOK)
     105                return rc;
     106       
     107    return (int) res;
     108}
     109
     110int nil_device_req(async_sess_t *sess, nic_device_id_t device_id,
     111    devman_handle_t handle, size_t mtu)
     112{
     113        async_exch_t *exch = async_exchange_begin(sess);
     114        int rc = async_req_3_0(exch, NET_NIL_DEVICE, (sysarg_t) device_id,
     115            (sysarg_t) handle, (sysarg_t) mtu);
     116        async_exchange_end(exch);
     117        return rc;
    83118}
    84119
  • uspace/lib/net/tl/icmp_client.c

    re68c834 r7a68fe5  
    3939#include <icmp_header.h>
    4040#include <packet_client.h>
    41 
    42 #ifdef CONFIG_DEBUG
    43 #include <stdio.h>
    44 #endif
    45 
    4641#include <errno.h>
    4742#include <sys/types.h>
    48 
    4943#include <net/icmp_codes.h>
    5044#include <net/packet.h>
     
    6054 * @return              Zero if the packet contains no data.
    6155 */
    62 int
    63 icmp_client_process_packet(packet_t *packet, icmp_type_t *type,
     56int icmp_client_process_packet(packet_t *packet, icmp_type_t *type,
    6457    icmp_code_t *code, icmp_param_t *pointer, icmp_param_t *mtu)
    6558{
     
    8174                *mtu = header->un.frag.mtu;
    8275
    83         /* Remove debug dump */
    84 #ifdef CONFIG_DEBUG
    85         printf("ICMP error %d (%d) in packet %d\n", header->type, header->code,
    86             packet_get_id(packet));
    87 #endif
    8876        return sizeof(icmp_header_t);
    8977}
  • uspace/lib/net/tl/tl_common.c

    re68c834 r7a68fe5  
    119119 */
    120120int tl_get_ip_packet_dimension(async_sess_t *sess,
    121     packet_dimensions_t *packet_dimensions, device_id_t device_id,
     121    packet_dimensions_t *packet_dimensions, nic_device_id_t device_id,
    122122    packet_dimension_t **packet_dimension)
    123123{
     
    160160int
    161161tl_update_ip_packet_dimension(packet_dimensions_t *packet_dimensions,
    162     device_id_t device_id, size_t content)
     162    nic_device_id_t device_id, size_t content)
    163163{
    164164        packet_dimension_t *packet_dimension;
     
    170170        packet_dimension->content = content;
    171171
    172         if (device_id != DEVICE_INVALID_ID) {
     172        if (device_id != NIC_DEVICE_INVALID_ID) {
    173173                packet_dimension = packet_dimensions_find(packet_dimensions,
    174                     DEVICE_INVALID_ID);
     174                    NIC_DEVICE_INVALID_ID);
    175175
    176176                if (packet_dimension) {
     
    179179                        else
    180180                                packet_dimensions_exclude(packet_dimensions,
    181                                     DEVICE_INVALID_ID, free);
     181                                    NIC_DEVICE_INVALID_ID, free);
    182182                }
    183183        }
  • uspace/lib/net/tl/tl_remote.c

    re68c834 r7a68fe5  
    5656 *
    5757 */
    58 int tl_received_msg(async_sess_t *sess, device_id_t device_id, packet_t *packet,
     58int tl_received_msg(async_sess_t *sess, nic_device_id_t device_id, packet_t *packet,
    5959    services_t target, services_t error)
    6060{
  • uspace/lib/net/tl/tl_skel.c

    re68c834 r7a68fe5  
    123123                goto out;
    124124       
     125        task_retval(0);
    125126        async_manager();
    126127       
  • uspace/lib/nic/Makefile

    re68c834 r7a68fe5  
    11#
    2 # Copyright (c) 2005 Martin Decky
    3 # Copyright (c) 2007 Jakub Jermar
     2# Copyright (c) 2011 Radim Vansa
    43# All rights reserved.
    54#
     
    2827#
    2928
    30 USPACE_PREFIX = ../../../..
    31 ROOT_PATH = $(USPACE_PREFIX)/..
    32 LIBS = $(LIBNET_PREFIX)/libnet.a
    33 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include
    34 
    35 COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common
    36 CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config
    37 
    38 -include $(COMMON_MAKEFILE)
    39 -include $(CONFIG_MAKEFILE)
    40 
    41 BINARY = ne2000
     29USPACE_PREFIX = ../..
     30LIBRARY = libnic
     31LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNET_PREFIX)/libnet.a
     32EXTRA_CFLAGS += -DLIBNIC_INTERNAL -Iinclude -I$(LIBDRV_PREFIX)/include -I$(LIBNET_PREFIX)/include
    4233
    4334SOURCES = \
    44         dp8390.c \
    45         ne2000.c
     35        src/nic_driver.c \
     36        src/nic_addr_db.c \
     37        src/nic_rx_control.c \
     38        src/nic_wol_virtues.c \
     39        src/nic_impl.c
    4640
    4741include $(USPACE_PREFIX)/Makefile.common
Note: See TracChangeset for help on using the changeset viewer.