xref: /openbsd-src/sys/dev/pci/if_ipwvar.h (revision 8d731e12dcb453123c72101d581d921f91adbed1)
1*8d731e12Stedu /*	$OpenBSD: if_ipwvar.h,v 1.28 2016/09/05 10:17:30 tedu Exp $	*/
2cc0e5093Sderaadt 
3cc0e5093Sderaadt /*-
4daa4cea5Sdamien  * Copyright (c) 2004-2006
5cc0e5093Sderaadt  *      Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
6cc0e5093Sderaadt  *
75a0a66dbSdamien  * Permission to use, copy, modify, and distribute this software for any
85a0a66dbSdamien  * purpose with or without fee is hereby granted, provided that the above
95a0a66dbSdamien  * copyright notice and this permission notice appear in all copies.
10cc0e5093Sderaadt  *
115a0a66dbSdamien  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
125a0a66dbSdamien  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
135a0a66dbSdamien  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
145a0a66dbSdamien  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
155a0a66dbSdamien  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
165a0a66dbSdamien  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
175a0a66dbSdamien  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18cc0e5093Sderaadt  */
19cc0e5093Sderaadt 
20b48ab102Sdamien struct ipw_firmware {
21dda7ffcbSdamien 	u_char	*data;
2211c713bcSderaadt 	size_t	size;
23dda7ffcbSdamien 	u_char	*main;
24dda7ffcbSdamien 	size_t	main_size;
25dda7ffcbSdamien 	u_char	*ucode;
26dda7ffcbSdamien 	size_t	ucode_size;
27b48ab102Sdamien };
28b48ab102Sdamien 
29cc0e5093Sderaadt struct ipw_soft_bd {
30cc0e5093Sderaadt 	struct ipw_bd	*bd;
31cc0e5093Sderaadt 	int		type;
32cc0e5093Sderaadt #define IPW_SBD_TYPE_NOASSOC	0
33cc0e5093Sderaadt #define IPW_SBD_TYPE_COMMAND	1
34cc0e5093Sderaadt #define IPW_SBD_TYPE_HEADER	2
35cc0e5093Sderaadt #define IPW_SBD_TYPE_DATA	3
36cc0e5093Sderaadt 	void		*priv;
37cc0e5093Sderaadt };
38cc0e5093Sderaadt 
39cc0e5093Sderaadt struct ipw_soft_hdr {
40cc0e5093Sderaadt 	struct ipw_hdr			hdr;
41cc0e5093Sderaadt 	bus_dmamap_t			map;
4286f44eaeSdamien 	SLIST_ENTRY(ipw_soft_hdr)	next;
43cc0e5093Sderaadt };
44cc0e5093Sderaadt 
45cc0e5093Sderaadt struct ipw_soft_buf {
46cc0e5093Sderaadt 	struct mbuf			*m;
47cc0e5093Sderaadt 	struct ieee80211_node		*ni;
48cc0e5093Sderaadt 	bus_dmamap_t			map;
4986f44eaeSdamien 	SLIST_ENTRY(ipw_soft_buf)	next;
50cc0e5093Sderaadt };
51cc0e5093Sderaadt 
52cc0e5093Sderaadt struct ipw_rx_radiotap_header {
53cc0e5093Sderaadt 	struct ieee80211_radiotap_header wr_ihdr;
54daa4cea5Sdamien 	uint8_t		wr_flags;
55daa4cea5Sdamien 	uint16_t	wr_chan_freq;
56daa4cea5Sdamien 	uint16_t	wr_chan_flags;
57daa4cea5Sdamien 	uint8_t		wr_antsignal;
58d51d3f93Sdamien } __packed;
59cc0e5093Sderaadt 
60cc0e5093Sderaadt #define IPW_RX_RADIOTAP_PRESENT						\
61cc0e5093Sderaadt 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
62cc0e5093Sderaadt 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
63cc0e5093Sderaadt 	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
64cc0e5093Sderaadt 
65cc0e5093Sderaadt struct ipw_tx_radiotap_header {
66cc0e5093Sderaadt 	struct ieee80211_radiotap_header wt_ihdr;
67daa4cea5Sdamien 	uint8_t		wt_flags;
68daa4cea5Sdamien 	uint16_t	wt_chan_freq;
69daa4cea5Sdamien 	uint16_t	wt_chan_flags;
70d51d3f93Sdamien } __packed;
71cc0e5093Sderaadt 
72cc0e5093Sderaadt #define IPW_TX_RADIOTAP_PRESENT						\
73cc0e5093Sderaadt 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
74cc0e5093Sderaadt 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
75cc0e5093Sderaadt 
765dffde3aSdamien #define IPW_MAX_NSEG	1
7786f44eaeSdamien 
78cc0e5093Sderaadt struct ipw_softc {
79cc0e5093Sderaadt 	struct device			sc_dev;
80cc0e5093Sderaadt 
81cc0e5093Sderaadt 	struct ieee80211com		sc_ic;
82cc0e5093Sderaadt 	int				(*sc_newstate)(struct ieee80211com *,
83cc0e5093Sderaadt 					    enum ieee80211_state, int);
84cc0e5093Sderaadt 
85*8d731e12Stedu 	struct rwlock			sc_rwlock;
86cc0e5093Sderaadt 
87cc0e5093Sderaadt 	bus_space_tag_t			sc_st;
88cc0e5093Sderaadt 	bus_space_handle_t		sc_sh;
89cc0e5093Sderaadt 	void 				*sc_ih;
90cc0e5093Sderaadt 	pci_chipset_tag_t		sc_pct;
91334dd92fSdamien 	pcitag_t			sc_pcitag;
92cc0e5093Sderaadt 	bus_size_t			sc_sz;
93cc0e5093Sderaadt 
94cc0e5093Sderaadt 	int				sc_tx_timer;
95cc0e5093Sderaadt 
96cc0e5093Sderaadt 	bus_dma_tag_t			sc_dmat;
97cc0e5093Sderaadt 
98cc0e5093Sderaadt 	bus_dmamap_t			tbd_map;
99cc0e5093Sderaadt 	bus_dmamap_t			rbd_map;
100cc0e5093Sderaadt 	bus_dmamap_t			status_map;
101cc0e5093Sderaadt 	bus_dmamap_t			cmd_map;
102cc0e5093Sderaadt 
103cc0e5093Sderaadt 	bus_dma_segment_t		tbd_seg;
104cc0e5093Sderaadt 	bus_dma_segment_t		rbd_seg;
105cc0e5093Sderaadt 	bus_dma_segment_t		status_seg;
106cc0e5093Sderaadt 	bus_dma_segment_t		cmd_seg;
107cc0e5093Sderaadt 
108cc0e5093Sderaadt 	struct ipw_bd			*tbd_list;
109cc0e5093Sderaadt 	struct ipw_bd			*rbd_list;
110cc0e5093Sderaadt 	struct ipw_status		*status_list;
111cc0e5093Sderaadt 
11286f44eaeSdamien 	struct ipw_cmd			cmd;
11386f44eaeSdamien 	struct ipw_soft_bd		stbd_list[IPW_NTBD];
11486f44eaeSdamien 	struct ipw_soft_buf		tx_sbuf_list[IPW_NDATA];
11586f44eaeSdamien 	struct ipw_soft_hdr		shdr_list[IPW_NDATA];
11686f44eaeSdamien 	struct ipw_soft_bd		srbd_list[IPW_NRBD];
11786f44eaeSdamien 	struct ipw_soft_buf		rx_sbuf_list[IPW_NRBD];
118cc0e5093Sderaadt 
11912679decSkrw 	struct task			sc_scantask;
12012679decSkrw 	struct task			sc_authandassoctask;
12112679decSkrw 
12286f44eaeSdamien 	SLIST_HEAD(, ipw_soft_hdr)	free_shdr;
12386f44eaeSdamien 	SLIST_HEAD(, ipw_soft_buf)	free_sbuf;
124cc0e5093Sderaadt 
125daa4cea5Sdamien 	uint32_t			table1_base;
126daa4cea5Sdamien 	uint32_t			table2_base;
127cc0e5093Sderaadt 
128daa4cea5Sdamien 	uint32_t			txcur;
129daa4cea5Sdamien 	uint32_t			txold;
130daa4cea5Sdamien 	uint32_t			rxcur;
1310a6ff4a3Sdamien 	int				txfree;
132cc0e5093Sderaadt 
133cc0e5093Sderaadt #if NBPFILTER > 0
134cc0e5093Sderaadt 	caddr_t				sc_drvbpf;
135cc0e5093Sderaadt 
136cc0e5093Sderaadt 	union {
137cc0e5093Sderaadt 		struct ipw_rx_radiotap_header th;
138daa4cea5Sdamien 		uint8_t	pad[64];
139cc0e5093Sderaadt 	} sc_rxtapu;
140cc0e5093Sderaadt #define sc_rxtap	sc_rxtapu.th
141cc0e5093Sderaadt 	int				sc_rxtap_len;
142cc0e5093Sderaadt 
143cc0e5093Sderaadt 	union {
144cc0e5093Sderaadt 		struct ipw_tx_radiotap_header th;
145daa4cea5Sdamien 		uint8_t	pad[64];
146cc0e5093Sderaadt 	} sc_txtapu;
147cc0e5093Sderaadt #define sc_txtap	sc_txtapu.th
148cc0e5093Sderaadt 	int				sc_txtap_len;
149cc0e5093Sderaadt #endif
150cc0e5093Sderaadt };
151