2 * Copyright (c) 2008 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 /* mac80211 and PCI callbacks */
19 #include <linux/nl80211.h>
22 #define ATH_PCI_VERSION "0.1"
24 #define IEEE80211_HTCAP_MAXRXAMPDU_FACTOR 13
25 #define IEEE80211_ACTION_CAT_HT 7
26 #define IEEE80211_ACTION_HT_TXCHWIDTH 0
28 static char *dev_info = "ath9k";
30 MODULE_AUTHOR("Atheros Communications");
31 MODULE_DESCRIPTION("Support for Atheros 802.11n wireless LAN cards.");
32 MODULE_SUPPORTED_DEVICE("Atheros 802.11n WLAN cards");
33 MODULE_LICENSE("Dual BSD/GPL");
35 static struct pci_device_id ath_pci_id_table[] __devinitdata = {
36 { PCI_VDEVICE(ATHEROS, 0x0023) }, /* PCI */
37 { PCI_VDEVICE(ATHEROS, 0x0024) }, /* PCI-E */
38 { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */
39 { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI */
40 { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */
44 static int test_update_chan(enum ieee80211_band band,
45 const struct hal_channel *chan,
50 for (i = 0; i < sc->sbands[band].n_channels; i++) {
51 if (sc->channels[band][i].center_freq == chan->channel)
58 static int ath_check_chanflags(struct ieee80211_channel *chan,
62 struct ieee80211_hw *hw = sc->hw;
63 struct ieee80211_supported_band *band;
64 struct ieee80211_channel *band_channel;
67 band = hw->wiphy->bands[chan->band];
69 for (i = 0; i < band->n_channels; i++) {
70 band_channel = &band->channels[i];
72 if ((band_channel->center_freq == chan->center_freq) &&
73 ((band_channel->hw_value & mode) == mode))
79 static int ath_setkey_tkip(struct ath_softc *sc,
80 struct ieee80211_key_conf *key,
81 struct hal_keyval *hk,
87 key_txmic = key->key + NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY;
88 key_rxmic = key->key + NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY;
91 /* Group key installation */
92 memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic));
93 return ath_keyset(sc, key->keyidx, hk, addr);
95 if (!sc->sc_splitmic) {
97 * data key goes at first index,
98 * the hal handles the MIC keys at index+64.
100 memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic));
101 memcpy(hk->kv_txmic, key_txmic, sizeof(hk->kv_txmic));
102 return ath_keyset(sc, key->keyidx, hk, addr);
105 * TX key goes at first index, RX key at +32.
106 * The hal handles the MIC keys at index+64.
108 memcpy(hk->kv_mic, key_txmic, sizeof(hk->kv_mic));
109 if (!ath_keyset(sc, key->keyidx, hk, NULL)) {
110 /* Txmic entry failed. No need to proceed further */
111 DPRINTF(sc, ATH_DBG_KEYCACHE,
112 "%s Setting TX MIC Key Failed\n", __func__);
116 memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic));
117 /* XXX delete tx key on failure? */
118 return ath_keyset(sc, key->keyidx+32, hk, addr);
121 static int ath_key_config(struct ath_softc *sc,
123 struct ieee80211_key_conf *key)
125 struct ieee80211_vif *vif;
126 struct hal_keyval hk;
127 const u8 *mac = NULL;
129 enum ieee80211_if_types opmode;
131 memset(&hk, 0, sizeof(hk));
135 hk.kv_type = HAL_CIPHER_WEP;
138 hk.kv_type = HAL_CIPHER_TKIP;
141 hk.kv_type = HAL_CIPHER_AES_CCM;
147 hk.kv_len = key->keylen;
148 memcpy(hk.kv_val, key->key, key->keylen);
153 vif = sc->sc_vaps[0]->av_if_data;
158 * For _M_STA mc tx, we will not setup a key at all since we never
160 * _M_STA mc rx, we will use the keyID.
161 * for _M_IBSS mc tx, we will use the keyID, and no macaddr.
162 * for _M_IBSS mc rx, we will alloc a slot and plumb the mac of the
163 * peer node. BUT we will plumb a cleartext key so that we can do
164 * perSta default key table lookup in software.
166 if (is_broadcast_ether_addr(addr)) {
168 case IEEE80211_IF_TYPE_STA:
169 /* default key: could be group WPA key
170 * or could be static WEP key */
173 case IEEE80211_IF_TYPE_IBSS:
175 case IEEE80211_IF_TYPE_AP:
185 if (key->alg == ALG_TKIP)
186 ret = ath_setkey_tkip(sc, key, &hk, mac);
188 ret = ath_keyset(sc, key->keyidx, &hk, mac);
193 sc->sc_keytype = hk.kv_type;
197 static void ath_key_delete(struct ath_softc *sc, struct ieee80211_key_conf *key)
199 #define ATH_MAX_NUM_KEYS 4
202 freeslot = (key->keyidx >= ATH_MAX_NUM_KEYS) ? 1 : 0;
203 ath_key_reset(sc, key->keyidx, freeslot);
204 #undef ATH_MAX_NUM_KEYS
207 static void setup_ht_cap(struct ieee80211_ht_info *ht_info)
209 /* Until mac80211 includes these fields */
211 #define IEEE80211_HT_CAP_DSSSCCK40 0x1000
212 #define IEEE80211_HT_CAP_MAXRXAMPDU_65536 0x3 /* 2 ^ 16 */
213 #define IEEE80211_HT_CAP_MPDUDENSITY_8 0x6 /* 8 usec */
215 ht_info->ht_supported = 1;
216 ht_info->cap = (u16)IEEE80211_HT_CAP_SUP_WIDTH
217 |(u16)IEEE80211_HT_CAP_MIMO_PS
218 |(u16)IEEE80211_HT_CAP_SGI_40
219 |(u16)IEEE80211_HT_CAP_DSSSCCK40;
221 ht_info->ampdu_factor = IEEE80211_HT_CAP_MAXRXAMPDU_65536;
222 ht_info->ampdu_density = IEEE80211_HT_CAP_MPDUDENSITY_8;
223 /* setup supported mcs set */
224 memset(ht_info->supp_mcs_set, 0, 16);
225 ht_info->supp_mcs_set[0] = 0xff;
226 ht_info->supp_mcs_set[1] = 0xff;
227 ht_info->supp_mcs_set[12] = IEEE80211_HT_CAP_MCS_TX_DEFINED;
230 static int ath_rate2idx(struct ath_softc *sc, int rate)
232 int i = 0, cur_band, n_rates;
233 struct ieee80211_hw *hw = sc->hw;
235 cur_band = hw->conf.channel->band;
236 n_rates = sc->sbands[cur_band].n_bitrates;
238 for (i = 0; i < n_rates; i++) {
239 if (sc->sbands[cur_band].bitrates[i].bitrate == rate)
244 * NB:mac80211 validates rx rate index against the supported legacy rate
245 * index only (should be done against ht rates also), return the highest
246 * legacy rate index for rx rate which does not match any one of the
247 * supported basic and extended rates to make mac80211 happy.
248 * The following hack will be cleaned up once the issue with
249 * the rx rate index validation in mac80211 is fixed.
256 static void ath9k_rx_prepare(struct ath_softc *sc,
258 struct ath_recv_status *status,
259 struct ieee80211_rx_status *rx_status)
261 struct ieee80211_hw *hw = sc->hw;
262 struct ieee80211_channel *curchan = hw->conf.channel;
264 memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
266 rx_status->mactime = status->tsf;
267 rx_status->band = curchan->band;
268 rx_status->freq = curchan->center_freq;
269 rx_status->signal = (status->rssi * 64) / 100;
270 rx_status->noise = ATH_DEFAULT_NOISE_FLOOR;
271 rx_status->rate_idx = ath_rate2idx(sc, (status->rateKbps / 100));
272 rx_status->antenna = status->antenna;
274 if (status->flags & ATH_RX_MIC_ERROR)
275 rx_status->flag |= RX_FLAG_MMIC_ERROR;
276 if (status->flags & ATH_RX_FCS_ERROR)
277 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
279 rx_status->flag |= RX_FLAG_TSFT;
282 static u_int8_t parse_mpdudensity(u_int8_t mpdudensity)
285 * 802.11n D2.0 defined values for "Minimum MPDU Start Spacing":
286 * 0 for no restriction
295 switch (mpdudensity) {
301 /* Our lower layer calculations limit our precision to
317 static int ath9k_start(struct ieee80211_hw *hw)
319 struct ath_softc *sc = hw->priv;
320 struct ieee80211_channel *curchan = hw->conf.channel;
321 struct hal_channel hchan;
324 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Starting driver with "
325 "initial channel: %d MHz\n", __func__, curchan->center_freq);
327 /* setup initial channel */
329 hchan.channel = curchan->center_freq;
330 hchan.channelFlags = ath_chan2flags(curchan, sc);
333 error = ath_open(sc, &hchan);
335 DPRINTF(sc, ATH_DBG_FATAL,
336 "%s: Unable to complete ath_open\n", __func__);
340 ieee80211_wake_queues(hw);
344 static int ath9k_tx(struct ieee80211_hw *hw,
347 struct ath_softc *sc = hw->priv;
350 /* Add the padding after the header if this is not already done */
351 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
353 padsize = hdrlen % 4;
354 if (skb_headroom(skb) < padsize)
356 skb_push(skb, padsize);
357 memmove(skb->data, skb->data + padsize, hdrlen);
360 DPRINTF(sc, ATH_DBG_XMIT, "%s: transmitting packet, skb: %p\n",
364 if (ath_tx_start(sc, skb) != 0) {
365 DPRINTF(sc, ATH_DBG_XMIT, "%s: TX failed\n", __func__);
366 dev_kfree_skb_any(skb);
367 /* FIXME: Check for proper return value from ATH_DEV */
374 static void ath9k_stop(struct ieee80211_hw *hw)
376 struct ath_softc *sc = hw->priv;
379 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Driver halt\n", __func__);
381 error = ath_suspend(sc);
383 DPRINTF(sc, ATH_DBG_CONFIG,
384 "%s: Device is no longer present\n", __func__);
386 ieee80211_stop_queues(hw);
389 static int ath9k_add_interface(struct ieee80211_hw *hw,
390 struct ieee80211_if_init_conf *conf)
392 struct ath_softc *sc = hw->priv;
393 int error, ic_opmode = 0;
395 /* Support only vap for now */
400 switch (conf->type) {
401 case IEEE80211_IF_TYPE_STA:
402 ic_opmode = HAL_M_STA;
404 case IEEE80211_IF_TYPE_IBSS:
405 ic_opmode = HAL_M_IBSS;
408 DPRINTF(sc, ATH_DBG_FATAL,
409 "%s: Only STA and IBSS are supported currently\n",
414 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Attach a VAP of type: %d\n",
418 error = ath_vap_attach(sc, 0, conf->vif, ic_opmode);
420 DPRINTF(sc, ATH_DBG_FATAL,
421 "%s: Unable to attach vap, error: %d\n",
429 static void ath9k_remove_interface(struct ieee80211_hw *hw,
430 struct ieee80211_if_init_conf *conf)
432 struct ath_softc *sc = hw->priv;
436 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Detach VAP\n", __func__);
438 avp = sc->sc_vaps[0];
440 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid interface\n",
445 #ifdef CONFIG_SLOW_ANT_DIV
446 ath_slow_ant_div_stop(&sc->sc_antdiv);
449 /* Update ratectrl */
450 ath_rate_newstate(sc, avp, 0);
452 /* Reclaim beacon resources */
453 if (sc->sc_opmode == HAL_M_HOSTAP || sc->sc_opmode == HAL_M_IBSS) {
454 ath9k_hw_stoptxdma(sc->sc_ah, sc->sc_bhalq);
455 ath_beacon_return(sc, avp);
458 /* Set interrupt mask */
459 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS);
460 ath9k_hw_set_interrupts(sc->sc_ah, sc->sc_imask & ~HAL_INT_GLOBAL);
463 error = ath_vap_detach(sc, 0);
465 DPRINTF(sc, ATH_DBG_FATAL,
466 "%s: Unable to detach vap, error: %d\n",
470 static int ath9k_config(struct ieee80211_hw *hw,
471 struct ieee80211_conf *conf)
473 struct ath_softc *sc = hw->priv;
474 struct ieee80211_channel *curchan = hw->conf.channel;
475 struct hal_channel hchan;
477 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Set channel: %d MHz\n",
479 curchan->center_freq);
481 hchan.channel = curchan->center_freq;
482 hchan.channelFlags = ath_chan2flags(curchan, sc);
483 sc->sc_config.txpowlimit = 2 * conf->power_level;
485 /* set h/w channel */
486 if (ath_set_channel(sc, &hchan) < 0)
487 DPRINTF(sc, ATH_DBG_FATAL, "%s: Unable to set channel\n",
493 static int ath9k_config_interface(struct ieee80211_hw *hw,
494 struct ieee80211_vif *vif,
495 struct ieee80211_if_conf *conf)
497 struct ath_softc *sc = hw->priv;
501 DECLARE_MAC_BUF(mac);
503 avp = sc->sc_vaps[0];
505 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid interface\n",
510 if ((conf->changed & IEEE80211_IFCC_BSSID) &&
511 !is_zero_ether_addr(conf->bssid)) {
513 case IEEE80211_IF_TYPE_STA:
514 case IEEE80211_IF_TYPE_IBSS:
515 /* Update ratectrl about the new state */
516 ath_rate_newstate(sc, avp, 0);
519 rfilt = ath_calcrxfilter(sc);
520 ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
523 memcpy(sc->sc_curbssid, conf->bssid, ETH_ALEN);
525 ath9k_hw_write_associd(sc->sc_ah, sc->sc_curbssid,
528 /* Set aggregation protection mode parameters */
529 sc->sc_config.ath_aggr_prot = 0;
532 * Reset our TSF so that its value is lower than the
533 * beacon that we are trying to catch.
534 * Only then hw will update its TSF register with the
535 * new beacon. Reset the TSF before setting the BSSID
536 * to avoid allowing in any frames that would update
537 * our TSF only to have us clear it
538 * immediately thereafter.
540 ath9k_hw_reset_tsf(sc->sc_ah);
542 /* Disable BMISS interrupt when we're not associated */
543 ath9k_hw_set_interrupts(sc->sc_ah,
545 ~(HAL_INT_SWBA | HAL_INT_BMISS));
546 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS);
548 DPRINTF(sc, ATH_DBG_CONFIG,
549 "%s: RX filter 0x%x bssid %s aid 0x%x\n",
551 print_mac(mac, sc->sc_curbssid), sc->sc_curaid);
553 /* need to reconfigure the beacon */
562 if ((conf->changed & IEEE80211_IFCC_BEACON) &&
563 (vif->type == IEEE80211_IF_TYPE_IBSS)) {
565 * Allocate and setup the beacon frame.
567 * Stop any previous beacon DMA. This may be
568 * necessary, for example, when an ibss merge
569 * causes reconfiguration; we may be called
570 * with beacon transmission active.
572 ath9k_hw_stoptxdma(sc->sc_ah, sc->sc_bhalq);
574 error = ath_beacon_alloc(sc, 0);
578 ath_beacon_sync(sc, 0);
581 /* Check for WLAN_CAPABILITY_PRIVACY ? */
582 if ((avp->av_opmode != IEEE80211_IF_TYPE_STA)) {
583 for (i = 0; i < IEEE80211_WEP_NKID; i++)
584 if (ath9k_hw_keyisvalid(sc->sc_ah, (u_int16_t)i))
585 ath9k_hw_keysetmac(sc->sc_ah,
590 /* Only legacy IBSS for now */
591 if (vif->type == IEEE80211_IF_TYPE_IBSS)
592 ath_update_chainmask(sc, 0);
597 #define SUPPORTED_FILTERS \
598 (FIF_PROMISC_IN_BSS | \
602 FIF_BCN_PRBRESP_PROMISC | \
605 /* Accept unicast, bcast and mcast frames */
607 static void ath9k_configure_filter(struct ieee80211_hw *hw,
608 unsigned int changed_flags,
609 unsigned int *total_flags,
611 struct dev_mc_list *mclist)
613 struct ath_softc *sc = hw->priv;
615 changed_flags &= SUPPORTED_FILTERS;
616 *total_flags &= SUPPORTED_FILTERS;
618 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
619 if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
626 static void ath9k_sta_notify(struct ieee80211_hw *hw,
627 struct ieee80211_vif *vif,
628 enum sta_notify_cmd cmd,
631 struct ath_softc *sc = hw->priv;
634 DECLARE_MAC_BUF(mac);
636 spin_lock_irqsave(&sc->node_lock, flags);
637 an = ath_node_find(sc, (u8 *) addr);
638 spin_unlock_irqrestore(&sc->node_lock, flags);
642 spin_lock_irqsave(&sc->node_lock, flags);
644 ath_node_attach(sc, (u8 *)addr, 0);
645 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Attach a node: %s\n",
647 print_mac(mac, addr));
649 ath_node_get(sc, (u8 *)addr);
651 spin_unlock_irqrestore(&sc->node_lock, flags);
653 case STA_NOTIFY_REMOVE:
655 DPRINTF(sc, ATH_DBG_FATAL,
656 "%s: Removal of a non-existent node\n",
659 ath_node_put(sc, an, ATH9K_BH_STATUS_INTACT);
660 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Put a node: %s\n",
662 print_mac(mac, addr));
670 static int ath9k_conf_tx(struct ieee80211_hw *hw,
672 const struct ieee80211_tx_queue_params *params)
674 struct ath_softc *sc = hw->priv;
675 struct hal_txq_info qi;
678 if (queue >= WME_NUM_AC)
681 qi.tqi_aifs = params->aifs;
682 qi.tqi_cwmin = params->cw_min;
683 qi.tqi_cwmax = params->cw_max;
684 qi.tqi_burstTime = params->txop;
685 qnum = ath_get_hal_qnum(queue, sc);
687 DPRINTF(sc, ATH_DBG_CONFIG,
688 "%s: Configure tx [queue/halq] [%d/%d], "
689 "aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
698 ret = ath_txq_update(sc, qnum, &qi);
700 DPRINTF(sc, ATH_DBG_FATAL,
701 "%s: TXQ Update failed\n", __func__);
706 static int ath9k_set_key(struct ieee80211_hw *hw,
707 enum set_key_cmd cmd,
708 const u8 *local_addr,
710 struct ieee80211_key_conf *key)
712 struct ath_softc *sc = hw->priv;
715 DPRINTF(sc, ATH_DBG_KEYCACHE, " %s: Set HW Key\n", __func__);
719 ret = ath_key_config(sc, addr, key);
721 set_bit(key->keyidx, sc->sc_keymap);
722 key->hw_key_idx = key->keyidx;
723 /* push IV and Michael MIC generation to stack */
724 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
725 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
729 ath_key_delete(sc, key);
730 clear_bit(key->keyidx, sc->sc_keymap);
731 sc->sc_keytype = HAL_CIPHER_CLR;
740 static void ath9k_ht_conf(struct ath_softc *sc,
741 struct ieee80211_bss_conf *bss_conf)
743 #define IEEE80211_HT_CAP_40MHZ_INTOLERANT BIT(14)
744 struct ath_ht_info *ht_info = &sc->sc_ht_info;
746 if (bss_conf->assoc_ht) {
747 ht_info->ext_chan_offset =
748 bss_conf->ht_bss_conf->bss_cap &
749 IEEE80211_HT_IE_CHA_SEC_OFFSET;
751 if (!(bss_conf->ht_conf->cap &
752 IEEE80211_HT_CAP_40MHZ_INTOLERANT) &&
753 (bss_conf->ht_bss_conf->bss_cap &
754 IEEE80211_HT_IE_CHA_WIDTH))
755 ht_info->tx_chan_width = HAL_HT_MACMODE_2040;
757 ht_info->tx_chan_width = HAL_HT_MACMODE_20;
759 ath9k_hw_set11nmac2040(sc->sc_ah, ht_info->tx_chan_width);
760 ht_info->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR +
761 bss_conf->ht_conf->ampdu_factor);
762 ht_info->mpdudensity =
763 parse_mpdudensity(bss_conf->ht_conf->ampdu_density);
767 #undef IEEE80211_HT_CAP_40MHZ_INTOLERANT
770 static void ath9k_bss_assoc_info(struct ath_softc *sc,
771 struct ieee80211_bss_conf *bss_conf)
773 struct ieee80211_hw *hw = sc->hw;
774 struct ieee80211_channel *curchan = hw->conf.channel;
775 struct hal_channel hchan;
777 DECLARE_MAC_BUF(mac);
779 if (bss_conf->assoc) {
780 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Bss Info ASSOC %d\n",
784 avp = sc->sc_vaps[0];
786 DPRINTF(sc, ATH_DBG_FATAL, "%s: Invalid interface\n",
791 /* Update ratectrl about the new state */
792 ath_rate_newstate(sc, avp, 1);
794 /* New association, store aid */
795 if (avp->av_opmode == HAL_M_STA) {
796 sc->sc_curaid = bss_conf->aid;
797 ath9k_hw_write_associd(sc->sc_ah, sc->sc_curbssid,
801 /* Configure the beacon */
802 ath_beacon_config(sc, 0);
805 /* Reset rssi stats */
806 sc->sc_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER;
807 sc->sc_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER;
808 sc->sc_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER;
809 sc->sc_halstats.ns_avgtxrate = ATH_RATE_DUMMY_MARKER;
811 /* Update chainmask */
812 ath_update_chainmask(sc, bss_conf->assoc_ht);
814 DPRINTF(sc, ATH_DBG_CONFIG,
815 "%s: bssid %s aid 0x%x\n",
817 print_mac(mac, sc->sc_curbssid), sc->sc_curaid);
819 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Set channel: %d MHz\n",
821 curchan->center_freq);
823 hchan.channel = curchan->center_freq;
824 hchan.channelFlags = ath_chan2flags(curchan, sc);
826 /* set h/w channel */
827 if (ath_set_channel(sc, &hchan) < 0)
828 DPRINTF(sc, ATH_DBG_FATAL,
829 "%s: Unable to set channel\n",
832 DPRINTF(sc, ATH_DBG_CONFIG,
833 "%s: Bss Info DISSOC\n", __func__);
838 static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
839 struct ieee80211_vif *vif,
840 struct ieee80211_bss_conf *bss_conf,
843 struct ath_softc *sc = hw->priv;
845 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
846 DPRINTF(sc, ATH_DBG_CONFIG, "%s: BSS Changed PREAMBLE %d\n",
848 bss_conf->use_short_preamble);
849 if (bss_conf->use_short_preamble)
850 sc->sc_flags |= ATH_PREAMBLE_SHORT;
852 sc->sc_flags &= ~ATH_PREAMBLE_SHORT;
855 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
856 DPRINTF(sc, ATH_DBG_CONFIG, "%s: BSS Changed CTS PROT %d\n",
858 bss_conf->use_cts_prot);
859 if (bss_conf->use_cts_prot &&
860 hw->conf.channel->band != IEEE80211_BAND_5GHZ)
861 sc->sc_flags |= ATH_PROTECT_ENABLE;
863 sc->sc_flags &= ~ATH_PROTECT_ENABLE;
866 if (changed & BSS_CHANGED_HT) {
867 DPRINTF(sc, ATH_DBG_CONFIG, "%s: BSS Changed HT %d\n",
870 ath9k_ht_conf(sc, bss_conf);
873 if (changed & BSS_CHANGED_ASSOC) {
874 DPRINTF(sc, ATH_DBG_CONFIG, "%s: BSS Changed ASSOC %d\n",
877 ath9k_bss_assoc_info(sc, bss_conf);
881 static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
884 struct ath_softc *sc = hw->priv;
885 struct ath_hal *ah = sc->sc_ah;
887 tsf = ath9k_hw_gettsf64(ah);
892 static void ath9k_reset_tsf(struct ieee80211_hw *hw)
894 struct ath_softc *sc = hw->priv;
895 struct ath_hal *ah = sc->sc_ah;
897 ath9k_hw_reset_tsf(ah);
900 static int ath9k_ampdu_action(struct ieee80211_hw *hw,
901 enum ieee80211_ampdu_mlme_action action,
906 struct ath_softc *sc = hw->priv;
910 case IEEE80211_AMPDU_RX_START:
911 ret = ath_rx_aggr_start(sc, addr, tid, ssn);
913 DPRINTF(sc, ATH_DBG_FATAL,
914 "%s: Unable to start RX aggregation\n",
917 case IEEE80211_AMPDU_RX_STOP:
918 ret = ath_rx_aggr_stop(sc, addr, tid);
920 DPRINTF(sc, ATH_DBG_FATAL,
921 "%s: Unable to stop RX aggregation\n",
924 case IEEE80211_AMPDU_TX_START:
925 ret = ath_tx_aggr_start(sc, addr, tid, ssn);
927 DPRINTF(sc, ATH_DBG_FATAL,
928 "%s: Unable to start TX aggregation\n",
931 ieee80211_start_tx_ba_cb_irqsafe(hw, (u8 *)addr, tid);
933 case IEEE80211_AMPDU_TX_STOP:
934 ret = ath_tx_aggr_stop(sc, addr, tid);
936 DPRINTF(sc, ATH_DBG_FATAL,
937 "%s: Unable to stop TX aggregation\n",
940 ieee80211_stop_tx_ba_cb_irqsafe(hw, (u8 *)addr, tid);
943 DPRINTF(sc, ATH_DBG_FATAL,
944 "%s: Unknown AMPDU action\n", __func__);
950 static struct ieee80211_ops ath9k_ops = {
952 .start = ath9k_start,
954 .add_interface = ath9k_add_interface,
955 .remove_interface = ath9k_remove_interface,
956 .config = ath9k_config,
957 .config_interface = ath9k_config_interface,
958 .configure_filter = ath9k_configure_filter,
960 .sta_notify = ath9k_sta_notify,
961 .conf_tx = ath9k_conf_tx,
962 .get_tx_stats = NULL,
963 .bss_info_changed = ath9k_bss_info_changed,
965 .set_key = ath9k_set_key,
967 .get_tkip_seq = NULL,
968 .set_rts_threshold = NULL,
969 .set_frag_threshold = NULL,
970 .set_retry_limit = NULL,
971 .get_tsf = ath9k_get_tsf,
972 .reset_tsf = ath9k_reset_tsf,
973 .tx_last_beacon = NULL,
974 .ampdu_action = ath9k_ampdu_action
977 u_int32_t ath_chan2flags(struct ieee80211_channel *chan,
978 struct ath_softc *sc)
980 struct ieee80211_hw *hw = sc->hw;
981 struct ath_ht_info *ht_info = &sc->sc_ht_info;
983 if (sc->sc_scanning) {
984 if (chan->band == IEEE80211_BAND_5GHZ) {
985 if (ath_check_chanflags(chan, CHANNEL_A_HT20, sc))
986 return CHANNEL_A_HT20;
990 if (ath_check_chanflags(chan, CHANNEL_G_HT20, sc))
991 return CHANNEL_G_HT20;
992 else if (ath_check_chanflags(chan, CHANNEL_G, sc))
998 if (chan->band == IEEE80211_BAND_2GHZ) {
999 if (!hw->conf.ht_conf.ht_supported) {
1000 if (ath_check_chanflags(chan, CHANNEL_G, sc))
1005 if ((ht_info->ext_chan_offset ==
1006 IEEE80211_HT_IE_CHA_SEC_NONE) &&
1007 (ht_info->tx_chan_width == HAL_HT_MACMODE_20))
1008 return CHANNEL_G_HT20;
1009 if ((ht_info->ext_chan_offset ==
1010 IEEE80211_HT_IE_CHA_SEC_ABOVE) &&
1011 (ht_info->tx_chan_width == HAL_HT_MACMODE_2040))
1012 return CHANNEL_G_HT40PLUS;
1013 if ((ht_info->ext_chan_offset ==
1014 IEEE80211_HT_IE_CHA_SEC_BELOW) &&
1015 (ht_info->tx_chan_width == HAL_HT_MACMODE_2040))
1016 return CHANNEL_G_HT40MINUS;
1019 if (!hw->conf.ht_conf.ht_supported)
1021 if ((ht_info->ext_chan_offset ==
1022 IEEE80211_HT_IE_CHA_SEC_NONE) &&
1023 (ht_info->tx_chan_width == HAL_HT_MACMODE_20))
1024 return CHANNEL_A_HT20;
1025 if ((ht_info->ext_chan_offset ==
1026 IEEE80211_HT_IE_CHA_SEC_ABOVE) &&
1027 (ht_info->tx_chan_width == HAL_HT_MACMODE_2040))
1028 return CHANNEL_A_HT40PLUS;
1029 if ((ht_info->ext_chan_offset ==
1030 IEEE80211_HT_IE_CHA_SEC_BELOW) &&
1031 (ht_info->tx_chan_width == HAL_HT_MACMODE_2040))
1032 return CHANNEL_A_HT40MINUS;
1038 void ath_setup_channel_list(struct ath_softc *sc,
1039 enum ieee80211_clist_cmd cmd,
1040 const struct hal_channel *chans,
1042 const u_int8_t *regclassids,
1046 const struct hal_channel *c;
1047 int i, a = 0, b = 0, flags;
1049 if (countrycode == CTRY_DEFAULT) {
1050 for (i = 0; i < nchan; i++) {
1053 /* XXX: Ah! make more readable, and
1054 * idententation friendly */
1055 if (IS_CHAN_2GHZ(c) &&
1056 !test_update_chan(IEEE80211_BAND_2GHZ, c, sc)) {
1057 sc->channels[IEEE80211_BAND_2GHZ][a].band =
1058 IEEE80211_BAND_2GHZ;
1059 sc->channels[IEEE80211_BAND_2GHZ][a].
1062 sc->channels[IEEE80211_BAND_2GHZ][a].max_power =
1064 sc->channels[IEEE80211_BAND_2GHZ][a].hw_value =
1067 if (c->privFlags & CHANNEL_DISALLOW_ADHOC)
1068 flags |= IEEE80211_CHAN_NO_IBSS;
1069 if (IS_CHAN_PASSIVE(c))
1070 flags |= IEEE80211_CHAN_PASSIVE_SCAN;
1072 sc->channels[IEEE80211_BAND_2GHZ][a].flags =
1074 sc->sbands[IEEE80211_BAND_2GHZ].n_channels++;
1076 DPRINTF(sc, ATH_DBG_CONFIG,
1077 "%s: 2MHz channel: %d, "
1078 "channelFlags: 0x%x\n",
1082 } else if (IS_CHAN_5GHZ(c) &&
1083 !test_update_chan(IEEE80211_BAND_5GHZ, c, sc)) {
1084 sc->channels[IEEE80211_BAND_5GHZ][b].band =
1085 IEEE80211_BAND_5GHZ;
1086 sc->channels[IEEE80211_BAND_5GHZ][b].
1089 sc->channels[IEEE80211_BAND_5GHZ][b].max_power =
1091 sc->channels[IEEE80211_BAND_5GHZ][b].hw_value =
1094 if (c->privFlags & CHANNEL_DISALLOW_ADHOC)
1095 flags |= IEEE80211_CHAN_NO_IBSS;
1096 if (IS_CHAN_PASSIVE(c))
1097 flags |= IEEE80211_CHAN_PASSIVE_SCAN;
1099 sc->channels[IEEE80211_BAND_5GHZ][b].
1101 sc->sbands[IEEE80211_BAND_5GHZ].n_channels++;
1103 DPRINTF(sc, ATH_DBG_CONFIG,
1104 "%s: 5MHz channel: %d, "
1105 "channelFlags: 0x%x\n",
1114 void ath_get_beaconconfig(struct ath_softc *sc,
1116 struct ath_beacon_config *conf)
1118 struct ieee80211_hw *hw = sc->hw;
1120 /* fill in beacon config data */
1122 conf->beacon_interval = hw->conf.beacon_int;
1123 conf->listen_interval = 100;
1124 conf->dtim_count = 1;
1125 conf->bmiss_timeout = ATH_DEFAULT_BMISS_LIMIT * conf->listen_interval;
1128 int ath_update_beacon(struct ath_softc *sc,
1130 struct ath_beacon_offset *bo,
1131 struct sk_buff *skb,
1137 void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
1138 struct ath_xmit_status *tx_status, struct ath_node *an)
1140 struct ieee80211_hw *hw = sc->hw;
1141 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1143 DPRINTF(sc, ATH_DBG_XMIT,
1144 "%s: TX complete: skb: %p\n", __func__, skb);
1146 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK ||
1147 tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
1148 /* free driver's private data area of tx_info */
1149 if (tx_info->driver_data[0] != NULL)
1150 kfree(tx_info->driver_data[0]);
1151 tx_info->driver_data[0] = NULL;
1154 if (tx_status->flags & ATH_TX_BAR) {
1155 tx_info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
1156 tx_status->flags &= ~ATH_TX_BAR;
1158 if (tx_status->flags)
1159 tx_info->status.excessive_retries = 1;
1161 tx_info->status.retry_count = tx_status->retries;
1163 ieee80211_tx_status(hw, skb);
1165 ath_node_put(sc, an, ATH9K_BH_STATUS_CHANGE);
1168 int ath__rx_indicate(struct ath_softc *sc,
1169 struct sk_buff *skb,
1170 struct ath_recv_status *status,
1173 struct ieee80211_hw *hw = sc->hw;
1174 struct ath_node *an = NULL;
1175 struct ieee80211_rx_status rx_status;
1176 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1177 int hdrlen = ieee80211_get_hdrlen_from_skb(skb);
1179 enum ATH_RX_TYPE st;
1181 /* see if any padding is done by the hw and remove it */
1183 padsize = hdrlen % 4;
1184 memmove(skb->data + padsize, skb->data, hdrlen);
1185 skb_pull(skb, padsize);
1188 /* remove FCS before passing up to protocol stack */
1189 skb_trim(skb, (skb->len - FCS_LEN));
1191 /* Prepare rx status */
1192 ath9k_rx_prepare(sc, skb, status, &rx_status);
1194 if (!(keyix == HAL_RXKEYIX_INVALID) &&
1195 !(status->flags & ATH_RX_DECRYPT_ERROR)) {
1196 rx_status.flag |= RX_FLAG_DECRYPTED;
1197 } else if ((le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_PROTECTED)
1198 && !(status->flags & ATH_RX_DECRYPT_ERROR)
1199 && skb->len >= hdrlen + 4) {
1200 keyix = skb->data[hdrlen + 3] >> 6;
1202 if (test_bit(keyix, sc->sc_keymap))
1203 rx_status.flag |= RX_FLAG_DECRYPTED;
1206 spin_lock_bh(&sc->node_lock);
1207 an = ath_node_find(sc, hdr->addr2);
1208 spin_unlock_bh(&sc->node_lock);
1211 ath_rx_input(sc, an,
1212 hw->conf.ht_conf.ht_supported,
1215 if (!an || (st != ATH_RX_CONSUMED))
1216 __ieee80211_rx(hw, skb, &rx_status);
1221 int ath_rx_subframe(struct ath_node *an,
1222 struct sk_buff *skb,
1223 struct ath_recv_status *status)
1225 struct ath_softc *sc = an->an_sc;
1226 struct ieee80211_hw *hw = sc->hw;
1227 struct ieee80211_rx_status rx_status;
1229 /* Prepare rx status */
1230 ath9k_rx_prepare(sc, skb, status, &rx_status);
1231 if (!(status->flags & ATH_RX_DECRYPT_ERROR))
1232 rx_status.flag |= RX_FLAG_DECRYPTED;
1234 __ieee80211_rx(hw, skb, &rx_status);
1239 enum hal_ht_macmode ath_cwm_macmode(struct ath_softc *sc)
1241 return sc->sc_ht_info.tx_chan_width;
1244 void ath_setup_rate(struct ath_softc *sc,
1245 enum wireless_mode wMode,
1246 enum RATE_TYPE type,
1247 const struct hal_rate_table *rt)
1249 int i, maxrates, a = 0, b = 0;
1250 struct ieee80211_supported_band *band_2ghz;
1251 struct ieee80211_supported_band *band_5ghz;
1252 struct ieee80211_rate *rates_2ghz;
1253 struct ieee80211_rate *rates_5ghz;
1255 if ((wMode >= WIRELESS_MODE_MAX) || (type != NORMAL_RATE))
1258 band_2ghz = &sc->sbands[IEEE80211_BAND_2GHZ];
1259 band_5ghz = &sc->sbands[IEEE80211_BAND_5GHZ];
1260 rates_2ghz = sc->rates[IEEE80211_BAND_2GHZ];
1261 rates_5ghz = sc->rates[IEEE80211_BAND_5GHZ];
1263 if (rt->rateCount > ATH_RATE_MAX)
1264 maxrates = ATH_RATE_MAX;
1266 maxrates = rt->rateCount;
1268 if ((band_2ghz->n_bitrates != 0) && (band_5ghz->n_bitrates != 0)) {
1269 DPRINTF(sc, ATH_DBG_CONFIG,
1270 "%s: Rates already setup\n", __func__);
1274 for (i = 0; i < maxrates; i++) {
1276 case WIRELESS_MODE_11b:
1277 case WIRELESS_MODE_11g:
1278 rates_2ghz[a].bitrate = rt->info[i].rateKbps / 100;
1279 rates_2ghz[a].hw_value = rt->info[i].rateCode;
1281 band_2ghz->n_bitrates = a;
1283 case WIRELESS_MODE_11a:
1284 rates_5ghz[b].bitrate = rt->info[i].rateKbps / 100;
1285 rates_5ghz[b].hw_value = rt->info[i].rateCode;
1287 band_5ghz->n_bitrates = b;
1294 if (band_2ghz->n_bitrates) {
1295 for (i = 0; i < band_2ghz->n_bitrates; i++) {
1296 DPRINTF(sc, ATH_DBG_CONFIG,
1297 "%s: 2GHz Rate: %2dMbps, ratecode: %2d\n",
1299 rates_2ghz[i].bitrate / 10,
1300 rates_2ghz[i].hw_value);
1302 } else if (band_5ghz->n_bitrates) {
1303 for (i = 0; i < band_5ghz->n_bitrates; i++) {
1304 DPRINTF(sc, ATH_DBG_CONFIG,
1305 "%s: 5Ghz Rate: %2dMbps, ratecode: %2d\n",
1307 rates_5ghz[i].bitrate / 10,
1308 rates_5ghz[i].hw_value);
1313 static int ath_detach(struct ath_softc *sc)
1315 struct ieee80211_hw *hw = sc->hw;
1317 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Detach ATH hw\n", __func__);
1321 ieee80211_unregister_hw(hw);
1323 /* unregister Rate control */
1324 ath_rate_control_unregister();
1338 static int ath_attach(u_int16_t devid,
1339 struct ath_softc *sc)
1341 struct ieee80211_hw *hw = sc->hw;
1344 DPRINTF(sc, ATH_DBG_CONFIG, "%s: Attach ATH hw\n", __func__);
1346 error = ath_init(devid, sc);
1352 INIT_LIST_HEAD(&sc->node_list);
1353 spin_lock_init(&sc->node_lock);
1355 /* get mac address from hardware and set in mac80211 */
1357 SET_IEEE80211_PERM_ADDR(hw, sc->sc_myaddr);
1359 /* setup channels and rates */
1361 sc->sbands[IEEE80211_BAND_2GHZ].channels =
1362 sc->channels[IEEE80211_BAND_2GHZ];
1363 sc->sbands[IEEE80211_BAND_2GHZ].bitrates =
1364 sc->rates[IEEE80211_BAND_2GHZ];
1365 sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
1367 if (sc->sc_ah->ah_caps.halHTSupport)
1368 /* Setup HT capabilities for 2.4Ghz*/
1369 setup_ht_cap(&sc->sbands[IEEE80211_BAND_2GHZ].ht_info);
1371 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
1372 &sc->sbands[IEEE80211_BAND_2GHZ];
1374 if (sc->sc_ah->ah_caps.halWirelessModes & ATH9K_MODE_SEL_11A) {
1375 sc->sbands[IEEE80211_BAND_5GHZ].channels =
1376 sc->channels[IEEE80211_BAND_5GHZ];
1377 sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
1378 sc->rates[IEEE80211_BAND_5GHZ];
1379 sc->sbands[IEEE80211_BAND_5GHZ].band =
1380 IEEE80211_BAND_5GHZ;
1382 if (sc->sc_ah->ah_caps.halHTSupport)
1383 /* Setup HT capabilities for 5Ghz*/
1384 setup_ht_cap(&sc->sbands[IEEE80211_BAND_5GHZ].ht_info);
1386 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
1387 &sc->sbands[IEEE80211_BAND_5GHZ];
1390 /* FIXME: Have to figure out proper hw init values later */
1393 hw->ampdu_queues = 1;
1395 /* Register rate control */
1396 hw->rate_control_algorithm = "ath9k_rate_control";
1397 error = ath_rate_control_register();
1399 DPRINTF(sc, ATH_DBG_FATAL,
1400 "%s: Unable to register rate control "
1401 "algorithm:%d\n", __func__, error);
1402 ath_rate_control_unregister();
1406 error = ieee80211_register_hw(hw);
1408 ath_rate_control_unregister();
1412 /* initialize tx/rx engine */
1414 error = ath_tx_init(sc, ATH_TXBUF);
1418 error = ath_rx_init(sc, ATH_RXBUF);
1429 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1432 struct ath_softc *sc;
1433 struct ieee80211_hw *hw;
1434 const char *athname;
1439 if (pci_enable_device(pdev))
1442 /* XXX 32-bit addressing only */
1443 if (pci_set_dma_mask(pdev, 0xffffffff)) {
1444 printk(KERN_ERR "ath_pci: 32-bit DMA not available\n");
1450 * Cache line size is used to size and align various
1451 * structures used to communicate with the hardware.
1453 pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &csz);
1456 * Linux 2.4.18 (at least) writes the cache line size
1457 * register as a 16-bit wide register which is wrong.
1458 * We must have this setup properly for rx buffer
1459 * DMA to work so force a reasonable value here if it
1462 csz = L1_CACHE_BYTES / sizeof(u_int32_t);
1463 pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, csz);
1466 * The default setting of latency timer yields poor results,
1467 * set it to the value used by other systems. It may be worth
1468 * tweaking this setting more.
1470 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xa8);
1472 pci_set_master(pdev);
1475 * Disable the RETRY_TIMEOUT register (0x41) to keep
1476 * PCI Tx retries from interfering with C3 CPU state.
1478 pci_read_config_dword(pdev, 0x40, &val);
1479 if ((val & 0x0000ff00) != 0)
1480 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
1482 ret = pci_request_region(pdev, 0, "ath9k");
1484 dev_err(&pdev->dev, "PCI memory region reserve error\n");
1489 mem = pci_iomap(pdev, 0, 0);
1491 printk(KERN_ERR "PCI memory map error\n") ;
1496 hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
1498 printk(KERN_ERR "ath_pci: no memory for ieee80211_hw\n");
1502 SET_IEEE80211_DEV(hw, &pdev->dev);
1503 pci_set_drvdata(pdev, hw);
1510 if (ath_attach(id->device, sc) != 0) {
1515 /* setup interrupt service routine */
1517 if (request_irq(pdev->irq, ath_isr, IRQF_SHARED, "ath", sc)) {
1518 printk(KERN_ERR "%s: request_irq failed\n",
1519 wiphy_name(hw->wiphy));
1524 athname = ath9k_hw_probe(id->vendor, id->device);
1526 printk(KERN_INFO "%s: %s: mem=0x%lx, irq=%d\n",
1527 wiphy_name(hw->wiphy),
1528 athname ? athname : "Atheros ???",
1529 (unsigned long)mem, pdev->irq);
1535 ieee80211_free_hw(hw);
1537 pci_iounmap(pdev, mem);
1539 pci_release_region(pdev, 0);
1541 pci_disable_device(pdev);
1545 static void ath_pci_remove(struct pci_dev *pdev)
1547 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
1548 struct ath_softc *sc = hw->priv;
1551 free_irq(pdev->irq, sc);
1553 pci_iounmap(pdev, sc->mem);
1554 pci_release_region(pdev, 0);
1555 pci_disable_device(pdev);
1556 ieee80211_free_hw(hw);
1561 static int ath_pci_suspend(struct pci_dev *pdev, pm_message_t state)
1563 pci_save_state(pdev);
1564 pci_disable_device(pdev);
1565 pci_set_power_state(pdev, 3);
1570 static int ath_pci_resume(struct pci_dev *pdev)
1575 err = pci_enable_device(pdev);
1578 pci_restore_state(pdev);
1580 * Suspend/Resume resets the PCI configuration space, so we have to
1581 * re-disable the RETRY_TIMEOUT register (0x41) to keep
1582 * PCI Tx retries from interfering with C3 CPU state
1584 pci_read_config_dword(pdev, 0x40, &val);
1585 if ((val & 0x0000ff00) != 0)
1586 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
1591 #endif /* CONFIG_PM */
1593 MODULE_DEVICE_TABLE(pci, ath_pci_id_table);
1595 static struct pci_driver ath_pci_driver = {
1597 .id_table = ath_pci_id_table,
1598 .probe = ath_pci_probe,
1599 .remove = ath_pci_remove,
1601 .suspend = ath_pci_suspend,
1602 .resume = ath_pci_resume,
1603 #endif /* CONFIG_PM */
1606 static int __init init_ath_pci(void)
1608 printk(KERN_INFO "%s: %s\n", dev_info, ATH_PCI_VERSION);
1610 if (pci_register_driver(&ath_pci_driver) < 0) {
1612 "ath_pci: No devices found, driver not installed.\n");
1613 pci_unregister_driver(&ath_pci_driver);
1619 module_init(init_ath_pci);
1621 static void __exit exit_ath_pci(void)
1623 pci_unregister_driver(&ath_pci_driver);
1624 printk(KERN_INFO "%s: driver unloaded\n", dev_info);
1626 module_exit(exit_ath_pci);