base.c (92fd4d4d67b945c0766416284d4ab236b31542c4) base.c (eef39befaae2a1559efe197d795c376a317af2af)
1/*-
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 *
8 * All rights reserved.

--- 535 unchanged lines hidden (view full) ---

544 if (!iter_data->any_assoc) {
545 if (avf->assoc)
546 iter_data->any_assoc = true;
547 }
548
549 /* Calculate combined mode - when APs are active, operate in AP mode.
550 * Otherwise use the mode of the new interface. This can currently
551 * only deal with combinations of APs and STAs. Only one ad-hoc
1/*-
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 *
8 * All rights reserved.

--- 535 unchanged lines hidden (view full) ---

544 if (!iter_data->any_assoc) {
545 if (avf->assoc)
546 iter_data->any_assoc = true;
547 }
548
549 /* Calculate combined mode - when APs are active, operate in AP mode.
550 * Otherwise use the mode of the new interface. This can currently
551 * only deal with combinations of APs and STAs. Only one ad-hoc
552 * interfaces is allowed above.
552 * interfaces is allowed.
553 */
554 if (avf->opmode == NL80211_IFTYPE_AP)
555 iter_data->opmode = NL80211_IFTYPE_AP;
556 else
557 if (iter_data->opmode == NL80211_IFTYPE_UNSPECIFIED)
558 iter_data->opmode = avf->opmode;
559}
560
553 */
554 if (avf->opmode == NL80211_IFTYPE_AP)
555 iter_data->opmode = NL80211_IFTYPE_AP;
556 else
557 if (iter_data->opmode == NL80211_IFTYPE_UNSPECIFIED)
558 iter_data->opmode = avf->opmode;
559}
560
561static void ath_do_set_opmode(struct ath5k_softc *sc)
561static void ath5k_update_bssid_mask_and_opmode(struct ath5k_softc *sc,
562 struct ieee80211_vif *vif)
562{
563{
563 struct ath5k_hw *ah = sc->ah;
564 ath5k_hw_set_opmode(ah, sc->opmode);
565 ATH5K_DBG(sc, ATH5K_DEBUG_MODE, "mode setup opmode %d (%s)\n",
566 sc->opmode, ath_opmode_to_string(sc->opmode));
567}
568
569void ath5k_update_bssid_mask_and_opmode(struct ath5k_softc *sc,
570 struct ieee80211_vif *vif)
571{
572 struct ath_common *common = ath5k_hw_common(sc->ah);
573 struct ath_vif_iter_data iter_data;
574
575 /*
576 * Use the hardware MAC address as reference, the hardware uses it
577 * together with the BSSID mask when matching addresses.
578 */
579 iter_data.hw_macaddr = common->macaddr;

--- 10 unchanged lines hidden (view full) ---

590 &iter_data);
591 memcpy(sc->bssidmask, iter_data.mask, ETH_ALEN);
592
593 sc->opmode = iter_data.opmode;
594 if (sc->opmode == NL80211_IFTYPE_UNSPECIFIED)
595 /* Nothing active, default to station mode */
596 sc->opmode = NL80211_IFTYPE_STATION;
597
564 struct ath_common *common = ath5k_hw_common(sc->ah);
565 struct ath_vif_iter_data iter_data;
566
567 /*
568 * Use the hardware MAC address as reference, the hardware uses it
569 * together with the BSSID mask when matching addresses.
570 */
571 iter_data.hw_macaddr = common->macaddr;

--- 10 unchanged lines hidden (view full) ---

582 &iter_data);
583 memcpy(sc->bssidmask, iter_data.mask, ETH_ALEN);
584
585 sc->opmode = iter_data.opmode;
586 if (sc->opmode == NL80211_IFTYPE_UNSPECIFIED)
587 /* Nothing active, default to station mode */
588 sc->opmode = NL80211_IFTYPE_STATION;
589
598 ath_do_set_opmode(sc);
590 ath5k_hw_set_opmode(sc->ah, sc->opmode);
591 ATH5K_DBG(sc, ATH5K_DEBUG_MODE, "mode setup opmode %d (%s)\n",
592 sc->opmode, ath_opmode_to_string(sc->opmode));
599
600 if (iter_data.need_set_hw_addr && iter_data.found_active)
601 ath5k_hw_set_lladdr(sc->ah, iter_data.active_mac);
602
603 if (ath5k_hw_hasbssidmask(sc->ah))
604 ath5k_hw_set_bssid_mask(sc->ah, sc->bssidmask);
605}
606

--- 695 unchanged lines hidden (view full) ---

