100
101
[CONF_SG_DHCP_TIME] = 5000,
101
102
[CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_A2DP] = 100,
105
[CONF_SG_BT_PER_THRESHOLD] = 7500,
106
[CONF_SG_HV3_MAX_OVERRIDE] = 0,
107
[CONF_SG_BT_NFS_SAMPLE_INTERVAL] = 400,
108
[CONF_SG_BT_LOAD_RATIO] = 50,
109
[CONF_SG_AUTO_PS_MODE] = 1,
110
[CONF_SG_AUTO_SCAN_PROBE_REQ] = 170,
111
[CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_HV3] = 50,
112
[CONF_SG_ANTENNA_CONFIGURATION] = 0,
113
[CONF_SG_BEACON_MISS_PERCENT] = 60,
114
[CONF_SG_RATE_ADAPT_THRESH] = 64,
115
[CONF_SG_RATE_ADAPT_SNR] = 1,
116
[CONF_SG_WLAN_PS_BT_ACL_MASTER_MIN_BR] = 10,
117
[CONF_SG_WLAN_PS_BT_ACL_MASTER_MAX_BR] = 25,
118
[CONF_SG_WLAN_PS_MAX_BT_ACL_MASTER_BR] = 25,
119
[CONF_SG_WLAN_PS_BT_ACL_SLAVE_MIN_BR] = 20,
120
[CONF_SG_WLAN_PS_BT_ACL_SLAVE_MAX_BR] = 25,
121
[CONF_SG_WLAN_PS_MAX_BT_ACL_SLAVE_BR] = 25,
122
[CONF_SG_WLAN_PS_BT_ACL_MASTER_MIN_EDR] = 7,
123
[CONF_SG_WLAN_PS_BT_ACL_MASTER_MAX_EDR] = 25,
124
[CONF_SG_WLAN_PS_MAX_BT_ACL_MASTER_EDR] = 25,
125
[CONF_SG_WLAN_PS_BT_ACL_SLAVE_MIN_EDR] = 8,
126
[CONF_SG_WLAN_PS_BT_ACL_SLAVE_MAX_EDR] = 25,
127
[CONF_SG_WLAN_PS_MAX_BT_ACL_SLAVE_EDR] = 25,
128
[CONF_SG_RXT] = 1200,
129
[CONF_SG_TXT] = 1000,
130
[CONF_SG_ADAPTIVE_RXT_TXT] = 1,
131
[CONF_SG_PS_POLL_TIMEOUT] = 10,
132
[CONF_SG_UPSD_TIMEOUT] = 10,
133
[CONF_SG_WLAN_ACTIVE_BT_ACL_MASTER_MIN_EDR] = 7,
134
[CONF_SG_WLAN_ACTIVE_BT_ACL_MASTER_MAX_EDR] = 15,
135
[CONF_SG_WLAN_ACTIVE_MAX_BT_ACL_MASTER_EDR] = 15,
136
[CONF_SG_WLAN_ACTIVE_BT_ACL_SLAVE_MIN_EDR] = 8,
137
[CONF_SG_WLAN_ACTIVE_BT_ACL_SLAVE_MAX_EDR] = 20,
138
[CONF_SG_WLAN_ACTIVE_MAX_BT_ACL_SLAVE_EDR] = 15,
139
[CONF_SG_WLAN_ACTIVE_BT_ACL_MIN_BR] = 20,
140
[CONF_SG_WLAN_ACTIVE_BT_ACL_MAX_BR] = 50,
141
[CONF_SG_WLAN_ACTIVE_MAX_BT_ACL_BR] = 10,
142
[CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_HV3] = 200,
143
[CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP] = 800,
144
[CONF_SG_PASSIVE_SCAN_A2DP_BT_TIME] = 75,
145
[CONF_SG_PASSIVE_SCAN_A2DP_WLAN_TIME] = 15,
146
[CONF_SG_HV3_MAX_SERVED] = 6,
147
[CONF_SG_DHCP_TIME] = 5000,
148
[CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_A2DP] = 100,
149
[CONF_SG_TEMP_PARAM_1] = 0,
150
[CONF_SG_TEMP_PARAM_2] = 0,
151
[CONF_SG_TEMP_PARAM_3] = 0,
152
[CONF_SG_TEMP_PARAM_4] = 0,
153
[CONF_SG_TEMP_PARAM_5] = 0,
154
[CONF_SG_AP_BEACON_MISS_TX] = 3,
155
[CONF_SG_RX_WINDOW_LENGTH] = 6,
156
[CONF_SG_AP_CONNECTION_PROTECTION_TIME] = 50,
157
[CONF_SG_TEMP_PARAM_6] = 1,
103
159
.state = CONF_SG_PROTECTIVE,
619
static void wl1271_irq_ps_regulate_link(struct wl1271 *wl, u8 hlid, u8 tx_blks)
623
/* only regulate station links */
624
if (hlid < WL1271_AP_STA_HLID_START)
627
fw_ps = test_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map);
630
* Wake up from high level PS if the STA is asleep with too little
631
* blocks in FW or if the STA is awake.
633
if (!fw_ps || tx_blks < WL1271_PS_STA_MAX_BLOCKS)
634
wl1271_ps_link_end(wl, hlid);
636
/* Start high-level PS if the STA is asleep with enough blocks in FW */
637
else if (fw_ps && tx_blks >= WL1271_PS_STA_MAX_BLOCKS)
638
wl1271_ps_link_start(wl, hlid, true);
641
static void wl1271_irq_update_links_status(struct wl1271 *wl,
642
struct wl1271_fw_ap_status *status)
647
cur_fw_ps_map = le32_to_cpu(status->link_ps_bitmap);
648
if (wl->ap_fw_ps_map != cur_fw_ps_map) {
649
wl1271_debug(DEBUG_PSM,
650
"link ps prev 0x%x cur 0x%x changed 0x%x",
651
wl->ap_fw_ps_map, cur_fw_ps_map,
652
wl->ap_fw_ps_map ^ cur_fw_ps_map);
654
wl->ap_fw_ps_map = cur_fw_ps_map;
657
for (hlid = WL1271_AP_STA_HLID_START; hlid < AP_MAX_LINKS; hlid++) {
658
u8 cnt = status->tx_lnk_free_blks[hlid] -
659
wl->links[hlid].prev_freed_blks;
661
wl->links[hlid].prev_freed_blks =
662
status->tx_lnk_free_blks[hlid];
663
wl->links[hlid].allocated_blks -= cnt;
665
wl1271_irq_ps_regulate_link(wl, hlid,
666
wl->links[hlid].allocated_blks);
479
670
static void wl1271_fw_status(struct wl1271 *wl,
480
struct wl1271_fw_status *status)
671
struct wl1271_fw_full_status *full_status)
673
struct wl1271_fw_common_status *status = &full_status->common;
482
674
struct timespec ts;
675
u32 old_tx_blk_count = wl->tx_blocks_available;
676
u32 freed_blocks = 0;
486
wl1271_raw_read(wl, FW_STATUS_ADDR, status, sizeof(*status), false);
679
if (wl->bss_type == BSS_TYPE_AP_BSS) {
680
wl1271_raw_read(wl, FW_STATUS_ADDR, status,
681
sizeof(struct wl1271_fw_ap_status), false);
683
wl1271_raw_read(wl, FW_STATUS_ADDR, status,
684
sizeof(struct wl1271_fw_sta_status), false);
488
687
wl1271_debug(DEBUG_IRQ, "intr: 0x%x (fw_rx_counter = %d, "
489
688
"drv_rx_counter = %d, tx_results_counter = %d)",
513
731
(s64)le32_to_cpu(status->fw_localtime);
516
#define WL1271_IRQ_MAX_LOOPS 10
518
static void wl1271_irq_work(struct work_struct *work)
734
static void wl1271_flush_deferred_work(struct wl1271 *wl)
738
/* Pass all received frames to the network stack */
739
while ((skb = skb_dequeue(&wl->deferred_rx_queue)))
740
ieee80211_rx_ni(wl->hw, skb);
742
/* Return sent skbs to the network stack */
743
while ((skb = skb_dequeue(&wl->deferred_tx_queue)))
744
ieee80211_tx_status(wl->hw, skb);
747
static void wl1271_netstack_work(struct work_struct *work)
750
container_of(work, struct wl1271, netstack_work);
753
wl1271_flush_deferred_work(wl);
754
} while (skb_queue_len(&wl->deferred_rx_queue));
757
#define WL1271_IRQ_MAX_LOOPS 256
759
irqreturn_t wl1271_irq(int irq, void *cookie)
522
763
int loopcount = WL1271_IRQ_MAX_LOOPS;
764
struct wl1271 *wl = (struct wl1271 *)cookie;
766
unsigned int defer_count;
523
767
unsigned long flags;
525
container_of(work, struct wl1271, irq_work);
769
/* TX might be handled here, avoid redundant work */
770
set_bit(WL1271_FLAG_TX_PENDING, &wl->flags);
771
cancel_work_sync(&wl->tx_work);
774
* In case edge triggered interrupt must be used, we cannot iterate
775
* more than once without introducing race conditions with the hardirq.
777
if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ)
527
780
mutex_lock(&wl->mutex);
598
862
if (intr & WL1271_ACX_INTR_HW_AVAILABLE)
599
863
wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_HW_AVAILABLE");
601
spin_lock_irqsave(&wl->wl_lock, flags);
604
if (test_bit(WL1271_FLAG_IRQ_PENDING, &wl->flags))
605
ieee80211_queue_work(wl->hw, &wl->irq_work);
607
clear_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);
608
spin_unlock_irqrestore(&wl->wl_lock, flags);
610
866
wl1271_ps_elp_sleep(wl);
869
spin_lock_irqsave(&wl->wl_lock, flags);
870
/* In case TX was not handled here, queue TX work */
871
clear_bit(WL1271_FLAG_TX_PENDING, &wl->flags);
872
if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&
874
ieee80211_queue_work(wl->hw, &wl->tx_work);
875
spin_unlock_irqrestore(&wl->wl_lock, flags);
613
877
mutex_unlock(&wl->mutex);
881
EXPORT_SYMBOL_GPL(wl1271_irq);
616
883
static int wl1271_fetch_firmware(struct wl1271 *wl)
618
885
const struct firmware *fw;
621
ret = request_firmware(&fw, WL1271_FW_NAME, wl1271_wl_to_dev(wl));
889
switch (wl->bss_type) {
890
case BSS_TYPE_AP_BSS:
891
if (wl->chip.id == CHIP_ID_1283_PG20)
892
fw_name = WL128X_AP_FW_NAME;
894
fw_name = WL127X_AP_FW_NAME;
897
case BSS_TYPE_STA_BSS:
898
if (wl->chip.id == CHIP_ID_1283_PG20)
899
fw_name = WL128X_FW_NAME;
901
fw_name = WL1271_FW_NAME;
904
wl1271_error("no compatible firmware for bss_type %d",
909
wl1271_debug(DEBUG_BOOT, "booting firmware %s", fw_name);
911
ret = request_firmware(&fw, fw_name, wl1271_wl_to_dev(wl));
624
914
wl1271_error("could not get firmware: %d", ret);
872
wl1271_disable_interrupts(wl);
873
1216
wl1271_power_off(wl);
875
1218
wl->state = WL1271_STATE_OFF;
876
1219
wl->rx_counter = 0;
1221
mutex_unlock(&wl->mutex);
1222
wl1271_disable_interrupts(wl);
1223
wl1271_flush_deferred_work(wl);
1224
cancel_work_sync(&wl->netstack_work);
1225
cancel_work_sync(&wl->recovery_work);
1226
mutex_lock(&wl->mutex);
1231
int wl1271_plt_stop(struct wl1271 *wl)
1235
mutex_lock(&wl->mutex);
1236
ret = __wl1271_plt_stop(wl);
879
1237
mutex_unlock(&wl->mutex);
881
cancel_work_sync(&wl->irq_work);
882
cancel_work_sync(&wl->recovery_work);
887
static int wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
1241
static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
889
1243
struct wl1271 *wl = hw->priv;
890
struct ieee80211_conf *conf = &hw->conf;
891
struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb);
892
struct ieee80211_sta *sta = txinfo->control.sta;
893
1244
unsigned long flags;
897
* peek into the rates configured in the STA entry.
898
* The rates set after connection stage, The first block only BG sets:
899
* the compare is for bit 0-16 of sta_rate_set. The second block add
900
* HT rates in case of HT supported.
902
spin_lock_irqsave(&wl->wl_lock, flags);
904
(sta->supp_rates[conf->channel->band] !=
905
(wl->sta_rate_set & HW_BG_RATES_MASK))) {
906
wl->sta_rate_set = sta->supp_rates[conf->channel->band];
907
set_bit(WL1271_FLAG_STA_RATES_CHANGED, &wl->flags);
910
#ifdef CONFIG_WL12XX_HT
912
sta->ht_cap.ht_supported &&
913
((wl->sta_rate_set >> HW_HT_RATES_OFFSET) !=
914
sta->ht_cap.mcs.rx_mask[0])) {
915
/* Clean MCS bits before setting them */
916
wl->sta_rate_set &= HW_BG_RATES_MASK;
918
(sta->ht_cap.mcs.rx_mask[0] << HW_HT_RATES_OFFSET);
919
set_bit(WL1271_FLAG_STA_RATES_CHANGED, &wl->flags);
922
wl->tx_queue_count++;
923
spin_unlock_irqrestore(&wl->wl_lock, flags);
925
/* queue the packet */
926
1248
q = wl1271_tx_get_queue(skb_get_queue_mapping(skb));
927
skb_queue_tail(&wl->tx_queue[q], skb);
930
* The chip specific setup must run before the first TX packet -
931
* before that, the tx_work will not be initialized!
934
if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags))
935
ieee80211_queue_work(wl->hw, &wl->tx_work);
1250
if (wl->bss_type == BSS_TYPE_AP_BSS)
1251
hlid = wl1271_tx_get_hlid(skb);
1253
spin_lock_irqsave(&wl->wl_lock, flags);
1255
wl->tx_queue_count++;
938
1258
* The workqueue is slow to process the tx_queue and we need stop
941
1261
if (wl->tx_queue_count >= WL1271_TX_QUEUE_HIGH_WATERMARK) {
942
1262
wl1271_debug(DEBUG_TX, "op_tx: stopping queues");
944
spin_lock_irqsave(&wl->wl_lock, flags);
945
1263
ieee80211_stop_queues(wl->hw);
946
1264
set_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags);
947
spin_unlock_irqrestore(&wl->wl_lock, flags);
1267
/* queue the packet */
1268
if (wl->bss_type == BSS_TYPE_AP_BSS) {
1269
wl1271_debug(DEBUG_TX, "queue skb hlid %d q %d", hlid, q);
1270
skb_queue_tail(&wl->links[hlid].tx_queue[q], skb);
1272
skb_queue_tail(&wl->tx_queue[q], skb);
1276
* The chip specific setup must run before the first TX packet -
1277
* before that, the tx_work will not be initialized!
1280
if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags) &&
1281
!test_bit(WL1271_FLAG_TX_PENDING, &wl->flags))
1282
ieee80211_queue_work(wl->hw, &wl->tx_work);
1284
spin_unlock_irqrestore(&wl->wl_lock, flags);
1287
int wl1271_tx_dummy_packet(struct wl1271 *wl)
1289
unsigned long flags;
1291
spin_lock_irqsave(&wl->wl_lock, flags);
1292
set_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags);
1293
wl->tx_queue_count++;
1294
spin_unlock_irqrestore(&wl->wl_lock, flags);
1296
/* The FW is low on RX memory blocks, so send the dummy packet asap */
1297
if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags))
1298
wl1271_tx_work_locked(wl);
1301
* If the FW TX is busy, TX work will be scheduled by the threaded
1302
* interrupt handler function
1308
* The size of the dummy packet should be at least 1400 bytes. However, in
1309
* order to minimize the number of bus transactions, aligning it to 512 bytes
1310
* boundaries could be beneficial, performance wise
1312
#define TOTAL_TX_DUMMY_PACKET_SIZE (ALIGN(1400, 512))
1314
static struct sk_buff *wl12xx_alloc_dummy_packet(struct wl1271 *wl)
1316
struct sk_buff *skb;
1317
struct ieee80211_hdr_3addr *hdr;
1318
unsigned int dummy_packet_size;
1320
dummy_packet_size = TOTAL_TX_DUMMY_PACKET_SIZE -
1321
sizeof(struct wl1271_tx_hw_descr) - sizeof(*hdr);
1323
skb = dev_alloc_skb(TOTAL_TX_DUMMY_PACKET_SIZE);
1325
wl1271_warning("Failed to allocate a dummy packet skb");
1329
skb_reserve(skb, sizeof(struct wl1271_tx_hw_descr));
1331
hdr = (struct ieee80211_hdr_3addr *) skb_put(skb, sizeof(*hdr));
1332
memset(hdr, 0, sizeof(*hdr));
1333
hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
1334
IEEE80211_STYPE_NULLFUNC |
1335
IEEE80211_FCTL_TODS);
1337
memset(skb_put(skb, dummy_packet_size), 0, dummy_packet_size);
1339
/* Dummy packets require the TID to be management */
1340
skb->priority = WL1271_TID_MGMT;
1342
/* Initialize all fields that might be used */
1343
skb_set_queue_mapping(skb, 0);
1344
memset(IEEE80211_SKB_CB(skb), 0, sizeof(struct ieee80211_tx_info));
953
1350
static struct notifier_block wl1271_dev_notifier = {
954
1351
.notifier_call = wl1271_dev_notify,
1355
static int wl1271_configure_suspend(struct wl1271 *wl)
1359
if (wl->bss_type != BSS_TYPE_STA_BSS)
1362
mutex_lock(&wl->mutex);
1364
ret = wl1271_ps_elp_wakeup(wl);
1368
/* enter psm if needed*/
1369
if (!test_bit(WL1271_FLAG_PSM, &wl->flags)) {
1370
DECLARE_COMPLETION_ONSTACK(compl);
1372
wl->ps_compl = &compl;
1373
ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE,
1374
wl->basic_rate, true);
1378
/* we must unlock here so we will be able to get events */
1379
wl1271_ps_elp_sleep(wl);
1380
mutex_unlock(&wl->mutex);
1382
ret = wait_for_completion_timeout(
1383
&compl, msecs_to_jiffies(WL1271_PS_COMPLETE_TIMEOUT));
1385
wl1271_warning("couldn't enter ps mode!");
1390
/* take mutex again, and wakeup */
1391
mutex_lock(&wl->mutex);
1393
ret = wl1271_ps_elp_wakeup(wl);
1398
wl1271_ps_elp_sleep(wl);
1400
mutex_unlock(&wl->mutex);
1406
static void wl1271_configure_resume(struct wl1271 *wl)
1410
if (wl->bss_type != BSS_TYPE_STA_BSS)
1413
mutex_lock(&wl->mutex);
1414
ret = wl1271_ps_elp_wakeup(wl);
1418
/* exit psm if it wasn't configured */
1419
if (!test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags))
1420
wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE,
1421
wl->basic_rate, true);
1423
wl1271_ps_elp_sleep(wl);
1425
mutex_unlock(&wl->mutex);
1428
static int wl1271_op_suspend(struct ieee80211_hw *hw,
1429
struct cfg80211_wowlan *wow)
1431
struct wl1271 *wl = hw->priv;
1432
wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow);
1433
wl->wow_enabled = !!wow;
1434
if (wl->wow_enabled) {
1436
ret = wl1271_configure_suspend(wl);
1438
wl1271_warning("couldn't prepare device to suspend");
1441
/* flush any remaining work */
1442
wl1271_debug(DEBUG_MAC80211, "flushing remaining works");
1443
flush_delayed_work(&wl->scan_complete_work);
1446
* disable and re-enable interrupts in order to flush
1449
wl1271_disable_interrupts(wl);
1452
* set suspended flag to avoid triggering a new threaded_irq
1453
* work. no need for spinlock as interrupts are disabled.
1455
set_bit(WL1271_FLAG_SUSPENDED, &wl->flags);
1457
wl1271_enable_interrupts(wl);
1458
flush_work(&wl->tx_work);
1459
flush_delayed_work(&wl->pspoll_work);
1460
flush_delayed_work(&wl->elp_work);
1465
static int wl1271_op_resume(struct ieee80211_hw *hw)
1467
struct wl1271 *wl = hw->priv;
1468
wl1271_debug(DEBUG_MAC80211, "mac80211 resume wow=%d",
1472
* re-enable irq_work enqueuing, and call irq_work directly if
1473
* there is a pending work.
1475
if (wl->wow_enabled) {
1476
struct wl1271 *wl = hw->priv;
1477
unsigned long flags;
1478
bool run_irq_work = false;
1480
spin_lock_irqsave(&wl->wl_lock, flags);
1481
clear_bit(WL1271_FLAG_SUSPENDED, &wl->flags);
1482
if (test_and_clear_bit(WL1271_FLAG_PENDING_WORK, &wl->flags))
1483
run_irq_work = true;
1484
spin_unlock_irqrestore(&wl->wl_lock, flags);
1487
wl1271_debug(DEBUG_MAC80211,
1488
"run postponed irq_work directly");
1490
wl1271_enable_interrupts(wl);
1493
wl1271_configure_resume(wl);
957
1500
static int wl1271_op_start(struct ieee80211_hw *hw)
959
1502
wl1271_debug(DEBUG_MAC80211, "mac80211 start");
1417
1999
wl->band = conf->channel->band;
1418
2000
wl->channel = channel;
1421
* FIXME: the mac80211 should really provide a fixed rate
1422
* to use here. for now, just use the smallest possible rate
1423
* for the band as a fixed rate for association frames and
1424
* other control messages.
1426
if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))
1427
wl1271_set_band_rate(wl);
1429
wl->basic_rate = wl1271_min_rate_get(wl);
1430
ret = wl1271_acx_rate_policies(wl);
1432
wl1271_warning("rate policy for update channel "
1435
if (test_bit(WL1271_FLAG_JOINED, &wl->flags)) {
1436
ret = wl1271_join(wl, false);
2004
* FIXME: the mac80211 should really provide a fixed
2005
* rate to use here. for now, just use the smallest
2006
* possible rate for the band as a fixed rate for
2007
* association frames and other control messages.
2009
if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))
2010
wl1271_set_band_rate(wl);
2012
wl->basic_rate = wl1271_tx_min_rate_get(wl);
2013
ret = wl1271_acx_sta_rate_policies(wl);
1438
wl1271_warning("cmd join to update channel "
2015
wl1271_warning("rate policy for channel "
1439
2016
"failed %d", ret);
2018
if (test_bit(WL1271_FLAG_JOINED, &wl->flags)) {
2019
ret = wl1271_join(wl, false);
2021
wl1271_warning("cmd join on channel "
1443
if (changed & IEEE80211_CONF_CHANGE_IDLE) {
1444
ret = wl1271_handle_idle(wl, conf->flags & IEEE80211_CONF_IDLE);
2027
if (changed & IEEE80211_CONF_CHANGE_IDLE && !is_ap) {
2028
ret = wl1271_sta_handle_idle(wl,
2029
conf->flags & IEEE80211_CONF_IDLE);
1446
2031
wl1271_warning("idle mode change failed %d", ret);
2183
static int wl1271_record_ap_key(struct wl1271 *wl, u8 id, u8 key_type,
2184
u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32,
2187
struct wl1271_ap_key *ap_key;
2190
wl1271_debug(DEBUG_CRYPT, "record ap key id %d", (int)id);
2192
if (key_size > MAX_KEY_SIZE)
2196
* Find next free entry in ap_keys. Also check we are not replacing
2199
for (i = 0; i < MAX_NUM_KEYS; i++) {
2200
if (wl->recorded_ap_keys[i] == NULL)
2203
if (wl->recorded_ap_keys[i]->id == id) {
2204
wl1271_warning("trying to record key replacement");
2209
if (i == MAX_NUM_KEYS)
2212
ap_key = kzalloc(sizeof(*ap_key), GFP_KERNEL);
2217
ap_key->key_type = key_type;
2218
ap_key->key_size = key_size;
2219
memcpy(ap_key->key, key, key_size);
2220
ap_key->hlid = hlid;
2221
ap_key->tx_seq_32 = tx_seq_32;
2222
ap_key->tx_seq_16 = tx_seq_16;
2224
wl->recorded_ap_keys[i] = ap_key;
2228
static void wl1271_free_ap_keys(struct wl1271 *wl)
2232
for (i = 0; i < MAX_NUM_KEYS; i++) {
2233
kfree(wl->recorded_ap_keys[i]);
2234
wl->recorded_ap_keys[i] = NULL;
2238
static int wl1271_ap_init_hwenc(struct wl1271 *wl)
2241
struct wl1271_ap_key *key;
2242
bool wep_key_added = false;
2244
for (i = 0; i < MAX_NUM_KEYS; i++) {
2245
if (wl->recorded_ap_keys[i] == NULL)
2248
key = wl->recorded_ap_keys[i];
2249
ret = wl1271_cmd_set_ap_key(wl, KEY_ADD_OR_REPLACE,
2250
key->id, key->key_type,
2251
key->key_size, key->key,
2252
key->hlid, key->tx_seq_32,
2257
if (key->key_type == KEY_WEP)
2258
wep_key_added = true;
2261
if (wep_key_added) {
2262
ret = wl1271_cmd_set_ap_default_wep_key(wl, wl->default_key);
2268
wl1271_free_ap_keys(wl);
2272
static int wl1271_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
2273
u8 key_size, const u8 *key, u32 tx_seq_32,
2274
u16 tx_seq_16, struct ieee80211_sta *sta)
2277
bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
2280
struct wl1271_station *wl_sta;
2284
wl_sta = (struct wl1271_station *)sta->drv_priv;
2285
hlid = wl_sta->hlid;
2287
hlid = WL1271_AP_BROADCAST_HLID;
2290
if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) {
2292
* We do not support removing keys after AP shutdown.
2293
* Pretend we do to make mac80211 happy.
2295
if (action != KEY_ADD_OR_REPLACE)
2298
ret = wl1271_record_ap_key(wl, id,
2300
key, hlid, tx_seq_32,
2303
ret = wl1271_cmd_set_ap_key(wl, action,
2304
id, key_type, key_size,
2305
key, hlid, tx_seq_32,
2313
static const u8 bcast_addr[ETH_ALEN] = {
2314
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
2317
addr = sta ? sta->addr : bcast_addr;
2319
if (is_zero_ether_addr(addr)) {
2320
/* We dont support TX only encryption */
2324
/* The wl1271 does not allow to remove unicast keys - they
2325
will be cleared automatically on next CMD_JOIN. Ignore the
2326
request silently, as we dont want the mac80211 to emit
2327
an error message. */
2328
if (action == KEY_REMOVE && !is_broadcast_ether_addr(addr))
2331
ret = wl1271_cmd_set_sta_key(wl, action,
2332
id, key_type, key_size,
2333
key, addr, tx_seq_32,
2338
/* the default WEP key needs to be configured at least once */
2339
if (key_type == KEY_WEP) {
2340
ret = wl1271_cmd_set_sta_default_wep_key(wl,
1596
2350
static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1597
2351
struct ieee80211_vif *vif,
1598
2352
struct ieee80211_sta *sta,
1599
2353
struct ieee80211_key_conf *key_conf)
1601
2355
struct wl1271 *wl = hw->priv;
1604
2357
u32 tx_seq_32 = 0;
1605
2358
u16 tx_seq_16 = 0;
1608
static const u8 bcast_addr[ETH_ALEN] =
1609
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1611
2361
wl1271_debug(DEBUG_MAC80211, "mac80211 set key");
1613
addr = sta ? sta->addr : bcast_addr;
1615
wl1271_debug(DEBUG_CRYPT, "CMD: 0x%x", cmd);
1616
wl1271_dump(DEBUG_CRYPT, "ADDR: ", addr, ETH_ALEN);
2363
wl1271_debug(DEBUG_CRYPT, "CMD: 0x%x sta: %p", cmd, sta);
1617
2364
wl1271_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x",
1618
2365
key_conf->cipher, key_conf->keyidx,
1619
2366
key_conf->keylen, key_conf->flags);
1620
2367
wl1271_dump(DEBUG_CRYPT, "KEY: ", key_conf->key, key_conf->keylen);
1622
if (is_zero_ether_addr(addr)) {
1623
/* We dont support TX only encryption */
1628
2369
mutex_lock(&wl->mutex);
1630
2371
if (unlikely(wl->state == WL1271_STATE_OFF)) {
1674
ret = wl1271_cmd_set_key(wl, KEY_ADD_OR_REPLACE,
1675
key_conf->keyidx, key_type,
1676
key_conf->keylen, key_conf->key,
1677
addr, tx_seq_32, tx_seq_16);
2415
ret = wl1271_set_key(wl, KEY_ADD_OR_REPLACE,
2416
key_conf->keyidx, key_type,
2417
key_conf->keylen, key_conf->key,
2418
tx_seq_32, tx_seq_16, sta);
1679
2420
wl1271_error("Could not add or replace key");
1680
2421
goto out_sleep;
1683
/* the default WEP key needs to be configured at least once */
1684
if (key_type == KEY_WEP) {
1685
ret = wl1271_cmd_set_default_wep_key(wl,
1692
2425
case DISABLE_KEY:
1693
/* The wl1271 does not allow to remove unicast keys - they
1694
will be cleared automatically on next CMD_JOIN. Ignore the
1695
request silently, as we dont want the mac80211 to emit
1696
an error message. */
1697
if (!is_broadcast_ether_addr(addr))
1700
ret = wl1271_cmd_set_key(wl, KEY_REMOVE,
1701
key_conf->keyidx, key_type,
1702
key_conf->keylen, key_conf->key,
2426
ret = wl1271_set_key(wl, KEY_REMOVE,
2427
key_conf->keyidx, key_type,
2428
key_conf->keylen, key_conf->key,
1705
2431
wl1271_error("Could not remove key");
1706
2432
goto out_sleep;
1824
static void wl1271_ssid_set(struct wl1271 *wl, struct sk_buff *skb,
2603
static int wl1271_ssid_set(struct wl1271 *wl, struct sk_buff *skb,
1827
u8 *ptr = skb->data + offset;
1829
/* find the location of the ssid in the beacon */
1830
while (ptr < skb->data + skb->len) {
1831
if (ptr[0] == WLAN_EID_SSID) {
1832
wl->ssid_len = ptr[1];
1833
memcpy(wl->ssid, ptr+2, wl->ssid_len);
1836
ptr += (ptr[1] + 2);
1838
wl1271_error("No SSID in IEs!\n");
2607
const u8 *ptr = cfg80211_find_ie(WLAN_EID_SSID, skb->data + offset,
2611
wl1271_error("No SSID in IEs!");
2616
if (ssid_len > IEEE80211_MAX_SSID_LEN) {
2617
wl1271_error("SSID is too long!");
2621
wl->ssid_len = ssid_len;
2622
memcpy(wl->ssid, ptr+2, ssid_len);
1841
static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
1842
struct ieee80211_vif *vif,
2626
static int wl1271_bss_erp_info_changed(struct wl1271 *wl,
1843
2627
struct ieee80211_bss_conf *bss_conf,
1846
enum wl1271_cmd_ps_mode mode;
1847
struct wl1271 *wl = hw->priv;
1848
struct ieee80211_sta *sta = ieee80211_find_sta(vif, bss_conf->bssid);
1849
bool do_join = false;
1850
bool set_assoc = false;
1853
wl1271_debug(DEBUG_MAC80211, "mac80211 bss info changed");
1855
mutex_lock(&wl->mutex);
1857
if (unlikely(wl->state == WL1271_STATE_OFF))
1860
ret = wl1271_ps_elp_wakeup(wl, false);
1864
if ((changed & BSS_CHANGED_BEACON_INT) &&
1865
(wl->bss_type == BSS_TYPE_IBSS)) {
1866
wl1271_debug(DEBUG_ADHOC, "ad-hoc beacon interval updated: %d",
2632
if (changed & BSS_CHANGED_ERP_SLOT) {
2633
if (bss_conf->use_short_slot)
2634
ret = wl1271_acx_slot(wl, SLOT_TIME_SHORT);
2636
ret = wl1271_acx_slot(wl, SLOT_TIME_LONG);
2638
wl1271_warning("Set slot time failed %d", ret);
2643
if (changed & BSS_CHANGED_ERP_PREAMBLE) {
2644
if (bss_conf->use_short_preamble)
2645
wl1271_acx_set_preamble(wl, ACX_PREAMBLE_SHORT);
2647
wl1271_acx_set_preamble(wl, ACX_PREAMBLE_LONG);
2650
if (changed & BSS_CHANGED_ERP_CTS_PROT) {
2651
if (bss_conf->use_cts_prot)
2652
ret = wl1271_acx_cts_protect(wl, CTSPROTECT_ENABLE);
2654
ret = wl1271_acx_cts_protect(wl, CTSPROTECT_DISABLE);
2656
wl1271_warning("Set ctsprotect failed %d", ret);
2665
static int wl1271_bss_beacon_info_changed(struct wl1271 *wl,
2666
struct ieee80211_vif *vif,
2667
struct ieee80211_bss_conf *bss_conf,
2670
bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
2673
if ((changed & BSS_CHANGED_BEACON_INT)) {
2674
wl1271_debug(DEBUG_MASTER, "beacon interval updated: %d",
1867
2675
bss_conf->beacon_int);
1869
2677
wl->beacon_int = bss_conf->beacon_int;
1873
if ((changed & BSS_CHANGED_BEACON) &&
1874
(wl->bss_type == BSS_TYPE_IBSS)) {
1875
struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
1877
wl1271_debug(DEBUG_ADHOC, "ad-hoc beacon updated");
1880
struct ieee80211_hdr *hdr;
1881
int ieoffset = offsetof(struct ieee80211_mgmt,
1884
wl1271_ssid_set(wl, beacon, ieoffset);
1886
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON,
1889
wl1271_min_rate_get(wl));
1892
dev_kfree_skb(beacon);
1896
hdr = (struct ieee80211_hdr *) beacon->data;
1897
hdr->frame_control = cpu_to_le16(
1898
IEEE80211_FTYPE_MGMT |
1899
IEEE80211_STYPE_PROBE_RESP);
1901
ret = wl1271_cmd_template_set(wl,
1902
CMD_TEMPL_PROBE_RESPONSE,
1905
wl1271_min_rate_get(wl));
1906
dev_kfree_skb(beacon);
2680
if ((changed & BSS_CHANGED_BEACON)) {
2681
struct ieee80211_hdr *hdr;
2682
int ieoffset = offsetof(struct ieee80211_mgmt,
2684
struct sk_buff *beacon = ieee80211_beacon_get(wl->hw, vif);
2690
wl1271_debug(DEBUG_MASTER, "beacon updated");
2692
ret = wl1271_ssid_set(wl, beacon, ieoffset);
2694
dev_kfree_skb(beacon);
2697
tmpl_id = is_ap ? CMD_TEMPL_AP_BEACON :
2699
ret = wl1271_cmd_template_set(wl, tmpl_id,
2702
wl1271_tx_min_rate_get(wl));
2704
dev_kfree_skb(beacon);
2708
hdr = (struct ieee80211_hdr *) beacon->data;
2709
hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2710
IEEE80211_STYPE_PROBE_RESP);
2712
tmpl_id = is_ap ? CMD_TEMPL_AP_PROBE_RESPONSE :
2713
CMD_TEMPL_PROBE_RESPONSE;
2714
ret = wl1271_cmd_template_set(wl,
2718
wl1271_tx_min_rate_get(wl));
2719
dev_kfree_skb(beacon);
2728
/* AP mode changes */
2729
static void wl1271_bss_info_changed_ap(struct wl1271 *wl,
2730
struct ieee80211_vif *vif,
2731
struct ieee80211_bss_conf *bss_conf,
2736
if ((changed & BSS_CHANGED_BASIC_RATES)) {
2737
u32 rates = bss_conf->basic_rates;
2739
wl->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates);
2740
wl->basic_rate = wl1271_tx_min_rate_get(wl);
2742
ret = wl1271_init_ap_rates(wl);
2744
wl1271_error("AP rate policy change failed %d", ret);
2748
ret = wl1271_ap_init_templates(wl);
2753
ret = wl1271_bss_beacon_info_changed(wl, vif, bss_conf, changed);
2757
if ((changed & BSS_CHANGED_BEACON_ENABLED)) {
2758
if (bss_conf->enable_beacon) {
2759
if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) {
2760
ret = wl1271_cmd_start_bss(wl);
2764
set_bit(WL1271_FLAG_AP_STARTED, &wl->flags);
2765
wl1271_debug(DEBUG_AP, "started AP");
2767
ret = wl1271_ap_init_hwenc(wl);
2772
if (test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) {
2773
ret = wl1271_cmd_stop_bss(wl);
2777
clear_bit(WL1271_FLAG_AP_STARTED, &wl->flags);
2778
wl1271_debug(DEBUG_AP, "stopped AP");
2783
if (changed & BSS_CHANGED_IBSS) {
2784
wl1271_debug(DEBUG_ADHOC, "ibss_joined: %d",
2785
bss_conf->ibss_joined);
2787
if (bss_conf->ibss_joined) {
2788
u32 rates = bss_conf->basic_rates;
2789
wl->basic_rate_set = wl1271_tx_enabled_rates_get(wl,
2791
wl->basic_rate = wl1271_tx_min_rate_get(wl);
2793
/* by default, use 11b rates */
2794
wl->rate_set = CONF_TX_IBSS_DEFAULT_RATES;
2795
ret = wl1271_acx_sta_rate_policies(wl);
1910
/* Need to update the SSID (for filtering etc) */
1915
if ((changed & BSS_CHANGED_BEACON_ENABLED) &&
1916
(wl->bss_type == BSS_TYPE_IBSS)) {
2801
ret = wl1271_bss_erp_info_changed(wl, bss_conf, changed);
2808
/* STA/IBSS mode changes */
2809
static void wl1271_bss_info_changed_sta(struct wl1271 *wl,
2810
struct ieee80211_vif *vif,
2811
struct ieee80211_bss_conf *bss_conf,
2814
bool do_join = false, set_assoc = false;
2815
bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS);
2816
u32 sta_rate_set = 0;
2818
struct ieee80211_sta *sta;
2819
bool sta_exists = false;
2820
struct ieee80211_sta_ht_cap sta_ht_cap;
2823
ret = wl1271_bss_beacon_info_changed(wl, vif, bss_conf,
2829
if ((changed & BSS_CHANGED_BEACON_INT) && is_ibss)
2832
/* Need to update the SSID (for filtering etc) */
2833
if ((changed & BSS_CHANGED_BEACON) && is_ibss)
2836
if ((changed & BSS_CHANGED_BEACON_ENABLED) && is_ibss) {
1917
2837
wl1271_debug(DEBUG_ADHOC, "ad-hoc beaconing: %s",
1918
2838
bss_conf->enable_beacon ? "enabled" : "disabled");
1942
2862
* and enable the BSSID filter
1944
2864
memcmp(wl->bssid, bss_conf->bssid, ETH_ALEN)) {
1945
memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
2865
memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
2867
if (!is_zero_ether_addr(wl->bssid)) {
1947
2868
ret = wl1271_cmd_build_null_data(wl);
1951
2872
ret = wl1271_build_qos_null_data(wl);
1955
2876
/* filter out all packets not from this BSSID */
1956
2877
wl1271_configure_filters(wl, 0);
1958
2879
/* Need to update the BSSID (for filtering etc) */
1959
2880
do_join = true;
1962
if (changed & BSS_CHANGED_ASSOC) {
2885
sta = ieee80211_find_sta(vif, bss_conf->bssid);
2887
/* save the supp_rates of the ap */
2888
sta_rate_set = sta->supp_rates[wl->hw->conf.channel->band];
2889
if (sta->ht_cap.ht_supported)
2891
(sta->ht_cap.mcs.rx_mask[0] << HW_HT_RATES_OFFSET);
2892
sta_ht_cap = sta->ht_cap;
2898
/* handle new association with HT and HT information change */
2899
if ((changed & BSS_CHANGED_HT) &&
2900
(bss_conf->channel_type != NL80211_CHAN_NO_HT)) {
2901
ret = wl1271_acx_set_ht_capabilities(wl, &sta_ht_cap,
2904
wl1271_warning("Set ht cap true failed %d",
2908
ret = wl1271_acx_set_ht_information(wl,
2909
bss_conf->ht_operation_mode);
2911
wl1271_warning("Set ht information failed %d",
2916
/* handle new association without HT and disassociation */
2917
else if (changed & BSS_CHANGED_ASSOC) {
2918
ret = wl1271_acx_set_ht_capabilities(wl, &sta_ht_cap,
2921
wl1271_warning("Set ht cap false failed %d",
2928
if ((changed & BSS_CHANGED_ASSOC)) {
1963
2929
if (bss_conf->assoc) {
2040
3013
/* Disable the keep-alive feature */
2041
3014
ret = wl1271_acx_keep_alive_mode(wl, false);
2045
3018
/* restore the bssid filter and go to dummy bssid */
2047
wl1271_dummy_join(wl);
2052
if (changed & BSS_CHANGED_ERP_SLOT) {
2053
if (bss_conf->use_short_slot)
2054
ret = wl1271_acx_slot(wl, SLOT_TIME_SHORT);
2056
ret = wl1271_acx_slot(wl, SLOT_TIME_LONG);
2058
wl1271_warning("Set slot time failed %d", ret);
2063
if (changed & BSS_CHANGED_ERP_PREAMBLE) {
2064
if (bss_conf->use_short_preamble)
2065
wl1271_acx_set_preamble(wl, ACX_PREAMBLE_SHORT);
2067
wl1271_acx_set_preamble(wl, ACX_PREAMBLE_LONG);
2070
if (changed & BSS_CHANGED_ERP_CTS_PROT) {
2071
if (bss_conf->use_cts_prot)
2072
ret = wl1271_acx_cts_protect(wl, CTSPROTECT_ENABLE);
2074
ret = wl1271_acx_cts_protect(wl, CTSPROTECT_DISABLE);
2076
wl1271_warning("Set ctsprotect failed %d", ret);
2082
* Takes care of: New association with HT enable,
2083
* HT information change in beacon.
2086
(changed & BSS_CHANGED_HT) &&
2087
(bss_conf->channel_type != NL80211_CHAN_NO_HT)) {
2088
ret = wl1271_acx_set_ht_capabilities(wl, &sta->ht_cap, true);
2090
wl1271_warning("Set ht cap true failed %d", ret);
2093
ret = wl1271_acx_set_ht_information(wl,
2094
bss_conf->ht_operation_mode);
2096
wl1271_warning("Set ht information failed %d", ret);
2101
* Takes care of: New association without HT,
2104
else if (sta && (changed & BSS_CHANGED_ASSOC)) {
2105
ret = wl1271_acx_set_ht_capabilities(wl, &sta->ht_cap, false);
2107
wl1271_warning("Set ht cap false failed %d", ret);
3021
wl1271_dummy_join(wl);
3026
ret = wl1271_bss_erp_info_changed(wl, bss_conf, changed);
2112
3030
if (changed & BSS_CHANGED_ARP_FILTER) {
2113
3031
__be32 addr = bss_conf->arp_addr_list[0];
2159
3105
struct wl1271 *wl = hw->priv;
2163
3109
mutex_lock(&wl->mutex);
2165
3111
wl1271_debug(DEBUG_MAC80211, "mac80211 conf tx %d", queue);
2167
if (unlikely(wl->state == WL1271_STATE_OFF)) {
3114
ps_scheme = CONF_PS_SCHEME_UPSD_TRIGGER;
3116
ps_scheme = CONF_PS_SCHEME_LEGACY;
3118
if (wl->state == WL1271_STATE_OFF) {
3120
* If the state is off, the parameters will be recorded and
3121
* configured on init. This happens in AP-mode.
3123
struct conf_tx_ac_category *conf_ac =
3124
&wl->conf.tx.ac_conf[wl1271_tx_get_queue(queue)];
3125
struct conf_tx_tid *conf_tid =
3126
&wl->conf.tx.tid_conf[wl1271_tx_get_queue(queue)];
3128
conf_ac->ac = wl1271_tx_get_queue(queue);
3129
conf_ac->cw_min = (u8)params->cw_min;
3130
conf_ac->cw_max = params->cw_max;
3131
conf_ac->aifsn = params->aifs;
3132
conf_ac->tx_op_limit = params->txop << 5;
3134
conf_tid->queue_id = wl1271_tx_get_queue(queue);
3135
conf_tid->channel_type = CONF_CHANNEL_TYPE_EDCF;
3136
conf_tid->tsid = wl1271_tx_get_queue(queue);
3137
conf_tid->ps_scheme = ps_scheme;
3138
conf_tid->ack_policy = CONF_ACK_POLICY_LEGACY;
3139
conf_tid->apsd_conf[0] = 0;
3140
conf_tid->apsd_conf[1] = 0;
2172
ret = wl1271_ps_elp_wakeup(wl, false);
3144
ret = wl1271_ps_elp_wakeup(wl);
2176
/* the txop is confed in units of 32us by the mac80211, we need us */
3149
* the txop is confed in units of 32us by the mac80211,
2177
3152
ret = wl1271_acx_ac_cfg(wl, wl1271_tx_get_queue(queue),
2178
3153
params->cw_min, params->cw_max,
2179
3154
params->aifs, params->txop << 5);
2181
3156
goto out_sleep;
2184
ps_scheme = CONF_PS_SCHEME_UPSD_TRIGGER;
2186
ps_scheme = CONF_PS_SCHEME_LEGACY;
2188
3158
ret = wl1271_acx_tid_cfg(wl, wl1271_tx_get_queue(queue),
2189
3159
CONF_CHANNEL_TYPE_EDCF,
2190
3160
wl1271_tx_get_queue(queue),
2191
ps_scheme, CONF_ACK_POLICY_LEGACY, 0, 0);
3161
ps_scheme, CONF_ACK_POLICY_LEGACY,
2196
3165
wl1271_ps_elp_sleep(wl);
3219
static int wl1271_allocate_sta(struct wl1271 *wl,
3220
struct ieee80211_sta *sta,
3223
struct wl1271_station *wl_sta;
3226
id = find_first_zero_bit(wl->ap_hlid_map, AP_MAX_STATIONS);
3227
if (id >= AP_MAX_STATIONS) {
3228
wl1271_warning("could not allocate HLID - too much stations");
3232
wl_sta = (struct wl1271_station *)sta->drv_priv;
3233
__set_bit(id, wl->ap_hlid_map);
3234
wl_sta->hlid = WL1271_AP_STA_HLID_START + id;
3235
*hlid = wl_sta->hlid;
3236
memcpy(wl->links[wl_sta->hlid].addr, sta->addr, ETH_ALEN);
3240
static void wl1271_free_sta(struct wl1271 *wl, u8 hlid)
3242
int id = hlid - WL1271_AP_STA_HLID_START;
3244
if (WARN_ON(!test_bit(id, wl->ap_hlid_map)))
3247
__clear_bit(id, wl->ap_hlid_map);
3248
memset(wl->links[hlid].addr, 0, ETH_ALEN);
3249
wl1271_tx_reset_link_queues(wl, hlid);
3250
__clear_bit(hlid, &wl->ap_ps_map);
3251
__clear_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map);
3254
static int wl1271_op_sta_add(struct ieee80211_hw *hw,
3255
struct ieee80211_vif *vif,
3256
struct ieee80211_sta *sta)
3258
struct wl1271 *wl = hw->priv;
3262
mutex_lock(&wl->mutex);
3264
if (unlikely(wl->state == WL1271_STATE_OFF))
3267
if (wl->bss_type != BSS_TYPE_AP_BSS)
3270
wl1271_debug(DEBUG_MAC80211, "mac80211 add sta %d", (int)sta->aid);
3272
ret = wl1271_allocate_sta(wl, sta, &hlid);
3276
ret = wl1271_ps_elp_wakeup(wl);
3280
ret = wl1271_cmd_add_sta(wl, sta, hlid);
3285
wl1271_ps_elp_sleep(wl);
3289
wl1271_free_sta(wl, hlid);
3292
mutex_unlock(&wl->mutex);
3296
static int wl1271_op_sta_remove(struct ieee80211_hw *hw,
3297
struct ieee80211_vif *vif,
3298
struct ieee80211_sta *sta)
3300
struct wl1271 *wl = hw->priv;
3301
struct wl1271_station *wl_sta;
3304
mutex_lock(&wl->mutex);
3306
if (unlikely(wl->state == WL1271_STATE_OFF))
3309
if (wl->bss_type != BSS_TYPE_AP_BSS)
3312
wl1271_debug(DEBUG_MAC80211, "mac80211 remove sta %d", (int)sta->aid);
3314
wl_sta = (struct wl1271_station *)sta->drv_priv;
3315
id = wl_sta->hlid - WL1271_AP_STA_HLID_START;
3316
if (WARN_ON(!test_bit(id, wl->ap_hlid_map)))
3319
ret = wl1271_ps_elp_wakeup(wl);
3323
ret = wl1271_cmd_remove_sta(wl, wl_sta->hlid);
3327
wl1271_free_sta(wl, wl_sta->hlid);
3330
wl1271_ps_elp_sleep(wl);
3333
mutex_unlock(&wl->mutex);
3337
static int wl1271_op_ampdu_action(struct ieee80211_hw *hw,
3338
struct ieee80211_vif *vif,
3339
enum ieee80211_ampdu_mlme_action action,
3340
struct ieee80211_sta *sta, u16 tid, u16 *ssn,
3343
struct wl1271 *wl = hw->priv;
3346
mutex_lock(&wl->mutex);
3348
if (unlikely(wl->state == WL1271_STATE_OFF)) {
3353
ret = wl1271_ps_elp_wakeup(wl);
3358
case IEEE80211_AMPDU_RX_START:
3359
if (wl->ba_support) {
3360
ret = wl1271_acx_set_ba_receiver_session(wl, tid, *ssn,
3363
wl->ba_rx_bitmap |= BIT(tid);
3369
case IEEE80211_AMPDU_RX_STOP:
3370
ret = wl1271_acx_set_ba_receiver_session(wl, tid, 0, false);
3372
wl->ba_rx_bitmap &= ~BIT(tid);
3376
* The BA initiator session management in FW independently.
3377
* Falling break here on purpose for all TX APDU commands.
3379
case IEEE80211_AMPDU_TX_START:
3380
case IEEE80211_AMPDU_TX_STOP:
3381
case IEEE80211_AMPDU_TX_OPERATIONAL:
3386
wl1271_error("Incorrect ampdu action id=%x\n", action);
3390
wl1271_ps_elp_sleep(wl);
3393
mutex_unlock(&wl->mutex);
3398
static bool wl1271_tx_frames_pending(struct ieee80211_hw *hw)
3400
struct wl1271 *wl = hw->priv;
3403
mutex_lock(&wl->mutex);
3405
if (unlikely(wl->state == WL1271_STATE_OFF))
3408
/* packets are considered pending if in the TX queue or the FW */
3409
ret = (wl->tx_queue_count > 0) || (wl->tx_frames_cnt > 0);
3411
/* the above is appropriate for STA mode for PS purposes */
3412
WARN_ON(wl->bss_type != BSS_TYPE_STA_BSS);
3415
mutex_unlock(&wl->mutex);
2250
3420
/* can't be const, mac80211 writes to this */
2251
3421
static struct ieee80211_rate wl1271_rates[] = {
2252
3422
{ .bitrate = 10,
2481
3653
.stop = wl1271_op_stop,
2482
3654
.add_interface = wl1271_op_add_interface,
2483
3655
.remove_interface = wl1271_op_remove_interface,
3657
.suspend = wl1271_op_suspend,
3658
.resume = wl1271_op_resume,
2484
3660
.config = wl1271_op_config,
2485
3661
.prepare_multicast = wl1271_op_prepare_multicast,
2486
3662
.configure_filter = wl1271_op_configure_filter,
2487
3663
.tx = wl1271_op_tx,
2488
3664
.set_key = wl1271_op_set_key,
2489
3665
.hw_scan = wl1271_op_hw_scan,
3666
.sched_scan_start = wl1271_op_sched_scan_start,
3667
.sched_scan_stop = wl1271_op_sched_scan_stop,
2490
3668
.bss_info_changed = wl1271_op_bss_info_changed,
2491
3669
.set_frag_threshold = wl1271_op_set_frag_threshold,
2492
3670
.set_rts_threshold = wl1271_op_set_rts_threshold,
2493
3671
.conf_tx = wl1271_op_conf_tx,
2494
3672
.get_tsf = wl1271_op_get_tsf,
2495
3673
.get_survey = wl1271_op_get_survey,
3674
.sta_add = wl1271_op_sta_add,
3675
.sta_remove = wl1271_op_sta_remove,
3676
.ampdu_action = wl1271_op_ampdu_action,
3677
.tx_frames_pending = wl1271_tx_frames_pending,
2496
3678
CFG80211_TESTMODE_CMD(wl1271_tm_cmd)