xref: /openbsd-src/sys/dev/pci/if_ipwvar.h (revision 0b7734b3d77bb9b21afec6f4621cae6c805dbd45)
1 /*	$OpenBSD: if_ipwvar.h,v 1.25 2015/09/01 07:09:55 deraadt Exp $	*/
2 
3 /*-
4  * Copyright (c) 2004-2006
5  *      Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
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 ipw_firmware {
21 	u_char	*data;
22 	size_t	size;
23 	u_char	*main;
24 	size_t	main_size;
25 	u_char	*ucode;
26 	size_t	ucode_size;
27 };
28 
29 struct ipw_soft_bd {
30 	struct ipw_bd	*bd;
31 	int		type;
32 #define IPW_SBD_TYPE_NOASSOC	0
33 #define IPW_SBD_TYPE_COMMAND	1
34 #define IPW_SBD_TYPE_HEADER	2
35 #define IPW_SBD_TYPE_DATA	3
36 	void		*priv;
37 };
38 
39 struct ipw_soft_hdr {
40 	struct ipw_hdr			hdr;
41 	bus_dmamap_t			map;
42 	SLIST_ENTRY(ipw_soft_hdr)	next;
43 };
44 
45 struct ipw_soft_buf {
46 	struct mbuf			*m;
47 	struct ieee80211_node		*ni;
48 	bus_dmamap_t			map;
49 	SLIST_ENTRY(ipw_soft_buf)	next;
50 };
51 
52 struct ipw_rx_radiotap_header {
53 	struct ieee80211_radiotap_header wr_ihdr;
54 	uint8_t		wr_flags;
55 	uint16_t	wr_chan_freq;
56 	uint16_t	wr_chan_flags;
57 	uint8_t		wr_antsignal;
58 } __packed;
59 
60 #define IPW_RX_RADIOTAP_PRESENT						\
61 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
62 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
63 	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
64 
65 struct ipw_tx_radiotap_header {
66 	struct ieee80211_radiotap_header wt_ihdr;
67 	uint8_t		wt_flags;
68 	uint16_t	wt_chan_freq;
69 	uint16_t	wt_chan_flags;
70 } __packed;
71 
72 #define IPW_TX_RADIOTAP_PRESENT						\
73 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
74 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
75 
76 #define IPW_MAX_NSEG	1
77 
78 struct ipw_softc {
79 	struct device			sc_dev;
80 
81 	struct ieee80211com		sc_ic;
82 	int				(*sc_newstate)(struct ieee80211com *,
83 					    enum ieee80211_state, int);
84 
85 	uint32_t			sc_flags;
86 #define IPW_FLAG_FW_INITED	(1 << 0)
87 #define IPW_FLAG_BUSY		(1 << 1)
88 
89 	bus_space_tag_t			sc_st;
90 	bus_space_handle_t		sc_sh;
91 	void 				*sc_ih;
92 	pci_chipset_tag_t		sc_pct;
93 	pcitag_t			sc_pcitag;
94 	bus_size_t			sc_sz;
95 
96 	int				sc_tx_timer;
97 
98 	bus_dma_tag_t			sc_dmat;
99 
100 	bus_dmamap_t			tbd_map;
101 	bus_dmamap_t			rbd_map;
102 	bus_dmamap_t			status_map;
103 	bus_dmamap_t			cmd_map;
104 
105 	bus_dma_segment_t		tbd_seg;
106 	bus_dma_segment_t		rbd_seg;
107 	bus_dma_segment_t		status_seg;
108 	bus_dma_segment_t		cmd_seg;
109 
110 	struct ipw_bd			*tbd_list;
111 	struct ipw_bd			*rbd_list;
112 	struct ipw_status		*status_list;
113 
114 	struct ipw_cmd			cmd;
115 	struct ipw_soft_bd		stbd_list[IPW_NTBD];
116 	struct ipw_soft_buf		tx_sbuf_list[IPW_NDATA];
117 	struct ipw_soft_hdr		shdr_list[IPW_NDATA];
118 	struct ipw_soft_bd		srbd_list[IPW_NRBD];
119 	struct ipw_soft_buf		rx_sbuf_list[IPW_NRBD];
120 
121 	struct task			sc_scantask;
122 	struct task			sc_authandassoctask;
123 
124 	SLIST_HEAD(, ipw_soft_hdr)	free_shdr;
125 	SLIST_HEAD(, ipw_soft_buf)	free_sbuf;
126 
127 	uint32_t			table1_base;
128 	uint32_t			table2_base;
129 
130 	uint32_t			txcur;
131 	uint32_t			txold;
132 	uint32_t			rxcur;
133 	int				txfree;
134 
135 #if NBPFILTER > 0
136 	caddr_t				sc_drvbpf;
137 
138 	union {
139 		struct ipw_rx_radiotap_header th;
140 		uint8_t	pad[64];
141 	} sc_rxtapu;
142 #define sc_rxtap	sc_rxtapu.th
143 	int				sc_rxtap_len;
144 
145 	union {
146 		struct ipw_tx_radiotap_header th;
147 		uint8_t	pad[64];
148 	} sc_txtapu;
149 #define sc_txtap	sc_txtapu.th
150 	int				sc_txtap_len;
151 #endif
152 };
153