From dc24979338a9c26cf9963899768e21a9c95d30f2 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 11 May 2016 22:51:08 -0700 Subject: [PATCH] wlan - Sync dev/netif/ath from FreeBSD part 5/N * Adjustments relative to previous commit to compile ath on DragonFly. * Tested with chromebook. --- sys/dev/netif/ath/ath/if_ath.c | 423 +++++++++++++++++++---- sys/dev/netif/ath/ath/if_ath_ahb.c | 50 ++- sys/dev/netif/ath/ath/if_ath_alq.c | 22 +- sys/dev/netif/ath/ath/if_ath_beacon.c | 44 ++- sys/dev/netif/ath/ath/if_ath_btcoex.c | 18 +- sys/dev/netif/ath/ath/if_ath_debug.c | 73 ++-- sys/dev/netif/ath/ath/if_ath_debug.h | 9 +- sys/dev/netif/ath/ath/if_ath_descdma.c | 61 ++-- sys/dev/netif/ath/ath/if_ath_ioctl.c | 46 ++- sys/dev/netif/ath/ath/if_ath_keycache.c | 30 +- sys/dev/netif/ath/ath/if_ath_led.c | 23 +- sys/dev/netif/ath/ath/if_ath_lna_div.c | 26 +- sys/dev/netif/ath/ath/if_ath_misc.h | 1 - sys/dev/netif/ath/ath/if_ath_pci.c | 41 ++- sys/dev/netif/ath/ath/if_ath_rx.c | 64 ++-- sys/dev/netif/ath/ath/if_ath_rx_edma.c | 71 ++-- sys/dev/netif/ath/ath/if_ath_spectral.c | 24 +- sys/dev/netif/ath/ath/if_ath_sysctl.c | 78 +++-- sys/dev/netif/ath/ath/if_ath_tdma.c | 48 +-- sys/dev/netif/ath/ath/if_ath_tx.c | 308 ++++++++++++++++- sys/dev/netif/ath/ath/if_ath_tx_edma.c | 60 ++-- sys/dev/netif/ath/ath/if_ath_tx_ht.c | 28 +- sys/dev/netif/ath/ath/if_athvar.h | 183 ++++++---- sys/dev/netif/ath/ath_dfs/null/dfs_null.c | 61 +++- sys/dev/netif/ath/ath_hal/Makefile | 22 +- sys/dev/netif/ath/ath_hal/ah.c | 9 +- sys/dev/netif/ath/ath_hal/ah.h | 76 ++-- sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c | 5 +- sys/dev/netif/ath/ath_hal/ah_eeprom_v4k.c | 6 +- sys/dev/netif/ath/ath_hal/ah_internal.h | 8 +- sys/dev/netif/ath/ath_hal/ah_osdep.c | 114 ++++-- sys/dev/netif/ath/ath_hal/ah_osdep.h | 14 +- sys/dev/netif/ath/ath_hal/ah_regdomain.c | 4 +- sys/dev/netif/ath/ath_hal/ar5212/ar5212.h | 2 +- sys/dev/netif/ath/ath_hal/ar5416/ar5416_reset.c | 2 + sys/dev/netif/ath/ath_hal/ar5416/ar5416reg.h | 2 +- sys/dev/netif/ath/ath_hal/ar9002/ar9280_attach.c | 2 +- sys/dev/netif/ath/ath_hal/ar9002/ar9280_olc.c | 2 +- sys/dev/netif/ath/ath_hal/ar9002/ar9285_btcoex.c | 3 +- sys/dev/netif/ath/ath_rate/amrr/amrr.c | 61 +++- sys/dev/netif/ath/ath_rate/onoe/onoe.c | 61 +++- sys/dev/netif/ath/ath_rate/sample/sample.c | 101 +++++- sys/dev/netif/ath/ath_rate/sample/sample.h | 4 +- 43 files changed, 1673 insertions(+), 617 deletions(-) diff --git a/sys/dev/netif/ath/ath/if_ath.c b/sys/dev/netif/ath/ath/if_ath.c index 87daaf3589..012387d606 100644 --- a/sys/dev/netif/ath/ath/if_ath.c +++ b/sys/dev/netif/ath/ath/if_ath.c @@ -30,6 +30,10 @@ #include __FBSDID("$FreeBSD$"); +#if defined(__DragonFly__) +#define CTLFLAG_RWTUN CTLFLAG_RW +#endif + /* * Driver for the Atheros Wireless LAN controller. * @@ -68,9 +72,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* for mp_ncpus */ +#if defined(__DragonFly__) +/* empty */ +#else +#include /* for mp_ncpus */ #include +#endif #include #include @@ -80,14 +88,17 @@ __FBSDID("$FreeBSD$"); #include #include #include +#if defined(__DragonFly__) +#include +#endif -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #include @@ -97,34 +108,34 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include /* XXX for softled */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef ATH_TX99_DIAG -#include +#include #endif #ifdef ATH_DEBUG_ALQ -#include +#include #endif /* @@ -220,7 +231,11 @@ static int ath_node_set_tim(struct ieee80211_node *, int); static void ath_node_recv_pspoll(struct ieee80211_node *, struct mbuf *); #ifdef IEEE80211_SUPPORT_TDMA -#include +#include +#endif + +#if defined(__DragonFly__) +extern const char* ath_hal_ether_sprintf(const u_int8_t *mac); #endif SYSCTL_DECL(_hw_ath); @@ -242,12 +257,23 @@ SYSCTL_INT(_hw_ath, OID_AUTO, anical, CTLFLAG_RW, &ath_anicalinterval, int ath_rxbuf = ATH_RXBUF; /* # rx buffers to allocate */ SYSCTL_INT(_hw_ath, OID_AUTO, rxbuf, CTLFLAG_RWTUN, &ath_rxbuf, 0, "rx buffers allocated"); +#if defined(__DragonFly__) +TUNABLE_INT("hw.ath.rxbuf", &ath_rxbuf); +#endif + int ath_txbuf = ATH_TXBUF; /* # tx buffers to allocate */ SYSCTL_INT(_hw_ath, OID_AUTO, txbuf, CTLFLAG_RWTUN, &ath_txbuf, 0, "tx buffers allocated"); +#if defined(__DragonFly__) +TUNABLE_INT("hw.ath.txbuf", &ath_txbuf); +#endif + int ath_txbuf_mgmt = ATH_MGMT_TXBUF; /* # mgmt tx buffers to allocate */ SYSCTL_INT(_hw_ath, OID_AUTO, txbuf_mgmt, CTLFLAG_RWTUN, &ath_txbuf_mgmt, 0, "tx (mgmt) buffers allocated"); +#if defined(__DragonFly__) +TUNABLE_INT("hw.ath.txbuf_mgmt", &ath_txbuf_mgmt); +#endif int ath_bstuck_threshold = 4; /* max missed beacons */ SYSCTL_INT(_hw_ath, OID_AUTO, bstuck, CTLFLAG_RW, &ath_bstuck_threshold, @@ -528,12 +554,16 @@ ath_fetch_mac_kenv(struct ath_softc *sc, uint8_t *macaddr) * Hints would be nice but the transition to dynamic * hints/kenv doesn't happen early enough for this * to work reliably (eg on anything embedded.) - */ - snprintf(devid_str, 32, "hint.%s.%d.macaddr", + */ + ksnprintf(devid_str, 32, "hint.%s.%d.macaddr", device_get_name(sc->sc_dev), device_get_unit(sc->sc_dev)); +#if defined(__DragonFly__) + if ((local_macstr = kgetenv(devid_str)) != NULL) { +#else if ((local_macstr = kern_getenv(devid_str)) != NULL) { +#endif uint32_t tmpmac[ETHER_ADDR_LEN]; int count; int i; @@ -544,7 +574,7 @@ ath_fetch_mac_kenv(struct ath_softc *sc, uint8_t *macaddr) local_macstr); /* Extract out the MAC address */ - count = sscanf(local_macstr, "%x%*c%x%*c%x%*c%x%*c%x%*c%x", + count = ksscanf(local_macstr, "%x%*c%x%*c%x%*c%x%*c%x%*c%x", &tmpmac[0], &tmpmac[1], &tmpmac[2], &tmpmac[3], &tmpmac[4], &tmpmac[5]); @@ -555,7 +585,7 @@ ath_fetch_mac_kenv(struct ath_softc *sc, uint8_t *macaddr) macaddr[i] = tmpmac[i]; } /* Done! */ - freeenv(local_macstr); + kfreeenv(local_macstr); local_macstr = NULL; } @@ -581,6 +611,9 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid); +#if defined(__DragonFly__) + wlan_serialize_enter(); +#endif ic->ic_softc = sc; ic->ic_name = device_get_nameunit(sc->sc_dev); @@ -597,7 +630,7 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) sc->sc_eepromdata, &ah_config, &status); if (ah == NULL) { device_printf(sc->sc_dev, - "unable to attach hardware; HAL status %u\n", status); + "unable to attach hardware; HAL status %u\n", status); error = ENXIO; goto bad; } @@ -649,8 +682,8 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) sc->sc_keymax = ath_hal_keycachesize(ah); if (sc->sc_keymax > ATH_KEYMAX) { device_printf(sc->sc_dev, - "Warning, using only %u of %u key cache slots\n", - ATH_KEYMAX, sc->sc_keymax); + "Warning, using only %u of %u key cache slots\n", + ATH_KEYMAX, sc->sc_keymax); sc->sc_keymax = ATH_KEYMAX; } /* @@ -690,13 +723,13 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) error = ath_desc_alloc(sc); if (error != 0) { device_printf(sc->sc_dev, - "failed to allocate TX descriptors: %d\n", error); + "failed to allocate TX descriptors: %d\n", error); goto bad; } error = ath_txdma_setup(sc); if (error != 0) { device_printf(sc->sc_dev, - "failed to allocate TX descriptors: %d\n", error); + "failed to allocate TX descriptors: %d\n", error); goto bad; } @@ -706,19 +739,31 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) error = ath_rxdma_setup(sc); if (error != 0) { device_printf(sc->sc_dev, - "failed to allocate RX descriptors: %d\n", error); + "failed to allocate RX descriptors: %d\n", error); goto bad; } - callout_init_mtx(&sc->sc_cal_ch, &sc->sc_mtx, 0); - callout_init_mtx(&sc->sc_wd_ch, &sc->sc_mtx, 0); +#if defined(__DragonFly__) + callout_init_lk(&sc->sc_cal_ch, &sc->sc_mtx); + callout_init_lk(&sc->sc_wd_ch, &sc->sc_mtx); +#else + callout_init_mtx(&sc->sc_cal_ch, &sc->sc_mtx); + callout_init_mtx(&sc->sc_wd_ch, &sc->sc_mtx); +#endif ATH_TXBUF_LOCK_INIT(sc); +#if defined(__DragonFly__) + sc->sc_tq = taskqueue_create("ath_taskq", M_INTWAIT, + taskqueue_thread_enqueue, &sc->sc_tq); + taskqueue_start_threads(&sc->sc_tq, 1, TDPRI_KERN_DAEMON, -1, + "%s taskq", device_get_nameunit(sc->sc_dev)); +#else sc->sc_tq = taskqueue_create("ath_taskq", M_NOWAIT, taskqueue_thread_enqueue, &sc->sc_tq); taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq", - device_get_nameunit(sc->sc_dev)); + device_get_nameunit(sc->sc_dev)); +#endif TASK_INIT(&sc->sc_rxtask, 0, sc->sc_rx.recv_tasklet, sc); TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc); @@ -738,7 +783,7 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) sc->sc_bhalq = ath_beaconq_setup(sc); if (sc->sc_bhalq == (u_int) -1) { device_printf(sc->sc_dev, - "unable to setup a beacon xmit queue!\n"); + "unable to setup a beacon xmit queue!\n"); error = EIO; goto bad2; } @@ -751,8 +796,8 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) /* NB: insure BK queue is the lowest priority h/w queue */ if (!ath_tx_setup(sc, WME_AC_BK, HAL_WME_AC_BK)) { device_printf(sc->sc_dev, - "unable to setup xmit queue for %s traffic!\n", - ieee80211_wme_acnames[WME_AC_BK]); + "unable to setup xmit queue for %s traffic!\n", + ieee80211_wme_acnames[WME_AC_BK]); error = EIO; goto bad2; } @@ -836,7 +881,11 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) sc->sc_ledstate = 1; sc->sc_ledon = 0; /* low true */ sc->sc_ledidle = (2700*hz)/1000; /* 2.7sec */ +#if defined(__DragonFly__) + callout_init_mp(&sc->sc_ledtimer); +#else callout_init(&sc->sc_ledtimer, 1); +#endif /* * Don't setup hardware-based blinking. @@ -1162,7 +1211,11 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) * Check if the hardware requires PCI register serialisation. * Some of the Owl based MACs require this. */ +#if defined(__DragonFly__) + if (ncpus > 1 && +#else if (mp_ncpus > 1 && +#endif ath_hal_getcapability(ah, HAL_CAP_SERIALISE_WAR, 0, NULL) == HAL_OK) { sc->sc_ah->ah_config.ah_serialise_reg_war = 1; @@ -1302,6 +1355,10 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) ath_power_setpower(sc, HAL_PM_FULL_SLEEP); ATH_UNLOCK(sc); +#if defined(__DragonFly__) + wlan_serialize_exit(); +#endif + return 0; bad2: ath_tx_cleanup(sc); @@ -1311,7 +1368,17 @@ bad2: bad: if (ah) ath_hal_detach(ah); + +#if defined(__DragonFly__) + /* + * To work around scoping issues with CURVNET_SET/CURVNET_RESTORE.. + */ + sc->sc_invalid = 1; + wlan_serialize_exit(); +#else sc->sc_invalid = 1; +#endif + return error; } @@ -1349,7 +1416,13 @@ ath_detach(struct ath_softc *sc) ath_stop(sc); ATH_UNLOCK(sc); +#if defined(__DragonFly__) + wlan_serialize_enter(); +#endif ieee80211_ifdetach(&sc->sc_ic); +#if defined(__DragonFly__) + wlan_serialize_exit(); +#endif taskqueue_free(sc->sc_tq); #ifdef ATH_TX99_DIAG if (sc->sc_tx99 != NULL) @@ -1451,7 +1524,7 @@ ath_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, int needbeacon, error; enum ieee80211_opmode ic_opmode; - avp = malloc(sizeof(struct ath_vap), M_80211_VAP, M_WAITOK | M_ZERO); + avp = kmalloc(sizeof(struct ath_vap), M_80211_VAP, M_WAITOK | M_ZERO); needbeacon = 0; IEEE80211_ADDR_COPY(mac, mac0); @@ -1692,7 +1765,7 @@ bad2: reclaim_address(sc, mac); ath_hal_setbssidmask(sc->sc_ah, sc->sc_hwbssidmask); bad: - free(avp, M_80211_VAP); + kfree(avp, M_80211_VAP); ATH_UNLOCK(sc); return NULL; } @@ -1791,7 +1864,7 @@ ath_vap_delete(struct ieee80211vap *vap) sc->sc_swbmiss = 0; } #endif - free(avp, M_80211_VAP); + kfree(avp, M_80211_VAP); if (sc->sc_running) { /* @@ -1800,7 +1873,7 @@ ath_vap_delete(struct ieee80211vap *vap) */ if (ath_startrecv(sc) != 0) device_printf(sc->sc_dev, - "%s: unable to restart recv logic\n", __func__); + "%s: unable to restart recv logic\n", __func__); if (sc->sc_beacons) { /* restart beacons */ #ifdef IEEE80211_SUPPORT_TDMA if (sc->sc_tdma) @@ -1843,7 +1916,11 @@ ath_suspend(struct ath_softc *sc) taskqueue_block(sc->sc_tq); ATH_LOCK(sc); +#if defined(__DragonFly__) + callout_stop_sync(&sc->sc_cal_ch); +#else callout_stop(&sc->sc_cal_ch); +#endif ATH_UNLOCK(sc); /* @@ -2030,7 +2107,7 @@ ath_intr(void *arg) HAL_INT status; DPRINTF(sc, ATH_DEBUG_ANY, "%s: ic_nrunning %d sc_running %d\n", - __func__, sc->sc_ic.ic_nrunning, sc->sc_running); + __func__, sc->sc_ic.ic_nrunning, sc->sc_running); ath_hal_getisr(ah, &status); /* clear ISR */ ath_hal_intrset(ah, 0); /* disable further intr's */ ATH_PCU_UNLOCK(sc); @@ -2281,14 +2358,21 @@ ath_fatal_proc(void *arg, int pending) * are caused by DMA errors. Collect h/w state from * the hal so we can diagnose what's going on. */ +#if defined(__DragonFly__) + wlan_serialize_enter(); +#endif if (ath_hal_getfatalstate(sc->sc_ah, &sp, &len)) { KASSERT(len >= 6*sizeof(u_int32_t), ("len %u bytes", len)); state = sp; device_printf(sc->sc_dev, - "0x%08x 0x%08x 0x%08x, 0x%08x 0x%08x 0x%08x\n", state[0], - state[1] , state[2], state[3], state[4], state[5]); + "0x%08x 0x%08x 0x%08x, 0x%08x 0x%08x 0x%08x\n", + state[0], state[1] , state[2], state[3], + state[4], state[5]); } ath_reset(sc, ATH_RESET_NOLOSS); +#if defined(__DragonFly__) + wlan_serialize_exit(); +#endif } static void @@ -2391,7 +2475,7 @@ ath_bmiss_proc(void *arg, int pending) if (ath_hal_gethangstate(sc->sc_ah, 0xff, &hangs) && hangs != 0) { ath_reset(sc, ATH_RESET_NOLOSS); device_printf(sc->sc_dev, - "bb hang detected (0x%x), resetting\n", hangs); + "bb hang detected (0x%x), resetting\n", hangs); } else { ath_reset(sc, ATH_RESET_NOLOSS); ieee80211_beacon_miss(&sc->sc_ic); @@ -2462,9 +2546,9 @@ ath_init(struct ath_softc *sc) sc->sc_cur_rxchainmask); if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_FALSE, - HAL_RESET_NORMAL, &status)) { + HAL_RESET_NORMAL, &status)) { device_printf(sc->sc_dev, - "unable to reset hardware; hal status %u\n", status); + "unable to reset hardware; hal status %u\n", status); return (ENODEV); } @@ -2612,12 +2696,21 @@ ath_stop(struct ath_softc *sc) if (sc->sc_tx99 != NULL) sc->sc_tx99->stop(sc->sc_tx99); #endif +#if defined(__DragonFly__) + callout_stop_sync(&sc->sc_wd_ch); +#else callout_stop(&sc->sc_wd_ch); +#endif sc->sc_wd_timer = 0; + /* ifp->if_flags &= ~IFF_RUNNING; */ sc->sc_running = 0; if (!sc->sc_invalid) { if (sc->sc_softled) { +#if defined(__DragonFly__) + callout_stop_sync(&sc->sc_ledtimer); +#else callout_stop(&sc->sc_ledtimer); +#endif ath_hal_gpioset(ah, sc->sc_ledpin, !sc->sc_ledon); sc->sc_blinking = 0; @@ -2665,8 +2758,20 @@ ath_txrx_stop_locked(struct ath_softc *sc) sc->sc_txstart_cnt || sc->sc_intr_cnt) { if (i <= 0) break; +#if defined(__DragonFly__) + if (wlan_is_serialized()) { + wlan_serialize_exit(); + lksleep(sc, &sc->sc_pcu_mtx, 0, "ath_txrx_stop", + msecs_to_ticks(10)); + wlan_serialize_enter(); + } else { + lksleep(sc, &sc->sc_pcu_mtx, 0, "ath_txrx_stop", + msecs_to_ticks(10)); + } +#else msleep(sc, &sc->sc_pcu_mtx, 0, "ath_txrx_stop", - msecs_to_ticks(10)); + msecs_to_ticks(10)); +#endif i--; } @@ -2735,7 +2840,12 @@ ath_reset_grablock(struct ath_softc *sc, int dowait) * 1 tick is likely not enough time for long calibrations * to complete. So we should wait quite a while. */ +#if defined(__DragonFly__) + tsleep(&sc->sc_inreset_cnt, 0, + "ath_reset_grablock", (hz + 99) / 100); +#else pause("ath_reset_grablock", msecs_to_ticks(100)); +#endif i--; ATH_PCU_LOCK(sc); } while (i > 0); @@ -2839,8 +2949,8 @@ ath_reset(struct ath_softc *sc, ATH_RESET_TYPE reset_type) if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_TRUE, HAL_RESET_NORMAL, &status)) device_printf(sc->sc_dev, - "%s: unable to reset hardware; hal status %u\n", - __func__, status); + "%s: unable to reset hardware; hal status %u\n", + __func__, status); sc->sc_diversity = ath_hal_getdiversity(ah); ATH_RX_LOCK(sc); @@ -2870,7 +2980,7 @@ ath_reset(struct ath_softc *sc, ATH_RESET_TYPE reset_type) if (ath_startrecv(sc) != 0) /* restart recv */ device_printf(sc->sc_dev, - "%s: unable to start recv logic\n", __func__); + "%s: unable to start recv logic\n", __func__); /* * We may be doing a reset in response to an ioctl * that changes the channel so update any state that @@ -3162,6 +3272,10 @@ ath_transmit(struct ieee80211com *ic, struct mbuf *m) ATH_PCU_UNLOCK(sc); sc->sc_stats.ast_tx_qstop++; ATH_KTR(sc, ATH_KTR_TX, 0, "ath_start_task: OACTIVE, finish"); +#if defined(__DragonFly__) + m_freem(m); + m = NULL; /* safety */ +#endif return (ENOBUFS); /* XXX should be EINVAL or? */ } sc->sc_txstart_cnt++; @@ -3487,25 +3601,33 @@ ath_update_mcast_hw(struct ath_softc *sc) mfilt[0] = mfilt[1] = 0; TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { ifp = vap->iv_ifp; +#if defined(__DragonFly__) + /* nothing */ +#else if_maddr_rlock(ifp); +#endif TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { caddr_t dl; - uint32_t val; - uint8_t pos; + u_int32_t val; + u_int8_t pos; /* calculate XOR of eight 6bit values */ dl = LLADDR((struct sockaddr_dl *) - ifma->ifma_addr); + ifma->ifma_addr); val = le32dec(dl + 0); pos = (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ - val; + val; val = le32dec(dl + 3); pos ^= (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ - val; + val; pos &= 0x3f; mfilt[pos / 32] |= (1 << (pos % 32)); } +#if defined(__DragonFly__) + /* nothing */ +#else if_maddr_runlock(ifp); +#endif } } else mfilt[0] = mfilt[1] = ~0; @@ -3651,7 +3773,13 @@ ath_reset_proc(void *arg, int pending) #if 0 device_printf(sc->sc_dev, "%s: resetting\n", __func__); #endif +#if defined(__DragonFly__) + wlan_serialize_enter(); +#endif ath_reset(sc, ATH_RESET_NOLOSS); +#if defined(__DragonFly__) + wlan_serialize_exit(); +#endif } /* @@ -3663,6 +3791,9 @@ ath_bstuck_proc(void *arg, int pending) struct ath_softc *sc = arg; uint32_t hangs = 0; +#if defined(__DragonFly__) + wlan_serialize_enter(); +#endif if (ath_hal_gethangstate(sc->sc_ah, 0xff, &hangs) && hangs != 0) device_printf(sc->sc_dev, "bb hang detected (0x%x)\n", hangs); @@ -3672,13 +3803,15 @@ ath_bstuck_proc(void *arg, int pending) #endif device_printf(sc->sc_dev, "stuck beacon; resetting (bmiss count %u)\n", - sc->sc_bmisscount); + sc->sc_bmisscount); sc->sc_stats.ast_bstuck++; /* * This assumes that there's no simultaneous channel mode change - * occurring. */ ath_reset(sc, ATH_RESET_NOLOSS); +#if defined(__DragonFly__) + wlan_serialize_exit(); +#endif } static int @@ -3738,7 +3871,7 @@ ath_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN]) const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space; struct ath_node *an; - an = malloc(space, M_80211_NODE, M_NOWAIT|M_ZERO); + an = kmalloc(space, M_80211_NODE, M_INTWAIT | M_ZERO); if (an == NULL) { /* XXX stat+msg */ return NULL; @@ -3746,14 +3879,23 @@ ath_node_alloc(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN]) ath_rate_node_init(sc, an); /* Setup the mutex - there's no associd yet so set the name to NULL */ - snprintf(an->an_name, sizeof(an->an_name), "%s: node %p", + ksnprintf(an->an_name, sizeof(an->an_name), "%s: node %p", device_get_nameunit(sc->sc_dev), an); +#if defined(__DragonFly__) + lockinit(&an->an_mtx, an->an_name, 0, 0); +#else mtx_init(&an->an_mtx, an->an_name, NULL, MTX_DEF); +#endif /* XXX setup ath_tid */ ath_tx_tid_init(sc, an); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE, "%s: %s: an %p\n", __func__, + ath_hal_ether_sprintf(mac), an); +#else DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: an %p\n", __func__, mac, ":", an); +#endif return &an->an_node; } @@ -3763,8 +3905,13 @@ ath_node_cleanup(struct ieee80211_node *ni) struct ieee80211com *ic = ni->ni_ic; struct ath_softc *sc = ic->ic_softc; +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE, "%s: %s: an %p\n", __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), ATH_NODE(ni)); +#else DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: an %p\n", __func__, ni->ni_macaddr, ":", ATH_NODE(ni)); +#endif /* Cleanup ath_tid, free unused bufs, unlink bufs in TXQ */ ath_tx_node_flush(sc, ATH_NODE(ni)); @@ -3778,9 +3925,18 @@ ath_node_free(struct ieee80211_node *ni) struct ieee80211com *ic = ni->ni_ic; struct ath_softc *sc = ic->ic_softc; +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE, "%s: %s: an %p\n", __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), ATH_NODE(ni)); +#else DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: an %p\n", __func__, ni->ni_macaddr, ":", ATH_NODE(ni)); +#endif +#if defined(__DragonFly__) + lockuninit(&ATH_NODE(ni)->an_mtx); +#else mtx_destroy(&ATH_NODE(ni)->an_mtx); +#endif sc->sc_node_free(ni); } @@ -5165,7 +5321,7 @@ ath_chan_set(struct ath_softc *sc, struct ieee80211_channel *chan) */ if (ath_startrecv(sc) != 0) { device_printf(sc->sc_dev, - "%s: unable to restart recv logic\n", __func__); + "%s: unable to restart recv logic\n", __func__); ret = EIO; goto finish; } @@ -5517,7 +5673,11 @@ ath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) * And stop the calibration callout whilst we have * ATH_LOCK held. */ +#if defined(__DragonFly__) + callout_stop_sync(&sc->sc_cal_ch); +#else callout_stop(&sc->sc_cal_ch); +#endif ATH_UNLOCK(sc); if (ostate == IEEE80211_S_CSA && nstate == IEEE80211_S_RUN) @@ -5837,12 +5997,20 @@ ath_newassoc(struct ieee80211_node *ni, int isnew) an->an_mcastrix = ath_tx_findrix(sc, tp->mcastrate); an->an_mgmtrix = ath_tx_findrix(sc, tp->mgmtrate); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE, "%s: %s: reassoc; isnew=%d, is_powersave=%d\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + isnew, + an->an_is_powersave); +#else DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: reassoc; isnew=%d, is_powersave=%d\n", __func__, ni->ni_macaddr, ":", isnew, an->an_is_powersave); +#endif ATH_NODE_LOCK(an); ath_rate_newassoc(sc, an, isnew); @@ -5863,12 +6031,20 @@ ath_newassoc(struct ieee80211_node *ni, int isnew) * marked as non-aggregate. */ if (! isnew) { +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE, + "%s: %s: reassoc; is_powersave=%d\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + an->an_is_powersave); +#else DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: reassoc; is_powersave=%d\n", __func__, ni->ni_macaddr, ":", an->an_is_powersave); +#endif /* XXX for now, we can't hold the lock across assoc */ ath_tx_node_reassoc(sc, an); @@ -6099,7 +6275,11 @@ ath_watchdog(void *arg) } else device_printf(sc->sc_dev, "device timeout\n"); do_reset = 1; +#if defined(__DragonFly__) + ++ic->ic_oerrors; /* don't care about SMP races */ +#else counter_u64_add(ic->ic_oerrors, 1); +#endif sc->sc_stats.ast_watchdog++; ath_power_restore_power_state(sc); @@ -6115,7 +6295,11 @@ ath_watchdog(void *arg) taskqueue_enqueue(sc->sc_tq, &sc->sc_resettask); } +#if defined(__DragonFly__) + callout_reset(&sc->sc_wd_ch, hz, ath_watchdog, sc); +#else callout_schedule(&sc->sc_wd_ch, hz); +#endif } static void @@ -6154,7 +6338,7 @@ ath_parent(struct ieee80211com *ic) } ATH_UNLOCK(sc); - if (error == 0) { + if (error == 0) { #ifdef ATH_TX99_DIAG if (sc->sc_tx99 != NULL) sc->sc_tx99->start(sc->sc_tx99); @@ -6182,13 +6366,13 @@ ath_announce(struct ath_softc *sc) for (i = 0; i <= WME_AC_VO; i++) { struct ath_txq *txq = sc->sc_ac2q[i]; device_printf(sc->sc_dev, - "Use hw queue %u for %s traffic\n", - txq->axq_qnum, ieee80211_wme_acnames[i]); + "Use hw queue %u for %s traffic\n", + txq->axq_qnum, ieee80211_wme_acnames[i]); } device_printf(sc->sc_dev, "Use hw queue %u for CAB traffic\n", - sc->sc_cabq->axq_qnum); + sc->sc_cabq->axq_qnum); device_printf(sc->sc_dev, "Use hw queue %u for beacons\n", - sc->sc_bhalq); + sc->sc_bhalq); } if (ath_rxbuf != ATH_RXBUF) device_printf(sc->sc_dev, "using %u rx buffers\n", ath_rxbuf); @@ -6239,11 +6423,18 @@ ath_node_powersave(struct ieee80211_node *ni, int enable) /* XXX and no TXQ locks should be held here */ +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6s: enable=%d\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + !! enable); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: enable=%d\n", __func__, ni->ni_macaddr, ":", !! enable); +#endif /* Suspend or resume software queue handling */ if (enable) @@ -6336,31 +6527,55 @@ ath_node_set_tim(struct ieee80211_node *ni, int enable) * from a variety of different process contexts! */ if (enable && an->an_tim_set == 1) { +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: enable=%d, tim_set=1, ignoring\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + enable); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: enable=%d, tim_set=1, ignoring\n", __func__, ni->ni_macaddr, ":", enable); +#endif ATH_TX_UNLOCK(sc); } else if (enable) { +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: enable=%d, enabling TIM\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + enable); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: enable=%d, enabling TIM\n", __func__, ni->ni_macaddr, ":", enable); +#endif an->an_tim_set = 1; ATH_TX_UNLOCK(sc); changed = avp->av_set_tim(ni, enable); } else if (an->an_swq_depth == 0) { /* disable */ +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: enable=%d, an_swq_depth == 0, disabling\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + enable); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: enable=%d, an_swq_depth == 0, disabling\n", __func__, ni->ni_macaddr, ":", enable); +#endif an->an_tim_set = 0; ATH_TX_UNLOCK(sc); changed = avp->av_set_tim(ni, enable); @@ -6368,12 +6583,20 @@ ath_node_set_tim(struct ieee80211_node *ni, int enable) /* * disable regardless; the node isn't in powersave now */ +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: enable=%d, an_pwrsave=0, disabling\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + enable); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: enable=%d, an_pwrsave=0, disabling\n", __func__, ni->ni_macaddr, ":", enable); +#endif an->an_tim_set = 0; ATH_TX_UNLOCK(sc); changed = avp->av_set_tim(ni, enable); @@ -6384,12 +6607,20 @@ ath_node_set_tim(struct ieee80211_node *ni, int enable) * for now. */ ATH_TX_UNLOCK(sc); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: enable=%d, an_swq_depth > 0, ignoring\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + enable); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: enable=%d, an_swq_depth > 0, ignoring\n", __func__, ni->ni_macaddr, ":", enable); +#endif changed = 0; } @@ -6457,11 +6688,18 @@ ath_tx_update_tim(struct ath_softc *sc, struct ieee80211_node *ni, if (an->an_is_powersave && an->an_tim_set == 0 && an->an_swq_depth != 0) { +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: swq_depth>0, tim_set=0, set!\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr)); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: swq_depth>0, tim_set=0, set!\n", __func__, ni->ni_macaddr, ":"); +#endif an->an_tim_set = 1; (void) avp->av_set_tim(ni, 1); } @@ -6476,12 +6714,20 @@ ath_tx_update_tim(struct ath_softc *sc, struct ieee80211_node *ni, an->an_stack_psq == 0 && an->an_tim_set == 1 && an->an_swq_depth == 0) { +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: swq_depth=0, tim_set=1, psq_set=0," + " clear!\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr)); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: swq_depth=0, tim_set=1, psq_set=0," " clear!\n", __func__, ni->ni_macaddr, ":"); +#endif an->an_tim_set = 0; (void) avp->av_set_tim(ni, 0); } @@ -6558,11 +6804,18 @@ ath_node_recv_pspoll(struct ieee80211_node *ni, struct mbuf *m) * Immediately punt. */ if (! an->an_is_powersave) { +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: not in powersave?\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr)); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: not in powersave?\n", __func__, ni->ni_macaddr, ":"); +#endif ATH_TX_UNLOCK(sc); avp->av_recv_pspoll(ni, m); return; @@ -6584,11 +6837,18 @@ ath_node_recv_pspoll(struct ieee80211_node *ni, struct mbuf *m) */ if (an->an_swq_depth == 0) { ATH_TX_UNLOCK(sc); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: SWQ empty; punting to net80211\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr)); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: SWQ empty; punting to net80211\n", __func__, ni->ni_macaddr, ":"); +#endif avp->av_recv_pspoll(ni, m); return; } @@ -6612,12 +6872,20 @@ ath_node_recv_pspoll(struct ieee80211_node *ni, struct mbuf *m) */ ATH_TX_UNLOCK(sc); taskqueue_enqueue(sc->sc_tq, &sc->sc_txqtask); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: leaking frame to TID %d\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + tid); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: leaking frame to TID %d\n", __func__, ni->ni_macaddr, ":", tid); +#endif return; } @@ -6626,11 +6894,18 @@ ath_node_recv_pspoll(struct ieee80211_node *ni, struct mbuf *m) /* * XXX nothing in the TIDs at this point? Eek. */ +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: TIDs empty, but ath_node showed traffic?!\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr)); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: TIDs empty, but ath_node showed traffic?!\n", __func__, ni->ni_macaddr, ":"); +#endif avp->av_recv_pspoll(ni, m); #else avp->av_recv_pspoll(ni, m); diff --git a/sys/dev/netif/ath/ath/if_ath_ahb.c b/sys/dev/netif/ath/ath/if_ath_ahb.c index 0b546a069b..26e28bec12 100644 --- a/sys/dev/netif/ath/ath/if_ath_ahb.c +++ b/sys/dev/netif/ath/ath/if_ath_ahb.c @@ -46,8 +46,12 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include #include +#endif #include #include @@ -58,13 +62,16 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include -#include +#include +#if defined(__DragonFly__) +#else #include #include #include +#endif /* * bus glue. @@ -117,6 +124,10 @@ ath_ahb_probe(device_t dev) return ENXIO; } +#if defined(__DragonFly__) +/* empty */ +#else + static void ath_ahb_intr(void *arg) { @@ -125,6 +136,8 @@ ath_ahb_intr(void *arg) ath_intr(arg); } +#endif + static int ath_ahb_attach(device_t dev) { @@ -177,8 +190,8 @@ ath_ahb_attach(device_t dev) * after boot-time. */ psc->sc_eeprom = bus_alloc_resource(dev, SYS_RES_MEMORY, - &rid, (uintptr_t) eepromaddr, - (uintptr_t) eepromaddr + (uintptr_t) (eepromsize - 1), 0, RF_ACTIVE); + &rid, (uintptr_t) eepromaddr, + (uintptr_t) eepromaddr + (uintptr_t) (eepromsize - 1), 0, RF_ACTIVE); if (psc->sc_eeprom == NULL) { device_printf(dev, "cannot map eeprom space\n"); goto bad0; @@ -193,7 +206,7 @@ ath_ahb_attach(device_t dev) sc->sc_invalid = 1; /* Copy the EEPROM data out */ - sc->sc_eepromdata = malloc(eepromsize, M_TEMP, M_NOWAIT | M_ZERO); + sc->sc_eepromdata = kmalloc(eepromsize, M_TEMP, M_INTWAIT | M_ZERO); if (sc->sc_eepromdata == NULL) { device_printf(dev, "cannot allocate memory for eeprom data\n"); goto bad1; @@ -218,18 +231,33 @@ ath_ahb_attach(device_t dev) device_printf(dev, "could not map interrupt\n"); goto bad1; } + +#if defined(__DragonFly__) + if (bus_setup_intr(dev, psc->sc_irq, + INTR_MPSAFE, + ath_intr, sc, &psc->sc_ih, + &wlan_global_serializer)) { + device_printf(dev, "could not establish interrupt\n"); + goto bad2; + } +#else if (bus_setup_intr(dev, psc->sc_irq, INTR_TYPE_NET | INTR_MPSAFE, NULL, ath_ahb_intr, sc, &psc->sc_ih)) { device_printf(dev, "could not establish interrupt\n"); goto bad2; } +#endif /* * Setup DMA descriptor area. */ if (bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */ +#if defined(__DragonFly__) + 16, 0, /* alignment, bounds */ +#else 1, 0, /* alignment, bounds */ +#endif BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ @@ -237,8 +265,11 @@ ath_ahb_attach(device_t dev) ATH_MAX_SCATTER, /* nsegments */ 0x3ffff, /* maxsegsize XXX */ BUS_DMA_ALLOCNOW, /* flags */ +#if defined(__DragonFly__) +#else NULL, /* lockfunc */ NULL, /* lockarg */ +#endif &sc->sc_dmat)) { device_printf(dev, "cannot allocate DMA tag\n"); goto bad3; @@ -284,7 +315,7 @@ bad0: bad: /* XXX?! */ if (sc->sc_eepromdata) - free(sc->sc_eepromdata, M_TEMP); + kfree(sc->sc_eepromdata, M_TEMP); return (error); } @@ -308,7 +339,7 @@ ath_ahb_detach(device_t dev) bus_release_resource(dev, SYS_RES_MEMORY, 0, psc->sc_eeprom); /* XXX?! */ if (sc->sc_eepromdata) - free(sc->sc_eepromdata, M_TEMP); + kfree(sc->sc_eepromdata, M_TEMP); ATH_TXSTATUS_LOCK_DESTROY(sc); ATH_RX_LOCK_DESTROY(sc); @@ -365,8 +396,11 @@ static driver_t ath_ahb_driver = { sizeof (struct ath_ahb_softc) }; static devclass_t ath_devclass; -DRIVER_MODULE(ath, nexus, ath_ahb_driver, ath_devclass, 0, 0); +DRIVER_MODULE(ath, nexus, ath_ahb_driver, ath_devclass, NULL, NULL); +#if defined(__DragonFly__) +#else DRIVER_MODULE(ath, apb, ath_ahb_driver, ath_devclass, 0, 0); +#endif MODULE_VERSION(ath, 1); MODULE_DEPEND(ath, wlan, 1, 1, 1); /* 802.11 media layer */ MODULE_DEPEND(ath, if_ath, 1, 1, 1); /* if_ath driver */ diff --git a/sys/dev/netif/ath/ath/if_ath_alq.c b/sys/dev/netif/ath/ath/if_ath_alq.c index 8ca53ae2c5..564901f2b8 100644 --- a/sys/dev/netif/ath/ath/if_ath_alq.c +++ b/sys/dev/netif/ath/ath/if_ath_alq.c @@ -39,14 +39,22 @@ #include #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include +#endif #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include +#endif #include #include -#include +#include #ifdef ATH_DEBUG_ALQ static struct ale * @@ -70,8 +78,8 @@ if_ath_alq_init(struct if_ath_alq *alq, const char *devname) bzero(alq, sizeof(*alq)); strncpy(alq->sc_alq_devname, devname, ATH_ALQ_DEVNAME_LEN); - printf("%s (%s): attached\n", __func__, alq->sc_alq_devname); - snprintf(alq->sc_alq_filename, ATH_ALQ_FILENAME_LEN, + kprintf("%s (%s): attached\n", __func__, alq->sc_alq_devname); + ksnprintf(alq->sc_alq_filename, ATH_ALQ_FILENAME_LEN, "/tmp/ath_%s_alq.log", alq->sc_alq_devname); /* XXX too conservative, right? */ @@ -95,7 +103,7 @@ if_ath_alq_tidyup(struct if_ath_alq *alq) { if_ath_alq_stop(alq); - printf("%s (%s): detached\n", __func__, alq->sc_alq_devname); + kprintf("%s (%s): detached\n", __func__, alq->sc_alq_devname); bzero(alq, sizeof(*alq)); } @@ -115,10 +123,10 @@ if_ath_alq_start(struct if_ath_alq *alq) alq->sc_alq_qsize, 0); if (error != 0) { - printf("%s (%s): failed, err=%d\n", __func__, + kprintf("%s (%s): failed, err=%d\n", __func__, alq->sc_alq_devname, error); } else { - printf("%s (%s): opened\n", __func__, alq->sc_alq_devname); + kprintf("%s (%s): opened\n", __func__, alq->sc_alq_devname); alq->sc_alq_isactive = 1; if_ath_alq_post(alq, ATH_ALQ_INIT_STATE, sizeof (struct if_ath_alq_init_state), @@ -134,7 +142,7 @@ if_ath_alq_stop(struct if_ath_alq *alq) if (alq->sc_alq_isactive == 0) return (0); - printf("%s (%s): closed\n", __func__, alq->sc_alq_devname); + kprintf("%s (%s): closed\n", __func__, alq->sc_alq_devname); alq->sc_alq_isactive = 0; alq_close(alq->sc_alq_alq); diff --git a/sys/dev/netif/ath/ath/if_ath_beacon.c b/sys/dev/netif/ath/ath/if_ath_beacon.c index c700230149..491aada20c 100644 --- a/sys/dev/netif/ath/ath/if_ath_beacon.c +++ b/sys/dev/netif/ath/ath/if_ath_beacon.c @@ -68,9 +68,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* for mp_ncpus */ +#if defined(__DragonFly__) +/* empty */ +#else +#include /* for mp_ncpus */ #include +#endif #include #include @@ -81,10 +85,10 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #include @@ -94,15 +98,15 @@ __FBSDID("$FreeBSD$"); #include #endif -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #ifdef ATH_TX99_DIAG -#include +#include #endif /* @@ -205,9 +209,15 @@ ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_node *ni) sc->sc_stats.ast_be_nombuf++; return ENOMEM; } +#if defined(__DragonFly__) + error = bus_dmamap_load_mbuf_segment(sc->sc_dmat, bf->bf_dmamap, m, + bf->bf_segs, 1, &bf->bf_nseg, + BUS_DMA_NOWAIT); +#else error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m, bf->bf_segs, &bf->bf_nseg, BUS_DMA_NOWAIT); +#endif if (error != 0) { device_printf(sc->sc_dev, "%s: cannot map mbuf, bus_dmamap_load_mbuf_sg returns %d\n", @@ -716,9 +726,16 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap) if (ieee80211_beacon_update(bf->bf_node, m, nmcastq)) { /* XXX too conservative? */ bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); +#if defined(__DragonFly__) + error = bus_dmamap_load_mbuf_segment(sc->sc_dmat, + bf->bf_dmamap, m, + bf->bf_segs, 1, &bf->bf_nseg, + BUS_DMA_NOWAIT); +#else error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m, bf->bf_segs, &bf->bf_nseg, BUS_DMA_NOWAIT); +#endif if (error != 0) { if_printf(vap->iv_ifp, "%s: bus_dmamap_load_mbuf_sg failed, error %u\n", @@ -832,9 +849,16 @@ ath_beacon_start_adhoc(struct ath_softc *sc, struct ieee80211vap *vap) if (ieee80211_beacon_update(bf->bf_node, m, 0)) { /* XXX too conservative? */ bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); +#if defined(__DragonFly__) + error = bus_dmamap_load_mbuf_segment(sc->sc_dmat, + bf->bf_dmamap, m, + bf->bf_segs, 1, &bf->bf_nseg, + BUS_DMA_NOWAIT); +#else error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m, bf->bf_segs, &bf->bf_nseg, BUS_DMA_NOWAIT); +#endif if (error != 0) { if_printf(vap->iv_ifp, "%s: bus_dmamap_load_mbuf_sg failed, error %u\n", diff --git a/sys/dev/netif/ath/ath/if_ath_btcoex.c b/sys/dev/netif/ath/ath/if_ath_btcoex.c index b78f866cbf..96cd00e3f6 100644 --- a/sys/dev/netif/ath/ath/if_ath_btcoex.c +++ b/sys/dev/netif/ath/ath/if_ath_btcoex.c @@ -48,8 +48,12 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include #include +#endif #include #include @@ -60,7 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include /* XXX for ether_sprintf */ -#include +#include #include @@ -69,8 +73,8 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include +#include +#include /* * Initial AR9285 / (WB195) bluetooth coexistence settings, @@ -374,7 +378,7 @@ ath_btcoex_ioctl(struct ath_softc *sc, struct ath_diag *ad) /* * Copy in data. */ - indata = malloc(insize, M_TEMP, M_NOWAIT); + indata = kmalloc(insize, M_TEMP, M_INTWAIT); if (indata == NULL) { error = ENOMEM; goto bad; @@ -391,7 +395,7 @@ ath_btcoex_ioctl(struct ath_softc *sc, struct ath_diag *ad) * pointer for us to use below in reclaiming the buffer; * may want to be more defensive. */ - outdata = malloc(outsize, M_TEMP, M_NOWAIT); + outdata = kmalloc(outsize, M_TEMP, M_INTWAIT); if (outdata == NULL) { error = ENOMEM; goto bad; @@ -407,9 +411,9 @@ ath_btcoex_ioctl(struct ath_softc *sc, struct ath_diag *ad) error = EFAULT; bad: if ((ad->ad_id & ATH_DIAG_IN) && indata != NULL) - free(indata, M_TEMP); + kfree(indata, M_TEMP); if ((ad->ad_id & ATH_DIAG_DYN) && outdata != NULL) - free(outdata, M_TEMP); + kfree(outdata, M_TEMP); return (error); } diff --git a/sys/dev/netif/ath/ath/if_ath_debug.c b/sys/dev/netif/ath/ath/if_ath_debug.c index d21ad6fea6..fdf6ddbfae 100644 --- a/sys/dev/netif/ath/ath/if_ath_debug.c +++ b/sys/dev/netif/ath/ath/if_ath_debug.c @@ -30,6 +30,10 @@ #include __FBSDID("$FreeBSD$"); +#if defined(__DragonFly__) +#define CTLFLAG_RWTUN CTLFLAG_RW +#endif + #include "opt_inet.h" #include "opt_ath.h" #include "opt_wlan.h" @@ -52,7 +56,10 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +#else #include +#endif #include #include @@ -62,13 +69,13 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #include @@ -78,16 +85,16 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include +#include +#include /* XXX for softled */ +#include #ifdef ATH_TX99_DIAG -#include +#include #endif #ifdef ATH_DEBUG -#include +#include uint64_t ath_debug = 0; @@ -105,7 +112,7 @@ ath_printrxbuf(struct ath_softc *sc, const struct ath_buf *bf, int i; for (i = 0, ds = bf->bf_desc; i < bf->bf_nseg; i++, ds++) { - printf("R[%2u] (DS.V:%p DS.P:%p) L:%08x D:%08x%s\n" + kprintf("R[%2u] (DS.V:%p DS.P:%p) L:%08x D:%08x%s\n" " %08x %08x %08x %08x\n", ix, ds, (const struct ath_desc *)bf->bf_daddr + i, ds->ds_link, ds->ds_data, @@ -113,17 +120,17 @@ ath_printrxbuf(struct ath_softc *sc, const struct ath_buf *bf, ds->ds_ctl0, ds->ds_ctl1, ds->ds_hw[0], ds->ds_hw[1]); if (ah->ah_magic == 0x20065416) { - printf(" %08x %08x %08x %08x %08x %08x %08x\n", + kprintf(" %08x %08x %08x %08x %08x %08x %08x\n", ds->ds_hw[2], ds->ds_hw[3], ds->ds_hw[4], ds->ds_hw[5], ds->ds_hw[6], ds->ds_hw[7], ds->ds_hw[8]); } else if (ah->ah_magic == 0x19741014) { - printf(" %08x %08x %08x %08x %08x %08x %08x\n", + kprintf(" %08x %08x %08x %08x %08x %08x %08x\n", ds->ds_hw[2], ds->ds_hw[3], ds->ds_hw[4], ds->ds_hw[5], ds->ds_hw[6], ds->ds_hw[7], ds->ds_hw[8]); - printf(" %08x %08x %08x %08x %08x %08x %08x\n", + kprintf(" %08x %08x %08x %08x %08x %08x %08x\n", ds->ds_hw[9], ds->ds_hw[10], ds->ds_hw[11], ds->ds_hw[12], ds->ds_hw[13], ds->ds_hw[14], ds->ds_hw[15]); @@ -142,7 +149,7 @@ ath_printtxbuf_edma(struct ath_softc *sc, const struct ath_buf *first_bf, const struct ath_desc_txedma *eds; int i, n; - printf("Q%u[%3u] (nseg=%d)", qnum, ix, bf->bf_nseg); + kprintf("Q%u[%3u] (nseg=%d)", qnum, ix, bf->bf_nseg); while (bf != NULL) { /* * XXX For now, assume the txmap size is 4. @@ -158,38 +165,38 @@ ath_printtxbuf_edma(struct ath_softc *sc, const struct ath_buf *first_bf, i < n; i ++, ds += sc->sc_tx_desclen) { eds = (const struct ath_desc_txedma *) ds; - printf(" (DS.V:%p DS.P:%p) I: %08x L:%08x F:%04x%s\n", + kprintf(" (DS.V:%p DS.P:%p) I: %08x L:%08x F:%04x%s\n", eds, (const struct ath_desc *)bf->bf_daddr + i, eds->ds_info, eds->ds_link, bf->bf_state.bfs_txflags, !done ? "" : (ts->ts_status == 0) ? " *" : " !"); - printf(" (D[0] = %08x(%08x), D[1] = %08x(%08x)\n", + kprintf(" (D[0] = %08x(%08x), D[1] = %08x(%08x)\n", eds->ds_hw[0], eds->ds_hw[1], eds->ds_hw[2], eds->ds_hw[3]); - printf(" (D[2] = %08x(%08x), D[3] = %08x(%08x)\n", + kprintf(" (D[2] = %08x(%08x), D[3] = %08x(%08x)\n", eds->ds_hw[4], eds->ds_hw[5], eds->ds_hw[6], eds->ds_hw[7]); - printf(" Seq: %d swtry: %d ADDBAW?: %d DOBAW?: %d\n", + kprintf(" Seq: %d swtry: %d ADDBAW?: %d DOBAW?: %d\n", bf->bf_state.bfs_seqno, bf->bf_state.bfs_retries, bf->bf_state.bfs_addedbaw, bf->bf_state.bfs_dobaw); - printf(" %08x %08x %08x %08x %08x %08x\n", + kprintf(" %08x %08x %08x %08x %08x %08x\n", eds->ds_hw[8], eds->ds_hw[9], eds->ds_hw[10], eds->ds_hw[11], eds->ds_hw[12], eds->ds_hw[13]); - printf(" %08x %08x %08x %08x %08x %08x %08x\n", + kprintf(" %08x %08x %08x %08x %08x %08x %08x\n", eds->ds_hw[14], eds->ds_hw[15], eds->ds_hw[16], eds->ds_hw[17], eds->ds_hw[18], eds->ds_hw[19], eds->ds_hw[20]); #if 0 - printf(" %08x %08x %08x %08x %08x %08x %08x %08x\n", + kprintf(" %08x %08x %08x %08x %08x %08x %08x %08x\n", ds->ds_hw[22],ds->ds_hw[23],ds->ds_hw[24], ds->ds_hw[25],ds->ds_hw[26],ds->ds_hw[27], ds->ds_hw[28], ds->ds_hw[29]); #endif } - printf(" [end]\n"); + kprintf(" [end]\n"); bf = bf->bf_next; } } @@ -204,35 +211,35 @@ ath_printtxbuf_legacy(struct ath_softc *sc, const struct ath_buf *first_bf, const struct ath_desc *ds; int i; - printf("Q%u[%3u]", qnum, ix); + kprintf("Q%u[%3u]", qnum, ix); while (bf != NULL) { - printf(" (bf=%p, lastds=%p)\n", bf, first_bf->bf_lastds); - printf(" Seq: %d swtry: %d ADDBAW?: %d DOBAW?: %d\n", + kprintf(" (bf=%p, lastds=%p)\n", bf, first_bf->bf_lastds); + kprintf(" Seq: %d swtry: %d ADDBAW?: %d DOBAW?: %d\n", bf->bf_state.bfs_seqno, bf->bf_state.bfs_retries, bf->bf_state.bfs_addedbaw, bf->bf_state.bfs_dobaw); for (i = 0, ds = bf->bf_desc; i < bf->bf_nseg; i++, ds++) { - printf(" (DS.V:%p DS.P:%p) L:%08x D:%08x F:%04x%s\n", + kprintf(" (DS.V:%p DS.P:%p) L:%08x D:%08x F:%04x%s\n", ds, (const struct ath_desc *)bf->bf_daddr + i, ds->ds_link, ds->ds_data, bf->bf_state.bfs_txflags, !done ? "" : (ts->ts_status == 0) ? " *" : " !"); - printf(" %08x %08x %08x %08x %08x %08x\n", + kprintf(" %08x %08x %08x %08x %08x %08x\n", ds->ds_ctl0, ds->ds_ctl1, ds->ds_hw[0], ds->ds_hw[1], ds->ds_hw[2], ds->ds_hw[3]); if (ah->ah_magic == 0x20065416) { - printf(" %08x %08x %08x %08x %08x %08x %08x %08x\n", + kprintf(" %08x %08x %08x %08x %08x %08x %08x %08x\n", ds->ds_hw[4], ds->ds_hw[5], ds->ds_hw[6], ds->ds_hw[7], ds->ds_hw[8], ds->ds_hw[9], ds->ds_hw[10],ds->ds_hw[11]); - printf(" %08x %08x %08x %08x %08x %08x %08x %08x\n", + kprintf(" %08x %08x %08x %08x %08x %08x %08x %08x\n", ds->ds_hw[12],ds->ds_hw[13],ds->ds_hw[14], ds->ds_hw[15],ds->ds_hw[16],ds->ds_hw[17], ds->ds_hw[18], ds->ds_hw[19]); } } - printf(" [end]\n"); + kprintf(" [end]\n"); bf = bf->bf_next; } } @@ -252,10 +259,10 @@ ath_printtxstatbuf(struct ath_softc *sc, const struct ath_buf *first_bf, const uint32_t *ds, u_int qnum, u_int ix, int done) { - printf("Q%u[%3u] ", qnum, ix); - printf(" %08x %08x %08x %08x %08x %08x\n", + kprintf("Q%u[%3u] ", qnum, ix); + kprintf(" %08x %08x %08x %08x %08x %08x\n", ds[0], ds[1], ds[2], ds[3], ds[4], ds[5]); - printf(" %08x %08x %08x %08x %08x\n", + kprintf(" %08x %08x %08x %08x %08x\n", ds[6], ds[7], ds[8], ds[9], ds[10]); } diff --git a/sys/dev/netif/ath/ath/if_ath_debug.h b/sys/dev/netif/ath/ath/if_ath_debug.h index 5d471393a6..e1a4e41d70 100644 --- a/sys/dev/netif/ath/ath/if_ath_debug.h +++ b/sys/dev/netif/ath/ath/if_ath_debug.h @@ -84,17 +84,24 @@ enum { ATH_KTR_TX = 0x00000080, }; +#if defined(__DragonFly__) + +#define ATH_KTR(_sc, _km, _kf, ...) + +#else + #define ATH_KTR(_sc, _km, _kf, ...) do { \ if (sc->sc_ktrdebug & (_km)) \ CTR##_kf(KTR_DEV, __VA_ARGS__); \ } while (0) +#endif extern uint64_t ath_debug; #define IFF_DUMPPKTS(sc, m) (sc->sc_debug & (m)) #define DPRINTF(sc, m, fmt, ...) do { \ if (sc->sc_debug & (m)) \ - device_printf(sc->sc_dev, fmt, __VA_ARGS__); \ + device_printf(sc->sc_dev, fmt, __VA_ARGS__); \ } while (0) #define KEYPRINTF(sc, ix, hk, mac) do { \ if (sc->sc_debug & ATH_DEBUG_KEYCACHE) \ diff --git a/sys/dev/netif/ath/ath/if_ath_descdma.c b/sys/dev/netif/ath/ath/if_ath_descdma.c index 66ff351b5a..c01468d0e5 100644 --- a/sys/dev/netif/ath/ath/if_ath_descdma.c +++ b/sys/dev/netif/ath/ath/if_ath_descdma.c @@ -68,9 +68,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* for mp_ncpus */ +#if defined(__DragonFly__) +/* empty */ +#else +#include /* for mp_ncpus */ #include +#endif #include #include @@ -81,13 +85,13 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #include @@ -97,28 +101,28 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include +#include +#include /* XXX for softled */ +#include -#include -#include +#include +#include #if 0 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif -#include +#include MALLOC_DECLARE(M_ATHDEV); @@ -186,8 +190,11 @@ ath_descdma_alloc_desc(struct ath_softc *sc, 1, /* nsegments */ dd->dd_desc_len, /* maxsegsize */ 0, /* flags */ +#if defined(__DragonFly__) +#else NULL, /* lockfunc */ NULL, /* lockarg */ +#endif &dd->dd_dmat); if (error != 0) { device_printf(sc->sc_dev, @@ -260,7 +267,7 @@ ath_descdma_setup(struct ath_softc *sc, /* allocate rx buffers */ bsize = sizeof(struct ath_buf) * nbuf; - bf = malloc(bsize, M_ATHDEV, M_NOWAIT | M_ZERO); + bf = kmalloc(bsize, M_ATHDEV, M_NOWAIT | M_ZERO); if (bf == NULL) { device_printf(sc->sc_dev, "malloc of %s buffers failed, size %u\n", @@ -348,7 +355,7 @@ ath_descdma_setup_rx_edma(struct ath_softc *sc, /* allocate rx buffers */ bsize = sizeof(struct ath_buf) * nbuf; - bf = malloc(bsize, M_ATHDEV, M_NOWAIT | M_ZERO); + bf = kmalloc(bsize, M_ATHDEV, M_NOWAIT | M_ZERO); if (bf == NULL) { device_printf(sc->sc_dev, "malloc of %s buffers failed, size %u\n", @@ -437,6 +444,6 @@ ath_descdma_cleanup(struct ath_softc *sc, TAILQ_INIT(head); if (dd->dd_bufptr != NULL) - free(dd->dd_bufptr, M_ATHDEV); + kfree(dd->dd_bufptr, M_ATHDEV); memset(dd, 0, sizeof(*dd)); } diff --git a/sys/dev/netif/ath/ath/if_ath_ioctl.c b/sys/dev/netif/ath/ath/if_ath_ioctl.c index 1128c18eea..54e09b7bc4 100644 --- a/sys/dev/netif/ath/ath/if_ath_ioctl.c +++ b/sys/dev/netif/ath/ath/if_ath_ioctl.c @@ -68,9 +68,11 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* for mp_ncpus */ +#if !defined(__DragonFly__) +#include /* for mp_ncpus */ #include +#endif #include #include @@ -81,13 +83,13 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #include @@ -97,22 +99,22 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include +#include +#include /* XXX for softled */ +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif -#include +#include /* * ioctl() related pieces. @@ -227,9 +229,9 @@ ath_ioctl_diag(struct ath_softc *sc, struct ath_diag *ad) bad: if ((ad->ad_id & ATH_DIAG_IN) && indata != NULL) - free(indata, M_TEMP); + kfree(indata, M_TEMP); if ((ad->ad_id & ATH_DIAG_DYN) && outdata != NULL) - free(outdata, M_TEMP); + kfree(outdata, M_TEMP); return error; } #endif /* ATH_DIAGAPI */ @@ -251,10 +253,18 @@ ath_ioctl(struct ieee80211com *ic, u_long cmd, void *data) sc->sc_stats.ast_rx_packets = 0; TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { ifp = vap->iv_ifp; +#if defined(__DragonFly__) + uint64_t v; + IFNET_STAT_GET(ifp, opackets, v); + sc->sc_stats.ast_tx_packets += v; + IFNET_STAT_GET(ifp, ipackets, v); + sc->sc_stats.ast_rx_packets += v; +#else sc->sc_stats.ast_tx_packets += ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS); sc->sc_stats.ast_rx_packets += ifp->if_get_counter(ifp, IFCOUNTER_IPACKETS); +#endif } sc->sc_stats.ast_tx_rssi = ATH_RSSI(sc->sc_halstats.ns_avgtxrssi); sc->sc_stats.ast_rx_rssi = ATH_RSSI(sc->sc_halstats.ns_avgrssi); diff --git a/sys/dev/netif/ath/ath/if_ath_keycache.c b/sys/dev/netif/ath/ath/if_ath_keycache.c index ff1df8463e..aa19da2c39 100644 --- a/sys/dev/netif/ath/ath/if_ath_keycache.c +++ b/sys/dev/netif/ath/ath/if_ath_keycache.c @@ -59,7 +59,11 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include +#endif #include #include @@ -70,15 +74,15 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include -#include +#include -#include -#include -#include +#include +#include +#include #ifdef ATH_DEBUG static void @@ -95,21 +99,21 @@ ath_keyprint(struct ath_softc *sc, const char *tag, u_int ix, }; int i, n; - printf("%s: [%02u] %-7s ", tag, ix, ciphers[hk->kv_type]); + kprintf("%s: [%02u] %-7s ", tag, ix, ciphers[hk->kv_type]); for (i = 0, n = hk->kv_len; i < n; i++) - printf("%02x", hk->kv_val[i]); - printf(" mac %s", ether_sprintf(mac)); + kprintf("%02x", hk->kv_val[i]); + kprintf(" mac %s", ether_sprintf(mac)); if (hk->kv_type == HAL_CIPHER_TKIP) { - printf(" %s ", sc->sc_splitmic ? "mic" : "rxmic"); + kprintf(" %s ", sc->sc_splitmic ? "mic" : "rxmic"); for (i = 0; i < sizeof(hk->kv_mic); i++) - printf("%02x", hk->kv_mic[i]); + kprintf("%02x", hk->kv_mic[i]); if (!sc->sc_splitmic) { - printf(" txmic "); + kprintf(" txmic "); for (i = 0; i < sizeof(hk->kv_txmic); i++) - printf("%02x", hk->kv_txmic[i]); + kprintf("%02x", hk->kv_txmic[i]); } } - printf("\n"); + kprintf("\n"); } #endif diff --git a/sys/dev/netif/ath/ath/if_ath_led.c b/sys/dev/netif/ath/ath/if_ath_led.c index a55e036468..e616d4ac3f 100644 --- a/sys/dev/netif/ath/ath/if_ath_led.c +++ b/sys/dev/netif/ath/ath/if_ath_led.c @@ -65,9 +65,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* for mp_ncpus */ - -#include #include #include @@ -77,13 +74,13 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #include @@ -93,14 +90,14 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include +#include +#include /* XXX for softled */ +#include -#include -#include +#include +#include -#include +#include /* * Software LED driver routines. diff --git a/sys/dev/netif/ath/ath/if_ath_lna_div.c b/sys/dev/netif/ath/ath/if_ath_lna_div.c index 5c102fb976..abd657520e 100644 --- a/sys/dev/netif/ath/ath/if_ath_lna_div.c +++ b/sys/dev/netif/ath/ath/if_ath_lna_div.c @@ -48,8 +48,12 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include #include +#endif #include #include @@ -60,7 +64,7 @@ __FBSDID("$FreeBSD$"); #include #include /* XXX for ether_sprintf */ -#include +#include #include @@ -69,9 +73,9 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include -#include +#include +#include +#include /* Linux compatibility macros */ /* @@ -96,8 +100,8 @@ ath_lna_div_attach(struct ath_softc *sc) if (! ath_hal_hasdivantcomb(sc->sc_ah)) return (0); - ss = malloc(sizeof(struct if_ath_ant_comb_state), - M_TEMP, M_WAITOK | M_ZERO); + ss = kmalloc(sizeof(struct if_ath_ant_comb_state), + M_TEMP, M_WAITOK | M_ZERO); if (ss == NULL) { device_printf(sc->sc_dev, "%s: failed to allocate\n", __func__); @@ -131,7 +135,7 @@ int ath_lna_div_detach(struct ath_softc *sc) { if (sc->sc_lna_div != NULL) { - free(sc->sc_lna_div, M_TEMP); + kfree(sc->sc_lna_div, M_TEMP); sc->sc_lna_div = NULL; } sc->sc_dolnadiv = 0; @@ -170,7 +174,7 @@ ath_lna_div_ioctl(struct ath_softc *sc, struct ath_diag *ad) /* * Copy in data. */ - indata = malloc(insize, M_TEMP, M_NOWAIT); + indata = kmalloc(insize, M_TEMP, M_INTWAIT); if (indata == NULL) { error = ENOMEM; goto bad; @@ -187,7 +191,7 @@ ath_lna_div_ioctl(struct ath_softc *sc, struct ath_diag *ad) * pointer for us to use below in reclaiming the buffer; * may want to be more defensive. */ - outdata = malloc(outsize, M_TEMP, M_NOWAIT); + outdata = kmalloc(outsize, M_TEMP, M_INTWAIT); if (outdata == NULL) { error = ENOMEM; goto bad; @@ -203,9 +207,9 @@ ath_lna_div_ioctl(struct ath_softc *sc, struct ath_diag *ad) error = EFAULT; bad: if ((ad->ad_id & ATH_DIAG_IN) && indata != NULL) - free(indata, M_TEMP); + kfree(indata, M_TEMP); if ((ad->ad_id & ATH_DIAG_DYN) && outdata != NULL) - free(outdata, M_TEMP); + kfree(outdata, M_TEMP); return (error); } diff --git a/sys/dev/netif/ath/ath/if_ath_misc.h b/sys/dev/netif/ath/ath/if_ath_misc.h index fbc4d67d72..1c9e059482 100644 --- a/sys/dev/netif/ath/ath/if_ath_misc.h +++ b/sys/dev/netif/ath/ath/if_ath_misc.h @@ -101,7 +101,6 @@ extern void ath_tx_update_tim(struct ath_softc *sc, * if_ath.c and do the ath_start() call there. Once that's done, * we can kill this. */ -extern void ath_start(struct ifnet *ifp); extern void ath_start_task(void *arg, int npending); extern void ath_tx_dump(struct ath_softc *sc, struct ath_txq *txq); diff --git a/sys/dev/netif/ath/ath/if_ath_pci.c b/sys/dev/netif/ath/ath/if_ath_pci.c index 88cbaffb1f..b1c28dd56f 100644 --- a/sys/dev/netif/ath/ath/if_ath_pci.c +++ b/sys/dev/netif/ath/ath/if_ath_pci.c @@ -44,8 +44,12 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include #include +#endif #include #include @@ -56,12 +60,17 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include -#include +#include +#if defined(__DragonFly__) +#include +#include +#else #include #include +#endif /* For EEPROM firmware */ #ifdef ATH_EEPROM_FIRMWARE @@ -82,7 +91,7 @@ struct ath_pci_softc { /* * XXX eventually this should be some system level definition - * so modules will have probe/attach information like USB. + * so modules will hvae probe/attach information like USB. * But for now.. */ struct pci_device_id { @@ -295,18 +304,32 @@ ath_pci_attach(device_t dev) device_printf(dev, "could not map interrupt\n"); goto bad1; } +#if defined(__DragonFly__) + if (bus_setup_intr(dev, psc->sc_irq, + INTR_MPSAFE, + ath_intr, sc, &psc->sc_ih, + &wlan_global_serializer)) { + device_printf(dev, "could not establish interrupt\n"); + goto bad2; + } +#else if (bus_setup_intr(dev, psc->sc_irq, INTR_TYPE_NET | INTR_MPSAFE, NULL, ath_intr, sc, &psc->sc_ih)) { device_printf(dev, "could not establish interrupt\n"); goto bad2; } +#endif /* * Setup DMA descriptor area. */ if (bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */ +#if defined(__DragonFly__) + 16, 0, /* alignment, bounds */ +#else 1, 0, /* alignment, bounds */ +#endif BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ @@ -314,8 +337,11 @@ ath_pci_attach(device_t dev) ATH_MAX_SCATTER, /* nsegments */ 0x3ffff, /* maxsegsize XXX */ BUS_DMA_ALLOCNOW, /* flags */ +#if defined(__DragonFly__) +#else NULL, /* lockfunc */ NULL, /* lockarg */ +#endif &sc->sc_dmat)) { device_printf(dev, "cannot allocate DMA tag\n"); goto bad3; @@ -341,7 +367,7 @@ ath_pci_attach(device_t dev) device_printf(dev, "%s: EEPROM firmware @ %p\n", __func__, fw->data); sc->sc_eepromdata = - malloc(fw->datasize, M_TEMP, M_WAITOK | M_ZERO); + kmalloc(fw->datasize, M_TEMP, M_WAITOK | M_ZERO); if (! sc->sc_eepromdata) { device_printf(dev, "%s: can't malloc eepromdata\n", __func__); @@ -356,7 +382,7 @@ ath_pci_attach(device_t dev) if (error == 0) /* success */ return 0; -#ifdef ATH_EEPROM_FIRMWARE +#ifdef ATH_EEPROM_FIRMWARE bad4: #endif bus_dma_tag_destroy(sc->sc_dmat); @@ -372,7 +398,6 @@ bad1: ATH_RX_LOCK_DESTROY(sc); ATH_TX_LOCK_DESTROY(sc); ATH_LOCK_DESTROY(sc); - bad: return (error); } @@ -401,7 +426,7 @@ ath_pci_detach(device_t dev) bus_release_resource(dev, SYS_RES_MEMORY, BS_BAR, psc->sc_sr); if (sc->sc_eepromdata) - free(sc->sc_eepromdata, M_TEMP); + kfree(sc->sc_eepromdata, M_TEMP); ATH_TXSTATUS_LOCK_DESTROY(sc); ATH_PCU_LOCK_DESTROY(sc); @@ -463,7 +488,7 @@ static driver_t ath_pci_driver = { sizeof (struct ath_pci_softc) }; static devclass_t ath_devclass; -DRIVER_MODULE(ath_pci, pci, ath_pci_driver, ath_devclass, 0, 0); +DRIVER_MODULE(ath_pci, pci, ath_pci_driver, ath_devclass, NULL, NULL); MODULE_VERSION(ath_pci, 1); MODULE_DEPEND(ath_pci, wlan, 1, 1, 1); /* 802.11 media layer */ MODULE_DEPEND(ath_pci, if_ath, 1, 1, 1); /* if_ath driver */ diff --git a/sys/dev/netif/ath/ath/if_ath_rx.c b/sys/dev/netif/ath/ath/if_ath_rx.c index cacd8f8c72..3d16482271 100644 --- a/sys/dev/netif/ath/ath/if_ath_rx.c +++ b/sys/dev/netif/ath/ath/if_ath_rx.c @@ -68,9 +68,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* for mp_ncpus */ +#if defined(__DragonFly__) +/* empty */ +#else +#include /* for mp_ncpus */ #include +#endif #include #include @@ -80,14 +84,17 @@ __FBSDID("$FreeBSD$"); #include #include #include +#if defined(__DragonFly__) +#include +#endif -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #include @@ -97,31 +104,31 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include /* XXX for softled */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef ATH_TX99_DIAG -#include +#include #endif #ifdef ATH_DEBUG_ALQ -#include +#include #endif -#include +#include /* * Calculate the receive filter according to the @@ -270,10 +277,17 @@ ath_legacy_rxbuf_init(struct ath_softc *sc, struct ath_buf *bf) } m->m_pkthdr.len = m->m_len = m->m_ext.ext_size; +#if defined(__DragonFly__) + error = bus_dmamap_load_mbuf_segment(sc->sc_dmat, + bf->bf_dmamap, m, + bf->bf_segs, 1, &bf->bf_nseg, + BUS_DMA_NOWAIT); +#else error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m, bf->bf_segs, &bf->bf_nseg, BUS_DMA_NOWAIT); +#endif if (error != 0) { DPRINTF(sc, ATH_DEBUG_ANY, "%s: bus_dmamap_load_mbuf_sg failed; error %d\n", @@ -722,7 +736,11 @@ ath_rx_pkt(struct ath_softc *sc, struct ath_rx_status *rs, HAL_STATUS status, rs->rs_keyix-32 : rs->rs_keyix); } } +#if defined(__DragonFly__) + ++ic->ic_ierrors; /* don't care about SMP races */ +#else counter_u64_add(ic->ic_ierrors, 1); +#endif rx_error: /* * Cleanup any pending partial frame. diff --git a/sys/dev/netif/ath/ath/if_ath_rx_edma.c b/sys/dev/netif/ath/ath/if_ath_rx_edma.c index 13e141c401..67401ba446 100644 --- a/sys/dev/netif/ath/ath/if_ath_rx_edma.c +++ b/sys/dev/netif/ath/ath/if_ath_rx_edma.c @@ -68,9 +68,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* for mp_ncpus */ +#if defined(__DragonFly__) +/* empty */ +#else +#include /* for mp_ncpus */ #include +#endif #include #include @@ -80,14 +84,17 @@ __FBSDID("$FreeBSD$"); #include #include #include +#if defined(__DragonFly__) +#include +#endif -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #include @@ -97,30 +104,30 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include /* XXX for softled */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef ATH_TX99_DIAG -#include +#include #endif -#include +#include #ifdef ATH_DEBUG_ALQ -#include +#include #endif /* @@ -646,7 +653,11 @@ ath_edma_rxbuf_init(struct ath_softc *sc, struct ath_buf *bf) ATH_RX_LOCK_ASSERT(sc); +#if defined(__DragonFly__) + m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, sc->sc_edma_bufsize); +#else m = m_getm(NULL, sc->sc_edma_bufsize, M_NOWAIT, MT_DATA); +#endif if (! m) return (ENOBUFS); /* XXX ?*/ @@ -682,8 +693,14 @@ ath_edma_rxbuf_init(struct ath_softc *sc, struct ath_buf *bf) /* * Create DMA mapping. */ +#if defined(__DragonFly__) + error = bus_dmamap_load_mbuf_segment( + sc->sc_dmat, bf->bf_dmamap, m, + bf->bf_segs, 1, &bf->bf_nseg, BUS_DMA_NOWAIT); +#else error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m, bf->bf_segs, &bf->bf_nseg, BUS_DMA_NOWAIT); +#endif if (error != 0) { device_printf(sc->sc_dev, "%s: failed; error=%d\n", @@ -899,9 +916,9 @@ ath_edma_setup_rxfifo(struct ath_softc *sc, HAL_RX_QUEUE qtype) re->m_fifolen); /* Allocate ath_buf FIFO array, pre-zero'ed */ - re->m_fifo = malloc(sizeof(struct ath_buf *) * re->m_fifolen, - M_ATHDEV, - M_NOWAIT | M_ZERO); + /* DragonFly: note use of M_INTWAIT */ + re->m_fifo = kmalloc(sizeof(struct ath_buf *) * re->m_fifolen, + M_ATHDEV, M_INTWAIT | M_ZERO); if (re->m_fifo == NULL) { device_printf(sc->sc_dev, "%s: malloc failed\n", __func__); @@ -926,7 +943,7 @@ ath_edma_rxfifo_free(struct ath_softc *sc, HAL_RX_QUEUE qtype) __func__, qtype); - free(re->m_fifo, M_ATHDEV); + kfree(re->m_fifo, M_ATHDEV); return (0); } diff --git a/sys/dev/netif/ath/ath/if_ath_spectral.c b/sys/dev/netif/ath/ath/if_ath_spectral.c index e4afdaefbb..2bb5d0ad84 100644 --- a/sys/dev/netif/ath/ath/if_ath_spectral.c +++ b/sys/dev/netif/ath/ath/if_ath_spectral.c @@ -47,8 +47,12 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include #include +#endif #include #include @@ -59,7 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include /* XXX for ether_sprintf */ -#include +#include #include @@ -68,10 +72,10 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include +#include +#include -#include +#include struct ath_spectral_state { HAL_SPECTRAL_PARAM spectral_state; @@ -111,7 +115,7 @@ ath_spectral_attach(struct ath_softc *sc) if (! ath_hal_spectral_supported(sc->sc_ah)) return (0); - ss = malloc(sizeof(struct ath_spectral_state), + ss = kmalloc(sizeof(struct ath_spectral_state), M_TEMP, M_WAITOK | M_ZERO); if (ss == NULL) { @@ -138,7 +142,7 @@ ath_spectral_detach(struct ath_softc *sc) return (0); if (sc->sc_spectral != NULL) { - free(sc->sc_spectral, M_TEMP); + kfree(sc->sc_spectral, M_TEMP); } return (0); } @@ -195,7 +199,7 @@ ath_ioctl_spectral(struct ath_softc *sc, struct ath_diag *ad) /* * Copy in data. */ - indata = malloc(insize, M_TEMP, M_NOWAIT); + indata = kmalloc(insize, M_TEMP, M_INTWAIT); if (indata == NULL) { error = ENOMEM; goto bad; @@ -212,7 +216,7 @@ ath_ioctl_spectral(struct ath_softc *sc, struct ath_diag *ad) * pointer for us to use below in reclaiming the buffer; * may want to be more defensive. */ - outdata = malloc(outsize, M_TEMP, M_NOWAIT); + outdata = kmalloc(outsize, M_TEMP, M_INTWAIT); if (outdata == NULL) { error = ENOMEM; goto bad; @@ -282,9 +286,9 @@ ath_ioctl_spectral(struct ath_softc *sc, struct ath_diag *ad) error = EFAULT; bad: if ((ad->ad_id & ATH_DIAG_IN) && indata != NULL) - free(indata, M_TEMP); + kfree(indata, M_TEMP); if ((ad->ad_id & ATH_DIAG_DYN) && outdata != NULL) - free(outdata, M_TEMP); + kfree(outdata, M_TEMP); return (error); } diff --git a/sys/dev/netif/ath/ath/if_ath_sysctl.c b/sys/dev/netif/ath/ath/if_ath_sysctl.c index ab829dfa6e..454a6de79a 100644 --- a/sys/dev/netif/ath/ath/if_ath_sysctl.c +++ b/sys/dev/netif/ath/ath/if_ath_sysctl.c @@ -59,7 +59,11 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include +#endif #include #include @@ -70,13 +74,13 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #include @@ -86,22 +90,22 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include +#include +#include /* XXX for softled */ +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef ATH_TX99_DIAG #include #endif #ifdef ATH_DEBUG_ALQ -#include +#include #endif static int @@ -466,33 +470,33 @@ ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) if (param != 1) return 0; - printf("no tx bufs (empty list): %d\n", sc->sc_stats.ast_tx_getnobuf); - printf("no tx bufs (was busy): %d\n", sc->sc_stats.ast_tx_getbusybuf); + kprintf("no tx bufs (empty list): %d\n", sc->sc_stats.ast_tx_getnobuf); + kprintf("no tx bufs (was busy): %d\n", sc->sc_stats.ast_tx_getbusybuf); - printf("aggr single packet: %d\n", + kprintf("aggr single packet: %d\n", sc->sc_aggr_stats.aggr_single_pkt); - printf("aggr single packet w/ BAW closed: %d\n", + kprintf("aggr single packet w/ BAW closed: %d\n", sc->sc_aggr_stats.aggr_baw_closed_single_pkt); - printf("aggr non-baw packet: %d\n", + kprintf("aggr non-baw packet: %d\n", sc->sc_aggr_stats.aggr_nonbaw_pkt); - printf("aggr aggregate packet: %d\n", + kprintf("aggr aggregate packet: %d\n", sc->sc_aggr_stats.aggr_aggr_pkt); - printf("aggr single packet low hwq: %d\n", + kprintf("aggr single packet low hwq: %d\n", sc->sc_aggr_stats.aggr_low_hwq_single_pkt); - printf("aggr single packet RTS aggr limited: %d\n", + kprintf("aggr single packet RTS aggr limited: %d\n", sc->sc_aggr_stats.aggr_rts_aggr_limited); - printf("aggr sched, no work: %d\n", + kprintf("aggr sched, no work: %d\n", sc->sc_aggr_stats.aggr_sched_nopkt); for (i = 0; i < 64; i++) { - printf("%2d: %10d ", i, sc->sc_aggr_stats.aggr_pkts[i]); + kprintf("%2d: %10d ", i, sc->sc_aggr_stats.aggr_pkts[i]); if (i % 4 == 3) - printf("\n"); + kprintf("\n"); } - printf("\n"); + kprintf("\n"); for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { if (ATH_TXQ_SETUP(sc, i)) { - printf("HW TXQ %d: axq_depth=%d, axq_aggr_depth=%d, " + kprintf("HW TXQ %d: axq_depth=%d, axq_aggr_depth=%d, " "axq_fifo_depth=%d, holdingbf=%p\n", i, sc->sc_txq[i].axq_depth, @@ -506,31 +510,31 @@ ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) ATH_TXBUF_LOCK(sc); TAILQ_FOREACH(bf, &sc->sc_txbuf, bf_list) { if (bf->bf_flags & ATH_BUF_BUSY) { - printf("Busy: %d\n", t); + kprintf("Busy: %d\n", t); i++; } t++; } ATH_TXBUF_UNLOCK(sc); - printf("Total TX buffers: %d; Total TX buffers busy: %d (%d)\n", + kprintf("Total TX buffers: %d; Total TX buffers busy: %d (%d)\n", t, i, sc->sc_txbuf_cnt); i = t = 0; ATH_TXBUF_LOCK(sc); TAILQ_FOREACH(bf, &sc->sc_txbuf_mgmt, bf_list) { if (bf->bf_flags & ATH_BUF_BUSY) { - printf("Busy: %d\n", t); + kprintf("Busy: %d\n", t); i++; } t++; } ATH_TXBUF_UNLOCK(sc); - printf("Total mgmt TX buffers: %d; Total mgmt TX buffers busy: %d\n", + kprintf("Total mgmt TX buffers: %d; Total mgmt TX buffers busy: %d\n", t, i); ATH_RX_LOCK(sc); for (i = 0; i < 2; i++) { - printf("%d: fifolen: %d/%d; head=%d; tail=%d; m_pending=%p, m_holdbf=%p\n", + kprintf("%d: fifolen: %d/%d; head=%d; tail=%d; m_pending=%p, m_holdbf=%p\n", i, sc->sc_rxedma[i].m_fifo_depth, sc->sc_rxedma[i].m_fifolen, @@ -543,7 +547,7 @@ ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) TAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) { i++; } - printf("Total RX buffers in free list: %d buffers\n", + kprintf("Total RX buffers in free list: %d buffers\n", i); ATH_RX_UNLOCK(sc); @@ -821,11 +825,17 @@ ath_sysctlattach(struct ath_softc *sc) #ifdef ATH_DEBUG SYSCTL_ADD_QUAD(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "debug", CTLFLAG_RW, &sc->sc_debug, +#if defined(__DragonFly__) + 0, +#endif "control debugging printfs"); #endif #ifdef ATH_DEBUG_ALQ SYSCTL_ADD_QUAD(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "ktrdebug", CTLFLAG_RW, &sc->sc_ktrdebug, +#if defined(__DragonFly__) + 0, +#endif "control debugging KTR"); #endif /* ATH_DEBUG_ALQ */ SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, @@ -1029,7 +1039,7 @@ ath_sysctl_stats_attach_rxphyerr(struct ath_softc *sc, struct sysctl_oid_list *p tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "rx_phy_err", CTLFLAG_RD, NULL, "Per-code RX PHY Errors"); child = SYSCTL_CHILDREN(tree); for (i = 0; i < 64; i++) { - snprintf(sn, sizeof(sn), "%d", i); + ksnprintf(sn, sizeof(sn), "%d", i); SYSCTL_ADD_UINT(ctx, child, OID_AUTO, sn, CTLFLAG_RD, &sc->sc_stats.ast_rx_phy[i], 0, ""); } } @@ -1048,7 +1058,7 @@ ath_sysctl_stats_attach_intr(struct ath_softc *sc, CTLFLAG_RD, NULL, "Sync interrupt statistics"); child = SYSCTL_CHILDREN(tree); for (i = 0; i < 32; i++) { - snprintf(sn, sizeof(sn), "%d", i); + ksnprintf(sn, sizeof(sn), "%d", i); SYSCTL_ADD_UINT(ctx, child, OID_AUTO, sn, CTLFLAG_RD, &sc->sc_intr_stats.sync_intr[i], 0, ""); } diff --git a/sys/dev/netif/ath/ath/if_ath_tdma.c b/sys/dev/netif/ath/ath/if_ath_tdma.c index e3460c6374..fec777c790 100644 --- a/sys/dev/netif/ath/ath/if_ath_tdma.c +++ b/sys/dev/netif/ath/ath/if_ath_tdma.c @@ -68,9 +68,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* for mp_ncpus */ +#if defined(__DragonFly__) +/* empty */ +#else +#include #include +#endif #include #include @@ -81,13 +85,13 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #include @@ -97,31 +101,31 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include /* XXX for softled */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef ATH_TX99_DIAG -#include +#include #endif #ifdef ATH_DEBUG_ALQ -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include static void ath_tdma_settimers(struct ath_softc *sc, u_int32_t nexttbtt, u_int32_t bintval); diff --git a/sys/dev/netif/ath/ath/if_ath_tx.c b/sys/dev/netif/ath/ath/if_ath_tx.c index d08df69131..0d40ce5888 100644 --- a/sys/dev/netif/ath/ath/if_ath_tx.c +++ b/sys/dev/netif/ath/ath/if_ath_tx.c @@ -61,7 +61,11 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include +#endif #include #include @@ -72,15 +76,15 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif -#include +#include #include @@ -89,22 +93,26 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include +#include +#include /* XXX for softled */ +#include -#include +#include #ifdef ATH_TX99_DIAG -#include +#include #endif -#include -#include -#include +#include +#include +#include #ifdef ATH_DEBUG_ALQ -#include +#include +#endif + +#if defined(__DragonFly__) +extern const char* ath_hal_ether_sprintf(const uint8_t *mac); #endif /* @@ -286,16 +294,25 @@ ath_txfrag_setup(struct ath_softc *sc, ath_bufhead *frags, static int ath_tx_dmasetup(struct ath_softc *sc, struct ath_buf *bf, struct mbuf *m0) { +#if defined(__DragonFly__) +#else struct mbuf *m; +#endif int error; /* * Load the DMA map so any coalescing is done. This * also calculates the number of descriptors we need. */ +#if defined(__DragonFly__) + error = bus_dmamap_load_mbuf_segment(sc->sc_dmat, bf->bf_dmamap, m0, + bf->bf_segs, 1, &bf->bf_nseg, + BUS_DMA_NOWAIT); +#else error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m0, bf->bf_segs, &bf->bf_nseg, BUS_DMA_NOWAIT); +#endif if (error == EFBIG) { /* XXX packet requires too many descriptors */ bf->bf_nseg = ATH_MAX_SCATTER + 1; @@ -311,6 +328,12 @@ ath_tx_dmasetup(struct ath_softc *sc, struct ath_buf *bf, struct mbuf *m0) */ if (bf->bf_nseg > ATH_MAX_SCATTER) { /* too many desc's, linearize */ sc->sc_stats.ast_tx_linear++; +#if defined(__DragonFly__) + error = bus_dmamap_load_mbuf_defrag(sc->sc_dmat, + bf->bf_dmamap, &m0, + bf->bf_segs, ATH_TXDESC, + &bf->bf_nseg, BUS_DMA_NOWAIT); +#else m = m_collapse(m0, M_NOWAIT, ATH_MAX_SCATTER); if (m == NULL) { ieee80211_free_mbuf(m0); @@ -321,6 +344,7 @@ ath_tx_dmasetup(struct ath_softc *sc, struct ath_buf *bf, struct mbuf *m0) error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m0, bf->bf_segs, &bf->bf_nseg, BUS_DMA_NOWAIT); +#endif if (error != 0) { sc->sc_stats.ast_tx_busdma++; ieee80211_free_mbuf(m0); @@ -1183,7 +1207,7 @@ ath_tx_calc_ctsduration(struct ath_hal *ah, int rix, int cix, /* This mustn't be called for HT modes */ if (rt->info[cix].phy == IEEE80211_T_HT) { - printf("%s: HT rate where it shouldn't be (0x%x)\n", + kprintf("%s: HT rate where it shouldn't be (0x%x)\n", __func__, rt->info[cix].rateCode); return (-1); } @@ -1446,10 +1470,18 @@ ath_tx_should_swq_frame(struct ath_softc *sc, struct ath_node *an, * Other control/mgmt frame; bypass software queuing * for now! */ +#if defined(__DragonFly__) DPRINTF(sc, ATH_DEBUG_XMIT, + "%s: %s: Node is asleep; sending mgmt " + "(type=%d, subtype=%d)\n", + __func__, ath_hal_ether_sprintf(ni->ni_macaddr), + type, subtype); +#else + DPRINTF(sc, ATH_DEBUG_XMIT, "%s: %6D: Node is asleep; sending mgmt " "(type=%d, subtype=%d)\n", __func__, ni->ni_macaddr, ":", type, subtype); +#endif return (0); } else { return (1); @@ -1674,7 +1706,7 @@ ath_tx_normal_setup(struct ath_softc *sc, struct ieee80211_node *ni, break; default: device_printf(sc->sc_dev, "bogus frame type 0x%x (%s)\n", - wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK, __func__); + wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK, __func__); /* XXX statistic */ /* XXX free tx dmamap */ ieee80211_free_mbuf(m0); @@ -2766,6 +2798,16 @@ ath_tx_leak_count_update(struct ath_softc *sc, struct ath_tid *tid, else wh->i_fc[1] &= ~IEEE80211_FC1_MORE_DATA; +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, + "%s: %s: leak count = %d, psq=%d, swq=%d, MORE=%d\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->an->an_leak_count, + tid->an->an_stack_psq, + tid->an->an_swq_depth, + !! (wh->i_fc[1] & IEEE80211_FC1_MORE_DATA)); +#else DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: leak count = %d, psq=%d, swq=%d, MORE=%d\n", __func__, @@ -2775,6 +2817,7 @@ ath_tx_leak_count_update(struct ath_softc *sc, struct ath_tid *tid, tid->an->an_stack_psq, tid->an->an_swq_depth, !! (wh->i_fc[1] & IEEE80211_FC1_MORE_DATA)); +#endif /* * Re-sync the underlying buffer. @@ -3236,11 +3279,19 @@ ath_tx_tid_pause(struct ath_softc *sc, struct ath_tid *tid) ATH_TX_LOCK_ASSERT(sc); tid->paused++; +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: [%s]: tid=%d, paused = %d\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->tid, + tid->paused); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: [%6D]: tid=%d, paused = %d\n", __func__, tid->an->an_node.ni_macaddr, ":", tid->tid, tid->paused); +#endif } /* @@ -3257,21 +3308,38 @@ ath_tx_tid_resume(struct ath_softc *sc, struct ath_tid *tid) * until it's actually resolved. */ if (tid->paused == 0) { +#if defined(__DragonFly__) + device_printf(sc->sc_dev, + "%s: [%s]: tid=%d, paused=0?\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->tid); +#else device_printf(sc->sc_dev, "%s: [%6D]: tid=%d, paused=0?\n", __func__, tid->an->an_node.ni_macaddr, ":", tid->tid); +#endif } else { tid->paused--; } +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: [%s]: tid=%d, unpaused = %d\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->tid, + tid->paused); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: [%6D]: tid=%d, unpaused = %d\n", __func__, tid->an->an_node.ni_macaddr, ":", tid->tid, tid->paused); +#endif if (tid->paused) return; @@ -3547,18 +3615,34 @@ ath_tx_tid_bar_unsuspend(struct ath_softc *sc, struct ath_tid *tid) ATH_TX_LOCK_ASSERT(sc); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, + "%s: %s: TID=%d, called\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->tid); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, "%s: %6D: TID=%d, called\n", __func__, tid->an->an_node.ni_macaddr, ":", tid->tid); +#endif if (tid->bar_tx == 0 || tid->bar_wait == 0) { +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, + "%s: %s: TID=%d, bar_tx=%d, bar_wait=%d: ?\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->tid, tid->bar_tx, tid->bar_wait); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, "%s: %6D: TID=%d, bar_tx=%d, bar_wait=%d: ?\n", __func__, tid->an->an_node.ni_macaddr, ":", tid->tid, tid->bar_tx, tid->bar_wait); +#endif } tid->bar_tx = tid->bar_wait = 0; @@ -3579,12 +3663,20 @@ ath_tx_tid_bar_tx_ready(struct ath_softc *sc, struct ath_tid *tid) if (tid->bar_wait == 0 || tid->hwq_depth > 0) return (0); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, + "%s: %s: TID=%d, bar ready\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->tid); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, "%s: %6D: TID=%d, bar ready\n", __func__, tid->an->an_node.ni_macaddr, ":", tid->tid); +#endif return (1); } @@ -3608,12 +3700,20 @@ ath_tx_tid_bar_tx(struct ath_softc *sc, struct ath_tid *tid) ATH_TX_LOCK_ASSERT(sc); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, + "%s: %s: TID=%d, called\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->tid); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, "%s: %6D: TID=%d, called\n", __func__, tid->an->an_node.ni_macaddr, ":", tid->tid); +#endif tap = ath_tx_get_tx_tid(tid->an, tid->tid); @@ -3621,15 +3721,31 @@ ath_tx_tid_bar_tx(struct ath_softc *sc, struct ath_tid *tid) * This is an error condition! */ if (tid->bar_wait == 0 || tid->bar_tx == 1) { +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, + "%s: %s: TID=%d, bar_tx=%d, bar_wait=%d: ?\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->tid, tid->bar_tx, tid->bar_wait); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, "%s: %6D: TID=%d, bar_tx=%d, bar_wait=%d: ?\n", __func__, tid->an->an_node.ni_macaddr, ":", tid->tid, tid->bar_tx, tid->bar_wait); +#endif return; } /* Don't do anything if we still have pending frames */ if (tid->hwq_depth > 0) { +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, + "%s: %s: TID=%d, hwq_depth=%d, waiting\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->tid, + tid->hwq_depth); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, "%s: %6D: TID=%d, hwq_depth=%d, waiting\n", __func__, @@ -3637,6 +3753,7 @@ ath_tx_tid_bar_tx(struct ath_softc *sc, struct ath_tid *tid) ":", tid->tid, tid->hwq_depth); +#endif return; } @@ -3655,6 +3772,14 @@ ath_tx_tid_bar_tx(struct ath_softc *sc, struct ath_tid *tid) * * XXX verify this is _actually_ the valid value to begin at! */ +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, + "%s: %s: TID=%d, new BAW left edge=%d\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->tid, + tap->txa_start); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, "%s: %6D: TID=%d, new BAW left edge=%d\n", __func__, @@ -3662,6 +3787,7 @@ ath_tx_tid_bar_tx(struct ath_softc *sc, struct ath_tid *tid) ":", tid->tid, tap->txa_start); +#endif /* Try sending the BAR frame */ /* We can't hold the lock here! */ @@ -3675,10 +3801,18 @@ ath_tx_tid_bar_tx(struct ath_softc *sc, struct ath_tid *tid) /* Failure? For now, warn loudly and continue */ ATH_TX_LOCK(sc); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, + "%s: %s: TID=%d, failed to TX BAR, continue!\n", + __func__, + ath_hal_ether_sprintf(tid->an->an_node.ni_macaddr), + tid->tid); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, "%s: %6D: TID=%d, failed to TX BAR, continue!\n", __func__, tid->an->an_node.ni_macaddr, ":", tid->tid); +#endif ath_tx_tid_bar_unsuspend(sc, tid); } @@ -3733,6 +3867,19 @@ ath_tx_tid_drain_print(struct ath_softc *sc, struct ath_node *an, txq = sc->sc_ac2q[tid->ac]; tap = ath_tx_get_tx_tid(an, tid->tid); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX | ATH_DEBUG_RESET, + "%s: %s: %s: bf=%p: addbaw=%d, dobaw=%d, " + "seqno=%d, retry=%d\n", + __func__, + pfx, + ath_hal_ether_sprintf(ni->ni_macaddr), + bf, + bf->bf_state.bfs_addedbaw, + bf->bf_state.bfs_dobaw, + SEQNO(bf->bf_state.bfs_seqno), + bf->bf_state.bfs_retries); +#else DPRINTF(sc, ATH_DEBUG_SW_TX | ATH_DEBUG_RESET, "%s: %s: %6D: bf=%p: addbaw=%d, dobaw=%d, " "seqno=%d, retry=%d\n", @@ -3745,6 +3892,18 @@ ath_tx_tid_drain_print(struct ath_softc *sc, struct ath_node *an, bf->bf_state.bfs_dobaw, SEQNO(bf->bf_state.bfs_seqno), bf->bf_state.bfs_retries); +#endif +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX | ATH_DEBUG_RESET, + "%s: %s: %s: bf=%p: txq[%d] axq_depth=%d, axq_aggr_depth=%d\n", + __func__, + pfx, + ath_hal_ether_sprintf(ni->ni_macaddr), + bf, + txq->axq_qnum, + txq->axq_depth, + txq->axq_aggr_depth); +#else DPRINTF(sc, ATH_DEBUG_SW_TX | ATH_DEBUG_RESET, "%s: %s: %6D: bf=%p: txq[%d] axq_depth=%d, axq_aggr_depth=%d\n", __func__, @@ -3755,6 +3914,20 @@ ath_tx_tid_drain_print(struct ath_softc *sc, struct ath_node *an, txq->axq_qnum, txq->axq_depth, txq->axq_aggr_depth); +#endif +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX | ATH_DEBUG_RESET, + "%s: %s: %s: bf=%p: tid txq_depth=%d hwq_depth=%d, bar_wait=%d, " + "isfiltered=%d\n", + __func__, + pfx, + ath_hal_ether_sprintf(ni->ni_macaddr), + bf, + tid->axq_depth, + tid->hwq_depth, + tid->bar_wait, + tid->isfiltered); +#else DPRINTF(sc, ATH_DEBUG_SW_TX | ATH_DEBUG_RESET, "%s: %s: %6D: bf=%p: tid txq_depth=%d hwq_depth=%d, bar_wait=%d, " "isfiltered=%d\n", @@ -3767,6 +3940,22 @@ ath_tx_tid_drain_print(struct ath_softc *sc, struct ath_node *an, tid->hwq_depth, tid->bar_wait, tid->isfiltered); +#endif +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX | ATH_DEBUG_RESET, + "%s: %s: %s: tid %d: " + "sched=%d, paused=%d, " + "incomp=%d, baw_head=%d, " + "baw_tail=%d txa_start=%d, ni_txseqs=%d\n", + __func__, + pfx, + ath_hal_ether_sprintf(ni->ni_macaddr), + tid->tid, + tid->sched, tid->paused, + tid->incomp, tid->baw_head, + tid->baw_tail, tap == NULL ? -1 : tap->txa_start, + ni->ni_txseqs[tid->tid]); +#else DPRINTF(sc, ATH_DEBUG_SW_TX | ATH_DEBUG_RESET, "%s: %s: %6D: tid %d: " "sched=%d, paused=%d, " @@ -3781,7 +3970,7 @@ ath_tx_tid_drain_print(struct ath_softc *sc, struct ath_node *an, tid->incomp, tid->baw_head, tid->baw_tail, tap == NULL ? -1 : tap->txa_start, ni->ni_txseqs[tid->tid]); - +#endif /* XXX Dump the frame, see what it is? */ if (IFF_DUMPPKTS(sc, ATH_DEBUG_XMIT)) ieee80211_dump_pkt(ni->ni_ic, @@ -3875,6 +4064,17 @@ ath_tx_tid_drain(struct ath_softc *sc, struct ath_node *an, /* But don't do it for non-QoS TIDs */ if (tap) { #if 1 +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: %s: node %p: TID %d: sliding BAW left edge to %d\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + an, + tid->tid, + tap->txa_start); +#else + +#endif DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: %6D: node %p: TID %d: sliding BAW left edge to %d\n", __func__, @@ -3976,6 +4176,19 @@ ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an) &an->an_node); ATH_TX_LOCK(sc); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE, + "%s: %s: flush; is_powersave=%d, stack_psq=%d, tim=%d, " + "swq_depth=%d, clrdmask=%d, leak_count=%d\n", + __func__, + ath_hal_ether_sprintf(an->an_node.ni_macaddr), + an->an_is_powersave, + an->an_stack_psq, + an->an_tim_set, + an->an_swq_depth, + an->clrdmask, + an->an_leak_count); +#else DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: flush; is_powersave=%d, stack_psq=%d, tim=%d, " "swq_depth=%d, clrdmask=%d, leak_count=%d\n", @@ -3988,6 +4201,7 @@ ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an) an->an_swq_depth, an->clrdmask, an->an_leak_count); +#endif for (tid = 0; tid < IEEE80211_TID_SIZE; tid++) { struct ath_tid *atid = &an->an_tid[tid]; @@ -5747,12 +5961,20 @@ ath_addba_request(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, } ATH_TX_UNLOCK(sc); +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: %s: called; dialogtoken=%d, baparamset=%d, batimeout=%d\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + dialogtoken, baparamset, batimeout); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: %6D: called; dialogtoken=%d, baparamset=%d, batimeout=%d\n", __func__, ni->ni_macaddr, ":", dialogtoken, baparamset, batimeout); +#endif DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: txa_start=%d, ni_txseqs=%d\n", __func__, tap->txa_start, ni->ni_txseqs[tid]); @@ -5791,11 +6013,18 @@ ath_addba_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, struct ath_tid *atid = &an->an_tid[tid]; int r; +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: %s: called; status=%d, code=%d, batimeout=%d\n", __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + status, code, batimeout); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: %6D: called; status=%d, code=%d, batimeout=%d\n", __func__, ni->ni_macaddr, ":", status, code, batimeout); +#endif DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: txa_start=%d, ni_txseqs=%d\n", @@ -5839,10 +6068,16 @@ ath_addba_stop(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap) ath_bufhead bf_cq; struct ath_buf *bf; +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: %s: called\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr)); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: %6D: called\n", __func__, ni->ni_macaddr, ":"); +#endif /* * Pause TID traffic early, so there aren't any races @@ -5924,12 +6159,20 @@ ath_tx_node_reassoc(struct ath_softc *sc, struct ath_node *an) tid = &an->an_tid[i]; if (tid->hwq_depth == 0) continue; +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_NODE, + "%s: %s: TID %d: cleaning up TID\n", + __func__, + ath_hal_ether_sprintf(an->an_node.ni_macaddr), + i); +#else DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: TID %d: cleaning up TID\n", __func__, an->an_node.ni_macaddr, ":", i); +#endif /* * In case there's a followup call to this, only call it * if we don't have a cleanup in progress. @@ -5974,6 +6217,18 @@ ath_bar_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, int attempts = tap->txa_attempts; int old_txa_start; +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, + "%s: %s: called; txa_tid=%d, atid->tid=%d, status=%d, attempts=%d, txa_start=%d, txa_seqpending=%d\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + tap->txa_tid, + atid->tid, + status, + attempts, + tap->txa_start, + tap->txa_seqpending); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, "%s: %6D: called; txa_tid=%d, atid->tid=%d, status=%d, attempts=%d, txa_start=%d, txa_seqpending=%d\n", __func__, @@ -5985,6 +6240,7 @@ ath_bar_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, attempts, tap->txa_start, tap->txa_seqpending); +#endif /* Note: This may update the BAW details */ /* @@ -6045,12 +6301,20 @@ ath_addba_response_timeout(struct ieee80211_node *ni, struct ath_node *an = ATH_NODE(ni); struct ath_tid *atid = &an->an_tid[tid]; +#if defined(__DragonFly__) + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: %s: TID=%d, called; resuming\n", + __func__, + ath_hal_ether_sprintf(ni->ni_macaddr), + tid); +#else DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: %6D: TID=%d, called; resuming\n", __func__, ni->ni_macaddr, ":", tid); +#endif ATH_TX_LOCK(sc); atid->addba_tx_pending = 0; @@ -6108,9 +6372,15 @@ ath_tx_node_sleep(struct ath_softc *sc, struct ath_node *an) ATH_TX_LOCK(sc); if (an->an_is_powersave) { +#if defined(__DragonFly__) DPRINTF(sc, ATH_DEBUG_XMIT, - "%s: %6D: node was already asleep!\n", - __func__, an->an_node.ni_macaddr, ":"); + "%s: %s: node was already asleep!\n", + __func__, ath_hal_ether_sprintf(an->an_node.ni_macaddr)); +#else + DPRINTF(sc, ATH_DEBUG_XMIT, + "%s: %6D: node was already asleep!\n", + __func__, an->an_node.ni_macaddr, ":"); +#endif ATH_TX_UNLOCK(sc); return; } diff --git a/sys/dev/netif/ath/ath/if_ath_tx_edma.c b/sys/dev/netif/ath/ath/if_ath_tx_edma.c index 44835c53f4..4c5c259aae 100644 --- a/sys/dev/netif/ath/ath/if_ath_tx_edma.c +++ b/sys/dev/netif/ath/ath/if_ath_tx_edma.c @@ -68,9 +68,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* for mp_ncpus */ +#if defined(__DragonFly__) +/* empty */ +#else +#include #include +#endif #include #include @@ -80,14 +84,17 @@ __FBSDID("$FreeBSD$"); #include #include #include +#if defined(__DragonFly__) +#include +#endif -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #include @@ -97,30 +104,30 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include /* XXX for softled */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef ATH_TX99_DIAG -#include +#include #endif -#include +#include #ifdef ATH_DEBUG_ALQ -#include +#include #endif /* @@ -468,9 +475,8 @@ ath_edma_setup_txfifo(struct ath_softc *sc, int qnum) { struct ath_tx_edma_fifo *te = &sc->sc_txedma[qnum]; - te->m_fifo = malloc(sizeof(struct ath_buf *) * HAL_TXFIFO_DEPTH, - M_ATHDEV, - M_NOWAIT | M_ZERO); + te->m_fifo = kmalloc(sizeof(struct ath_buf *) * HAL_TXFIFO_DEPTH, + M_ATHDEV, M_INTWAIT | M_ZERO); if (te->m_fifo == NULL) { device_printf(sc->sc_dev, "%s: malloc failed\n", __func__); @@ -491,7 +497,7 @@ ath_edma_free_txfifo(struct ath_softc *sc, int qnum) struct ath_tx_edma_fifo *te = &sc->sc_txedma[qnum]; /* XXX TODO: actually deref the ath_buf entries? */ - free(te->m_fifo, M_ATHDEV); + kfree(te->m_fifo, M_ATHDEV); return (0); } diff --git a/sys/dev/netif/ath/ath/if_ath_tx_ht.c b/sys/dev/netif/ath/ath/if_ath_tx_ht.c index 75e949afdd..1658e3769b 100644 --- a/sys/dev/netif/ath/ath/if_ath_tx_ht.c +++ b/sys/dev/netif/ath/ath/if_ath_tx_ht.c @@ -52,7 +52,11 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include +#endif #include #include @@ -62,13 +66,13 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #include @@ -78,18 +82,18 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include /* XXX for softled */ -#include +#include +#include /* XXX for softled */ +#include #ifdef ATH_TX99_DIAG -#include +#include #endif -#include /* XXX for some support functions */ -#include -#include -#include +#include /* XXX for some support functions */ +#include +#include +#include /* * XXX net80211? diff --git a/sys/dev/netif/ath/ath/if_athvar.h b/sys/dev/netif/ath/ath/if_athvar.h index 9052ebeaef..2d2fdc8911 100644 --- a/sys/dev/netif/ath/ath/if_athvar.h +++ b/sys/dev/netif/ath/ath/if_athvar.h @@ -37,17 +37,21 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef ATH_DEBUG_ALQ -#include +#include #endif #define ATH_TIMEOUT 1000 +#if defined(__DragonFly__) +#define ATH_ENABLE_11N +#endif + /* * There is a separate TX ath_buf pool for management frames. * This ensures that management frames such as probe responses @@ -197,7 +201,11 @@ struct ath_node { struct ath_buf *an_ff_buf[WME_NUM_AC]; /* ff staging area */ struct ath_tid an_tid[IEEE80211_TID_SIZE]; /* per-TID state */ char an_name[32]; /* eg "wlan0_a1" */ +#if defined(__DragonFly__) + struct lock an_mtx; /* protecting the rate control state */ +#else struct mtx an_mtx; /* protecting the rate control state */ +#endif uint32_t an_swq_depth; /* how many SWQ packets for this node */ int clrdmask; /* has clrdmask been set */ @@ -354,7 +362,11 @@ struct ath_txq { u_int axq_intrcnt; /* interrupt count */ u_int32_t *axq_link; /* link ptr in last TX desc */ TAILQ_HEAD(axq_q_s, ath_buf) axq_q; /* transmit queue */ +#if defined(__DragonFly__) + struct lock axq_lock; /* lock on q and link */ +#else struct mtx axq_lock; /* lock on q and link */ +#endif /* * This is the FIFO staging buffer when doing EDMA. @@ -394,24 +406,25 @@ struct ath_txq { TAILQ_HEAD(axq_t_s,ath_tid) axq_tidq; }; +/* + * Macros modified for DragonFly + */ #define ATH_TXQ_LOCK_INIT(_sc, _tq) do { \ - snprintf((_tq)->axq_name, sizeof((_tq)->axq_name), "%s_txq%u", \ + ksnprintf((_tq)->axq_name, sizeof((_tq)->axq_name), "%s_txq%u", \ device_get_nameunit((_sc)->sc_dev), (_tq)->axq_qnum); \ - mtx_init(&(_tq)->axq_lock, (_tq)->axq_name, NULL, MTX_DEF); \ + lockinit(&(_tq)->axq_lock, (_tq)->axq_name, 0, 0); \ } while (0) -#define ATH_TXQ_LOCK_DESTROY(_tq) mtx_destroy(&(_tq)->axq_lock) -#define ATH_TXQ_LOCK(_tq) mtx_lock(&(_tq)->axq_lock) -#define ATH_TXQ_UNLOCK(_tq) mtx_unlock(&(_tq)->axq_lock) -#define ATH_TXQ_LOCK_ASSERT(_tq) mtx_assert(&(_tq)->axq_lock, MA_OWNED) -#define ATH_TXQ_UNLOCK_ASSERT(_tq) mtx_assert(&(_tq)->axq_lock, \ - MA_NOTOWNED) +#define ATH_TXQ_LOCK_DESTROY(_tq) lockuninit(&(_tq)->axq_lock) +#define ATH_TXQ_LOCK(_tq) lockmgr(&(_tq)->axq_lock, LK_EXCLUSIVE) +#define ATH_TXQ_UNLOCK(_tq) lockmgr(&(_tq)->axq_lock, LK_RELEASE) +#define ATH_TXQ_LOCK_ASSERT(_tq) KKASSERT(lockstatus(&(_tq)->axq_lock, curthread) == LK_EXCLUSIVE) +#define ATH_TXQ_UNLOCK_ASSERT(_tq) KKASSERT(lockstatus(&(_tq)->axq_lock, curthread) != LK_EXCLUSIVE) -#define ATH_NODE_LOCK(_an) mtx_lock(&(_an)->an_mtx) -#define ATH_NODE_UNLOCK(_an) mtx_unlock(&(_an)->an_mtx) -#define ATH_NODE_LOCK_ASSERT(_an) mtx_assert(&(_an)->an_mtx, MA_OWNED) -#define ATH_NODE_UNLOCK_ASSERT(_an) mtx_assert(&(_an)->an_mtx, \ - MA_NOTOWNED) +#define ATH_NODE_LOCK(_an) lockmgr(&(_an)->an_mtx, LK_EXCLUSIVE) +#define ATH_NODE_UNLOCK(_an) lockmgr(&(_an)->an_mtx, LK_RELEASE) +#define ATH_NODE_LOCK_ASSERT(_an) KKASSERT(lockstatus(&(_an)->an_mtx, curthread) == LK_EXCLUSIVE) +#define ATH_NODE_UNLOCK_ASSERT(_an) KKASSERT(lockstatus(&(_an)->an_mtx, curthread) != LK_EXCLUSIVE) /* * These are for the hardware queue. @@ -594,14 +607,31 @@ struct ath_softc { HAL_BUS_TAG sc_st; /* bus space tag */ HAL_BUS_HANDLE sc_sh; /* bus space handle */ bus_dma_tag_t sc_dmat; /* bus DMA tag */ +#if defined(__DragonFly__) + struct lock sc_mtx; /* master lock (recursive) */ + struct lock sc_pcu_mtx; /* PCU access mutex */ +#else struct mtx sc_mtx; /* master lock (recursive) */ struct mtx sc_pcu_mtx; /* PCU access mutex */ +#endif char sc_pcu_mtx_name[32]; +#if defined(__DragonFly__) + struct lock sc_rx_mtx; /* RX access mutex */ +#else struct mtx sc_rx_mtx; /* RX access mutex */ +#endif char sc_rx_mtx_name[32]; +#if defined(__DragonFly__) + struct lock sc_tx_mtx; /* TX handling/comp mutex */ +#else struct mtx sc_tx_mtx; /* TX handling/comp mutex */ +#endif char sc_tx_mtx_name[32]; +#if defined(__DragonFly__) + struct lock sc_tx_ic_mtx; /* TX queue mutex */ +#else struct mtx sc_tx_ic_mtx; /* TX queue mutex */ +#endif char sc_tx_ic_mtx_name[32]; struct taskqueue *sc_tq; /* private task queue */ struct ath_hal *sc_ah; /* Atheros HAL */ @@ -752,7 +782,11 @@ struct ath_softc { struct ath_descdma sc_txdma_mgmt; /* mgmt TX descriptors */ ath_bufhead sc_txbuf_mgmt; /* mgmt transmit buffer */ struct ath_descdma sc_txsdma; /* EDMA TX status desc's */ +#if defined(__DragonFly__) + struct lock sc_txbuflock; /* txbuf lock */ +#else struct mtx sc_txbuflock; /* txbuf lock */ +#endif char sc_txname[12]; /* e.g. "ath0_buf" */ u_int sc_txqsetup; /* h/w queues setup */ u_int sc_txintrperiod;/* tx interrupt batching */ @@ -762,7 +796,11 @@ struct ath_softc { struct task sc_txqtask; /* tx proc processing */ struct ath_descdma sc_txcompdma; /* TX EDMA completion */ +#if defined(__DragonFly__) + struct lock sc_txcomplock; /* TX EDMA completion lock */ +#else struct mtx sc_txcomplock; /* TX EDMA completion lock */ +#endif char sc_txcompname[12]; /* eg ath0_txcomp */ int sc_wd_timer; /* count down for wd timer */ @@ -911,35 +949,31 @@ struct ath_softc { }; #define ATH_LOCK_INIT(_sc) \ - mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \ - NULL, MTX_DEF | MTX_RECURSE) -#define ATH_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx) -#define ATH_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) -#define ATH_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) -#define ATH_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED) -#define ATH_UNLOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_NOTOWNED) + lockinit(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \ + 0, LK_CANRECURSE) +#define ATH_LOCK_DESTROY(_sc) lockuninit(&(_sc)->sc_mtx) +#define ATH_LOCK(_sc) lockmgr(&(_sc)->sc_mtx, LK_EXCLUSIVE) +#define ATH_UNLOCK(_sc) lockmgr(&(_sc)->sc_mtx, LK_RELEASE) +#define ATH_LOCK_ASSERT(_sc) KKASSERT(lockstatus(&(_sc)->sc_mtx, curthread) == LK_EXCLUSIVE) +#define ATH_UNLOCK_ASSERT(_sc) KKASSERT(lockstatus(&(_sc)->sc_mtx, curthread) != LK_EXCLUSIVE) /* * The TX lock is non-reentrant and serialises the TX frame send * and completion operations. */ #define ATH_TX_LOCK_INIT(_sc) do {\ - snprintf((_sc)->sc_tx_mtx_name, \ + ksnprintf((_sc)->sc_tx_mtx_name, \ sizeof((_sc)->sc_tx_mtx_name), \ "%s TX lock", \ device_get_nameunit((_sc)->sc_dev)); \ - mtx_init(&(_sc)->sc_tx_mtx, (_sc)->sc_tx_mtx_name, \ - NULL, MTX_DEF); \ + lockinit(&(_sc)->sc_tx_mtx, (_sc)->sc_tx_mtx_name, \ + 0, 0); \ } while (0) -#define ATH_TX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_tx_mtx) -#define ATH_TX_LOCK(_sc) mtx_lock(&(_sc)->sc_tx_mtx) -#define ATH_TX_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_tx_mtx) -#define ATH_TX_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_tx_mtx, \ - MA_OWNED) -#define ATH_TX_UNLOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_tx_mtx, \ - MA_NOTOWNED) -#define ATH_TX_TRYLOCK(_sc) (mtx_owned(&(_sc)->sc_tx_mtx) != 0 && \ - mtx_trylock(&(_sc)->sc_tx_mtx)) +#define ATH_TX_LOCK_DESTROY(_sc) lockuninit(&(_sc)->sc_tx_mtx) +#define ATH_TX_LOCK(_sc) lockmgr(&(_sc)->sc_tx_mtx, LK_EXCLUSIVE) +#define ATH_TX_UNLOCK(_sc) lockmgr(&(_sc)->sc_tx_mtx, LK_RELEASE) +#define ATH_TX_LOCK_ASSERT(_sc) KKASSERT(lockstatus(&(_sc)->sc_tx_mtx, curthread) == LK_EXCLUSIVE) +#define ATH_TX_UNLOCK_ASSERT(_sc) KKASSERT(lockstatus(&(_sc)->sc_tx_mtx, curthread) != LK_EXCLUSIVE) /* * The PCU lock is non-recursive and should be treated as a spinlock. @@ -959,20 +993,18 @@ struct ath_softc { * ath_set_channel, the channel scanning API and perhaps quite a bit more. */ #define ATH_PCU_LOCK_INIT(_sc) do {\ - snprintf((_sc)->sc_pcu_mtx_name, \ + ksnprintf((_sc)->sc_pcu_mtx_name, \ sizeof((_sc)->sc_pcu_mtx_name), \ "%s PCU lock", \ device_get_nameunit((_sc)->sc_dev)); \ - mtx_init(&(_sc)->sc_pcu_mtx, (_sc)->sc_pcu_mtx_name, \ - NULL, MTX_DEF); \ + lockinit(&(_sc)->sc_pcu_mtx, (_sc)->sc_pcu_mtx_name, \ + 0, 0); \ } while (0) -#define ATH_PCU_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_pcu_mtx) -#define ATH_PCU_LOCK(_sc) mtx_lock(&(_sc)->sc_pcu_mtx) -#define ATH_PCU_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_pcu_mtx) -#define ATH_PCU_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_pcu_mtx, \ - MA_OWNED) -#define ATH_PCU_UNLOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_pcu_mtx, \ - MA_NOTOWNED) +#define ATH_PCU_LOCK_DESTROY(_sc) lockuninit(&(_sc)->sc_pcu_mtx) +#define ATH_PCU_LOCK(_sc) lockmgr(&(_sc)->sc_pcu_mtx, LK_EXCLUSIVE) +#define ATH_PCU_UNLOCK(_sc) lockmgr(&(_sc)->sc_pcu_mtx, LK_RELEASE) +#define ATH_PCU_LOCK_ASSERT(_sc) KKASSERT(lockstatus(&(_sc)->sc_pcu_mtx, curthread) == LK_EXCLUSIVE) +#define ATH_PCU_UNLOCK_ASSERT(_sc) KKASSERT(lockstatus(&(_sc)->sc_pcu_mtx, curthread) != LK_EXCLUSIVE) /* * The RX lock is primarily a(nother) workaround to ensure that the @@ -981,48 +1013,46 @@ struct ath_softc { * RX path can be executed via various reset/channel change paths. */ #define ATH_RX_LOCK_INIT(_sc) do {\ - snprintf((_sc)->sc_rx_mtx_name, \ + ksnprintf((_sc)->sc_rx_mtx_name, \ sizeof((_sc)->sc_rx_mtx_name), \ "%s RX lock", \ device_get_nameunit((_sc)->sc_dev)); \ - mtx_init(&(_sc)->sc_rx_mtx, (_sc)->sc_rx_mtx_name, \ - NULL, MTX_DEF); \ + lockinit(&(_sc)->sc_rx_mtx, (_sc)->sc_rx_mtx_name, \ + 0, 0); \ } while (0) -#define ATH_RX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_rx_mtx) -#define ATH_RX_LOCK(_sc) mtx_lock(&(_sc)->sc_rx_mtx) -#define ATH_RX_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_rx_mtx) -#define ATH_RX_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_rx_mtx, \ - MA_OWNED) -#define ATH_RX_UNLOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_rx_mtx, \ - MA_NOTOWNED) +#define ATH_RX_LOCK_DESTROY(_sc) lockuninit(&(_sc)->sc_rx_mtx) +#define ATH_RX_LOCK(_sc) lockmgr(&(_sc)->sc_rx_mtx, LK_EXCLUSIVE) +#define ATH_RX_UNLOCK(_sc) lockmgr(&(_sc)->sc_rx_mtx, LK_RELEASE) +#define ATH_RX_LOCK_ASSERT(_sc) KKASSERT(lockstatus(&(_sc)->sc_rx_mtx, curthread) == LK_EXCLUSIVE) +#define ATH_RX_UNLOCK_ASSERT(_sc) KKASSERT(lockstatus(&(_sc)->sc_rx_mtx, curthread) != LK_EXCLUSIVE) #define ATH_TXQ_SETUP(sc, i) ((sc)->sc_txqsetup & (1<sc_txname, sizeof((_sc)->sc_txname), "%s_buf", \ + ksnprintf((_sc)->sc_txname, sizeof((_sc)->sc_txname), "%s_buf", \ device_get_nameunit((_sc)->sc_dev)); \ - mtx_init(&(_sc)->sc_txbuflock, (_sc)->sc_txname, NULL, MTX_DEF); \ + lockinit(&(_sc)->sc_txbuflock, (_sc)->sc_txname, 0, 0); \ } while (0) -#define ATH_TXBUF_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_txbuflock) -#define ATH_TXBUF_LOCK(_sc) mtx_lock(&(_sc)->sc_txbuflock) -#define ATH_TXBUF_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_txbuflock) +#define ATH_TXBUF_LOCK_DESTROY(_sc) lockuninit(&(_sc)->sc_txbuflock) +#define ATH_TXBUF_LOCK(_sc) lockmgr(&(_sc)->sc_txbuflock, LK_EXCLUSIVE) +#define ATH_TXBUF_UNLOCK(_sc) lockmgr(&(_sc)->sc_txbuflock, LK_RELEASE) #define ATH_TXBUF_LOCK_ASSERT(_sc) \ - mtx_assert(&(_sc)->sc_txbuflock, MA_OWNED) + KKASSERT(lockstatus(&(_sc)->sc_txbuflock, curthread) == LK_EXCLUSIVE) #define ATH_TXBUF_UNLOCK_ASSERT(_sc) \ - mtx_assert(&(_sc)->sc_txbuflock, MA_NOTOWNED) + KKASSERT(lockstatus(&(_sc)->sc_txbuflock, curthread) != LK_EXCLUSIVE) #define ATH_TXSTATUS_LOCK_INIT(_sc) do { \ - snprintf((_sc)->sc_txcompname, sizeof((_sc)->sc_txcompname), \ + ksnprintf((_sc)->sc_txcompname, sizeof((_sc)->sc_txcompname), \ "%s_buf", \ device_get_nameunit((_sc)->sc_dev)); \ - mtx_init(&(_sc)->sc_txcomplock, (_sc)->sc_txcompname, NULL, \ - MTX_DEF); \ + lockinit(&(_sc)->sc_txcomplock, (_sc)->sc_txcompname, 0, \ + 0); \ } while (0) -#define ATH_TXSTATUS_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_txcomplock) -#define ATH_TXSTATUS_LOCK(_sc) mtx_lock(&(_sc)->sc_txcomplock) -#define ATH_TXSTATUS_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_txcomplock) +#define ATH_TXSTATUS_LOCK_DESTROY(_sc) lockuninit(&(_sc)->sc_txcomplock) +#define ATH_TXSTATUS_LOCK(_sc) lockmgr(&(_sc)->sc_txcomplock, LK_EXCLUSIVE) +#define ATH_TXSTATUS_UNLOCK(_sc) lockmgr(&(_sc)->sc_txcomplock, LK_RELEASE) #define ATH_TXSTATUS_LOCK_ASSERT(_sc) \ - mtx_assert(&(_sc)->sc_txcomplock, MA_OWNED) + KKASSERT(lockstatus(&(_sc)->sc_txcomplock, curthread) == LK_EXCLUSIVE) int ath_attach(u_int16_t, struct ath_softc *); int ath_detach(struct ath_softc *); @@ -1031,6 +1061,13 @@ void ath_suspend(struct ath_softc *); void ath_shutdown(struct ath_softc *); void ath_intr(void *); +#if defined(__DragonFly__) + +#define IF_LOCK(ifsnd) /* XXX */ +#define IF_UNLOCK(ifsnd) /* XXX */ + +#endif + /* * HAL definitions to comply with local coding convention. */ @@ -1333,7 +1370,7 @@ void ath_intr(void *); (ath_hal_getcapability(_ah, HAL_CAP_RXSTATUSLEN, 0, _req) \ == HAL_OK) #define ath_hal_setrxbufsize(_ah, _req) \ - (ath_hal_setcapability(_ah, HAL_CAP_RXBUFSIZE, 0, _req, NULL) \ + ((int)ath_hal_setcapability(_ah, HAL_CAP_RXBUFSIZE, 0, _req, NULL) \ == HAL_OK) #define ath_hal_getchannoise(_ah, _c) \ diff --git a/sys/dev/netif/ath/ath_dfs/null/dfs_null.c b/sys/dev/netif/ath/ath_dfs/null/dfs_null.c index e31a61d857..da4390b4e9 100644 --- a/sys/dev/netif/ath/ath_dfs/null/dfs_null.c +++ b/sys/dev/netif/ath/ath_dfs/null/dfs_null.c @@ -47,8 +47,12 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include #include +#endif #include #include @@ -59,7 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include /* XXX for ether_sprintf */ -#include +#include #include @@ -68,10 +72,10 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include +#include +#include -#include +#include /* * Methods which are required @@ -230,7 +234,7 @@ ath_ioctl_phyerr(struct ath_softc *sc, struct ath_diag *ad) /* * Copy in data. */ - indata = malloc(insize, M_TEMP, M_NOWAIT); + indata = kmalloc(insize, M_TEMP, M_INTWAIT); if (indata == NULL) { error = ENOMEM; goto bad; @@ -247,7 +251,7 @@ ath_ioctl_phyerr(struct ath_softc *sc, struct ath_diag *ad) * pointer for us to use below in reclaiming the buffer; * may want to be more defensive. */ - outdata = malloc(outsize, M_TEMP, M_NOWAIT); + outdata = kmalloc(outsize, M_TEMP, M_INTWAIT); if (outdata == NULL) { error = ENOMEM; goto bad; @@ -278,9 +282,9 @@ ath_ioctl_phyerr(struct ath_softc *sc, struct ath_diag *ad) error = EFAULT; bad: if ((ad->ad_id & ATH_DIAG_IN) && indata != NULL) - free(indata, M_TEMP); + kfree(indata, M_TEMP); if ((ad->ad_id & ATH_DIAG_DYN) && outdata != NULL) - free(outdata, M_TEMP); + kfree(outdata, M_TEMP); return (error); } @@ -293,3 +297,44 @@ ath_dfs_get_thresholds(struct ath_softc *sc, HAL_PHYERR_PARAM *param) ath_hal_getdfsthresh(sc->sc_ah, param); return (1); } + +#if defined(__DragonFly__) +/* + * Module glue. + */ +static int +null_dfs_modevent(module_t mod, int type, void *unused) +{ + int error; + + wlan_serialize_enter(); + + switch (type) { + case MOD_LOAD: + if (bootverbose) { + kprintf("ath_dfs: WTF module\n"); + } + error = 0; + break; + case MOD_UNLOAD: + error = 0; + break; + default: + error = EINVAL; + break; + } + wlan_serialize_exit(); + + return error; +} + +static moduledata_t null_dfs_mod = { + "ath_dfs", + null_dfs_modevent, + 0 +}; + +DECLARE_MODULE(ath_dfs, null_dfs_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); +MODULE_VERSION(ath_dfs, 1); + +#endif diff --git a/sys/dev/netif/ath/ath_hal/Makefile b/sys/dev/netif/ath/ath_hal/Makefile index 8de294f8d0..936a36c8fc 100644 --- a/sys/dev/netif/ath/ath_hal/Makefile +++ b/sys/dev/netif/ath/ath_hal/Makefile @@ -93,12 +93,22 @@ SRCS+= ar9287.c ar9287_reset.c ar9287_attach.c ar9287_cal.c ar9287_olc.c # + AR9300 HAL .PATH: ${HALCONTRIB}/ar9300 -SRCS+= ar9300_interrupts.c ar9300_radar.c ar9300_ani.c ar9300_keycache.c -SRCS+= ar9300_radio.c ar9300_xmit.c ar9300_attach.c ar9300_mci.c ar9300_stub.c -SRCS+= ar9300_xmit_ds.c ar9300_beacon.c ar9300_misc.c ar9300_recv.c -SRCS+= ar9300_stub_funcs.c ar9300_eeprom.c ar9300_paprd.c ar9300_recv_ds.c -SRCS+= ar9300_freebsd.c ar9300_phy.c ar9300_reset.c ar9300_gpio.c -SRCS+= ar9300_power.c ar9300_timer.c +#SRCS+= ar9300_interrupts.c ar9300_radar.c ar9300_ani.c ar9300_keycache.c +#SRCS+= ar9300_radio.c ar9300_xmit.c ar9300_attach.c ar9300_mci.c ar9300_stub.c +#SRCS+= ar9300_xmit_ds.c ar9300_beacon.c ar9300_misc.c ar9300_recv.c +#SRCS+= ar9300_stub_funcs.c ar9300_eeprom.c ar9300_paprd.c ar9300_recv_ds.c +#SRCS+= ar9300_freebsd.c ar9300_phy.c ar9300_reset.c ar9300_gpio.c +#SRCS+= ar9300_power.c ar9300_timer.c + +SRCS+= ar9300_aic.c ar9300_ani.c ar9300_attach.c ar9300_beacon.c +SRCS+= ar9300_eeprom.c ar9300_freebsd.c ar9300_gpio.c ar9300_interrupts.c +SRCS+= ar9300_keycache.c ar9300_mci.c ar9300_misc.c ar9300_paprd.c +SRCS+= ar9300_phy.c ar9300_power.c ar9300_radar.c ar9300_radio.c +SRCS+= ar9300_raw_adc_capture.c ar9300_recv.c ar9300_recv_ds.c ar9300_reset.c +SRCS+= ar9300_rtt.c ar9300_spectral.c ar9300_stub.c +SRCS+= ar9300_stub_funcs.c ar9300_timer.c ar9300_tx99_tgt.c ar9300_txbf.c +SRCS+= ar9300_txbf_cal.c ar9300_xmit.c ar9300_xmit_ds.c +# missing ar9300_sim.c CFLAGS+= -I. -I${HAL} -I${HALCONTRIB} diff --git a/sys/dev/netif/ath/ath_hal/ah.c b/sys/dev/netif/ath/ath_hal/ah.c index e14feb26c1..f433d7a02f 100644 --- a/sys/dev/netif/ath/ath_hal/ah.c +++ b/sys/dev/netif/ath/ath_hal/ah.c @@ -939,10 +939,6 @@ ath_hal_getdiagstate(struct ath_hal *ah, int request, } else return AH_FALSE; return AH_TRUE; - case HAL_DIAG_CHANSURVEY: - *result = &AH_PRIVATE(ah)->ah_chansurvey; - *resultsize = sizeof(HAL_CHANNEL_SURVEY); - return AH_TRUE; } return AH_FALSE; } @@ -1441,18 +1437,17 @@ ath_hal_mhz2ieee_2ghz(struct ath_hal *ah, int freq) /* * Clear the current survey data. - * + * * This should be done during a channel change. */ void ath_hal_survey_clear(struct ath_hal *ah) { - OS_MEMZERO(&AH_PRIVATE(ah)->ah_chansurvey, sizeof(AH_PRIVATE(ah)->ah_chansurvey)); } -/* +/* * Add a sample to the channel survey. */ void diff --git a/sys/dev/netif/ath/ath_hal/ah.h b/sys/dev/netif/ath/ath_hal/ah.h index cb98888613..b9430094a3 100644 --- a/sys/dev/netif/ath/ath_hal/ah.h +++ b/sys/dev/netif/ath/ath_hal/ah.h @@ -538,16 +538,16 @@ typedef enum { /* XXX this is duplicate information! */ typedef struct { - u_int32_t cyclecnt_diff; /* delta cycle count */ - u_int32_t rxclr_cnt; /* rx clear count */ - u_int32_t extrxclr_cnt; /* ext chan rx clear count */ - u_int32_t txframecnt_diff; /* delta tx frame count */ - u_int32_t rxframecnt_diff; /* delta rx frame count */ - u_int32_t listen_time; /* listen time in msec - time for which ch is free */ - u_int32_t ofdmphyerr_cnt; /* OFDM err count since last reset */ - u_int32_t cckphyerr_cnt; /* CCK err count since last reset */ - u_int32_t ofdmphyerrcnt_diff; /* delta OFDM Phy Error Count */ - HAL_BOOL valid; /* if the stats are valid*/ + u_int32_t cyclecnt_diff; /* delta cycle count */ + u_int32_t rxclr_cnt; /* rx clear count */ + u_int32_t extrxclr_cnt; /* ext chan rx clear count */ + u_int32_t txframecnt_diff; /* delta tx frame count */ + u_int32_t rxframecnt_diff; /* delta rx frame count */ + u_int32_t listen_time; /* listen time in msec - time for which ch is free */ + u_int32_t ofdmphyerr_cnt; /* OFDM err count since last reset */ + u_int32_t cckphyerr_cnt; /* CCK err count since last reset */ + u_int32_t ofdmphyerrcnt_diff; /* delta OFDM Phy Error Count */ + HAL_BOOL valid; /* if the stats are valid*/ } HAL_ANISTATS; typedef struct { @@ -863,40 +863,40 @@ typedef struct { * to fetch ANI information. */ typedef struct { - uint32_t ast_ani_niup; /* ANI increased noise immunity */ - uint32_t ast_ani_nidown; /* ANI decreased noise immunity */ - uint32_t ast_ani_spurup; /* ANI increased spur immunity */ - uint32_t ast_ani_spurdown;/* ANI descreased spur immunity */ - uint32_t ast_ani_ofdmon; /* ANI OFDM weak signal detect on */ - uint32_t ast_ani_ofdmoff;/* ANI OFDM weak signal detect off */ - uint32_t ast_ani_cckhigh;/* ANI CCK weak signal threshold high */ - uint32_t ast_ani_ccklow; /* ANI CCK weak signal threshold low */ - uint32_t ast_ani_stepup; /* ANI increased first step level */ - uint32_t ast_ani_stepdown;/* ANI decreased first step level */ - uint32_t ast_ani_ofdmerrs;/* ANI cumulative ofdm phy err count */ - uint32_t ast_ani_cckerrs;/* ANI cumulative cck phy err count */ - uint32_t ast_ani_reset; /* ANI parameters zero'd for non-STA */ - uint32_t ast_ani_lzero; /* ANI listen time forced to zero */ - uint32_t ast_ani_lneg; /* ANI listen time calculated < 0 */ - HAL_MIB_STATS ast_mibstats; /* MIB counter stats */ - HAL_NODE_STATS ast_nodestats; /* Latest rssi stats from driver */ + uint32_t ast_ani_niup; /* ANI increased noise immunity */ + uint32_t ast_ani_nidown; /* ANI decreased noise immunity */ + uint32_t ast_ani_spurup; /* ANI increased spur immunity */ + uint32_t ast_ani_spurdown;/* ANI descreased spur immunity */ + uint32_t ast_ani_ofdmon; /* ANI OFDM weak signal detect on */ + uint32_t ast_ani_ofdmoff;/* ANI OFDM weak signal detect off */ + uint32_t ast_ani_cckhigh;/* ANI CCK weak signal threshold high */ + uint32_t ast_ani_ccklow; /* ANI CCK weak signal threshold low */ + uint32_t ast_ani_stepup; /* ANI increased first step level */ + uint32_t ast_ani_stepdown;/* ANI decreased first step level */ + uint32_t ast_ani_ofdmerrs;/* ANI cumulative ofdm phy err count */ + uint32_t ast_ani_cckerrs;/* ANI cumulative cck phy err count */ + uint32_t ast_ani_reset; /* ANI parameters zero'd for non-STA */ + uint32_t ast_ani_lzero; /* ANI listen time forced to zero */ + uint32_t ast_ani_lneg; /* ANI listen time calculated < 0 */ + HAL_MIB_STATS ast_mibstats; /* MIB counter stats */ + HAL_NODE_STATS ast_nodestats; /* Latest rssi stats from driver */ } HAL_ANI_STATS; typedef struct { - uint8_t noiseImmunityLevel; - uint8_t spurImmunityLevel; - uint8_t firstepLevel; - uint8_t ofdmWeakSigDetectOff; - uint8_t cckWeakSigThreshold; - uint32_t listenTime; + uint8_t noiseImmunityLevel; + uint8_t spurImmunityLevel; + uint8_t firstepLevel; + uint8_t ofdmWeakSigDetectOff; + uint8_t cckWeakSigThreshold; + uint32_t listenTime; /* NB: intentionally ordered so data exported to user space is first */ - uint32_t txFrameCount; /* Last txFrameCount */ - uint32_t rxFrameCount; /* Last rx Frame count */ - uint32_t cycleCount; /* Last cycleCount + uint32_t txFrameCount; /* Last txFrameCount */ + uint32_t rxFrameCount; /* Last rx Frame count */ + uint32_t cycleCount; /* Last cycleCount (to detect wrap-around) */ - uint32_t ofdmPhyErrCount;/* OFDM err count since last reset */ - uint32_t cckPhyErrCount; /* CCK err count since last reset */ + uint32_t ofdmPhyErrCount;/* OFDM err count since last reset */ + uint32_t cckPhyErrCount; /* CCK err count since last reset */ } HAL_ANI_STATE; struct ath_desc; diff --git a/sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c b/sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c index abdbce0564..0cef0e8d56 100644 --- a/sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c +++ b/sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c @@ -248,8 +248,9 @@ v9287EepromReadCTLInfo(struct ath_hal *ah, HAL_EEPROM_9287 *ee) HALASSERT(AR9287_NUM_CTLS <= sizeof(ee->ee_rdEdgesPower)/NUM_EDGES); - for (i = 0; ee->ee_base.ctlIndex[i] != 0 && i < AR9287_NUM_CTLS; i++) { - for (j = 0; j < NUM_EDGES; j ++) { + /* WARNING! must check i bound before indexing the array */ + for (i = 0; i < AR9287_NUM_CTLS && ee->ee_base.ctlIndex[i] != 0; i++) { + for (j = 0; j < AR9287_NUM_BAND_EDGES; j++) { /* XXX Confirm this is the right thing to do when an invalid channel is stored */ if (ee->ee_base.ctlData[i].ctlEdges[CTL_CHAIN][j].bChannel == AR5416_BCHAN_UNUSED) { rep[j].rdEdge = 0; diff --git a/sys/dev/netif/ath/ath_hal/ah_eeprom_v4k.c b/sys/dev/netif/ath/ath_hal/ah_eeprom_v4k.c index 12cb67e437..6f517d97e1 100644 --- a/sys/dev/netif/ath/ath_hal/ah_eeprom_v4k.c +++ b/sys/dev/netif/ath/ath_hal/ah_eeprom_v4k.c @@ -237,8 +237,10 @@ v4kEepromReadCTLInfo(struct ath_hal *ah, HAL_EEPROM_v4k *ee) HALASSERT(AR5416_4K_NUM_CTLS <= sizeof(ee->ee_rdEdgesPower)/NUM_EDGES); - for (i = 0; ee->ee_base.ctlIndex[i] != 0 && i < AR5416_4K_NUM_CTLS; i++) { - for (j = 0; j < NUM_EDGES; j ++) { + /* WARNING! must check i bound before indexing the array */ + /* WARNING! AR5416_4K_NUM_BAND_EDGES != NUM_EDGES */ + for (i = 0; i < AR5416_4K_NUM_CTLS && ee->ee_base.ctlIndex[i] != 0; i++) { + for (j = 0; j < AR5416_4K_NUM_BAND_EDGES; j++) { /* XXX Confirm this is the right thing to do when an invalid channel is stored */ if (ee->ee_base.ctlData[i].ctlEdges[CTL_CHAIN][j].bChannel == AR5416_BCHAN_UNUSED) { rep[j].rdEdge = 0; diff --git a/sys/dev/netif/ath/ath_hal/ah_internal.h b/sys/dev/netif/ath/ath_hal/ah_internal.h index a4c76562fd..83927b9c53 100644 --- a/sys/dev/netif/ath/ath_hal/ah_internal.h +++ b/sys/dev/netif/ath/ath_hal/ah_internal.h @@ -27,7 +27,7 @@ #define AH_MIN(a,b) ((a)<(b)?(a):(b)) #define AH_MAX(a,b) ((a)>(b)?(a):(b)) -#include +#include #include "opt_ah.h" /* needed for AH_SUPPORT_AR5416 */ #ifndef AH_SUPPORT_AR5416 @@ -428,7 +428,7 @@ struct ath_hal_private { /* * Channel survey history - current channel only. */ - HAL_CHANNEL_SURVEY ah_chansurvey; /* channel survey */ + HAL_CHANNEL_SURVEY ah_chansurvey; /* channel survey */ }; #define AH_PRIVATE(_ah) ((struct ath_hal_private *)(_ah)) @@ -1036,12 +1036,12 @@ extern int ath_hal_mhz2ieee_2ghz(struct ath_hal *, int freq); /* * Clear the channel survey data. */ -extern void ath_hal_survey_clear(struct ath_hal *ah); +extern void ath_hal_survey_clear(struct ath_hal *ah); /* * Add a sample to the channel survey data. */ -extern void ath_hal_survey_add_sample(struct ath_hal *ah, +extern void ath_hal_survey_add_sample(struct ath_hal *ah, HAL_SURVEY_SAMPLE *hs); #endif /* _ATH_AH_INTERAL_H_ */ diff --git a/sys/dev/netif/ath/ath_hal/ah_osdep.c b/sys/dev/netif/ath/ath_hal/ah_osdep.c index 3d633a44ad..6a14f786de 100644 --- a/sys/dev/netif/ath/ath_hal/ah_osdep.c +++ b/sys/dev/netif/ath/ath_hal/ah_osdep.c @@ -30,6 +30,10 @@ */ #include "opt_ah.h" +#if defined(__DragonFly__) +#define CTLFLAG_RWTUN CTLFLAG_RW +#endif + #include #include #include @@ -38,16 +42,28 @@ #include #include #include +#if defined(__DragonFly__) +#else #include +#endif #include #include #include #include /* XXX for ether_sprintf */ +#if defined(__DragonFly__) + +#include +#include +#include +#include +#include /* ether_sprintf */ -#include -#include +#endif + +#include +#include /* * WiSoC boards overload the bus tag with information about the @@ -70,9 +86,8 @@ * XXX This is a global lock for now; it should be pushed to * a per-device lock in some platform-independent fashion. */ -struct mtx ah_regser_mtx; -MTX_SYSINIT(ah_regser, &ah_regser_mtx, "Atheros register access mutex", - MTX_SPIN); +struct lock ah_regser_mtx; +LOCK_SYSINIT(ah_regser, &ah_regser_mtx, "Atheros register access mutex", 0); extern void ath_hal_printf(struct ath_hal *, const char*, ...) __printflike(2,3); @@ -105,28 +120,28 @@ static MALLOC_DEFINE(M_ATH_HAL, "ath_hal", "ath hal data"); void* ath_hal_malloc(size_t size) { - return malloc(size, M_ATH_HAL, M_NOWAIT | M_ZERO); + return kmalloc(size, M_ATH_HAL, M_INTWAIT | M_ZERO); } void ath_hal_free(void* p) { - free(p, M_ATH_HAL); + kfree(p, M_ATH_HAL); } void -ath_hal_vprintf(struct ath_hal *ah, const char* fmt, va_list ap) +ath_hal_vprintf(struct ath_hal *ah, const char* fmt, __va_list ap) { - vprintf(fmt, ap); + kvprintf(fmt, ap); } void ath_hal_printf(struct ath_hal *ah, const char* fmt, ...) { - va_list ap; - va_start(ap, fmt); + __va_list ap; + __va_start(ap, fmt); ath_hal_vprintf(ah, fmt, ap); - va_end(ap); + __va_end(ap); } const char* @@ -162,9 +177,9 @@ DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...) (ah != NULL && ah->ah_config.ah_debug & mask) || (ath_hal_debug & mask)) { __va_list ap; - va_start(ap, fmt); + __va_start(ap, fmt); ath_hal_vprintf(ah, fmt, ap); - va_end(ap); + __va_end(ap); } } #undef HAL_DEBUG_UNMASKABLE @@ -184,9 +199,9 @@ DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...) * NB: doesn't handle multiple devices properly; only one DEVICE record * is emitted and the different devices are not identified. */ -#include -#include -#include +/*#include FreeBSD */ +/*#include FreeBSD */ +#include static struct alq *ath_hal_alq; static int ath_hal_alq_emitdev; /* need to emit DEVICE record */ @@ -209,13 +224,13 @@ ath_hal_setlogging(int enable) sizeof (struct athregrec), ath_hal_alq_qsize); ath_hal_alq_lost = 0; ath_hal_alq_emitdev = 1; - printf("ath_hal: logging to %s enabled\n", + kprintf("ath_hal: logging to %s enabled\n", ath_hal_logfile); } else { if (ath_hal_alq) alq_close(ath_hal_alq); ath_hal_alq = NULL; - printf("ath_hal: logging disabled\n"); + kprintf("ath_hal: logging disabled\n"); error = 0; } return (error); @@ -291,11 +306,11 @@ ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val) } } if (ah->ah_config.ah_serialise_reg_war) - mtx_lock_spin(&ah_regser_mtx); + lockmgr(&ah_regser_mtx, LK_EXCLUSIVE); bus_space_write_4(tag, h, reg, val); OS_BUS_BARRIER_REG(ah, reg, OS_BUS_BARRIER_WRITE); if (ah->ah_config.ah_serialise_reg_war) - mtx_unlock_spin(&ah_regser_mtx); + lockmgr(&ah_regser_mtx, LK_RELEASE); } u_int32_t @@ -305,21 +320,19 @@ ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg) bus_space_handle_t h = ah->ah_sh; u_int32_t val; -#ifdef AH_DEBUG /* Debug - complain if we haven't fully waken things up */ if (! ath_hal_reg_whilst_asleep(ah, reg) && ah->ah_powerMode != HAL_PM_AWAKE) { ath_hal_printf(ah, "%s: reg=0x%08x, pm=%d\n", __func__, reg, ah->ah_powerMode); } -#endif if (ah->ah_config.ah_serialise_reg_war) - mtx_lock_spin(&ah_regser_mtx); + lockmgr(&ah_regser_mtx, LK_EXCLUSIVE); OS_BUS_BARRIER_REG(ah, reg, OS_BUS_BARRIER_READ); val = bus_space_read_4(tag, h, reg); if (ah->ah_config.ah_serialise_reg_war) - mtx_unlock_spin(&ah_regser_mtx); + lockmgr(&ah_regser_mtx, LK_RELEASE); if (ath_hal_alq) { struct ale *ale = ath_hal_alq_get(ah); if (ale) { @@ -368,7 +381,7 @@ ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val) bus_space_tag_t tag = BUSTAG(ah); bus_space_handle_t h = ah->ah_sh; -#ifdef AH_DEBUG +#ifdef AH_DEBUG /* Debug - complain if we haven't fully waken things up */ if (! ath_hal_reg_whilst_asleep(ah, reg) && ah->ah_powerMode != HAL_PM_AWAKE) { @@ -378,11 +391,11 @@ ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val) #endif if (ah->ah_config.ah_serialise_reg_war) - mtx_lock_spin(&ah_regser_mtx); + lockmgr(&ah_regser_mtx, LK_EXCLUSIVE); bus_space_write_4(tag, h, reg, val); OS_BUS_BARRIER_REG(ah, reg, OS_BUS_BARRIER_WRITE); if (ah->ah_config.ah_serialise_reg_war) - mtx_unlock_spin(&ah_regser_mtx); + lockmgr(&ah_regser_mtx, LK_RELEASE); } u_int32_t @@ -392,7 +405,7 @@ ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg) bus_space_handle_t h = ah->ah_sh; u_int32_t val; -#ifdef AH_DEBUG +#ifdef AH_DEBUG /* Debug - complain if we haven't fully waken things up */ if (! ath_hal_reg_whilst_asleep(ah, reg) && ah->ah_powerMode != HAL_PM_AWAKE) { @@ -402,21 +415,56 @@ ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg) #endif if (ah->ah_config.ah_serialise_reg_war) - mtx_lock_spin(&ah_regser_mtx); + lockmgr(&ah_regser_mtx, LK_EXCLUSIVE); OS_BUS_BARRIER_REG(ah, reg, OS_BUS_BARRIER_READ); val = bus_space_read_4(tag, h, reg); if (ah->ah_config.ah_serialise_reg_war) - mtx_unlock_spin(&ah_regser_mtx); + lockmgr(&ah_regser_mtx, LK_RELEASE); return val; } -#endif /* AH_DEBUG_ALQ */ +#endif /* AH_DEBUG || AH_REGOPS_FUNC */ #ifdef AH_ASSERT void ath_hal_assert_failed(const char* filename, int lineno, const char *msg) { - printf("Atheros HAL assertion failure: %s: line %u: %s\n", + kprintf("Atheros HAL assertion failure: %s: line %u: %s\n", filename, lineno, msg); panic("ath_hal_assert"); } #endif /* AH_ASSERT */ + +/* + * Module glue. + */ +static int +ath_hal_modevent(module_t mod, int type, void *unused) +{ + int error; + + wlan_serialize_enter(); + + switch (type) { + case MOD_LOAD: + error = 0; + break; + case MOD_UNLOAD: + error = 0; + break; + default: + error = EINVAL; + break; + } + wlan_serialize_exit(); + + return error; +} + +static moduledata_t ath_hal_mod = { + "ath_hal", + ath_hal_modevent, + 0 +}; + +DECLARE_MODULE(ath_hal, ath_hal_mod, SI_SUB_DRIVERS, SI_ORDER_ANY); +MODULE_VERSION(ath_hal, 1); diff --git a/sys/dev/netif/ath/ath_hal/ah_osdep.h b/sys/dev/netif/ath/ath_hal/ah_osdep.h index 94601927ca..eaba88fb44 100644 --- a/sys/dev/netif/ath/ath_hal/ah_osdep.h +++ b/sys/dev/netif/ath/ath_hal/ah_osdep.h @@ -39,7 +39,19 @@ #include #include -#include +#if defined(__DragonFly__) + +#include + +#ifndef true +#define true 1 +#endif + +#ifndef false +#define false 0 +#endif + +#endif /* * Bus i/o type definitions. diff --git a/sys/dev/netif/ath/ath_hal/ah_regdomain.c b/sys/dev/netif/ath/ath_hal/ah_regdomain.c index 4f374c4bee..74e984e88e 100644 --- a/sys/dev/netif/ath/ath_hal/ah_regdomain.c +++ b/sys/dev/netif/ath/ath_hal/ah_regdomain.c @@ -21,8 +21,8 @@ #include "ah.h" -#include -#include +#include +#include #include "ah_internal.h" #include "ah_eeprom.h" diff --git a/sys/dev/netif/ath/ath_hal/ar5212/ar5212.h b/sys/dev/netif/ath/ath_hal/ar5212/ar5212.h index bab061dbb3..6fda438b8f 100644 --- a/sys/dev/netif/ath/ath_hal/ar5212/ar5212.h +++ b/sys/dev/netif/ath/ath_hal/ar5212/ar5212.h @@ -347,7 +347,7 @@ struct ath_hal_5212 { uint32_t ah_tx_chainmask; /* Used to return ANI statistics to the diagnostic API */ - HAL_ANI_STATS ext_ani_stats; + HAL_ANI_STATS ext_ani_stats; }; #define AH5212(_ah) ((struct ath_hal_5212 *)(_ah)) diff --git a/sys/dev/netif/ath/ath_hal/ar5416/ar5416_reset.c b/sys/dev/netif/ath/ath_hal/ar5416/ar5416_reset.c index 6abb7b4f85..dd4aed9c02 100644 --- a/sys/dev/netif/ath/ath_hal/ar5416/ar5416_reset.c +++ b/sys/dev/netif/ath/ath_hal/ar5416/ar5416_reset.c @@ -2442,6 +2442,8 @@ ar5416GetGainBoundariesAndPdadcs(struct ath_hal *ah, int16_t minDelta = 0; CHAN_CENTERS centers; + minPwrT4[0] = 0; /* make gcc5 happy */ + ar5416GetChannelCenters(ah, chan, ¢ers); /* Trim numPiers for the number of populated channel Piers */ diff --git a/sys/dev/netif/ath/ath_hal/ar5416/ar5416reg.h b/sys/dev/netif/ath/ath_hal/ar5416/ar5416reg.h index de424be7df..f702cd7832 100644 --- a/sys/dev/netif/ath/ath_hal/ar5416/ar5416reg.h +++ b/sys/dev/netif/ath/ath_hal/ar5416/ar5416reg.h @@ -19,7 +19,7 @@ #ifndef _DEV_ATH_AR5416REG_H #define _DEV_ATH_AR5416REG_H -#include +#include /* * Register added starting with the AR5416 diff --git a/sys/dev/netif/ath/ath_hal/ar9002/ar9280_attach.c b/sys/dev/netif/ath/ath_hal/ar9002/ar9280_attach.c index 3be3e3539a..7d058ab297 100644 --- a/sys/dev/netif/ath/ath_hal/ar9002/ar9280_attach.c +++ b/sys/dev/netif/ath/ath_hal/ar9002/ar9280_attach.c @@ -316,7 +316,7 @@ ar9280Attach(uint16_t devid, HAL_SOFTC sc, */ ecode = ath_hal_eepromGet(ah, AR_EEP_PWDCLKIND, &pwr); if (AR_SREV_MERLIN_20_OR_LATER(ah) && ecode == HAL_OK && pwr == 0) { - printf("[ath] enabling AN_TOP2_FIXUP\n"); + kprintf("[ath] enabling AN_TOP2_FIXUP\n"); AH5416(ah)->ah_need_an_top2_fixup = 1; } diff --git a/sys/dev/netif/ath/ath_hal/ar9002/ar9280_olc.c b/sys/dev/netif/ath/ath_hal/ar9002/ar9280_olc.c index 334ca60e99..37ddf8befe 100644 --- a/sys/dev/netif/ath/ath_hal/ar9002/ar9280_olc.c +++ b/sys/dev/netif/ath/ath_hal/ar9002/ar9280_olc.c @@ -342,7 +342,7 @@ ar9280SetPowerCalTable(struct ath_hal *ah, struct ar5416eeprom *pEepData, for (i = 0; i < AR5416_MAX_CHAINS; i++) { regChainOffset = ar5416GetRegChainOffset(ah, i); if (pEepData->baseEepHeader.txMask & (1 << i)) { - uint16_t diff; + uint16_t diff = 0; /* quiet gcc error w/ass */ if (IEEE80211_IS_CHAN_2GHZ(chan)) { pRawDataset = pEepData->calPierData2G[i]; diff --git a/sys/dev/netif/ath/ath_hal/ar9002/ar9285_btcoex.c b/sys/dev/netif/ath/ath_hal/ar9002/ar9285_btcoex.c index 4d79a4f842..25074efab2 100644 --- a/sys/dev/netif/ath/ath_hal/ar9002/ar9285_btcoex.c +++ b/sys/dev/netif/ath/ath_hal/ar9002/ar9285_btcoex.c @@ -53,8 +53,9 @@ ar9285BTCoexAntennaDiversity(struct ath_hal *ah) !! (ahp->ah_btCoexFlag & HAL_BT_COEX_FLAG_ANT_DIV_ALLOW), !! (ahp->ah_btCoexFlag & HAL_BT_COEX_FLAG_ANT_DIV_ENABLE)); + /* NOTE: disparate enum comparison must be cast */ if ((ahp->ah_btCoexFlag & HAL_BT_COEX_FLAG_ANT_DIV_ALLOW) || - (AH5212(ah)->ah_diversity != HAL_ANT_VARIABLE)) { + ((int)AH5212(ah)->ah_diversity != HAL_ANT_VARIABLE)) { if ((ahp->ah_btCoexFlag & HAL_BT_COEX_FLAG_ANT_DIV_ENABLE) && (AH5212(ah)->ah_antControl == HAL_ANT_VARIABLE)) { /* Enable antenna diversity */ diff --git a/sys/dev/netif/ath/ath_rate/amrr/amrr.c b/sys/dev/netif/ath/ath_rate/amrr/amrr.c index c2520097d0..7a24227699 100644 --- a/sys/dev/netif/ath/ath_rate/amrr/amrr.c +++ b/sys/dev/netif/ath/ath_rate/amrr/amrr.c @@ -57,8 +57,12 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include #include +#endif #include #include @@ -67,7 +71,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include @@ -76,9 +80,9 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include -#include +#include +#include +#include static int ath_rateinterval = 1000; /* rate ctl interval (ms) */ static int ath_rate_max_success_threshold = 10; @@ -452,7 +456,7 @@ ath_rate_attach(struct ath_softc *sc) { struct amrr_softc *asc; - asc = malloc(sizeof(struct amrr_softc), M_DEVBUF, M_NOWAIT|M_ZERO); + asc = kmalloc(sizeof(struct amrr_softc), M_DEVBUF, M_INTWAIT|M_ZERO); if (asc == NULL) return NULL; asc->arc.arc_space = sizeof(struct amrr_node); @@ -466,5 +470,50 @@ ath_rate_detach(struct ath_ratectrl *arc) { struct amrr_softc *asc = (struct amrr_softc *) arc; - free(asc, M_DEVBUF); + kfree(asc, M_DEVBUF); +} + +#if defined(__DragonFly__) + +/* + * Module glue. + */ +static int +amrr_modevent(module_t mod, int type, void *unused) +{ + int error; + + wlan_serialize_enter(); + + switch (type) { + case MOD_LOAD: + if (bootverbose) { + kprintf("ath_rate: version 0.1\n"); + } + error = 0; + break; + case MOD_UNLOAD: + error = 0; + break; + default: + error = EINVAL; + break; + } + wlan_serialize_exit(); + + return error; } + +static moduledata_t amrr_mod = { + "ath_rate", + amrr_modevent, + 0 +}; + +DECLARE_MODULE(ath_rate, amrr_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); +MODULE_VERSION(ath_rate, 1); +MODULE_DEPEND(ath_rate, ath_hal, 1, 1, 1); +MODULE_DEPEND(ath_rate, wlan, 1, 1, 1); + +#endif diff --git a/sys/dev/netif/ath/ath_rate/onoe/onoe.c b/sys/dev/netif/ath/ath_rate/onoe/onoe.c index 7c73926526..ac68545250 100644 --- a/sys/dev/netif/ath/ath_rate/onoe/onoe.c +++ b/sys/dev/netif/ath/ath_rate/onoe/onoe.c @@ -45,8 +45,12 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include #include +#endif #include #include @@ -56,7 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include /* XXX for ether_sprintf */ -#include +#include #include @@ -65,9 +69,9 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include -#include +#include +#include +#include /* * Default parameters for the rate control algorithm. These are @@ -420,7 +424,7 @@ ath_rate_attach(struct ath_softc *sc) { struct onoe_softc *osc; - osc = malloc(sizeof(struct onoe_softc), M_DEVBUF, M_NOWAIT|M_ZERO); + osc = kmalloc(sizeof(struct onoe_softc), M_DEVBUF, M_INTWAIT|M_ZERO); if (osc == NULL) return NULL; osc->arc.arc_space = sizeof(struct onoe_node); @@ -434,5 +438,50 @@ ath_rate_detach(struct ath_ratectrl *arc) { struct onoe_softc *osc = (struct onoe_softc *) arc; - free(osc, M_DEVBUF); + kfree(osc, M_DEVBUF); +} + +#if defined(__DragonFly__) + +/* + * Module glue. + */ +static int +onoe_modevent(module_t mod, int type, void *unused) +{ + int error; + + wlan_serialize_enter(); + + switch (type) { + case MOD_LOAD: + if (bootverbose) { + kprintf("ath_rate: \n"); + } + error = 0; + break; + case MOD_UNLOAD: + error = 0; + break; + default: + error = EINVAL; + break; + } + wlan_serialize_exit(); + + return error; } + +static moduledata_t onoe_mod = { + "ath_rate", + onoe_modevent, + 0 +}; + +DECLARE_MODULE(ath_rate, onoe_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); +MODULE_VERSION(ath_rate, 1); +MODULE_DEPEND(ath_rate, ath_hal, 1, 1, 1); +MODULE_DEPEND(ath_rate, wlan, 1, 1, 1); + +#endif diff --git a/sys/dev/netif/ath/ath_rate/sample/sample.c b/sys/dev/netif/ath/ath_rate/sample/sample.c index 815c68b7a2..908b3a4c3b 100644 --- a/sys/dev/netif/ath/ath_rate/sample/sample.c +++ b/sys/dev/netif/ath/ath_rate/sample/sample.c @@ -55,8 +55,12 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(__DragonFly__) +/* empty */ +#else #include #include +#endif #include #include @@ -67,7 +71,7 @@ __FBSDID("$FreeBSD$"); #include #include /* XXX for ether_sprintf */ -#include +#include #include @@ -76,10 +80,14 @@ __FBSDID("$FreeBSD$"); #include #endif -#include -#include -#include -#include +#include +#include +#include +#include + +#if defined(__DragonFly__) +extern const char* ath_hal_ether_sprintf(const uint8_t *mac); +#endif /* * This file is an implementation of the SampleRate algorithm @@ -586,7 +594,7 @@ ath_rate_findrate(struct ath_softc *sc, struct ath_node *an, * This is likely not optimal! */ #if 0 - printf("cur rix/att %x/%d, best rix/att %x/%d\n", + kprintf("cur rix/att %x/%d, best rix/att %x/%d\n", MCS(cur_rix), cur_att, MCS(best_rix), average_tx_time); #endif if ((MCS(best_rix) > MCS(cur_rix)) && @@ -640,7 +648,7 @@ done: * out how to better reproduce it. */ if (rix < 0 || rix >= rt->rateCount) { - printf("%s: ERROR: rix %d out of bounds (rateCount=%d)\n", + kprintf("%s: ERROR: rix %d out of bounds (rateCount=%d)\n", __func__, rix, rt->rateCount); @@ -1093,16 +1101,21 @@ ath_rate_ctl_reset(struct ath_softc *sc, struct ieee80211_node *ni) if (ieee80211_msg(ni->ni_vap, IEEE80211_MSG_RATECTL)) { uint64_t mask; +#if defined(__DragonFly__) + ieee80211_note(ni->ni_vap, "[%s] %s: size 1600 rate/tt", + ath_hal_ether_sprintf(ni->ni_macaddr), __func__); +#else ieee80211_note(ni->ni_vap, "[%6D] %s: size 1600 rate/tt", ni->ni_macaddr, ":", __func__); +#endif for (mask = sn->ratemask, rix = 0; mask != 0; mask >>= 1, rix++) { if ((mask & 1) == 0) continue; - printf(" %d %s/%d", dot11rate(rt, rix), dot11rate_label(rt, rix), + kprintf(" %d %s/%d", dot11rate(rt, rix), dot11rate_label(rt, rix), calc_usecs_unicast_packet(sc, 1600, rix, 0,0, (ni->ni_chw == 40))); } - printf("\n"); + kprintf("\n"); } #endif for (y = 0; y < NUM_PACKET_SIZE_BINS; y++) { @@ -1197,8 +1210,13 @@ ath_rate_fetch_node_stats(struct ath_softc *sc, struct ath_node *an, * Take a temporary copy of the sample node state so we can * modify it before we copy it. */ +#if defined(__DragonFly__) + tv = kmalloc(sizeof(struct ath_rateioctl_rt), M_TEMP, + M_INTWAIT | M_ZERO); +#else tv = malloc(sizeof(struct ath_rateioctl_rt), M_TEMP, - M_NOWAIT | M_ZERO); + M_NOWAIT | M_ZERO); +#endif if (tv == NULL) { return (ENOMEM); } @@ -1238,7 +1256,7 @@ ath_rate_fetch_node_stats(struct ath_softc *sc, struct ath_node *an, copyout(sn, rs->buf + o, sizeof(struct sample_node)); o += sizeof(struct sample_node); - free(tv, M_TEMP); + kfree(tv, M_TEMP); return (0); } @@ -1252,25 +1270,25 @@ sample_stats(void *arg, struct ieee80211_node *ni) uint64_t mask; int rix, y; - printf("\n[%s] refcnt %d static_rix (%d %s) ratemask 0x%jx\n", + kprintf("\n[%s] refcnt %d static_rix (%d %s) ratemask 0x%jx\n", ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni), dot11rate(rt, sn->static_rix), dot11rate_label(rt, sn->static_rix), (uintmax_t)sn->ratemask); for (y = 0; y < NUM_PACKET_SIZE_BINS; y++) { - printf("[%4u] cur rix %d (%d %s) since switch: packets %d ticks %u\n", + kprintf("[%4u] cur rix %d (%d %s) since switch: packets %d ticks %u\n", bin_to_size(y), sn->current_rix[y], dot11rate(rt, sn->current_rix[y]), dot11rate_label(rt, sn->current_rix[y]), sn->packets_since_switch[y], sn->ticks_since_switch[y]); - printf("[%4u] last sample (%d %s) cur sample (%d %s) packets sent %d\n", + kprintf("[%4u] last sample (%d %s) cur sample (%d %s) packets sent %d\n", bin_to_size(y), dot11rate(rt, sn->last_sample_rix[y]), dot11rate_label(rt, sn->last_sample_rix[y]), dot11rate(rt, sn->current_sample_rix[y]), dot11rate_label(rt, sn->current_sample_rix[y]), sn->packets_sent[y]); - printf("[%4u] packets since sample %d sample tt %u\n", + kprintf("[%4u] packets since sample %d sample tt %u\n", bin_to_size(y), sn->packets_since_sample[y], sn->sample_tt[y]); } @@ -1280,7 +1298,7 @@ sample_stats(void *arg, struct ieee80211_node *ni) for (y = 0; y < NUM_PACKET_SIZE_BINS; y++) { if (sn->stats[y][rix].total_packets == 0) continue; - printf("[%2u %s:%4u] %8ju:%-8ju (%3d%%) (EWMA %3d.%1d%%) T %8ju F %4d avg %5u last %u\n", + kprintf("[%2u %s:%4u] %8ju:%-8ju (%3d%%) (EWMA %3d.%1d%%) T %8ju F %4d avg %5u last %u\n", dot11rate(rt, rix), dot11rate_label(rt, rix), bin_to_size(y), (uintmax_t) sn->stats[y][rix].total_packets, @@ -1370,7 +1388,11 @@ ath_rate_attach(struct ath_softc *sc) { struct sample_softc *ssc; +#if defined(__DragonFly__) + ssc = kmalloc(sizeof(struct sample_softc), M_DEVBUF, M_INTWAIT|M_ZERO); +#else ssc = malloc(sizeof(struct sample_softc), M_DEVBUF, M_NOWAIT|M_ZERO); +#endif if (ssc == NULL) return NULL; ssc->arc.arc_space = sizeof(struct sample_node); @@ -1389,5 +1411,50 @@ ath_rate_detach(struct ath_ratectrl *arc) { struct sample_softc *ssc = (struct sample_softc *) arc; - free(ssc, M_DEVBUF); + kfree(ssc, M_DEVBUF); } + +#if defined(__DragonFly__) + +/* + * Module glue. + */ +static int +sample_modevent(module_t mod, int type, void *unused) +{ + int error; + + wlan_serialize_enter(); + + switch (type) { + case MOD_LOAD: + if (bootverbose) { + kprintf("ath_rate: \n"); + } + error = 0; + break; + case MOD_UNLOAD: + error = 0; + break; + default: + error = EINVAL; + break; + } + wlan_serialize_exit(); + + return error; +} + +static moduledata_t sample_mod = { + "ath_rate", + sample_modevent, + 0 +}; + +DECLARE_MODULE(ath_rate, sample_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); +MODULE_VERSION(ath_rate, 1); +MODULE_DEPEND(ath_rate, ath_hal, 1, 1, 1); +MODULE_DEPEND(ath_rate, wlan, 1, 1, 1); + +#endif diff --git a/sys/dev/netif/ath/ath_rate/sample/sample.h b/sys/dev/netif/ath/ath_rate/sample/sample.h index 5495141c60..f7dbc7fbc4 100644 --- a/sys/dev/netif/ath/ath_rate/sample/sample.h +++ b/sys/dev/netif/ath/ath_rate/sample/sample.h @@ -113,7 +113,7 @@ struct sample_node { #ifdef _KERNEL #define ATH_NODE_SAMPLE(an) ((struct sample_node *)&(an)[1]) -#define IS_RATE_DEFINED(sn, rix) (((uint64_t) (sn)->ratemask & (1ULL<<((uint64_t) rix))) != 0) +#define IS_RATE_DEFINED(sn, rix) (((uint64_t)(sn)->ratemask & (1ULL<<((uint64_t) rix))) != 0) #ifndef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) @@ -148,7 +148,7 @@ static unsigned calc_usecs_unicast_packet(struct ath_softc *sc, KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); if (rix >= rt->rateCount) { - printf("bogus rix %d, max %u, mode %u\n", + kprintf("bogus rix %d, max %u, mode %u\n", rix, rt->rateCount, sc->sc_curmode); return 0; } -- 2.11.4.GIT