malovar.h revision 1.2 1 1.1 degroote /* $OpenBSD: malo.h,v 1.10 2010/08/08 16:36:33 deraadt Exp $ */
2 1.1 degroote
3 1.1 degroote /*
4 1.1 degroote * Copyright (c) 2006 Claudio Jeker <claudio (at) openbsd.org>
5 1.1 degroote * Copyright (c) 2006 Marcus Glocker <mglocker (at) openbsd.org>
6 1.1 degroote *
7 1.1 degroote * Permission to use, copy, modify, and distribute this software for any
8 1.1 degroote * purpose with or without fee is hereby granted, provided that the above
9 1.1 degroote * copyright notice and this permission notice appear in all copies.
10 1.1 degroote *
11 1.1 degroote * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 1.1 degroote * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 1.1 degroote * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 1.1 degroote * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 1.1 degroote * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 1.1 degroote * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 1.1 degroote * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 1.1 degroote */
19 1.1 degroote
20 1.1 degroote //#define MALO_DEBUG
21 1.1 degroote
22 1.1 degroote struct malo_rx_desc;
23 1.1 degroote struct malo_rx_data;
24 1.1 degroote
25 1.1 degroote struct malo_rx_ring {
26 1.1 degroote bus_dmamap_t map;
27 1.1 degroote bus_dma_segment_t seg;
28 1.1 degroote bus_addr_t physaddr;
29 1.1 degroote struct malo_rx_desc *desc;
30 1.1 degroote struct malo_rx_data *data;
31 1.1 degroote int count;
32 1.1 degroote int cur;
33 1.1 degroote int next;
34 1.1 degroote };
35 1.1 degroote
36 1.1 degroote struct malo_tx_desc;
37 1.1 degroote struct malo_tx_data;
38 1.1 degroote
39 1.1 degroote struct malo_tx_ring {
40 1.1 degroote bus_dmamap_t map;
41 1.1 degroote bus_dma_segment_t seg;
42 1.1 degroote bus_addr_t physaddr;
43 1.1 degroote struct malo_tx_desc *desc;
44 1.1 degroote struct malo_tx_data *data;
45 1.1 degroote int count;
46 1.1 degroote int queued;
47 1.1 degroote int cur;
48 1.1 degroote int next;
49 1.1 degroote int stat;
50 1.1 degroote };
51 1.1 degroote
52 1.1 degroote // XXX Support for RSSI ?
53 1.1 degroote #define MALO_RX_RADIOTAP_PRESENT \
54 1.1 degroote ((1 << IEEE80211_RADIOTAP_FLAGS) | \
55 1.1 degroote (1 << IEEE80211_RADIOTAP_CHANNEL))
56 1.1 degroote
57 1.1 degroote struct malo_rx_radiotap_hdr {
58 1.1 degroote struct ieee80211_radiotap_header wr_ihdr;
59 1.1 degroote uint8_t wr_flags;
60 1.1 degroote uint16_t wr_chan_freq;
61 1.1 degroote uint16_t wr_chan_flags;
62 1.1 degroote } __packed;
63 1.1 degroote
64 1.1 degroote #define MALO_TX_RADIOTAP_PRESENT \
65 1.1 degroote ((1 << IEEE80211_RADIOTAP_FLAGS) | \
66 1.1 degroote (1 << IEEE80211_RADIOTAP_RATE) | \
67 1.1 degroote (1 << IEEE80211_RADIOTAP_CHANNEL))
68 1.1 degroote
69 1.1 degroote struct malo_tx_radiotap_hdr {
70 1.1 degroote struct ieee80211_radiotap_header wt_ihdr;
71 1.1 degroote uint8_t wt_flags;
72 1.1 degroote uint8_t wt_rate;
73 1.1 degroote uint16_t wt_chan_freq;
74 1.1 degroote uint16_t wt_chan_flags;
75 1.1 degroote } __packed;
76 1.1 degroote
77 1.1 degroote struct malo_softc {
78 1.1 degroote device_t sc_dev;
79 1.1 degroote struct ethercom sc_ec;
80 1.1 degroote struct ieee80211com sc_ic;
81 1.1 degroote #define sc_if sc_ec.ec_if
82 1.1 degroote struct malo_rx_ring sc_rxring;
83 1.1 degroote struct malo_tx_ring sc_txring;
84 1.1 degroote
85 1.1 degroote bus_dma_tag_t sc_dmat;
86 1.1 degroote bus_space_tag_t sc_mem1_bt;
87 1.1 degroote bus_space_tag_t sc_mem2_bt;
88 1.1 degroote bus_space_handle_t sc_mem1_bh;
89 1.1 degroote bus_space_handle_t sc_mem2_bh;
90 1.1 degroote
91 1.1 degroote bus_dmamap_t sc_cmd_dmam;
92 1.1 degroote bus_dma_segment_t sc_cmd_dmas;
93 1.1 degroote void *sc_cmd_mem;
94 1.1 degroote bus_addr_t sc_cmd_dmaaddr;
95 1.1 degroote uint32_t *sc_cookie;
96 1.1 degroote bus_addr_t sc_cookie_dmaaddr;
97 1.1 degroote
98 1.1 degroote uint32_t sc_RxPdWrPtr;
99 1.1 degroote uint32_t sc_RxPdRdPtr;
100 1.1 degroote
101 1.1 degroote int (*sc_newstate)
102 1.1 degroote (struct ieee80211com *,
103 1.1 degroote enum ieee80211_state, int);
104 1.1 degroote
105 1.1 degroote int (*sc_enable)(struct malo_softc *);
106 1.1 degroote void (*sc_disable)(struct malo_softc *);
107 1.1 degroote
108 1.1 degroote struct callout sc_scan_to;
109 1.1 degroote int sc_tx_timer;
110 1.1 degroote int sc_last_txrate;
111 1.1 degroote
112 1.1 degroote struct bpf_if * sc_drvbpf;
113 1.1 degroote
114 1.1 degroote union {
115 1.1 degroote struct malo_rx_radiotap_hdr th;
116 1.1 degroote uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
117 1.1 degroote } sc_rxtapu;
118 1.1 degroote #define sc_rxtap sc_rxtapu.th
119 1.1 degroote int sc_rxtap_len;
120 1.1 degroote
121 1.1 degroote union {
122 1.1 degroote struct malo_tx_radiotap_hdr th;
123 1.1 degroote uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
124 1.1 degroote } sc_txtapu;
125 1.1 degroote #define sc_txtap sc_txtapu.th
126 1.1 degroote int sc_txtap_len;
127 1.1 degroote };
128 1.1 degroote
129 1.1 degroote int malo_intr(void *arg);
130 1.1 degroote int malo_attach(struct malo_softc *sc);
131 1.1 degroote int malo_detach(void *arg);
132 1.2 degroote int malo_init(struct ifnet *);
133 1.2 degroote void malo_stop(struct ifnet *, int disable);
134