xref: /titanic_50/usr/src/uts/common/io/rum/rum_var.h (revision fbd1eea75de85d354a131a825206994dfdece931)
1 /*
2  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 2005, 2006 Damien Bergamini <damien.bergamini@free.fr>
8  * Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
9  *
10  * Permission to use, copy, modify, and distribute this software for any
11  * purpose with or without fee is hereby granted, provided that the above
12  * copyright notice and this permission notice appear in all copies.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  */
22 #ifndef	_RUM_VAR_H
23 #define	_RUM_VAR_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #define	RAL_FLAG_RUNNING	(1<<0)
30 
31 #define	RAL_RCR_PROMISC		(1<<0)
32 #define	RAL_RCR_MULTI		(2<<0)
33 
34 #ifndef	DDI_NT_NET_WIFI
35 #define	DDI_NT_NET_WIFI		"ddi_network:wifi"
36 #endif
37 
38 /*
39  * Bit flags in the ral_dbg_flags
40  */
41 #define	RAL_DBG_MSG		0x000001
42 #define	RAL_DBG_ERR		0x000002
43 #define	RAL_DBG_USB		0x000004
44 #define	RAL_DBG_TX		0x000008
45 #define	RAL_DBG_RX		0x000010
46 #define	RAL_DBG_IOCTL		0x000020
47 #define	RAL_DBG_HW		0x000040
48 #define	RAL_DBG_ALL		0x000fff
49 
50 #ifdef DEBUG
51 #define	RAL_DEBUG \
52 	ral_debug
53 #else
54 #define	RAL_DEBUG
55 #endif
56 
57 #define	RAL_RX_LIST_COUNT	8
58 #define	RAL_TX_LIST_COUNT	8
59 
60 struct rum_amrr {
61 	int	txcnt;
62 	int	retrycnt;
63 	int	success;
64 	int	success_threshold;
65 	int	recovery;
66 };
67 
68 struct rum_softc {
69 	struct ieee80211com	sc_ic;
70 	dev_info_t		*sc_dev;
71 
72 	usb_client_dev_data_t	*sc_udev;	/* usb dev */
73 
74 	int			sc_rx_no;
75 	int			sc_tx_no;
76 
77 	uint8_t			rf_rev;
78 	uint8_t			rffreq;
79 
80 	kmutex_t		sc_genlock;
81 
82 	usb_pipe_handle_t	sc_rx_pipeh;
83 	usb_pipe_handle_t	sc_tx_pipeh;
84 
85 	enum ieee80211_state	sc_state;
86 	struct rum_amrr		amrr;
87 
88 	kmutex_t		tx_lock;
89 	kmutex_t		rx_lock;
90 
91 	int			tx_queued;
92 	int			rx_queued;
93 
94 	int			sc_tx_timer;
95 
96 	timeout_id_t		sc_scan_id;
97 	timeout_id_t		sc_amrr_id;
98 
99 	uint32_t		sc_need_sched;
100 	uint32_t		sc_flags;
101 	uint32_t		sc_rcr;		/* RAL RCR */
102 
103 	int			dwelltime;
104 
105 	uint32_t		sta[6];
106 	uint32_t		rf_regs[4];
107 	uint8_t			txpow[44];
108 
109 #pragma pack(1)
110 	struct {
111 		uint8_t	val;
112 		uint8_t	reg;
113 	}			bbp_prom[16];
114 #pragma pack()
115 
116 	int			hw_radio;
117 	int			rx_ant;
118 	int			tx_ant;
119 	int			nb_ant;
120 	int			ext_2ghz_lna;
121 	int			ext_5ghz_lna;
122 	int			rssi_2ghz_corr;
123 	int			rssi_5ghz_corr;
124 	int			sifs;
125 	uint8_t			bbp17;
126 
127 	/* kstats */
128 	uint32_t		sc_tx_nobuf;
129 	uint32_t		sc_rx_nobuf;
130 	uint32_t		sc_tx_err;
131 	uint32_t		sc_rx_err;
132 	uint32_t		sc_tx_retries;
133 
134 	int			(*sc_newstate)(struct ieee80211com *,
135 				    enum ieee80211_state, int);
136 };
137 
138 #define	RAL_IS_RUNNING(_sc)	((_sc)->sc_flags & RAL_FLAG_RUNNING)
139 #define	RAL_LOCK(sc)		mutex_enter(&(sc)->sc_genlock)
140 #define	RAL_UNLOCK(sc)		mutex_exit(&(sc)->sc_genlock)
141 
142 #define	MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
143 #define	MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif /* _RUM_VAR_H */
150