xref: /freebsd/sys/dev/iwi/if_iwivar.h (revision 87569f75a91f298c52a71823c04d41cf53c88889)
1 /*	$FreeBSD$	*/
2 
3 /*-
4  * Copyright (c) 2004-2006
5  *      Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice unmodified, this list of conditions, and the following
12  *    disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 struct iwi_rx_radiotap_header {
31 	struct ieee80211_radiotap_header wr_ihdr;
32 	uint8_t		wr_flags;
33 	uint8_t		wr_rate;
34 	uint16_t	wr_chan_freq;
35 	uint16_t	wr_chan_flags;
36 	uint8_t		wr_antsignal;
37 	uint8_t		wr_antenna;
38 };
39 
40 #define IWI_RX_RADIOTAP_PRESENT						\
41 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
42 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
43 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
44 	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |			\
45 	 (1 << IEEE80211_RADIOTAP_ANTENNA))
46 
47 struct iwi_tx_radiotap_header {
48 	struct ieee80211_radiotap_header wt_ihdr;
49 	uint8_t		wt_flags;
50 	uint16_t	wt_chan_freq;
51 	uint16_t	wt_chan_flags;
52 };
53 
54 #define IWI_TX_RADIOTAP_PRESENT						\
55 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
56 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
57 
58 struct iwi_cmd_ring {
59 	bus_dma_tag_t		desc_dmat;
60 	bus_dmamap_t		desc_map;
61 	bus_addr_t		physaddr;
62 	struct iwi_cmd_desc	*desc;
63 	int			count;
64 	int			queued;
65 	int			cur;
66 	int			next;
67 };
68 
69 struct iwi_tx_data {
70 	bus_dmamap_t		map;
71 	struct mbuf		*m;
72 	struct ieee80211_node	*ni;
73 };
74 
75 struct iwi_tx_ring {
76 	bus_dma_tag_t		desc_dmat;
77 	bus_dma_tag_t		data_dmat;
78 	bus_dmamap_t		desc_map;
79 	bus_addr_t		physaddr;
80 	bus_addr_t		csr_ridx;
81 	bus_addr_t		csr_widx;
82 	struct iwi_tx_desc	*desc;
83 	struct iwi_tx_data	*data;
84 	int			count;
85 	int			queued;
86 	int			cur;
87 	int			next;
88 };
89 
90 struct iwi_rx_data {
91 	bus_dmamap_t	map;
92 	bus_addr_t	physaddr;
93 	uint32_t	reg;
94 	struct mbuf	*m;
95 };
96 
97 struct iwi_rx_ring {
98 	bus_dma_tag_t		data_dmat;
99 	struct iwi_rx_data	*data;
100 	int			count;
101 	int			cur;
102 };
103 
104 struct iwi_node {
105 	struct ieee80211_node	in_node;
106 	int			in_station;
107 #define IWI_MAX_IBSSNODE	32
108 };
109 
110 struct iwi_softc {
111 	struct ifnet		*sc_ifp;
112 	struct ieee80211com	sc_ic;
113 	int			(*sc_newstate)(struct ieee80211com *,
114 				    enum ieee80211_state, int);
115 	void			(*sc_node_free)(struct ieee80211_node *);
116 	device_t		sc_dev;
117 
118 	struct mtx		sc_mtx;
119 	struct unrhdr		*sc_unr;
120 	struct task		sc_init_task;
121 
122 	uint32_t		flags;
123 #define IWI_FLAG_FW_INITED	(1 << 0)
124 #define IWI_FLAG_SCANNING	(1 << 1)
125 #define IWI_FLAG_INIT_LOCKED	(1 << 2)
126 
127 	struct iwi_cmd_ring	cmdq;
128 	struct iwi_tx_ring	txq[WME_NUM_AC];
129 	struct iwi_rx_ring	rxq;
130 
131 	struct resource		*irq;
132 	struct resource		*mem;
133 	bus_space_tag_t		sc_st;
134 	bus_space_handle_t	sc_sh;
135 	void 			*sc_ih;
136 	int			mem_rid;
137 	int			irq_rid;
138 
139 	int			antenna;
140 	int			dwelltime;
141 	int			bluetooth;
142 
143 	int			sc_tx_timer;
144 
145 	struct bpf_if		*sc_drvbpf;
146 
147 	union {
148 		struct iwi_rx_radiotap_header th;
149 		uint8_t	pad[64];
150 	}			sc_rxtapu;
151 #define sc_rxtap	sc_rxtapu.th
152 	int			sc_rxtap_len;
153 
154 	union {
155 		struct iwi_tx_radiotap_header th;
156 		uint8_t	pad[64];
157 	}			sc_txtapu;
158 #define sc_txtap	sc_txtapu.th
159 	int			sc_txtap_len;
160 };
161 
162