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 extern int ath5k_modparam_nohwcrypt
;
51 /********************\
52 * Mac80211 functions *
53 \********************/
56 ath5k_tx(struct ieee80211_hw
*hw
, struct sk_buff
*skb
)
58 struct ath5k_softc
*sc
= hw
->priv
;
59 u16 qnum
= skb_get_queue_mapping(skb
);
61 if (WARN_ON(qnum
>= sc
->ah
->ah_capabilities
.cap_queues
.q_tx_num
)) {
62 dev_kfree_skb_any(skb
);
66 ath5k_tx_queue(hw
, skb
, &sc
->txqs
[qnum
]);
71 ath5k_start(struct ieee80211_hw
*hw
)
73 return ath5k_init_hw(hw
->priv
);
78 ath5k_stop(struct ieee80211_hw
*hw
)
80 ath5k_stop_hw(hw
->priv
);
85 ath5k_add_interface(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
)
87 struct ath5k_softc
*sc
= hw
->priv
;
89 struct ath5k_vif
*avf
= (void *)vif
->drv_priv
;
91 mutex_lock(&sc
->lock
);
93 if ((vif
->type
== NL80211_IFTYPE_AP
||
94 vif
->type
== NL80211_IFTYPE_ADHOC
)
95 && (sc
->num_ap_vifs
+ sc
->num_adhoc_vifs
) >= ATH_BCBUF
) {
100 /* Don't allow other interfaces if one ad-hoc is configured.
101 * TODO: Fix the problems with ad-hoc and multiple other interfaces.
102 * We would need to operate the HW in ad-hoc mode to allow TSF updates
103 * for the IBSS, but this breaks with additional AP or STA interfaces
105 if (sc
->num_adhoc_vifs
||
106 (sc
->nvifs
&& vif
->type
== NL80211_IFTYPE_ADHOC
)) {
107 ATH5K_ERR(sc
, "Only one single ad-hoc interface is allowed.\n");
113 case NL80211_IFTYPE_AP
:
114 case NL80211_IFTYPE_STATION
:
115 case NL80211_IFTYPE_ADHOC
:
116 case NL80211_IFTYPE_MESH_POINT
:
117 avf
->opmode
= vif
->type
;
125 ATH5K_DBG(sc
, ATH5K_DEBUG_MODE
, "add interface mode %d\n", avf
->opmode
);
127 /* Assign the vap/adhoc to a beacon xmit slot. */
128 if ((avf
->opmode
== NL80211_IFTYPE_AP
) ||
129 (avf
->opmode
== NL80211_IFTYPE_ADHOC
) ||
130 (avf
->opmode
== NL80211_IFTYPE_MESH_POINT
)) {
133 WARN_ON(list_empty(&sc
->bcbuf
));
134 avf
->bbuf
= list_first_entry(&sc
->bcbuf
, struct ath5k_buf
,
136 list_del(&avf
->bbuf
->list
);
139 for (slot
= 0; slot
< ATH_BCBUF
; slot
++) {
140 if (!sc
->bslot
[slot
]) {
145 BUG_ON(sc
->bslot
[avf
->bslot
] != NULL
);
146 sc
->bslot
[avf
->bslot
] = vif
;
147 if (avf
->opmode
== NL80211_IFTYPE_AP
)
149 else if (avf
->opmode
== NL80211_IFTYPE_ADHOC
)
150 sc
->num_adhoc_vifs
++;
153 /* Any MAC address is fine, all others are included through the
156 memcpy(&sc
->lladdr
, vif
->addr
, ETH_ALEN
);
157 ath5k_hw_set_lladdr(sc
->ah
, vif
->addr
);
159 memcpy(&avf
->lladdr
, vif
->addr
, ETH_ALEN
);
161 ath5k_mode_setup(sc
, vif
);
165 mutex_unlock(&sc
->lock
);
171 ath5k_remove_interface(struct ieee80211_hw
*hw
,
172 struct ieee80211_vif
*vif
)
174 struct ath5k_softc
*sc
= hw
->priv
;
175 struct ath5k_vif
*avf
= (void *)vif
->drv_priv
;
178 mutex_lock(&sc
->lock
);
182 ath5k_txbuf_free_skb(sc
, avf
->bbuf
);
183 list_add_tail(&avf
->bbuf
->list
, &sc
->bcbuf
);
184 for (i
= 0; i
< ATH_BCBUF
; i
++) {
185 if (sc
->bslot
[i
] == vif
) {
192 if (avf
->opmode
== NL80211_IFTYPE_AP
)
194 else if (avf
->opmode
== NL80211_IFTYPE_ADHOC
)
195 sc
->num_adhoc_vifs
--;
197 ath5k_update_bssid_mask_and_opmode(sc
, NULL
);
198 mutex_unlock(&sc
->lock
);
203 * TODO: Phy disable/diversity etc
206 ath5k_config(struct ieee80211_hw
*hw
, u32 changed
)
208 struct ath5k_softc
*sc
= hw
->priv
;
209 struct ath5k_hw
*ah
= sc
->ah
;
210 struct ieee80211_conf
*conf
= &hw
->conf
;
214 mutex_lock(&sc
->lock
);
216 if (changed
& IEEE80211_CONF_CHANGE_CHANNEL
) {
217 ret
= ath5k_chan_set(sc
, conf
->channel
);
222 if ((changed
& IEEE80211_CONF_CHANGE_POWER
) &&
223 (sc
->power_level
!= conf
->power_level
)) {
224 sc
->power_level
= conf
->power_level
;
227 ath5k_hw_set_txpower_limit(ah
, (conf
->power_level
* 2));
230 if (changed
& IEEE80211_CONF_CHANGE_RETRY_LIMITS
) {
231 ah
->ah_retry_long
= conf
->long_frame_max_tx_count
;
232 ah
->ah_retry_short
= conf
->short_frame_max_tx_count
;
234 for (i
= 0; i
< ah
->ah_capabilities
.cap_queues
.q_tx_num
; i
++)
235 ath5k_hw_set_tx_retry_limits(ah
, i
);
239 * 1) Move this on config_interface and handle each case
240 * separately eg. when we have only one STA vif, use
241 * AR5K_ANTMODE_SINGLE_AP
243 * 2) Allow the user to change antenna mode eg. when only
244 * one antenna is present
246 * 3) Allow the user to set default/tx antenna when possible
248 * 4) Default mode should handle 90% of the cases, together
249 * with fixed a/b and single AP modes we should be able to
250 * handle 99%. Sectored modes are extreme cases and i still
251 * haven't found a usage for them. If we decide to support them,
252 * then we must allow the user to set how many tx antennas we
255 ath5k_hw_set_antenna_mode(ah
, ah
->ah_ant_mode
);
258 mutex_unlock(&sc
->lock
);
264 ath5k_bss_info_changed(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
265 struct ieee80211_bss_conf
*bss_conf
, u32 changes
)
267 struct ath5k_vif
*avf
= (void *)vif
->drv_priv
;
268 struct ath5k_softc
*sc
= hw
->priv
;
269 struct ath5k_hw
*ah
= sc
->ah
;
270 struct ath_common
*common
= ath5k_hw_common(ah
);
273 mutex_lock(&sc
->lock
);
275 if (changes
& BSS_CHANGED_BSSID
) {
276 /* Cache for later use during resets */
277 memcpy(common
->curbssid
, bss_conf
->bssid
, ETH_ALEN
);
279 ath5k_hw_set_bssid(ah
);
283 if (changes
& BSS_CHANGED_BEACON_INT
)
284 sc
->bintval
= bss_conf
->beacon_int
;
286 if (changes
& BSS_CHANGED_ASSOC
) {
287 avf
->assoc
= bss_conf
->assoc
;
289 sc
->assoc
= bss_conf
->assoc
;
291 sc
->assoc
= ath_any_vif_assoc(sc
);
293 if (sc
->opmode
== NL80211_IFTYPE_STATION
)
294 set_beacon_filter(hw
, sc
->assoc
);
295 ath5k_hw_set_ledstate(sc
->ah
, sc
->assoc
?
296 AR5K_LED_ASSOC
: AR5K_LED_INIT
);
297 if (bss_conf
->assoc
) {
298 ATH5K_DBG(sc
, ATH5K_DEBUG_ANY
,
299 "Bss Info ASSOC %d, bssid: %pM\n",
300 bss_conf
->aid
, common
->curbssid
);
301 common
->curaid
= bss_conf
->aid
;
302 ath5k_hw_set_bssid(ah
);
303 /* Once ANI is available you would start it here */
307 if (changes
& BSS_CHANGED_BEACON
) {
308 spin_lock_irqsave(&sc
->block
, flags
);
309 ath5k_beacon_update(hw
, vif
);
310 spin_unlock_irqrestore(&sc
->block
, flags
);
313 if (changes
& BSS_CHANGED_BEACON_ENABLED
)
314 sc
->enable_beacon
= bss_conf
->enable_beacon
;
316 if (changes
& (BSS_CHANGED_BEACON
| BSS_CHANGED_BEACON_ENABLED
|
317 BSS_CHANGED_BEACON_INT
))
318 ath5k_beacon_config(sc
);
320 mutex_unlock(&sc
->lock
);
325 ath5k_prepare_multicast(struct ieee80211_hw
*hw
,
326 struct netdev_hw_addr_list
*mc_list
)
330 struct netdev_hw_addr
*ha
;
335 netdev_hw_addr_list_for_each(ha
, mc_list
) {
336 /* calculate XOR of eight 6-bit values */
337 val
= get_unaligned_le32(ha
->addr
+ 0);
338 pos
= (val
>> 18) ^ (val
>> 12) ^ (val
>> 6) ^ val
;
339 val
= get_unaligned_le32(ha
->addr
+ 3);
340 pos
^= (val
>> 18) ^ (val
>> 12) ^ (val
>> 6) ^ val
;
342 mfilt
[pos
/ 32] |= (1 << (pos
% 32));
343 /* XXX: we might be able to just do this instead,
344 * but not sure, needs testing, if we do use this we'd
345 * neet to inform below to not reset the mcast */
346 /* ath5k_hw_set_mcast_filterindex(ah,
350 return ((u64
)(mfilt
[1]) << 32) | mfilt
[0];
355 * o always accept unicast, broadcast, and multicast traffic
356 * o multicast traffic for all BSSIDs will be enabled if mac80211
358 * o maintain current state of phy ofdm or phy cck error reception.
359 * If the hardware detects any of these type of errors then
360 * ath5k_hw_get_rx_filter() will pass to us the respective
361 * hardware filters to be able to receive these type of frames.
362 * o probe request frames are accepted only when operating in
363 * hostap, adhoc, or monitor modes
364 * o enable promiscuous mode according to the interface state
366 * - when operating in adhoc mode so the 802.11 layer creates
367 * node table entries for peers,
368 * - when operating in station mode for collecting rssi data when
369 * the station is otherwise quiet, or
373 ath5k_configure_filter(struct ieee80211_hw
*hw
, unsigned int changed_flags
,
374 unsigned int *new_flags
, u64 multicast
)
376 #define SUPPORTED_FIF_FLAGS \
377 (FIF_PROMISC_IN_BSS | FIF_ALLMULTI | FIF_FCSFAIL | \
378 FIF_PLCPFAIL | FIF_CONTROL | FIF_OTHER_BSS | \
379 FIF_BCN_PRBRESP_PROMISC)
381 struct ath5k_softc
*sc
= hw
->priv
;
382 struct ath5k_hw
*ah
= sc
->ah
;
385 mutex_lock(&sc
->lock
);
387 mfilt
[0] = multicast
;
388 mfilt
[1] = multicast
>> 32;
390 /* Only deal with supported flags */
391 changed_flags
&= SUPPORTED_FIF_FLAGS
;
392 *new_flags
&= SUPPORTED_FIF_FLAGS
;
394 /* If HW detects any phy or radar errors, leave those filters on.
395 * Also, always enable Unicast, Broadcasts and Multicast
396 * XXX: move unicast, bssid broadcasts and multicast to mac80211 */
397 rfilt
= (ath5k_hw_get_rx_filter(ah
) & (AR5K_RX_FILTER_PHYERR
)) |
398 (AR5K_RX_FILTER_UCAST
| AR5K_RX_FILTER_BCAST
|
399 AR5K_RX_FILTER_MCAST
);
401 if (changed_flags
& (FIF_PROMISC_IN_BSS
| FIF_OTHER_BSS
)) {
402 if (*new_flags
& FIF_PROMISC_IN_BSS
)
403 __set_bit(ATH_STAT_PROMISC
, sc
->status
);
405 __clear_bit(ATH_STAT_PROMISC
, sc
->status
);
408 if (test_bit(ATH_STAT_PROMISC
, sc
->status
))
409 rfilt
|= AR5K_RX_FILTER_PROM
;
411 /* Note, AR5K_RX_FILTER_MCAST is already enabled */
412 if (*new_flags
& FIF_ALLMULTI
) {
417 /* This is the best we can do */
418 if (*new_flags
& (FIF_FCSFAIL
| FIF_PLCPFAIL
))
419 rfilt
|= AR5K_RX_FILTER_PHYERR
;
421 /* FIF_BCN_PRBRESP_PROMISC really means to enable beacons
422 * and probes for any BSSID */
423 if ((*new_flags
& FIF_BCN_PRBRESP_PROMISC
) || (sc
->nvifs
> 1))
424 rfilt
|= AR5K_RX_FILTER_BEACON
;
426 /* FIF_CONTROL doc says that if FIF_PROMISC_IN_BSS is not
427 * set we should only pass on control frames for this
428 * station. This needs testing. I believe right now this
429 * enables *all* control frames, which is OK.. but
430 * but we should see if we can improve on granularity */
431 if (*new_flags
& FIF_CONTROL
)
432 rfilt
|= AR5K_RX_FILTER_CONTROL
;
434 /* Additional settings per mode -- this is per ath5k */
436 /* XXX move these to mac80211, and add a beacon IFF flag to mac80211 */
438 switch (sc
->opmode
) {
439 case NL80211_IFTYPE_MESH_POINT
:
440 rfilt
|= AR5K_RX_FILTER_CONTROL
|
441 AR5K_RX_FILTER_BEACON
|
442 AR5K_RX_FILTER_PROBEREQ
|
445 case NL80211_IFTYPE_AP
:
446 case NL80211_IFTYPE_ADHOC
:
447 rfilt
|= AR5K_RX_FILTER_PROBEREQ
|
448 AR5K_RX_FILTER_BEACON
;
450 case NL80211_IFTYPE_STATION
:
452 rfilt
|= AR5K_RX_FILTER_BEACON
;
458 ath5k_hw_set_rx_filter(ah
, rfilt
);
460 /* Set multicast bits */
461 ath5k_hw_set_mcast_filter(ah
, mfilt
[0], mfilt
[1]);
462 /* Set the cached hw filter flags, this will later actually
464 sc
->filter_flags
= rfilt
;
466 mutex_unlock(&sc
->lock
);
471 ath5k_set_key(struct ieee80211_hw
*hw
, enum set_key_cmd cmd
,
472 struct ieee80211_vif
*vif
, struct ieee80211_sta
*sta
,
473 struct ieee80211_key_conf
*key
)
475 struct ath5k_softc
*sc
= hw
->priv
;
476 struct ath5k_hw
*ah
= sc
->ah
;
477 struct ath_common
*common
= ath5k_hw_common(ah
);
480 if (ath5k_modparam_nohwcrypt
)
483 switch (key
->cipher
) {
484 case WLAN_CIPHER_SUITE_WEP40
:
485 case WLAN_CIPHER_SUITE_WEP104
:
486 case WLAN_CIPHER_SUITE_TKIP
:
488 case WLAN_CIPHER_SUITE_CCMP
:
489 if (common
->crypt_caps
& ATH_CRYPT_CAP_CIPHER_AESCCM
)
497 mutex_lock(&sc
->lock
);
501 ret
= ath_key_config(common
, vif
, sta
, key
);
503 key
->hw_key_idx
= ret
;
504 /* push IV and Michael MIC generation to stack */
505 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_IV
;
506 if (key
->cipher
== WLAN_CIPHER_SUITE_TKIP
)
507 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_MMIC
;
508 if (key
->cipher
== WLAN_CIPHER_SUITE_CCMP
)
509 key
->flags
|= IEEE80211_KEY_FLAG_SW_MGMT
;
514 ath_key_delete(common
, key
);
521 mutex_unlock(&sc
->lock
);
527 ath5k_sw_scan_start(struct ieee80211_hw
*hw
)
529 struct ath5k_softc
*sc
= hw
->priv
;
531 ath5k_hw_set_ledstate(sc
->ah
, AR5K_LED_SCAN
);
536 ath5k_sw_scan_complete(struct ieee80211_hw
*hw
)
538 struct ath5k_softc
*sc
= hw
->priv
;
539 ath5k_hw_set_ledstate(sc
->ah
, sc
->assoc
?
540 AR5K_LED_ASSOC
: AR5K_LED_INIT
);
545 ath5k_get_stats(struct ieee80211_hw
*hw
,
546 struct ieee80211_low_level_stats
*stats
)
548 struct ath5k_softc
*sc
= hw
->priv
;
551 ath5k_hw_update_mib_counters(sc
->ah
);
553 stats
->dot11ACKFailureCount
= sc
->stats
.ack_fail
;
554 stats
->dot11RTSFailureCount
= sc
->stats
.rts_fail
;
555 stats
->dot11RTSSuccessCount
= sc
->stats
.rts_ok
;
556 stats
->dot11FCSErrorCount
= sc
->stats
.fcs_error
;
563 ath5k_conf_tx(struct ieee80211_hw
*hw
, u16 queue
,
564 const struct ieee80211_tx_queue_params
*params
)
566 struct ath5k_softc
*sc
= hw
->priv
;
567 struct ath5k_hw
*ah
= sc
->ah
;
568 struct ath5k_txq_info qi
;
571 if (queue
>= ah
->ah_capabilities
.cap_queues
.q_tx_num
)
574 mutex_lock(&sc
->lock
);
576 ath5k_hw_get_tx_queueprops(ah
, queue
, &qi
);
578 qi
.tqi_aifs
= params
->aifs
;
579 qi
.tqi_cw_min
= params
->cw_min
;
580 qi
.tqi_cw_max
= params
->cw_max
;
581 qi
.tqi_burst_time
= params
->txop
;
583 ATH5K_DBG(sc
, ATH5K_DEBUG_ANY
,
584 "Configure tx [queue %d], "
585 "aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
586 queue
, params
->aifs
, params
->cw_min
,
587 params
->cw_max
, params
->txop
);
589 if (ath5k_hw_set_tx_queueprops(ah
, queue
, &qi
)) {
591 "Unable to update hardware queue %u!\n", queue
);
594 ath5k_hw_reset_tx_queue(ah
, queue
);
596 mutex_unlock(&sc
->lock
);
603 ath5k_get_tsf(struct ieee80211_hw
*hw
)
605 struct ath5k_softc
*sc
= hw
->priv
;
607 return ath5k_hw_get_tsf64(sc
->ah
);
612 ath5k_set_tsf(struct ieee80211_hw
*hw
, u64 tsf
)
614 struct ath5k_softc
*sc
= hw
->priv
;
616 ath5k_hw_set_tsf64(sc
->ah
, tsf
);
621 ath5k_reset_tsf(struct ieee80211_hw
*hw
)
623 struct ath5k_softc
*sc
= hw
->priv
;
626 * in IBSS mode we need to update the beacon timers too.
627 * this will also reset the TSF if we call it with 0
629 if (sc
->opmode
== NL80211_IFTYPE_ADHOC
)
630 ath5k_beacon_update_timers(sc
, 0);
632 ath5k_hw_reset_tsf(sc
->ah
);
637 ath5k_get_survey(struct ieee80211_hw
*hw
, int idx
, struct survey_info
*survey
)
639 struct ath5k_softc
*sc
= hw
->priv
;
640 struct ieee80211_conf
*conf
= &hw
->conf
;
641 struct ath_common
*common
= ath5k_hw_common(sc
->ah
);
642 struct ath_cycle_counters
*cc
= &common
->cc_survey
;
643 unsigned int div
= common
->clockrate
* 1000;
648 spin_lock_bh(&common
->cc_lock
);
649 ath_hw_cycle_counters_update(common
);
650 if (cc
->cycles
> 0) {
651 sc
->survey
.channel_time
+= cc
->cycles
/ div
;
652 sc
->survey
.channel_time_busy
+= cc
->rx_busy
/ div
;
653 sc
->survey
.channel_time_rx
+= cc
->rx_frame
/ div
;
654 sc
->survey
.channel_time_tx
+= cc
->tx_frame
/ div
;
656 memset(cc
, 0, sizeof(*cc
));
657 spin_unlock_bh(&common
->cc_lock
);
659 memcpy(survey
, &sc
->survey
, sizeof(*survey
));
661 survey
->channel
= conf
->channel
;
662 survey
->noise
= sc
->ah
->ah_noise_floor
;
663 survey
->filled
= SURVEY_INFO_NOISE_DBM
|
664 SURVEY_INFO_CHANNEL_TIME
|
665 SURVEY_INFO_CHANNEL_TIME_BUSY
|
666 SURVEY_INFO_CHANNEL_TIME_RX
|
667 SURVEY_INFO_CHANNEL_TIME_TX
;
674 * ath5k_set_coverage_class - Set IEEE 802.11 coverage class
676 * @hw: struct ieee80211_hw pointer
677 * @coverage_class: IEEE 802.11 coverage class number
679 * Mac80211 callback. Sets slot time, ACK timeout and CTS timeout for given
680 * coverage class. The values are persistent, they are restored after device
684 ath5k_set_coverage_class(struct ieee80211_hw
*hw
, u8 coverage_class
)
686 struct ath5k_softc
*sc
= hw
->priv
;
688 mutex_lock(&sc
->lock
);
689 ath5k_hw_set_coverage_class(sc
->ah
, coverage_class
);
690 mutex_unlock(&sc
->lock
);
695 ath5k_set_antenna(struct ieee80211_hw
*hw
, u32 tx_ant
, u32 rx_ant
)
697 struct ath5k_softc
*sc
= hw
->priv
;
699 if (tx_ant
== 1 && rx_ant
== 1)
700 ath5k_hw_set_antenna_mode(sc
->ah
, AR5K_ANTMODE_FIXED_A
);
701 else if (tx_ant
== 2 && rx_ant
== 2)
702 ath5k_hw_set_antenna_mode(sc
->ah
, AR5K_ANTMODE_FIXED_B
);
703 else if ((tx_ant
& 3) == 3 && (rx_ant
& 3) == 3)
704 ath5k_hw_set_antenna_mode(sc
->ah
, AR5K_ANTMODE_DEFAULT
);
712 ath5k_get_antenna(struct ieee80211_hw
*hw
, u32
*tx_ant
, u32
*rx_ant
)
714 struct ath5k_softc
*sc
= hw
->priv
;
716 switch (sc
->ah
->ah_ant_mode
) {
717 case AR5K_ANTMODE_FIXED_A
:
718 *tx_ant
= 1; *rx_ant
= 1; break;
719 case AR5K_ANTMODE_FIXED_B
:
720 *tx_ant
= 2; *rx_ant
= 2; break;
721 case AR5K_ANTMODE_DEFAULT
:
722 *tx_ant
= 3; *rx_ant
= 3; break;
728 const struct ieee80211_ops ath5k_hw_ops
= {
730 .start
= ath5k_start
,
732 .add_interface
= ath5k_add_interface
,
733 /* .change_interface = not implemented */
734 .remove_interface
= ath5k_remove_interface
,
735 .config
= ath5k_config
,
736 .bss_info_changed
= ath5k_bss_info_changed
,
737 .prepare_multicast
= ath5k_prepare_multicast
,
738 .configure_filter
= ath5k_configure_filter
,
739 /* .set_tim = not implemented */
740 .set_key
= ath5k_set_key
,
741 /* .update_tkip_key = not implemented */
742 /* .hw_scan = not implemented */
743 .sw_scan_start
= ath5k_sw_scan_start
,
744 .sw_scan_complete
= ath5k_sw_scan_complete
,
745 .get_stats
= ath5k_get_stats
,
746 /* .get_tkip_seq = not implemented */
747 /* .set_frag_threshold = not implemented */
748 /* .set_rts_threshold = not implemented */
749 /* .sta_add = not implemented */
750 /* .sta_remove = not implemented */
751 /* .sta_notify = not implemented */
752 .conf_tx
= ath5k_conf_tx
,
753 .get_tsf
= ath5k_get_tsf
,
754 .set_tsf
= ath5k_set_tsf
,
755 .reset_tsf
= ath5k_reset_tsf
,
756 /* .tx_last_beacon = not implemented */
757 /* .ampdu_action = not needed */
758 .get_survey
= ath5k_get_survey
,
759 .set_coverage_class
= ath5k_set_coverage_class
,
760 /* .rfkill_poll = not implemented */
761 /* .flush = not implemented */
762 /* .channel_switch = not implemented */
763 /* .napi_poll = not implemented */
764 .set_antenna
= ath5k_set_antenna
,
765 .get_antenna
= ath5k_get_antenna
,