xref: /openbsd/sys/dev/ic/malo.h (revision 73471bf0)
1 /*	$OpenBSD: malo.h,v 1.12 2013/12/06 21:03:03 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 struct malo_rx_desc;
21 struct malo_rx_data;
22 
23 struct malo_rx_ring {
24 	bus_dmamap_t		map;
25 	bus_dma_segment_t	seg;
26 	bus_addr_t		physaddr;
27 	struct malo_rx_desc	*desc;
28 	struct malo_rx_data	*data;
29 	int			count;
30 	int			cur;
31 	int			next;
32 };
33 
34 struct malo_tx_desc;
35 struct malo_tx_data;
36 
37 struct malo_tx_ring {
38 	bus_dmamap_t		map;
39 	bus_dma_segment_t	seg;
40 	bus_addr_t		physaddr;
41 	struct malo_tx_desc	*desc;
42 	struct malo_tx_data	*data;
43 	int			count;
44 	int			queued;
45 	int			cur;
46 	int			next;
47 	int			stat;
48 };
49 
50 #define MALO_RX_RADIOTAP_PRESENT					\
51 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
52 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
53 	 (1 << IEEE80211_RADIOTAP_RSSI))
54 
55 struct malo_rx_radiotap_hdr {
56 	struct ieee80211_radiotap_header	wr_ihdr;
57 	uint8_t					wr_flags;
58 	uint16_t				wr_chan_freq;
59 	uint16_t				wr_chan_flags;
60 	uint8_t					wr_rssi;
61 	uint8_t					wr_max_rssi;
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 	struct device		sc_dev;
79 	struct ieee80211com	sc_ic;
80 	struct malo_rx_ring	sc_rxring;
81 	struct malo_tx_ring	sc_txring;
82 
83 	bus_dma_tag_t		sc_dmat;
84 	bus_space_tag_t		sc_mem1_bt;
85 	bus_space_tag_t		sc_mem2_bt;
86 	bus_space_handle_t	sc_mem1_bh;
87 	bus_space_handle_t	sc_mem2_bh;
88 
89 	bus_dmamap_t		sc_cmd_dmam;
90 	bus_dma_segment_t	sc_cmd_dmas;
91 	void			*sc_cmd_mem;
92 	bus_addr_t		sc_cmd_dmaaddr;
93 	uint32_t		*sc_cookie;
94 	bus_addr_t		sc_cookie_dmaaddr;
95 
96 	uint32_t		sc_RxPdWrPtr;
97 	uint32_t		sc_RxPdRdPtr;
98 
99 	int			(*sc_newstate)
100 				(struct ieee80211com *,
101 				 enum ieee80211_state, int);
102 
103 	int			(*sc_enable)(struct malo_softc *);
104 	void			(*sc_disable)(struct malo_softc *);
105 
106 	struct timeout		sc_scan_to;
107 	int			sc_tx_timer;
108 	int			sc_last_txrate;
109 
110 #if NBPFILTER > 0
111 	caddr_t		sc_drvbpf;
112 
113 	union {
114 		struct malo_rx_radiotap_hdr th;
115 		uint8_t pad[64];
116 	}		sc_rxtapu;
117 #define sc_rxtap	sc_rxtapu.th
118 	int		sc_rxtap_len;
119 
120 	union {
121 		struct malo_tx_radiotap_hdr th;
122 		uint8_t pad[64];
123 	}		sc_txtapu;
124 #define sc_txtap	sc_txtapu.th
125 	int		sc_txtap_len;
126 #endif
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 malo_softc *);
134