xref: /titanic_51/usr/src/uts/common/io/rum/rum_var.h (revision 1886f67eb9de99edbcda88765f2c603a30c87fc2)
1 /*
2  * Copyright 2009 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 #define	RAL_RX_LIST_COUNT	8
51 #define	RAL_TX_LIST_COUNT	8
52 
53 struct rum_amrr {
54 	int	txcnt;
55 	int	retrycnt;
56 	int	success;
57 	int	success_threshold;
58 	int	recovery;
59 };
60 
61 struct rum_softc {
62 	struct ieee80211com	sc_ic;
63 	dev_info_t		*sc_dev;
64 
65 	usb_client_dev_data_t	*sc_udev;	/* usb dev */
66 
67 	int			sc_rx_no;
68 	int			sc_tx_no;
69 
70 	uint8_t			rf_rev;
71 	uint8_t			rffreq;
72 
73 	kmutex_t		sc_genlock;
74 
75 	usb_pipe_handle_t	sc_rx_pipeh;
76 	usb_pipe_handle_t	sc_tx_pipeh;
77 
78 	enum ieee80211_state	sc_state;
79 	struct rum_amrr		amrr;
80 
81 	kmutex_t		tx_lock;
82 	kmutex_t		rx_lock;
83 
84 	int			tx_queued;
85 	int			rx_queued;
86 
87 	int			sc_tx_timer;
88 
89 	timeout_id_t		sc_scan_id;
90 	timeout_id_t		sc_amrr_id;
91 
92 	uint32_t		sc_need_sched;
93 	uint32_t		sc_flags;
94 	uint32_t		sc_rcr;		/* RAL RCR */
95 
96 	int			dwelltime;
97 
98 	uint32_t		sta[6];
99 	uint32_t		rf_regs[4];
100 	uint8_t			txpow[44];
101 
102 #pragma pack(1)
103 	struct {
104 		uint8_t	val;
105 		uint8_t	reg;
106 	}			bbp_prom[16];
107 #pragma pack()
108 
109 	int			hw_radio;
110 	int			rx_ant;
111 	int			tx_ant;
112 	int			nb_ant;
113 	int			ext_2ghz_lna;
114 	int			ext_5ghz_lna;
115 	int			rssi_2ghz_corr;
116 	int			rssi_5ghz_corr;
117 	int			sifs;
118 	uint8_t			bbp17;
119 
120 	/* kstats */
121 	uint32_t		sc_tx_nobuf;
122 	uint32_t		sc_rx_nobuf;
123 	uint32_t		sc_tx_err;
124 	uint32_t		sc_rx_err;
125 	uint32_t		sc_tx_retries;
126 
127 	int			(*sc_newstate)(struct ieee80211com *,
128 				    enum ieee80211_state, int);
129 };
130 
131 #define	RAL_IS_RUNNING(_sc)	((_sc)->sc_flags & RAL_FLAG_RUNNING)
132 #define	RAL_LOCK(sc)		mutex_enter(&(sc)->sc_genlock)
133 #define	RAL_UNLOCK(sc)		mutex_exit(&(sc)->sc_genlock)
134 
135 #define	MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
136 #define	MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif /* _RUM_VAR_H */
143