xref: /freebsd/sys/dev/ipw/if_ipwvar.h (revision f0a75d274af375d15b97b830966b99a02b7db911)
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 #define IPW_MAX_NSEG	1
31 
32 struct ipw_soft_bd {
33 	struct ipw_bd	*bd;
34 	int		type;
35 #define IPW_SBD_TYPE_NOASSOC	0
36 #define IPW_SBD_TYPE_COMMAND	1
37 #define IPW_SBD_TYPE_HEADER	2
38 #define IPW_SBD_TYPE_DATA	3
39 	void		*priv;
40 };
41 
42 struct ipw_soft_hdr {
43 	struct ipw_hdr			hdr;
44 	bus_dmamap_t			map;
45 	SLIST_ENTRY(ipw_soft_hdr)	next;
46 };
47 
48 struct ipw_soft_buf {
49 	struct mbuf			*m;
50 	struct ieee80211_node		*ni;
51 	bus_dmamap_t			map;
52 	SLIST_ENTRY(ipw_soft_buf)	next;
53 };
54 
55 struct ipw_rx_radiotap_header {
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_antsignal;
61 };
62 
63 #define IPW_RX_RADIOTAP_PRESENT						\
64 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
65 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
66 	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
67 
68 struct ipw_tx_radiotap_header {
69 	struct ieee80211_radiotap_header wt_ihdr;
70 	uint8_t		wt_flags;
71 	uint16_t	wt_chan_freq;
72 	uint16_t	wt_chan_flags;
73 };
74 
75 #define IPW_TX_RADIOTAP_PRESENT						\
76 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
77 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
78 
79 struct ipw_softc {
80 	struct ifnet			*sc_ifp;
81 	struct ieee80211com		sc_ic;
82 	int				(*sc_newstate)(struct ieee80211com *,
83 					    enum ieee80211_state, int);
84 	device_t			sc_dev;
85 
86 	struct mtx			sc_mtx;
87 	struct task			sc_init_task;
88 
89 	uint32_t			flags;
90 #define IPW_FLAG_FW_INITED		(1 << 0)
91 #define IPW_FLAG_INIT_LOCKED		(1 << 1)
92 #define IPW_FLAG_HAS_RADIO_SWITCH	(1 << 2)
93 #define	IPW_FLAG_FW_WARNED		(1 << 3)
94 
95 	int				irq_rid;
96 	int				mem_rid;
97 	struct resource			*irq;
98 	struct resource			*mem;
99 	bus_space_tag_t			sc_st;
100 	bus_space_handle_t		sc_sh;
101 	void 				*sc_ih;
102 	const struct firmware		*sc_firmware;
103 
104 	int				sc_tx_timer;
105 
106 	bus_dma_tag_t			tbd_dmat;
107 	bus_dma_tag_t			rbd_dmat;
108 	bus_dma_tag_t			status_dmat;
109 	bus_dma_tag_t			cmd_dmat;
110 	bus_dma_tag_t			hdr_dmat;
111 	bus_dma_tag_t			txbuf_dmat;
112 	bus_dma_tag_t			rxbuf_dmat;
113 
114 	bus_dmamap_t			tbd_map;
115 	bus_dmamap_t			rbd_map;
116 	bus_dmamap_t			status_map;
117 	bus_dmamap_t			cmd_map;
118 
119 	bus_addr_t			tbd_phys;
120 	bus_addr_t			rbd_phys;
121 	bus_addr_t			status_phys;
122 
123 	struct ipw_bd			*tbd_list;
124 	struct ipw_bd			*rbd_list;
125 	struct ipw_status		*status_list;
126 
127 	struct ipw_cmd			cmd;
128 	struct ipw_soft_bd		stbd_list[IPW_NTBD];
129 	struct ipw_soft_buf		tx_sbuf_list[IPW_NDATA];
130 	struct ipw_soft_hdr		shdr_list[IPW_NDATA];
131 	struct ipw_soft_bd		srbd_list[IPW_NRBD];
132 	struct ipw_soft_buf		rx_sbuf_list[IPW_NRBD];
133 
134 	SLIST_HEAD(, ipw_soft_hdr)	free_shdr;
135 	SLIST_HEAD(, ipw_soft_buf)	free_sbuf;
136 
137 	uint32_t			table1_base;
138 	uint32_t			table2_base;
139 
140 	uint32_t			txcur;
141 	uint32_t			txold;
142 	uint32_t			rxcur;
143 	int				txfree;
144 
145 	int				dwelltime;
146 
147 	struct bpf_if			*sc_drvbpf;
148 
149 	union {
150 		struct ipw_rx_radiotap_header th;
151 		uint8_t	pad[64];
152 	} sc_rxtapu;
153 #define sc_rxtap	sc_rxtapu.th
154 	int				sc_rxtap_len;
155 
156 	union {
157 		struct ipw_tx_radiotap_header th;
158 		uint8_t	pad[64];
159 	} sc_txtapu;
160 #define sc_txtap	sc_txtapu.th
161 	int				sc_txtap_len;
162 };
163