1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 #ifndef _DEV_IC_ANVAR_H
38 #define _DEV_IC_ANVAR_H
39
40 #define AN_TIMEOUT 65536
41 #define AN_MAGIC 0x414e
42
43
44 #define AN_INTRS (AN_EV_RX | AN_EV_TX | AN_EV_TX_EXC | AN_EV_LINKSTAT)
45
46
47
48
49 #define CSR_WRITE_2(sc, reg, val) \
50 bus_space_write_2(sc->sc_iot, sc->sc_ioh, reg, val)
51
52 #define CSR_READ_2(sc, reg) \
53 bus_space_read_2(sc->sc_iot, sc->sc_ioh, reg)
54
55 #ifndef __BUS_SPACE_HAS_STREAM_METHODS
56 #define bus_space_write_multi_stream_2 bus_space_write_multi_2
57 #define bus_space_read_multi_stream_2 bus_space_read_multi_2
58 #endif
59
60 #define CSR_WRITE_MULTI_STREAM_2(sc, reg, val, count) \
61 bus_space_write_multi_stream_2(sc->sc_iot, sc->sc_ioh, reg, val, count)
62 #define CSR_READ_MULTI_STREAM_2(sc, reg, buf, count) \
63 bus_space_read_multi_stream_2(sc->sc_iot, sc->sc_ioh, reg, buf, count)
64
65 #define AN_TX_MAX_LEN \
66 (sizeof(struct an_txframe) + ETHER_TYPE_LEN + ETHER_MAX_LEN)
67 #define AN_TX_RING_CNT 4
68 #define AN_INC(x, y) (x) = (x + 1) % y
69
70 struct an_wepkey {
71 int an_wep_key[16];
72 int an_wep_keylen;
73 };
74
75 #define AN_GAPLEN_MAX 8
76
77 #define AN_RX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_FLAGS) | \
78 (1 << IEEE80211_RADIOTAP_RATE) | \
79 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
80 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
81
82 struct an_rx_radiotap_header {
83 struct ieee80211_radiotap_header ar_ihdr;
84 u_int8_t ar_flags;
85 u_int8_t ar_rate;
86 u_int16_t ar_chan_freq;
87 u_int16_t ar_chan_flags;
88 int8_t ar_antsignal;
89 } __packed;
90
91 #define AN_TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_FLAGS) | \
92 (1 << IEEE80211_RADIOTAP_RATE) | \
93 (1 << IEEE80211_RADIOTAP_CHANNEL))
94
95 struct an_tx_radiotap_header {
96 struct ieee80211_radiotap_header at_ihdr;
97 u_int8_t at_flags;
98 u_int8_t at_rate;
99 u_int16_t at_chan_freq;
100 u_int16_t at_chan_flags;
101 } __packed;
102
103
104 struct an_softc {
105 struct device sc_dev;
106 struct ieee80211com sc_ic;
107 bus_space_tag_t sc_iot;
108 bus_space_handle_t sc_ioh;
109 void *sc_ih;
110 int (*sc_enable)(struct an_softc *);
111 void (*sc_disable)(struct an_softc *);
112 int (*sc_newstate)(struct ieee80211com *,
113 enum ieee80211_state, int);
114
115 int sc_enabled;
116 int sc_invalid;
117 int sc_attached;
118 void *sc_sdhook;
119
120
121 int sc_bap_id;
122 int sc_bap_off;
123
124 int sc_use_leap;
125 struct an_wepkey sc_wepkeys[IEEE80211_WEP_NKID];
126 int sc_perskeylen[IEEE80211_WEP_NKID];
127 int sc_tx_key;
128 int sc_tx_perskey;
129 int sc_tx_timer;
130 struct an_txdesc {
131 int d_fid;
132 int d_inuse;
133 } sc_txd[AN_TX_RING_CNT];
134 int sc_txnext;
135 int sc_txcur;
136
137 struct an_rid_genconfig sc_config;
138 struct an_rid_caps sc_caps;
139 union {
140 u_int16_t sc_val[1];
141 u_int8_t sc_txbuf[AN_TX_MAX_LEN];
142 struct an_rid_ssidlist sc_ssidlist;
143 struct an_rid_aplist sc_aplist;
144 struct an_rid_status sc_status;
145 struct an_rid_wepkey sc_wepkey;
146 struct an_rid_leapkey sc_leapkey;
147 struct an_rid_encap sc_encap;
148 } sc_buf;
149
150 caddr_t sc_drvbpf;
151 union {
152 struct an_rx_radiotap_header tap;
153 u_int8_t pad[64];
154 } sc_rxtapu;
155 union {
156 struct an_tx_radiotap_header tap;
157 u_int8_t pad[64];
158 } sc_txtapu;
159 };
160
161 #define sc_rxtap sc_rxtapu.tap
162 #define sc_txtap sc_txtapu.tap
163
164 int an_attach(struct an_softc *);
165 int an_detach(struct an_softc *);
166 int an_activate(struct device *, enum devact);
167 void an_power(int, void *);
168 void an_shutdown(void *);
169 int an_intr(void *);
170 int an_init(struct ifnet *);
171 void an_stop(struct ifnet *, int);
172
173 #endif