34#include <sys/sockio.h>
35#include <sys/sysctl.h>
39#include <sys/kernel.h>
40#include <sys/socket.h>
42#include <sys/malloc.h>
43#include <sys/module.h>
45#include <sys/endian.h>
50#include <net/if_var.h>
51#include <net/if_arp.h>
52#include <net/ethernet.h>
54#include <net/if_media.h>
55#include <net/if_types.h>
58#include <netinet/in.h>
59#include <netinet/in_systm.h>
60#include <netinet/in_var.h>
61#include <netinet/if_ether.h>
62#include <netinet/ip.h>
65#include <net80211/ieee80211_var.h>
66#include <net80211/ieee80211_regdomain.h>
67#include <net80211/ieee80211_radiotap.h>
68#include <net80211/ieee80211_ratectl.h>
74#define USB_DEBUG_VAR ural_debug
81static int ural_debug = 0;
83static SYSCTL_NODE(_hw_usb, OID_AUTO, ural, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
89#define URAL_RSSI(rssi) \
90 ((rssi) > (RAL_NOISE_FLOOR + RAL_RSSI_CORR) ? \
91 ((rssi) - (RAL_NOISE_FLOOR + RAL_RSSI_CORR)) : 0)
95#define URAL_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) }
134 const char [IFNAMSIZ],
int,
enum ieee80211_opmode,
135 int,
const uint8_t [IEEE80211_ADDR_LEN],
136 const uint8_t [IEEE80211_ADDR_LEN]);
142 enum ieee80211_state,
int);
146 struct ieee80211_node *);
148 struct ieee80211_node *);
150 struct ieee80211_node *);
151static int ural_transmit(
struct ieee80211com *,
struct mbuf *);
169 struct ieee80211_channel[]);
172 struct ieee80211_channel *);
179 const struct ieee80211_channel *);
191static int ural_raw_xmit(
struct ieee80211_node *,
struct mbuf *,
192 const struct ieee80211_bpf_params *);
194 struct ieee80211_node *);
270 0x307f6, 0x307fb, 0x30800, 0x30805, 0x3080a, 0x3080f, 0x30814,
271 0x30819, 0x3081e, 0x30823, 0x30828, 0x3082d, 0x30832, 0x3083e
275 0x00327, 0x00328, 0x00329, 0x0032a, 0x0032b, 0x0032c, 0x0032d,
276 0x0032e, 0x0032f, 0x00340, 0x00341, 0x00342, 0x00343, 0x00346
280 0x00327, 0x00328, 0x00329, 0x0032a, 0x0032b, 0x0032c, 0x0032d,
281 0x0032e, 0x0032f, 0x00340, 0x00341, 0x00342, 0x00343, 0x00346
285 0x20327, 0x20328, 0x20329, 0x2032a, 0x2032b, 0x2032c, 0x2032d,
286 0x2032e, 0x2032f, 0x20340, 0x20341, 0x20342, 0x20343, 0x20346
290 0x2032f, 0x20340, 0x20341, 0x20342, 0x20343, 0x20344, 0x20345,
291 0x20346, 0x20347, 0x20348, 0x20349, 0x2034a, 0x2034b, 0x2034e
295 0x2044d, 0x2044e, 0x2044f, 0x20460, 0x20461, 0x20462, 0x20463,
296 0x20464, 0x20465, 0x20466, 0x20467, 0x20468, 0x20469, 0x2046b
300 0x0022a, 0x0022b, 0x0022b, 0x0022c, 0x0022c, 0x0022d, 0x0022d,
301 0x0022e, 0x0022e, 0x0022f, 0x0022d, 0x00240, 0x00240, 0x00241
305 0x00226, 0x00227, 0x00227, 0x00228, 0x00228, 0x00229, 0x00229,
306 0x0022a, 0x0022a, 0x0022b, 0x0022b, 0x0022c, 0x0022c, 0x0022d
319 { 1, 0x08808, 0x0044d, 0x00282 },
320 { 2, 0x08808, 0x0044e, 0x00282 },
321 { 3, 0x08808, 0x0044f, 0x00282 },
322 { 4, 0x08808, 0x00460, 0x00282 },
323 { 5, 0x08808, 0x00461, 0x00282 },
324 { 6, 0x08808, 0x00462, 0x00282 },
325 { 7, 0x08808, 0x00463, 0x00282 },
326 { 8, 0x08808, 0x00464, 0x00282 },
327 { 9, 0x08808, 0x00465, 0x00282 },
328 { 10, 0x08808, 0x00466, 0x00282 },
329 { 11, 0x08808, 0x00467, 0x00282 },
330 { 12, 0x08808, 0x00468, 0x00282 },
331 { 13, 0x08808, 0x00469, 0x00282 },
332 { 14, 0x08808, 0x0046b, 0x00286 },
334 { 36, 0x08804, 0x06225, 0x00287 },
335 { 40, 0x08804, 0x06226, 0x00287 },
336 { 44, 0x08804, 0x06227, 0x00287 },
337 { 48, 0x08804, 0x06228, 0x00287 },
338 { 52, 0x08804, 0x06229, 0x00287 },
339 { 56, 0x08804, 0x0622a, 0x00287 },
340 { 60, 0x08804, 0x0622b, 0x00287 },
341 { 64, 0x08804, 0x0622c, 0x00287 },
343 { 100, 0x08804, 0x02200, 0x00283 },
344 { 104, 0x08804, 0x02201, 0x00283 },
345 { 108, 0x08804, 0x02202, 0x00283 },
346 { 112, 0x08804, 0x02203, 0x00283 },
347 { 116, 0x08804, 0x02204, 0x00283 },
348 { 120, 0x08804, 0x02205, 0x00283 },
349 { 124, 0x08804, 0x02206, 0x00283 },
350 { 128, 0x08804, 0x02207, 0x00283 },
351 { 132, 0x08804, 0x02208, 0x00283 },
352 { 136, 0x08804, 0x02209, 0x00283 },
353 { 140, 0x08804, 0x0220a, 0x00283 },
355 { 149, 0x08808, 0x02429, 0x00281 },
356 { 153, 0x08808, 0x0242b, 0x00281 },
357 { 157, 0x08808, 0x0242d, 0x00281 },
358 { 161, 0x08808, 0x0242f, 0x00281 }
362 { 36, 40, 44, 48, 52, 56, 60, 64,
363 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
364 149, 153, 157, 161 };
431 struct ural_softc *sc = device_get_softc(self);
432 struct ieee80211com *ic = &sc->
sc_ic;
440 mtx_init(&sc->
sc_mtx, device_get_nameunit(self),
441 MTX_NETWORK_LOCK, MTX_DEF);
442 mbufq_init(&sc->
sc_snd, ifqmaxlen);
449 device_printf(self,
"could not allocate USB transfers, "
462 device_printf(self,
"MAC/BBP RT2570 (rev 0x%02x), RF %s\n",
466 ic->ic_name = device_get_nameunit(self);
467 ic->ic_phytype = IEEE80211_T_OFDM;
473 | IEEE80211_C_MONITOR
476 | IEEE80211_C_SHPREAMBLE
485 ieee80211_ifattach(ic);
497 ieee80211_radiotap_attach(ic,
504 ieee80211_announce(ic);
516 struct ural_softc *sc = device_get_softc(self);
517 struct ieee80211com *ic = &sc->
sc_ic;
532 if (ic->ic_softc == sc)
533 ieee80211_ifdetach(ic);
553 DPRINTFN(1,
"Control request failed, %s (retrying)\n",
561static struct ieee80211vap *
563 enum ieee80211_opmode opmode,
int flags,
564 const uint8_t bssid[IEEE80211_ADDR_LEN],
565 const uint8_t mac[IEEE80211_ADDR_LEN])
569 struct ieee80211vap *vap;
571 if (!TAILQ_EMPTY(&ic->ic_vaps))
573 uvp = malloc(
sizeof(
struct ural_vap), M_80211_VAP, M_WAITOK | M_ZERO);
577 if (ieee80211_vap_setup(ic, vap,
name, unit, opmode,
578 flags | IEEE80211_CLONE_NOBEACONS, bssid) != 0) {
580 free(uvp, M_80211_VAP);
590 ieee80211_ratectl_init(vap);
591 ieee80211_ratectl_setinterval(vap, 1000 );
594 ieee80211_vap_attach(vap, ieee80211_media_change,
595 ieee80211_media_status, mac);
596 ic->ic_opmode = opmode;
604 struct ieee80211com *ic = vap->iv_ic;
608 ieee80211_ratectl_deinit(vap);
609 ieee80211_vap_detach(vap);
610 free(uvp, M_80211_VAP);
618 if (
data->m != NULL) {
619 ieee80211_tx_complete(
data->ni,
data->m, txerr);
661 if (
data->m != NULL) {
665 if (
data->ni != NULL) {
666 ieee80211_free_node(
data->ni);
673ural_newstate(
struct ieee80211vap *vap,
enum ieee80211_state nstate,
int arg)
676 struct ieee80211com *ic = vap->iv_ic;
678 const struct ieee80211_txparam *tp;
679 struct ieee80211_node *ni;
683 ieee80211_state_name[vap->iv_state],
684 ieee80211_state_name[nstate]);
686 IEEE80211_UNLOCK(ic);
691 case IEEE80211_S_INIT:
692 if (vap->iv_state == IEEE80211_S_RUN) {
701 case IEEE80211_S_RUN:
702 ni = ieee80211_ref_node(vap->iv_bss);
704 if (vap->iv_opmode != IEEE80211_M_MONITOR) {
705 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC)
711 IEEE80211_ADDR_COPY(sc->
sc_bssid, ni->ni_bssid);
715 if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
716 vap->iv_opmode == IEEE80211_M_IBSS) {
717 m = ieee80211_beacon_alloc(ni);
720 "could not allocate beacon\n");
723 ieee80211_ref_node(ni);
726 "could not send beacon\n");
734 if (vap->iv_opmode != IEEE80211_M_MONITOR)
741 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)];
742 if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE)
744 ieee80211_free_node(ni);
752 return (uvp->
newstate(vap, nstate, arg));
757 ieee80211_free_node(ni);
765 struct ieee80211vap *vap;
775 DPRINTFN(11,
"transfer complete, %d bytes\n",
len);
787 STAILQ_REMOVE_HEAD(&sc->
tx_q,
next);
791 DPRINTFN(0,
"data overflow, %u bytes\n",
800 vap =
data->ni->ni_vap;
801 if (ieee80211_radiotap_active_vap(vap)) {
808 ieee80211_radiotap_tx(vap, m);
816 DPRINTFN(11,
"sending frame len=%u xferlen=%u\n",
817 m->m_pkthdr.len,
len);
828 DPRINTFN(11,
"transfer error, %s\n",
843 device_printf(sc->
sc_dev,
"device timeout\n");
852 struct ieee80211com *ic = &sc->
sc_ic;
853 struct ieee80211_node *ni;
854 struct epoch_tracker et;
855 struct mbuf *m = NULL;
858 int8_t rssi = 0, nf = 0;
866 DPRINTFN(15,
"rx done, actlen=%d\n",
len);
869 DPRINTF(
"%s: xfer too short %d\n",
871 counter_u64_add(ic->ic_ierrors, 1);
889 DPRINTFN(5,
"PHY or CRC error\n");
890 counter_u64_add(ic->ic_ierrors, 1);
894 m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
896 DPRINTF(
"could not allocate mbuf\n");
897 counter_u64_add(ic->ic_ierrors, 1);
903 m->m_pkthdr.len = m->m_len = (flags >> 16) & 0xfff;
905 if (ieee80211_radiotap_active(ic)) {
912 IEEE80211_T_OFDM : IEEE80211_T_CCK);
918 m_adj(m, -IEEE80211_CRC_LEN);
933 ni = ieee80211_find_rxnode(ic,
934 mtod(m,
struct ieee80211_frame_min *));
937 (void) ieee80211_input(ni, m, rssi, nf);
938 ieee80211_free_node(ni);
940 (
void) ieee80211_input_all(ic, m, rssi, nf);
969 case 108:
return 0xc;
982 uint32_t flags,
int len,
int rate)
984 struct ieee80211com *ic = &sc->
sc_ic;
985 uint16_t plcp_length;
988 desc->flags = htole32(flags);
990 desc->flags |= htole32(
len << 16);
997 desc->plcp_service = 4;
999 len += IEEE80211_CRC_LEN;
1000 if (ieee80211_rate2phytype(ic->ic_rt, rate) == IEEE80211_T_OFDM) {
1003 plcp_length =
len & 0xfff;
1004 desc->plcp_length_hi = plcp_length >> 6;
1005 desc->plcp_length_lo = plcp_length & 0x3f;
1009 plcp_length = howmany(16 *
len, rate);
1015 desc->plcp_length_hi = plcp_length >> 8;
1016 desc->plcp_length_lo = plcp_length & 0xff;
1018 if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
1019 desc->plcp_signal |= 0x08;
1026#define RAL_TX_TIMEOUT 5000
1031 struct ieee80211vap *vap = ni->ni_vap;
1032 struct ieee80211com *ic = ni->ni_ic;
1033 const struct ieee80211_txparam *tp;
1038 ieee80211_free_node(
ni);
1041 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) {
1043 ieee80211_free_node(
ni);
1049 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_bsschan)];
1053 data->rate = tp->mgmtrate;
1059 DPRINTFN(10,
"sending beacon frame len=%u rate=%u\n",
1060 m0->m_pkthdr.len, tp->mgmtrate);
1071 const struct ieee80211_txparam *tp = ni->ni_txparms;
1072 struct ieee80211com *ic = ni->ni_ic;
1074 struct ieee80211_frame *wh;
1075 struct ieee80211_key *
k;
1085 wh = mtod(m0,
struct ieee80211_frame *);
1086 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
1087 k = ieee80211_crypto_encap(ni, m0);
1092 wh = mtod(m0,
struct ieee80211_frame *);
1097 data->rate = tp->mgmtrate;
1100 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
1103 dur = ieee80211_ack_duration(ic->ic_rt, tp->mgmtrate,
1104 ic->ic_flags & IEEE80211_F_SHPREAMBLE);
1105 USETW(wh->i_dur, dur);
1108 if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
1109 IEEE80211_FC0_TYPE_MGT &&
1110 (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) ==
1111 IEEE80211_FC0_SUBTYPE_PROBE_RESP)
1117 DPRINTFN(10,
"sending mgt frame len=%u rate=%u\n",
1118 m0->m_pkthdr.len, tp->mgmtrate);
1128 const struct mbuf *m,
struct ieee80211_node *ni,
int prot,
int rate)
1130 struct ieee80211com *ic = ni->ni_ic;
1133 int protrate, flags;
1135 mprot = ieee80211_alloc_prot(ni, m, rate, prot);
1136 if (mprot == NULL) {
1137 if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1);
1138 device_printf(sc->
sc_dev,
1139 "could not allocate mbuf for protection mode %d\n", prot);
1143 protrate = ieee80211_ctl_rate(ic->ic_rt, rate);
1145 if (prot == IEEE80211_PROT_RTSCTS)
1153 data->ni = ieee80211_ref_node(ni);
1154 data->rate = protrate;
1165 const struct ieee80211_bpf_params *params)
1167 struct ieee80211com *ic = ni->ni_ic;
1174 KASSERT(params != NULL, (
"no raw xmit params"));
1176 rate = params->ibp_rate0;
1177 if (!ieee80211_isratevalid(ic->ic_rt,
rate)) {
1182 if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0)
1184 if (params->ibp_flags & (IEEE80211_BPF_RTS|IEEE80211_BPF_CTS)) {
1186 params->ibp_flags & IEEE80211_BPF_RTS ?
1187 IEEE80211_PROT_RTSCTS : IEEE80211_PROT_CTSONLY,
1207 DPRINTFN(10,
"sending raw frame len=%u rate=%u\n",
1208 m0->m_pkthdr.len,
rate);
1219 struct ieee80211vap *vap = ni->ni_vap;
1220 struct ieee80211com *ic = ni->ni_ic;
1222 struct ieee80211_frame *wh;
1223 const struct ieee80211_txparam *tp = ni->ni_txparms;
1224 struct ieee80211_key *
k;
1231 wh = mtod(m0,
struct ieee80211_frame *);
1233 if (m0->m_flags & M_EAPOL)
1234 rate = tp->mgmtrate;
1235 else if (IEEE80211_IS_MULTICAST(wh->i_addr1))
1236 rate = tp->mcastrate;
1237 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE)
1238 rate = tp->ucastrate;
1240 (void) ieee80211_ratectl_rate(ni, NULL, 0);
1241 rate = ni->ni_txrate;
1244 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
1245 k = ieee80211_crypto_encap(ni, m0);
1251 wh = mtod(m0,
struct ieee80211_frame *);
1254 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
1255 int prot = IEEE80211_PROT_NONE;
1256 if (m0->m_pkthdr.len + IEEE80211_CRC_LEN > vap->iv_rtsthreshold)
1257 prot = IEEE80211_PROT_RTSCTS;
1258 else if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
1259 ieee80211_rate2phytype(ic->ic_rt, rate) == IEEE80211_T_OFDM)
1260 prot = ic->ic_protmode;
1261 if (prot != IEEE80211_PROT_NONE) {
1279 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
1283 dur = ieee80211_ack_duration(ic->ic_rt, rate,
1284 ic->ic_flags & IEEE80211_F_SHPREAMBLE);
1285 USETW(wh->i_dur, dur);
1290 DPRINTFN(10,
"sending data frame len=%u rate=%u\n",
1291 m0->m_pkthdr.len, rate);
1324 struct ieee80211_node *ni;
1333 (m = mbufq_dequeue(&sc->
sc_snd)) != NULL) {
1334 ni = (
struct ieee80211_node *) m->m_pkthdr.rcvif;
1336 if_inc_counter(ni->ni_vap->iv_ifp,
1337 IFCOUNTER_OERRORS, 1);
1338 ieee80211_free_node(ni);
1355 if (ic->ic_nrunning > 0) {
1365 ieee80211_start_all(ic);
1382 device_printf(sc->
sc_dev,
"could not set test mode: %s\n",
1401 device_printf(sc->
sc_dev,
"could not read EEPROM: %s\n",
1417 USETW(
req.wLength, sizeof (uint16_t));
1421 device_printf(sc->
sc_dev,
"could not read MAC register: %s\n",
1426 return le16toh(
val);
1443 device_printf(sc->
sc_dev,
"could not read MAC register: %s\n",
1462 device_printf(sc->
sc_dev,
"could not write MAC register: %s\n",
1481 device_printf(sc->
sc_dev,
"could not write MAC register: %s\n",
1492 for (ntries = 0; ntries < 100; ntries++) {
1498 if (ntries == 100) {
1499 device_printf(sc->
sc_dev,
"could not write to BBP\n");
1516 for (ntries = 0; ntries < 100; ntries++) {
1522 if (ntries == 100) {
1523 device_printf(sc->
sc_dev,
"could not read BBP\n");
1536 for (ntries = 0; ntries < 100; ntries++) {
1542 if (ntries == 100) {
1543 device_printf(sc->
sc_dev,
"could not write to RF\n");
1554 DPRINTFN(15,
"RF R[%u] <- 0x%05x\n",
reg & 0x3,
val & 0xfffff);
1582 int maxchans,
int *nchans,
struct ieee80211_channel chans[])
1585 uint8_t bands[IEEE80211_MODE_BYTES];
1587 memset(bands, 0,
sizeof(bands));
1588 setbit(bands, IEEE80211_MODE_11B);
1589 setbit(bands, IEEE80211_MODE_11G);
1590 ieee80211_add_channels_default_2ghz(chans, maxchans, nchans, bands, 0);
1593 setbit(bands, IEEE80211_MODE_11A);
1594 ieee80211_add_channel_list_5ghz(chans, maxchans, nchans,
1612 struct ieee80211com *ic = &sc->
sc_ic;
1616 chan = ieee80211_chan2ieee(ic, c);
1617 if (
chan == 0 ||
chan == IEEE80211_CHAN_ANY)
1620 if (IEEE80211_IS_CHAN_2GHZ(c))
1626 power -= (100 - ic->ic_txpowlimit) / 8;
1628 DPRINTFN(2,
"setting channel to %u, txpower to %u\n",
chan, power);
1691 if (ic->ic_opmode != IEEE80211_M_MONITOR &&
1692 (ic->ic_flags & IEEE80211_F_SCAN) == 0) {
1696 tmp &= ~RAL_JAPAN_FILTER;
1733 DPRINTFN(2,
"disabling RF autotune\n");
1743 struct ieee80211com *ic = &sc->
sc_ic;
1744 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
1745 uint16_t logcwmin, preload, tmp;
1750 tmp = (16 * vap->iv_bss->ni_intval) << 4;
1753 logcwmin = (ic->ic_opmode == IEEE80211_M_IBSS) ? 2 : 0;
1754 preload = (ic->ic_opmode == IEEE80211_M_IBSS) ? 320 : 6;
1755 tmp = logcwmin << 12 | preload;
1760 if (ic->ic_opmode == IEEE80211_M_STA)
1766 DPRINTF(
"enabling TSF synchronization\n");
1777#define RAL_RXTX_TURNAROUND 5
1781 struct ieee80211com *ic = &sc->
sc_ic;
1782 uint16_t slottime, sifs, eifs;
1784 slottime = IEEE80211_GET_SLOTTIME(ic);
1790 if (ic->ic_curmode == IEEE80211_MODE_11B) {
1806 struct ieee80211com *ic = &sc->
sc_ic;
1811 tmp &= ~RAL_SHORT_PREAMBLE;
1812 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE)
1823 if (IEEE80211_IS_CHAN_5GHZ(c)) {
1826 }
else if (IEEE80211_IS_CHAN_ANYG(c)) {
1840 tmp = bssid[0] | bssid[1] << 8;
1843 tmp = bssid[2] | bssid[3] << 8;
1846 tmp = bssid[4] | bssid[5] << 8;
1849 DPRINTF(
"setting BSSID to %6D\n", bssid,
":");
1866 DPRINTF(
"setting MAC address to %6D\n",
addr,
":");
1876 tmp &= ~RAL_DROP_NOT_TO_ME;
1877 if (sc->
sc_ic.ic_promisc == 0)
1882 DPRINTF(
"%s promiscuous mode\n", sc->
sc_ic.ic_promisc ?
1883 "entering" :
"leaving");
1908 default:
return "unknown";
1915 struct ieee80211com *ic = &sc->
sc_ic;
1943 for (ntries = 0; ntries < 100; ntries++) {
1949 if (ntries == 100) {
1950 device_printf(sc->
sc_dev,
"timeout waiting for BBP\n");
1960 for (i = 0; i < 16; i++) {
1979 else if (antenna == 2)
2007 else if (antenna == 2)
2014 rx &= ~RAL_BBP_FLIPIQ;
2022 struct ieee80211com *ic = &sc->
sc_ic;
2023 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
2039 for (ntries = 0; ntries < 100; ntries++) {
2047 if (ntries == 100) {
2048 device_printf(sc->
sc_dev,
2049 "timeout waiting for BBP/RF to wakeup\n");
2079 if (ic->ic_opmode != IEEE80211_M_MONITOR) {
2081 if (ic->ic_opmode != IEEE80211_M_HOSTAP)
2083 if (ic->ic_promisc == 0)
2127 const struct ieee80211_bpf_params *params)
2129 struct ieee80211com *ic = ni->ni_ic;
2145 if (params == NULL) {
2170 struct ieee80211vap *vap = ni->ni_vap;
2183 struct ieee80211vap *vap = &uvp->
vap;
2184 struct ieee80211com *ic = vap->iv_ic;
2193 struct ieee80211vap *vap = &uvp->
vap;
2194 struct ural_softc *sc = vap->iv_ic->ic_softc;
2195 struct ieee80211_ratectl_tx_stats *txs = &sc->
sc_txs;
2202 txs->flags = IEEE80211_RATECTL_TX_STATS_RETRIES;
2203 txs->nsuccess = sc->
sta[7] +
2206 txs->nframes = txs->nsuccess +
fail;
2208 txs->nretries = sc->
sta[8] +
fail;
2210 ieee80211_ratectl_tx_update(vap, txs);
2213 if_inc_counter(vap->iv_ifp, IFCOUNTER_OERRORS,
fail);
static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB DWC OTG")
SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, phy_type, CTLFLAG_RDTUN, &dwc_otg_phy_type, 0, "DWC OTG PHY TYPE - 0/1/2/3 - ULPI/HSIC/INTERNAL/UTMI+")
static const STRUCT_USB_HOST_ID ural_devs[]
static void ural_bbp_write(struct ural_softc *sc, uint8_t reg, uint8_t val)
static void ural_read_eeprom(struct ural_softc *sc)
USB_PNP_HOST_INFO(ural_devs)
static void ural_update_slot(struct ural_softc *sc)
static void ural_tx_free(struct ural_tx_data *, int)
static int ural_tx_mgt(struct ural_softc *, struct mbuf *, struct ieee80211_node *)
static const uint32_t ural_rf2526_hi_r2[]
static const uint32_t ural_rf2525_r2[]
static void ural_update_promisc(struct ieee80211com *ic)
static const uint32_t ural_rf2525_hi_r2[]
static void ural_set_channel(struct ieee80211com *ic)
static void ural_setup_tx_desc(struct ural_softc *, struct ural_tx_desc *, uint32_t, int, int)
static usb_callback_t ural_bulk_read_callback
static uint8_t ural_bbp_read(struct ural_softc *sc, uint8_t reg)
static void ural_init(struct ural_softc *sc)
static void ural_start(struct ural_softc *)
static void ural_enable_tsf_sync(struct ural_softc *sc)
DRIVER_MODULE(ural, uhub, ural_driver, ural_devclass, NULL, 0)
static void ural_vap_delete(struct ieee80211vap *)
static const struct @123 ural_def_bbp[]
#define RAL_RXTX_TURNAROUND
static void ural_enable_tsf(struct ural_softc *sc)
static void ural_scan_end(struct ieee80211com *ic)
static void ural_set_testmode(struct ural_softc *)
static const uint8_t ural_chan_5ghz[]
static int ural_bbp_init(struct ural_softc *sc)
static const uint32_t ural_rf2523_r2[]
static struct ieee80211vap * ural_vap_create(struct ieee80211com *, const char[IFNAMSIZ], int, enum ieee80211_opmode, int, const uint8_t[IEEE80211_ADDR_LEN], const uint8_t[IEEE80211_ADDR_LEN])
static void ural_set_rxantenna(struct ural_softc *sc, int antenna)
static const uint32_t ural_rf2522_r2[]
static void ural_write(struct ural_softc *, uint16_t, uint16_t)
static void ural_parent(struct ieee80211com *)
static const struct usb_config ural_config[URAL_N_TRANSFER]
static uint16_t ural_read(struct ural_softc *, uint16_t)
static void ural_set_chan(struct ural_softc *sc, struct ieee80211_channel *c)
static void ural_setup_tx_list(struct ural_softc *)
static driver_t ural_driver
static const struct @124 ural_rf5222[]
static const uint32_t ural_rf2524_r2[]
static void ural_set_macaddr(struct ural_softc *sc, const uint8_t *addr)
static device_probe_t ural_match
static void ural_set_basicrates(struct ural_softc *sc, const struct ieee80211_channel *c)
static void ural_set_bssid(struct ural_softc *sc, const uint8_t *bssid)
static int ural_transmit(struct ieee80211com *, struct mbuf *)
static void ural_ratectl_start(struct ural_softc *sc, struct ieee80211_node *ni)
static const uint32_t ural_rf2526_r2[]
static void ural_ratectl_task(void *arg, int pending)
static void ural_set_txpreamble(struct ural_softc *sc)
MODULE_DEPEND(ural, usb, 1, 1, 1)
static devclass_t ural_devclass
static device_detach_t ural_detach
static void ural_write_multi(struct ural_softc *, uint16_t, void *, static void ural_getradiocaps(struct ieee80211com int)
static int ural_newstate(struct ieee80211vap *, enum ieee80211_state, int)
static int ural_tx_data(struct ural_softc *, struct mbuf *, struct ieee80211_node *)
static const uint32_t ural_rf2525e_r2[]
static void ural_read_multi(struct ural_softc *, uint16_t, void *, int)
static void ural_stop(struct ural_softc *sc)
static void ural_scan_start(struct ieee80211com *ic)
static device_attach_t ural_attach
static int ural_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, const struct ieee80211_bpf_params *params)
static device_method_t ural_methods[]
static void ural_getradiocaps(struct ieee80211com *ic, int maxchans, int *nchans, struct ieee80211_channel chans[])
static void ural_unsetup_tx_list(struct ural_softc *)
static void ural_set_txantenna(struct ural_softc *sc, int antenna)
static void ural_setpromisc(struct ural_softc *sc)
static const char * ural_get_rf(int rev)
static void ural_disable_rf_tune(struct ural_softc *sc)
static int ural_sendprot(struct ural_softc *sc, const struct mbuf *m, struct ieee80211_node *ni, int prot, int rate)
static void ural_eeprom_read(struct ural_softc *, uint16_t, void *, int)
static void ural_rf_write(struct ural_softc *sc, uint8_t reg, uint32_t val)
static int ural_pause(struct ural_softc *sc, int timeout)
static usb_error_t ural_do_request(struct ural_softc *sc, struct usb_device_request *req, void *data)
static int ural_tx_raw(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni, const struct ieee80211_bpf_params *params)
static usb_callback_t ural_bulk_write_callback
static uint8_t ural_plcp_signal(int rate)
static int ural_tx_bcn(struct ural_softc *, struct mbuf *, struct ieee80211_node *)
static void ural_ratectl_timeout(void *arg)
#define RAL_SHORT_PREAMBLE
#define RAL_EEPROM_BBP_BASE
#define RAL_TX_IFS_NEWBACKOFF
#define RAL_DROP_BAD_VERSION
#define RAL_WRITE_MULTI_MAC
#define RAL_ENABLE_TSF_SYNC(x)
#define RAL_EEPROM_CONFIG0
#define RAL_EEPROM_TXPOWER
#define RAL_ENABLE_BEACON_GENERATOR
#define RAL_BBP_DIVERSITY
#define RAL_VENDOR_REQUEST
#define RAL_EEPROM_ADDRESS
#define RAL_READ_MULTI_MAC
#define RAL_DROP_NOT_TO_ME
#define RAL_RX_RADIOTAP_PRESENT
#define RAL_TX_LIST_COUNT
#define RAL_TX_RADIOTAP_PRESENT
#define RAL_LOCK_ASSERT(sc, t)
uint8_t sc_bssid[IEEE80211_ADDR_LEN]
struct ieee80211_ratectl_tx_stats sc_txs
struct ural_tx_radiotap_header sc_txtap
struct usb_xfer * sc_xfer[URAL_N_TRANSFER]
struct ural_tx_data tx_data[RAL_TX_LIST_COUNT]
struct usb_device * sc_udev
struct ural_rx_radiotap_header sc_rxtap
struct ural_softc::@126 bbp_prom[16]
struct ural_rx_desc sc_rx_desc
struct ieee80211com sc_ic
struct ieee80211_node * ni
struct usb_callout ratectl_ch
int(* newstate)(struct ieee80211vap *, enum ieee80211_state, int)
enum usb_hc_mode usb_mode
struct usbd_lookup_info info
struct usb_device * device
struct usb_xfer_flags flags
#define UT_WRITE_VENDOR_DEVICE
#define UT_READ_VENDOR_DEVICE
void usbd_copy_in(struct usb_page_cache *cache, usb_frlength_t offset, const void *ptr, usb_frlength_t len)
void usbd_copy_out(struct usb_page_cache *cache, usb_frlength_t offset, void *ptr, usb_frlength_t len)
struct usb_endpoint_descriptor desc
const char * usbd_errstr(usb_error_t err)
int usbd_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id, struct usb_attach_arg *uaa)
usb_error_t usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx, struct usb_device_request *req, void *data, uint16_t flags, uint16_t *actlen, usb_timeout_t timeout)
void usbd_transfer_submit(struct usb_xfer *xfer)
void * usbd_xfer_get_priv(struct usb_xfer *xfer)
void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup)
void usbd_xfer_set_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex, usb_frlength_t len)
struct usb_page_cache * usbd_xfer_get_frame(struct usb_xfer *xfer, usb_frcount_t frindex)
usb_error_t usbd_transfer_setup(struct usb_device *udev, const uint8_t *ifaces, struct usb_xfer **ppxfer, const struct usb_config *setup_start, uint16_t n_setup, void *priv_sc, struct mtx *xfer_mtx)
void usbd_transfer_start(struct usb_xfer *xfer)
void usbd_xfer_set_priv(struct usb_xfer *xfer, void *ptr)
void usbd_transfer_drain(struct usb_xfer *xfer)
void * usbd_xfer_softc(struct usb_xfer *xfer)
void usbd_xfer_set_stall(struct usb_xfer *xfer)
void usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes, int *nframes)
usb_frlength_t usbd_xfer_max_len(struct usb_xfer *xfer)
void device_set_usb_desc(device_t dev)
void usb_pause_mtx(struct mtx *mtx, int timo)
#define usb_callout_init_mtx(c, m, f)
#define usb_callout_reset(c,...)
#define usb_callout_drain(c)
#define USB_ST_TRANSFERRED
void usbd_m_copy_in(struct usb_page_cache *cache, usb_frlength_t dst_offset, struct mbuf *m, usb_size_t src_offset, usb_frlength_t src_len)
void() usb_callback_t(struct usb_xfer *, usb_error_t)
#define STRUCT_USB_HOST_ID
#define usb_callout_stop(c)
#define USB_GET_STATE(xfer)