1/*	$NetBSD: if_iwivar.h,v 1.20 2020/03/20 13:33:23 thorpej Exp $ */
2
3/*-
4 * Copyright (c) 2004, 2005
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#include <sys/ioccom.h>
31
32struct iwi_firmware {
33	void	*boot;
34	int	boot_size;
35	void	*ucode;
36	int	ucode_size;
37	void	*main;
38	int	main_size;
39};
40
41struct iwi_rx_radiotap_header {
42	struct ieee80211_radiotap_header wr_ihdr;
43	uint8_t		wr_flags;
44	uint8_t		wr_rate;
45	uint16_t	wr_chan_freq;
46	uint16_t	wr_chan_flags;
47	uint8_t		wr_antsignal;
48	uint8_t		wr_antenna;
49};
50
51#define IWI_RX_RADIOTAP_PRESENT						\
52	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
53	 (1 << IEEE80211_RADIOTAP_RATE) |				\
54	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
55	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |			\
56	 (1 << IEEE80211_RADIOTAP_ANTENNA))
57
58struct iwi_tx_radiotap_header {
59	struct ieee80211_radiotap_header wt_ihdr;
60	uint8_t		wt_flags;
61	uint16_t	wt_chan_freq;
62	uint16_t	wt_chan_flags;
63};
64
65#define IWI_TX_RADIOTAP_PRESENT						\
66	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
67	 (1 << IEEE80211_RADIOTAP_CHANNEL))
68
69struct iwi_cmd_ring {
70	bus_dmamap_t		desc_map;
71	bus_dma_segment_t	desc_seg;
72	struct iwi_cmd_desc	*desc;
73	int			count;
74	int			queued;
75	int			cur;
76	int			next;
77};
78
79struct iwi_tx_data {
80	bus_dmamap_t		map;
81	struct mbuf		*m;
82	struct ieee80211_node	*ni;
83};
84
85struct iwi_tx_ring {
86	bus_dmamap_t		desc_map;
87	bus_dma_segment_t	desc_seg;
88	bus_size_t		csr_ridx;
89	bus_size_t		csr_widx;
90	struct iwi_tx_desc	*desc;
91	struct iwi_tx_data	*data;
92	int			count;
93	int			queued;
94	int			cur;
95	int			next;
96};
97
98struct iwi_rx_data {
99	bus_dmamap_t	map;
100	struct mbuf	*m;
101};
102
103struct iwi_rx_ring {
104	struct iwi_rx_data	*data;
105	int			count;
106	int			cur;
107};
108
109struct iwi_node {
110	struct ieee80211_node	in_node;
111	int			in_station;
112#define IWI_MAX_IBSSNODE	32
113};
114
115struct iwi_softc {
116	device_t		sc_dev;
117	struct ethercom		sc_ec;
118	struct ieee80211com	sc_ic;
119	int			(*sc_newstate)(struct ieee80211com *,
120				    enum ieee80211_state, int);
121	void			(*sc_node_free)(struct ieee80211_node *);
122
123	uint32_t		sc_unr;
124
125	struct iwi_firmware	fw;
126	const char		*sc_fwname;
127	char			*sc_blob;
128	size_t			sc_blobsize;
129
130	uint32_t		flags;
131#define IWI_FLAG_FW_CACHED	(1 << 0)
132#define IWI_FLAG_FW_INITED	(1 << 1)
133#define IWI_FLAG_SCANNING	(1 << 3)
134
135	bus_dma_tag_t		sc_dmat;
136
137	struct iwi_cmd_ring	cmdq;
138	struct iwi_tx_ring	txq[WME_NUM_AC];
139	struct iwi_rx_ring	rxq;
140
141	struct resource		*irq;
142	struct resource		*mem;
143	bus_space_tag_t		sc_st;
144	bus_space_handle_t	sc_sh;
145	void 			*sc_ih;
146	pci_chipset_tag_t	sc_pct;
147	pcitag_t		sc_pcitag;
148	bus_size_t		sc_sz;
149	void			*sc_soft_ih;
150
151	kmutex_t		sc_media_mtx;	/* XXX */
152
153	struct sysctllog	*sc_sysctllog;
154
155	int			antenna;
156	int			dwelltime;
157	int			bluetooth;
158	int			nictype;
159
160	int			sc_tx_timer;
161
162	struct bpf_if		*sc_drvbpf;
163
164	union {
165		struct iwi_rx_radiotap_header th;
166		uint8_t	pad[64];
167	} sc_rxtapu;
168#define sc_rxtap	sc_rxtapu.th
169	int			sc_rxtap_len;
170
171	union {
172		struct iwi_tx_radiotap_header th;
173		uint8_t	pad[64];
174	} sc_txtapu;
175#define sc_txtap	sc_txtapu.th
176	int			sc_txtap_len;
177};
178
179#define	sc_if	sc_ec.ec_if
180
181#define SIOCGRADIO	_IOWR('i', 139, struct ifreq)
182#define SIOCGTABLE0	_IOWR('i', 140, struct ifreq)
183