summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/wlan
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb/wlan')
-rw-r--r--sys/dev/usb/wlan/if_rsu.c45
-rw-r--r--sys/dev/usb/wlan/if_rum.c21
-rw-r--r--sys/dev/usb/wlan/if_run.c34
-rw-r--r--sys/dev/usb/wlan/if_runreg.h25
-rw-r--r--sys/dev/usb/wlan/if_uath.c31
-rw-r--r--sys/dev/usb/wlan/if_upgt.c23
-rw-r--r--sys/dev/usb/wlan/if_ural.c21
-rw-r--r--sys/dev/usb/wlan/if_urtw.c33
-rw-r--r--sys/dev/usb/wlan/if_urtwn.c116
-rw-r--r--sys/dev/usb/wlan/if_urtwnreg.h2
-rw-r--r--sys/dev/usb/wlan/if_zyd.c21
11 files changed, 207 insertions, 165 deletions
diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c
index a6b5ebd..4ad6ab5 100644
--- a/sys/dev/usb/wlan/if_rsu.c
+++ b/sys/dev/usb/wlan/if_rsu.c
@@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
@@ -72,7 +71,7 @@ __FBSDID("$FreeBSD$");
#ifdef USB_DEBUG
static int rsu_debug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, rsu, CTLFLAG_RW, 0, "USB rsu");
-SYSCTL_INT(_hw_usb_rsu, OID_AUTO, debug, CTLFLAG_RWTUN, &rsu_debug, 0,
+SYSCTL_INT(_hw_usb_rsu, OID_AUTO, debug, CTLFLAG_RW, &rsu_debug, 0,
"Debug level");
#endif
@@ -121,7 +120,6 @@ static const STRUCT_USB_HOST_ID rsu_devs[] = {
RSU_DEV_HT(SITECOMEU, WL349V1),
RSU_DEV_HT(SITECOMEU, WL353),
RSU_DEV_HT(SWEEX2, LW154),
- //RSU_DEV_HT(TRENDNET, TEW646UBH),
#undef RSU_DEV_HT
#undef RSU_DEV
};
@@ -1155,9 +1153,16 @@ rsu_event_survey(struct rsu_softc *sc, uint8_t *buf, int len)
pktlen = sizeof(*wh) + le32toh(bss->ieslen);
if (__predict_false(pktlen > MCLBYTES))
return;
- m = m_get2(pktlen, M_NOWAIT, MT_DATA, M_PKTHDR);
+ MGETHDR(m, M_NOWAIT, MT_DATA);
if (__predict_false(m == NULL))
return;
+ if (pktlen > MHLEN) {
+ MCLGET(m, M_NOWAIT);
+ if (!(m->m_flags & M_EXT)) {
+ m_free(m);
+ return;
+ }
+ }
wh = mtod(m, struct ieee80211_frame *);
wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT |
IEEE80211_FC0_SUBTYPE_BEACON;
@@ -1353,11 +1358,11 @@ rsu_rx_frame(struct rsu_softc *sc, uint8_t *buf, int pktlen, int *rssi)
rxdw3 = le32toh(stat->rxdw3);
if (__predict_false(rxdw0 & R92S_RXDW0_CRCERR)) {
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return NULL;
}
if (__predict_false(pktlen < sizeof(*wh) || pktlen > MCLBYTES)) {
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return NULL;
}
@@ -1373,11 +1378,19 @@ rsu_rx_frame(struct rsu_softc *sc, uint8_t *buf, int pktlen, int *rssi)
DPRINTFN(5, "Rx frame len=%d rate=%d infosz=%d rssi=%d\n",
pktlen, rate, infosz, *rssi);
- m = m_get2(pktlen, M_NOWAIT, MT_DATA, M_PKTHDR);
+ MGETHDR(m, M_NOWAIT, MT_DATA);
if (__predict_false(m == NULL)) {
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return NULL;
}
+ if (pktlen > MHLEN) {
+ MCLGET(m, M_NOWAIT);
+ if (__predict_false(!(m->m_flags & M_EXT))) {
+ ifp->if_ierrors++;
+ m_freem(m);
+ return NULL;
+ }
+ }
/* Finalize mbuf. */
m->m_pkthdr.rcvif = ifp;
/* Hardware does Rx TCP checksum offload. */
@@ -1484,7 +1497,7 @@ rsu_rxeof(struct usb_xfer *xfer, struct rsu_data *data, int *rssi)
if (__predict_false(len < sizeof(*stat))) {
DPRINTF("xfer too short %d\n", len);
- if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1);
+ sc->sc_ifp->if_ierrors++;
return (NULL);
}
/* Determine if it is a firmware C2H event or an 802.11 frame. */
@@ -1562,7 +1575,7 @@ tr_setup:
}
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto tr_setup;
}
break;
@@ -1597,7 +1610,7 @@ rsu_txeof(struct usb_xfer *xfer, struct rsu_data *data)
ieee80211_free_node(data->ni);
data->ni = NULL;
}
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
}
@@ -1641,7 +1654,7 @@ tr_setup:
rsu_txeof(xfer, data);
STAILQ_INSERT_TAIL(&sc->sc_tx_inactive, data, next);
}
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
@@ -1802,11 +1815,11 @@ rsu_start_locked(struct ifnet *ifp)
bf = rsu_getbuf(sc);
if (bf == NULL) {
- if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
+ ifp->if_iqdrops++;
m_freem(m);
ieee80211_free_node(ni);
} else if (rsu_tx_start(sc, ni, m, bf) != 0) {
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next);
ieee80211_free_node(ni);
}
@@ -2312,10 +2325,10 @@ rsu_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
RSU_UNLOCK(sc);
return (ENOBUFS);
}
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
if (rsu_tx_start(sc, ni, m, bf) != 0) {
ieee80211_free_node(ni);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next);
RSU_UNLOCK(sc);
return (EIO);
diff --git a/sys/dev/usb/wlan/if_rum.c b/sys/dev/usb/wlan/if_rum.c
index a3dc562..e1e8f2e 100644
--- a/sys/dev/usb/wlan/if_rum.c
+++ b/sys/dev/usb/wlan/if_rum.c
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
@@ -82,7 +81,7 @@ __FBSDID("$FreeBSD$");
static int rum_debug = 0;
static SYSCTL_NODE(_hw_usb, OID_AUTO, rum, CTLFLAG_RW, 0, "USB rum");
-SYSCTL_INT(_hw_usb_rum, OID_AUTO, debug, CTLFLAG_RWTUN, &rum_debug, 0,
+SYSCTL_INT(_hw_usb_rum, OID_AUTO, debug, CTLFLAG_RW, &rum_debug, 0,
"Debug level");
#endif
@@ -797,7 +796,7 @@ rum_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
rum_tx_free(data, 0);
usbd_xfer_set_priv(xfer, NULL);
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
/* FALLTHROUGH */
@@ -851,7 +850,7 @@ tr_setup:
DPRINTFN(11, "transfer error, %s\n",
usbd_errstr(error));
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
data = usbd_xfer_get_priv(xfer);
if (data != NULL) {
rum_tx_free(data, error);
@@ -897,7 +896,7 @@ rum_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
if (len < (int)(RT2573_RX_DESC_SIZE + IEEE80211_MIN_LEN)) {
DPRINTF("%s: xfer too short %d\n",
device_get_nameunit(sc->sc_dev), len);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto tr_setup;
}
@@ -914,14 +913,14 @@ rum_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
* filled RUM_TXRX_CSR2:
*/
DPRINTFN(5, "PHY or CRC error\n");
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto tr_setup;
}
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL) {
DPRINTF("could not allocate mbuf\n");
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto tr_setup;
}
usbd_copy_out(pc, RT2573_RX_DESC_SIZE,
@@ -1321,7 +1320,7 @@ rum_start(struct ifnet *ifp)
ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
if (rum_tx_data(sc, m, ni) != 0) {
ieee80211_free_node(ni);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
break;
}
}
@@ -2205,7 +2204,7 @@ rum_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
return EIO;
}
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
if (params == NULL) {
/*
@@ -2226,7 +2225,7 @@ rum_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
return 0;
bad:
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
RUM_UNLOCK(sc);
ieee80211_free_node(ni);
return EIO;
@@ -2281,7 +2280,7 @@ rum_ratectl_task(void *arg, int pending)
(void) ieee80211_ratectl_rate(ni, NULL, 0);
ieee80211_free_node(ni);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, fail); /* count TX retry-fail as Tx errors */
+ ifp->if_oerrors += fail; /* count TX retry-fail as Tx errors */
usb_callout_reset(&rvp->ratectl_ch, hz, rum_ratectl_timeout, rvp);
RUM_UNLOCK(sc);
diff --git a/sys/dev/usb/wlan/if_run.c b/sys/dev/usb/wlan/if_run.c
index eeb46d3..c4b09a0 100644
--- a/sys/dev/usb/wlan/if_run.c
+++ b/sys/dev/usb/wlan/if_run.c
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
@@ -84,7 +83,7 @@ __FBSDID("$FreeBSD$");
#ifdef RUN_DEBUG
int run_debug = 0;
static SYSCTL_NODE(_hw_usb, OID_AUTO, run, CTLFLAG_RW, 0, "USB run");
-SYSCTL_INT(_hw_usb_run, OID_AUTO, debug, CTLFLAG_RWTUN, &run_debug, 0,
+SYSCTL_INT(_hw_usb_run, OID_AUTO, debug, CTLFLAG_RW, &run_debug, 0,
"run debug level");
#endif
@@ -319,7 +318,6 @@ static const STRUCT_USB_HOST_ID run_devs[] = {
RUN_DEV(ZINWELL, RT3072_2),
RUN_DEV(ZYXEL, RT2870_1),
RUN_DEV(ZYXEL, RT2870_2),
- RUN_DEV(ZYXEL, RT3070),
RUN_DEV_EJECT(ZYXEL, NWD2705),
RUN_DEV_EJECT(RALINK, RT_STOR),
#undef RUN_DEV_EJECT
@@ -2576,7 +2574,7 @@ run_drain_fifo(void *arg)
if (stat & RT2860_TXQ_OK)
(*wstat)[RUN_SUCCESS]++;
else
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
/*
* Check if there were retries, ie if the Tx success rate is
* different from the requested rate. Note that it works only
@@ -2622,7 +2620,7 @@ run_iter_func(void *arg, struct ieee80211_node *ni)
goto fail;
/* count failed TX as errors */
- if_inc_counter(ifp, IFCOUNTER_OERRORS, le16toh(sta[0].error.fail));
+ ifp->if_oerrors += le16toh(sta[0].error.fail);
retrycnt = le16toh(sta[1].tx.retry);
success = le16toh(sta[1].tx.success);
@@ -2788,7 +2786,7 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uint32_t dmalen)
rxwisize += sizeof(uint32_t);
if (__predict_false(len > dmalen)) {
m_freem(m);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
DPRINTF("bad RXWI length %u > %u\n", len, dmalen);
return;
}
@@ -2798,7 +2796,7 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uint32_t dmalen)
if (__predict_false(flags & (RT2860_RX_CRCERR | RT2860_RX_ICVERR))) {
m_freem(m);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
DPRINTF("%s error.\n", (flags & RT2860_RX_CRCERR)?"CRC":"ICV");
return;
}
@@ -2827,7 +2825,7 @@ run_rx_frame(struct run_softc *sc, struct mbuf *m, uint32_t dmalen)
ieee80211_notify_michael_failure(ni->ni_vap, wh,
rxwi->keyidx);
m_freem(m);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
DPRINTF("MIC error. Someone is lying.\n");
return;
}
@@ -2927,7 +2925,7 @@ tr_setup:
}
if (sc->rx_m == NULL) {
DPRINTF("could not allocate mbuf - idle with stall\n");
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
usbd_xfer_set_stall(xfer);
usbd_xfer_set_frames(xfer, 0);
} else {
@@ -2951,7 +2949,7 @@ tr_setup:
if (error == USB_ERR_TIMEOUT)
device_printf(sc->sc_dev, "device timeout\n");
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto tr_setup;
}
@@ -3000,7 +2998,7 @@ tr_setup:
m0 = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (__predict_false(m0 == NULL)) {
DPRINTF("could not allocate mbuf\n");
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
break;
}
m_copydata(m, 4 /* skip 32-bit DMA-len header */,
@@ -3072,7 +3070,7 @@ run_bulk_tx_callbackN(struct usb_xfer *xfer, usb_error_t error, u_int index)
usbd_xfer_set_priv(xfer, NULL);
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
/* FALLTHROUGH */
case USB_ST_SETUP:
@@ -3091,7 +3089,7 @@ tr_setup:
DPRINTF("data overflow, %u bytes\n",
m->m_pkthdr.len);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
run_tx_free(pq, data, 1);
@@ -3146,7 +3144,7 @@ tr_setup:
data = usbd_xfer_get_priv(xfer);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
if (data != NULL) {
if(data->ni != NULL)
@@ -3569,7 +3567,7 @@ run_sendprot(struct run_softc *sc,
mprot = ieee80211_alloc_cts(ic, ni->ni_vap->iv_myaddr, dur);
}
if (mprot == NULL) {
- if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1);
+ sc->sc_ifp->if_oerrors++;
DPRINTF("could not allocate mbuf\n");
return (ENOBUFS);
}
@@ -3705,20 +3703,20 @@ run_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
if (params == NULL) {
/* tx mgt packet */
if ((error = run_tx_mgt(sc, m, ni)) != 0) {
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
DPRINTF("mgt tx failed\n");
goto done;
}
} else {
/* tx raw packet with param */
if ((error = run_tx_param(sc, m, ni, params)) != 0) {
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
DPRINTF("tx with param failed\n");
goto done;
}
}
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
done:
RUN_UNLOCK(sc);
diff --git a/sys/dev/usb/wlan/if_runreg.h b/sys/dev/usb/wlan/if_runreg.h
index aa54a72..3ca01cd 100644
--- a/sys/dev/usb/wlan/if_runreg.h
+++ b/sys/dev/usb/wlan/if_runreg.h
@@ -962,6 +962,31 @@ struct rt2860_rxwi {
#define RT2860_RIDX_MAX 12
/*
+ * Control and status registers access macros.
+ */
+#define RAL_READ(sc, reg) \
+ bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
+
+#define RAL_WRITE(sc, reg, val) \
+ bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
+
+#define RAL_BARRIER_WRITE(sc) \
+ bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, 0x1800, \
+ BUS_SPACE_BARRIER_WRITE)
+
+#define RAL_BARRIER_READ_WRITE(sc) \
+ bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, 0x1800, \
+ BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
+
+#define RAL_WRITE_REGION_1(sc, offset, datap, count) \
+ bus_space_write_region_1((sc)->sc_st, (sc)->sc_sh, (offset), \
+ (datap), (count))
+
+#define RAL_SET_REGION_4(sc, offset, val, count) \
+ bus_space_set_region_4((sc)->sc_st, (sc)->sc_sh, (offset), \
+ (val), (count))
+
+/*
* EEPROM access macro.
*/
#define RT2860_EEPROM_CTL(sc, val) do { \
diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c
index 0796fbe..6806c33 100644
--- a/sys/dev/usb/wlan/if_uath.c
+++ b/sys/dev/usb/wlan/if_uath.c
@@ -86,7 +86,6 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
@@ -115,16 +114,18 @@ __FBSDID("$FreeBSD$");
static SYSCTL_NODE(_hw_usb, OID_AUTO, uath, CTLFLAG_RW, 0, "USB Atheros");
static int uath_countrycode = CTRY_DEFAULT; /* country code */
-SYSCTL_INT(_hw_usb_uath, OID_AUTO, countrycode, CTLFLAG_RWTUN, &uath_countrycode,
+SYSCTL_INT(_hw_usb_uath, OID_AUTO, countrycode, CTLFLAG_RW | CTLFLAG_TUN, &uath_countrycode,
0, "country code");
+TUNABLE_INT("hw.usb.uath.countrycode", &uath_countrycode);
static int uath_regdomain = 0; /* regulatory domain */
SYSCTL_INT(_hw_usb_uath, OID_AUTO, regdomain, CTLFLAG_RD, &uath_regdomain,
0, "regulatory domain");
#ifdef UATH_DEBUG
int uath_debug = 0;
-SYSCTL_INT(_hw_usb_uath, OID_AUTO, debug, CTLFLAG_RWTUN, &uath_debug, 0,
+SYSCTL_INT(_hw_usb_uath, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &uath_debug, 0,
"uath debug level");
+TUNABLE_INT("hw.usb.uath.debug", &uath_debug);
enum {
UATH_DEBUG_XMIT = 0x00000001, /* basic xmit operation */
UATH_DEBUG_XMIT_DUMP = 0x00000002, /* xmit dump */
@@ -1333,7 +1334,7 @@ uath_watchdog(void *arg)
if (--sc->sc_tx_timer == 0) {
device_printf(sc->sc_dev, "device timeout\n");
/*uath_init(ifp); XXX needs a process context! */
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
return;
}
callout_reset(&sc->watchdog_ch, hz, uath_watchdog, sc);
@@ -1814,7 +1815,7 @@ uath_start(struct ifnet *ifp)
next = m->m_nextpkt;
if (uath_tx_start(sc, m, ni, bf) != 0) {
bad:
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
reclaim:
STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next);
UATH_STAT_INC(sc, st_tx_inactive);
@@ -1878,7 +1879,7 @@ uath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
sc->sc_seqnum = 0;
if (uath_tx_start(sc, m, ni, bf) != 0) {
ieee80211_free_node(ni);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next);
UATH_STAT_INC(sc, st_tx_inactive);
UATH_UNLOCK(sc);
@@ -2553,14 +2554,14 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data,
if (actlen < (int)UATH_MIN_RXBUFSZ) {
DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL,
"%s: wrong xfer size (len=%d)\n", __func__, actlen);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return (NULL);
}
chunk = (struct uath_chunk *)data->buf;
if (chunk->seqnum == 0 && chunk->flags == 0 && chunk->length == 0) {
device_printf(sc->sc_dev, "%s: strange response\n", __func__);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
UATH_RESET_INTRX(sc);
return (NULL);
}
@@ -2593,7 +2594,7 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data,
if ((sc->sc_intrx_len + sizeof(struct uath_rx_desc) +
chunklen) > UATH_MAX_INTRX_SIZE) {
UATH_STAT_INC(sc, st_invalidlen);
- if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
+ ifp->if_iqdrops++;
if (sc->sc_intrx_head != NULL)
m_freem(sc->sc_intrx_head);
UATH_RESET_INTRX(sc);
@@ -2618,7 +2619,7 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data,
if (mnew == NULL) {
DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL,
"%s: can't get new mbuf, drop frame\n", __func__);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
if (sc->sc_intrx_head != NULL)
m_freem(sc->sc_intrx_head);
UATH_RESET_INTRX(sc);
@@ -2659,7 +2660,7 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data,
DPRINTF(sc, UATH_DEBUG_RECV | UATH_DEBUG_RECV_ALL,
"%s: bad descriptor (len=%d)\n", __func__,
be32toh(desc->len));
- if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
+ ifp->if_iqdrops++;
UATH_STAT_INC(sc, st_toobigrxpkt);
if (sc->sc_intrx_head != NULL)
m_freem(sc->sc_intrx_head);
@@ -2703,7 +2704,7 @@ uath_data_rxeof(struct usb_xfer *xfer, struct uath_data *data,
tap->wr_antnoise = -95;
}
- if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
+ ifp->if_ipackets++;
UATH_RESET_INTRX(sc);
return (m);
@@ -2790,7 +2791,7 @@ setup:
}
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto setup;
}
break;
@@ -2826,7 +2827,7 @@ uath_data_txeof(struct usb_xfer *xfer, struct uath_data *data)
data->ni = NULL;
}
sc->sc_tx_timer = 0;
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
}
@@ -2878,7 +2879,7 @@ setup:
if ((sc->sc_flags & UATH_FLAG_INVALID) == 0)
ieee80211_free_node(data->ni);
data->ni = NULL;
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
}
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
diff --git a/sys/dev/usb/wlan/if_upgt.c b/sys/dev/usb/wlan/if_upgt.c
index dc6dc1b..1f60ebc 100644
--- a/sys/dev/usb/wlan/if_upgt.c
+++ b/sys/dev/usb/wlan/if_upgt.c
@@ -31,7 +31,6 @@
#include <sys/sysctl.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
@@ -76,8 +75,9 @@ static SYSCTL_NODE(_hw, OID_AUTO, upgt, CTLFLAG_RD, 0,
#ifdef UPGT_DEBUG
int upgt_debug = 0;
-SYSCTL_INT(_hw_upgt, OID_AUTO, debug, CTLFLAG_RWTUN, &upgt_debug,
+SYSCTL_INT(_hw_upgt, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &upgt_debug,
0, "control debugging printfs");
+TUNABLE_INT("hw.upgt.debug", &upgt_debug);
enum {
UPGT_DEBUG_XMIT = 0x00000001, /* basic xmit operation */
UPGT_DEBUG_RECV = 0x00000002, /* basic recv operation */
@@ -182,7 +182,7 @@ static const STRUCT_USB_HOST_ID upgt_devs[] = {
UPGT_DEV(FSC, E5400),
UPGT_DEV(GLOBESPAN, PRISM_GT_1),
UPGT_DEV(GLOBESPAN, PRISM_GT_2),
- //UPGT_DEV(NETGEAR, WG111V1_2),
+ UPGT_DEV(NETGEAR, WG111V2_2),
UPGT_DEV(INTERSIL, PRISM_GT),
UPGT_DEV(SMC, 2862WG),
UPGT_DEV(USR, USR5422),
@@ -416,7 +416,7 @@ upgt_txeof(struct usb_xfer *xfer, struct upgt_data *data)
ieee80211_free_node(data->ni);
data->ni = NULL;
}
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
}
static void
@@ -854,7 +854,7 @@ upgt_start(struct ifnet *ifp)
STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, data_tx, next);
UPGT_STAT_INC(sc, st_tx_inactive);
ieee80211_free_node(ni);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
continue;
}
sc->sc_tx_timer = 5;
@@ -891,7 +891,7 @@ upgt_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, data_tx, next);
UPGT_STAT_INC(sc, st_tx_inactive);
ieee80211_free_node(ni);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
UPGT_UNLOCK(sc);
return (EIO);
}
@@ -911,7 +911,7 @@ upgt_watchdog(void *arg)
if (--sc->sc_tx_timer == 0) {
device_printf(sc->sc_dev, "watchdog timeout\n");
/* upgt_init(ifp); XXX needs a process context ? */
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
return;
}
callout_reset(&sc->sc_watchdog_ch, hz, upgt_watchdog, sc);
@@ -1552,7 +1552,7 @@ upgt_rx(struct upgt_softc *sc, uint8_t *data, int pkglen, int *rssi)
tap->wr_rate = upgt_rx_rate(sc, rxdesc->rate);
tap->wr_antsignal = rxdesc->rssi;
}
- if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
+ ifp->if_ipackets++;
DPRINTF(sc, UPGT_DEBUG_RX_PROC, "%s: RX done\n", __func__);
*rssi = rxdesc->rssi;
@@ -2293,8 +2293,7 @@ done:
* will stall. It's strange, but it works, so we keep reading
* the statistics here. *shrug*
*/
- if (!(if_get_counter_default(ifp, IFCOUNTER_OPACKETS) %
- UPGT_TX_STAT_INTERVAL))
+ if (!(ifp->if_opackets % UPGT_TX_STAT_INTERVAL))
upgt_get_stats(sc);
return (error);
@@ -2367,7 +2366,7 @@ setup:
}
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto setup;
}
break;
@@ -2419,7 +2418,7 @@ setup:
if (data->ni != NULL) {
ieee80211_free_node(data->ni);
data->ni = NULL;
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
}
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
diff --git a/sys/dev/usb/wlan/if_ural.c b/sys/dev/usb/wlan/if_ural.c
index c81b708..69b41dd 100644
--- a/sys/dev/usb/wlan/if_ural.c
+++ b/sys/dev/usb/wlan/if_ural.c
@@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
@@ -83,7 +82,7 @@ __FBSDID("$FreeBSD$");
static int ural_debug = 0;
static SYSCTL_NODE(_hw_usb, OID_AUTO, ural, CTLFLAG_RW, 0, "USB ural");
-SYSCTL_INT(_hw_usb_ural, OID_AUTO, debug, CTLFLAG_RWTUN, &ural_debug, 0,
+SYSCTL_INT(_hw_usb_ural, OID_AUTO, debug, CTLFLAG_RW, &ural_debug, 0,
"Debug level");
#endif
@@ -805,7 +804,7 @@ ural_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
ural_tx_free(data, 0);
usbd_xfer_set_priv(xfer, NULL);
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
/* FALLTHROUGH */
@@ -859,7 +858,7 @@ tr_setup:
DPRINTFN(11, "transfer error, %s\n",
usbd_errstr(error));
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
data = usbd_xfer_get_priv(xfer);
if (data != NULL) {
ural_tx_free(data, error);
@@ -900,7 +899,7 @@ ural_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
if (len < (int)(RAL_RX_DESC_SIZE + IEEE80211_MIN_LEN)) {
DPRINTF("%s: xfer too short %d\n",
device_get_nameunit(sc->sc_dev), len);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto tr_setup;
}
@@ -919,14 +918,14 @@ ural_bulk_read_callback(struct usb_xfer *xfer, usb_error_t error)
* filled RAL_TXRX_CSR2:
*/
DPRINTFN(5, "PHY or CRC error\n");
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto tr_setup;
}
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (m == NULL) {
DPRINTF("could not allocate mbuf\n");
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto tr_setup;
}
usbd_copy_out(pc, 0, mtod(m, uint8_t *), len);
@@ -1370,7 +1369,7 @@ ural_start(struct ifnet *ifp)
ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
if (ural_tx_data(sc, m, ni) != 0) {
ieee80211_free_node(ni);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
break;
}
}
@@ -2210,7 +2209,7 @@ ural_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
return EIO;
}
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
if (params == NULL) {
/*
@@ -2230,7 +2229,7 @@ ural_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
RAL_UNLOCK(sc);
return 0;
bad:
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
RAL_UNLOCK(sc);
ieee80211_free_node(ni);
return EIO; /* XXX */
@@ -2284,7 +2283,7 @@ ural_ratectl_task(void *arg, int pending)
ieee80211_ratectl_tx_update(vap, ni, &sum, &ok, &retrycnt);
(void) ieee80211_ratectl_rate(ni, NULL, 0);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, fail); /* count TX retry-fail as Tx errors */
+ ifp->if_oerrors += fail; /* count TX retry-fail as Tx errors */
usb_callout_reset(&uvp->ratectl_ch, hz, ural_ratectl_timeout, uvp);
RAL_UNLOCK(sc);
diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c
index d2c6ef9..5612f19 100644
--- a/sys/dev/usb/wlan/if_urtw.c
+++ b/sys/dev/usb/wlan/if_urtw.c
@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
#include <sys/rman.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
@@ -65,8 +64,9 @@ __FBSDID("$FreeBSD$");
static SYSCTL_NODE(_hw_usb, OID_AUTO, urtw, CTLFLAG_RW, 0, "USB Realtek 8187L");
#ifdef URTW_DEBUG
int urtw_debug = 0;
-SYSCTL_INT(_hw_usb_urtw, OID_AUTO, debug, CTLFLAG_RWTUN, &urtw_debug, 0,
+SYSCTL_INT(_hw_usb_urtw, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &urtw_debug, 0,
"control debugging printfs");
+TUNABLE_INT("hw.usb.urtw.debug", &urtw_debug);
enum {
URTW_DEBUG_XMIT = 0x00000001, /* basic xmit operation */
URTW_DEBUG_RECV = 0x00000002, /* basic recv operation */
@@ -89,8 +89,9 @@ enum {
} while (0)
#endif
static int urtw_preamble_mode = URTW_PREAMBLE_MODE_LONG;
-SYSCTL_INT(_hw_usb_urtw, OID_AUTO, preamble_mode, CTLFLAG_RWTUN,
+SYSCTL_INT(_hw_usb_urtw, OID_AUTO, preamble_mode, CTLFLAG_RW | CTLFLAG_TUN,
&urtw_preamble_mode, 0, "set the preable mode (long or short)");
+TUNABLE_INT("hw.usb.urtw.preamble_mode", &urtw_preamble_mode);
/* recognized device vendors/products */
#define urtw_lookup(v, p) \
@@ -1472,7 +1473,7 @@ urtw_start(struct ifnet *ifp)
m->m_pkthdr.rcvif = NULL;
if (urtw_tx_start(sc, ni, m, bf, URTW_PRIORITY_NORMAL) != 0) {
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next);
ieee80211_free_node(ni);
break;
@@ -1582,10 +1583,10 @@ urtw_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
return (ENOBUFS); /* XXX */
}
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
if (urtw_tx_start(sc, ni, m, bf, URTW_PRIORITY_LOW) != 0) {
ieee80211_free_node(ni);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next);
URTW_UNLOCK(sc);
return (EIO);
@@ -1918,7 +1919,7 @@ urtw_watchdog(void *arg)
if (sc->sc_txtimer > 0) {
if (--sc->sc_txtimer == 0) {
device_printf(sc->sc_dev, "device timeout\n");
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
return;
}
callout_reset(&sc->sc_watchdog_ch, hz, urtw_watchdog, sc);
@@ -3993,7 +3994,7 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *data, int *rssi_p,
usbd_xfer_status(xfer, &actlen, NULL, NULL, NULL);
if (actlen < (int)URTW_MIN_RXBUFSZ) {
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return (NULL);
}
@@ -4004,7 +4005,7 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *data, int *rssi_p,
(actlen - (sizeof(struct urtw_8187b_rxhdr))));
flen = le32toh(rx->flag) & 0xfff;
if (flen > actlen) {
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return (NULL);
}
rate = (le32toh(rx->flag) >> URTW_RX_FLAG_RXRATE_SHIFT) & 0xf;
@@ -4018,7 +4019,7 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *data, int *rssi_p,
(actlen - (sizeof(struct urtw_8187l_rxhdr))));
flen = le32toh(rx->flag) & 0xfff;
if (flen > actlen) {
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return (NULL);
}
@@ -4030,7 +4031,7 @@ urtw_rxeof(struct usb_xfer *xfer, struct urtw_data *data, int *rssi_p,
mnew = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
if (mnew == NULL) {
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return (NULL);
}
@@ -4127,7 +4128,7 @@ setup:
}
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto setup;
}
break;
@@ -4156,7 +4157,7 @@ urtw_txstatus_eof(struct usb_xfer *xfer)
pktretry = val & 0xff;
seq = (val >> 16) & 0xff;
if (pktretry == URTW_TX_MAXRETRY)
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
DPRINTF(sc, URTW_DEBUG_TXSTATUS, "pktretry %d seq %#x\n",
pktretry, seq);
}
@@ -4184,7 +4185,7 @@ setup:
default:
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto setup;
}
break;
@@ -4218,7 +4219,7 @@ urtw_txeof(struct usb_xfer *xfer, struct urtw_data *data)
data->ni = NULL;
}
sc->sc_txtimer = 0;
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
}
@@ -4265,7 +4266,7 @@ setup:
if (data->ni != NULL) {
ieee80211_free_node(data->ni);
data->ni = NULL;
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
}
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
diff --git a/sys/dev/usb/wlan/if_urtwn.c b/sys/dev/usb/wlan/if_urtwn.c
index 28bf713..2475727 100644
--- a/sys/dev/usb/wlan/if_urtwn.c
+++ b/sys/dev/usb/wlan/if_urtwn.c
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
@@ -78,7 +77,7 @@ __FBSDID("$FreeBSD$");
static int urtwn_debug = 0;
SYSCTL_NODE(_hw_usb, OID_AUTO, urtwn, CTLFLAG_RW, 0, "USB urtwn");
-SYSCTL_INT(_hw_usb_urtwn, OID_AUTO, debug, CTLFLAG_RWTUN, &urtwn_debug, 0,
+SYSCTL_INT(_hw_usb_urtwn, OID_AUTO, debug, CTLFLAG_RW, &urtwn_debug, 0,
"Debug level");
#endif
@@ -153,9 +152,7 @@ static const STRUCT_USB_HOST_ID urtwn_devs[] = {
URTWN_DEV(TRENDNET, RTL8192CU),
URTWN_DEV(ZYXEL, RTL8192CU),
/* URTWN_RTL8188E */
- //URTWN_RTL8188E_DEV(DLINK, DWA123D1),
URTWN_RTL8188E_DEV(DLINK, DWA125D1),
- //URTWN_RTL8188E_DEV(ELECOM, WDC150SU2M),
URTWN_RTL8188E_DEV(REALTEK, RTL8188ETV),
URTWN_RTL8188E_DEV(REALTEK, RTL8188EU),
#undef URTWN_RTL8188E_DEV
@@ -176,12 +173,12 @@ static struct ieee80211vap *urtwn_vap_create(struct ieee80211com *,
const uint8_t [IEEE80211_ADDR_LEN],
const uint8_t [IEEE80211_ADDR_LEN]);
static void urtwn_vap_delete(struct ieee80211vap *);
-static struct mbuf * urtwn_rx_frame(struct urtwn_softc *, uint8_t *, int,
+static struct mbuf * urtwn_rx_frame(struct urtwn_softc *, uint8_t *, int,
int *);
-static struct mbuf * urtwn_rxeof(struct usb_xfer *, struct urtwn_data *,
+static struct mbuf * urtwn_rxeof(struct usb_xfer *, struct urtwn_data *,
int *, int8_t *);
static void urtwn_txeof(struct usb_xfer *, struct urtwn_data *);
-static int urtwn_alloc_list(struct urtwn_softc *,
+static int urtwn_alloc_list(struct urtwn_softc *,
struct urtwn_data[], int, int);
static int urtwn_alloc_rx_list(struct urtwn_softc *);
static int urtwn_alloc_tx_list(struct urtwn_softc *);
@@ -191,24 +188,24 @@ static void urtwn_free_list(struct urtwn_softc *,
struct urtwn_data data[], int);
static struct urtwn_data * _urtwn_getbuf(struct urtwn_softc *);
static struct urtwn_data * urtwn_getbuf(struct urtwn_softc *);
-static int urtwn_write_region_1(struct urtwn_softc *, uint16_t,
+static int urtwn_write_region_1(struct urtwn_softc *, uint16_t,
uint8_t *, int);
static void urtwn_write_1(struct urtwn_softc *, uint16_t, uint8_t);
static void urtwn_write_2(struct urtwn_softc *, uint16_t, uint16_t);
static void urtwn_write_4(struct urtwn_softc *, uint16_t, uint32_t);
-static int urtwn_read_region_1(struct urtwn_softc *, uint16_t,
+static int urtwn_read_region_1(struct urtwn_softc *, uint16_t,
uint8_t *, int);
static uint8_t urtwn_read_1(struct urtwn_softc *, uint16_t);
static uint16_t urtwn_read_2(struct urtwn_softc *, uint16_t);
static uint32_t urtwn_read_4(struct urtwn_softc *, uint16_t);
-static int urtwn_fw_cmd(struct urtwn_softc *, uint8_t,
+static int urtwn_fw_cmd(struct urtwn_softc *, uint8_t,
const void *, int);
static void urtwn_r92c_rf_write(struct urtwn_softc *, int,
uint8_t, uint32_t);
-static void urtwn_r88e_rf_write(struct urtwn_softc *, int,
+static void urtwn_r88e_rf_write(struct urtwn_softc *, int,
uint8_t, uint32_t);
static uint32_t urtwn_rf_read(struct urtwn_softc *, int, uint8_t);
-static int urtwn_llt_write(struct urtwn_softc *, uint32_t,
+static int urtwn_llt_write(struct urtwn_softc *, uint32_t,
uint32_t);
static uint8_t urtwn_efuse_read_1(struct urtwn_softc *, uint16_t);
static void urtwn_efuse_read(struct urtwn_softc *);
@@ -219,7 +216,7 @@ static void urtwn_r88e_read_rom(struct urtwn_softc *);
static int urtwn_ra_init(struct urtwn_softc *);
static void urtwn_tsf_sync_enable(struct urtwn_softc *);
static void urtwn_set_led(struct urtwn_softc *, int, int);
-static int urtwn_newstate(struct ieee80211vap *,
+static int urtwn_newstate(struct ieee80211vap *,
enum ieee80211_state, int);
static void urtwn_watchdog(void *);
static void urtwn_update_avgrssi(struct urtwn_softc *, int, int8_t);
@@ -237,7 +234,7 @@ static int urtwn_r88e_power_on(struct urtwn_softc *);
static int urtwn_llt_init(struct urtwn_softc *);
static void urtwn_fw_reset(struct urtwn_softc *);
static void urtwn_r88e_fw_reset(struct urtwn_softc *);
-static int urtwn_fw_loadpage(struct urtwn_softc *, int,
+static int urtwn_fw_loadpage(struct urtwn_softc *, int,
const uint8_t *, int);
static int urtwn_load_firmware(struct urtwn_softc *);
static int urtwn_r92c_dma_init(struct urtwn_softc *);
@@ -249,22 +246,22 @@ static void urtwn_cam_init(struct urtwn_softc *);
static void urtwn_pa_bias_init(struct urtwn_softc *);
static void urtwn_rxfilter_init(struct urtwn_softc *);
static void urtwn_edca_init(struct urtwn_softc *);
-static void urtwn_write_txpower(struct urtwn_softc *, int,
+static void urtwn_write_txpower(struct urtwn_softc *, int,
uint16_t[]);
static void urtwn_get_txpower(struct urtwn_softc *, int,
- struct ieee80211_channel *,
+ struct ieee80211_channel *,
struct ieee80211_channel *, uint16_t[]);
static void urtwn_r88e_get_txpower(struct urtwn_softc *, int,
- struct ieee80211_channel *,
+ struct ieee80211_channel *,
struct ieee80211_channel *, uint16_t[]);
static void urtwn_set_txpower(struct urtwn_softc *,
- struct ieee80211_channel *,
+ struct ieee80211_channel *,
struct ieee80211_channel *);
static void urtwn_scan_start(struct ieee80211com *);
static void urtwn_scan_end(struct ieee80211com *);
static void urtwn_set_channel(struct ieee80211com *);
static void urtwn_set_chan(struct urtwn_softc *,
- struct ieee80211_channel *,
+ struct ieee80211_channel *,
struct ieee80211_channel *);
static void urtwn_update_mcast(struct ifnet *);
static void urtwn_iq_calib(struct urtwn_softc *);
@@ -470,7 +467,7 @@ urtwn_attach(device_t self)
ic->ic_vap_delete = urtwn_vap_delete;
ic->ic_update_mcast = urtwn_update_mcast;
- ieee80211_radiotap_attach(ic, &sc->sc_txtap.wt_ihdr,
+ ieee80211_radiotap_attach(ic, &sc->sc_txtap.wt_ihdr,
sizeof(sc->sc_txtap), URTWN_TX_RADIOTAP_PRESENT,
&sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap),
URTWN_RX_RADIOTAP_PRESENT);
@@ -492,7 +489,7 @@ urtwn_detach(device_t self)
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
unsigned int x;
-
+
/* Prevent further ioctls. */
URTWN_LOCK(sc);
sc->sc_flags |= URTWN_DETACHED;
@@ -604,7 +601,7 @@ urtwn_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
vap = &uvp->vap;
/* enable s/w bmiss handling for sta mode */
- if (ieee80211_vap_setup(ic, vap, name, unit, opmode,
+ if (ieee80211_vap_setup(ic, vap, name, unit, opmode,
flags | IEEE80211_CLONE_NOBEACONS, bssid, mac) != 0) {
/* out of memory */
free(uvp, M_80211_VAP);
@@ -660,11 +657,7 @@ urtwn_rx_frame(struct urtwn_softc *sc, uint8_t *buf, int pktlen, int *rssi_p)
* This should not happen since we setup our Rx filter
* to not receive these frames.
*/
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
- return (NULL);
- }
- if (pktlen < sizeof(*wh) || pktlen > MCLBYTES) {
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return (NULL);
}
@@ -673,7 +666,7 @@ urtwn_rx_frame(struct urtwn_softc *sc, uint8_t *buf, int pktlen, int *rssi_p)
/* Get RSSI from PHY status descriptor if present. */
if (infosz != 0 && (rxdw0 & R92C_RXDW0_PHYST)) {
- if (sc->chip & URTWN_CHIP_88E)
+ if (sc->chip & URTWN_CHIP_88E)
rssi = urtwn_r88e_get_rssi(sc, rate, &stat[1]);
else
rssi = urtwn_get_rssi(sc, rate, &stat[1]);
@@ -749,7 +742,7 @@ urtwn_rxeof(struct usb_xfer *xfer, struct urtwn_data *data, int *rssi,
usbd_xfer_status(xfer, &len, NULL, NULL, NULL);
if (len < sizeof(*stat)) {
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return (NULL);
}
@@ -864,7 +857,7 @@ tr_setup:
}
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
goto tr_setup;
}
break;
@@ -898,7 +891,7 @@ urtwn_txeof(struct usb_xfer *xfer, struct urtwn_data *data)
data->ni = NULL;
}
sc->sc_txtimer = 0;
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
}
@@ -940,7 +933,7 @@ tr_setup:
if (data->ni != NULL) {
ieee80211_free_node(data->ni);
data->ni = NULL;
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
}
if (error != USB_ERR_CANCELLED) {
usbd_xfer_set_stall(xfer);
@@ -1184,7 +1177,7 @@ urtwn_efuse_read_1(struct urtwn_softc *sc, uint16_t addr)
return (MS(reg, R92C_EFUSE_CTRL_DATA));
urtwn_ms_delay(sc);
}
- device_printf(sc->sc_dev,
+ device_printf(sc->sc_dev,
"could not read efuse byte at address 0x%x\n", addr);
return (0xff);
}
@@ -1195,7 +1188,7 @@ urtwn_efuse_read(struct urtwn_softc *sc)
uint8_t *rom = (uint8_t *)&sc->rom;
uint16_t addr = 0;
uint32_t reg;
- uint8_t off, msk;
+ uint8_t off, msk, vol;
int i;
urtwn_efuse_switch_power(sc);
@@ -1228,15 +1221,18 @@ urtwn_efuse_read(struct urtwn_softc *sc)
printf("\n");
}
#endif
- urtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_OFF);
-}
+ /* Disable LDO 2.5V. */
+ vol = urtwn_read_1(sc, R92C_EFUSE_TEST + 3);
+ urtwn_write_1(sc, R92C_EFUSE_TEST + 3, vol & ~(0x80));
+}
static void
urtwn_efuse_switch_power(struct urtwn_softc *sc)
{
uint32_t reg;
- urtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_ON);
+ if (sc->chip & URTWN_CHIP_88E)
+ urtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_ON);
reg = urtwn_read_2(sc, R92C_SYS_ISO_CTRL);
if (!(reg & R92C_SYS_ISO_CTRL_PWC_EV12V)) {
@@ -1254,6 +1250,16 @@ urtwn_efuse_switch_power(struct urtwn_softc *sc)
urtwn_write_2(sc, R92C_SYS_CLKR,
reg | R92C_SYS_CLKR_LOADER_EN | R92C_SYS_CLKR_ANA8M);
}
+
+ if (!(sc->chip & URTWN_CHIP_88E)) {
+ uint8_t vol;
+
+ /* Enable LDO 2.5V. */
+ vol = urtwn_read_1(sc, R92C_EFUSE_TEST + 3);
+ vol &= 0x0f;
+ vol |= 0x30;
+ urtwn_write_1(sc, R92C_EFUSE_TEST + 3, (vol | 0x80));
+ }
}
static int
@@ -1483,7 +1489,7 @@ static void
urtwn_set_led(struct urtwn_softc *sc, int led, int on)
{
uint8_t reg;
-
+
if (led == URTWN_LED_LINK) {
if (sc->chip & URTWN_CHIP_88E) {
reg = urtwn_read_1(sc, R92C_LEDCFG2) & 0xf0;
@@ -1644,7 +1650,7 @@ urtwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
if (sc->chip & URTWN_CHIP_88E)
ni->ni_txrate =
ni->ni_rates.rs_rates[ni->ni_rates.rs_nrates-1];
- else
+ else
urtwn_ra_init(sc);
/* Turn link LED on. */
urtwn_set_led(sc, URTWN_LED_LINK, 1);
@@ -1672,7 +1678,7 @@ urtwn_watchdog(void *arg)
if (sc->sc_txtimer > 0) {
if (--sc->sc_txtimer == 0) {
device_printf(sc->sc_dev, "device timeout\n");
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
return;
}
callout_reset(&sc->sc_watchdog_ch, hz, urtwn_watchdog, sc);
@@ -1755,7 +1761,7 @@ urtwn_r88e_get_rssi(struct urtwn_softc *sc, int rate, void *physt)
cck = (struct r88e_rx_cck *)physt;
cck_agc_rpt = cck->agc_rpt;
lna_idx = (cck_agc_rpt & 0xe0) >> 5;
- vga_idx = cck_agc_rpt & 0x1f;
+ vga_idx = cck_agc_rpt & 0x1f;
switch (lna_idx) {
case 7:
if (vga_idx <= 27)
@@ -1795,7 +1801,7 @@ urtwn_r88e_get_rssi(struct urtwn_softc *sc, int rate, void *physt)
static int
-urtwn_tx_start(struct urtwn_softc *sc, struct ieee80211_node *ni,
+urtwn_tx_start(struct urtwn_softc *sc, struct ieee80211_node *ni,
struct mbuf *m0, struct urtwn_data *data)
{
struct ifnet *ifp = sc->sc_ifp;
@@ -1836,7 +1842,7 @@ urtwn_tx_start(struct urtwn_softc *sc, struct ieee80211_node *ni,
/* in case packet header moved, reset pointer */
wh = mtod(m0, struct ieee80211_frame *);
}
-
+
switch (type) {
case IEEE80211_FC0_TYPE_CTL:
case IEEE80211_FC0_TYPE_MGT:
@@ -1848,7 +1854,7 @@ urtwn_tx_start(struct urtwn_softc *sc, struct ieee80211_node *ni,
xfer = urtwn_pipes[M_WME_GETAC(m0)];
break;
}
-
+
hasqos = 0;
/* Fill Tx descriptor. */
@@ -1892,7 +1898,10 @@ urtwn_tx_start(struct urtwn_softc *sc, struct ieee80211_node *ni,
txd->txdw4 |= htole32(SM(R92C_TXDW4_RTSRATE, 8));
txd->txdw5 |= htole32(0x0001ff00);
/* Send data at OFDM54. */
- txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE, 11));
+ if (sc->chip & URTWN_CHIP_88E)
+ txd->txdw5 |= htole32(0x13 & 0x3f);
+ else
+ txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE, 11));
} else {
txd->txdw1 |= htole32(
SM(R92C_TXDW1_MACID, 0) |
@@ -1973,7 +1982,7 @@ urtwn_start_locked(struct ifnet *ifp, struct urtwn_softc *sc)
m->m_pkthdr.rcvif = NULL;
if (urtwn_tx_start(sc, ni, m, bf) != 0) {
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next);
ieee80211_free_node(ni);
break;
@@ -2323,7 +2332,7 @@ urtwn_fw_loadpage(struct urtwn_softc *sc, int page, const uint8_t *buf, int len)
else
mlen = 1;
/* XXX fix this deconst */
- error = urtwn_write_region_1(sc, off,
+ error = urtwn_write_region_1(sc, off,
__DECONST(uint8_t *, buf), mlen);
if (error != 0)
break;
@@ -2458,7 +2467,7 @@ fail:
static __inline int
urtwn_dma_init(struct urtwn_softc *sc)
{
-
+
return sc->sc_dma_init(sc);
}
@@ -3226,10 +3235,10 @@ urtwn_set_chan(struct urtwn_softc *sc, struct ieee80211_channel *c,
urtwn_bb_read(sc, R92C_FPGA0_ANAPARAM2) |
R92C_FPGA0_ANAPARAM2_CBW20);
}
-
+
/* Select 20MHz bandwidth. */
urtwn_rf_write(sc, 0, R92C_RF_CHNLBW,
- (sc->rf_chnlbw[0] & ~0xfff) | chan |
+ (sc->rf_chnlbw[0] & ~0xfff) | chan |
((sc->chip & URTWN_CHIP_88E) ? R88E_RF_CHNLBW_BW20 :
R92C_RF_CHNLBW_BW20));
}
@@ -3304,7 +3313,7 @@ urtwn_init_locked(void *arg)
error = urtwn_alloc_rx_list(sc);
if (error != 0)
goto fail;
-
+
error = urtwn_alloc_tx_list(sc);
if (error != 0)
goto fail;
@@ -3348,7 +3357,6 @@ urtwn_init_locked(void *arg)
urtwn_rxfilter_init(sc);
- /* Set response rate. */
reg = urtwn_read_4(sc, R92C_RRSR);
reg = RW(reg, R92C_RRSR_RATE_BITMAP, R92C_RRSR_RATE_CCK_ONLY_1M);
urtwn_write_4(sc, R92C_RRSR, reg);
@@ -3540,10 +3548,10 @@ urtwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
return (ENOBUFS);
}
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
if (urtwn_tx_start(sc, ni, m, bf) != 0) {
ieee80211_free_node(ni);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next);
URTWN_UNLOCK(sc);
return (EIO);
diff --git a/sys/dev/usb/wlan/if_urtwnreg.h b/sys/dev/usb/wlan/if_urtwnreg.h
index 2bbec7a..4eef029 100644
--- a/sys/dev/usb/wlan/if_urtwnreg.h
+++ b/sys/dev/usb/wlan/if_urtwnreg.h
@@ -177,13 +177,13 @@
#define R92C_RD_NAV_NXT 0x544
#define R92C_NAV_PROT_LEN 0x546
#define R92C_BCN_CTRL 0x550
+#define R92C_USTIME_TSF 0x551
#define R92C_MBID_NUM 0x552
#define R92C_DUAL_TSF_RST 0x553
#define R92C_BCN_INTERVAL 0x554
#define R92C_DRVERLYINT 0x558
#define R92C_BCNDMATIM 0x559
#define R92C_ATIMWND 0x55a
-#define R92C_USTIME_TSF 0x55c
#define R92C_BCN_MAX_ERR 0x55d
#define R92C_RXTSF_OFFSET_CCK 0x55e
#define R92C_RXTSF_OFFSET_OFDM 0x55f
diff --git a/sys/dev/usb/wlan/if_zyd.c b/sys/dev/usb/wlan/if_zyd.c
index ca1fb06..35a064b 100644
--- a/sys/dev/usb/wlan/if_zyd.c
+++ b/sys/dev/usb/wlan/if_zyd.c
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
@@ -80,7 +79,7 @@ __FBSDID("$FreeBSD$");
static int zyd_debug = 0;
static SYSCTL_NODE(_hw_usb, OID_AUTO, zyd, CTLFLAG_RW, 0, "USB zyd");
-SYSCTL_INT(_hw_usb_zyd, OID_AUTO, debug, CTLFLAG_RWTUN, &zyd_debug, 0,
+SYSCTL_INT(_hw_usb_zyd, OID_AUTO, debug, CTLFLAG_RW, &zyd_debug, 0,
"zyd debug level");
enum {
@@ -679,7 +678,7 @@ zyd_intr_read_callback(struct usb_xfer *xfer, usb_error_t error)
ieee80211_free_node(ni);
}
if (le16toh(retry->count) & 0x100)
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); /* too many retries */
+ ifp->if_oerrors++; /* too many retries */
break;
}
case ZYD_NOTIF_IORD:
@@ -2188,7 +2187,7 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len)
if (len < ZYD_MIN_FRAGSZ) {
DPRINTF(sc, ZYD_DEBUG_RECV, "%s: frame too short (length=%d)\n",
device_get_nameunit(sc->sc_dev), len);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return;
}
pc = usbd_xfer_get_frame(xfer, 0);
@@ -2199,7 +2198,7 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len)
DPRINTF(sc, ZYD_DEBUG_RECV,
"%s: RX status indicated error (%x)\n",
device_get_nameunit(sc->sc_dev), stat.flags);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return;
}
@@ -2211,7 +2210,7 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len)
if (rlen > (int)MCLBYTES) {
DPRINTF(sc, ZYD_DEBUG_RECV, "%s: frame too long (length=%d)\n",
device_get_nameunit(sc->sc_dev), rlen);
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return;
} else if (rlen > (int)MHLEN)
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
@@ -2220,7 +2219,7 @@ zyd_rx_data(struct usb_xfer *xfer, int offset, uint16_t len)
if (m == NULL) {
DPRINTF(sc, ZYD_DEBUG_RECV, "%s: could not allocate rx mbuf\n",
device_get_nameunit(sc->sc_dev));
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
+ ifp->if_ierrors++;
return;
}
m->m_pkthdr.rcvif = ifp;
@@ -2403,7 +2402,7 @@ zyd_bulk_write_callback(struct usb_xfer *xfer, usb_error_t error)
zyd_tx_free(data, 0);
usbd_xfer_set_priv(xfer, NULL);
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ ifp->if_opackets++;
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
/* FALLTHROUGH */
@@ -2447,7 +2446,7 @@ tr_setup:
DPRINTF(sc, ZYD_DEBUG_ANY, "transfer error, %s\n",
usbd_errstr(error));
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
data = usbd_xfer_get_priv(xfer);
usbd_xfer_set_priv(xfer, NULL);
if (data != NULL)
@@ -2608,7 +2607,7 @@ zyd_start(struct ifnet *ifp)
ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
if (zyd_tx_start(sc, m, ni) != 0) {
ieee80211_free_node(ni);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
break;
}
}
@@ -2646,7 +2645,7 @@ zyd_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
*/
if (zyd_tx_start(sc, m, ni) != 0) {
ZYD_UNLOCK(sc);
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ ifp->if_oerrors++;
ieee80211_free_node(ni);
return (EIO);
}
OpenPOWER on IntegriCloud