Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/dev/usb Adapt to latest usbwifi changes
details: https://anonhg.NetBSD.org/src-all/rev/b6a410aad94e
branches: trunk
changeset: 371104:b6a410aad94e
user: Martin Husemann <martin%NetBSD.org@localhost>
date: Tue Feb 08 21:07:14 2022 +0100
description:
Adapt to latest usbwifi changes
diffstat:
sys/dev/usb/if_urtwn.c | 212 ++++++++++++++++++++++-----------------------
sys/dev/usb/if_urtwnvar.h | 6 +-
2 files changed, 108 insertions(+), 110 deletions(-)
diffs (truncated from 779 to 300 lines):
diff -r 337942b359b7 -r b6a410aad94e sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c Tue Feb 08 21:04:15 2022 +0100
+++ b/sys/dev/usb/if_urtwn.c Tue Feb 08 21:07:14 2022 +0100
@@ -65,7 +65,6 @@
#include <machine/endian.h>
#include <sys/intr.h>
-#include <net/bpf.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_dl.h>
@@ -335,7 +334,6 @@
static void urtwn_temp_calib(struct urtwn_softc *);
static void urtwn_newassoc(struct ieee80211_node *, int);
static void urtwn_delay_ms(struct urtwn_softc *, int ms);
-static void urtwn_chip_stop(struct urtwn_softc *);
/* Functions for wifi refresh */
static struct ieee80211vap *
urtwn_vap_create(struct ieee80211com *,
@@ -386,7 +384,7 @@
urtwn_attach( device_t parent, device_t self, void *aux)
{
struct urtwn_softc *sc = device_private(self);
- struct ieee80211com *ic = &sc->sc_uw.uw_ic;
+ struct ieee80211com *ic = usbwifi_ic(&sc->sc_uw);
struct usb_attach_arg *uaa = aux;
char *devinfop;
const struct urtwn_dev *dev;
@@ -433,12 +431,10 @@
(void) usbd_do_request(sc->sc_uw.uw_udev, &req, 0);
+ cv_init(&sc->sc_task_cv, "urtwntsk");
mutex_init(&sc->sc_task_mtx, MUTEX_DEFAULT, IPL_NET);
- usbwifi_attach(&sc->sc_uw, "urtwndet");
-
- usbwifi_lock_core(&sc->sc_uw);
- usb_init_task(&sc->sc_task, urtwn_task, sc, 0);
+ usbwifi_attach(&sc->sc_uw);
/* NNN make these callouts use a vap ... in vap create??? */
callout_init(&sc->sc_calib_to, CALLOUT_MPSAFE);
@@ -504,6 +500,9 @@
num_rx, num_rx > 1 ? "s" : "",
num_tx, num_tx > 1 ? "s" : "");
+ /* use usbwifi tick instead? */
+ usb_init_task(&sc->sc_task, urtwn_task, sc, 0);
+
/* Set device capabilities. */
ic->ic_caps =
IEEE80211_C_STA | /* station mode */
@@ -569,14 +568,9 @@
ic->ic_th = &sc->sc_txtapu.th.wt_ihdr;
usbwifi_attach_finalize(&sc->sc_uw);
-
- usbwifi_unlock_core(&sc->sc_uw);
-
return;
fail:
- usbwifi_set_dying(&sc->sc_uw, true);
- usbwifi_unlock_core(&sc->sc_uw);
aprint_error_dev(self, "attach failed\n");
}
@@ -584,24 +578,21 @@
urtwn_detach(device_t self, int flags)
{
struct urtwn_softc *sc = device_private(self);
+ int err;
URTWNHIST_FUNC(); URTWNHIST_CALLED();
- usbwifi_set_dying(&sc->sc_uw, true);
+ err = usbwifi_detach(self, flags);
+ if (err)
+ return err;
callout_halt(&sc->sc_calib_to, NULL);
-
- usbwifi_detach(self, flags);
-
- if (ISSET(sc->sc_uw.uw_flags, URTWN_FLAG_ATTACHED)) {
- usb_rem_task_wait(sc->sc_uw.uw_udev, &sc->sc_task, USB_TASKQ_DRIVER,
- NULL);
- }
-
+ if (sc->sc_uw.uw_pri != NULL)
+ usb_rem_task_wait(sc->sc_uw.uw_udev, &sc->sc_task,
+ USB_TASKQ_DRIVER, NULL);
callout_destroy(&sc->sc_calib_to);
-
+ cv_destroy(&sc->sc_task_cv);
mutex_destroy(&sc->sc_task_mtx);
-
return 0;
}
@@ -678,8 +669,9 @@
urtwn_task(void *arg)
{
struct urtwn_softc *sc = arg;
- struct ieee80211com *ic = &sc->sc_uw.uw_ic;
+ struct ieee80211com *ic = usbwifi_ic(&sc->sc_uw);
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+/* XXX VAP is wrong */
struct urtwn_host_cmd_ring *ring = &sc->cmdq;
struct urtwn_host_cmd *cmd;
int s;
@@ -722,8 +714,8 @@
ring->queued--;
ring->next = (ring->next + 1) % URTWN_HOST_CMD_RING_COUNT;
}
+ cv_broadcast(&sc->sc_task_cv);
mutex_spin_exit(&sc->sc_task_mtx);
- wakeup(&sc->cmdq);
splx(s);
}
@@ -764,8 +756,10 @@
URTWNHIST_FUNC(); URTWNHIST_CALLED();
/* Wait for all queued asynchronous commands to complete. */
+ mutex_spin_enter(&sc->sc_task_mtx);
while (sc->cmdq.queued > 0)
- tsleep(&sc->cmdq, 0, "endtask", 0);
+ cv_wait(&sc->sc_task_cv, &sc->sc_task_mtx);
+ mutex_spin_exit(&sc->sc_task_mtx);
}
static int
@@ -776,7 +770,7 @@
usbd_status error;
URTWNHIST_FUNC(); URTWNHIST_CALLED();
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
req.bRequest = R92C_REQ_REGS;
@@ -848,7 +842,7 @@
usbd_status error;
URTWNHIST_FUNC(); URTWNHIST_CALLED();
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
req.bmRequestType = UT_READ_VENDOR_DEVICE;
req.bRequest = R92C_REQ_REGS;
@@ -922,7 +916,12 @@
DPRINTFN(DBG_REG, "id=%jd, buf=%#jx, len=%jd", id, (intptr_t)buf,
len, 0);
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
+ if (!ISSET(sc->sc_uw.uw_flags, URTWN_FLAG_FWREADY)) {
+ DPRINTFN(DBG_INIT, "fw not running, uw_flags=%jx",
+ sc->sc_uw.uw_flags, 0, 0, 0);
+ return EAGAIN;
+ }
fwcur = sc->fwcur;
sc->fwcur = (sc->fwcur + 1) % R92C_H2C_NBOX;
@@ -953,13 +952,13 @@
&cp[1], 2);
urtwn_write_4(sc, R92C_HMEBOX(fwcur),
cp[0] + (cp[3] << 8) + (cp[4] << 16) +
- (cp[5] << 24));
+ ((uint32_t)cp[5] << 24));
} else {
urtwn_write_region(sc, R92E_HMEBOX_EXT(fwcur),
&cp[4], 2);
urtwn_write_4(sc, R92C_HMEBOX(fwcur),
cp[0] + (cp[1] << 8) + (cp[2] << 16) +
- (cp[3] << 24));
+ ((uint32_t)cp[3] << 24));
}
} else {
urtwn_write_region(sc, R92C_HMEBOX(fwcur), cp, len);
@@ -1038,7 +1037,7 @@
{
int ntries;
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
urtwn_write_4(sc, R92C_LLT_INIT,
SM(R92C_LLT_INIT_OP, R92C_LLT_INIT_OP_WRITE) |
@@ -1062,7 +1061,7 @@
uint32_t reg;
int ntries;
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
reg = urtwn_read_4(sc, R92C_EFUSE_CTRL);
reg = RW(reg, R92C_EFUSE_CTRL_ADDR, addr);
@@ -1094,7 +1093,7 @@
URTWNHIST_FUNC(); URTWNHIST_CALLED();
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
urtwn_efuse_switch_power(sc);
@@ -1271,12 +1270,12 @@
static void
urtwn_read_rom(struct urtwn_softc *sc)
{
- struct ieee80211com *ic = &sc->sc_uw.uw_ic;
+ struct ieee80211com *ic = usbwifi_ic(&sc->sc_uw);
struct r92c_rom *rom = &sc->rom;
URTWNHIST_FUNC(); URTWNHIST_CALLED();
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
/* Read full ROM image. */
urtwn_efuse_read(sc);
@@ -1303,7 +1302,7 @@
static void
urtwn_r88e_read_rom(struct urtwn_softc *sc)
{
- struct ieee80211com *ic = &sc->sc_uw.uw_ic;
+ struct ieee80211com *ic = usbwifi_ic(&sc->sc_uw);
uint8_t *rom = sc->r88e_rom;
uint32_t reg;
uint16_t addr = 0;
@@ -1312,7 +1311,7 @@
URTWNHIST_FUNC(); URTWNHIST_CALLED();
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
off = 0;
urtwn_efuse_switch_power(sc);
@@ -1396,7 +1395,7 @@
URTWNHIST_FUNC(); URTWNHIST_CALLED();
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
/* Get normal and basic rates mask. */
rates = basicrates = 1;
@@ -1490,7 +1489,7 @@
static int
urtwn_get_nettype(struct urtwn_softc *sc)
{
- struct ieee80211com *ic = &sc->sc_uw.uw_ic;
+ struct ieee80211com *ic = usbwifi_ic(&sc->sc_uw);
int type;
URTWNHIST_FUNC(); URTWNHIST_CALLED();
@@ -1520,7 +1519,7 @@
URTWNHIST_FUNC();
URTWNHIST_CALLARGS("type=%jd", type, 0, 0, 0);
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
reg = urtwn_read_1(sc, R92C_CR + 2) & 0x0c;
urtwn_write_1(sc, R92C_CR + 2, reg | type);
@@ -1530,12 +1529,13 @@
urtwn_tsf_sync_enable(struct urtwn_softc *sc)
{
struct ieee80211vap *vap = TAILQ_FIRST(&sc->sc_uw.uw_ic.ic_vaps);
+/* XXX VAP is wrong */
struct ieee80211_node *ni = vap->iv_bss;
uint64_t tsf;
URTWNHIST_FUNC(); URTWNHIST_CALLED();
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
/* Enable TSF synchronization. */
urtwn_write_1(sc, R92C_BCN_CTRL,
@@ -1565,7 +1565,7 @@
URTWNHIST_FUNC();
URTWNHIST_CALLARGS("led=%jd, on=%jd", led, on, 0, 0);
- usbwifi_isowned_core(&sc->sc_uw);
+ usbwifi_isowned_ic(&sc->sc_uw);
if (led == URTWN_LED_LINK) {
if (ISSET(sc->chip, URTWN_CHIP_92EU)) {
@@ -1605,6 +1605,7 @@
{
struct urtwn_softc *sc = arg;
struct ieee80211vap *vap = TAILQ_FIRST(&(sc->sc_uw.uw_ic.ic_vaps));
+/* XXX VAP is wrong */
URTWNHIST_FUNC(); URTWNHIST_CALLED();
Home |
Main Index |
Thread Index |
Old Index