Home | History | Annotate | Line # | Download | only in usb
if_otusvar.h revision 1.1.12.3
      1  1.1.12.3      yamt /*	$NetBSD: if_otusvar.h,v 1.1.12.3 2014/05/22 11:40:36 yamt Exp $	*/
      2       1.1  christos /*	$OpenBSD: if_otusreg.h,v 1.6 2009/04/06 18:17:01 damien Exp $	*/
      3       1.1  christos 
      4       1.1  christos /*-
      5       1.1  christos  * Copyright (c) 2009 Damien Bergamini <damien.bergamini (at) free.fr>
      6       1.1  christos  * Copyright (c) 2007-2008 Atheros Communications, Inc.
      7       1.1  christos  *
      8       1.1  christos  * Permission to use, copy, modify, and distribute this software for any
      9       1.1  christos  * purpose with or without fee is hereby granted, provided that the above
     10       1.1  christos  * copyright notice and this permission notice appear in all copies.
     11       1.1  christos  *
     12       1.1  christos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     13       1.1  christos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     14       1.1  christos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     15       1.1  christos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     16       1.1  christos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     17       1.1  christos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     18       1.1  christos  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     19       1.1  christos  */
     20  1.1.12.1      yamt #ifndef _IF_OTUSVAR_H_
     21  1.1.12.1      yamt #define _IF_OTUSVAR_H_
     22       1.1  christos 
     23       1.1  christos #ifndef HAVE_EDCA
     24       1.1  christos /************************************************************
     25       1.1  christos  * XXX: This block belongs in sys/net80211/ieee80211_var.h.
     26       1.1  christos  */
     27       1.1  christos /*
     28       1.1  christos  * EDCA AC parameters.
     29       1.1  christos  */
     30       1.1  christos struct ieee80211_edca_ac_params {
     31       1.1  christos 	u_int8_t	ac_ecwmin;	/* CWmin = 2^ECWmin - 1 */
     32       1.1  christos 	u_int8_t	ac_ecwmax;	/* CWmax = 2^ECWmax - 1 */
     33       1.1  christos 	u_int8_t	ac_aifsn;
     34       1.1  christos 	u_int16_t	ac_txoplimit;	/* 32TU */
     35       1.1  christos 	u_int8_t	ac_acm;
     36       1.1  christos };
     37       1.1  christos /************************************************************/
     38       1.1  christos #endif /* ! HAVE_EDCA */
     39       1.1  christos 
     40       1.1  christos /* Default EDCA parameters for when QoS is disabled. */
     41       1.1  christos static const struct ieee80211_edca_ac_params otus_edca_def[] = {
     42       1.1  christos 	{ 4, 10, 3,  0, 0 },
     43       1.1  christos 	{ 4, 10, 7,  0, 0 },
     44       1.1  christos 	{ 3,  4, 2, 94, 0 },
     45       1.1  christos 	{ 2,  3, 2, 47, 0 }
     46       1.1  christos };
     47       1.1  christos 
     48       1.1  christos #define OTUS_TX_DATA_LIST_COUNT	8
     49       1.1  christos #define OTUS_RX_DATA_LIST_COUNT	1
     50       1.1  christos 
     51       1.1  christos #define OTUS_CMD_TIMEOUT	1000
     52       1.1  christos #define OTUS_TX_TIMEOUT		1000
     53       1.1  christos 
     54       1.1  christos #define OTUS_UID(aid)		(IEEE80211_AID(aid) + 4)
     55       1.1  christos 
     56       1.1  christos #define OTUS_MAX_TXCMDSZ	64
     57       1.1  christos #define OTUS_RXBUFSZ		(8 * 1024)
     58       1.1  christos #define OTUS_TXBUFSZ		(4 * 1024)
     59       1.1  christos 
     60       1.1  christos #define OTUS_RIDX_CCK1		 0
     61       1.1  christos #define OTUS_RIDX_OFDM6		 4
     62       1.1  christos #define OTUS_RIDX_OFDM24	 8
     63       1.1  christos #define OTUS_RIDX_MAX		11
     64       1.1  christos static const struct otus_rate {
     65       1.1  christos 	uint8_t	rate;
     66       1.1  christos 	uint8_t	mcs;
     67       1.1  christos } otus_rates[] = {
     68       1.1  christos 	{   2, 0x0 },
     69       1.1  christos 	{   4, 0x1 },
     70       1.1  christos 	{  11, 0x2 },
     71       1.1  christos 	{  22, 0x3 },
     72       1.1  christos 	{  12, 0xb },
     73       1.1  christos 	{  18, 0xf },
     74       1.1  christos 	{  24, 0xa },
     75       1.1  christos 	{  36, 0xe },
     76       1.1  christos 	{  48, 0x9 },
     77       1.1  christos 	{  72, 0xd },
     78       1.1  christos 	{  96, 0x8 },
     79       1.1  christos 	{ 108, 0xc }
     80       1.1  christos };
     81       1.1  christos 
     82       1.1  christos struct otus_rx_radiotap_header {
     83       1.1  christos 	struct ieee80211_radiotap_header wr_ihdr;
     84       1.1  christos 	uint8_t		wr_flags;
     85       1.1  christos 	uint8_t		wr_rate;
     86       1.1  christos 	uint16_t	wr_chan_freq;
     87       1.1  christos 	uint16_t	wr_chan_flags;
     88       1.1  christos 	uint8_t		wr_antsignal;
     89       1.1  christos } __packed;
     90       1.1  christos 
     91       1.1  christos #define OTUS_RX_RADIOTAP_PRESENT			\
     92       1.1  christos 	(1 << IEEE80211_RADIOTAP_FLAGS |		\
     93       1.1  christos 	 1 << IEEE80211_RADIOTAP_RATE |			\
     94       1.1  christos 	 1 << IEEE80211_RADIOTAP_CHANNEL |		\
     95       1.1  christos 	 1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL)
     96       1.1  christos 
     97       1.1  christos struct otus_tx_radiotap_header {
     98       1.1  christos 	struct ieee80211_radiotap_header wt_ihdr;
     99       1.1  christos 	uint8_t		wt_flags;
    100       1.1  christos 	uint8_t		wt_rate;
    101       1.1  christos 	uint16_t	wt_chan_freq;
    102       1.1  christos 	uint16_t	wt_chan_flags;
    103       1.1  christos } __packed;
    104       1.1  christos 
    105       1.1  christos #define OTUS_TX_RADIOTAP_PRESENT			\
    106       1.1  christos 	(1 << IEEE80211_RADIOTAP_FLAGS |		\
    107       1.1  christos 	 1 << IEEE80211_RADIOTAP_RATE |			\
    108       1.1  christos 	 1 << IEEE80211_RADIOTAP_CHANNEL)
    109       1.1  christos 
    110       1.1  christos 
    111       1.1  christos struct otus_softc;
    112       1.1  christos 
    113       1.1  christos struct otus_tx_cmd {
    114       1.1  christos 	usbd_xfer_handle	xfer;
    115       1.1  christos 	uint8_t			*buf;
    116       1.1  christos 	void			*odata;
    117       1.1  christos 	uint16_t		token;
    118       1.1  christos 	uint8_t			done;
    119       1.1  christos };
    120       1.1  christos 
    121       1.1  christos struct otus_rx_data {
    122       1.1  christos 	struct otus_softc	*sc;
    123       1.1  christos 	usbd_xfer_handle	xfer;
    124       1.1  christos 	uint8_t			*buf;
    125       1.1  christos };
    126       1.1  christos 
    127       1.1  christos struct otus_tx_data {
    128  1.1.12.2      yamt 	struct otus_softc		*sc;
    129  1.1.12.2      yamt 	usbd_xfer_handle		xfer;
    130  1.1.12.2      yamt 	uint8_t				*buf;
    131  1.1.12.2      yamt 	TAILQ_ENTRY(otus_tx_data)	next;
    132       1.1  christos };
    133       1.1  christos 
    134       1.1  christos struct otus_host_cmd {
    135       1.1  christos 	void	(*cb)(struct otus_softc *, void *);
    136       1.1  christos 	uint8_t	data[256];
    137       1.1  christos };
    138       1.1  christos 
    139       1.1  christos #define OTUS_HOST_CMD_RING_COUNT	32
    140       1.1  christos struct otus_host_cmd_ring {
    141       1.1  christos 	struct otus_host_cmd	cmd[OTUS_HOST_CMD_RING_COUNT];
    142       1.1  christos 	int			cur;
    143       1.1  christos 	int			next;
    144       1.1  christos 	int			queued;
    145       1.1  christos };
    146       1.1  christos 
    147       1.1  christos struct otus_node {
    148       1.1  christos 	struct ieee80211_node		ni;	/* must be first */
    149       1.1  christos 	struct ieee80211_amrr_node	amn;
    150       1.1  christos 	uint8_t				ridx[IEEE80211_RATE_MAXSIZE];
    151       1.1  christos };
    152       1.1  christos 
    153       1.1  christos struct otus_cmd_newstate {
    154       1.1  christos 	enum ieee80211_state	state;
    155       1.1  christos 	int			arg;
    156       1.1  christos };
    157       1.1  christos 
    158       1.1  christos struct otus_cmd_key {
    159       1.1  christos 	struct ieee80211_key	key;
    160       1.1  christos 	uint16_t		associd;
    161       1.1  christos };
    162       1.1  christos 
    163       1.1  christos struct otus_softc {
    164       1.1  christos 	device_t			sc_dev;
    165       1.1  christos 	struct ieee80211com		sc_ic;
    166       1.1  christos 	struct ethercom			sc_ec;
    167       1.1  christos #define sc_if	sc_ec.ec_if
    168       1.1  christos 	int				(*sc_newstate)(struct ieee80211com *,
    169       1.1  christos 					    enum ieee80211_state, int);
    170       1.1  christos 	void				(*sc_led_newstate)(struct otus_softc *);
    171       1.1  christos 
    172       1.1  christos 	usbd_device_handle		sc_udev;
    173       1.1  christos 	usbd_interface_handle		sc_iface;
    174       1.1  christos 
    175       1.1  christos 	struct ar5416eeprom		sc_eeprom;
    176       1.1  christos 	uint8_t				sc_capflags;
    177       1.1  christos 	uint8_t				sc_rxmask;
    178       1.1  christos 	uint8_t				sc_txmask;
    179       1.1  christos 
    180       1.1  christos 	usbd_pipe_handle		sc_data_tx_pipe;
    181       1.1  christos 	usbd_pipe_handle		sc_data_rx_pipe;
    182       1.1  christos 	usbd_pipe_handle		sc_cmd_tx_pipe;
    183       1.1  christos 	usbd_pipe_handle		sc_cmd_rx_pipe;
    184       1.1  christos 	uint8_t 			*sc_ibuf;
    185       1.1  christos 
    186       1.1  christos 	int				sc_if_flags;
    187       1.1  christos 	int				sc_tx_timer;
    188       1.1  christos 	int				sc_fixed_ridx;
    189       1.1  christos 	int				sc_bb_reset;
    190       1.1  christos 
    191       1.1  christos 	struct ieee80211_channel	*sc_curchan;
    192       1.1  christos 
    193       1.1  christos 	struct usb_task			sc_task;
    194       1.1  christos 	callout_t			sc_scan_to;
    195       1.1  christos 	callout_t			sc_calib_to;
    196       1.1  christos 	struct ieee80211_amrr		sc_amrr;
    197       1.1  christos 
    198       1.1  christos 	unsigned int			sc_write_idx;
    199       1.1  christos 	uint32_t			sc_led_state;
    200       1.1  christos 
    201       1.1  christos 	kmutex_t			sc_cmd_mtx;
    202       1.1  christos 	kmutex_t			sc_task_mtx;
    203       1.1  christos 	kmutex_t			sc_write_mtx;
    204  1.1.12.2      yamt 	kmutex_t			sc_tx_mtx;
    205       1.1  christos 
    206       1.1  christos 	const uint32_t			*sc_phy_vals;
    207       1.1  christos 
    208       1.1  christos 	struct {
    209       1.1  christos 		uint32_t	reg;
    210       1.1  christos 		uint32_t	val;
    211       1.1  christos 	} __packed			sc_write_buf[AR_FW_MAX_WRITES];
    212       1.1  christos 
    213       1.1  christos 	struct otus_host_cmd_ring	sc_cmdq;
    214       1.1  christos 	struct otus_tx_cmd		sc_tx_cmd;
    215       1.1  christos 	struct otus_tx_data		sc_tx_data[OTUS_TX_DATA_LIST_COUNT];
    216  1.1.12.2      yamt 	TAILQ_HEAD(, otus_tx_data)	sc_tx_free_list;
    217       1.1  christos 	struct otus_rx_data		sc_rx_data[OTUS_RX_DATA_LIST_COUNT];
    218       1.1  christos 
    219       1.1  christos 	struct bpf_if *			sc_drvbpf;
    220       1.1  christos 	union {
    221       1.1  christos 		struct otus_rx_radiotap_header th;
    222       1.1  christos 		uint8_t	pad[64];
    223       1.1  christos 	}				sc_rxtapu;
    224       1.1  christos #define sc_rxtap	sc_rxtapu.th
    225       1.1  christos 	int				sc_rxtap_len;
    226       1.1  christos 	union {
    227       1.1  christos 		struct otus_tx_radiotap_header th;
    228       1.1  christos 		uint8_t	pad[64];
    229       1.1  christos 	}				sc_txtapu;
    230       1.1  christos #define sc_txtap	sc_txtapu.th
    231       1.1  christos 	int				sc_txtap_len;
    232  1.1.12.2      yamt 
    233  1.1.12.2      yamt 	uint8_t				sc_rx_error_msk;
    234  1.1.12.2      yamt 	int				sc_dying;
    235       1.1  christos };
    236  1.1.12.1      yamt 
    237  1.1.12.1      yamt #endif /* _IF_OTUSVAR_H_ */
    238