commit e425abdd9ab4835c5457b05b042929b4c133c032 Author: Jiri Slaby Date: Wed Jul 25 09:17:19 2007 +0200 remove yet another u used stuff from if_ath.c diff --git a/ath/if_ath.c b/ath/if_ath.c index acc4e2b..c92986a 100644 --- a/ath/if_ath.c +++ b/ath/if_ath.c @@ -5,108 +5,10 @@ static int ath_regdomain = 0; /* regulatory domain */ static int ath_outdoor = true; /* enable outdoor use */ static int ath_xchanmode = true; /* enable extended channels */ -#ifdef AR_DEBUG -static int ath_debug = 0; -#define IFF_DUMPPKTS(sc, _m) \ - ((sc->sc_debug & _m) || ieee80211_msg_dumppkts(&sc->sc_ic)) -#define KEYPRINTF(sc, ix, hk, mac) do { \ - if (sc->sc_debug & ATH_DEBUG_KEYCACHE) \ - ath_keyprint(__func__, ix, hk, mac); \ -} while (0) -static void ath_printrxbuf(struct ath_buf *bf, int); -//static void ath_printtxbuf(struct ath_buf *bf, int); -#else -#define IFF_DUMPPKTS(sc, _m) 0 -#define DPRINTF(sc, _m, _fmt, ...) -#define KEYPRINTF(sc, k, ix, mac) -#endif - MODULE_PARM_DESC(countrycode, "Override default country code"); MODULE_PARM_DESC(outdoor, "Enable/disable outdoor use"); MODULE_PARM_DESC(xchanmode, "Enable/disable extended channel mode"); - -/* - * For packet capture, define the same physical layer packet header - * structure as used in the wlan-ng driver - */ -enum { - DIDmsg_lnxind_wlansniffrm = 0x00000044, - DIDmsg_lnxind_wlansniffrm_hosttime = 0x00010044, - DIDmsg_lnxind_wlansniffrm_mactime = 0x00020044, - DIDmsg_lnxind_wlansniffrm_channel = 0x00030044, - DIDmsg_lnxind_wlansniffrm_rssi = 0x00040044, - DIDmsg_lnxind_wlansniffrm_sq = 0x00050044, - DIDmsg_lnxind_wlansniffrm_signal = 0x00060044, - DIDmsg_lnxind_wlansniffrm_noise = 0x00070044, - DIDmsg_lnxind_wlansniffrm_rate = 0x00080044, - DIDmsg_lnxind_wlansniffrm_istx = 0x00090044, - DIDmsg_lnxind_wlansniffrm_frmlen = 0x000A0044 -}; -enum { - P80211ENUM_msgitem_status_no_value = 0x00 -}; -enum { - P80211ENUM_truth_false = 0x00, - P80211ENUM_truth_true = 0x01 -}; - -struct p80211item_u32 { - u32 did; - u16 status; - u16 len; - u32 data; -}; - -struct wlan_ng_prism2_header { - u32 msgcode; - u32 msglen; -#define WLAN_DEVNAMELEN_MAX 16 - u8 devname[WLAN_DEVNAMELEN_MAX]; - struct p80211item_u32 hosttime; - struct p80211item_u32 mactime; - struct p80211item_u32 channel; - struct p80211item_u32 rssi; - struct p80211item_u32 sq; - struct p80211item_u32 signal; - struct p80211item_u32 noise; - struct p80211item_u32 rate; - struct p80211item_u32 istx; - struct p80211item_u32 frmlen; -}; - -static void -ath_radar_tasklet(unsigned long data) -{ - struct ieee80211_hw *hw = (void *)data; - struct ath_softc *sc = dev->priv; - struct ieee80211com *ic = &sc->sc_ic; - struct ieee80211_channel *c; - - c = radar_handle_interference (ic); - - if (c == NULL) - { - ath_stop (dev); - printk ("%s: FATAL ERROR - All available channels are marked as being interfered by radar. Stopping radio.\n", dev->name); - return; - } - - ic->ic_des_chan = c; - ic->ic_ibss_chan = c; - ieee80211_new_state (ic, IEEE80211_S_INIT, -1); - ath_init(hw); -} - -static void -ath_rxorn_tasklet(unsigned long data) -{ - struct ieee80211_hw *hw = (void *)data; - - printk(KERN_WARNING "rx FIFO overrun; resetting\n"); - ath_reset(hw); -} - static void ath_bmiss_tasklet(unsigned long data) { @@ -145,78 +47,6 @@ ath_bmiss_tasklet(unsigned long data) } } - -#define NUM_RADIOTAP_ELEMENTS 18 - -static int radiotap_elem_to_bytes[NUM_RADIOTAP_ELEMENTS] = - {8, /* IEEE80211_RADIOTAP_TSFT */ - 1, /* IEEE80211_RADIOTAP_FLAGS */ - 1, /* IEEE80211_RADIOTAP_RATE */ - 4, /* IEEE80211_RADIOTAP_CHANNEL */ - 2, /* IEEE80211_RADIOTAP_FHSS */ - 1, /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */ - 1, /* IEEE80211_RADIOTAP_DBM_ANTNOISE */ - 2, /* IEEE80211_RADIOTAP_LOCK_QUALITY */ - 2, /* IEEE80211_RADIOTAP_TX_ATTENUATION */ - 2, /* IEEE80211_RADIOTAP_DB_TX_ATTENUATION */ - 1, /* IEEE80211_RADIOTAP_DBM_TX_POWER */ - 1, /* IEEE80211_RADIOTAP_ANTENNA */ - 1, /* IEEE80211_RADIOTAP_DB_ANTSIGNAL */ - 1, /* IEEE80211_RADIOTAP_DB_ANTNOISE */ - 2, /* IEEE80211_RADIOTAP_RX_FLAGS */ - 2, /* IEEE80211_RADIOTAP_TX_FLAGS */ - 1, /* IEEE80211_RADIOTAP_RTS_RETRIES */ - 1, /* IEEE80211_RADIOTAP_DATA_RETRIES */ - }; - -/* - * the following rt_* functions deal with verifying that a valid - * radiotap header is on a packet as well as functions to extracting - * what information is included. - * XXX maybe these should go in ieee_radiotap.c - */ -static int rt_el_present(struct ieee80211_radiotap_header *th, u_int32_t element) -{ - if (element > NUM_RADIOTAP_ELEMENTS) - return 0; - return le32_to_cpu(th->it_present) & (1 << element); -} - -static int rt_check_header(struct ieee80211_radiotap_header *th, int len) -{ - int bytes = 0; - int x = 0; - if (th->it_version != 0) - return 0; - - if (le16_to_cpu(th->it_len) < sizeof(struct ieee80211_radiotap_header)) - return 0; - - for (x = 0; x < NUM_RADIOTAP_ELEMENTS; x++) { - if (rt_el_present(th, x)) - bytes += radiotap_elem_to_bytes[x]; - } - - if (le16_to_cpu(th->it_len) < sizeof(struct ieee80211_radiotap_header) + bytes) - return 0; - - if (le16_to_cpu(th->it_len) > len) - return 0; - - return 1; -} - -static u_int8_t *rt_el_offset(struct ieee80211_radiotap_header *th, u_int32_t element) { - unsigned int x = 0; - u_int8_t *offset = ((u_int8_t *) th) + sizeof(struct ieee80211_radiotap_header); - for (x = 0; x < NUM_RADIOTAP_ELEMENTS && x < element; x++) { - if (rt_el_present(th, x)) - offset += radiotap_elem_to_bytes[x]; - } - - return offset; -} - #ifdef AR_DEBUG static void ath_keyprint(const char *tag, u_int ix, @@ -290,70 +120,6 @@ ath_keyset_tkip(struct ath_softc *sc, const struct ieee80211_key *k, } /* - * Set a net80211 key into the hardware. This handles the - * potential distribution of key state to multiple key - * cache slots for TKIP with hardware MIC support. - */ -static int -ath_keyset(struct ath_softc *sc, const struct ieee80211_key *k, - const u_int8_t mac0[IEEE80211_ADDR_LEN], - struct ieee80211_node *bss) -{ -#define N(a) (sizeof(a)/sizeof(a[0])) - static const u_int8_t ciphermap[] = { - AR5K_CIPHER_WEP, /* IEEE80211_CIPHER_WEP */ - AR5K_CIPHER_TKIP, /* IEEE80211_CIPHER_TKIP */ - AR5K_CIPHER_AES_OCB, /* IEEE80211_CIPHER_AES_OCB */ - AR5K_CIPHER_AES_CCM, /* IEEE80211_CIPHER_AES_CCM */ - (u_int8_t) -1, /* 4 is not allocated */ - AR5K_CIPHER_CKIP, /* IEEE80211_CIPHER_CKIP */ - AR5K_CIPHER_CLR, /* IEEE80211_CIPHER_NONE */ - }; - struct ath_hal *ah = sc->sc_ah; - const struct ieee80211_cipher *cip = k->wk_cipher; - u_int8_t gmac[IEEE80211_ADDR_LEN]; - const u_int8_t *mac; - AR5K_KEYVAL hk; - - memset(&hk, 0, sizeof(hk)); - /* - * Software crypto uses a "clear key" so non-crypto - * state kept in the key cache are maintained and - * so that rx frames have an entry to match. - */ - if ((k->wk_flags & IEEE80211_KEY_SWCRYPT) == 0) { - KASSERT(cip->ic_cipher < N(ciphermap), - ("invalid cipher type %u", cip->ic_cipher)); - hk.wk_type = ciphermap[cip->ic_cipher]; - hk.wk_len = k->wk_keylen; - memcpy(hk.wk_key, k->wk_key, k->wk_keylen); - } else - hk.wk_type = AR5K_CIPHER_CLR; - - if ((k->wk_flags & IEEE80211_KEY_GROUP) && sc->sc_mcastkey) { - /* - * Group keys on hardware that supports multicast frame - * key search use a mac that is the sender's address with - * the high bit set instead of the app-specified address. - */ - IEEE80211_ADDR_COPY(gmac, bss->ni_macaddr); - gmac[0] |= 0x80; - mac = gmac; - } else - mac = mac0; - - if (hk.wk_type == AR5K_CIPHER_TKIP && - (k->wk_flags & IEEE80211_KEY_SWMIC) == 0 && - sc->sc_splitmic) { - return ath_keyset_tkip(sc, k, &hk, mac); - } else { - KEYPRINTF(sc, k->wk_keyix, &hk, mac); - return ath5k_hw_set_key(ah, k->wk_keyix, &hk, mac, false); - } -#undef N -} - -/* * Allocate tx/rx key slots for TKIP. We allocate two slots for * each key, one for decrypt/encrypt and the other for the MIC. */ @@ -551,58 +317,6 @@ ath_key_delete(struct ieee80211com *ic, const struct ieee80211_key *k) } /* - * Block/unblock tx+rx processing while a key change is done. - * We assume the caller serializes key management operations - * so we only need to worry about synchronization with other - * uses that originate in the driver. - */ -static void -ath_key_update_begin(struct ieee80211com *ic) -{ - struct net_device *dev = ic->ic_dev; - struct ath_softc *sc = dev->priv; - - DPRINTF(sc, ATH_DEBUG_FATAL, "%lu %s (%s)\n", jiffies, __func__, dev->name); - DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__); - /* - * When called from the rx tasklet we cannot use - * tasklet_disable because it will block waiting - * for us to complete execution. - * - * XXX Using in_softirq is not right since we might - * be called from other soft irq contexts than - * ath_rx_tasklet. - * TODO: can cause bugs - */ -#if 1 - if (!in_softirq()) - tasklet_disable(&sc->sc_rxtq); -#endif - netif_stop_queue(dev); // TODO: find a way to not block mgmt frames - if (sc->sc_rawdev_enabled) - netif_stop_queue(&sc->sc_rawdev); -} - -static void -ath_key_update_end(struct ieee80211com *ic) -{ - struct net_device *dev = ic->ic_dev; - struct ath_softc *sc = dev->priv; - - DPRINTF(sc, ATH_DEBUG_FATAL, "%lu %s (%s)\n", jiffies, __func__, dev->name); - DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__); - netif_start_queue(dev); - if (sc->sc_rawdev_enabled) - netif_start_queue(&sc->sc_rawdev); -#if 1 - if (!in_softirq()) /* NB: see above */ - tasklet_enable(&sc->sc_rxtq); -#endif -} - - -#endif -/* * Set the slot time based on the current setting. * This is called by ath_updateslot below and when a non-ERP node * joins the network @@ -711,37 +425,6 @@ ath_wme_update(struct ieee80211com *ic) /* * Deferred processing of transmit interrupt; special-cased - * for a single hardware transmit queue (e.g. 5210 and 5211). - */ -static void -ath_tx_tasklet_q0(unsigned long data) -{ - struct net_device *dev = (struct net_device *)data; - struct ath_softc *sc = dev->priv; - - ath_tx_processq(sc, &sc->sc_txq[0]); - ath_tx_processq(sc, sc->sc_cabq); - - sc->sc_tx_timer = 0; - - if (sc->sc_softled) - ath_led_event(sc, ATH_LED_TX); - - // TODO: okay??? - /* - * Don't wakeup unless we're associated; this insures we don't - * signal the upper layer it's ok to start sending data frames. - */ - /* XXX use a low watermark to reduce wakeups */ - if (ic->ic_state == IEEE80211_S_RUN) - netif_wake_queue(dev); - - if (sc->sc_rawdev_enabled) - netif_wake_queue(&sc->sc_rawdev); -} - -/* - * Deferred processing of transmit interrupt; special-cased * for four hardware queues, 0-3 (e.g. 5212 w/ WME support). */ static void @@ -778,44 +461,6 @@ ath_tx_tasklet_q0123(unsigned long data) } /* - * Deferred processing of transmit interrupt. - */ -static void -ath_tx_tasklet(unsigned long data) -{ - struct net_device *dev = (struct net_device *)data; - struct ath_softc *sc = dev->priv; - int i; - - /* - * Process each active queue. - */ - /* XXX faster to read ISR_S0_S and ISR_S1_S to determine q's? */ - for (i = 0; i < AR5K_NUM_TX_QUEUES; i++) { - if (ATH_TXQ_SETUP(sc, i)) - ath_tx_processq(sc, &sc->sc_txq[i]); - } - - sc->sc_tx_timer = 0; - - if (sc->sc_softled) - ath_led_event(sc, ATH_LED_TX); - - // TODO: okay??? - /* - * Don't wakeup unless we're associated; this insures we don't - * signal the upper layer it's ok to start sending data frames. - */ - /* XXX use a low watermark to reduce wakeups */ - if (ic->ic_state == IEEE80211_S_RUN) - netif_wake_queue(dev); - - if (sc->sc_rawdev_enabled) - netif_wake_queue(&sc->sc_rawdev); - -} - -/* * Allocate a key cache slot to the station so we can * setup a mapping from key index to node. The key cache * slot is needed for managing antenna state and for @@ -846,27 +491,6 @@ ath_setup_stationkey(struct ieee80211_node *ni) } /* - * Setup driver-specific state for a newly associated node. - * Note that we're called also on a re-associate, the isnew - * param tells us if this is the first time or not. - */ -static void -ath_newassoc(struct ieee80211_node *ni, int isnew) -{ - struct ieee80211com *ic = ni->ni_ic; - struct ath_softc *sc = ic->ic_dev->priv; - - ath_rate_newassoc(sc, ATH_NODE(ni), isnew); - if (isnew && - (ic->ic_flags & IEEE80211_F_PRIVACY) == 0 && sc->sc_hasclrkey) { - KASSERT(ni->ni_ucastkey.wk_keyix == IEEE80211_KEYIX_NONE, - "new assoc with a unicast key already setup (keyix %u)", - ni->ni_ucastkey.wk_keyix); - ath_setup_stationkey(ni); - } -} - -/* * Return netdevice statistics. */ static struct net_device_stats * @@ -985,46 +609,11 @@ bad: static int ath_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { -#define IS_RUNNING(dev) \ - ((dev->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP)) struct ath_softc *sc = dev->priv; int error = 0; ATH_LOCK(sc); switch (cmd) { - case SIOCSIFFLAGS: - if (IS_RUNNING(dev)) { - /* - * To avoid rescanning another access point, - * do not call ath_init() here. Instead, - * only reflect promisc mode settings. - */ - ath_mode_init(dev); - } else if (dev->flags & IFF_UP) { - /* - * Beware of being called during attach/detach - * to reset promiscuous mode. In that case we - * will still be marked UP but not RUNNING. - * However trying to re-init the interface - * is the wrong thing to do as we've already - * torn down much of our state. There's - * probably a better way to deal with this. - */ -// if (!sc->sc_invalid && ic->ic_bss != NULL) - ath_init(dev); /* XXX lose error */ - } else - ath_stop_locked(dev); - break; - case SIOCADDMULTI: - case SIOCDELMULTI: - /* - * The upper layer has already installed/removed - * the multicast address(es), just recalculate the - * multicast filter for the card. - */ - if (dev->flags & IFF_RUNNING) - ath_mode_init(dev); - break; case SIOCGATHSTATS: /* NB: embed these numbers to get a consistent view */ sc->sc_stats.ast_tx_packets = ic->ic_devstats->tx_packets; @@ -1049,17 +638,6 @@ ath_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) else error = ath_ioctl_ethtool(sc, cmd, ifr->ifr_data); break; - default: - error = ieee80211_ioctlx(ic, ifr, cmd); - if (error == -ENETRESET) { - if (IS_RUNNING(dev) && - ic->ic_roaming != IEEE80211_ROAMING_MANUAL) - ath_init(dev); /* XXX lose error */ - error = 0; - } - if (error == -ERESTART) - error = IS_RUNNING(dev) ? ath_reset(dev) : 0; - break; } ATH_UNLOCK(sc); return error;