commit af21a9c0abb3644869fe5890b87acb9963d9a6f1 Author: Jiri Slaby Date: Mon Jun 25 14:34:31 2007 +0200 remove yet copied stuff from if_ath.c diff --git a/ath/if_ath.c b/ath/if_ath.c index f8bb32a..beae81d 100644 --- a/ath/if_ath.c +++ b/ath/if_ath.c @@ -1,74 +1,9 @@ -/*- - * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce at minimum a disclaimer - * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any - * redistribution must be conditioned upon including a substantially - * similar Disclaimer requirement for further binary redistribution. - * 3. Neither the names of the above-listed copyright holders nor the names - * of any contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * NO WARRANTY - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, - * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGES. - */ - -/* - * Driver for the Atheros Wireless LAN controller. - * - * This software is derived from work of Atsushi Onoe; his contribution - * is greatly appreciated. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - /* * #define AR_DEBUG here if you need to debug the ath_pci module (athdebug) * disable this if not needed because it adds an amount of load */ #define AR_DEBUG -/*#include "radar.h"*/ - -#include "if_ath_pci.h" -#include "if_athvar.h" -#include "ath5k.h" -#include "ath_hw.h" - /* unaligned little endian access */ #define LE_READ_2(_p) (le16_to_cpu(get_unaligned((__le16 *)(_p)))) #define LE_READ_4(_p) (le32_to_cpu(get_unaligned((__le32 *)(_p)))) @@ -79,107 +14,6 @@ enum { ATH_LED_POLL, }; -static int ath_init(struct ieee80211_hw *); -static int ath_reset(struct ieee80211_hw *); -static void ath_fatal_tasklet(unsigned long); -static void ath_bstuck_tasklet(unsigned long); -static void ath_rxorn_tasklet(unsigned long); -static void ath_bmiss_tasklet(unsigned long); -static void ath_radar_tasklet(unsigned long); -static int ath_stop_locked(struct ieee80211_hw *); -static int ath_stop(struct ieee80211_hw *); -#ifdef BLE -static int ath_media_change(struct net_device *); -static int ath_key_alloc(struct ieee80211com *, - const struct ieee80211_key_conf *); -static int ath_key_delete(struct ieee80211com *, - const struct ieee80211_key_conf *); -static int ath_key_set(struct ieee80211com *, - const struct ieee80211_key_conf *, - const u_int8_t mac[IEEE80211_ADDR_LEN]); -static void ath_key_update_begin(struct ieee80211com *); -static void ath_key_update_end(struct ieee80211com *); -static void ath_mode_init(struct net_device *); -#endif -static void ath_setslottime(struct ath_softc *); -//static void ath_updateslot(struct net_device *); -static int ath_beaconq_setup(struct ath_hal *); -//static int ath_beacon_alloc(struct ath_softc *, struct ieee80211_node *); -static void ath_beacon_setup(struct ath_softc *, struct ath_buf *, - struct ieee80211_tx_control *); -static void ath_beacon_send(struct net_device *); -//static void ath_beacon_free(struct ath_softc *); -//static void ath_beacon_config(struct ath_softc *); -static void ath_descdma_cleanup(struct ath_softc *sc, struct list_head *); -static int ath_desc_alloc(struct ath_softc *); -static void ath_desc_free(struct ath_softc *); -#ifdef BLE -static struct ieee80211_node *ath_node_alloc(struct ieee80211_node_table *); -static void ath_node_free(struct ieee80211_node *); -static u_int8_t ath_node_getrssi(const struct ieee80211_node *); -#endif -static int ath_rxbuf_init(struct ath_softc *, struct ath_buf *); -#ifdef BLE -static void ath_recv_mgmt(struct ieee80211com *, struct sk_buff *, - struct ieee80211_node *, - int subtype, int rssi, u_int32_t rstamp); -#endif -static void ath_setdefantenna(struct ath_softc *, u_int); -static void ath_rx_tasklet(unsigned long data); -static struct ath_txq *ath_txq_setup(struct ath_softc*, int qtype, int subtype); -//static int ath_wme_update(struct ieee80211com *); -static void ath_tx_cleanupq(struct ath_softc *, struct ath_txq *); -static void ath_tx_cleanup(struct ath_softc *); -#ifdef BLE -static int ath_start(struct sk_buff *, struct net_device *); -static int ath_tx_setup(struct ath_softc *, int ac, int txq); -static int ath_tx_start(struct net_device *, struct ieee80211_node *, - struct ath_buf *, struct sk_buff *); -static void ath_tx_tasklet_q0(unsigned long data); -static void ath_tx_tasklet_q0123(unsigned long data); -static void ath_tx_tasklet(unsigned long data); -static void ath_tx_timeout(struct net_device *); -static int ath_chan_set(struct ath_softc *, struct ieee80211_channel *); -#endif -//static void ath_draintxq(struct ath_softc *); -//static void ath_stoprecv(struct ath_softc *); -static int ath_startrecv(struct ath_softc *); -//static void ath_chan_change(struct ath_softc *, struct ieee80211_channel *); -static void ath_next_scan(unsigned long); -static void ath_calibrate(unsigned long); -#ifdef BLE -static int ath_newstate(struct ieee80211com *, enum ieee80211_state, int); -#if IEEE80211_VLAN_TAG_USED -static void ath_vlan_register(struct net_device *, struct vlan_group *); -static void ath_vlan_kill_vid(struct net_device *, unsigned short ); -#endif -static struct net_device_stats *ath_getstats(struct net_device *); -static struct iw_statistics *ath_iw_getstats(struct net_device *); -static struct iw_handler_def ath_iw_handler_def; -static void ath_setup_stationkey(struct ieee80211_node *); -static void ath_newassoc(struct ieee80211_node *, int); -#endif -static int ath_getchannels(struct ieee80211_hw *, u_int cc, - bool outdoor, bool xchanmode); -#ifdef BLE -static void ath_led_event(struct ath_softc *, int); -#endif -static void ath_led_off(unsigned long arg); -static void ath_update_txpow(struct ath_softc *); -#ifdef BLE -static int ath_set_mac_address(struct net_device *, void *); -static int ath_change_mtu(struct net_device *, int); -static int ath_ioctl(struct net_device *, struct ifreq *, int); -#endif -static int ath_rate_setup(struct ieee80211_hw *, u_int mode); -static void ath_setcurmode(struct ath_softc *, unsigned int); - -//static int ath_rawdev_attach(struct ath_softc *); -//static void ath_rawdev_detach(struct ath_softc *); -static void ath_dynamic_sysctl_register(struct ath_softc *); -static void ath_dynamic_sysctl_unregister(struct ath_softc *); -static void ath_announce(struct ath_softc *); - static const char *hal_status_desc[] = { "Everything went O.K.", "Unable to allocate memory for ath_hal", @@ -204,32 +38,6 @@ static int ath_xchanmode = true; /* enable extended channels */ static int ath_debug = 0; #define IFF_DUMPPKTS(sc, _m) \ ((sc->sc_debug & _m) || ieee80211_msg_dumppkts(&sc->sc_ic)) -enum { - ATH_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ - ATH_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ - ATH_DEBUG_RECV = 0x00000004, /* basic recv operation */ - ATH_DEBUG_RECV_DESC = 0x00000008, /* recv descriptors */ - ATH_DEBUG_RATE = 0x00000010, /* rate control */ - ATH_DEBUG_RESET = 0x00000020, /* reset processing */ - ATH_DEBUG_MODE = 0x00000040, /* mode init/setup */ - ATH_DEBUG_BEACON = 0x00000080, /* beacon handling */ - ATH_DEBUG_WATCHDOG = 0x00000100, /* watchdog timeout */ - ATH_DEBUG_INTR = 0x00001000, /* ISR */ - ATH_DEBUG_TX_PROC = 0x00002000, /* tx ISR proc */ - ATH_DEBUG_RX_PROC = 0x00004000, /* rx ISR proc */ - ATH_DEBUG_BEACON_PROC = 0x00008000, /* beacon ISR proc */ - ATH_DEBUG_CALIBRATE = 0x00010000, /* periodic calibration */ - ATH_DEBUG_KEYCACHE = 0x00020000, /* key cache management */ - ATH_DEBUG_STATE = 0x00040000, /* 802.11 state transitions */ - ATH_DEBUG_NODE = 0x00080000, /* node management */ - ATH_DEBUG_LED = 0x00100000, /* led management */ - ATH_DEBUG_FATAL = 0x80000000, /* fatal errors */ - ATH_DEBUG_ANY = 0xffffffff -}; -#define DPRINTF(sc, _m, _fmt...) do { \ - if (sc->sc_debug & (_m)) \ - printk(_fmt); \ -} while (0) #define KEYPRINTF(sc, ix, hk, mac) do { \ if (sc->sc_debug & ATH_DEBUG_KEYCACHE) \ ath_keyprint(__func__, ix, hk, mac); \ @@ -308,599 +116,6 @@ struct wlan_ng_prism2_header { struct p80211item_u32 frmlen; }; -int -ath_attach(u_int16_t devid, struct ieee80211_hw *hw) -{ - struct ath_softc *sc = hw->priv; -// struct ieee80211com *ic = &sc->sc_ic; - struct ath_hal *ah; - enum ath5k_status status; - int error = 0, i; - u_int8_t csz; - - DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid); - - /* - * Cache line size is used to size and align various - * structures used to communicate with the hardware. - */ - bus_read_cachesize(sc, &csz); - /* XXX assert csz is non-zero */ - sc->sc_cachelsz = csz << 2; /* convert to bytes */ - - ATH_LOCK_INIT(sc); - ATH_TXBUF_LOCK_INIT(sc); - - tasklet_init(&sc->sc_rxtq, ath_rx_tasklet, (unsigned long)hw); - tasklet_init(&sc->sc_rxorntq, ath_rxorn_tasklet, (unsigned long)hw); - tasklet_init(&sc->sc_fataltq, ath_fatal_tasklet, (unsigned long)hw); - tasklet_init(&sc->sc_bmisstq, ath_bmiss_tasklet, (unsigned long)hw); - tasklet_init(&sc->sc_bstuckq, ath_bstuck_tasklet, (unsigned long)hw); - tasklet_init(&sc->sc_radartq, ath_radar_tasklet, (unsigned long)hw); - - /* - * Attach the hal - */ - ah = ath5k_hw_init(devid, sc, sc->sc_iobase, &status); - if (ah == NULL) { - printk(KERN_ERR "%s: unable to attach hardware: '%s' (HAL status %u)\n", - __func__, hal_status_desc[status], status); - error = ENXIO; - goto bad; - } - sc->sc_ah = ah; - - /* - * Check if the MAC has multi-rate retry support. - * We do this by trying to setup a fake extended - * descriptor. MAC's that don't have support will - * return false w/o doing anything. MAC's that do - * support it will return true w/o doing anything. - */ - sc->sc_mrretry = ah->ah_setup_xtx_desc(ah, NULL, 0, 0, 0, 0, 0, 0); - - /* - * Check if the device has hardware counters for PHY - * errors. If so we need to enable the MIB interrupt - * so we can act on stat triggers. - */ - if (ath_hal_hwphycounters(ah)) - sc->sc_needmib = 1; - - /* - * Get the hardware key cache size. - */ - sc->sc_keymax = ath5k_hw_get_keycache_size(ah); - if (sc->sc_keymax > ATH_KEYMAX) { - printk(KERN_WARNING "Warning, using only %u of %u key cache " - "slots\n", ATH_KEYMAX, sc->sc_keymax); - sc->sc_keymax = ATH_KEYMAX; - } - - /* - * Reset the key cache since some parts do not - * reset the contents on initial power up. - */ - for (i = 0; i < sc->sc_keymax; i++) - ath5k_hw_reset_key(ah, i); - /* - * Mark key cache slots associated with global keys - * as in use. If we knew TKIP was not to be used we - * could leave the +32, +64, and +32+64 slots free. - * XXX only for splitmic. - */ -#ifdef BLE - for (i = 0; i < IEEE80211_WEP_NKID; i++) { - setbit(sc->sc_keymap, i); - setbit(sc->sc_keymap, i+32); - setbit(sc->sc_keymap, i+64); - setbit(sc->sc_keymap, i+32+64); - } -#endif - - /* - * Collect the channel list using the default country - * code and including outdoor channels. The 802.11 layer - * is resposible for filtering this list based on settings - * like the phy mode. - */ - if (countrycode != -1) - ath_countrycode = countrycode; - if (outdoor != -1) - ath_outdoor = outdoor; - if (xchanmode != -1) - ath_xchanmode = xchanmode; - error = ath_getchannels(hw, ath_countrycode, ath_outdoor,ath_xchanmode); - if (error != 0) { - printk("error! but continuing anyways...\n"); - //goto bad; - } - - /* - * Setup rate tables for all potential media types. - */ - ath_rate_setup(hw, MODE_IEEE80211A); - ath_rate_setup(hw, MODE_IEEE80211B); - ath_rate_setup(hw, MODE_IEEE80211G); - ath_rate_setup(hw, MODE_ATHEROS_TURBO); - ath_rate_setup(hw, MODE_ATHEROS_TURBOG); - /* NB: setup here so ath_rate_update is happy */ - ath_setcurmode(sc, MODE_IEEE80211A); - - /* - * Allocate tx+rx descriptors and populate the lists. - */ - error = ath_desc_alloc(sc); - if (error != 0) { - printk(KERN_ERR "failed to allocate descriptors: %d\n", error); - goto bad; - } - - /* - * Allocate hardware transmit queues: one queue for - * beacon frames and one data queue for each QoS - * priority. Note that the hal handles reseting - * these queues at the needed time. - * - * XXX PS-Poll - */ - sc->sc_bhalq = ath_beaconq_setup(ah); - if (sc->sc_bhalq == (u_int) -1) { - printk(KERN_ERR "unable to setup a beacon xmit queue!\n"); - goto bad2; - } - sc->sc_cabq = ath_txq_setup(sc, AR5K_TX_QUEUE_CAB, 0); - if (sc->sc_cabq == NULL) { - printk(KERN_ERR "unable to setup CAB xmit queue!\n"); - error = EIO; - goto bad2; - } -#ifdef BLE - /* NB: insure BK queue is the lowest priority h/w queue */ - if (!ath_tx_setup(sc, WME_AC_BK, AR5K_WME_AC_BK)) { - printk(KERN_ERR "unable to setup xmit queue for %s traffic!\n", - ieee80211_wme_acnames[WME_AC_BK]); - error = EIO; - goto bad2; - } - if (!ath_tx_setup(sc, WME_AC_BE, AR5K_WME_AC_BE) || - !ath_tx_setup(sc, WME_AC_VI, AR5K_WME_AC_VI) || - !ath_tx_setup(sc, WME_AC_VO, AR5K_WME_AC_VO)) { - /* - * Not enough hardware tx queues to properly do WME; - * just punt and assign them all to the same h/w queue. - * We could do a better job of this if, for example, - * we allocate queues when we switch from station to - * AP mode. - */ - if (sc->sc_ac2q[WME_AC_VI] != NULL) - ath_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_VI]); - if (sc->sc_ac2q[WME_AC_BE] != NULL) - ath_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_BE]); - sc->sc_ac2q[WME_AC_BE] = sc->sc_ac2q[WME_AC_BK]; - sc->sc_ac2q[WME_AC_VI] = sc->sc_ac2q[WME_AC_BK]; - sc->sc_ac2q[WME_AC_VO] = sc->sc_ac2q[WME_AC_BK]; - } - - /* - * Special case certain configurations. Note the - * CAB queue is handled by these specially so don't - * include them when checking the txq setup mask. - */ - switch (sc->sc_txqsetup &~ (1<sc_cabq->axq_qnum)) { - case 0x01: - ATH_INIT_TQUEUE(&sc->sc_txtq, ath_tx_tasklet_q0, dev); - break; - case 0x0f: - ATH_INIT_TQUEUE(&sc->sc_txtq, ath_tx_tasklet_q0123, dev); - break; - default: - ATH_INIT_TQUEUE(&sc->sc_txtq, ath_tx_tasklet, dev); - break; - } - - /* - * Setup rate control. Some rate control modules - * call back to change the anntena state so expose - * the necessary entry points. - * XXX maybe belongs in struct ath_ratectrl? - */ - sc->sc_setdefantenna = ath_setdefantenna; - sc->sc_rc = ath_rate_attach(sc); - if (sc->sc_rc == NULL) { - error = EIO; - goto bad2; - } -#endif - init_timer(&sc->sc_scan_ch); - sc->sc_scan_ch.function = ath_next_scan; - sc->sc_scan_ch.data = (unsigned long)hw; - - init_timer(&sc->sc_cal_ch); - sc->sc_cal_ch.function = ath_calibrate; - sc->sc_cal_ch.data = (unsigned long)hw; - - sc->sc_blinking = 0; - sc->sc_ledstate = 1; - sc->sc_ledon = 0; /* low true */ - sc->sc_ledidle = (2700*HZ)/1000; /* 2.7sec */ - - init_timer(&sc->sc_ledtimer); - sc->sc_ledtimer.function = ath_led_off; - sc->sc_ledtimer.data = (unsigned long) sc; - /* - * Auto-enable soft led processing for IBM cards and for - * 5211 minipci cards. Users can also manually enable/disable - * support with a sysctl. - */ - sc->sc_softled = (devid == PCI_DEVICE_ID_ATHEROS_AR5212_IBM || - devid == PCI_DEVICE_ID_ATHEROS_AR5211); - if (sc->sc_softled) { - ath5k_hw_set_gpio_output(ah, sc->sc_ledpin); - ath5k_hw_set_gpio(ah, sc->sc_ledpin, !sc->sc_ledon); - } - -#ifdef BLE - ether_setup(dev); - dev->open = ath_init; - dev->stop = ath_stop; - dev->hard_start_xmit = ath_start; - dev->tx_timeout = ath_tx_timeout; - dev->watchdog_timeo = 5 * HZ; /* XXX */ - dev->set_multicast_list = ath_mode_init; - dev->do_ioctl = ath_ioctl; - dev->get_stats = ath_getstats; - dev->set_mac_address = ath_set_mac_address; - dev->change_mtu = &ath_change_mtu; - dev->tx_queue_len = ATH_TXBUF; /* TODO? 1 for mgmt frame */ -/*get_wireless_stats moved from net_device to iw_handler_def*/ -# if IW_HANDLER_VERSION < 7 - dev->get_wireless_stats = ath_iw_getstats; -# endif - ieee80211_ioctl_iwsetup(&ath_iw_handler_def); - dev->wireless_handlers = &ath_iw_handler_def; -#if IEEE80211_VLAN_TAG_USED - dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; - dev->vlan_rx_register = ath_vlan_register; - dev->vlan_rx_kill_vid = ath_vlan_kill_vid; -#endif /* IEEE80211_VLAN_TAG_USED */ - ic->ic_dev = dev; - ic->ic_devstats = &sc->sc_devstats; - ic->ic_init = ath_init; - ic->ic_reset = ath_reset; - ic->ic_newassoc = ath_newassoc; - ic->ic_updateslot = ath_updateslot; - ic->ic_wme.wme_update = ath_wme_update; - /* XXX not right but it's not used anywhere important */ - ic->ic_phytype = MODULATION_OFDM; - ic->ic_opmode = IEEE80211_M_STA; - ic->ic_caps = - IEEE80211_C_IBSS /* ibss, nee adhoc, mode */ - | IEEE80211_C_AHDEMO /* adhoc demo (pseudo_ibss) mode */ - | IEEE80211_C_HOSTAP /* hostap mode */ - | IEEE80211_C_MONITOR /* monitor mode */ - | IEEE80211_C_SHPREAMBLE /* short preamble supported */ - | IEEE80211_C_SHSLOT /* short slot time supported */ - | IEEE80211_C_WPA /* capable of WPA1+WPA2 */ - ; - /* - * initialize management queue - */ - skb_queue_head_init(&ic->ic_mgtq); - - /* - * Query the hal to figure out h/w crypto support. - */ - if (ath_hal_ciphersupported(ah, AR5K_CIPHER_WEP)) - ic->ic_caps |= IEEE80211_C_WEP; - if (ath_hal_ciphersupported(ah, AR5K_CIPHER_AES_OCB)) - ic->ic_caps |= IEEE80211_C_AES; - if (ath_hal_ciphersupported(ah, AR5K_CIPHER_AES_CCM)) - ic->ic_caps |= IEEE80211_C_AES_CCM; - if (ath_hal_ciphersupported(ah, AR5K_CIPHER_CKIP)) - ic->ic_caps |= IEEE80211_C_CKIP; - if (ath_hal_ciphersupported(ah, AR5K_CIPHER_TKIP)) { - ic->ic_caps |= IEEE80211_C_TKIP; - /* - * Check if h/w does the MIC and/or whether the - * separate key cache entries are required to - * handle both tx+rx MIC keys. - */ - if (ath_hal_ciphersupported(ah, AR5K_CIPHER_MIC)) - ic->ic_caps |= IEEE80211_C_TKIPMIC; - if (ath_hal_tkipsplit(ah)) - sc->sc_splitmic = 1; - } - sc->sc_hasclrkey = ath_hal_ciphersupported(ah, AR5K_CIPHER_CLR); - sc->sc_mcastkey = ath_hal_getmcastkeysearch(ah); - /* - * TPC support can be done either with a global cap or - * per-packet support. The latter is not available on - * all parts. We're a bit pedantic here as all parts - * support a global cap. - */ - if (ath_hal_hastpc(ah) || ath_hal_hastxpowlimit(ah)) - ic->ic_caps |= IEEE80211_C_TXPMGT; - - /* - * Mark WME capability only if we have sufficient - * hardware queues to do proper priority scheduling. - */ - if (sc->sc_ac2q[WME_AC_BE] != sc->sc_ac2q[WME_AC_BK]) - ic->ic_caps |= IEEE80211_C_WME; - /* - * Check for misc other capabilities. - */ - if (ath_hal_hasbursting(ah)) - ic->ic_caps |= IEEE80211_C_BURST; - - /* - * Indicate we need the 802.11 header padded to a - * 32-bit boundary for 4-address and QoS frames. - */ - ic->ic_flags |= IEEE80211_F_DATAPAD; -#endif - - /* - * Query the hal about antenna support. - */ - sc->sc_defant = ath5k_hw_get_def_antenna(ah); - - /* - * Not all chips have the VEOL support we want to - * use with IBSS beacons; check here for it. - */ - sc->sc_hasveol = ath_hal_hasveol(ah); - - sc->sc_rxfilter = 0; - - /* get mac address from hardware */ -// ath_hal_getmac(ah, ic->ic_myaddr); BLEE -// IEEE80211_ADDR_COPY(dev->dev_addr, ic->ic_myaddr); -#ifdef BLE - /* call MI attach routine. */ - ieee80211_ifattach(ic); - /* override default methods */ - ic->ic_node_alloc = ath_node_alloc; - sc->sc_node_free = ic->ic_node_free; - ic->ic_node_free = ath_node_free; - ic->ic_node_getrssi = ath_node_getrssi; - sc->sc_recv_mgmt = ic->ic_recv_mgmt; - ic->ic_recv_mgmt = ath_recv_mgmt; - sc->sc_newstate = ic->ic_newstate; - ic->ic_newstate = ath_newstate; - ic->ic_crypto.cs_key_alloc = ath_key_alloc; - ic->ic_crypto.cs_key_delete = ath_key_delete; - ic->ic_crypto.cs_key_set = ath_key_set; - ic->ic_crypto.cs_key_update_begin = ath_key_update_begin; - ic->ic_crypto.cs_key_update_end = ath_key_update_end; - - radar_init(ic); -#endif -#if 0 - /* complete initialization */ - ieee80211_media_init(ic, ath_media_change, ieee80211_media_status); - - if (register_netdev(dev)) { - printk(KERN_ERR "%s: unable to register device\n", dev->name); - goto bad3; - } - -#endif - /* - * Attach dynamic MIB vars and announce support - * now that we have a device name with unit number. - */ - ath_dynamic_sysctl_register(sc); -// ath_rate_dynamic_sysctl_register(sc); - ath_announce(sc); - - return 0; -//bad3: -// ieee80211_ifdetach(ic); -// ath_rate_detach(sc->sc_rc); -bad2: -#ifdef BLE - if (sc->sc_txq[WME_AC_BK].axq_qnum != (u_int) -1) { - ATH_TXQ_LOCK_DESTROY(&sc->sc_txq[WME_AC_BK]); - } - if (sc->sc_txq[WME_AC_BE].axq_qnum != (u_int) -1) { - ATH_TXQ_LOCK_DESTROY(&sc->sc_txq[WME_AC_BE]); - } - if (sc->sc_txq[WME_AC_VI].axq_qnum != (u_int) -1) { - ATH_TXQ_LOCK_DESTROY(&sc->sc_txq[WME_AC_VI]); - } - if (sc->sc_txq[WME_AC_VO].axq_qnum != (u_int) -1) { - ATH_TXQ_LOCK_DESTROY(&sc->sc_txq[WME_AC_VO]); - } -#endif - ath_tx_cleanup(sc); - ath_desc_free(sc); -bad: - if (ah) { - ath5k_hw_detach(ah); - } - sc->sc_invalid = 1; - return error; -} - -int -ath_detach(struct ieee80211_hw *hw) -{ - struct ath_softc *sc = hw->priv; -// struct ieee80211com *ic = &sc->sc_ic; - - ath_stop(hw); - sc->sc_invalid = 1; - /* - * NB: the order of these is important: - * o call the 802.11 layer before detaching the hal to - * insure callbacks into the driver to delete global - * key cache entries can be handled - * o reclaim the tx queue data structures after calling - * the 802.11 layer as we'll get called back to reclaim - * node state and potentially want to use them - * o to cleanup the tx queues the hal is called, so detach - * it last - * Other than that, it's straightforward... - */ -// ieee80211_ifdetach(ic); -// ath_rate_detach(sc->sc_rc); - ath_desc_free(sc); - ath_tx_cleanup(sc); - ath5k_hw_detach(sc->sc_ah); - - /* - * NB: can't reclaim these until after ieee80211_ifdetach - * returns because we'll get called back to reclaim node - * state and potentially want to use them. - */ - ath_dynamic_sysctl_unregister(sc); -// ath_rawdev_detach(sc); -// unregister_netdev(dev); - - return 0; -} - -void -ath_suspend(struct ieee80211_hw *hw) -{ - struct ath_softc *sc = hw->priv; - struct ath_hal *ah = sc->sc_ah; - - if (sc->sc_softled) - ath5k_hw_set_gpio(ah, sc->sc_ledpin, 1); - - ath_stop(hw); -} - -void -ath_resume(struct ieee80211_hw *hw) -{ - struct ath_softc *sc = hw->priv; - struct ath_hal *ah = sc->sc_ah; - - ath_init(hw); - if (sc->sc_softled) { - ath5k_hw_set_gpio_output(ah, sc->sc_ledpin); - ath5k_hw_set_gpio(ah, sc->sc_ledpin, 0); - } -} - -/* - * Interrupt handler. Most of the actual processing is deferred. - */ - -/* - *Port r1752 - Starting linux kernel v2.6.19 and later - *interrupt handlers are not passed. - */ -irqreturn_t ath_intr(int irq, void *dev_id) -{ - struct net_device *dev = dev_id; - struct ath_softc *sc = dev->priv; - struct ath_hal *ah = sc->sc_ah; - enum ath5k_int status; - int needmark; - - if (sc->sc_invalid) { - /* - * The hardware is not ready/present, don't touch anything. - * Note this can happen early on if the IRQ is shared. - */ - DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid; ignored\n", __func__); - return IRQ_NONE; - } - if (!ath_hw_irq_pending(ah)) /* shared irq, not for us */ - return IRQ_NONE; - if ((dev->flags & (IFF_RUNNING|IFF_UP)) != (IFF_RUNNING|IFF_UP)) { - DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags 0x%x\n", - __func__, dev->flags); - ath5k_hw_get_isr(ah, &status); /* clear ISR */ - ath5k_hw_set_intr(ah, 0); /* disable further intr's */ - return IRQ_HANDLED; - } - needmark = 0; - - do { - /* - * Figure out the reason(s) for the interrupt. Note - * that the hal returns a pseudo-ISR that may include - * bits we haven't explicitly enabled so we mask the - * value to insure we only process bits we requested. - */ - ath5k_hw_get_isr(ah, &status); /* NB: clears ISR too */ - DPRINTF(sc, ATH_DEBUG_INTR, "%s: status 0x%x\n", __func__, status); - status &= sc->sc_imask; /* discard unasked for bits */ - if (status & AR5K_INT_FATAL) { - /* - * Fatal errors are unrecoverable. Typically - * these are caused by DMA errors. Unfortunately - * the exact reason is not (presently) returned - * by the hal. - */ - sc->sc_stats.ast_hardware++; - ath5k_hw_set_intr(ah, 0); /* disable intr's until reset */ - tasklet_schedule(&sc->sc_fataltq); - } else if (status & AR5K_INT_RXORN) { - sc->sc_stats.ast_rxorn++; - ath5k_hw_set_intr(ah, 0); /* disable intr's until reset */ - tasklet_schedule(&sc->sc_rxorntq); - } else { - if (status & AR5K_INT_SWBA) { - /* - * Software beacon alert--time to send a beacon. - * Handle beacon transmission directly; deferring - * this is too slow to meet timing constraints - * under load. - */ - ath_beacon_send(dev); - } - if (status & AR5K_INT_RXEOL) { - /* - * NB: the hardware should re-read the link when - * RXE bit is written, but it doesn't work at - * least on older hardware revs. - */ - sc->sc_stats.ast_rxeol++; - sc->sc_rxlink = NULL; - } - if (status & AR5K_INT_TXURN) { - sc->sc_stats.ast_txurn++; - /* bump tx trigger level */ - ath5k_hw_update_tx_triglevel(ah, true); - } - if (status & AR5K_INT_RX) - tasklet_schedule(&sc->sc_rxtq); - if (status & AR5K_INT_TX) - tasklet_schedule(&sc->sc_txtq); - if (status & AR5K_INT_BMISS) { - sc->sc_stats.ast_bmiss++; - tasklet_schedule(&sc->sc_bmisstq); - } - if (status & AR5K_INT_MIB) { - sc->sc_stats.ast_mib++; - /* - * Disable interrupts until we service the MIB - * interrupt; otherwise it will continue to fire. - */ - ath5k_hw_set_intr(ah, 0); - /* - * Let the hal handle the event. We assume it will - * clear whatever condition caused the interrupt. - */ -#ifdef BLE - ath5k_hw_proc_mib_event(ah, - &ATH_NODE(sc->sc_ic.ic_bss)->an_halstats); -#endif - ath5k_hw_set_intr(ah, sc->sc_imask); - } - } - } while (ath5k_hw_is_intr_pending(ah)); - - return IRQ_HANDLED; -} - static void ath_fatal_tasklet(unsigned long data) { @@ -6384,103 +5599,3 @@ ath_announce(struct ath_softc *sc) #endif #undef AR5K_MODE_DUALBAND } - -/* - * Static (i.e. global) sysctls. Note that the hal sysctls - * are located under ours by sharing the setting for DEV_ATH. - */ -enum { - DEV_ATH = 9, /* XXX known by hal */ -}; - -static ctl_table ath_static_sysctls[] = { -#ifdef AR_DEBUG - { .ctl_name = CTL_AUTO, - .procname = "debug", - .mode = 0644, - .data = &ath_debug, - .maxlen = sizeof(ath_debug), - .proc_handler = proc_dointvec - }, -#endif - { .ctl_name = CTL_AUTO, - .procname = "countrycode", - .mode = 0444, - .data = &ath_countrycode, - .maxlen = sizeof(ath_countrycode), - .proc_handler = proc_dointvec - }, - { .ctl_name = CTL_AUTO, - .procname = "regdomain", - .mode = 0444, - .data = &ath_regdomain, - .maxlen = sizeof(ath_regdomain), - .proc_handler = proc_dointvec - }, - { .ctl_name = CTL_AUTO, - .procname = "outdoor", - .mode = 0444, - .data = &ath_outdoor, - .maxlen = sizeof(ath_outdoor), - .proc_handler = proc_dointvec - }, - { .ctl_name = CTL_AUTO, - .procname = "xchanmode", - .mode = 0444, - .data = &ath_xchanmode, - .maxlen = sizeof(ath_xchanmode), - .proc_handler = proc_dointvec - }, - { .ctl_name = CTL_AUTO, - .procname = "dwelltime", - .mode = 0644, - .data = &ath_dwelltime, - .maxlen = sizeof(ath_dwelltime), - .extra1 = &mindwelltime, - .extra2 = &maxint, - .proc_handler = proc_dointvec_minmax - }, - { .ctl_name = CTL_AUTO, - .procname = "calibrate", - .mode = 0644, - .data = &ath_calinterval, - .maxlen = sizeof(ath_calinterval), - .extra1 = &mincalibrate, - .extra2 = &maxint, - .proc_handler = proc_dointvec_minmax - }, - { 0 } -}; -static ctl_table ath_ath_table[] = { - { .ctl_name = DEV_ATH, - .procname = "ath", - .mode = 0555, - .child = ath_static_sysctls - }, { 0 } -}; -static ctl_table ath_root_table[] = { - { .ctl_name = CTL_DEV, - .procname = "dev", - .mode = 0555, - .child = ath_ath_table - }, { 0 } -}; -static struct ctl_table_header *ath_sysctl_header; - -void -ath_sysctl_register(void) -{ - static int initialized = 0; - - if (!initialized) { - ath_sysctl_header = register_sysctl_table(ath_root_table); - initialized = 1; - } -} - -void -ath_sysctl_unregister(void) -{ - if (ath_sysctl_header) - unregister_sysctl_table(ath_sysctl_header); -}