1302 struct ath5k_hw *ah = sc->ah;
1303 struct ath_common *common = ath5k_hw_common(ah);
1304
1305 /* only beacons from our BSSID */
1306 if (!ieee80211_is_beacon(mgmt->frame_control) ||
1307 memcmp(mgmt->bssid, common->curbssid, ETH_ALEN) != 0)
1308 return;
1309
593
594 if (iter_data.need_set_hw_addr && iter_data.found_active)
595 ath5k_hw_set_lladdr(sc->ah, iter_data.active_mac);
596
597 if (ath5k_hw_hasbssidmask(sc->ah))
598 ath5k_hw_set_bssid_mask(sc->ah, sc->bssidmask);
599}
600

--- 695 unchanged lines hidden (view full) ---

1296 struct ath5k_hw *ah = sc->ah;
1297 struct ath_common *common = ath5k_hw_common(ah);
1298
1299 /* only beacons from our BSSID */
1300 if (!ieee80211_is_beacon(mgmt->frame_control) ||
1301 memcmp(mgmt->bssid, common->curbssid, ETH_ALEN) != 0)
1302 return;
1303
1310 ah->ah_beacon_rssi_avg = ath5k_moving_average(ah->ah_beacon_rssi_avg,
1311 rssi);
1304 ewma_add(&ah->ah_beacon_rssi_avg, rssi);
1312
1313 /* in IBSS mode we should keep RSSI statistics per neighbour */
1314 /* le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS */
1315}
1316
1317/*
1318 * Compute padding position. skb must contain an IEEE 802.11 frame
1319 */

--- 1237 unchanged lines hidden (view full) ---

2557 goto err;
2558 }
2559
2560 ath5k_ani_init(ah, ah->ah_sc->ani_state.ani_mode);
2561
2562 ah->ah_cal_next_full = jiffies;
2563 ah->ah_cal_next_ani = jiffies;
2564 ah->ah_cal_next_nf = jiffies;
1305
1306 /* in IBSS mode we should keep RSSI statistics per neighbour */
1307 /* le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS */
1308}
1309
1310/*
1311 * Compute padding position. skb must contain an IEEE 802.11 frame
1312 */

--- 1237 unchanged lines hidden (view full) ---

