xref: /freebsd/sys/dev/usb/wlan/if_rumvar.h (revision 830940567b49bb0c08dfaed40418999e76616909)
1 /*	$FreeBSD$	*/
2 
3 /*-
4  * Copyright (c) 2005, 2006 Damien Bergamini <damien.bergamini@free.fr>
5  * Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
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 #define RUM_TX_LIST_COUNT	8
21 #define RUM_TX_MINFREE		2
22 
23 struct rum_rx_radiotap_header {
24 	struct ieee80211_radiotap_header wr_ihdr;
25 	uint8_t		wr_flags;
26 	uint8_t		wr_rate;
27 	uint16_t	wr_chan_freq;
28 	uint16_t	wr_chan_flags;
29 	int8_t		wr_antsignal;
30 	int8_t		wr_antnoise;
31 	uint8_t		wr_antenna;
32 };
33 
34 #define RT2573_RX_RADIOTAP_PRESENT					\
35 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
36 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
37 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
38 	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
39 	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |			\
40 	 (1 << IEEE80211_RADIOTAP_ANTENNA) |				\
41 	 0)
42 
43 struct rum_tx_radiotap_header {
44 	struct ieee80211_radiotap_header wt_ihdr;
45 	uint8_t		wt_flags;
46 	uint8_t		wt_rate;
47 	uint16_t	wt_chan_freq;
48 	uint16_t	wt_chan_flags;
49 	uint8_t		wt_antenna;
50 };
51 
52 #define RT2573_TX_RADIOTAP_PRESENT					\
53 	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
54 	 (1 << IEEE80211_RADIOTAP_RATE) |				\
55 	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
56 	 (1 << IEEE80211_RADIOTAP_ANTENNA))
57 
58 struct rum_softc;
59 
60 struct rum_tx_data {
61 	STAILQ_ENTRY(rum_tx_data)	next;
62 	struct rum_softc		*sc;
63 	struct rum_tx_desc		desc;
64 	struct mbuf			*m;
65 	struct ieee80211_node		*ni;
66 	int				rate;
67 };
68 typedef STAILQ_HEAD(, rum_tx_data) rum_txdhead;
69 
70 struct rum_node {
71 	struct ieee80211_node	ni;
72 	struct ieee80211_amrr_node amn;
73 };
74 #define	RUM_NODE(ni)	((struct rum_node *)(ni))
75 
76 struct rum_vap {
77 	struct ieee80211vap		vap;
78 	struct ieee80211_beacon_offsets	bo;
79 	struct ieee80211_amrr		amrr;
80 	struct usb_callout		amrr_ch;
81 	struct task			amrr_task;
82 
83 	int				(*newstate)(struct ieee80211vap *,
84 					    enum ieee80211_state, int);
85 };
86 #define	RUM_VAP(vap)	((struct rum_vap *)(vap))
87 
88 enum {
89 	RUM_BULK_WR,
90 	RUM_BULK_RD,
91 	RUM_N_TRANSFER = 2,
92 };
93 
94 struct rum_softc {
95 	struct ifnet			*sc_ifp;
96 	device_t			sc_dev;
97 	struct usb_device		*sc_udev;
98 
99 	struct usb_xfer		*sc_xfer[RUM_N_TRANSFER];
100 
101 	uint8_t				rf_rev;
102 	uint8_t				rffreq;
103 
104 	struct rum_tx_data		tx_data[RUM_TX_LIST_COUNT];
105 	rum_txdhead			tx_q;
106 	rum_txdhead			tx_free;
107 	int				tx_nfree;
108 	struct rum_rx_desc		sc_rx_desc;
109 
110 	struct mtx			sc_mtx;
111 
112 	uint32_t			sta[6];
113 	uint32_t			rf_regs[4];
114 	uint8_t				txpow[44];
115 	uint8_t				sc_bssid[6];
116 
117 	struct {
118 		uint8_t	val;
119 		uint8_t	reg;
120 	} __packed			bbp_prom[16];
121 
122 	int				hw_radio;
123 	int				rx_ant;
124 	int				tx_ant;
125 	int				nb_ant;
126 	int				ext_2ghz_lna;
127 	int				ext_5ghz_lna;
128 	int				rssi_2ghz_corr;
129 	int				rssi_5ghz_corr;
130 	uint8_t				bbp17;
131 
132 	struct rum_rx_radiotap_header	sc_rxtap;
133 	int				sc_rxtap_len;
134 
135 	struct rum_tx_radiotap_header	sc_txtap;
136 	int				sc_txtap_len;
137 };
138 
139 #define RUM_LOCK(sc)		mtx_lock(&(sc)->sc_mtx)
140 #define RUM_UNLOCK(sc)		mtx_unlock(&(sc)->sc_mtx)
141 #define RUM_LOCK_ASSERT(sc, t)	mtx_assert(&(sc)->sc_mtx, t)
142