xref: /titanic_52/usr/src/uts/common/io/urtw/urtw_var.h (revision dfa03ef6809f806ad32c097e1f909a56bcaa247e)
126594249SQin Michael Li /*
226594249SQin Michael Li  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
326594249SQin Michael Li  * Use is subject to license terms.
426594249SQin Michael Li  */
526594249SQin Michael Li 
626594249SQin Michael Li /*
726594249SQin Michael Li  * Copyright (c) 2008 Weongyo Jeong
826594249SQin Michael Li  * All rights reserved.
926594249SQin Michael Li  *
1026594249SQin Michael Li  * Redistribution and use in source and binary forms, with or without
1126594249SQin Michael Li  * modification, are permitted provided that the following conditions
1226594249SQin Michael Li  * are met:
1326594249SQin Michael Li  * 1. Redistributions of source code must retain the above copyright
1426594249SQin Michael Li  *    notice, this list of conditions and the following disclaimer,
1526594249SQin Michael Li  *    without modification.
1626594249SQin Michael Li  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1726594249SQin Michael Li  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
1826594249SQin Michael Li  *    redistribution must be conditioned upon including a substantially
1926594249SQin Michael Li  *    similar Disclaimer requirement for further binary redistribution.
2026594249SQin Michael Li  *
2126594249SQin Michael Li  * NO WARRANTY
2226594249SQin Michael Li  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2326594249SQin Michael Li  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2426594249SQin Michael Li  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
2526594249SQin Michael Li  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
2626594249SQin Michael Li  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
2726594249SQin Michael Li  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2826594249SQin Michael Li  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2926594249SQin Michael Li  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
3026594249SQin Michael Li  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3126594249SQin Michael Li  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
3226594249SQin Michael Li  * THE POSSIBILITY OF SUCH DAMAGES.
3326594249SQin Michael Li  */
3426594249SQin Michael Li #ifndef	_URTW_VAR_H
3526594249SQin Michael Li #define	_URTW_VAR_H
3626594249SQin Michael Li 
3726594249SQin Michael Li #ifdef __cplusplus
3826594249SQin Michael Li extern "C" {
3926594249SQin Michael Li #endif
4026594249SQin Michael Li 
41*dfa03ef6SQin Michael Li #define	URTW_RX_DATA_LIST_COUNT	(2)
4226594249SQin Michael Li #define	URTW_TX_DATA_LIST_COUNT	(16)
4326594249SQin Michael Li #define	URTW_RX_MAXSIZE	(0x9c4)
4426594249SQin Michael Li #define	URTW_TX_MAXSIZE	URTW_RX_MAXSIZE
4526594249SQin Michael Li 
4626594249SQin Michael Li #define	UT_READ_VENDOR_DEVICE (USB_DEV_REQ_TYPE_VENDOR |\
4726594249SQin Michael Li 	USB_DEV_REQ_DEV_TO_HOST)
4826594249SQin Michael Li 
4926594249SQin Michael Li #define	UT_WRITE_VENDOR_DEVICE (USB_DEV_REQ_TYPE_VENDOR |\
5026594249SQin Michael Li 	USB_DEV_REQ_HOST_TO_DEV)
5126594249SQin Michael Li 
5226594249SQin Michael Li #define	USBD_INVAL (-1)
5326594249SQin Michael Li #define	URTW_TX_TIMEOUT	(5)
5426594249SQin Michael Li 
5526594249SQin Michael Li typedef int usbd_status;
5626594249SQin Michael Li 
5726594249SQin Michael Li #define	URTW_MAX_CHANNELS (15)
5826594249SQin Michael Li #define	LOW_PRIORITY_PIPE (0)
5926594249SQin Michael Li #define	NORMAL_PRIORITY_PIPE (1)
6026594249SQin Michael Li #define	URTW_LED_LINKOFF_BLINK	(1000*1000)
6126594249SQin Michael Li #define	URTW_LED_LINKON_BLINK	(300*1000)
6226594249SQin Michael Li 
63*dfa03ef6SQin Michael Li struct urtw_rf {
64*dfa03ef6SQin Michael Li 	/* RF methods */
65*dfa03ef6SQin Michael Li 	usbd_status			(*init)(struct urtw_rf *);
66*dfa03ef6SQin Michael Li 	usbd_status			(*set_chan)(struct urtw_rf *, int);
67*dfa03ef6SQin Michael Li 	usbd_status			(*set_sens)(struct urtw_rf *);
68*dfa03ef6SQin Michael Li 
69*dfa03ef6SQin Michael Li 	/* RF attributes */
70*dfa03ef6SQin Michael Li 	struct urtw_softc		*rf_sc;
71*dfa03ef6SQin Michael Li 	uint32_t			max_sens;
72*dfa03ef6SQin Michael Li 	int32_t				sens;
73*dfa03ef6SQin Michael Li };
74*dfa03ef6SQin Michael Li 
7526594249SQin Michael Li struct urtw_softc {
7626594249SQin Michael Li 	struct ieee80211com	sc_ic;
7726594249SQin Michael Li 	dev_info_t		*sc_dev;
7826594249SQin Michael Li 	kmutex_t		sc_genlock;
7926594249SQin Michael Li 	kmutex_t		tx_lock;
8026594249SQin Michael Li 	kmutex_t		rx_lock;
8126594249SQin Michael Li 	usb_client_dev_data_t	*sc_udev;
8226594249SQin Michael Li 	usb_pipe_handle_t	sc_rxpipe;
8326594249SQin Michael Li 	usb_pipe_handle_t	sc_txpipe_low;
8426594249SQin Michael Li 	usb_pipe_handle_t	sc_txpipe_normal;
8526594249SQin Michael Li 
8626594249SQin Michael Li 	int			sc_tx_low_queued;
8726594249SQin Michael Li 	int 			sc_tx_normal_queued;
8826594249SQin Michael Li 	int			rx_queued;
8926594249SQin Michael Li 	timeout_id_t		sc_scan_id;
9026594249SQin Michael Li 	uint32_t		sc_need_sched;
9126594249SQin Michael Li 	int			dwelltime;
9226594249SQin Michael Li 	/* kstats */
9326594249SQin Michael Li 	uint32_t		sc_tx_nobuf;
9426594249SQin Michael Li 	uint32_t		sc_rx_nobuf;
9526594249SQin Michael Li 	uint32_t		sc_rx_err;
9626594249SQin Michael Li 
9726594249SQin Michael Li 	int			sc_flags;
9826594249SQin Michael Li 	int			sc_arg;
9926594249SQin Michael Li 	int			(*sc_newstate)(struct ieee80211com *,
10026594249SQin Michael Li 				    enum ieee80211_state, int);
10126594249SQin Michael Li 
10226594249SQin Michael Li 	int				sc_epromtype;
10326594249SQin Michael Li #define	URTW_EEPROM_93C46		0
10426594249SQin Michael Li #define	URTW_EEPROM_93C56		1
10526594249SQin Michael Li 	uint8_t				sc_crcmon;
10626594249SQin Michael Li 	uint8_t				sc_bssid[IEEE80211_ADDR_LEN];
10726594249SQin Michael Li 
108*dfa03ef6SQin Michael Li 	struct urtw_rf			sc_rf;
109*dfa03ef6SQin Michael Li 
11026594249SQin Michael Li 	/* for LED  */
11126594249SQin Michael Li 	kmutex_t			sc_ledlock;
11226594249SQin Michael Li 	timeout_id_t			sc_led_ch;
11326594249SQin Michael Li 	uint8_t				sc_psr;
11426594249SQin Michael Li 	uint8_t				sc_strategy;
11526594249SQin Michael Li 	uint8_t				sc_led_freq;
11626594249SQin Michael Li #define	URTW_LED_GPIO			1
11726594249SQin Michael Li 	uint8_t				sc_gpio_ledon;
11826594249SQin Michael Li 	uint8_t				sc_gpio_ledinprogress;
11926594249SQin Michael Li 	uint8_t				sc_gpio_ledstate;
12026594249SQin Michael Li 	uint8_t				sc_gpio_ledpin;
12126594249SQin Michael Li 	uint8_t				sc_gpio_blinktime;
12226594249SQin Michael Li 	uint8_t				sc_gpio_blinkstate;
12326594249SQin Michael Li 	uint8_t				sc_rts_retry;
12426594249SQin Michael Li 	uint8_t				sc_tx_retry;
12526594249SQin Michael Li 	uint8_t				sc_preamble_mode;
12626594249SQin Michael Li 	int				sc_currate;
12726594249SQin Michael Li 	/* TX power  */
12826594249SQin Michael Li 	uint8_t				sc_txpwr_cck[URTW_MAX_CHANNELS];
12926594249SQin Michael Li 	uint8_t				sc_txpwr_cck_base;
13026594249SQin Michael Li 	uint8_t				sc_txpwr_ofdm[URTW_MAX_CHANNELS];
13126594249SQin Michael Li 	uint8_t				sc_txpwr_ofdm_base;
132*dfa03ef6SQin Michael Li 
133*dfa03ef6SQin Michael Li 	uint8_t				sc_hwrev;
134*dfa03ef6SQin Michael Li 	int				(*urtw_init)(void *);
13526594249SQin Michael Li };
13626594249SQin Michael Li #define	URTW_FLAG_RUNNING	(1 << 0)
13726594249SQin Michael Li #define	URTW_FLAG_SUSPEND	(1 << 1)
13826594249SQin Michael Li #define	URTW_FLAG_PLUGIN_ONLINE	(1 << 2)
139*dfa03ef6SQin Michael Li #define	URTW_FLAG_HP		(1 << 3)
14026594249SQin Michael Li 
14126594249SQin Michael Li #define	URTW_IS_PLUGIN_ONLINE(_sc) \
14226594249SQin Michael Li 	((_sc)->sc_flags & URTW_FLAG_PLUGIN_ONLINE)
14326594249SQin Michael Li #define	URTW_IS_RUNNING(_sc) \
14426594249SQin Michael Li 	((_sc)->sc_flags & URTW_FLAG_RUNNING)
14526594249SQin Michael Li #define	URTW_IS_NOT_RUNNING(_sc) \
14626594249SQin Michael Li 	(((_sc)->sc_flags & URTW_FLAG_RUNNING) == 0)
14726594249SQin Michael Li #define	URTW_IS_SUSPENDING(_sc)	((_sc)->sc_flags & URTW_FLAG_SUSPEND)
14826594249SQin Michael Li 
14926594249SQin Michael Li #define	URTW_LOCK(sc)		mutex_enter(&(sc)->sc_genlock)
15026594249SQin Michael Li #define	URTW_UNLOCK(sc)		mutex_exit(&(sc)->sc_genlock)
15126594249SQin Michael Li #define	URTW_LEDLOCK(sc)	mutex_enter(&(sc)->sc_ledlock)
15226594249SQin Michael Li #define	URTW_LEDUNLOCK(sc)	mutex_exit(&(sc)->sc_ledlock)
15326594249SQin Michael Li 
15426594249SQin Michael Li #ifdef __cplusplus
15526594249SQin Michael Li }
15626594249SQin Michael Li #endif
15726594249SQin Michael Li 
15826594249SQin Michael Li #endif /* _URTW_VAR_H */
159