2550 goto err;
2551 }
2552
2553 ath5k_ani_init(ah, ah->ah_sc->ani_state.ani_mode);
2554
2555 ah->ah_cal_next_full = jiffies;
2556 ah->ah_cal_next_ani = jiffies;
2557 ah->ah_cal_next_nf = jiffies;
2558 ewma_init(&ah->ah_beacon_rssi_avg, 1000, 8);
2565
2566 /*
2567 * Change channels and update the h/w rate map if we're switching;
2568 * e.g. 11a to 11b/g.
2569 *
2570 * We may be doing a reset in response to an ioctl that changes the
2571 * channel so update any state that might change as a result.
2572 *

--- 628 unchanged lines hidden (view full) ---

3201 return 0;
3202}
3203
3204static int ath5k_get_survey(struct ieee80211_hw *hw, int idx,
3205 struct survey_info *survey)
3206{
3207 struct ath5k_softc *sc = hw->priv;
3208 struct ieee80211_conf *conf = &hw->conf;
2559
2560 /*
2561 * Change channels and update the h/w rate map if we're switching;
2562 * e.g. 11a to 11b/g.
2563 *
2564 * We may be doing a reset in response to an ioctl that changes the
2565 * channel so update any state that might change as a result.
2566 *

--- 628 unchanged lines hidden (view full) ---

3195 return 0;
3196}
3197
3198static int ath5k_get_survey(struct ieee80211_hw *hw, int idx,
3199 struct survey_info *survey)
3200{
3201 struct ath5k_softc *sc = hw->priv;
3202 struct ieee80211_conf *conf = &hw->conf;
3203 struct ath_common *common = ath5k_hw_common(sc->ah);
3204 struct ath_cycle_counters *cc = &common->cc_survey;
3205 unsigned int div = common->clockrate * 1000;
3209
3206
3210 if (idx != 0)
3207 if (idx != 0)
3211 return -ENOENT;
3212
3213 survey->channel = conf->channel;
3214 survey->filled = SURVEY_INFO_NOISE_DBM;
3215 survey->noise = sc->ah->ah_noise_floor;
3216
3208 return -ENOENT;
3209
3210 survey->channel = conf->channel;
3211 survey->filled = SURVEY_INFO_NOISE_DBM;
3212 survey->noise = sc->ah->ah_noise_floor;
3213
3214 spin_lock_bh(&common->cc_lock);
3215 ath_hw_cycle_counters_update(common);
3216 if (cc->cycles > 0) {
3217 survey->filled |= SURVEY_INFO_CHANNEL_TIME |
3218 SURVEY_INFO_CHANNEL_TIME_BUSY |
3219 SURVEY_INFO_CHANNEL_TIME_RX |
3220 SURVEY_INFO_CHANNEL_TIME_TX;
3221 survey->channel_time += cc->cycles / div;
3222 survey->channel_time_busy += cc->rx_busy / div;
3223 survey->channel_time_rx += cc->rx_frame / div;
3224 survey->channel_time_tx += cc->tx_frame / div;
3225 }
3226 memset(cc, 0, sizeof(*cc));
3227 spin_unlock_bh(&common->cc_lock);
3228
3217 return 0;
3218}
3219
3220static u64
3221ath5k_get_tsf(struct ieee80211_hw *hw)
3222{
3223 struct ath5k_softc *sc = hw->priv;
3224

--- 165 unchanged lines hidden (view full) ---

3390 } else
3391 ath5k_hw_reset_tx_queue(ah, queue);
3392
3393 mutex_unlock(&sc->lock);
3394
3395 return ret;
3396}
3397
3229 return 0;
3230}
3231
3232static u64
3233ath5k_get_tsf(struct ieee80211_hw *hw)
3234{
3235 struct ath5k_softc *sc = hw->priv;
3236

--- 165 unchanged lines hidden (view full) ---

3402 } else
3403 ath5k_hw_reset_tx_queue(ah, queue);
3404
3405 mutex_unlock(&sc->lock);
3406
3407 return ret;
3408}
3409
3410static int ath5k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
3411{
3412 struct ath5k_softc *sc = hw->priv;
3413
3414 if (tx_ant == 1 && rx_ant == 1)
3415 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_A);
3416 else if (tx_ant == 2 && rx_ant == 2)
3417 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_B);
3418 else if ((tx_ant & 3) == 3 && (rx_ant & 3) == 3)
3419 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_DEFAULT);
3420 else
3421 return -EINVAL;
3422 return 0;
3423}
3424
3425static int ath5k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
3426{
3427 struct ath5k_softc *sc = hw->priv;
3428
3429 switch (sc->ah->ah_ant_mode) {
3430 case AR5K_ANTMODE_FIXED_A:
3431 *tx_ant = 1; *rx_ant = 1; break;
3432 case AR5K_ANTMODE_FIXED_B:
3433 *tx_ant = 2; *rx_ant = 2; break;
3434 case AR5K_ANTMODE_DEFAULT:
3435 *tx_ant = 3; *rx_ant = 3; break;
3436 }
3437 return 0;
3438}
3439
3398static const struct ieee80211_ops ath5k_hw_ops = {
3399 .tx = ath5k_tx,
3400 .start = ath5k_start,
3401 .stop = ath5k_stop,
3402 .add_interface = ath5k_add_interface,
3403 .remove_interface = ath5k_remove_interface,
3404 .config = ath5k_config,
3405 .prepare_multicast = ath5k_prepare_multicast,

--- 4 unchanged lines hidden (view full) ---

3410 .conf_tx = ath5k_conf_tx,
3411 .get_tsf = ath5k_get_tsf,
3412 .set_tsf = ath5k_set_tsf,
3413 .reset_tsf = ath5k_reset_tsf,
3414 .bss_info_changed = ath5k_bss_info_changed,
3415 .sw_scan_start = ath5k_sw_scan_start,
3416 .sw_scan_complete = ath5k_sw_scan_complete,
3417 .set_coverage_class = ath5k_set_coverage_class,
3440static const struct ieee80211_ops ath5k_hw_ops = {
3441 .tx = ath5k_tx,
3442 .start = ath5k_start,
3443 .stop = ath5k_stop,
3444 .add_interface = ath5k_add_interface,
3445 .remove_interface = ath5k_remove_interface,
3446 .config = ath5k_config,
3447 .prepare_multicast = ath5k_prepare_multicast,

--- 4 unchanged lines hidden (view full) ---

3452 .conf_tx = ath5k_conf_tx,
3453 .get_tsf = ath5k_get_tsf,
3454 .set_tsf = ath5k_set_tsf,
3455 .reset_tsf = ath5k_reset_tsf,
3456 .bss_info_changed = ath5k_bss_info_changed,
3457 .sw_scan_start = ath5k_sw_scan_start,
3458 .sw_scan_complete = ath5k_sw_scan_complete,
3459 .set_coverage_class = ath5k_set_coverage_class,
3460 .set_antenna = ath5k_set_antenna,
3461 .get_antenna = ath5k_get_antenna,
3418};
3419
3420/********************\
3421* PCI Initialization *
3422\********************/
3423
3424static int __devinit
3425ath5k_pci_probe(struct pci_dev *pdev,

--- 330 unchanged lines hidden ---
3462};
3463
3464/********************\
3465* PCI Initialization *
3466\********************/
3467
3468static int __devinit
3469ath5k_pci_probe(struct pci_dev *pdev,

--- 330 unchanged lines hidden ---