xref: /titanic_51/usr/src/uts/common/io/ural/ural_var.h (revision dc4bf86d3869090fa08d98d7030728be986fd289)
1 /*
2  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 2005
8  *	Damien Bergamini <damien.bergamini@free.fr>
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	_URAL_VAR_H
23 #define	_URAL_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_TX_LIST_COUNT	8
51 #define	RAL_RX_LIST_COUNT	8
52 
53 struct ural_amrr {
54 	int	txcnt;
55 	int	retrycnt;
56 	int	success;
57 	int	success_threshold;
58 	int	recovery;
59 };
60 
61 struct ural_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 	uint32_t		asic_rev;
68 	uint8_t			rf_rev;
69 
70 	kmutex_t		sc_genlock;
71 
72 	usb_pipe_handle_t	sc_rx_pipeh;
73 	usb_pipe_handle_t	sc_tx_pipeh;
74 
75 	enum ieee80211_state	sc_state;
76 	struct ural_amrr	amrr;
77 
78 	kmutex_t		tx_lock;
79 	kmutex_t		rx_lock;
80 
81 	int			tx_queued;
82 	int			rx_queued;
83 
84 	int			sc_tx_timer;
85 
86 	timeout_id_t		sc_scan_id;
87 	timeout_id_t		sc_amrr_id;
88 
89 	uint32_t		sc_need_sched;
90 	uint32_t		sc_flags;
91 	uint32_t		sc_rcr;		/* RAL RCR */
92 
93 	int			dwelltime;
94 
95 	uint16_t		sta[11];
96 	uint32_t		rf_regs[4];
97 	uint8_t			txpow[14];
98 
99 #pragma pack(1)
100 	struct {
101 		uint8_t		val;
102 		uint8_t		reg;
103 	} 			bbp_prom[16];
104 #pragma pack()
105 
106 	int			led_mode;
107 	int			hw_radio;
108 	int			rx_ant;
109 	int			tx_ant;
110 	int			nb_ant;
111 
112 	/* kstats */
113 	uint32_t		sc_tx_nobuf;
114 	uint32_t		sc_rx_nobuf;
115 	uint32_t		sc_tx_err;
116 	uint32_t		sc_rx_err;
117 	uint32_t		sc_tx_retries;
118 
119 	int			(*sc_newstate)(struct ieee80211com *,
120 				    enum ieee80211_state, int);
121 
122 };
123 
124 #define	RAL_IS_RUNNING(_sc)	((_sc)->sc_flags & RAL_FLAG_RUNNING)
125 #define	RAL_LOCK(sc)		mutex_enter(&(sc)->sc_genlock)
126 #define	RAL_UNLOCK(sc)		mutex_exit(&(sc)->sc_genlock)
127 
128 #define	MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
129 #define	MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* _URAL_VAR_H */
136