Home | History | Annotate | Line # | Download | only in cxgb
cxgb_osdep.h revision 1.1.4.3
      1  1.1.4.2  rmind /**************************************************************************
      2  1.1.4.2  rmind 
      3  1.1.4.2  rmind Copyright (c) 2007, Chelsio Inc.
      4  1.1.4.2  rmind All rights reserved.
      5  1.1.4.2  rmind 
      6  1.1.4.2  rmind Redistribution and use in source and binary forms, with or without
      7  1.1.4.2  rmind modification, are permitted provided that the following conditions are met:
      8  1.1.4.2  rmind 
      9  1.1.4.2  rmind  1. Redistributions of source code must retain the above copyright notice,
     10  1.1.4.2  rmind     this list of conditions and the following disclaimer.
     11  1.1.4.2  rmind 
     12  1.1.4.2  rmind  2. Neither the name of the Chelsio Corporation nor the names of its
     13  1.1.4.2  rmind     contributors may be used to endorse or promote products derived from
     14  1.1.4.2  rmind     this software without specific prior written permission.
     15  1.1.4.2  rmind 
     16  1.1.4.2  rmind THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     17  1.1.4.2  rmind AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  1.1.4.2  rmind IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.1.4.2  rmind ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     20  1.1.4.2  rmind LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.1.4.2  rmind CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.1.4.2  rmind SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.1.4.2  rmind INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.1.4.2  rmind CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.1.4.2  rmind ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.1.4.2  rmind POSSIBILITY OF SUCH DAMAGE.
     27  1.1.4.2  rmind 
     28  1.1.4.2  rmind 
     29  1.1.4.2  rmind ***************************************************************************/
     30  1.1.4.2  rmind 
     31  1.1.4.2  rmind #include <sys/param.h>
     32  1.1.4.2  rmind #include <sys/systm.h>
     33  1.1.4.2  rmind #include <sys/endian.h>
     34  1.1.4.2  rmind 
     35  1.1.4.2  rmind #include <dev/mii/mii.h>
     36  1.1.4.2  rmind 
     37  1.1.4.2  rmind #ifndef _CXGB_OSDEP_H_
     38  1.1.4.2  rmind #define _CXGB_OSDEP_H_
     39  1.1.4.2  rmind 
     40  1.1.4.2  rmind typedef char *caddr_t;
     41  1.1.4.2  rmind #include <dev/pci/cxgb/cxgb_version.h>
     42  1.1.4.2  rmind #include <dev/pci/cxgb/cxgb_config.h>
     43  1.1.4.2  rmind #include <sys/mbuf.h>
     44  1.1.4.3  rmind #include <sys/bus.h>
     45  1.1.4.2  rmind 
     46  1.1.4.2  rmind #include <netinet/in_systm.h>
     47  1.1.4.2  rmind #include <netinet/in.h>
     48  1.1.4.2  rmind #include <netinet/ip.h>
     49  1.1.4.2  rmind 
     50  1.1.4.2  rmind #include <sys/simplelock.h>
     51  1.1.4.2  rmind 
     52  1.1.4.2  rmind #include <sys/kthread.h>
     53  1.1.4.2  rmind #include <sys/workqueue.h>
     54  1.1.4.2  rmind 
     55  1.1.4.2  rmind #include <sys/atomic.h>
     56  1.1.4.2  rmind 
     57  1.1.4.2  rmind void pci_enable_busmaster(device_t dev);
     58  1.1.4.2  rmind 
     59  1.1.4.2  rmind struct cxgb_task
     60  1.1.4.2  rmind {
     61  1.1.4.2  rmind     const char *name;
     62  1.1.4.2  rmind     void (*func)(struct work *, void *);
     63  1.1.4.2  rmind     struct workqueue *wq;
     64  1.1.4.2  rmind     struct work w;
     65  1.1.4.2  rmind     void *context;
     66  1.1.4.2  rmind };
     67  1.1.4.2  rmind 
     68  1.1.4.2  rmind void cxgb_make_task(void *);
     69  1.1.4.2  rmind 
     70  1.1.4.2  rmind void m_cljset(struct mbuf *m, void *cl, int type);
     71  1.1.4.2  rmind 
     72  1.1.4.2  rmind #define mtx simplelock
     73  1.1.4.2  rmind #define mtx_init(a, b, c, d) { (a)->lock_data = __SIMPLELOCK_UNLOCKED; }
     74  1.1.4.2  rmind #define mtx_destroy(a)
     75  1.1.4.2  rmind #define mtx_lock(a) simple_lock(a)
     76  1.1.4.2  rmind #define mtx_unlock(a) simple_unlock(a)
     77  1.1.4.2  rmind #define mtx_trylock(a) simple_lock_try(a)
     78  1.1.4.2  rmind #define MA_OWNED 1
     79  1.1.4.2  rmind #define MA_NOTOWNED 0
     80  1.1.4.2  rmind #define mtx_assert(a, w)
     81  1.1.4.2  rmind 
     82  1.1.4.2  rmind #if 0
     83  1.1.4.2  rmind #define RT_LOCK_INIT(_rt) \
     84  1.1.4.2  rmind         mtx_init(&(_rt)->rt_mtx, "rtentry", NULL, MTX_DEF | MTX_DUPOK)
     85  1.1.4.2  rmind #define RT_LOCK(_rt)            mtx_lock(&(_rt)->rt_mtx)
     86  1.1.4.2  rmind #define RT_UNLOCK(_rt)          mtx_unlock(&(_rt)->rt_mtx)
     87  1.1.4.2  rmind #define RT_LOCK_DESTROY(_rt)    mtx_destroy(&(_rt)->rt_mtx)
     88  1.1.4.2  rmind #define RT_LOCK_ASSERT(_rt)     mtx_assert(&(_rt)->rt_mtx, MA_OWNED)
     89  1.1.4.2  rmind #else
     90  1.1.4.2  rmind #define RT_LOCK_INIT(_rt)
     91  1.1.4.2  rmind #define RT_LOCK(_rt)
     92  1.1.4.2  rmind #define RT_UNLOCK(_rt)
     93  1.1.4.2  rmind #define RT_LOCK_DESTROY(_rt)
     94  1.1.4.2  rmind #define RT_LOCK_ASSERT(_rt)
     95  1.1.4.2  rmind #endif
     96  1.1.4.2  rmind 
     97  1.1.4.2  rmind #define RT_ADDREF(_rt)  do {                                    \
     98  1.1.4.2  rmind         RT_LOCK_ASSERT(_rt);                                    \
     99  1.1.4.2  rmind         KASSERT((_rt)->rt_refcnt >= 0);                         \
    100  1.1.4.2  rmind         (_rt)->rt_refcnt++;                                     \
    101  1.1.4.2  rmind } while (0)
    102  1.1.4.2  rmind #define RT_REMREF(_rt)  do {                                    \
    103  1.1.4.2  rmind         RT_LOCK_ASSERT(_rt);                                    \
    104  1.1.4.2  rmind         KASSERT((_rt)->rt_refcnt > 0);                          \
    105  1.1.4.2  rmind         (_rt)->rt_refcnt--;                                     \
    106  1.1.4.2  rmind } while (0)
    107  1.1.4.2  rmind 
    108  1.1.4.2  rmind 
    109  1.1.4.2  rmind #define EVL_VLID_MASK       0x0FFF
    110  1.1.4.2  rmind 
    111  1.1.4.2  rmind static inline void critical_enter(void)
    112  1.1.4.2  rmind {
    113  1.1.4.2  rmind }
    114  1.1.4.2  rmind 
    115  1.1.4.2  rmind static inline void critical_exit(void)
    116  1.1.4.2  rmind {
    117  1.1.4.2  rmind }
    118  1.1.4.2  rmind 
    119  1.1.4.2  rmind static inline void device_printf(device_t d, ...)
    120  1.1.4.2  rmind {
    121  1.1.4.2  rmind }
    122  1.1.4.2  rmind 
    123  1.1.4.2  rmind int atomic_fetchadd_int(volatile int *p, int v);
    124  1.1.4.2  rmind #if 0
    125  1.1.4.2  rmind int atomic_add_int(volatile int *p, int v);
    126  1.1.4.2  rmind #endif
    127  1.1.4.2  rmind int atomic_load_acq_int(volatile int *p);
    128  1.1.4.2  rmind void atomic_store_rel_int(volatile int *p, int v);
    129  1.1.4.2  rmind 
    130  1.1.4.2  rmind u_short in_cksum_hdr(struct ip *ih);
    131  1.1.4.2  rmind 
    132  1.1.4.2  rmind #define if_drv_flags if_flags
    133  1.1.4.2  rmind #define IFF_DRV_RUNNING IFF_RUNNING
    134  1.1.4.2  rmind #define IFF_DRV_OACTIVE IFF_OACTIVE
    135  1.1.4.2  rmind 
    136  1.1.4.2  rmind #define MJUM16BYTES (16*1024)
    137  1.1.4.2  rmind #define MJUMPAGESIZE PAGE_SIZE
    138  1.1.4.2  rmind 
    139  1.1.4.2  rmind #if 0
    140  1.1.4.2  rmind #define rw_rlock(x) rw_enter(x, RW_READER)
    141  1.1.4.2  rmind #define rw_runlock(x) rw_exit(x)
    142  1.1.4.2  rmind #define rw_wlock(x) rw_enter(x, RW_WRITER)
    143  1.1.4.2  rmind #define rw_wunlock(x) rw_exit(x)
    144  1.1.4.2  rmind #endif
    145  1.1.4.2  rmind 
    146  1.1.4.2  rmind #define callout_drain(x) callout_stop(x)
    147  1.1.4.2  rmind 
    148  1.1.4.2  rmind static inline int atomic_cmpset_ptr(volatile long *dst, long exp, long src)
    149  1.1.4.2  rmind {
    150  1.1.4.2  rmind     if (*dst == exp)
    151  1.1.4.2  rmind     {
    152  1.1.4.2  rmind         *dst = src;
    153  1.1.4.2  rmind         return (1);
    154  1.1.4.2  rmind     }
    155  1.1.4.2  rmind     return (0);
    156  1.1.4.2  rmind }
    157  1.1.4.2  rmind #define atomic_cmpset_int(a, b, c) atomic_cmpset_ptr((volatile long *)a, (long)b, (long)c)
    158  1.1.4.2  rmind 
    159  1.1.4.2  rmind static inline int atomic_set_int(volatile int *dst, int val)
    160  1.1.4.2  rmind {
    161  1.1.4.2  rmind     *dst = val;
    162  1.1.4.2  rmind 
    163  1.1.4.2  rmind     return (val);
    164  1.1.4.2  rmind }
    165  1.1.4.2  rmind 
    166  1.1.4.2  rmind static inline void log(int x, ...)
    167  1.1.4.2  rmind {
    168  1.1.4.2  rmind }
    169  1.1.4.2  rmind 
    170  1.1.4.2  rmind struct cxgb_attach_args
    171  1.1.4.2  rmind {
    172  1.1.4.2  rmind     int port;
    173  1.1.4.2  rmind };
    174  1.1.4.2  rmind 
    175  1.1.4.2  rmind #define INT3 __asm("int $3")
    176  1.1.4.2  rmind 
    177  1.1.4.2  rmind static inline struct mbuf *
    178  1.1.4.2  rmind m_defrag(struct mbuf *m0, int flags)
    179  1.1.4.2  rmind {
    180  1.1.4.2  rmind         struct mbuf *m;
    181  1.1.4.2  rmind         MGETHDR(m, flags, MT_DATA);
    182  1.1.4.2  rmind         if (m == NULL)
    183  1.1.4.2  rmind                 return NULL;
    184  1.1.4.2  rmind 
    185  1.1.4.2  rmind         M_COPY_PKTHDR(m, m0);
    186  1.1.4.2  rmind         MCLGET(m, flags);
    187  1.1.4.2  rmind         if ((m->m_flags & M_EXT) == 0) {
    188  1.1.4.2  rmind                 m_free(m);
    189  1.1.4.2  rmind                 return NULL;
    190  1.1.4.2  rmind         }
    191  1.1.4.2  rmind         m_copydata(m0, 0, m0->m_pkthdr.len, mtod(m, void *));
    192  1.1.4.2  rmind         m->m_len = m->m_pkthdr.len;
    193  1.1.4.2  rmind         return m;
    194  1.1.4.2  rmind }
    195  1.1.4.2  rmind 
    196  1.1.4.2  rmind 
    197  1.1.4.2  rmind typedef struct adapter adapter_t;
    198  1.1.4.2  rmind struct sge_rspq;
    199  1.1.4.2  rmind 
    200  1.1.4.2  rmind struct t3_mbuf_hdr {
    201  1.1.4.2  rmind     struct mbuf *mh_head;
    202  1.1.4.2  rmind     struct mbuf *mh_tail;
    203  1.1.4.2  rmind };
    204  1.1.4.2  rmind 
    205  1.1.4.2  rmind 
    206  1.1.4.2  rmind #define PANIC_IF(exp) do {                  \
    207  1.1.4.2  rmind     if (exp)                            \
    208  1.1.4.2  rmind         panic("BUG: %s", exp);      \
    209  1.1.4.2  rmind } while (0)
    210  1.1.4.2  rmind 
    211  1.1.4.2  rmind 
    212  1.1.4.2  rmind #define m_get_priority(m) ((uintptr_t)(m)->m_pkthdr.rcvif)
    213  1.1.4.2  rmind #define m_set_priority(m, pri) ((m)->m_pkthdr.rcvif = (struct ifnet *)((uintptr_t)pri))
    214  1.1.4.2  rmind 
    215  1.1.4.2  rmind #define if_name(ifp) (ifp)->if_xname
    216  1.1.4.2  rmind #define M_SANITY(m, n)
    217  1.1.4.2  rmind 
    218  1.1.4.2  rmind #define __read_mostly __section(".data.read_mostly")
    219  1.1.4.2  rmind 
    220  1.1.4.2  rmind /*
    221  1.1.4.2  rmind  * Workaround for weird Chelsio issue
    222  1.1.4.2  rmind  */
    223  1.1.4.2  rmind #define CXGB_TX_CLEANUP_THRESHOLD        32
    224  1.1.4.2  rmind 
    225  1.1.4.2  rmind #define LOG_WARNING                       1
    226  1.1.4.2  rmind #define LOG_ERR                           2
    227  1.1.4.2  rmind 
    228  1.1.4.2  rmind #define DPRINTF printf
    229  1.1.4.2  rmind 
    230  1.1.4.2  rmind #define TX_MAX_SIZE                (1 << 16)    /* 64KB                          */
    231  1.1.4.2  rmind #define TX_MAX_SEGS                      36     /* maximum supported by card     */
    232  1.1.4.2  rmind #define TX_MAX_DESC                       4     /* max descriptors per packet    */
    233  1.1.4.2  rmind 
    234  1.1.4.2  rmind #define TX_START_MIN_DESC  (TX_MAX_DESC << 2)
    235  1.1.4.2  rmind 
    236  1.1.4.2  rmind #if 0
    237  1.1.4.2  rmind #define TX_START_MAX_DESC (TX_ETH_Q_SIZE >> 2)  /* maximum number of descriptors */
    238  1.1.4.2  rmind #endif
    239  1.1.4.2  rmind 
    240  1.1.4.2  rmind #define TX_START_MAX_DESC (TX_MAX_DESC << 3)    /* maximum number of descriptors
    241  1.1.4.2  rmind                          * call to start used per    */
    242  1.1.4.2  rmind 
    243  1.1.4.2  rmind #define TX_CLEAN_MAX_DESC (TX_MAX_DESC << 4)    /* maximum tx descriptors
    244  1.1.4.2  rmind                          * to clean per iteration        */
    245  1.1.4.2  rmind 
    246  1.1.4.2  rmind 
    247  1.1.4.2  rmind #if defined(__i386__) || defined(__amd64__)
    248  1.1.4.2  rmind #define mb()    __asm volatile("mfence":::"memory")
    249  1.1.4.2  rmind #define rmb()   __asm volatile("lfence":::"memory")
    250  1.1.4.2  rmind #define wmb()   __asm volatile("sfence" ::: "memory")
    251  1.1.4.2  rmind #define smp_mb() mb()
    252  1.1.4.2  rmind 
    253  1.1.4.2  rmind #define L1_CACHE_BYTES 64
    254  1.1.4.2  rmind static __inline
    255  1.1.4.2  rmind void prefetch(void *x)
    256  1.1.4.2  rmind {
    257  1.1.4.2  rmind         __asm volatile("prefetcht0 %0" :: "m" (*(unsigned long *)x));
    258  1.1.4.2  rmind }
    259  1.1.4.2  rmind 
    260  1.1.4.2  rmind extern void kdb_backtrace(void);
    261  1.1.4.2  rmind 
    262  1.1.4.2  rmind #define WARN_ON(condition) do { \
    263  1.1.4.2  rmind         if (unlikely((condition)!=0)) { \
    264  1.1.4.2  rmind                 log(LOG_WARNING, "BUG: warning at %s:%d/%s()\n", __FILE__, __LINE__, __func__); \
    265  1.1.4.2  rmind                 kdb_backtrace(); \
    266  1.1.4.2  rmind         } \
    267  1.1.4.2  rmind } while (0)
    268  1.1.4.2  rmind 
    269  1.1.4.2  rmind 
    270  1.1.4.2  rmind #else /* !i386 && !amd64 */
    271  1.1.4.2  rmind #define mb()
    272  1.1.4.2  rmind #define rmb()
    273  1.1.4.2  rmind #define wmb()
    274  1.1.4.2  rmind #define smp_mb()
    275  1.1.4.2  rmind #define prefetch(x)
    276  1.1.4.2  rmind #define L1_CACHE_BYTES 32
    277  1.1.4.2  rmind #endif
    278  1.1.4.2  rmind #define DBG_RX          (1 << 0)
    279  1.1.4.2  rmind static const int debug_flags = DBG_RX;
    280  1.1.4.2  rmind 
    281  1.1.4.2  rmind #ifdef DEBUG_PRINT
    282  1.1.4.2  rmind #define DBG(flag, msg) do { \
    283  1.1.4.2  rmind     if ((flag & debug_flags))   \
    284  1.1.4.2  rmind         printf msg; \
    285  1.1.4.2  rmind } while (0)
    286  1.1.4.2  rmind #else
    287  1.1.4.2  rmind #define DBG(...)
    288  1.1.4.2  rmind #endif
    289  1.1.4.2  rmind 
    290  1.1.4.2  rmind #define promisc_rx_mode(rm)  ((rm)->port->ifp->if_flags & IFF_PROMISC)
    291  1.1.4.2  rmind #define allmulti_rx_mode(rm) ((rm)->port->ifp->if_flags & IFF_ALLMULTI)
    292  1.1.4.2  rmind 
    293  1.1.4.2  rmind #define CH_ERR(adap, fmt, ...) { }
    294  1.1.4.2  rmind 
    295  1.1.4.2  rmind #define CH_WARN(adap, fmt, ...) { }
    296  1.1.4.2  rmind #define CH_ALERT(adap, fmt, ...) { }
    297  1.1.4.2  rmind 
    298  1.1.4.2  rmind #define t3_os_sleep(x) DELAY((x) * 1000)
    299  1.1.4.2  rmind 
    300  1.1.4.2  rmind #define test_and_clear_bit(bit, p) atomic_cmpset_int((p), ((*(p)) | bit), ((*(p)) & ~bit))
    301  1.1.4.2  rmind 
    302  1.1.4.2  rmind 
    303  1.1.4.2  rmind #define max_t(type, a, b) (type)max((a), (b))
    304  1.1.4.2  rmind #define net_device ifnet
    305  1.1.4.2  rmind #define cpu_to_be32            htobe32
    306  1.1.4.2  rmind 
    307  1.1.4.2  rmind 
    308  1.1.4.2  rmind 
    309  1.1.4.2  rmind /* Standard PHY definitions */
    310  1.1.4.2  rmind #define BMCR_LOOPBACK       BMCR_LOOP
    311  1.1.4.2  rmind #define BMCR_ISOLATE        BMCR_ISO
    312  1.1.4.2  rmind #define BMCR_ANENABLE       BMCR_AUTOEN
    313  1.1.4.2  rmind #define BMCR_SPEED1000      BMCR_SPEED1
    314  1.1.4.2  rmind #define BMCR_SPEED100       BMCR_SPEED0
    315  1.1.4.2  rmind #define BMCR_ANRESTART      BMCR_STARTNEG
    316  1.1.4.2  rmind #define BMCR_FULLDPLX       BMCR_FDX
    317  1.1.4.2  rmind #define BMSR_LSTATUS        BMSR_LINK
    318  1.1.4.2  rmind #define BMSR_ANEGCOMPLETE   BMSR_ACOMP
    319  1.1.4.2  rmind 
    320  1.1.4.2  rmind #define MII_LPA         MII_ANLPAR
    321  1.1.4.2  rmind #define MII_ADVERTISE       MII_ANAR
    322  1.1.4.2  rmind #define MII_CTRL1000        MII_100T2CR
    323  1.1.4.2  rmind 
    324  1.1.4.2  rmind #define ADVERTISE_PAUSE_CAP ANAR_FC
    325  1.1.4.2  rmind #define ADVERTISE_PAUSE_ASYM    0x0800
    326  1.1.4.2  rmind #define ADVERTISE_1000HALF  ANAR_X_HD
    327  1.1.4.2  rmind #define ADVERTISE_1000FULL  ANAR_X_FD
    328  1.1.4.2  rmind #define ADVERTISE_10FULL    ANAR_10_FD
    329  1.1.4.2  rmind #define ADVERTISE_10HALF    ANAR_10
    330  1.1.4.2  rmind #define ADVERTISE_100FULL   ANAR_TX_FD
    331  1.1.4.2  rmind #define ADVERTISE_100HALF   ANAR_TX
    332  1.1.4.2  rmind 
    333  1.1.4.2  rmind /* Standard PCI Extended Capaibilities definitions */
    334  1.1.4.2  rmind #define PCI_CAP_ID_VPD  0x03
    335  1.1.4.2  rmind #define PCI_VPD_ADDR    2
    336  1.1.4.2  rmind #define PCI_VPD_ADDR_F  0x8000
    337  1.1.4.2  rmind #define PCI_VPD_DATA    4
    338  1.1.4.2  rmind 
    339  1.1.4.2  rmind #define PCI_CAP_ID_EXP  0x10
    340  1.1.4.2  rmind #define PCI_EXP_DEVCTL  8
    341  1.1.4.2  rmind #define PCI_EXP_DEVCTL_PAYLOAD 0x00e0
    342  1.1.4.2  rmind #define PCI_EXP_LNKCTL  16
    343  1.1.4.2  rmind #define PCI_EXP_LNKSTA  18
    344  1.1.4.2  rmind 
    345  1.1.4.2  rmind /*
    346  1.1.4.2  rmind  * Linux compatibility macros
    347  1.1.4.2  rmind  */
    348  1.1.4.2  rmind 
    349  1.1.4.2  rmind /* Some simple translations */
    350  1.1.4.2  rmind #define __devinit
    351  1.1.4.2  rmind #define udelay(x) DELAY(x)
    352  1.1.4.2  rmind #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
    353  1.1.4.2  rmind #define le32_to_cpu(x) le32toh(x)
    354  1.1.4.2  rmind #define cpu_to_le32(x) htole32(x)
    355  1.1.4.2  rmind #define swab32(x) bswap32(x)
    356  1.1.4.2  rmind #define simple_strtoul strtoul
    357  1.1.4.2  rmind 
    358  1.1.4.2  rmind /* More types and endian definitions */
    359  1.1.4.2  rmind typedef uint8_t u8;
    360  1.1.4.2  rmind typedef uint16_t u16;
    361  1.1.4.2  rmind typedef uint32_t u32;
    362  1.1.4.2  rmind typedef uint64_t u64;
    363  1.1.4.2  rmind 
    364  1.1.4.2  rmind typedef uint8_t __u8;
    365  1.1.4.2  rmind typedef uint16_t __u16;
    366  1.1.4.2  rmind typedef uint32_t __u32;
    367  1.1.4.2  rmind typedef uint8_t __be8;
    368  1.1.4.2  rmind typedef uint16_t __be16;
    369  1.1.4.2  rmind typedef uint32_t __be32;
    370  1.1.4.2  rmind typedef uint64_t __be64;
    371  1.1.4.2  rmind 
    372  1.1.4.2  rmind #if BYTE_ORDER == BIG_ENDIAN
    373  1.1.4.2  rmind #define __BIG_ENDIAN_BITFIELD
    374  1.1.4.2  rmind #elif BYTE_ORDER == LITTLE_ENDIAN
    375  1.1.4.2  rmind #define __LITTLE_ENDIAN_BITFIELD
    376  1.1.4.2  rmind #else
    377  1.1.4.2  rmind #error "Must set BYTE_ORDER"
    378  1.1.4.2  rmind #endif
    379  1.1.4.2  rmind 
    380  1.1.4.2  rmind /* Indicates what features are supported by the interface. */
    381  1.1.4.2  rmind #define SUPPORTED_10baseT_Half          (1 << 0)
    382  1.1.4.2  rmind #define SUPPORTED_10baseT_Full          (1 << 1)
    383  1.1.4.2  rmind #define SUPPORTED_100baseT_Half         (1 << 2)
    384  1.1.4.2  rmind #define SUPPORTED_100baseT_Full         (1 << 3)
    385  1.1.4.2  rmind #define SUPPORTED_1000baseT_Half        (1 << 4)
    386  1.1.4.2  rmind #define SUPPORTED_1000baseT_Full        (1 << 5)
    387  1.1.4.2  rmind #define SUPPORTED_Autoneg               (1 << 6)
    388  1.1.4.2  rmind #define SUPPORTED_TP                    (1 << 7)
    389  1.1.4.2  rmind #define SUPPORTED_AUI                   (1 << 8)
    390  1.1.4.2  rmind #define SUPPORTED_MII                   (1 << 9)
    391  1.1.4.2  rmind #define SUPPORTED_FIBRE                 (1 << 10)
    392  1.1.4.2  rmind #define SUPPORTED_BNC                   (1 << 11)
    393  1.1.4.2  rmind #define SUPPORTED_10000baseT_Full       (1 << 12)
    394  1.1.4.2  rmind #define SUPPORTED_Pause                 (1 << 13)
    395  1.1.4.2  rmind #define SUPPORTED_Asym_Pause            (1 << 14)
    396  1.1.4.2  rmind 
    397  1.1.4.2  rmind /* Indicates what features are advertised by the interface. */
    398  1.1.4.2  rmind #define ADVERTISED_10baseT_Half         (1 << 0)
    399  1.1.4.2  rmind #define ADVERTISED_10baseT_Full         (1 << 1)
    400  1.1.4.2  rmind #define ADVERTISED_100baseT_Half        (1 << 2)
    401  1.1.4.2  rmind #define ADVERTISED_100baseT_Full        (1 << 3)
    402  1.1.4.2  rmind #define ADVERTISED_1000baseT_Half       (1 << 4)
    403  1.1.4.2  rmind #define ADVERTISED_1000baseT_Full       (1 << 5)
    404  1.1.4.2  rmind #define ADVERTISED_Autoneg              (1 << 6)
    405  1.1.4.2  rmind #define ADVERTISED_TP                   (1 << 7)
    406  1.1.4.2  rmind #define ADVERTISED_AUI                  (1 << 8)
    407  1.1.4.2  rmind #define ADVERTISED_MII                  (1 << 9)
    408  1.1.4.2  rmind #define ADVERTISED_FIBRE                (1 << 10)
    409  1.1.4.2  rmind #define ADVERTISED_BNC                  (1 << 11)
    410  1.1.4.2  rmind #define ADVERTISED_10000baseT_Full      (1 << 12)
    411  1.1.4.2  rmind #define ADVERTISED_Pause                (1 << 13)
    412  1.1.4.2  rmind #define ADVERTISED_Asym_Pause           (1 << 14)
    413  1.1.4.2  rmind 
    414  1.1.4.2  rmind /* Enable or disable autonegotiation.  If this is set to enable,
    415  1.1.4.2  rmind  * the forced link modes above are completely ignored.
    416  1.1.4.2  rmind  */
    417  1.1.4.2  rmind #define AUTONEG_DISABLE         0x00
    418  1.1.4.2  rmind #define AUTONEG_ENABLE          0x01
    419  1.1.4.2  rmind 
    420  1.1.4.2  rmind #define SPEED_10        10
    421  1.1.4.2  rmind #define SPEED_100       100
    422  1.1.4.2  rmind #define SPEED_1000      1000
    423  1.1.4.2  rmind #define SPEED_10000     10000
    424  1.1.4.2  rmind #define DUPLEX_HALF     0
    425  1.1.4.2  rmind #define DUPLEX_FULL     1
    426  1.1.4.2  rmind 
    427  1.1.4.2  rmind #endif
    428