2 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
3 * Copyright (c) 2004-2005 Atheros Communications, Inc.
4 * Copyright (c) 2006 Devicescape Software, Inc.
5 * Copyright (c) 2007 Jiri Slaby <jirislaby@gmail.com>
6 * Copyright (c) 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
7 * Copyright (c) 2010 Bruno Randolf <br1@einfach.org>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
19 * redistribution must be conditioned upon including a substantially
20 * similar Disclaimer requirement for further binary redistribution.
21 * 3. Neither the names of the above-listed copyright holders nor the names
22 * of any contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * Alternatively, this software may be distributed under the terms of the
26 * GNU General Public License ("GPL") version 2 as published by the Free
27 * Software Foundation.
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
33 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
34 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
35 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
38 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
40 * THE POSSIBILITY OF SUCH DAMAGES.
44 #include <asm/unaligned.h>
49 /********************\
50 * Mac80211 functions *
51 \********************/
54 ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
56 struct ath5k_softc *sc = hw->priv;
57 u16 qnum = skb_get_queue_mapping(skb);
59 if (WARN_ON(qnum >= sc->ah->ah_capabilities.cap_queues.q_tx_num)) {
60 dev_kfree_skb_any(skb);
64 ath5k_tx_queue(hw, skb, &sc->txqs[qnum]);
69 ath5k_start(struct ieee80211_hw *hw)
71 return ath5k_init_hw(hw->priv);
76 ath5k_stop(struct ieee80211_hw *hw)
78 ath5k_stop_hw(hw->priv);
83 ath5k_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
85 struct ath5k_softc *sc = hw->priv;
87 struct ath5k_vif *avf = (void *)vif->drv_priv;
89 mutex_lock(&sc->lock);
91 if ((vif->type == NL80211_IFTYPE_AP ||
92 vif->type == NL80211_IFTYPE_ADHOC)
93 && (sc->num_ap_vifs + sc->num_adhoc_vifs) >= ATH_BCBUF) {
98 /* Don't allow other interfaces if one ad-hoc is configured.
99 * TODO: Fix the problems with ad-hoc and multiple other interfaces.
100 * We would need to operate the HW in ad-hoc mode to allow TSF updates
101 * for the IBSS, but this breaks with additional AP or STA interfaces
103 if (sc->num_adhoc_vifs ||
104 (sc->nvifs && vif->type == NL80211_IFTYPE_ADHOC)) {
105 ATH5K_ERR(sc, "Only one single ad-hoc interface is allowed.\n");
111 case NL80211_IFTYPE_AP:
112 case NL80211_IFTYPE_STATION:
113 case NL80211_IFTYPE_ADHOC:
114 case NL80211_IFTYPE_MESH_POINT:
115 avf->opmode = vif->type;
123 ATH5K_DBG(sc, ATH5K_DEBUG_MODE, "add interface mode %d\n", avf->opmode);
125 /* Assign the vap/adhoc to a beacon xmit slot. */
126 if ((avf->opmode == NL80211_IFTYPE_AP) ||
127 (avf->opmode == NL80211_IFTYPE_ADHOC) ||
128 (avf->opmode == NL80211_IFTYPE_MESH_POINT)) {
131 WARN_ON(list_empty(&sc->bcbuf));
132 avf->bbuf = list_first_entry(&sc->bcbuf, struct ath5k_buf,
134 list_del(&avf->bbuf->list);
137 for (slot = 0; slot < ATH_BCBUF; slot++) {
138 if (!sc->bslot[slot]) {
143 BUG_ON(sc->bslot[avf->bslot] != NULL);
144 sc->bslot[avf->bslot] = vif;
145 if (avf->opmode == NL80211_IFTYPE_AP)
147 else if (avf->opmode == NL80211_IFTYPE_ADHOC)
148 sc->num_adhoc_vifs++;
151 /* Any MAC address is fine, all others are included through the
154 memcpy(&sc->lladdr, vif->addr, ETH_ALEN);
155 ath5k_hw_set_lladdr(sc->ah, vif->addr);
157 memcpy(&avf->lladdr, vif->addr, ETH_ALEN);
159 ath5k_update_bssid_mask_and_opmode(sc, vif);
162 mutex_unlock(&sc->lock);
168 ath5k_remove_interface(struct ieee80211_hw *hw,
169 struct ieee80211_vif *vif)
171 struct ath5k_softc *sc = hw->priv;
172 struct ath5k_vif *avf = (void *)vif->drv_priv;
175 mutex_lock(&sc->lock);
179 ath5k_txbuf_free_skb(sc, avf->bbuf);
180 list_add_tail(&avf->bbuf->list, &sc->bcbuf);
181 for (i = 0; i < ATH_BCBUF; i++) {
182 if (sc->bslot[i] == vif) {
189 if (avf->opmode == NL80211_IFTYPE_AP)
191 else if (avf->opmode == NL80211_IFTYPE_ADHOC)
192 sc->num_adhoc_vifs--;
194 ath5k_update_bssid_mask_and_opmode(sc, NULL);
195 mutex_unlock(&sc->lock);
200 * TODO: Phy disable/diversity etc
203 ath5k_config(struct ieee80211_hw *hw, u32 changed)
205 struct ath5k_softc *sc = hw->priv;
206 struct ath5k_hw *ah = sc->ah;
207 struct ieee80211_conf *conf = &hw->conf;
211 mutex_lock(&sc->lock);
213 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
214 ret = ath5k_chan_set(sc, conf->channel);
219 if ((changed & IEEE80211_CONF_CHANGE_POWER) &&
220 (sc->power_level != conf->power_level)) {
221 sc->power_level = conf->power_level;
224 ath5k_hw_set_txpower_limit(ah, (conf->power_level * 2));
227 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) {
228 ah->ah_retry_long = conf->long_frame_max_tx_count;
229 ah->ah_retry_short = conf->short_frame_max_tx_count;
231 for (i = 0; i < ah->ah_capabilities.cap_queues.q_tx_num; i++)
232 ath5k_hw_set_tx_retry_limits(ah, i);
236 * 1) Move this on config_interface and handle each case
237 * separately eg. when we have only one STA vif, use
238 * AR5K_ANTMODE_SINGLE_AP
240 * 2) Allow the user to change antenna mode eg. when only
241 * one antenna is present
243 * 3) Allow the user to set default/tx antenna when possible
245 * 4) Default mode should handle 90% of the cases, together
246 * with fixed a/b and single AP modes we should be able to
247 * handle 99%. Sectored modes are extreme cases and i still
248 * haven't found a usage for them. If we decide to support them,
249 * then we must allow the user to set how many tx antennas we
252 ath5k_hw_set_antenna_mode(ah, ah->ah_ant_mode);
255 mutex_unlock(&sc->lock);
261 ath5k_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
262 struct ieee80211_bss_conf *bss_conf, u32 changes)
264 struct ath5k_vif *avf = (void *)vif->drv_priv;
265 struct ath5k_softc *sc = hw->priv;
266 struct ath5k_hw *ah = sc->ah;
267 struct ath_common *common = ath5k_hw_common(ah);
270 mutex_lock(&sc->lock);
272 if (changes & BSS_CHANGED_BSSID) {
273 /* Cache for later use during resets */
274 memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
276 ath5k_hw_set_bssid(ah);
280 if (changes & BSS_CHANGED_BEACON_INT)
281 sc->bintval = bss_conf->beacon_int;
283 if (changes & BSS_CHANGED_ERP_SLOT) {
286 ah->ah_short_slot = bss_conf->use_short_slot;
287 slot_time = ath5k_hw_get_default_slottime(ah) +
288 3 * ah->ah_coverage_class;
289 ath5k_hw_set_ifs_intervals(ah, slot_time);
292 if (changes & BSS_CHANGED_ASSOC) {
293 avf->assoc = bss_conf->assoc;
295 sc->assoc = bss_conf->assoc;
297 sc->assoc = ath5k_any_vif_assoc(sc);
299 if (sc->opmode == NL80211_IFTYPE_STATION)
300 ath5k_set_beacon_filter(hw, sc->assoc);
301 ath5k_hw_set_ledstate(sc->ah, sc->assoc ?
302 AR5K_LED_ASSOC : AR5K_LED_INIT);
303 if (bss_conf->assoc) {
304 ATH5K_DBG(sc, ATH5K_DEBUG_ANY,
305 "Bss Info ASSOC %d, bssid: %pM\n",
306 bss_conf->aid, common->curbssid);
307 common->curaid = bss_conf->aid;
308 ath5k_hw_set_bssid(ah);
309 /* Once ANI is available you would start it here */
313 if (changes & BSS_CHANGED_BEACON) {
314 spin_lock_irqsave(&sc->block, flags);
315 ath5k_beacon_update(hw, vif);
316 spin_unlock_irqrestore(&sc->block, flags);
319 if (changes & BSS_CHANGED_BEACON_ENABLED)
320 sc->enable_beacon = bss_conf->enable_beacon;
322 if (changes & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_ENABLED |
323 BSS_CHANGED_BEACON_INT))
324 ath5k_beacon_config(sc);
326 mutex_unlock(&sc->lock);
331 ath5k_prepare_multicast(struct ieee80211_hw *hw,
332 struct netdev_hw_addr_list *mc_list)
336 struct netdev_hw_addr *ha;
341 netdev_hw_addr_list_for_each(ha, mc_list) {
342 /* calculate XOR of eight 6-bit values */
343 val = get_unaligned_le32(ha->addr + 0);
344 pos = (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val;
345 val = get_unaligned_le32(ha->addr + 3);
346 pos ^= (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val;
348 mfilt[pos / 32] |= (1 << (pos % 32));
349 /* XXX: we might be able to just do this instead,
350 * but not sure, needs testing, if we do use this we'd
351 * need to inform below not to reset the mcast */
352 /* ath5k_hw_set_mcast_filterindex(ah,
356 return ((u64)(mfilt[1]) << 32) | mfilt[0];
361 * o always accept unicast, broadcast, and multicast traffic
362 * o multicast traffic for all BSSIDs will be enabled if mac80211
364 * o maintain current state of phy ofdm or phy cck error reception.
365 * If the hardware detects any of these type of errors then
366 * ath5k_hw_get_rx_filter() will pass to us the respective
367 * hardware filters to be able to receive these type of frames.
368 * o probe request frames are accepted only when operating in
369 * hostap, adhoc, or monitor modes
370 * o enable promiscuous mode according to the interface state
372 * - when operating in adhoc mode so the 802.11 layer creates
373 * node table entries for peers,
374 * - when operating in station mode for collecting rssi data when
375 * the station is otherwise quiet, or
379 ath5k_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
380 unsigned int *new_flags, u64 multicast)
382 #define SUPPORTED_FIF_FLAGS \
383 (FIF_PROMISC_IN_BSS | FIF_ALLMULTI | FIF_FCSFAIL | \
384 FIF_PLCPFAIL | FIF_CONTROL | FIF_OTHER_BSS | \
385 FIF_BCN_PRBRESP_PROMISC)
387 struct ath5k_softc *sc = hw->priv;
388 struct ath5k_hw *ah = sc->ah;
390 struct ath5k_vif_iter_data iter_data; /* to count STA interfaces */
392 mutex_lock(&sc->lock);
394 mfilt[0] = multicast;
395 mfilt[1] = multicast >> 32;
397 /* Only deal with supported flags */
398 changed_flags &= SUPPORTED_FIF_FLAGS;
399 *new_flags &= SUPPORTED_FIF_FLAGS;
401 /* If HW detects any phy or radar errors, leave those filters on.
402 * Also, always enable Unicast, Broadcasts and Multicast
403 * XXX: move unicast, bssid broadcasts and multicast to mac80211 */
404 rfilt = (ath5k_hw_get_rx_filter(ah) & (AR5K_RX_FILTER_PHYERR)) |
405 (AR5K_RX_FILTER_UCAST | AR5K_RX_FILTER_BCAST |
406 AR5K_RX_FILTER_MCAST);
408 if (changed_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) {
409 if (*new_flags & FIF_PROMISC_IN_BSS)
410 __set_bit(ATH_STAT_PROMISC, sc->status);
412 __clear_bit(ATH_STAT_PROMISC, sc->status);
415 if (test_bit(ATH_STAT_PROMISC, sc->status))
416 rfilt |= AR5K_RX_FILTER_PROM;
418 /* Note, AR5K_RX_FILTER_MCAST is already enabled */
419 if (*new_flags & FIF_ALLMULTI) {
424 /* This is the best we can do */
425 if (*new_flags & (FIF_FCSFAIL | FIF_PLCPFAIL))
426 rfilt |= AR5K_RX_FILTER_PHYERR;
428 /* FIF_BCN_PRBRESP_PROMISC really means to enable beacons
429 * and probes for any BSSID */
430 if ((*new_flags & FIF_BCN_PRBRESP_PROMISC) || (sc->nvifs > 1))
431 rfilt |= AR5K_RX_FILTER_BEACON;
433 /* FIF_CONTROL doc says that if FIF_PROMISC_IN_BSS is not
434 * set we should only pass on control frames for this
435 * station. This needs testing. I believe right now this
436 * enables *all* control frames, which is OK.. but
437 * but we should see if we can improve on granularity */
438 if (*new_flags & FIF_CONTROL)
439 rfilt |= AR5K_RX_FILTER_CONTROL;
441 /* Additional settings per mode -- this is per ath5k */
443 /* XXX move these to mac80211, and add a beacon IFF flag to mac80211 */
445 switch (sc->opmode) {
446 case NL80211_IFTYPE_MESH_POINT:
447 rfilt |= AR5K_RX_FILTER_CONTROL |
448 AR5K_RX_FILTER_BEACON |
449 AR5K_RX_FILTER_PROBEREQ |
452 case NL80211_IFTYPE_AP:
453 case NL80211_IFTYPE_ADHOC:
454 rfilt |= AR5K_RX_FILTER_PROBEREQ |
455 AR5K_RX_FILTER_BEACON;
457 case NL80211_IFTYPE_STATION:
459 rfilt |= AR5K_RX_FILTER_BEACON;
464 iter_data.hw_macaddr = NULL;
465 iter_data.n_stas = 0;
466 iter_data.need_set_hw_addr = false;
467 ieee80211_iterate_active_interfaces_atomic(sc->hw, ath5k_vif_iter,
470 /* Set up RX Filter */
471 if (iter_data.n_stas > 1) {
472 /* If you have multiple STA interfaces connected to
473 * different APs, ARPs are not received (most of the time?)
474 * Enabling PROMISC appears to fix that problem.
476 rfilt |= AR5K_RX_FILTER_PROM;
480 ath5k_hw_set_rx_filter(ah, rfilt);
482 /* Set multicast bits */
483 ath5k_hw_set_mcast_filter(ah, mfilt[0], mfilt[1]);
484 /* Set the cached hw filter flags, this will later actually
486 sc->filter_flags = rfilt;
488 mutex_unlock(&sc->lock);
493 ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
494 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
495 struct ieee80211_key_conf *key)
497 struct ath5k_softc *sc = hw->priv;
498 struct ath5k_hw *ah = sc->ah;
499 struct ath_common *common = ath5k_hw_common(ah);
502 if (ath5k_modparam_nohwcrypt)
505 switch (key->cipher) {
506 case WLAN_CIPHER_SUITE_WEP40:
507 case WLAN_CIPHER_SUITE_WEP104:
508 case WLAN_CIPHER_SUITE_TKIP:
510 case WLAN_CIPHER_SUITE_CCMP:
511 if (common->crypt_caps & ATH_CRYPT_CAP_CIPHER_AESCCM)
519 mutex_lock(&sc->lock);
523 ret = ath_key_config(common, vif, sta, key);
525 key->hw_key_idx = ret;
526 /* push IV and Michael MIC generation to stack */
527 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
528 if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
529 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
530 if (key->cipher == WLAN_CIPHER_SUITE_CCMP)
531 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT;
536 ath_key_delete(common, key);
543 mutex_unlock(&sc->lock);
549 ath5k_sw_scan_start(struct ieee80211_hw *hw)
551 struct ath5k_softc *sc = hw->priv;
553 ath5k_hw_set_ledstate(sc->ah, AR5K_LED_SCAN);
558 ath5k_sw_scan_complete(struct ieee80211_hw *hw)
560 struct ath5k_softc *sc = hw->priv;
561 ath5k_hw_set_ledstate(sc->ah, sc->assoc ?
562 AR5K_LED_ASSOC : AR5K_LED_INIT);
567 ath5k_get_stats(struct ieee80211_hw *hw,
568 struct ieee80211_low_level_stats *stats)
570 struct ath5k_softc *sc = hw->priv;
573 ath5k_hw_update_mib_counters(sc->ah);
575 stats->dot11ACKFailureCount = sc->stats.ack_fail;
576 stats->dot11RTSFailureCount = sc->stats.rts_fail;
577 stats->dot11RTSSuccessCount = sc->stats.rts_ok;
578 stats->dot11FCSErrorCount = sc->stats.fcs_error;
585 ath5k_conf_tx(struct ieee80211_hw *hw, u16 queue,
586 const struct ieee80211_tx_queue_params *params)
588 struct ath5k_softc *sc = hw->priv;
589 struct ath5k_hw *ah = sc->ah;
590 struct ath5k_txq_info qi;
593 if (queue >= ah->ah_capabilities.cap_queues.q_tx_num)
596 mutex_lock(&sc->lock);
598 ath5k_hw_get_tx_queueprops(ah, queue, &qi);
600 qi.tqi_aifs = params->aifs;
601 qi.tqi_cw_min = params->cw_min;
602 qi.tqi_cw_max = params->cw_max;
603 qi.tqi_burst_time = params->txop;
605 ATH5K_DBG(sc, ATH5K_DEBUG_ANY,
606 "Configure tx [queue %d], "
607 "aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
608 queue, params->aifs, params->cw_min,
609 params->cw_max, params->txop);
611 if (ath5k_hw_set_tx_queueprops(ah, queue, &qi)) {
613 "Unable to update hardware queue %u!\n", queue);
616 ath5k_hw_reset_tx_queue(ah, queue);
618 mutex_unlock(&sc->lock);
625 ath5k_get_tsf(struct ieee80211_hw *hw)
627 struct ath5k_softc *sc = hw->priv;
629 return ath5k_hw_get_tsf64(sc->ah);
634 ath5k_set_tsf(struct ieee80211_hw *hw, u64 tsf)
636 struct ath5k_softc *sc = hw->priv;
638 ath5k_hw_set_tsf64(sc->ah, tsf);
643 ath5k_reset_tsf(struct ieee80211_hw *hw)
645 struct ath5k_softc *sc = hw->priv;
648 * in IBSS mode we need to update the beacon timers too.
649 * this will also reset the TSF if we call it with 0
651 if (sc->opmode == NL80211_IFTYPE_ADHOC)
652 ath5k_beacon_update_timers(sc, 0);
654 ath5k_hw_reset_tsf(sc->ah);
659 ath5k_get_survey(struct ieee80211_hw *hw, int idx, struct survey_info *survey)
661 struct ath5k_softc *sc = hw->priv;
662 struct ieee80211_conf *conf = &hw->conf;
663 struct ath_common *common = ath5k_hw_common(sc->ah);
664 struct ath_cycle_counters *cc = &common->cc_survey;
665 unsigned int div = common->clockrate * 1000;
670 spin_lock_bh(&common->cc_lock);
671 ath_hw_cycle_counters_update(common);
672 if (cc->cycles > 0) {
673 sc->survey.channel_time += cc->cycles / div;
674 sc->survey.channel_time_busy += cc->rx_busy / div;
675 sc->survey.channel_time_rx += cc->rx_frame / div;
676 sc->survey.channel_time_tx += cc->tx_frame / div;
678 memset(cc, 0, sizeof(*cc));
679 spin_unlock_bh(&common->cc_lock);
681 memcpy(survey, &sc->survey, sizeof(*survey));
683 survey->channel = conf->channel;
684 survey->noise = sc->ah->ah_noise_floor;
685 survey->filled = SURVEY_INFO_NOISE_DBM |
686 SURVEY_INFO_CHANNEL_TIME |
687 SURVEY_INFO_CHANNEL_TIME_BUSY |
688 SURVEY_INFO_CHANNEL_TIME_RX |
689 SURVEY_INFO_CHANNEL_TIME_TX;
696 * ath5k_set_coverage_class - Set IEEE 802.11 coverage class
698 * @hw: struct ieee80211_hw pointer
699 * @coverage_class: IEEE 802.11 coverage class number
701 * Mac80211 callback. Sets slot time, ACK timeout and CTS timeout for given
702 * coverage class. The values are persistent, they are restored after device
706 ath5k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
708 struct ath5k_softc *sc = hw->priv;
710 mutex_lock(&sc->lock);
711 ath5k_hw_set_coverage_class(sc->ah, coverage_class);
712 mutex_unlock(&sc->lock);
717 ath5k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
719 struct ath5k_softc *sc = hw->priv;
721 if (tx_ant == 1 && rx_ant == 1)
722 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_A);
723 else if (tx_ant == 2 && rx_ant == 2)
724 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_B);
725 else if ((tx_ant & 3) == 3 && (rx_ant & 3) == 3)
726 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_DEFAULT);
734 ath5k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
736 struct ath5k_softc *sc = hw->priv;
738 switch (sc->ah->ah_ant_mode) {
739 case AR5K_ANTMODE_FIXED_A:
740 *tx_ant = 1; *rx_ant = 1; break;
741 case AR5K_ANTMODE_FIXED_B:
742 *tx_ant = 2; *rx_ant = 2; break;
743 case AR5K_ANTMODE_DEFAULT:
744 *tx_ant = 3; *rx_ant = 3; break;
750 static void ath5k_get_ringparam(struct ieee80211_hw *hw,
751 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
753 struct ath5k_softc *sc = hw->priv;
755 *tx = sc->txqs[AR5K_TX_QUEUE_ID_DATA_MIN].txq_max;
757 *tx_max = ATH5K_TXQ_LEN_MAX;
758 *rx = *rx_max = ATH_RXBUF;
762 static int ath5k_set_ringparam(struct ieee80211_hw *hw, u32 tx, u32 rx)
764 struct ath5k_softc *sc = hw->priv;
767 /* only support setting tx ring size for now */
771 /* restrict tx ring size min/max */
772 if (!tx || tx > ATH5K_TXQ_LEN_MAX)
775 for (qnum = 0; qnum < ARRAY_SIZE(sc->txqs); qnum++) {
776 if (!sc->txqs[qnum].setup)
778 if (sc->txqs[qnum].qnum < AR5K_TX_QUEUE_ID_DATA_MIN ||
779 sc->txqs[qnum].qnum > AR5K_TX_QUEUE_ID_DATA_MAX)
782 sc->txqs[qnum].txq_max = tx;
783 if (sc->txqs[qnum].txq_len >= sc->txqs[qnum].txq_max)
784 ieee80211_stop_queue(hw, sc->txqs[qnum].qnum);
791 const struct ieee80211_ops ath5k_hw_ops = {
793 .start = ath5k_start,
795 .add_interface = ath5k_add_interface,
796 /* .change_interface = not implemented */
797 .remove_interface = ath5k_remove_interface,
798 .config = ath5k_config,
799 .bss_info_changed = ath5k_bss_info_changed,
800 .prepare_multicast = ath5k_prepare_multicast,
801 .configure_filter = ath5k_configure_filter,
802 /* .set_tim = not implemented */
803 .set_key = ath5k_set_key,
804 /* .update_tkip_key = not implemented */
805 /* .hw_scan = not implemented */
806 .sw_scan_start = ath5k_sw_scan_start,
807 .sw_scan_complete = ath5k_sw_scan_complete,
808 .get_stats = ath5k_get_stats,
809 /* .get_tkip_seq = not implemented */
810 /* .set_frag_threshold = not implemented */
811 /* .set_rts_threshold = not implemented */
812 /* .sta_add = not implemented */
813 /* .sta_remove = not implemented */
814 /* .sta_notify = not implemented */
815 .conf_tx = ath5k_conf_tx,
816 .get_tsf = ath5k_get_tsf,
817 .set_tsf = ath5k_set_tsf,
818 .reset_tsf = ath5k_reset_tsf,
819 /* .tx_last_beacon = not implemented */
820 /* .ampdu_action = not needed */
821 .get_survey = ath5k_get_survey,
822 .set_coverage_class = ath5k_set_coverage_class,
823 /* .rfkill_poll = not implemented */
824 /* .flush = not implemented */
825 /* .channel_switch = not implemented */
826 /* .napi_poll = not implemented */
827 .set_antenna = ath5k_set_antenna,
828 .get_antenna = ath5k_get_antenna,
829 .set_ringparam = ath5k_set_ringparam,
830 .get_ringparam = ath5k_get_ringparam,