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 };
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 };
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           void                          *sc_soft_ih;
83           struct malo_rx_ring sc_rxring;
84           struct malo_tx_ring sc_txring;
85 
86           bus_dma_tag_t                 sc_dmat;
87           bus_space_tag_t               sc_mem1_bt;
88           bus_space_tag_t               sc_mem2_bt;
89           bus_space_handle_t  sc_mem1_bh;
90           bus_space_handle_t  sc_mem2_bh;
91 
92           bus_dmamap_t                  sc_cmd_dmam;
93           bus_dma_segment_t   sc_cmd_dmas;
94           void                          *sc_cmd_mem;
95           bus_addr_t                    sc_cmd_dmaaddr;
96           uint32_t            *sc_cookie;
97           bus_addr_t                    sc_cookie_dmaaddr;
98 
99           uint32_t            sc_RxPdWrPtr;
100           uint32_t            sc_RxPdRdPtr;
101 
102           int                           (*sc_newstate)
103                                         (struct ieee80211com *,
104                                          enum ieee80211_state, int);
105 
106           int                           (*sc_enable)(struct malo_softc *);
107           void                          (*sc_disable)(struct malo_softc *);
108 
109           struct callout                sc_scan_to;
110           int                           sc_tx_timer;
111           int                           sc_last_txrate;
112 
113           struct bpf_if *               sc_drvbpf;
114 
115           union {
116                     struct malo_rx_radiotap_hdr th;
117                     uint8_t pad[IEEE80211_RADIOTAP_HDRLEN];
118           }                   sc_rxtapu;
119 #define sc_rxtap    sc_rxtapu.th
120           int                 sc_rxtap_len;
121 
122           union {
123                     struct malo_tx_radiotap_hdr th;
124                     uint8_t   pad[IEEE80211_RADIOTAP_HDRLEN];
125           }                   sc_txtapu;
126 #define sc_txtap    sc_txtapu.th
127           int                 sc_txtap_len;
128 };
129 
130 int malo_intr(void *arg);
131 void malo_softintr(void *arg);
132 int malo_attach(struct malo_softc *sc);
133 int malo_detach(void *arg);
134 int malo_init(struct ifnet *);
135 void malo_stop(struct ifnet *, int disable);
136