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