if_iwm - Recognize IWM_FW_PAGING_BLOCK_CMD wide cmd response correctly.
[dragonfly.git] / sys / dev / netif / nfe / if_nfevar.h
1 /*      $OpenBSD: if_nfevar.h,v 1.11 2006/02/19 13:57:02 damien Exp $   */
2
3 /*
4  * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18
19 struct nfe_tx_data {
20         bus_dmamap_t    map;
21         struct mbuf     *m;
22 };
23
24 struct nfe_tx_ring {
25         bus_dma_tag_t           tag;
26         bus_dmamap_t            map;
27         bus_addr_t              physaddr;
28         struct nfe_desc32       *desc32;
29         struct nfe_desc64       *desc64;
30
31         bus_dma_tag_t           data_tag;
32         struct nfe_tx_data      *data;
33         int                     queued;
34         int                     cur;
35         int                     next;
36 };
37
38 struct nfe_softc;
39
40 struct nfe_jbuf {
41         struct nfe_softc        *sc;
42         struct nfe_rx_ring      *ring;
43         int                     inuse;
44         int                     slot;
45         caddr_t                 buf;
46         bus_addr_t              physaddr;
47         SLIST_ENTRY(nfe_jbuf)   jnext;
48 };
49
50 struct nfe_rx_data {
51         bus_dmamap_t    map;
52         struct mbuf     *m;
53 };
54
55 struct nfe_rx_ring {
56         bus_dma_tag_t           tag;
57         bus_dmamap_t            map;
58         bus_addr_t              physaddr;
59         struct nfe_desc32       *desc32;
60         struct nfe_desc64       *desc64;
61
62         bus_dma_tag_t           jtag;
63         bus_dmamap_t            jmap;
64         caddr_t                 jpool;
65         struct nfe_jbuf         *jbuf;
66         SLIST_HEAD(, nfe_jbuf)  jfreelist;
67
68         bus_dma_tag_t           data_tag;
69         bus_dmamap_t            data_tmpmap;
70         struct nfe_rx_data      *data;
71         int                     bufsz;
72         int                     cur;
73         int                     next;
74 };
75
76 struct nfe_softc {
77         struct arpcom           arpcom;
78
79         int                     sc_mem_rid;
80         time_t                  sc_rate_second;
81         int                     sc_rate_acc;
82         int                     sc_rate_avg;
83         struct resource         *sc_mem_res;
84         bus_space_handle_t      sc_memh;
85         bus_space_tag_t         sc_memt;
86
87         int                     sc_irq_rid;
88         struct resource         *sc_irq_res;
89         void                    *sc_ih;
90
91         device_t                sc_miibus;
92         struct callout          sc_tick_ch;
93
94         int                     sc_if_flags;
95         uint32_t                sc_caps;        /* hardware capabilities */
96 #define NFE_JUMBO_SUP   0x01
97 #define NFE_40BIT_ADDR  0x02
98 #define NFE_HW_CSUM     0x04
99 #define NFE_HW_VLAN     0x08
100 #define NFE_FIX_EADDR   0x10
101 #define NFE_NO_PWRCTL   0x20
102 #define NFE_WORDALIGN   0x40    /* word alignment DMA */
103
104         uint32_t                sc_flags;
105 #define NFE_F_USE_JUMBO 0x01    /* use jumbo frame */
106 #define NFE_F_DYN_IM    0x02    /* enable dynamic interrupt moderation */
107 #define NFE_F_IRQ_TIMER 0x04    /* hardware timer irq is used */
108
109         uint32_t                rxtxctl_desc;
110         uint32_t                rxtxctl;
111         uint8_t                 mii_phyaddr;
112
113         struct ifpoll_compat    sc_npoll;
114         bus_dma_tag_t           sc_dtag;
115         struct nfe_tx_ring      txq;
116         struct nfe_rx_ring      rxq;
117
118         uint32_t                sc_irq_enable;
119         int                     sc_tx_spare;
120         int                     sc_imtime;
121         int                     sc_rx_ring_count;
122         int                     sc_tx_ring_count;
123         int                     sc_debug;
124
125         struct lwkt_serialize   sc_jbuf_serializer;
126 };
127
128 #define NFE_IRQ_ENABLE(sc)      \
129         ((sc)->sc_imtime == 0 ? NFE_IRQ_NOIMTIMER : \
130          (((sc)->sc_flags & NFE_F_DYN_IM) ? NFE_IRQ_NOIMTIMER: NFE_IRQ_IMTIMER))
131
132 #define NFE_ADDR_HI(addr)       ((uint64_t) (addr) >> 32)
133 #define NFE_ADDR_LO(addr)       ((uint64_t) (addr) & 0xffffffff)