Changeset cf9cb36 in mainline for uspace/lib/nic


Ignore:
Timestamp:
2012-01-22T13:41:20Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
eb2efc7
Parents:
8d7ec69d
Message:

Decouple libnic from libnet.

Location:
uspace/lib/nic
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/nic/Makefile

    r8d7ec69d rcf9cb36  
    2929USPACE_PREFIX = ../..
    3030LIBRARY = libnic
    31 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNET_PREFIX)/libnet.a
    32 EXTRA_CFLAGS += -DLIBNIC_INTERNAL -Iinclude -I$(LIBDRV_PREFIX)/include -I$(LIBNET_PREFIX)/include
     31#LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBNET_PREFIX)/libnet.a
     32EXTRA_CFLAGS += -DLIBNIC_INTERNAL -Iinclude -I$(LIBDRV_PREFIX)/include
     33# -I$(LIBNET_PREFIX)/include
    3334
    3435SOURCES = \
  • uspace/lib/nic/include/nic_driver.h

    r8d7ec69d rcf9cb36  
    4444
    4545#include <fibril_synch.h>
    46 #include <net/device.h>
     46#include <nic/nic.h>
    4747#include <async.h>
    4848
  • uspace/lib/nic/include/nic_ev.h

    r8d7ec69d rcf9cb36  
    4040
    4141#include <async.h>
    42 /* XXX for nic_device_id_t and nic_address_t */
    43 #include <net/device.h>
     42#include <nic/nic.h>
    4443#include <sys/types.h>
    4544
  • uspace/lib/nic/include/nic_impl.h

    r8d7ec69d rcf9cb36  
    4040
    4141#include <assert.h>
    42 #include <net/device.h>
     42#include <nic/nic.h>
    4343#include <ddf/driver.h>
    44 #include <nil_remote.h>
    4544
    4645/* Inclusion of this file is not prohibited, because drivers could want to
  • uspace/lib/nic/include/nic_rx_control.h

    r8d7ec69d rcf9cb36  
    4545#include <adt/hash_table.h>
    4646#include <fibril_synch.h>
    47 #include <net/device.h>
     47#include <nic/nic.h>
    4848
    4949#include "nic_addr_db.h"
  • uspace/lib/nic/include/nic_wol_virtues.h

    r8d7ec69d rcf9cb36  
    4343#endif
    4444
    45 #include <net/device.h>
     45#include <nic/nic.h>
    4646#include <adt/hash_table.h>
    4747#include "nic.h"
  • uspace/lib/nic/src/nic_ev.c

    r8d7ec69d rcf9cb36  
    3838#include <async.h>
    3939#include <device/nic.h>
     40#include <errno.h>
    4041#include "nic_ev.h"
    4142
  • uspace/lib/nic/src/nic_impl.c

    r8d7ec69d rcf9cb36  
    3636 */
    3737
     38#include <errno.h>
    3839#include <str_error.h>
    3940#include <ipc/services.h>
  • uspace/lib/nic/src/nic_rx_control.c

    r8d7ec69d rcf9cb36  
    4040#include <bool.h>
    4141#include <errno.h>
    42 #include <net/device.h>
    43 #include <net_checksum.h>
    44 #include <packet_client.h>
     42#include <mem.h>
     43#include <nic/nic.h>
    4544#include "nic_rx_control.h"
    4645
     
    488487}
    489488
     489/** Polynomial used in multicast address hashing */
     490#define CRC_MCAST_POLYNOMIAL  0x04c11db6
     491
     492/** Compute the standard hash from MAC
     493 *
     494 * Hashing MAC into 64 possible values and using the value as index to
     495 * 64bit number.
     496 *
     497 * The code is copied from qemu-0.13's implementation of ne2000 and rt8139
     498 * drivers, but according to documentation there it originates in FreeBSD.
     499 *
     500 * @param[in] addr The 6-byte MAC address to be hashed
     501 *
     502 * @return 64-bit number with only single bit set to 1
     503 *
     504 */
     505static uint64_t multicast_hash(const uint8_t addr[6])
     506{
     507        uint32_t crc;
     508    int carry, i, j;
     509    uint8_t b;
     510
     511    crc = 0xffffffff;
     512    for (i = 0; i < 6; i++) {
     513        b = addr[i];
     514        for (j = 0; j < 8; j++) {
     515            carry = ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01);
     516            crc <<= 1;
     517            b >>= 1;
     518            if (carry)
     519                crc = ((crc ^ CRC_MCAST_POLYNOMIAL) | carry);
     520        }
     521    }
     522       
     523    uint64_t one64 = 1;
     524    return one64 << (crc >> 26);
     525}
     526
     527
    490528/**
    491529 * Computes hash for the address list based on standard multicast address
  • uspace/lib/nic/src/nic_wol_virtues.c

    r8d7ec69d rcf9cb36  
    3838#include "nic_wol_virtues.h"
    3939#include <assert.h>
     40#include <errno.h>
    4041
    4142#define NIC_WV_HASH_COUNT 32
Note: See TracChangeset for help on using the changeset viewer.