if_uralvar.h revision 246614
1237285Sscottl/*	$FreeBSD: head/sys/dev/usb/wlan/if_uralvar.h 246614 2013-02-10 10:36:16Z hselasky $	*/
2237285Sscottl
3237285Sscottl/*-
4237285Sscottl * Copyright (c) 2005
5237285Sscottl *	Damien Bergamini <damien.bergamini@free.fr>
6237285Sscottl *
7237285Sscottl * Permission to use, copy, modify, and distribute this software for any
8237285Sscottl * purpose with or without fee is hereby granted, provided that the above
9237285Sscottl * copyright notice and this permission notice appear in all copies.
10237285Sscottl *
11237285Sscottl * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12237285Sscottl * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13237285Sscottl * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14237285Sscottl * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15237285Sscottl * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16237285Sscottl * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17237285Sscottl * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18237285Sscottl */
19237285Sscottl
20237285Sscottl#define RAL_TX_LIST_COUNT	8
21237285Sscottl#define RAL_TX_MINFREE		2
22237285Sscottl
23237285Sscottl#define URAL_SCAN_START         1
24237285Sscottl#define URAL_SCAN_END           2
25237285Sscottl#define URAL_SET_CHANNEL        3
26237285Sscottl
27237285Sscottl
28237285Sscottlstruct ural_rx_radiotap_header {
29237285Sscottl	struct ieee80211_radiotap_header wr_ihdr;
30237285Sscottl	uint8_t		wr_flags;
31237285Sscottl	uint8_t		wr_rate;
32237285Sscottl	uint16_t	wr_chan_freq;
33237285Sscottl	uint16_t	wr_chan_flags;
34237285Sscottl	int8_t		wr_antsignal;
35237285Sscottl	int8_t		wr_antnoise;
36237285Sscottl	uint8_t		wr_antenna;
37237285Sscottl};
38237285Sscottl
39237285Sscottl#define RAL_RX_RADIOTAP_PRESENT						\
40237285Sscottl	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
41237285Sscottl	 (1 << IEEE80211_RADIOTAP_RATE) |				\
42237285Sscottl	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
43237285Sscottl	 (1 << IEEE80211_RADIOTAP_ANTENNA) |				\
44237285Sscottl	 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |			\
45237285Sscottl	 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE))
46237285Sscottl
47237285Sscottlstruct ural_tx_radiotap_header {
48237285Sscottl	struct ieee80211_radiotap_header wt_ihdr;
49237285Sscottl	uint8_t		wt_flags;
50237285Sscottl	uint8_t		wt_rate;
51237285Sscottl	uint16_t	wt_chan_freq;
52237285Sscottl	uint16_t	wt_chan_flags;
53237285Sscottl	uint8_t		wt_antenna;
54237285Sscottl};
55237285Sscottl
56237285Sscottl#define RAL_TX_RADIOTAP_PRESENT						\
57237285Sscottl	((1 << IEEE80211_RADIOTAP_FLAGS) |				\
58237285Sscottl	 (1 << IEEE80211_RADIOTAP_RATE) |				\
59237285Sscottl	 (1 << IEEE80211_RADIOTAP_CHANNEL) |				\
60237285Sscottl	 (1 << IEEE80211_RADIOTAP_ANTENNA))
61
62struct ural_softc;
63
64struct ural_tx_data {
65	STAILQ_ENTRY(ural_tx_data)	next;
66	struct ural_softc		*sc;
67	struct ural_tx_desc		desc;
68	struct mbuf			*m;
69	struct ieee80211_node		*ni;
70	int				rate;
71};
72typedef STAILQ_HEAD(, ural_tx_data) ural_txdhead;
73
74struct ural_vap {
75	struct ieee80211vap		vap;
76	struct ieee80211_beacon_offsets	bo;
77	struct usb_callout		ratectl_ch;
78	struct task			ratectl_task;
79
80	int				(*newstate)(struct ieee80211vap *,
81					    enum ieee80211_state, int);
82};
83#define	URAL_VAP(vap)	((struct ural_vap *)(vap))
84
85enum {
86	URAL_BULK_WR,
87	URAL_BULK_RD,
88	URAL_N_TRANSFER = 2,
89};
90
91struct ural_softc {
92	struct ifnet			*sc_ifp;
93	device_t			sc_dev;
94	struct usb_device		*sc_udev;
95
96	uint32_t			asic_rev;
97	uint8_t				rf_rev;
98
99	struct usb_xfer		*sc_xfer[URAL_N_TRANSFER];
100
101	struct ural_tx_data		tx_data[RAL_TX_LIST_COUNT];
102	ural_txdhead			tx_q;
103	ural_txdhead			tx_free;
104	int				tx_nfree;
105	struct ural_rx_desc		sc_rx_desc;
106
107	struct mtx			sc_mtx;
108
109	uint16_t			sta[11];
110	uint32_t			rf_regs[4];
111	uint8_t				txpow[14];
112	uint8_t				sc_bssid[6];
113	uint8_t				sc_detached;
114
115	struct {
116		uint8_t			val;
117		uint8_t			reg;
118	} __packed			bbp_prom[16];
119
120	int				led_mode;
121	int				hw_radio;
122	int				rx_ant;
123	int				tx_ant;
124	int				nb_ant;
125
126	struct ural_rx_radiotap_header	sc_rxtap;
127	int				sc_rxtap_len;
128
129	struct ural_tx_radiotap_header	sc_txtap;
130	int				sc_txtap_len;
131};
132
133#define RAL_LOCK(sc)		mtx_lock(&(sc)->sc_mtx)
134#define RAL_UNLOCK(sc)		mtx_unlock(&(sc)->sc_mtx)
135#define RAL_LOCK_ASSERT(sc, t)	mtx_assert(&(sc)->sc_mtx, t)
136