Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/dev/pci Convert to new worldorder
details: https://anonhg.NetBSD.org/src-all/rev/80f1d3b6433c
branches: trunk
changeset: 951807:80f1d3b6433c
user: Martin Husemann <martin%NetBSD.org@localhost>
date: Fri Sep 25 19:35:56 2020 +0200
description:
Convert to new worldorder
diffstat:
sys/dev/pci/if_rtwn.c | 611 ++++++++++++++++++++++++----------------------
sys/dev/pci/if_rtwnreg.h | 21 +-
2 files changed, 335 insertions(+), 297 deletions(-)
diffs (truncated from 1239 to 300 lines):
diff -r 6581880db7ad -r 80f1d3b6433c sys/dev/pci/if_rtwn.c
--- a/sys/dev/pci/if_rtwn.c Fri Sep 25 19:35:32 2020 +0200
+++ b/sys/dev/pci/if_rtwn.c Fri Sep 25 19:35:56 2020 +0200
@@ -29,6 +29,7 @@
#include <sys/sockio.h>
#include <sys/mbuf.h>
#include <sys/kernel.h>
+#include <sys/kmem.h>
#include <sys/socket.h>
#include <sys/systm.h>
#include <sys/callout.h>
@@ -52,6 +53,7 @@
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_radiotap.h>
+#include <net80211/ieee80211_regdomain.h>
#include <dev/firmload.h>
@@ -63,10 +65,11 @@
#include <dev/ic/rtwn_data.h>
#include <dev/pci/if_rtwnreg.h>
+#define RTWN_DEBUG 1
#ifdef RTWN_DEBUG
#define DPRINTF(x) do { if (rtwn_debug) printf x; } while (0)
#define DPRINTFN(n, x) do { if (rtwn_debug >= (n)) printf x; } while (0)
-int rtwn_debug = 0;
+int rtwn_debug = 3;
#else
#define DPRINTF(x)
#define DPRINTFN(n, x)
@@ -125,8 +128,7 @@
static int rtwn_read_chipid(struct rtwn_softc *);
static void rtwn_efuse_switch_power(struct rtwn_softc *);
static void rtwn_read_rom(struct rtwn_softc *);
-static int rtwn_media_change(struct ifnet *);
-static int rtwn_ra_init(struct rtwn_softc *);
+static int rtwn_ra_init(struct ieee80211vap *vap);
static int rtwn_get_nettype(struct rtwn_softc *);
static void rtwn_set_nettype0_msr(struct rtwn_softc *, uint8_t);
static void rtwn_tsf_sync_enable(struct rtwn_softc *);
@@ -134,20 +136,23 @@
static void rtwn_calib_to(void *);
static void rtwn_next_scan(void *);
static void rtwn_newassoc(struct ieee80211_node *, int);
-static int rtwn_reset(struct ifnet *);
-static int rtwn_newstate(struct ieee80211com *, enum ieee80211_state,
+static void rtwn_parent(struct ieee80211com *);
+static int rtwn_transmit(struct ieee80211com *ic, struct mbuf *m);
+static int rtwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
+ const struct ieee80211_bpf_params *bpfp);
+static int rtwn_newstate(struct ieee80211vap *, enum ieee80211_state,
int);
+static void rtwn_scan_start(struct ieee80211com *ic);
+static void rtwn_scan_end(struct ieee80211com *ic);
static int rtwn_wme_update(struct ieee80211com *);
static void rtwn_update_avgrssi(struct rtwn_softc *, int, int8_t);
static int8_t rtwn_get_rssi(struct rtwn_softc *, int, void *);
static void rtwn_rx_frame(struct rtwn_softc *, struct r92c_rx_desc_pci *,
struct rtwn_rx_data *, int);
-static int rtwn_tx(struct rtwn_softc *, struct mbuf *,
- struct ieee80211_node *);
static void rtwn_tx_done(struct rtwn_softc *, int);
-static void rtwn_start(struct ifnet *);
-static void rtwn_watchdog(struct ifnet *);
-static int rtwn_ioctl(struct ifnet *, u_long, void *);
+static void rtwn_start(struct rtwn_softc *);
+static void rtwn_watchdog(void *);
+// static int rtwn_ioctl(struct ifnet *, u_long, void *);
static int rtwn_power_on(struct rtwn_softc *);
static int rtwn_llt_init(struct rtwn_softc *);
static void rtwn_fw_reset(struct rtwn_softc *);
@@ -167,17 +172,35 @@
uint16_t[]);
static void rtwn_set_txpower(struct rtwn_softc *,
struct ieee80211_channel *, struct ieee80211_channel *);
-static void rtwn_set_chan(struct rtwn_softc *,
- struct ieee80211_channel *, struct ieee80211_channel *);
+static void rtwn_set_chan(struct ieee80211com *ic);
static void rtwn_iq_calib(struct rtwn_softc *);
static void rtwn_lc_calib(struct rtwn_softc *);
static void rtwn_temp_calib(struct rtwn_softc *);
-static int rtwn_init(struct ifnet *);
-static void rtwn_init_task(void *);
-static void rtwn_stop(struct ifnet *, int);
+static int rtwn_init(struct rtwn_softc *);
+static void rtwn_stop(struct rtwn_softc *);
static int rtwn_intr(void *);
static void rtwn_softintr(void *);
+static struct ieee80211vap *
+rtwn_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ],
+ int unit, enum ieee80211_opmode opmode, int flags,
+ const uint8_t bssid[IEEE80211_ADDR_LEN],
+ const uint8_t macaddr[IEEE80211_ADDR_LEN]);
+static void
+rtwn_vap_delete(struct ieee80211vap *vap);
+static void
+rtwn_get_radiocaps(struct ieee80211com *ic,
+ int maxchans, int *nchans, struct ieee80211_channel chans[]);
+
+/*
+ * We ovveride the VAP's newstate method, so need to save the old
+ * function pointer for each VAP.
+ */
+struct rtwn_vap {
+ struct ieee80211vap vap;
+ int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int);
+};
+
/* Aliases. */
#define rtwn_bb_write rtwn_write_4
#define rtwn_bb_read rtwn_read_4
@@ -213,7 +236,6 @@
struct rtwn_softc *sc = device_private(self);
struct pci_attach_args *pa = aux;
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = GET_IFP(sc);
int i, error;
pcireg_t memtype;
const char *intrstr;
@@ -226,13 +248,14 @@
pci_aprint_devinfo(pa, NULL);
- callout_init(&sc->scan_to, 0);
- callout_setfunc(&sc->scan_to, rtwn_next_scan, sc);
- callout_init(&sc->calib_to, 0);
- callout_setfunc(&sc->calib_to, rtwn_calib_to, sc);
+ callout_init(&sc->sc_scan_to, 0);
+ callout_setfunc(&sc->sc_scan_to, rtwn_next_scan, sc);
+ callout_init(&sc->sc_calib_to, 0);
+ callout_setfunc(&sc->sc_calib_to, rtwn_calib_to, sc);
+ callout_init(&sc->sc_watchdog_to, 0);
+ callout_setfunc(&sc->sc_watchdog_to, rtwn_watchdog, sc);
sc->sc_soft_ih = softint_establish(SOFTINT_NET, rtwn_softintr, sc);
- sc->init_task = softint_establish(SOFTINT_NET, rtwn_init_task, sc);
/* Power up the device */
pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0);
@@ -307,18 +330,28 @@
aprint_normal_dev(self, "MAC/BB RTL%s, RF 6052 %dT%dR, address %s\n",
(sc->chip & RTWN_CHIP_92C) ? "8192CE" : "8188CE",
- sc->ntxchains, sc->nrxchains, ether_sprintf(ic->ic_myaddr));
+ sc->ntxchains, sc->nrxchains, ether_sprintf(ic->ic_macaddr));
+
+ /* setup device name and general props */
+ ic->ic_name = device_xname(self);
+ ic->ic_txstream = sc->ntxchains;
+ ic->ic_rxstream = sc->nrxchains;
+ ic->ic_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+
+ /* init radio send queue */
+ sc->sc_sendq.ifq_maxlen = 32;
+ IFQ_LOCK_INIT(&sc->sc_sendq);
/*
* Setup the 802.11 device.
*/
- ic->ic_ifp = ifp;
+ ic->ic_softc = sc;
ic->ic_phytype = IEEE80211_T_OFDM; /* Not only, but not used. */
ic->ic_opmode = IEEE80211_M_STA; /* Default to BSS mode. */
- ic->ic_state = IEEE80211_S_INIT;
/* Set device capabilities. */
ic->ic_caps =
+ IEEE80211_C_STA | /* Station (AP) mode supported. */
IEEE80211_C_MONITOR | /* Monitor mode supported. */
IEEE80211_C_IBSS | /* IBSS mode supported */
IEEE80211_C_HOSTAP | /* HostAp mode supported */
@@ -336,55 +369,25 @@
for (i = 0; i < sc->nrxchains; i++)
ic->ic_sup_mcs[i] = 0xff;
#endif
-
- /* Set supported .11b and .11g rates. */
- ic->ic_sup_rates[IEEE80211_MODE_11B] = ieee80211_std_rateset_11b;
- ic->ic_sup_rates[IEEE80211_MODE_11G] = ieee80211_std_rateset_11g;
-
- /* Set supported .11b and .11g channels (1 through 14). */
- for (i = 1; i <= 14; i++) {
- ic->ic_channels[i].ic_freq =
- ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ);
- ic->ic_channels[i].ic_flags =
- IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM |
- IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ;
- }
-
- ifp->if_softc = sc;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_init = rtwn_init;
- ifp->if_ioctl = rtwn_ioctl;
- ifp->if_start = rtwn_start;
- ifp->if_watchdog = rtwn_watchdog;
- IFQ_SET_READY(&ifp->if_snd);
- memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
-
- error = if_initialize(ifp);
- if (error != 0) {
- ifp->if_softc = NULL; /* For rtwn_detach() */
- aprint_error_dev(sc->sc_dev, "if_initialize failed(%d)\n",
- error);
- goto fail;
- }
- ieee80211_ifattach(ic);
- /* Use common softint-based if_input */
- ifp->if_percpuq = if_percpuq_create(ifp);
- if_register(ifp);
+ rtwn_get_radiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
+ ic->ic_channels);
+
+ /* Initialize the IEEE802.11 device */
+ ieee80211_ifattach(ic);
/* override default methods */
+ ic->ic_vap_create = rtwn_vap_create;
+ ic->ic_vap_delete = rtwn_vap_delete;
+ ic->ic_set_channel = rtwn_set_chan;
+ ic->ic_getradiocaps = rtwn_get_radiocaps;
+ ic->ic_parent = rtwn_parent;
+ ic->ic_scan_start = rtwn_scan_start;
+ ic->ic_scan_end = rtwn_scan_end;
+ ic->ic_transmit = rtwn_transmit;
+ ic->ic_raw_xmit = rtwn_raw_xmit;
ic->ic_newassoc = rtwn_newassoc;
- ic->ic_reset = rtwn_reset;
ic->ic_wme.wme_update = rtwn_wme_update;
- /* Override state transition machine. */
- sc->sc_newstate = ic->ic_newstate;
- ic->ic_newstate = rtwn_newstate;
- ieee80211_media_init(ic, rtwn_media_change, ieee80211_media_status);
-
- bpf_attach2(ifp, DLT_IEEE802_11_RADIO,
- sizeof(struct ieee80211_frame) + IEEE80211_RADIOTAP_HDRLEN,
- &sc->sc_drvbpf);
-
sc->sc_rxtap_len = sizeof(sc->sc_rxtapu);
sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len);
sc->sc_rxtap.wr_ihdr.it_present = htole32(RTWN_RX_RADIOTAP_PRESENT);
@@ -393,15 +396,11 @@
sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len);
sc->sc_txtap.wt_ihdr.it_present = htole32(RTWN_TX_RADIOTAP_PRESENT);
+ SET(sc->sc_flags, RTWN_FLAG_ATTACHED);
ieee80211_announce(ic);
if (!pmf_device_register(self, NULL, NULL))
aprint_error_dev(self, "couldn't establish power handler\n");
-
- return;
-
-fail:
- rtwn_detach(self, 0);
}
static int
@@ -409,22 +408,18 @@
{
struct rtwn_softc *sc = device_private(self);
struct ieee80211com *ic = &sc->sc_ic;
- struct ifnet *ifp = GET_IFP(sc);
int s, i;
- callout_stop(&sc->scan_to);
- callout_stop(&sc->calib_to);
+ callout_stop(&sc->sc_scan_to);
+ callout_stop(&sc->sc_calib_to);
+ callout_stop(&sc->sc_watchdog_to);
s = splnet();
- if (ifp->if_softc != NULL) {
- rtwn_stop(ifp, 0);
-
+ if (ISSET(sc->sc_flags, RTWN_FLAG_ATTACHED)) {
pmf_device_deregister(self);
- ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
- bpf_detach(ifp);
+
ieee80211_ifdetach(ic);
- if_detach(ifp);
}
/* Free Tx/Rx buffers. */
@@ -434,11 +429,10 @@
splx(s);
- callout_destroy(&sc->scan_to);
- callout_destroy(&sc->calib_to);
-
- if (sc->init_task != NULL)
- softint_disestablish(sc->init_task);
+ callout_destroy(&sc->sc_scan_to);
+ callout_destroy(&sc->sc_calib_to);
Home |
Main Index |
Thread Index |
Old Index