if_runvar.h revision 203134
1203134Sthompsa/* $OpenBSD: if_runvar.h,v 1.3 2009/03/26 20:17:27 damien Exp $ */ 2203134Sthompsa 3203134Sthompsa/*- 4203134Sthompsa * Copyright (c) 2008,2009 Damien Bergamini <damien.bergamini@free.fr> 5203134Sthompsa * ported to FreeBSD by Akinori Furukoshi <moonlightakkiy@yahoo.ca> 6203134Sthompsa * 7203134Sthompsa * Permission to use, copy, modify, and distribute this software for any 8203134Sthompsa * purpose with or without fee is hereby granted, provided that the above 9203134Sthompsa * copyright notice and this permission notice appear in all copies. 10203134Sthompsa * 11203134Sthompsa * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12203134Sthompsa * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13203134Sthompsa * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14203134Sthompsa * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15203134Sthompsa * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16203134Sthompsa * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17203134Sthompsa * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18203134Sthompsa * 19203134Sthompsa * $FreeBSD: head/sys/dev/usb/wlan/if_runvar.h 203134 2010-01-28 22:24:54Z thompsa $ 20203134Sthompsa */ 21203134Sthompsa 22203134Sthompsa#ifndef _IF_RUNVAR_H_ 23203134Sthompsa#define _IF_RUNVAR_H_ 24203134Sthompsa 25203134Sthompsa#define RUN_MAX_RXSZ \ 26203134Sthompsa MIN(4096, MJUMPAGESIZE) 27203134Sthompsa#if 0 28203134Sthompsa (sizeof (uint32_t) + \ 29203134Sthompsa sizeof (struct rt2860_rxwi) + \ 30203134Sthompsa sizeof (uint16_t) + \ 31203134Sthompsa MCLBYTES + \ 32203134Sthompsa sizeof (struct rt2870_rxd)) 33203134Sthompsa#endif 34203134Sthompsa/* NB: "11" is the maximum number of padding bytes needed for Tx */ 35203134Sthompsa#define RUN_MAX_TXSZ \ 36203134Sthompsa (sizeof (struct rt2870_txd) + \ 37203134Sthompsa sizeof (struct rt2860_rxwi) + \ 38203134Sthompsa MCLBYTES + 11) 39203134Sthompsa 40203134Sthompsa#define RUN_TX_TIMEOUT 5000 /* ms */ 41203134Sthompsa 42203134Sthompsa/* Tx ring count was 8/endpoint, now 32 for all 4 (or 6) endpoints. */ 43203134Sthompsa#define RUN_TX_RING_COUNT 32 44203134Sthompsa#define RUN_RX_RING_COUNT 1 45203134Sthompsa 46203134Sthompsa#define RT2870_WCID_MAX 253 47203134Sthompsa#define RUN_AID2WCID(aid) ((aid) & 0xff) 48203134Sthompsa 49203134Sthompsastruct run_rx_radiotap_header { 50203134Sthompsa struct ieee80211_radiotap_header wr_ihdr; 51203134Sthompsa uint8_t wr_flags; 52203134Sthompsa uint8_t wr_rate; 53203134Sthompsa uint16_t wr_chan_freq; 54203134Sthompsa uint16_t wr_chan_flags; 55203134Sthompsa uint8_t wr_dbm_antsignal; 56203134Sthompsa uint8_t wr_antenna; 57203134Sthompsa uint8_t wr_antsignal; 58203134Sthompsa} __packed; 59203134Sthompsa 60203134Sthompsa#define RUN_RX_RADIOTAP_PRESENT \ 61203134Sthompsa (1 << IEEE80211_RADIOTAP_FLAGS | \ 62203134Sthompsa 1 << IEEE80211_RADIOTAP_RATE | \ 63203134Sthompsa 1 << IEEE80211_RADIOTAP_CHANNEL | \ 64203134Sthompsa 1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL | \ 65203134Sthompsa 1 << IEEE80211_RADIOTAP_ANTENNA | \ 66203134Sthompsa 1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) 67203134Sthompsa 68203134Sthompsastruct run_tx_radiotap_header { 69203134Sthompsa struct ieee80211_radiotap_header wt_ihdr; 70203134Sthompsa uint8_t wt_flags; 71203134Sthompsa uint8_t wt_rate; 72203134Sthompsa uint16_t wt_chan_freq; 73203134Sthompsa uint16_t wt_chan_flags; 74203134Sthompsa uint8_t wt_hwqueue; 75203134Sthompsa} __packed; 76203134Sthompsa 77203134Sthompsa#define IEEE80211_RADIOTAP_HWQUEUE 15 78203134Sthompsa 79203134Sthompsa#define RUN_TX_RADIOTAP_PRESENT \ 80203134Sthompsa (1 << IEEE80211_RADIOTAP_FLAGS | \ 81203134Sthompsa 1 << IEEE80211_RADIOTAP_RATE | \ 82203134Sthompsa 1 << IEEE80211_RADIOTAP_CHANNEL | \ 83203134Sthompsa 1 << IEEE80211_RADIOTAP_HWQUEUE) 84203134Sthompsa 85203134Sthompsastruct run_softc; 86203134Sthompsa 87203134Sthompsastruct run_tx_data { 88203134Sthompsa STAILQ_ENTRY(run_tx_data) next; 89203134Sthompsa struct run_softc *sc; 90203134Sthompsa struct mbuf *m; 91203134Sthompsa struct ieee80211_node *ni; 92203134Sthompsa uint32_t align[0]; /* dummy field */ 93203134Sthompsa uint8_t desc[sizeof(struct rt2870_txd) + 94203134Sthompsa sizeof(struct rt2860_txwi)]; 95203134Sthompsa int ridx; 96203134Sthompsa uint8_t mcs; 97203134Sthompsa}; 98203134SthompsaSTAILQ_HEAD(run_tx_data_head, run_tx_data); 99203134Sthompsa 100203134Sthompsastruct run_node { 101203134Sthompsa struct ieee80211_node ni; 102203134Sthompsa uint8_t ridx[IEEE80211_RATE_MAXSIZE]; 103203134Sthompsa uint8_t ctl_ridx[IEEE80211_RATE_MAXSIZE]; 104203134Sthompsa}; 105203134Sthompsa 106203134Sthompsastruct run_vap { 107203134Sthompsa struct ieee80211vap vap; 108203134Sthompsa struct ieee80211_beacon_offsets bo; 109203134Sthompsa struct ieee80211_amrr amrr; 110203134Sthompsa struct ieee80211_amrr_node amn[RT2870_WCID_MAX + 1]; 111203134Sthompsa struct usb_callout amrr_ch; 112203134Sthompsa struct task amrr_task; 113203134Sthompsa uint8_t amrr_run; 114203134Sthompsa#define RUN_AMRR_ON 1 115203134Sthompsa#define RUN_AMRR_OFF 0 116203134Sthompsa 117203134Sthompsa int (*newstate)(struct ieee80211vap *, 118203134Sthompsa enum ieee80211_state, int); 119203134Sthompsa}; 120203134Sthompsa#define RUN_VAP(vap) ((struct run_vap *)(vap)) 121203134Sthompsa 122203134Sthompsa/* 123203134Sthompsa * There are 7 bulk endpoints: 1 for RX 124203134Sthompsa * and 6 for TX (4 EDCAs + HCCA + Prio). 125203134Sthompsa * Update 03-14-2009: some devices like the Planex GW-US300MiniS 126203134Sthompsa * seem to have only 4 TX bulk endpoints (Fukaumi Naoki). 127203134Sthompsa */ 128203134Sthompsaenum { 129203134Sthompsa RUN_BULK_TX_BE, /* = WME_AC_BE */ 130203134Sthompsa RUN_BULK_TX_BK, /* = WME_AC_BK */ 131203134Sthompsa RUN_BULK_TX_VI, /* = WME_AC_VI */ 132203134Sthompsa RUN_BULK_TX_VO, /* = WME_AC_VO */ 133203134Sthompsa RUN_BULK_TX_HCCA, 134203134Sthompsa RUN_BULK_TX_PRIO, 135203134Sthompsa RUN_BULK_RX, 136203134Sthompsa RUN_N_XFER, 137203134Sthompsa}; 138203134Sthompsa 139203134Sthompsa#define RUN_EP_QUEUES RUN_BULK_RX 140203134Sthompsa 141203134Sthompsastruct run_endpoint_queue { 142203134Sthompsa struct run_tx_data tx_data[RUN_TX_RING_COUNT]; 143203134Sthompsa struct run_tx_data_head tx_qh; 144203134Sthompsa struct run_tx_data_head tx_fh; 145203134Sthompsa uint32_t tx_nfree; 146203134Sthompsa}; 147203134Sthompsa 148203134Sthompsastruct run_softc { 149203134Sthompsa device_t sc_dev; 150203134Sthompsa struct usb_device *sc_udev; 151203134Sthompsa struct ifnet *sc_ifp; 152203134Sthompsa struct run_vap *sc_rvp; 153203134Sthompsa 154203134Sthompsa int (*sc_srom_read)(struct run_softc *, 155203134Sthompsa uint16_t, uint16_t *); 156203134Sthompsa 157203134Sthompsa const struct firmware *fwp; 158203134Sthompsa 159203134Sthompsa uint32_t mac_rev; 160203134Sthompsa uint8_t rf_rev; 161203134Sthompsa uint8_t freq; 162203134Sthompsa uint8_t ntxchains; 163203134Sthompsa uint8_t nrxchains; 164203134Sthompsa int fixed_ridx; 165203134Sthompsa 166203134Sthompsa uint8_t rf24_20mhz; 167203134Sthompsa uint8_t rf24_40mhz; 168203134Sthompsa uint8_t ext_2ghz_lna; 169203134Sthompsa uint8_t ext_5ghz_lna; 170203134Sthompsa uint8_t calib_2ghz; 171203134Sthompsa uint8_t calib_5ghz; 172203134Sthompsa int8_t txpow1[50]; 173203134Sthompsa int8_t txpow2[50]; 174203134Sthompsa int8_t rssi_2ghz[3]; 175203134Sthompsa int8_t rssi_5ghz[3]; 176203134Sthompsa uint8_t lna[4]; 177203134Sthompsa 178203134Sthompsa struct { 179203134Sthompsa uint8_t reg; 180203134Sthompsa uint8_t val; 181203134Sthompsa } bbp[8]; 182203134Sthompsa uint8_t leds; 183203134Sthompsa uint16_t led[3]; 184203134Sthompsa uint32_t txpow20mhz[5]; 185203134Sthompsa uint32_t txpow40mhz_2ghz[5]; 186203134Sthompsa uint32_t txpow40mhz_5ghz[5]; 187203134Sthompsa 188203134Sthompsa uint8_t sc_bssid[6]; 189203134Sthompsa 190203134Sthompsa struct mtx sc_mtx; 191203134Sthompsa 192203134Sthompsa struct run_endpoint_queue sc_epq[RUN_EP_QUEUES]; 193203134Sthompsa 194203134Sthompsa struct task wme_task; 195203134Sthompsa struct task usb_timeout_task; 196203134Sthompsa 197203134Sthompsa struct usb_xfer *sc_xfer[RUN_N_XFER]; 198203134Sthompsa 199203134Sthompsa struct mbuf *rx_m; 200203134Sthompsa 201203134Sthompsa int sifs; 202203134Sthompsa 203203134Sthompsa union { 204203134Sthompsa struct run_rx_radiotap_header th; 205203134Sthompsa uint8_t pad[64]; 206203134Sthompsa } sc_rxtapu; 207203134Sthompsa#define sc_rxtap sc_rxtapu.th 208203134Sthompsa int sc_rxtap_len; 209203134Sthompsa 210203134Sthompsa union { 211203134Sthompsa struct run_tx_radiotap_header th; 212203134Sthompsa uint8_t pad[64]; 213203134Sthompsa } sc_txtapu; 214203134Sthompsa#define sc_txtap sc_txtapu.th 215203134Sthompsa int sc_txtap_len; 216203134Sthompsa}; 217203134Sthompsa 218203134Sthompsa#define RUN_LOCK(sc) mtx_lock(&(sc)->sc_mtx) 219203134Sthompsa#define RUN_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) 220203134Sthompsa#define RUN_LOCK_ASSERT(sc, t) mtx_assert(&(sc)->sc_mtx, t) 221203134Sthompsa 222203134Sthompsa#endif /* _IF_RUNVAR_H_ */ 223