xref: /openbsd/sys/dev/pci/if_iwivar.h (revision 8932bfb7)
1 /*	$OpenBSD: if_iwivar.h,v 1.23 2010/09/07 16:21:45 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 iwi_rx_radiotap_header {
21 	struct ieee80211_radiotap_header wr_ihdr;
22 	uint8_t		wr_flags;
23 	uint8_t		wr_rate;
24 	uint16_t	wr_chan_freq;
25 	uint16_t	wr_chan_flags;
26 	uint8_t		wr_antsignal;
27 	uint8_t		wr_antenna;
28 } __packed;
29 
30 #define IWI_RX_RADIOTAP_PRESENT						\
31 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
32 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
33 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
34 	 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |			\
35 	 (1 << IEEE80211_RADIOTAP_ANTENNA))
36 
37 struct iwi_tx_radiotap_header {
38 	struct ieee80211_radiotap_header wt_ihdr;
39 	uint8_t		wt_flags;
40 	uint16_t	wt_chan_freq;
41 	uint16_t	wt_chan_flags;
42 } __packed;
43 
44 #define IWI_TX_RADIOTAP_PRESENT						\
45 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
46 	 (1 << IEEE80211_RADIOTAP_CHANNEL))
47 
48 
49 struct iwi_cmd_ring {
50 	bus_dmamap_t		map;
51 	bus_dma_segment_t	seg;
52 	struct iwi_cmd_desc	*desc;
53 	int			queued;
54 	int			cur;
55 	int			next;
56 };
57 
58 struct iwi_tx_data {
59 	bus_dmamap_t		map;
60 	struct mbuf		*m;
61 	struct ieee80211_node	*ni;
62 };
63 
64 struct iwi_tx_ring {
65 	bus_dmamap_t		map;
66 	bus_dma_segment_t	seg;
67 	bus_size_t		csr_ridx;
68 	bus_size_t		csr_widx;
69 	struct iwi_tx_desc	*desc;
70 	struct iwi_tx_data	data[IWI_TX_RING_COUNT];
71 	int			queued;
72 	int			cur;
73 	int			next;
74 };
75 
76 struct iwi_rx_data {
77 	bus_dmamap_t		map;
78 	struct mbuf		*m;
79 	uint32_t		reg;
80 };
81 
82 struct iwi_rx_ring {
83 	struct iwi_rx_data	data[IWI_RX_RING_COUNT];
84 	int			cur;
85 };
86 
87 struct iwi_softc {
88 	struct device		sc_dev;
89 
90 	struct ieee80211com	sc_ic;
91 	int			(*sc_newstate)(struct ieee80211com *,
92 				    enum ieee80211_state, int);
93 
94 	uint32_t		sc_flags;
95 #define IWI_FLAG_FW_INITED	(1 << 0)
96 #define IWI_FLAG_BUSY		(1 << 1)
97 
98 	bus_dma_tag_t		sc_dmat;
99 
100 	struct iwi_cmd_ring	cmdq;
101 	struct iwi_tx_ring	txq[4];
102 	struct iwi_rx_ring	rxq;
103 
104 #define IWI_MAX_NODE	32
105 	uint8_t			sta[IWI_MAX_NODE][IEEE80211_ADDR_LEN];
106 	uint8_t			nsta;
107 
108 	bus_space_tag_t		sc_st;
109 	bus_space_handle_t	sc_sh;
110 	void 			*sc_ih;
111 	pci_chipset_tag_t	sc_pct;
112 	pcitag_t		sc_pcitag;
113 	bus_size_t		sc_sz;
114 
115 	int			sc_tx_timer;
116 
117 	struct workq_task	sc_resume_wqt;
118 
119 #if NBPFILTER > 0
120 	caddr_t			sc_drvbpf;
121 
122 	union {
123 		struct iwi_rx_radiotap_header th;
124 		uint8_t	pad[64];
125 	} sc_rxtapu;
126 #define sc_rxtap	sc_rxtapu.th
127 	int			sc_rxtap_len;
128 
129 	union {
130 		struct iwi_tx_radiotap_header th;
131 		uint8_t	pad[64];
132 	} sc_txtapu;
133 #define sc_txtap	sc_txtapu.th
134 	int			sc_txtap_len;
135 #endif
136 };
137