xref: /illumos-gate/usr/src/uts/common/io/urtw/urtw_var.h (revision dfa03ef6)
1 /*
2  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 2008 Weongyo Jeong
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer,
15  *    without modification.
16  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
17  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
18  *    redistribution must be conditioned upon including a substantially
19  *    similar Disclaimer requirement for further binary redistribution.
20  *
21  * NO WARRANTY
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
25  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
26  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
27  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
30  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32  * THE POSSIBILITY OF SUCH DAMAGES.
33  */
34 #ifndef	_URTW_VAR_H
35 #define	_URTW_VAR_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #define	URTW_RX_DATA_LIST_COUNT	(2)
42 #define	URTW_TX_DATA_LIST_COUNT	(16)
43 #define	URTW_RX_MAXSIZE	(0x9c4)
44 #define	URTW_TX_MAXSIZE	URTW_RX_MAXSIZE
45 
46 #define	UT_READ_VENDOR_DEVICE (USB_DEV_REQ_TYPE_VENDOR |\
47 	USB_DEV_REQ_DEV_TO_HOST)
48 
49 #define	UT_WRITE_VENDOR_DEVICE (USB_DEV_REQ_TYPE_VENDOR |\
50 	USB_DEV_REQ_HOST_TO_DEV)
51 
52 #define	USBD_INVAL (-1)
53 #define	URTW_TX_TIMEOUT	(5)
54 
55 typedef int usbd_status;
56 
57 #define	URTW_MAX_CHANNELS (15)
58 #define	LOW_PRIORITY_PIPE (0)
59 #define	NORMAL_PRIORITY_PIPE (1)
60 #define	URTW_LED_LINKOFF_BLINK	(1000*1000)
61 #define	URTW_LED_LINKON_BLINK	(300*1000)
62 
63 struct urtw_rf {
64 	/* RF methods */
65 	usbd_status			(*init)(struct urtw_rf *);
66 	usbd_status			(*set_chan)(struct urtw_rf *, int);
67 	usbd_status			(*set_sens)(struct urtw_rf *);
68 
69 	/* RF attributes */
70 	struct urtw_softc		*rf_sc;
71 	uint32_t			max_sens;
72 	int32_t				sens;
73 };
74 
75 struct urtw_softc {
76 	struct ieee80211com	sc_ic;
77 	dev_info_t		*sc_dev;
78 	kmutex_t		sc_genlock;
79 	kmutex_t		tx_lock;
80 	kmutex_t		rx_lock;
81 	usb_client_dev_data_t	*sc_udev;
82 	usb_pipe_handle_t	sc_rxpipe;
83 	usb_pipe_handle_t	sc_txpipe_low;
84 	usb_pipe_handle_t	sc_txpipe_normal;
85 
86 	int			sc_tx_low_queued;
87 	int 			sc_tx_normal_queued;
88 	int			rx_queued;
89 	timeout_id_t		sc_scan_id;
90 	uint32_t		sc_need_sched;
91 	int			dwelltime;
92 	/* kstats */
93 	uint32_t		sc_tx_nobuf;
94 	uint32_t		sc_rx_nobuf;
95 	uint32_t		sc_rx_err;
96 
97 	int			sc_flags;
98 	int			sc_arg;
99 	int			(*sc_newstate)(struct ieee80211com *,
100 				    enum ieee80211_state, int);
101 
102 	int				sc_epromtype;
103 #define	URTW_EEPROM_93C46		0
104 #define	URTW_EEPROM_93C56		1
105 	uint8_t				sc_crcmon;
106 	uint8_t				sc_bssid[IEEE80211_ADDR_LEN];
107 
108 	struct urtw_rf			sc_rf;
109 
110 	/* for LED  */
111 	kmutex_t			sc_ledlock;
112 	timeout_id_t			sc_led_ch;
113 	uint8_t				sc_psr;
114 	uint8_t				sc_strategy;
115 	uint8_t				sc_led_freq;
116 #define	URTW_LED_GPIO			1
117 	uint8_t				sc_gpio_ledon;
118 	uint8_t				sc_gpio_ledinprogress;
119 	uint8_t				sc_gpio_ledstate;
120 	uint8_t				sc_gpio_ledpin;
121 	uint8_t				sc_gpio_blinktime;
122 	uint8_t				sc_gpio_blinkstate;
123 	uint8_t				sc_rts_retry;
124 	uint8_t				sc_tx_retry;
125 	uint8_t				sc_preamble_mode;
126 	int				sc_currate;
127 	/* TX power  */
128 	uint8_t				sc_txpwr_cck[URTW_MAX_CHANNELS];
129 	uint8_t				sc_txpwr_cck_base;
130 	uint8_t				sc_txpwr_ofdm[URTW_MAX_CHANNELS];
131 	uint8_t				sc_txpwr_ofdm_base;
132 
133 	uint8_t				sc_hwrev;
134 	int				(*urtw_init)(void *);
135 };
136 #define	URTW_FLAG_RUNNING	(1 << 0)
137 #define	URTW_FLAG_SUSPEND	(1 << 1)
138 #define	URTW_FLAG_PLUGIN_ONLINE	(1 << 2)
139 #define	URTW_FLAG_HP		(1 << 3)
140 
141 #define	URTW_IS_PLUGIN_ONLINE(_sc) \
142 	((_sc)->sc_flags & URTW_FLAG_PLUGIN_ONLINE)
143 #define	URTW_IS_RUNNING(_sc) \
144 	((_sc)->sc_flags & URTW_FLAG_RUNNING)
145 #define	URTW_IS_NOT_RUNNING(_sc) \
146 	(((_sc)->sc_flags & URTW_FLAG_RUNNING) == 0)
147 #define	URTW_IS_SUSPENDING(_sc)	((_sc)->sc_flags & URTW_FLAG_SUSPEND)
148 
149 #define	URTW_LOCK(sc)		mutex_enter(&(sc)->sc_genlock)
150 #define	URTW_UNLOCK(sc)		mutex_exit(&(sc)->sc_genlock)
151 #define	URTW_LEDLOCK(sc)	mutex_enter(&(sc)->sc_ledlock)
152 #define	URTW_LEDUNLOCK(sc)	mutex_exit(&(sc)->sc_ledlock)
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 #endif /* _URTW_VAR_H */
159