Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/phil-wifi]: src/sys End of the week state save:
details: https://anonhg.NetBSD.org/src/rev/be7f20fb4ef7
branches: phil-wifi
changeset: 363488:be7f20fb4ef7
user: phil <phil%NetBSD.org@localhost>
date: Sat Jul 28 00:49:43 2018 +0000
description:
End of the week state save:
Got workqueues doing FreeBSD tasks. (still questions on how correct it is.)
Incremental changes in many places.
Still *lots* of debugging code that needs to go away some day.
"ifconfig urtwn0 up" now does not crash, still needs scan to work properly.
diffstat:
sys/dev/usb/if_urtwn.c | 516 ++++++++++++++++++++++++++++++++++---
sys/net80211/ieee80211.c | 16 +-
sys/net80211/ieee80211_adhoc.c | 7 +-
sys/net80211/ieee80211_hostap.c | 3 +-
sys/net80211/ieee80211_input.c | 4 +-
sys/net80211/ieee80211_ioctl.c | 7 +-
sys/net80211/ieee80211_mesh.c | 3 +-
sys/net80211/ieee80211_monitor.c | 3 +-
sys/net80211/ieee80211_netbsd.c | 45 +++-
sys/net80211/ieee80211_netbsd.h | 65 ++-
sys/net80211/ieee80211_proto.c | 16 +-
sys/net80211/ieee80211_scan.c | 35 ++-
sys/net80211/ieee80211_scan_sta.c | 28 +-
sys/net80211/ieee80211_sta.c | 3 +-
sys/net80211/ieee80211_tdma.c | 3 +-
sys/net80211/ieee80211_wds.c | 3 +-
16 files changed, 661 insertions(+), 96 deletions(-)
diffs (truncated from 1552 to 300 lines):
diff -r 0901b8df5a73 -r be7f20fb4ef7 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c Fri Jul 20 20:33:05 2018 +0000
+++ b/sys/dev/usb/if_urtwn.c Sat Jul 28 00:49:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_urtwn.c,v 1.59.2.3 2018/07/20 20:33:05 phil Exp $ */
+/* $NetBSD: if_urtwn.c,v 1.59.2.4 2018/07/28 00:49:43 phil Exp $ */
/* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */
/*-
@@ -19,13 +19,30 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* Some code taken from FreeBSD dev/usb/wlan/if_urtw.c with copyright */
+/*-
+ * Copyright (c) 2008 Weongyo Jeong <weongyo%FreeBSD.org@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
/*-
* Driver for Realtek RTL8188CE-VAU/RTL8188CUS/RTL8188EU/RTL8188RU/RTL8192CU
* RTL8192EU.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.3 2018/07/20 20:33:05 phil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.59.2.4 2018/07/28 00:49:43 phil Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -94,7 +111,7 @@
#define DBG_REG __BIT(6)
#define DBG_ALL 0xffffffffU
/* NNN Reset urtwn_debug to 0 when done debugging. */
-u_int urtwn_debug = DBG_INIT|DBG_FN|DBG_STM;
+u_int urtwn_debug = DBG_ALL & ~DBG_REG;
#define DPRINTFN(n, s) \
do { if (urtwn_debug & (n)) printf s; } while (/*CONSTCOND*/0)
#else
@@ -203,6 +220,11 @@
#undef URTWN_RTL8188E_DEV
#undef URTWN_RTL8192EU_DEV
+/* urtwn data */
+static const uint8_t urtwn_chan_2ghz[] =
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
+
+
static int urtwn_match(device_t, cfdata_t, void *);
static void urtwn_attach(device_t, device_t, void *);
static int urtwn_detach(device_t, int);
@@ -252,7 +274,7 @@
static void urtwn_read_rom(struct urtwn_softc *);
static void urtwn_r88e_read_rom(struct urtwn_softc *);
static int urtwn_media_change(struct ifnet *);
-static int urtwn_ra_init(struct urtwn_softc *);
+static int urtwn_ra_init(struct ieee80211vap *);
static int urtwn_get_nettype(struct urtwn_softc *);
static void urtwn_set_nettype0_msr(struct urtwn_softc *, uint8_t);
static void urtwn_tsf_sync_enable(struct urtwn_softc *);
@@ -262,7 +284,7 @@
static void urtwn_next_scan(void *);
static int urtwn_newstate(struct ieee80211vap *, enum ieee80211_state,
int);
-static void urtwn_newstate_cb(struct urtwn_softc *, void *);
+// static void urtwn_newstate_cb(struct urtwn_softc *, void *);
static int urtwn_wme_update(struct ieee80211com *);
static void urtwn_wme_update_cb(struct urtwn_softc *, void *);
static void urtwn_update_avgrssi(struct urtwn_softc *, int, int8_t);
@@ -326,7 +348,8 @@
static int urtwn_transmit(struct ieee80211com *, struct mbuf *);
static int urtwn_raw_xmit(struct ieee80211_node *, struct mbuf *,
const struct ieee80211_bpf_params *);
-
+static void urtwn_getradiocaps(struct ieee80211com *, int, int *,
+ struct ieee80211_channel []);
/* Aliases. */
#define urtwn_bb_write urtwn_write_4
@@ -394,8 +417,9 @@
(void) usbd_do_request(sc->sc_udev, &req, 0);
mutex_init(&sc->sc_task_mtx, MUTEX_DEFAULT, IPL_NET);
- mutex_init(&sc->sc_tx_mtx, MUTEX_DEFAULT, IPL_NONE);
- mutex_init(&sc->sc_rx_mtx, MUTEX_DEFAULT, IPL_NONE);
+ printf ("sc_tx_mtx INIT, addr 0x%lx\n", (long) &sc->sc_tx_mtx);
+ mutex_init(&sc->sc_tx_mtx, MUTEX_DEFAULT, IPL_SOFTNET);
+ mutex_init(&sc->sc_rx_mtx, MUTEX_DEFAULT, IPL_SOFTNET);
mutex_init(&sc->sc_fwcmd_mtx, MUTEX_DEFAULT, IPL_NONE);
mutex_init(&sc->sc_write_mtx, MUTEX_DEFAULT, IPL_NONE);
@@ -492,13 +516,9 @@
IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ;
}
- printf ("eurtwn: Calling ieee80211_ifattach()\n");
-
ieee80211_ifattach(ic);
- printf ("urtwn: Returned from ieee80211_ifattach().\n");
-
- /* override default methods NNN Need a lot more here!!! */
+ /* override default methods NNN Need more here? */
ic->ic_newassoc = urtwn_newassoc;
ic->ic_wme.wme_update = urtwn_wme_update;
ic->ic_vap_create = urtwn_vap_create;
@@ -509,6 +529,7 @@
ic->ic_set_channel = urtwn_set_channel;
ic->ic_transmit = urtwn_transmit;
ic->ic_raw_xmit = urtwn_raw_xmit;
+ ic->ic_getradiocaps = urtwn_getradiocaps;
/* Shouldn't do it, but call vap_create??? */
@@ -529,6 +550,8 @@
/* Debug all! NNN */
vap->iv_debug = IEEE80211_MSG_ANY;
+ printf ("Initial vap->iv_flags is 0x%lx\n", (long)vap->iv_flags);
+
bpf_attach2(vap->iv_ifp, DLT_IEEE802_11_RADIO,
sizeof(struct ieee80211_frame) + IEEE80211_RADIOTAP_HDRLEN,
&sc->sc_drvbpf);
@@ -549,7 +572,6 @@
aprint_error_dev(self, "couldn't establish power handler\n");
SET(sc->sc_flags, URTWN_FLAG_ATTACHED);
-printf ("urtwn: Finished attach.\n");
return;
fail:
@@ -576,6 +598,8 @@
if (ISSET(sc->sc_flags, URTWN_FLAG_ATTACHED)) {
usb_rem_task(sc->sc_udev, &sc->sc_task);
+ // urtwn_stop(...) ??
+ // vap_detach(...) ??
ieee80211_ifdetach(&sc->sc_ic);
@@ -592,6 +616,7 @@
mutex_destroy(&sc->sc_write_mtx);
mutex_destroy(&sc->sc_fwcmd_mtx);
+ printf ("sc_tx_mtx destroy\n");
mutex_destroy(&sc->sc_tx_mtx);
mutex_destroy(&sc->sc_rx_mtx);
mutex_destroy(&sc->sc_task_mtx);
@@ -736,6 +761,7 @@
for (size_t j = 0; j < sc->rx_npipe; j++) {
TAILQ_INIT(&sc->rx_free_list[j]);
for (i = 0; i < URTWN_RX_LIST_COUNT; i++) {
+ printf ("alloc rx_data[%ld][%ld]\n", j, i);
data = &sc->rx_data[j][i];
data->sc = sc; /* Backpointer for callbacks. */
@@ -785,6 +811,7 @@
DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
+ printf ("enter sc_tx_mtx, adr is 0x%lx\n", (long)&sc->sc_tx_mtx);
mutex_enter(&sc->sc_tx_mtx);
for (size_t j = 0; j < sc->tx_npipe; j++) {
TAILQ_INIT(&sc->tx_free_list[j]);
@@ -810,11 +837,14 @@
}
}
mutex_exit(&sc->sc_tx_mtx);
+ printf ("exit sc_tx_mtx\n");
return 0;
fail:
urtwn_free_tx_list(sc);
mutex_exit(&sc->sc_tx_mtx);
+ printf ("exit sc_tx_mtx\n");
+ printf ("Out of urtwn_alloc_tx_list with error.\n");
return error;
}
@@ -1532,18 +1562,16 @@
* Initialize rate adaptation in firmware.
*/
static int
-urtwn_ra_init(struct urtwn_softc *sc)
+urtwn_ra_init(struct ieee80211vap *vap)
{
static const uint8_t map[] = {
2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108
};
- struct ieee80211com *ic = &sc->sc_ic;
-#ifdef notyet
- struct ieee80211_node *ni = ic->ic_bss; */
+ struct ieee80211com *ic = vap->iv_ic;
+ struct urtwn_softc *sc = ic->ic_softc;
+ struct ieee80211_node *ni = vap->iv_bss;
struct ieee80211_rateset *rs = &ni->ni_rates;
-#else
- struct ieee80211_rateset *rs = ic->ic_sup_rates;
-#endif
+
struct r92c_fw_cmd_macid_cfg cmd;
uint32_t rates, basicrates;
uint32_t mask, rrsr_mask, rrsr_rate;
@@ -1592,14 +1620,14 @@
device_xname(sc->sc_dev), __func__, mode, rates, basicrates,
maxrate, maxbasicrate));
-//NNN if (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE) {
+ if (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE) {
maxbasicrate |= R92C_RATE_SHORTGI;
maxrate |= R92C_RATE_SHORTGI;
-//NNN }
+ }
/* Set rates mask for group addressed frames. */
cmd.macid = URTWN_MACID_BC | URTWN_MACID_VALID;
-//NNN if (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)
+ if (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)
cmd.macid |= URTWN_MACID_SHORTGI;
mask = (mode << 28) | basicrates;
@@ -1620,7 +1648,7 @@
/* Set rates mask for unicast frames. */
cmd.macid = URTWN_MACID_BSS | URTWN_MACID_VALID;
-//NNN if (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)
+ if (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE)
cmd.macid |= URTWN_MACID_SHORTGI;
mask = (mode << 28) | rates;
@@ -1697,8 +1725,8 @@
static void
urtwn_tsf_sync_enable(struct urtwn_softc *sc)
{
-#ifdef notyet
- struct ieee80211_node *ni = sc->sc_ic.ic_bss;
+ struct ieee80211vap *vap = TAILQ_FIRST(&sc->sc_ic.ic_vaps);
+ struct ieee80211_node *ni = vap->iv_bss;
uint64_t tsf;
DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
@@ -1723,7 +1751,6 @@
urtwn_write_1(sc, R92C_BCN_CTRL,
urtwn_read_1(sc, R92C_BCN_CTRL) | R92C_BCN_CTRL_EN_BCN);
-#endif
}
static void
@@ -1781,6 +1808,7 @@
return;
/* Do it in a process context. */
+ printf ("Doing a urtwn_calib_to via do_async...\n");
urtwn_do_async(sc, urtwn_calib_to_cb, vap, sizeof(struct ieee80211vap *));
}
@@ -1857,7 +1885,8 @@
ni->ni_txrate = 0;
}
-static __unused int
+#if OLDSTUFF
+static int
urtwn_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
{
struct urtwn_softc *sc = vap->iv_ic->ic_softc;
@@ -2024,6 +2053,7 @@
/* Start periodic scan. */
if (!sc->sc_dying)
callout_schedule(&sc->sc_scan_to, hz / 5);
+ printf ("Finished to scan code\n");
break;
case IEEE80211_S_AUTH:
@@ -2054,6 +2084,7 @@
break;
case IEEE80211_S_RUN:
+ printf ("if_urtwn: going to new state S_RUN\n");
ni = vap->iv_bss;
/* XXX: Set 20MHz mode */
@@ -2156,7 +2187,7 @@
ISSET(sc->chip, URTWN_CHIP_92EU))
ni->ni_txrate = ni->ni_rates.rs_nrates - 1;
else
- urtwn_ra_init(sc);
+ urtwn_ra_init(vap);
Home |
Main Index |
Thread Index |
Old Index