1/* $NetBSD: if_urtwnvar.h,v 1.1 2012/03/25 00:11:16 nonaka Exp $ */ 2/* $OpenBSD: if_urtwnreg.h,v 1.3 2010/11/16 18:02:59 damien Exp $ */ 3 4/*- 5 * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20/* 21 * Driver definitions. 22 */ 23#define URTWN_RX_LIST_COUNT 1 24#define URTWN_TX_LIST_COUNT 8 25#define URTWN_HOST_CMD_RING_COUNT 32 26 27#define URTWN_RXBUFSZ (16 * 1024) 28#define URTWN_TXBUFSZ (sizeof(struct r92c_tx_desc) + IEEE80211_MAX_LEN + 8) 29 30#define URTWN_RIDX_COUNT 28 31 32#define URTWN_TX_TIMEOUT 5000 /* ms */ 33 34#define URTWN_LED_LINK 0 35#define URTWN_LED_DATA 1 36 37struct urtwn_rx_radiotap_header { 38 struct ieee80211_radiotap_header wr_ihdr; 39 uint8_t wr_flags; 40 uint8_t wr_rate; 41 uint16_t wr_chan_freq; 42 uint16_t wr_chan_flags; 43 uint8_t wr_dbm_antsignal; 44} __packed; 45 46#define URTWN_RX_RADIOTAP_PRESENT \ 47 (1 << IEEE80211_RADIOTAP_FLAGS | \ 48 1 << IEEE80211_RADIOTAP_RATE | \ 49 1 << IEEE80211_RADIOTAP_CHANNEL | \ 50 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) 51 52struct urtwn_tx_radiotap_header { 53 struct ieee80211_radiotap_header wt_ihdr; 54 uint8_t wt_flags; 55 uint16_t wt_chan_freq; 56 uint16_t wt_chan_flags; 57} __packed; 58 59#define URTWN_TX_RADIOTAP_PRESENT \ 60 (1 << IEEE80211_RADIOTAP_FLAGS | \ 61 1 << IEEE80211_RADIOTAP_CHANNEL) 62 63struct urtwn_softc; 64 65struct urtwn_rx_data { 66 struct urtwn_softc *sc; 67 usbd_xfer_handle xfer; 68 uint8_t *buf; 69}; 70 71struct urtwn_tx_data { 72 struct urtwn_softc *sc; 73 usbd_pipe_handle pipe; 74 usbd_xfer_handle xfer; 75 uint8_t *buf; 76 TAILQ_ENTRY(urtwn_tx_data) next; 77}; 78 79struct urtwn_host_cmd { 80 void (*cb)(struct urtwn_softc *, void *); 81 uint8_t data[256]; 82}; 83 84struct urtwn_cmd_newstate { 85 enum ieee80211_state state; 86 int arg; 87}; 88 89struct urtwn_host_cmd_ring { 90 struct urtwn_host_cmd cmd[URTWN_HOST_CMD_RING_COUNT]; 91 int cur; 92 int next; 93 int queued; 94}; 95 96#if 1 /* XXX: sys/net80211/ieee80211.h */ 97#define IEEE80211_QOS_ACKPOLICY_BA 0x60 /* Block ACK */ 98 99#define IEEE80211_HTINFO_2NDCHAN 0x03 /* secondary/ext chan offset */ 100#define IEEE80211_HTINFO_2NDCHAN_S 0 101#define IEEE80211_HTINFO_2NDCHAN_NONE 0x00 /* no secondary/ext channel */ 102#define IEEE80211_HTINFO_2NDCHAN_ABOVE 0x01 /* above private channel */ 103/* NB: 2 is reserved */ 104#define IEEE80211_HTINFO_2NDCHAN_BELOW 0x03 /* below primary channel */ 105#endif /* XXX: 1 */ 106 107struct urtwn_softc { 108 device_t sc_dev; 109 struct ieee80211com sc_ic; 110 struct ethercom sc_ec; 111#define sc_if sc_ec.ec_if 112 int (*sc_newstate)(struct ieee80211com *, 113 enum ieee80211_state, int); 114 115 usbd_device_handle sc_udev; 116 usbd_interface_handle sc_iface; 117 u_int sc_flags; 118#define URTWN_FLAG_CCK_HIPWR __BIT(0) 119#define URTWN_FLAG_ATTACHED __BIT(1) 120#define URTWN_FLAG_FWREADY __BIT(2) 121 int sc_dying; 122 123 struct usb_task sc_task; 124 callout_t sc_scan_to; 125 callout_t sc_calib_to; 126 127 kmutex_t sc_task_mtx; 128 kmutex_t sc_fwcmd_mtx; 129 kmutex_t sc_tx_mtx; 130 131 usbd_pipe_handle rx_pipe; 132 int rx_npipe; 133 usbd_pipe_handle tx_pipe[R92C_MAX_EPOUT]; 134 int tx_npipe; 135 int ac2idx[WME_NUM_AC]; 136 137 u_int chip; 138#define URTWN_CHIP_92C 0x01 139#define URTWN_CHIP_92C_1T2R 0x02 140#define URTWN_CHIP_UMC 0x04 141#define URTWN_CHIP_UMC_A_CUT 0x08 142 143 uint8_t board_type; 144 uint8_t regulatory; 145 uint8_t pa_setting; 146 int avg_pwdb; 147 int thcal_state; 148 int thcal_lctemp; 149 int ntxchains; 150 int nrxchains; 151 int ledlink; 152 bool iqk_inited; 153 154 int tx_timer; 155 156 struct urtwn_host_cmd_ring cmdq; 157 int fwcur; 158 struct urtwn_rx_data rx_data[URTWN_RX_LIST_COUNT]; 159 struct urtwn_tx_data tx_data[URTWN_TX_LIST_COUNT]; 160 TAILQ_HEAD(, urtwn_tx_data) tx_free_list; 161 162 struct r92c_rom rom; 163 164 uint32_t rf_chnlbw[R92C_MAX_CHAINS]; 165 166 struct bpf_if * sc_drvbpf; 167 union { 168 struct urtwn_rx_radiotap_header th; 169 uint8_t pad[64]; 170 } sc_rxtapu; 171#define sc_rxtap sc_rxtapu.th 172 int sc_rxtap_len; 173 union { 174 struct urtwn_tx_radiotap_header th; 175 uint8_t pad[64]; 176 } sc_txtapu; 177#define sc_txtap sc_txtapu.th 178 int sc_txtap_len; 179}; 180