xref: /titanic_50/usr/src/uts/common/io/urtw/urtw_var.h (revision 5c51f1241dbbdf2656d0e10011981411ed0c9673)
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	(1)
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_softc {
64 	struct ieee80211com	sc_ic;
65 	dev_info_t		*sc_dev;
66 	kmutex_t		sc_genlock;
67 	kmutex_t		tx_lock;
68 	kmutex_t		rx_lock;
69 	usb_client_dev_data_t	*sc_udev;
70 	usb_pipe_handle_t	sc_rxpipe;
71 	usb_pipe_handle_t	sc_txpipe_low;
72 	usb_pipe_handle_t	sc_txpipe_normal;
73 
74 	int			sc_tx_low_queued;
75 	int 			sc_tx_normal_queued;
76 	int			rx_queued;
77 	timeout_id_t		sc_scan_id;
78 	uint32_t		sc_need_sched;
79 	int			dwelltime;
80 	/* kstats */
81 	uint32_t		sc_tx_nobuf;
82 	uint32_t		sc_rx_nobuf;
83 	uint32_t		sc_rx_err;
84 
85 	int			sc_flags;
86 	int			sc_arg;
87 	int			(*sc_newstate)(struct ieee80211com *,
88 				    enum ieee80211_state, int);
89 
90 	int				sc_epromtype;
91 #define	URTW_EEPROM_93C46		0
92 #define	URTW_EEPROM_93C56		1
93 	uint8_t				sc_crcmon;
94 	uint8_t				sc_bssid[IEEE80211_ADDR_LEN];
95 
96 	/* for RF  */
97 	usbd_status			(*sc_rf_init)(struct urtw_softc *);
98 	usbd_status			(*sc_rf_set_chan)(struct urtw_softc *,
99 					    int);
100 	usbd_status			(*sc_rf_set_sens)(struct urtw_softc *,
101 					    int);
102 	uint8_t				sc_rfchip;
103 	uint32_t			sc_max_sens;
104 	uint32_t			sc_sens;
105 	/* for LED  */
106 	kmutex_t			sc_ledlock;
107 	timeout_id_t			sc_led_ch;
108 	uint8_t				sc_psr;
109 	uint8_t				sc_strategy;
110 	uint8_t				sc_led_freq;
111 #define	URTW_LED_GPIO			1
112 	uint8_t				sc_gpio_ledon;
113 	uint8_t				sc_gpio_ledinprogress;
114 	uint8_t				sc_gpio_ledstate;
115 	uint8_t				sc_gpio_ledpin;
116 	uint8_t				sc_gpio_blinktime;
117 	uint8_t				sc_gpio_blinkstate;
118 	uint8_t				sc_rts_retry;
119 	uint8_t				sc_tx_retry;
120 	uint8_t				sc_preamble_mode;
121 	int				sc_currate;
122 	/* TX power  */
123 	uint8_t				sc_txpwr_cck[URTW_MAX_CHANNELS];
124 	uint8_t				sc_txpwr_cck_base;
125 	uint8_t				sc_txpwr_ofdm[URTW_MAX_CHANNELS];
126 	uint8_t				sc_txpwr_ofdm_base;
127 };
128 #define	URTW_FLAG_RUNNING	(1 << 0)
129 #define	URTW_FLAG_SUSPEND	(1 << 1)
130 #define	URTW_FLAG_PLUGIN_ONLINE		(1 << 2)
131 
132 #define	URTW_IS_PLUGIN_ONLINE(_sc) \
133 	((_sc)->sc_flags & URTW_FLAG_PLUGIN_ONLINE)
134 #define	URTW_IS_RUNNING(_sc) \
135 	((_sc)->sc_flags & URTW_FLAG_RUNNING)
136 #define	URTW_IS_NOT_RUNNING(_sc) \
137 	(((_sc)->sc_flags & URTW_FLAG_RUNNING) == 0)
138 #define	URTW_IS_SUSPENDING(_sc)	((_sc)->sc_flags & URTW_FLAG_SUSPEND)
139 
140 #define	URTW_LOCK(sc)		mutex_enter(&(sc)->sc_genlock)
141 #define	URTW_UNLOCK(sc)		mutex_exit(&(sc)->sc_genlock)
142 #define	URTW_LEDLOCK(sc)	mutex_enter(&(sc)->sc_ledlock)
143 #define	URTW_LEDUNLOCK(sc)	mutex_exit(&(sc)->sc_ledlock)
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif /* _URTW_VAR_H */
150