1 /* $NetBSD: if_urtwnvar.h,v 1.7 2013/10/15 15:13:18 skrll 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 #ifndef _IF_URTWNVAR_H_ 20 #define _IF_URTWNVAR_H_ 21 22 /* 23 * Driver definitions. 24 */ 25 #define URTWN_RX_LIST_COUNT 1 26 #define URTWN_TX_LIST_COUNT 8 27 28 #define URTWN_HOST_CMD_RING_COUNT 32 29 30 #define URTWN_RXBUFSZ (16 * 1024) 31 #define URTWN_TXBUFSZ (sizeof(struct r92c_tx_desc) + IEEE80211_MAX_LEN + 8) 32 33 #define URTWN_RIDX_COUNT 28 34 35 #define URTWN_TX_TIMEOUT 5000 /* ms */ 36 37 #define URTWN_LED_LINK 0 38 #define URTWN_LED_DATA 1 39 40 struct urtwn_rx_radiotap_header { 41 struct ieee80211_radiotap_header wr_ihdr; 42 uint8_t wr_flags; 43 uint8_t wr_rate; 44 uint16_t wr_chan_freq; 45 uint16_t wr_chan_flags; 46 uint8_t wr_dbm_antsignal; 47 } __packed; 48 49 #define URTWN_RX_RADIOTAP_PRESENT \ 50 (1 << IEEE80211_RADIOTAP_FLAGS | \ 51 1 << IEEE80211_RADIOTAP_RATE | \ 52 1 << IEEE80211_RADIOTAP_CHANNEL | \ 53 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) 54 55 struct urtwn_tx_radiotap_header { 56 struct ieee80211_radiotap_header wt_ihdr; 57 uint8_t wt_flags; 58 uint16_t wt_chan_freq; 59 uint16_t wt_chan_flags; 60 } __packed; 61 62 #define URTWN_TX_RADIOTAP_PRESENT \ 63 (1 << IEEE80211_RADIOTAP_FLAGS | \ 64 1 << IEEE80211_RADIOTAP_CHANNEL) 65 66 struct urtwn_softc; 67 68 struct urtwn_rx_data { 69 struct urtwn_softc *sc; 70 usbd_xfer_handle xfer; 71 uint8_t *buf; 72 }; 73 74 struct urtwn_tx_data { 75 struct urtwn_softc *sc; 76 usbd_pipe_handle pipe; 77 usbd_xfer_handle xfer; 78 uint8_t *buf; 79 TAILQ_ENTRY(urtwn_tx_data) next; 80 }; 81 82 struct urtwn_host_cmd { 83 void (*cb)(struct urtwn_softc *, void *); 84 uint8_t data[256]; 85 }; 86 87 struct urtwn_cmd_newstate { 88 enum ieee80211_state state; 89 int arg; 90 }; 91 92 struct urtwn_host_cmd_ring { 93 struct urtwn_host_cmd cmd[URTWN_HOST_CMD_RING_COUNT]; 94 int cur; 95 int next; 96 int queued; 97 }; 98 99 #if 1 /* XXX: sys/net80211/ieee80211.h */ 100 101 #define IEEE80211_HTINFO_2NDCHAN 0x03 /* secondary/ext chan offset */ 102 #define IEEE80211_HTINFO_2NDCHAN_S 0 103 #define IEEE80211_HTINFO_2NDCHAN_NONE 0x00 /* no secondary/ext channel */ 104 #define IEEE80211_HTINFO_2NDCHAN_ABOVE 0x01 /* above private channel */ 105 /* NB: 2 is reserved */ 106 #define IEEE80211_HTINFO_2NDCHAN_BELOW 0x03 /* below primary channel */ 107 #endif /* XXX: 1 */ 108 109 struct urtwn_softc { 110 device_t sc_dev; 111 struct ieee80211com sc_ic; 112 struct ethercom sc_ec; 113 #define sc_if sc_ec.ec_if 114 int (*sc_newstate)(struct ieee80211com *, 115 enum ieee80211_state, int); 116 117 usbd_device_handle sc_udev; 118 usbd_interface_handle sc_iface; 119 u_int sc_flags; 120 #define URTWN_FLAG_CCK_HIPWR __BIT(0) 121 #define URTWN_FLAG_ATTACHED __BIT(1) 122 #define URTWN_FLAG_FWREADY __BIT(2) 123 int sc_dying; 124 125 struct usb_task sc_task; 126 callout_t sc_scan_to; 127 callout_t sc_calib_to; 128 129 kmutex_t sc_task_mtx; 130 kmutex_t sc_fwcmd_mtx; 131 kmutex_t sc_tx_mtx; 132 kmutex_t sc_write_mtx; 133 134 usbd_pipe_handle rx_pipe; 135 int rx_npipe; 136 usbd_pipe_handle tx_pipe[R92C_MAX_EPOUT]; 137 int tx_npipe; 138 int ac2idx[WME_NUM_AC]; 139 140 u_int chip; 141 #define URTWN_CHIP_92C 0x01 142 #define URTWN_CHIP_92C_1T2R 0x02 143 #define URTWN_CHIP_UMC 0x04 144 #define URTWN_CHIP_UMC_A_CUT 0x08 145 146 uint8_t board_type; 147 uint8_t regulatory; 148 uint8_t pa_setting; 149 int avg_pwdb; 150 int thcal_state; 151 int thcal_lctemp; 152 size_t ntxchains; 153 size_t nrxchains; 154 int ledlink; 155 bool iqk_inited; 156 157 int tx_timer; 158 159 struct urtwn_host_cmd_ring cmdq; 160 int fwcur; 161 struct urtwn_rx_data rx_data[URTWN_RX_LIST_COUNT]; 162 struct urtwn_tx_data tx_data[URTWN_TX_LIST_COUNT]; 163 TAILQ_HEAD(, urtwn_tx_data) tx_free_list; 164 165 struct r92c_rom rom; 166 167 uint32_t rf_chnlbw[R92C_MAX_CHAINS]; 168 169 struct bpf_if * sc_drvbpf; 170 union { 171 struct urtwn_rx_radiotap_header th; 172 uint8_t pad[64]; 173 } sc_rxtapu; 174 #define sc_rxtap sc_rxtapu.th 175 int sc_rxtap_len; 176 union { 177 struct urtwn_tx_radiotap_header th; 178 uint8_t pad[64]; 179 } sc_txtapu; 180 #define sc_txtap sc_txtapu.th 181 int sc_txtap_len; 182 }; 183 184 #endif /* _IF_URTWNVAR_H_ */ 185