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