diff options
author | Reinette Chatre <reinette.chatre@intel.com> | 2010-02-22 19:24:47 -0500 |
---|---|---|
committer | Reinette Chatre <reinette.chatre@intel.com> | 2010-03-19 16:40:58 -0400 |
commit | fe6b23dd361199bfbc50b0cbce6bed37c5797c75 (patch) | |
tree | 96acb9c114342d7dc731310159dc4195248d115e /drivers | |
parent | 7e2461910e9115c9964975f77584baf8c2f76bfe (diff) |
iwlwifi: implement new mac80211 station add/remove calls
mac80211 recently implemented two new callbacks that are used to request
station add/remove from the driver. The benefot from these new callbacks
are that they enable the driver to sleep while performing this work.
This is a big patch since a few things need to be coordinated in this move.
First we need to decouple station management from rate scaling, which
caused a lot of code to be moved and/or deleted. Next we needed to tie in
with mac80211's station management callback and let it direct our station
management as well as trigger the rate scaling initialization.
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-rs.c | 83 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945.c | 10 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 120 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn-rs.h | 7 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn.c | 95 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-core.c | 1 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-core.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-dev.h | 8 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-sta.c | 528 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-sta.h | 11 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 45 |
12 files changed, 522 insertions, 389 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c index b588cb69536a..605aca4c78c8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c | |||
@@ -329,16 +329,25 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, | |||
329 | 329 | ||
330 | } | 330 | } |
331 | 331 | ||
332 | static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, | 332 | /* |
333 | struct ieee80211_sta *sta, void *priv_sta) | 333 | * Called after adding a new station to initialize rate scaling |
334 | */ | ||
335 | void iwl3945_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_id) | ||
334 | { | 336 | { |
335 | struct iwl3945_rs_sta *rs_sta = priv_sta; | 337 | struct ieee80211_hw *hw = priv->hw; |
336 | struct iwl_priv *priv = (struct iwl_priv *)priv_r; | 338 | struct ieee80211_conf *conf = &priv->hw->conf; |
339 | struct iwl3945_sta_priv *psta; | ||
340 | struct iwl3945_rs_sta *rs_sta; | ||
341 | struct ieee80211_supported_band *sband; | ||
337 | int i; | 342 | int i; |
338 | 343 | ||
339 | IWL_DEBUG_RATE(priv, "enter\n"); | 344 | IWL_DEBUG_INFO(priv, "enter \n"); |
345 | if (sta_id == priv->hw_params.bcast_sta_id) | ||
346 | goto out; | ||
340 | 347 | ||
341 | spin_lock_init(&rs_sta->lock); | 348 | psta = (struct iwl3945_sta_priv *) sta->drv_priv; |
349 | rs_sta = &psta->rs_sta; | ||
350 | sband = hw->wiphy->bands[conf->channel->band]; | ||
342 | 351 | ||
343 | rs_sta->priv = priv; | 352 | rs_sta->priv = priv; |
344 | 353 | ||
@@ -351,9 +360,7 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, | |||
351 | rs_sta->last_flush = jiffies; | 360 | rs_sta->last_flush = jiffies; |
352 | rs_sta->flush_time = IWL_RATE_FLUSH; | 361 | rs_sta->flush_time = IWL_RATE_FLUSH; |
353 | rs_sta->last_tx_packets = 0; | 362 | rs_sta->last_tx_packets = 0; |
354 | rs_sta->ibss_sta_added = 0; | ||
355 | 363 | ||
356 | init_timer(&rs_sta->rate_scale_flush); | ||
357 | rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; | 364 | rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; |
358 | rs_sta->rate_scale_flush.function = iwl3945_bg_rate_scale_flush; | 365 | rs_sta->rate_scale_flush.function = iwl3945_bg_rate_scale_flush; |
359 | 366 | ||
@@ -380,8 +387,10 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, | |||
380 | IWL_FIRST_OFDM_RATE; | 387 | IWL_FIRST_OFDM_RATE; |
381 | } | 388 | } |
382 | 389 | ||
390 | out: | ||
391 | priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; | ||
383 | 392 | ||
384 | IWL_DEBUG_RATE(priv, "leave\n"); | 393 | IWL_DEBUG_INFO(priv, "leave\n"); |
385 | } | 394 | } |
386 | 395 | ||
387 | static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) | 396 | static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) |
@@ -405,6 +414,9 @@ static void *rs_alloc_sta(void *iwl_priv, struct ieee80211_sta *sta, gfp_t gfp) | |||
405 | 414 | ||
406 | rs_sta = &psta->rs_sta; | 415 | rs_sta = &psta->rs_sta; |
407 | 416 | ||
417 | spin_lock_init(&rs_sta->lock); | ||
418 | init_timer(&rs_sta->rate_scale_flush); | ||
419 | |||
408 | IWL_DEBUG_RATE(priv, "leave\n"); | 420 | IWL_DEBUG_RATE(priv, "leave\n"); |
409 | 421 | ||
410 | return rs_sta; | 422 | return rs_sta; |
@@ -413,13 +425,14 @@ static void *rs_alloc_sta(void *iwl_priv, struct ieee80211_sta *sta, gfp_t gfp) | |||
413 | static void rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta, | 425 | static void rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta, |
414 | void *priv_sta) | 426 | void *priv_sta) |
415 | { | 427 | { |
416 | struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; | 428 | struct iwl3945_rs_sta *rs_sta = priv_sta; |
417 | struct iwl3945_rs_sta *rs_sta = &psta->rs_sta; | ||
418 | struct iwl_priv *priv __maybe_unused = rs_sta->priv; | ||
419 | 429 | ||
420 | IWL_DEBUG_RATE(priv, "enter\n"); | 430 | /* |
431 | * Be careful not to use any members of iwl3945_rs_sta (like trying | ||
432 | * to use iwl_priv to print out debugging) since it may not be fully | ||
433 | * initialized at this point. | ||
434 | */ | ||
421 | del_timer_sync(&rs_sta->rate_scale_flush); | 435 | del_timer_sync(&rs_sta->rate_scale_flush); |
422 | IWL_DEBUG_RATE(priv, "leave\n"); | ||
423 | } | 436 | } |
424 | 437 | ||
425 | 438 | ||
@@ -458,6 +471,13 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband | |||
458 | return; | 471 | return; |
459 | } | 472 | } |
460 | 473 | ||
474 | /* Treat uninitialized rate scaling data same as non-existing. */ | ||
475 | if (!rs_sta->priv) { | ||
476 | IWL_DEBUG_RATE(priv, "leave: STA priv data uninitialized!\n"); | ||
477 | return; | ||
478 | } | ||
479 | |||
480 | |||
461 | rs_sta->tx_packets++; | 481 | rs_sta->tx_packets++; |
462 | 482 | ||
463 | scale_rate_index = first_index; | 483 | scale_rate_index = first_index; |
@@ -625,7 +645,6 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, | |||
625 | u32 fail_count; | 645 | u32 fail_count; |
626 | s8 scale_action = 0; | 646 | s8 scale_action = 0; |
627 | unsigned long flags; | 647 | unsigned long flags; |
628 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
629 | u16 rate_mask = sta ? sta->supp_rates[sband->band] : 0; | 648 | u16 rate_mask = sta ? sta->supp_rates[sband->band] : 0; |
630 | s8 max_rate_idx = -1; | 649 | s8 max_rate_idx = -1; |
631 | struct iwl_priv *priv = (struct iwl_priv *)priv_r; | 650 | struct iwl_priv *priv = (struct iwl_priv *)priv_r; |
@@ -633,6 +652,12 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, | |||
633 | 652 | ||
634 | IWL_DEBUG_RATE(priv, "enter\n"); | 653 | IWL_DEBUG_RATE(priv, "enter\n"); |
635 | 654 | ||
655 | /* Treat uninitialized rate scaling data same as non-existing. */ | ||
656 | if (rs_sta && !rs_sta->priv) { | ||
657 | IWL_DEBUG_RATE(priv, "Rate scaling information not initialized yet.\n"); | ||
658 | priv_sta = NULL; | ||
659 | } | ||
660 | |||
636 | if (rate_control_send_low(sta, priv_sta, txrc)) | 661 | if (rate_control_send_low(sta, priv_sta, txrc)) |
637 | return; | 662 | return; |
638 | 663 | ||
@@ -650,20 +675,6 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, | |||
650 | if (sband->band == IEEE80211_BAND_5GHZ) | 675 | if (sband->band == IEEE80211_BAND_5GHZ) |
651 | rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; | 676 | rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; |
652 | 677 | ||
653 | if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && | ||
654 | !rs_sta->ibss_sta_added) { | ||
655 | u8 sta_id = iwl_find_station(priv, hdr->addr1); | ||
656 | |||
657 | if (sta_id == IWL_INVALID_STATION) { | ||
658 | IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", | ||
659 | hdr->addr1); | ||
660 | sta_id = iwl_add_station(priv, hdr->addr1, false, | ||
661 | CMD_ASYNC, NULL); | ||
662 | } | ||
663 | if (sta_id != IWL_INVALID_STATION) | ||
664 | rs_sta->ibss_sta_added = 1; | ||
665 | } | ||
666 | |||
667 | spin_lock_irqsave(&rs_sta->lock, flags); | 678 | spin_lock_irqsave(&rs_sta->lock, flags); |
668 | 679 | ||
669 | /* for recent assoc, choose best rate regarding | 680 | /* for recent assoc, choose best rate regarding |
@@ -883,12 +894,22 @@ static void iwl3945_remove_debugfs(void *priv, void *priv_sta) | |||
883 | } | 894 | } |
884 | #endif | 895 | #endif |
885 | 896 | ||
897 | /* | ||
898 | * Initialization of rate scaling information is done by driver after | ||
899 | * the station is added. Since mac80211 calls this function before a | ||
900 | * station is added we ignore it. | ||
901 | */ | ||
902 | static void rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband, | ||
903 | struct ieee80211_sta *sta, void *priv_sta) | ||
904 | { | ||
905 | } | ||
906 | |||
886 | static struct rate_control_ops rs_ops = { | 907 | static struct rate_control_ops rs_ops = { |
887 | .module = NULL, | 908 | .module = NULL, |
888 | .name = RS_NAME, | 909 | .name = RS_NAME, |
889 | .tx_status = rs_tx_status, | 910 | .tx_status = rs_tx_status, |
890 | .get_rate = rs_get_rate, | 911 | .get_rate = rs_get_rate, |
891 | .rate_init = rs_rate_init, | 912 | .rate_init = rs_rate_init_stub, |
892 | .alloc = rs_alloc, | 913 | .alloc = rs_alloc, |
893 | .free = rs_free, | 914 | .free = rs_free, |
894 | .alloc_sta = rs_alloc_sta, | 915 | .alloc_sta = rs_alloc_sta, |
@@ -899,7 +920,6 @@ static struct rate_control_ops rs_ops = { | |||
899 | #endif | 920 | #endif |
900 | 921 | ||
901 | }; | 922 | }; |
902 | |||
903 | void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | 923 | void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) |
904 | { | 924 | { |
905 | struct iwl_priv *priv = hw->priv; | 925 | struct iwl_priv *priv = hw->priv; |
@@ -916,6 +936,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | |||
916 | sta = ieee80211_find_sta(priv->vif, | 936 | sta = ieee80211_find_sta(priv->vif, |
917 | priv->stations[sta_id].sta.sta.addr); | 937 | priv->stations[sta_id].sta.sta.addr); |
918 | if (!sta) { | 938 | if (!sta) { |
939 | IWL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n"); | ||
919 | rcu_read_unlock(); | 940 | rcu_read_unlock(); |
920 | return; | 941 | return; |
921 | } | 942 | } |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c index 7f95f9019093..11785e2c767a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c | |||
@@ -1956,16 +1956,6 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv) | |||
1956 | return rc; | 1956 | return rc; |
1957 | } | 1957 | } |
1958 | 1958 | ||
1959 | /* If we have set the ASSOC_MSK and we are in BSS mode then | ||
1960 | * add the IWL_AP_ID to the station rate table */ | ||
1961 | if (iwl_is_associated(priv) && | ||
1962 | (priv->iw_mode == NL80211_IFTYPE_STATION)) | ||
1963 | if (iwl_add_station(priv, priv->active_rxon.bssid_addr, | ||
1964 | true, CMD_SYNC, NULL) == IWL_INVALID_STATION) { | ||
1965 | IWL_ERR(priv, "Error adding AP address for transmit\n"); | ||
1966 | return -EIO; | ||
1967 | } | ||
1968 | |||
1969 | /* Init the hardware's rate fallback order based on the band */ | 1959 | /* Init the hardware's rate fallback order based on the band */ |
1970 | rc = iwl3945_init_hw_rate_table(priv); | 1960 | rc = iwl3945_init_hw_rate_table(priv); |
1971 | if (rc) { | 1961 | if (rc) { |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h index 452dfd5456c6..b89219573b91 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.h +++ b/drivers/net/wireless/iwlwifi/iwl-3945.h | |||
@@ -95,7 +95,6 @@ struct iwl3945_rs_sta { | |||
95 | u8 tgg; | 95 | u8 tgg; |
96 | u8 flush_pending; | 96 | u8 flush_pending; |
97 | u8 start_rate; | 97 | u8 start_rate; |
98 | u8 ibss_sta_added; | ||
99 | struct timer_list rate_scale_flush; | 98 | struct timer_list rate_scale_flush; |
100 | struct iwl3945_rate_scale_data win[IWL_RATE_COUNT_3945]; | 99 | struct iwl3945_rate_scale_data win[IWL_RATE_COUNT_3945]; |
101 | #ifdef CONFIG_MAC80211_DEBUGFS | 100 | #ifdef CONFIG_MAC80211_DEBUGFS |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 84271cc62afa..970eec82d106 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c | |||
@@ -769,6 +769,15 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, | |||
769 | 769 | ||
770 | IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n"); | 770 | IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n"); |
771 | 771 | ||
772 | /* Treat uninitialized rate scaling data same as non-existing. */ | ||
773 | if (!lq_sta) { | ||
774 | IWL_DEBUG_RATE(priv, "Station rate scaling not created yet.\n"); | ||
775 | return; | ||
776 | } else if (!lq_sta->drv) { | ||
777 | IWL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); | ||
778 | return; | ||
779 | } | ||
780 | |||
772 | if (!ieee80211_is_data(hdr->frame_control) || | 781 | if (!ieee80211_is_data(hdr->frame_control) || |
773 | info->flags & IEEE80211_TX_CTL_NO_ACK) | 782 | info->flags & IEEE80211_TX_CTL_NO_ACK) |
774 | return; | 783 | return; |
@@ -778,10 +787,6 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, | |||
778 | !(info->flags & IEEE80211_TX_STAT_AMPDU)) | 787 | !(info->flags & IEEE80211_TX_STAT_AMPDU)) |
779 | return; | 788 | return; |
780 | 789 | ||
781 | if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && | ||
782 | !lq_sta->ibss_sta_added) | ||
783 | return; | ||
784 | |||
785 | /* | 790 | /* |
786 | * Ignore this Tx frame response if its initial rate doesn't match | 791 | * Ignore this Tx frame response if its initial rate doesn't match |
787 | * that of latest Link Quality command. There may be stragglers | 792 | * that of latest Link Quality command. There may be stragglers |
@@ -827,7 +832,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, | |||
827 | lq_sta->missed_rate_counter++; | 832 | lq_sta->missed_rate_counter++; |
828 | if (lq_sta->missed_rate_counter > IWL_MISSED_RATE_MAX) { | 833 | if (lq_sta->missed_rate_counter > IWL_MISSED_RATE_MAX) { |
829 | lq_sta->missed_rate_counter = 0; | 834 | lq_sta->missed_rate_counter = 0; |
830 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); | 835 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC, false); |
831 | } | 836 | } |
832 | /* Regardless, ignore this status info for outdated rate */ | 837 | /* Regardless, ignore this status info for outdated rate */ |
833 | return; | 838 | return; |
@@ -1915,7 +1920,7 @@ static u32 rs_update_rate_tbl(struct iwl_priv *priv, | |||
1915 | /* Update uCode's rate table. */ | 1920 | /* Update uCode's rate table. */ |
1916 | rate = rate_n_flags_from_tbl(priv, tbl, index, is_green); | 1921 | rate = rate_n_flags_from_tbl(priv, tbl, index, is_green); |
1917 | rs_fill_link_cmd(priv, lq_sta, rate); | 1922 | rs_fill_link_cmd(priv, lq_sta, rate); |
1918 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); | 1923 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC, false); |
1919 | 1924 | ||
1920 | return rate; | 1925 | return rate; |
1921 | } | 1926 | } |
@@ -2291,7 +2296,7 @@ lq_update: | |||
2291 | IWL_DEBUG_RATE(priv, "Switch current mcs: %X index: %d\n", | 2296 | IWL_DEBUG_RATE(priv, "Switch current mcs: %X index: %d\n", |
2292 | tbl->current_rate, index); | 2297 | tbl->current_rate, index); |
2293 | rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); | 2298 | rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); |
2294 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); | 2299 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC, false); |
2295 | } else | 2300 | } else |
2296 | done_search = 1; | 2301 | done_search = 1; |
2297 | } | 2302 | } |
@@ -2340,7 +2345,20 @@ out: | |||
2340 | return; | 2345 | return; |
2341 | } | 2346 | } |
2342 | 2347 | ||
2343 | 2348 | /** | |
2349 | * rs_initialize_lq - Initialize a station's hardware rate table | ||
2350 | * | ||
2351 | * The uCode's station table contains a table of fallback rates | ||
2352 | * for automatic fallback during transmission. | ||
2353 | * | ||
2354 | * NOTE: This sets up a default set of values. These will be replaced later | ||
2355 | * if the driver's iwl-agn-rs rate scaling algorithm is used, instead of | ||
2356 | * rc80211_simple. | ||
2357 | * | ||
2358 | * NOTE: Run REPLY_ADD_STA command to set up station table entry, before | ||
2359 | * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, | ||
2360 | * which requires station table entry to exist). | ||
2361 | */ | ||
2344 | static void rs_initialize_lq(struct iwl_priv *priv, | 2362 | static void rs_initialize_lq(struct iwl_priv *priv, |
2345 | struct ieee80211_conf *conf, | 2363 | struct ieee80211_conf *conf, |
2346 | struct ieee80211_sta *sta, | 2364 | struct ieee80211_sta *sta, |
@@ -2390,7 +2408,8 @@ static void rs_initialize_lq(struct iwl_priv *priv, | |||
2390 | tbl->current_rate = rate; | 2408 | tbl->current_rate = rate; |
2391 | rs_set_expected_tpt_table(lq_sta, tbl); | 2409 | rs_set_expected_tpt_table(lq_sta, tbl); |
2392 | rs_fill_link_cmd(NULL, lq_sta, rate); | 2410 | rs_fill_link_cmd(NULL, lq_sta, rate); |
2393 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); | 2411 | priv->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; |
2412 | iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_SYNC, true); | ||
2394 | out: | 2413 | out: |
2395 | return; | 2414 | return; |
2396 | } | 2415 | } |
@@ -2402,9 +2421,6 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, | |||
2402 | struct sk_buff *skb = txrc->skb; | 2421 | struct sk_buff *skb = txrc->skb; |
2403 | struct ieee80211_supported_band *sband = txrc->sband; | 2422 | struct ieee80211_supported_band *sband = txrc->sband; |
2404 | struct iwl_priv *priv = (struct iwl_priv *)priv_r; | 2423 | struct iwl_priv *priv = (struct iwl_priv *)priv_r; |
2405 | struct ieee80211_conf *conf = &priv->hw->conf; | ||
2406 | struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; | ||
2407 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
2408 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 2424 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
2409 | struct iwl_lq_sta *lq_sta = priv_sta; | 2425 | struct iwl_lq_sta *lq_sta = priv_sta; |
2410 | int rate_idx; | 2426 | int rate_idx; |
@@ -2422,30 +2438,18 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, | |||
2422 | lq_sta->max_rate_idx = -1; | 2438 | lq_sta->max_rate_idx = -1; |
2423 | } | 2439 | } |
2424 | 2440 | ||
2441 | /* Treat uninitialized rate scaling data same as non-existing. */ | ||
2442 | if (lq_sta && !lq_sta->drv) { | ||
2443 | IWL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); | ||
2444 | priv_sta = NULL; | ||
2445 | } | ||
2446 | |||
2425 | /* Send management frames and NO_ACK data using lowest rate. */ | 2447 | /* Send management frames and NO_ACK data using lowest rate. */ |
2426 | if (rate_control_send_low(sta, priv_sta, txrc)) | 2448 | if (rate_control_send_low(sta, priv_sta, txrc)) |
2427 | return; | 2449 | return; |
2428 | 2450 | ||
2429 | rate_idx = lq_sta->last_txrate_idx; | 2451 | rate_idx = lq_sta->last_txrate_idx; |
2430 | 2452 | ||
2431 | if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && | ||
2432 | !lq_sta->ibss_sta_added) { | ||
2433 | u8 sta_id = iwl_find_station(priv, hdr->addr1); | ||
2434 | |||
2435 | if (sta_id == IWL_INVALID_STATION) { | ||
2436 | IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", | ||
2437 | hdr->addr1); | ||
2438 | sta_id = iwl_add_station(priv, hdr->addr1, | ||
2439 | false, CMD_ASYNC, ht_cap); | ||
2440 | } | ||
2441 | if ((sta_id != IWL_INVALID_STATION)) { | ||
2442 | lq_sta->lq.sta_id = sta_id; | ||
2443 | lq_sta->lq.rs_table[0].rate_n_flags = 0; | ||
2444 | lq_sta->ibss_sta_added = 1; | ||
2445 | rs_initialize_lq(priv, conf, sta, lq_sta); | ||
2446 | } | ||
2447 | } | ||
2448 | |||
2449 | if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { | 2453 | if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { |
2450 | rate_idx -= IWL_FIRST_OFDM_RATE; | 2454 | rate_idx -= IWL_FIRST_OFDM_RATE; |
2451 | /* 6M and 9M shared same MCS index */ | 2455 | /* 6M and 9M shared same MCS index */ |
@@ -2495,16 +2499,25 @@ static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, | |||
2495 | return lq_sta; | 2499 | return lq_sta; |
2496 | } | 2500 | } |
2497 | 2501 | ||
2498 | static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, | 2502 | /* |
2499 | struct ieee80211_sta *sta, void *priv_sta) | 2503 | * Called after adding a new station to initialize rate scaling |
2504 | */ | ||
2505 | void iwl_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_id) | ||
2500 | { | 2506 | { |
2501 | int i, j; | 2507 | int i, j; |
2502 | struct iwl_priv *priv = (struct iwl_priv *)priv_r; | 2508 | struct ieee80211_hw *hw = priv->hw; |
2503 | struct ieee80211_conf *conf = &priv->hw->conf; | 2509 | struct ieee80211_conf *conf = &priv->hw->conf; |
2504 | struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; | 2510 | struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; |
2505 | struct iwl_lq_sta *lq_sta = priv_sta; | 2511 | struct iwl_station_priv *sta_priv; |
2512 | struct iwl_lq_sta *lq_sta; | ||
2513 | struct ieee80211_supported_band *sband; | ||
2514 | |||
2515 | sta_priv = (struct iwl_station_priv *) sta->drv_priv; | ||
2516 | lq_sta = &sta_priv->lq_sta; | ||
2517 | sband = hw->wiphy->bands[conf->channel->band]; | ||
2506 | 2518 | ||
2507 | lq_sta->lq.sta_id = 0xff; | 2519 | |
2520 | lq_sta->lq.sta_id = sta_id; | ||
2508 | 2521 | ||
2509 | for (j = 0; j < LQ_SIZE; j++) | 2522 | for (j = 0; j < LQ_SIZE; j++) |
2510 | for (i = 0; i < IWL_RATE_COUNT; i++) | 2523 | for (i = 0; i < IWL_RATE_COUNT; i++) |
@@ -2516,33 +2529,13 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, | |||
2516 | for (i = 0; i < IWL_RATE_COUNT; i++) | 2529 | for (i = 0; i < IWL_RATE_COUNT; i++) |
2517 | rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); | 2530 | rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); |
2518 | 2531 | ||
2519 | IWL_DEBUG_RATE(priv, "LQ: *** rate scale station global init ***\n"); | 2532 | IWL_DEBUG_RATE(priv, "LQ: *** rate scale station global init for station %d ***\n", |
2533 | sta_id); | ||
2520 | /* TODO: what is a good starting rate for STA? About middle? Maybe not | 2534 | /* TODO: what is a good starting rate for STA? About middle? Maybe not |
2521 | * the lowest or the highest rate.. Could consider using RSSI from | 2535 | * the lowest or the highest rate.. Could consider using RSSI from |
2522 | * previous packets? Need to have IEEE 802.1X auth succeed immediately | 2536 | * previous packets? Need to have IEEE 802.1X auth succeed immediately |
2523 | * after assoc.. */ | 2537 | * after assoc.. */ |
2524 | 2538 | ||
2525 | lq_sta->ibss_sta_added = 0; | ||
2526 | if (priv->iw_mode == NL80211_IFTYPE_AP) { | ||
2527 | u8 sta_id = iwl_find_station(priv, | ||
2528 | sta->addr); | ||
2529 | |||
2530 | /* for IBSS the call are from tasklet */ | ||
2531 | IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", sta->addr); | ||
2532 | |||
2533 | if (sta_id == IWL_INVALID_STATION) { | ||
2534 | IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", sta->addr); | ||
2535 | sta_id = iwl_add_station(priv, sta->addr, false, | ||
2536 | CMD_ASYNC, ht_cap); | ||
2537 | } | ||
2538 | if ((sta_id != IWL_INVALID_STATION)) { | ||
2539 | lq_sta->lq.sta_id = sta_id; | ||
2540 | lq_sta->lq.rs_table[0].rate_n_flags = 0; | ||
2541 | } | ||
2542 | /* FIXME: this is w/a remove it later */ | ||
2543 | priv->assoc_station_added = 1; | ||
2544 | } | ||
2545 | |||
2546 | lq_sta->is_dup = 0; | 2539 | lq_sta->is_dup = 0; |
2547 | lq_sta->max_rate_idx = -1; | 2540 | lq_sta->max_rate_idx = -1; |
2548 | lq_sta->missed_rate_counter = IWL_MISSED_RATE_MAX; | 2541 | lq_sta->missed_rate_counter = IWL_MISSED_RATE_MAX; |
@@ -2795,7 +2788,7 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file, | |||
2795 | 2788 | ||
2796 | if (lq_sta->dbg_fixed_rate) { | 2789 | if (lq_sta->dbg_fixed_rate) { |
2797 | rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); | 2790 | rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); |
2798 | iwl_send_lq_cmd(lq_sta->drv, &lq_sta->lq, CMD_ASYNC); | 2791 | iwl_send_lq_cmd(lq_sta->drv, &lq_sta->lq, CMD_ASYNC, false); |
2799 | } | 2792 | } |
2800 | 2793 | ||
2801 | return count; | 2794 | return count; |
@@ -2992,12 +2985,21 @@ static void rs_remove_debugfs(void *priv, void *priv_sta) | |||
2992 | } | 2985 | } |
2993 | #endif | 2986 | #endif |
2994 | 2987 | ||
2988 | /* | ||
2989 | * Initialization of rate scaling information is done by driver after | ||
2990 | * the station is added. Since mac80211 calls this function before a | ||
2991 | * station is added we ignore it. | ||
2992 | */ | ||
2993 | static void rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband, | ||
2994 | struct ieee80211_sta *sta, void *priv_sta) | ||
2995 | { | ||
2996 | } | ||
2995 | static struct rate_control_ops rs_ops = { | 2997 | static struct rate_control_ops rs_ops = { |
2996 | .module = NULL, | 2998 | .module = NULL, |
2997 | .name = RS_NAME, | 2999 | .name = RS_NAME, |
2998 | .tx_status = rs_tx_status, | 3000 | .tx_status = rs_tx_status, |
2999 | .get_rate = rs_get_rate, | 3001 | .get_rate = rs_get_rate, |
3000 | .rate_init = rs_rate_init, | 3002 | .rate_init = rs_rate_init_stub, |
3001 | .alloc = rs_alloc, | 3003 | .alloc = rs_alloc, |
3002 | .free = rs_free, | 3004 | .free = rs_free, |
3003 | .alloc_sta = rs_alloc_sta, | 3005 | .alloc_sta = rs_alloc_sta, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h index e182f5a0f736..8292f6d48ec6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h | |||
@@ -403,7 +403,6 @@ struct iwl_lq_sta { | |||
403 | u8 is_green; | 403 | u8 is_green; |
404 | u8 is_dup; | 404 | u8 is_dup; |
405 | enum ieee80211_band band; | 405 | enum ieee80211_band band; |
406 | u8 ibss_sta_added; | ||
407 | 406 | ||
408 | /* The following are bitmaps of rates; IWL_RATE_6M_MASK, etc. */ | 407 | /* The following are bitmaps of rates; IWL_RATE_6M_MASK, etc. */ |
409 | u32 supp_rates; | 408 | u32 supp_rates; |
@@ -478,6 +477,12 @@ static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index) | |||
478 | */ | 477 | */ |
479 | extern void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); | 478 | extern void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); |
480 | 479 | ||
480 | /* Initialize station's rate scaling information after adding station */ | ||
481 | extern void iwl_rs_rate_init(struct iwl_priv *priv, | ||
482 | struct ieee80211_sta *sta, u8 sta_id); | ||
483 | extern void iwl3945_rs_rate_init(struct iwl_priv *priv, | ||
484 | struct ieee80211_sta *sta, u8 sta_id); | ||
485 | |||
481 | /** | 486 | /** |
482 | * iwl_rate_control_register - Register the rate control algorithm callbacks | 487 | * iwl_rate_control_register - Register the rate control algorithm callbacks |
483 | * | 488 | * |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 85ff1552481f..4b4b47676ad8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -144,9 +144,6 @@ int iwl_commit_rxon(struct iwl_priv *priv) | |||
144 | return 0; | 144 | return 0; |
145 | } | 145 | } |
146 | 146 | ||
147 | /* station table will be cleared */ | ||
148 | priv->assoc_station_added = 0; | ||
149 | |||
150 | /* If we are currently associated and the new config requires | 147 | /* If we are currently associated and the new config requires |
151 | * an RXON_ASSOC and the new config wants the associated mask enabled, | 148 | * an RXON_ASSOC and the new config wants the associated mask enabled, |
152 | * we must clear the associated from the active configuration | 149 | * we must clear the associated from the active configuration |
@@ -198,25 +195,7 @@ int iwl_commit_rxon(struct iwl_priv *priv) | |||
198 | } | 195 | } |
199 | 196 | ||
200 | priv->start_calib = 0; | 197 | priv->start_calib = 0; |
201 | |||
202 | /* If we have set the ASSOC_MSK and we are in BSS mode then | ||
203 | * add the IWL_AP_ID to the station rate table */ | ||
204 | if (new_assoc) { | 198 | if (new_assoc) { |
205 | if (priv->iw_mode == NL80211_IFTYPE_STATION) { | ||
206 | ret = iwl_rxon_add_station(priv, | ||
207 | priv->active_rxon.bssid_addr, 1); | ||
208 | if (ret == IWL_INVALID_STATION) { | ||
209 | IWL_ERR(priv, | ||
210 | "Error adding AP address for TX.\n"); | ||
211 | return -EIO; | ||
212 | } | ||
213 | priv->assoc_station_added = 1; | ||
214 | if (priv->default_wep_key && | ||
215 | iwl_send_static_wepkey_cmd(priv, 0)) | ||
216 | IWL_ERR(priv, | ||
217 | "Could not send WEP static key.\n"); | ||
218 | } | ||
219 | |||
220 | /* | 199 | /* |
221 | * allow CTS-to-self if possible for new association. | 200 | * allow CTS-to-self if possible for new association. |
222 | * this is relevant only for 5000 series and up, | 201 | * this is relevant only for 5000 series and up, |
@@ -2498,10 +2477,6 @@ void iwl_post_associate(struct iwl_priv *priv) | |||
2498 | return; | 2477 | return; |
2499 | } | 2478 | } |
2500 | 2479 | ||
2501 | IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", | ||
2502 | priv->assoc_id, priv->active_rxon.bssid_addr); | ||
2503 | |||
2504 | |||
2505 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) | 2480 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
2506 | return; | 2481 | return; |
2507 | 2482 | ||
@@ -2553,6 +2528,9 @@ void iwl_post_associate(struct iwl_priv *priv) | |||
2553 | 2528 | ||
2554 | iwlcore_commit_rxon(priv); | 2529 | iwlcore_commit_rxon(priv); |
2555 | 2530 | ||
2531 | IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", | ||
2532 | priv->assoc_id, priv->active_rxon.bssid_addr); | ||
2533 | |||
2556 | switch (priv->iw_mode) { | 2534 | switch (priv->iw_mode) { |
2557 | case NL80211_IFTYPE_STATION: | 2535 | case NL80211_IFTYPE_STATION: |
2558 | break; | 2536 | break; |
@@ -2562,7 +2540,7 @@ void iwl_post_associate(struct iwl_priv *priv) | |||
2562 | /* assume default assoc id */ | 2540 | /* assume default assoc id */ |
2563 | priv->assoc_id = 1; | 2541 | priv->assoc_id = 1; |
2564 | 2542 | ||
2565 | iwl_rxon_add_station(priv, priv->bssid, 0); | 2543 | iwl_add_local_station(priv, priv->bssid, true); |
2566 | iwl_send_beacon_cmd(priv); | 2544 | iwl_send_beacon_cmd(priv); |
2567 | 2545 | ||
2568 | break; | 2546 | break; |
@@ -2573,9 +2551,6 @@ void iwl_post_associate(struct iwl_priv *priv) | |||
2573 | break; | 2551 | break; |
2574 | } | 2552 | } |
2575 | 2553 | ||
2576 | if (priv->iw_mode == NL80211_IFTYPE_ADHOC) | ||
2577 | priv->assoc_station_added = 1; | ||
2578 | |||
2579 | spin_lock_irqsave(&priv->lock, flags); | 2554 | spin_lock_irqsave(&priv->lock, flags); |
2580 | iwl_activate_qos(priv, 0); | 2555 | iwl_activate_qos(priv, 0); |
2581 | spin_unlock_irqrestore(&priv->lock, flags); | 2556 | spin_unlock_irqrestore(&priv->lock, flags); |
@@ -2974,18 +2949,7 @@ static void iwl_mac_sta_notify(struct ieee80211_hw *hw, | |||
2974 | struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; | 2949 | struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; |
2975 | int sta_id; | 2950 | int sta_id; |
2976 | 2951 | ||
2977 | /* | ||
2978 | * TODO: We really should use this callback to | ||
2979 | * actually maintain the station table in | ||
2980 | * the device. | ||
2981 | */ | ||
2982 | |||
2983 | switch (cmd) { | 2952 | switch (cmd) { |
2984 | case STA_NOTIFY_ADD: | ||
2985 | atomic_set(&sta_priv->pending_frames, 0); | ||
2986 | if (vif->type == NL80211_IFTYPE_AP) | ||
2987 | sta_priv->client = true; | ||
2988 | break; | ||
2989 | case STA_NOTIFY_SLEEP: | 2953 | case STA_NOTIFY_SLEEP: |
2990 | WARN_ON(!sta_priv->client); | 2954 | WARN_ON(!sta_priv->client); |
2991 | sta_priv->asleep = true; | 2955 | sta_priv->asleep = true; |
@@ -3006,6 +2970,55 @@ static void iwl_mac_sta_notify(struct ieee80211_hw *hw, | |||
3006 | } | 2970 | } |
3007 | } | 2971 | } |
3008 | 2972 | ||
2973 | /** | ||
2974 | * iwl_restore_wepkeys - Restore WEP keys to device | ||
2975 | */ | ||
2976 | static void iwl_restore_wepkeys(struct iwl_priv *priv) | ||
2977 | { | ||
2978 | mutex_lock(&priv->mutex); | ||
2979 | if (priv->iw_mode == NL80211_IFTYPE_STATION && | ||
2980 | priv->default_wep_key && | ||
2981 | iwl_send_static_wepkey_cmd(priv, 0)) | ||
2982 | IWL_ERR(priv, "Could not send WEP static key\n"); | ||
2983 | mutex_unlock(&priv->mutex); | ||
2984 | } | ||
2985 | |||
2986 | static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, | ||
2987 | struct ieee80211_vif *vif, | ||
2988 | struct ieee80211_sta *sta) | ||
2989 | { | ||
2990 | struct iwl_priv *priv = hw->priv; | ||
2991 | struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; | ||
2992 | bool is_ap = priv->iw_mode == NL80211_IFTYPE_STATION; | ||
2993 | int ret; | ||
2994 | u8 sta_id; | ||
2995 | |||
2996 | IWL_DEBUG_INFO(priv, "received request to add station %pM\n", | ||
2997 | sta->addr); | ||
2998 | |||
2999 | atomic_set(&sta_priv->pending_frames, 0); | ||
3000 | if (vif->type == NL80211_IFTYPE_AP) | ||
3001 | sta_priv->client = true; | ||
3002 | |||
3003 | ret = iwl_add_station_common(priv, sta->addr, is_ap, &sta->ht_cap, | ||
3004 | &sta_id); | ||
3005 | if (ret) { | ||
3006 | IWL_ERR(priv, "Unable to add station %pM (%d)\n", | ||
3007 | sta->addr, ret); | ||
3008 | /* Should we return success if return code is EEXIST ? */ | ||
3009 | return ret; | ||
3010 | } | ||
3011 | |||
3012 | iwl_restore_wepkeys(priv); | ||
3013 | |||
3014 | /* Initialize rate scaling */ | ||
3015 | IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM \n", | ||
3016 | sta->addr); | ||
3017 | iwl_rs_rate_init(priv, sta, sta_id); | ||
3018 | |||
3019 | return ret; | ||
3020 | } | ||
3021 | |||
3009 | /***************************************************************************** | 3022 | /***************************************************************************** |
3010 | * | 3023 | * |
3011 | * sysfs attributes | 3024 | * sysfs attributes |
@@ -3359,6 +3372,8 @@ static struct ieee80211_ops iwl_hw_ops = { | |||
3359 | .ampdu_action = iwl_mac_ampdu_action, | 3372 | .ampdu_action = iwl_mac_ampdu_action, |
3360 | .hw_scan = iwl_mac_hw_scan, | 3373 | .hw_scan = iwl_mac_hw_scan, |
3361 | .sta_notify = iwl_mac_sta_notify, | 3374 | .sta_notify = iwl_mac_sta_notify, |
3375 | .sta_add = iwlagn_mac_sta_add, | ||
3376 | .sta_remove = iwl_mac_sta_remove, | ||
3362 | }; | 3377 | }; |
3363 | 3378 | ||
3364 | static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | 3379 | static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index a33e4536657a..d4c2a3e17c53 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c | |||
@@ -2530,7 +2530,6 @@ void iwl_mac_reset_tsf(struct ieee80211_hw *hw) | |||
2530 | spin_lock_irqsave(&priv->lock, flags); | 2530 | spin_lock_irqsave(&priv->lock, flags); |
2531 | priv->assoc_id = 0; | 2531 | priv->assoc_id = 0; |
2532 | priv->assoc_capability = 0; | 2532 | priv->assoc_capability = 0; |
2533 | priv->assoc_station_added = 0; | ||
2534 | 2533 | ||
2535 | /* new association get rid of ibss beacon skb */ | 2534 | /* new association get rid of ibss beacon skb */ |
2536 | if (priv->ibss_beacon) | 2535 | if (priv->ibss_beacon) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index aced12f1611e..2482a25d543f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h | |||
@@ -667,7 +667,7 @@ extern int iwl_send_statistics_request(struct iwl_priv *priv, | |||
667 | u8 flags, bool clear); | 667 | u8 flags, bool clear); |
668 | extern int iwl_verify_ucode(struct iwl_priv *priv); | 668 | extern int iwl_verify_ucode(struct iwl_priv *priv); |
669 | extern int iwl_send_lq_cmd(struct iwl_priv *priv, | 669 | extern int iwl_send_lq_cmd(struct iwl_priv *priv, |
670 | struct iwl_link_quality_cmd *lq, u8 flags); | 670 | struct iwl_link_quality_cmd *lq, u8 flags, bool init); |
671 | extern void iwl_rx_reply_rx(struct iwl_priv *priv, | 671 | extern void iwl_rx_reply_rx(struct iwl_priv *priv, |
672 | struct iwl_rx_mem_buffer *rxb); | 672 | struct iwl_rx_mem_buffer *rxb); |
673 | extern void iwl_rx_reply_rx_phy(struct iwl_priv *priv, | 673 | extern void iwl_rx_reply_rx_phy(struct iwl_priv *priv, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 2e4d47c7139b..9c676ea420b9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h | |||
@@ -544,11 +544,18 @@ struct iwl_qos_info { | |||
544 | struct iwl_qosparam_cmd def_qos_parm; | 544 | struct iwl_qosparam_cmd def_qos_parm; |
545 | }; | 545 | }; |
546 | 546 | ||
547 | /* | ||
548 | * Structure should be accessed with sta_lock held. When station addition | ||
549 | * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only | ||
550 | * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock | ||
551 | * held. | ||
552 | */ | ||
547 | struct iwl_station_entry { | 553 | struct iwl_station_entry { |
548 | struct iwl_addsta_cmd sta; | 554 | struct iwl_addsta_cmd sta; |
549 | struct iwl_tid_data tid[MAX_TID_COUNT]; | 555 | struct iwl_tid_data tid[MAX_TID_COUNT]; |
550 | u8 used; | 556 | u8 used; |
551 | struct iwl_hw_key keyinfo; | 557 | struct iwl_hw_key keyinfo; |
558 | struct iwl_link_quality_cmd *lq; | ||
552 | }; | 559 | }; |
553 | 560 | ||
554 | /* | 561 | /* |
@@ -1163,7 +1170,6 @@ struct iwl_priv { | |||
1163 | 1170 | ||
1164 | u16 active_rate; | 1171 | u16 active_rate; |
1165 | 1172 | ||
1166 | u8 assoc_station_added; | ||
1167 | u8 start_calib; | 1173 | u8 start_calib; |
1168 | struct iwl_sensitivity_data sensitivity_data; | 1174 | struct iwl_sensitivity_data sensitivity_data; |
1169 | struct iwl_chain_noise_data chain_noise_data; | 1175 | struct iwl_chain_noise_data chain_noise_data; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c index 312099099ed3..d401b6f226f9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-sta.c | |||
@@ -29,6 +29,7 @@ | |||
29 | 29 | ||
30 | #include <net/mac80211.h> | 30 | #include <net/mac80211.h> |
31 | #include <linux/etherdevice.h> | 31 | #include <linux/etherdevice.h> |
32 | #include <linux/sched.h> | ||
32 | 33 | ||
33 | #include "iwl-dev.h" | 34 | #include "iwl-dev.h" |
34 | #include "iwl-core.h" | 35 | #include "iwl-core.h" |
@@ -61,6 +62,19 @@ u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr) | |||
61 | addr, priv->num_stations); | 62 | addr, priv->num_stations); |
62 | 63 | ||
63 | out: | 64 | out: |
65 | /* | ||
66 | * It may be possible that more commands interacting with stations | ||
67 | * arrive before we completed processing the adding of | ||
68 | * station | ||
69 | */ | ||
70 | if (ret != IWL_INVALID_STATION && | ||
71 | (!(priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) || | ||
72 | ((priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) && | ||
73 | (priv->stations[ret].used & IWL_STA_UCODE_INPROGRESS)))) { | ||
74 | IWL_ERR(priv, "Requested station info for sta %d before ready. \n", | ||
75 | ret); | ||
76 | ret = IWL_INVALID_STATION; | ||
77 | } | ||
64 | spin_unlock_irqrestore(&priv->sta_lock, flags); | 78 | spin_unlock_irqrestore(&priv->sta_lock, flags); |
65 | return ret; | 79 | return ret; |
66 | } | 80 | } |
@@ -155,13 +169,6 @@ static void iwl_process_add_sta_resp(struct iwl_priv *priv, | |||
155 | priv->stations[sta_id].sta.mode == | 169 | priv->stations[sta_id].sta.mode == |
156 | STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", | 170 | STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", |
157 | addsta->sta.addr); | 171 | addsta->sta.addr); |
158 | |||
159 | /* | ||
160 | * Determine if we wanted to modify or add a station, | ||
161 | * if adding a station succeeded we have some more initialization | ||
162 | * to do when using station notification. TODO | ||
163 | */ | ||
164 | |||
165 | spin_unlock_irqrestore(&priv->sta_lock, flags); | 172 | spin_unlock_irqrestore(&priv->sta_lock, flags); |
166 | } | 173 | } |
167 | 174 | ||
@@ -187,6 +194,10 @@ int iwl_send_add_sta(struct iwl_priv *priv, | |||
187 | .flags = flags, | 194 | .flags = flags, |
188 | .data = data, | 195 | .data = data, |
189 | }; | 196 | }; |
197 | u8 sta_id = sta->sta.sta_id; | ||
198 | |||
199 | IWL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n", | ||
200 | sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); | ||
190 | 201 | ||
191 | if (flags & CMD_ASYNC) | 202 | if (flags & CMD_ASYNC) |
192 | cmd.callback = iwl_add_sta_callback; | 203 | cmd.callback = iwl_add_sta_callback; |
@@ -260,18 +271,19 @@ static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index, | |||
260 | } | 271 | } |
261 | 272 | ||
262 | /** | 273 | /** |
263 | * iwl_add_station - Add station to tables in driver and device | 274 | * iwl_prep_station - Prepare station information for addition |
275 | * | ||
276 | * should be called with sta_lock held | ||
264 | */ | 277 | */ |
265 | u8 iwl_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap, u8 flags, | 278 | static u8 iwl_prep_station(struct iwl_priv *priv, const u8 *addr, |
266 | struct ieee80211_sta_ht_cap *ht_info) | 279 | bool is_ap, |
280 | struct ieee80211_sta_ht_cap *ht_info) | ||
267 | { | 281 | { |
268 | struct iwl_station_entry *station; | 282 | struct iwl_station_entry *station; |
269 | unsigned long flags_spin; | ||
270 | int i; | 283 | int i; |
271 | int sta_id = IWL_INVALID_STATION; | 284 | u8 sta_id = IWL_INVALID_STATION; |
272 | u16 rate; | 285 | u16 rate; |
273 | 286 | ||
274 | spin_lock_irqsave(&priv->sta_lock, flags_spin); | ||
275 | if (is_ap) | 287 | if (is_ap) |
276 | sta_id = IWL_AP_ID; | 288 | sta_id = IWL_AP_ID; |
277 | else if (is_broadcast_ether_addr(addr)) | 289 | else if (is_broadcast_ether_addr(addr)) |
@@ -289,20 +301,32 @@ u8 iwl_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap, u8 flags, | |||
289 | sta_id = i; | 301 | sta_id = i; |
290 | } | 302 | } |
291 | 303 | ||
292 | /* These two conditions have the same outcome, but keep them separate | 304 | /* |
293 | since they have different meanings */ | 305 | * These two conditions have the same outcome, but keep them |
294 | if (unlikely(sta_id == IWL_INVALID_STATION)) { | 306 | * separate |
295 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | 307 | */ |
308 | if (unlikely(sta_id == IWL_INVALID_STATION)) | ||
309 | return sta_id; | ||
310 | |||
311 | /* | ||
312 | * uCode is not able to deal with multiple requests to add a | ||
313 | * station. Keep track if one is in progress so that we do not send | ||
314 | * another. | ||
315 | */ | ||
316 | if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) { | ||
317 | IWL_DEBUG_INFO(priv, "STA %d already in process of being added.\n", | ||
318 | sta_id); | ||
296 | return sta_id; | 319 | return sta_id; |
297 | } | 320 | } |
298 | 321 | ||
299 | if (priv->stations[sta_id].used && | 322 | if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) && |
323 | (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) && | ||
300 | !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) { | 324 | !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) { |
301 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | 325 | IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n", |
326 | sta_id, addr); | ||
302 | return sta_id; | 327 | return sta_id; |
303 | } | 328 | } |
304 | 329 | ||
305 | |||
306 | station = &priv->stations[sta_id]; | 330 | station = &priv->stations[sta_id]; |
307 | station->used = IWL_STA_DRIVER_ACTIVE; | 331 | station->used = IWL_STA_DRIVER_ACTIVE; |
308 | IWL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n", | 332 | IWL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n", |
@@ -327,86 +351,185 @@ u8 iwl_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap, u8 flags, | |||
327 | /* Turn on both antennas for the station... */ | 351 | /* Turn on both antennas for the station... */ |
328 | station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); | 352 | station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); |
329 | 353 | ||
354 | return sta_id; | ||
355 | |||
356 | } | ||
357 | |||
358 | #define STA_WAIT_TIMEOUT (HZ/2) | ||
359 | |||
360 | /** | ||
361 | * iwl_add_station_common - | ||
362 | */ | ||
363 | int iwl_add_station_common(struct iwl_priv *priv, const u8 *addr, | ||
364 | bool is_ap, | ||
365 | struct ieee80211_sta_ht_cap *ht_info, | ||
366 | u8 *sta_id_r) | ||
367 | { | ||
368 | struct iwl_station_entry *station; | ||
369 | unsigned long flags_spin; | ||
370 | int ret = 0; | ||
371 | u8 sta_id; | ||
372 | |||
373 | *sta_id_r = 0; | ||
374 | spin_lock_irqsave(&priv->sta_lock, flags_spin); | ||
375 | sta_id = iwl_prep_station(priv, addr, is_ap, ht_info); | ||
376 | if (sta_id == IWL_INVALID_STATION) { | ||
377 | IWL_ERR(priv, "Unable to prepare station %pM for addition\n", | ||
378 | addr); | ||
379 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
380 | return -EINVAL; | ||
381 | } | ||
382 | |||
383 | /* | ||
384 | * uCode is not able to deal with multiple requests to add a | ||
385 | * station. Keep track if one is in progress so that we do not send | ||
386 | * another. | ||
387 | */ | ||
388 | if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) { | ||
389 | IWL_DEBUG_INFO(priv, "STA %d already in process of being added.\n", | ||
390 | sta_id); | ||
391 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
392 | return -EEXIST; | ||
393 | } | ||
394 | |||
395 | if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) && | ||
396 | (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) { | ||
397 | IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n", | ||
398 | sta_id, addr); | ||
399 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
400 | return -EEXIST; | ||
401 | } | ||
402 | |||
403 | priv->stations[sta_id].used |= IWL_STA_UCODE_INPROGRESS; | ||
404 | station = &priv->stations[sta_id]; | ||
330 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | 405 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); |
331 | 406 | ||
332 | /* Add station to device's station table */ | 407 | /* Add station to device's station table */ |
333 | iwl_send_add_sta(priv, &station->sta, flags); | 408 | ret = iwl_send_add_sta(priv, &station->sta, CMD_SYNC); |
334 | return sta_id; | 409 | if (ret) { |
335 | 410 | IWL_ERR(priv, "Adding station %pM failed.\n", station->sta.sta.addr); | |
411 | spin_lock_irqsave(&priv->sta_lock, flags_spin); | ||
412 | priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; | ||
413 | priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; | ||
414 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
415 | } | ||
416 | *sta_id_r = sta_id; | ||
417 | return ret; | ||
336 | } | 418 | } |
337 | EXPORT_SYMBOL(iwl_add_station); | 419 | EXPORT_SYMBOL(iwl_add_station_common); |
338 | 420 | ||
339 | static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, const u8 *addr) | 421 | static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, bool is_ap) |
340 | { | 422 | { |
341 | unsigned long flags; | 423 | int i, r; |
342 | u8 sta_id = iwl_find_station(priv, addr); | 424 | struct iwl_link_quality_cmd link_cmd = { |
425 | .reserved1 = 0, | ||
426 | }; | ||
427 | u32 rate_flags; | ||
428 | |||
429 | /* Set up the rate scaling to start at selected rate, fall back | ||
430 | * all the way down to 1M in IEEE order, and then spin on 1M */ | ||
431 | if (is_ap) | ||
432 | r = IWL_RATE_54M_INDEX; | ||
433 | else if (priv->band == IEEE80211_BAND_5GHZ) | ||
434 | r = IWL_RATE_6M_INDEX; | ||
435 | else | ||
436 | r = IWL_RATE_1M_INDEX; | ||
343 | 437 | ||
344 | BUG_ON(sta_id == IWL_INVALID_STATION); | 438 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { |
439 | rate_flags = 0; | ||
440 | if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE) | ||
441 | rate_flags |= RATE_MCS_CCK_MSK; | ||
345 | 442 | ||
346 | IWL_DEBUG_ASSOC(priv, "Removed STA from Ucode: %pM\n", addr); | 443 | rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) << |
444 | RATE_MCS_ANT_POS; | ||
347 | 445 | ||
348 | spin_lock_irqsave(&priv->sta_lock, flags); | 446 | link_cmd.rs_table[i].rate_n_flags = |
447 | iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags); | ||
448 | r = iwl_get_prev_ieee_rate(r); | ||
449 | } | ||
349 | 450 | ||
350 | /* Ucode must be active and driver must be non active */ | 451 | link_cmd.general_params.single_stream_ant_msk = |
351 | if (priv->stations[sta_id].used != IWL_STA_UCODE_ACTIVE) | 452 | first_antenna(priv->hw_params.valid_tx_ant); |
352 | IWL_ERR(priv, "removed non active STA %d\n", sta_id); | 453 | link_cmd.general_params.dual_stream_ant_msk = 3; |
454 | link_cmd.agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; | ||
455 | link_cmd.agg_params.agg_time_limit = | ||
456 | cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); | ||
353 | 457 | ||
354 | priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE; | 458 | /* Update the rate scaling for control frame Tx to AP */ |
459 | link_cmd.sta_id = is_ap ? IWL_AP_ID : priv->hw_params.bcast_sta_id; | ||
355 | 460 | ||
356 | memset(&priv->stations[sta_id], 0, sizeof(struct iwl_station_entry)); | 461 | iwl_send_cmd_pdu(priv, REPLY_TX_LINK_QUALITY_CMD, |
357 | spin_unlock_irqrestore(&priv->sta_lock, flags); | 462 | sizeof(link_cmd), &link_cmd); |
358 | } | 463 | } |
359 | 464 | ||
360 | static void iwl_remove_sta_callback(struct iwl_priv *priv, | 465 | /* |
361 | struct iwl_device_cmd *cmd, | 466 | * iwl_add_local_stations - Add stations not requested by mac80211 |
362 | struct iwl_rx_packet *pkt) | 467 | * |
468 | * This will be either the broadcast station or the bssid station needed by | ||
469 | * ad-hoc. | ||
470 | * | ||
471 | * Function sleeps. | ||
472 | */ | ||
473 | int iwl_add_local_station(struct iwl_priv *priv, const u8 *addr, bool init_rs) | ||
363 | { | 474 | { |
364 | struct iwl_rem_sta_cmd *rm_sta = | 475 | int ret; |
365 | (struct iwl_rem_sta_cmd *)cmd->cmd.payload; | 476 | u8 sta_id; |
366 | const u8 *addr = rm_sta->addr; | ||
367 | 477 | ||
368 | if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { | 478 | ret = iwl_add_station_common(priv, addr, 0, NULL, &sta_id); |
369 | IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", | 479 | if (ret) { |
370 | pkt->hdr.flags); | 480 | IWL_ERR(priv, "Unable to add station %pM\n", addr); |
371 | return; | 481 | return ret; |
372 | } | 482 | } |
373 | 483 | ||
374 | switch (pkt->u.rem_sta.status) { | 484 | if (init_rs) |
375 | case REM_STA_SUCCESS_MSK: | 485 | /* Set up default rate scaling table in device's station table */ |
376 | iwl_sta_ucode_deactivate(priv, addr); | 486 | iwl_sta_init_lq(priv, addr, false); |
377 | break; | 487 | return 0; |
378 | default: | 488 | } |
379 | IWL_ERR(priv, "REPLY_REMOVE_STA failed\n"); | 489 | EXPORT_SYMBOL(iwl_add_local_station); |
380 | break; | 490 | |
381 | } | 491 | /** |
492 | * iwl_sta_ucode_deactivate - deactivate ucode status for a station | ||
493 | * | ||
494 | * priv->sta_lock must be held | ||
495 | */ | ||
496 | static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, u8 sta_id) | ||
497 | { | ||
498 | /* Ucode must be active and driver must be non active */ | ||
499 | if (priv->stations[sta_id].used != IWL_STA_UCODE_ACTIVE) | ||
500 | IWL_ERR(priv, "removed non active STA %u\n", sta_id); | ||
501 | |||
502 | priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE; | ||
503 | |||
504 | memset(&priv->stations[sta_id], 0, sizeof(struct iwl_station_entry)); | ||
505 | IWL_DEBUG_ASSOC(priv, "Removed STA %u\n", sta_id); | ||
382 | } | 506 | } |
383 | 507 | ||
384 | static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr, | 508 | static int iwl_send_remove_station(struct iwl_priv *priv, |
385 | u8 flags) | 509 | struct iwl_station_entry *station) |
386 | { | 510 | { |
387 | struct iwl_rx_packet *pkt; | 511 | struct iwl_rx_packet *pkt; |
388 | int ret; | 512 | int ret; |
389 | 513 | ||
514 | unsigned long flags_spin; | ||
390 | struct iwl_rem_sta_cmd rm_sta_cmd; | 515 | struct iwl_rem_sta_cmd rm_sta_cmd; |
391 | 516 | ||
392 | struct iwl_host_cmd cmd = { | 517 | struct iwl_host_cmd cmd = { |
393 | .id = REPLY_REMOVE_STA, | 518 | .id = REPLY_REMOVE_STA, |
394 | .len = sizeof(struct iwl_rem_sta_cmd), | 519 | .len = sizeof(struct iwl_rem_sta_cmd), |
395 | .flags = flags, | 520 | .flags = CMD_SYNC, |
396 | .data = &rm_sta_cmd, | 521 | .data = &rm_sta_cmd, |
397 | }; | 522 | }; |
398 | 523 | ||
399 | memset(&rm_sta_cmd, 0, sizeof(rm_sta_cmd)); | 524 | memset(&rm_sta_cmd, 0, sizeof(rm_sta_cmd)); |
400 | rm_sta_cmd.num_sta = 1; | 525 | rm_sta_cmd.num_sta = 1; |
401 | memcpy(&rm_sta_cmd.addr, addr , ETH_ALEN); | 526 | memcpy(&rm_sta_cmd.addr, &station->sta.sta.addr , ETH_ALEN); |
527 | |||
528 | cmd.flags |= CMD_WANT_SKB; | ||
402 | 529 | ||
403 | if (flags & CMD_ASYNC) | ||
404 | cmd.callback = iwl_remove_sta_callback; | ||
405 | else | ||
406 | cmd.flags |= CMD_WANT_SKB; | ||
407 | ret = iwl_send_cmd(priv, &cmd); | 530 | ret = iwl_send_cmd(priv, &cmd); |
408 | 531 | ||
409 | if (ret || (flags & CMD_ASYNC)) | 532 | if (ret) |
410 | return ret; | 533 | return ret; |
411 | 534 | ||
412 | pkt = (struct iwl_rx_packet *)cmd.reply_page; | 535 | pkt = (struct iwl_rx_packet *)cmd.reply_page; |
@@ -419,7 +542,9 @@ static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr, | |||
419 | if (!ret) { | 542 | if (!ret) { |
420 | switch (pkt->u.rem_sta.status) { | 543 | switch (pkt->u.rem_sta.status) { |
421 | case REM_STA_SUCCESS_MSK: | 544 | case REM_STA_SUCCESS_MSK: |
422 | iwl_sta_ucode_deactivate(priv, addr); | 545 | spin_lock_irqsave(&priv->sta_lock, flags_spin); |
546 | iwl_sta_ucode_deactivate(priv, station->sta.sta.sta_id); | ||
547 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
423 | IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n"); | 548 | IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n"); |
424 | break; | 549 | break; |
425 | default: | 550 | default: |
@@ -436,23 +561,35 @@ static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr, | |||
436 | /** | 561 | /** |
437 | * iwl_remove_station - Remove driver's knowledge of station. | 562 | * iwl_remove_station - Remove driver's knowledge of station. |
438 | */ | 563 | */ |
439 | int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, bool is_ap) | 564 | static int iwl_remove_station(struct iwl_priv *priv, struct ieee80211_sta *sta) |
440 | { | 565 | { |
441 | int sta_id = IWL_INVALID_STATION; | 566 | int sta_id = IWL_INVALID_STATION; |
442 | int i, ret = -EINVAL; | 567 | int i, ret = -EINVAL; |
443 | unsigned long flags; | 568 | unsigned long flags; |
569 | bool is_ap = priv->iw_mode == NL80211_IFTYPE_STATION; | ||
570 | struct iwl_station_entry *station; | ||
571 | |||
572 | if (!iwl_is_ready(priv)) { | ||
573 | IWL_DEBUG_INFO(priv, | ||
574 | "Unable to remove station %pM, device not ready. \n", | ||
575 | sta->addr); | ||
576 | /* | ||
577 | * It is typical for stations to be removed when we are | ||
578 | * going down. Return success since device will be down | ||
579 | * soon anyway | ||
580 | */ | ||
581 | return 0; | ||
582 | } | ||
444 | 583 | ||
445 | spin_lock_irqsave(&priv->sta_lock, flags); | 584 | spin_lock_irqsave(&priv->sta_lock, flags); |
446 | 585 | ||
447 | if (is_ap) | 586 | if (is_ap) |
448 | sta_id = IWL_AP_ID; | 587 | sta_id = IWL_AP_ID; |
449 | else if (is_broadcast_ether_addr(addr)) | ||
450 | sta_id = priv->hw_params.bcast_sta_id; | ||
451 | else | 588 | else |
452 | for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) | 589 | for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) |
453 | if (priv->stations[i].used && | 590 | if (priv->stations[i].used && |
454 | !compare_ether_addr(priv->stations[i].sta.sta.addr, | 591 | !compare_ether_addr(priv->stations[i].sta.sta.addr, |
455 | addr)) { | 592 | sta->addr)) { |
456 | sta_id = i; | 593 | sta_id = i; |
457 | break; | 594 | break; |
458 | } | 595 | } |
@@ -461,17 +598,17 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, bool is_ap) | |||
461 | goto out; | 598 | goto out; |
462 | 599 | ||
463 | IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n", | 600 | IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n", |
464 | sta_id, addr); | 601 | sta_id, sta->addr); |
465 | 602 | ||
466 | if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { | 603 | if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { |
467 | IWL_ERR(priv, "Removing %pM but non DRIVER active\n", | 604 | IWL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n", |
468 | addr); | 605 | sta->addr); |
469 | goto out; | 606 | goto out; |
470 | } | 607 | } |
471 | 608 | ||
472 | if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) { | 609 | if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) { |
473 | IWL_ERR(priv, "Removing %pM but non UCODE active\n", | 610 | IWL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n", |
474 | addr); | 611 | sta->addr); |
475 | goto out; | 612 | goto out; |
476 | } | 613 | } |
477 | 614 | ||
@@ -482,9 +619,10 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, bool is_ap) | |||
482 | 619 | ||
483 | BUG_ON(priv->num_stations < 0); | 620 | BUG_ON(priv->num_stations < 0); |
484 | 621 | ||
622 | station = &priv->stations[sta_id]; | ||
485 | spin_unlock_irqrestore(&priv->sta_lock, flags); | 623 | spin_unlock_irqrestore(&priv->sta_lock, flags); |
486 | 624 | ||
487 | ret = iwl_send_remove_station(priv, addr, CMD_ASYNC); | 625 | ret = iwl_send_remove_station(priv, station); |
488 | return ret; | 626 | return ret; |
489 | out: | 627 | out: |
490 | spin_unlock_irqrestore(&priv->sta_lock, flags); | 628 | spin_unlock_irqrestore(&priv->sta_lock, flags); |
@@ -548,12 +686,16 @@ EXPORT_SYMBOL(iwl_clear_ucode_stations); | |||
548 | * | 686 | * |
549 | * All stations considered active by driver, but not present in ucode, is | 687 | * All stations considered active by driver, but not present in ucode, is |
550 | * restored. | 688 | * restored. |
689 | * | ||
690 | * Function sleeps. | ||
551 | */ | 691 | */ |
552 | void iwl_restore_stations(struct iwl_priv *priv) | 692 | void iwl_restore_stations(struct iwl_priv *priv) |
553 | { | 693 | { |
694 | struct iwl_station_entry *station; | ||
554 | unsigned long flags_spin; | 695 | unsigned long flags_spin; |
555 | int i; | 696 | int i; |
556 | bool found = false; | 697 | bool found = false; |
698 | int ret; | ||
557 | 699 | ||
558 | if (!iwl_is_ready(priv)) { | 700 | if (!iwl_is_ready(priv)) { |
559 | IWL_DEBUG_INFO(priv, "Not ready yet, not restoring any stations.\n"); | 701 | IWL_DEBUG_INFO(priv, "Not ready yet, not restoring any stations.\n"); |
@@ -575,8 +717,24 @@ void iwl_restore_stations(struct iwl_priv *priv) | |||
575 | 717 | ||
576 | for (i = 0; i < priv->hw_params.max_stations; i++) { | 718 | for (i = 0; i < priv->hw_params.max_stations; i++) { |
577 | if ((priv->stations[i].used & IWL_STA_UCODE_INPROGRESS)) { | 719 | if ((priv->stations[i].used & IWL_STA_UCODE_INPROGRESS)) { |
578 | iwl_send_add_sta(priv, &priv->stations[i].sta, | 720 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); |
579 | CMD_ASYNC); | 721 | station = &priv->stations[i]; |
722 | ret = iwl_send_add_sta(priv, &priv->stations[i].sta, CMD_SYNC); | ||
723 | if (ret) { | ||
724 | IWL_ERR(priv, "Adding station %pM failed.\n", | ||
725 | station->sta.sta.addr); | ||
726 | spin_lock_irqsave(&priv->sta_lock, flags_spin); | ||
727 | priv->stations[i].used &= ~IWL_STA_DRIVER_ACTIVE; | ||
728 | priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS; | ||
729 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
730 | } | ||
731 | /* | ||
732 | * Rate scaling has already been initialized, send | ||
733 | * current LQ command | ||
734 | */ | ||
735 | if (station->lq) | ||
736 | iwl_send_lq_cmd(priv, station->lq, CMD_SYNC, true); | ||
737 | spin_lock_irqsave(&priv->sta_lock, flags_spin); | ||
580 | priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS; | 738 | priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS; |
581 | } | 739 | } |
582 | } | 740 | } |
@@ -585,7 +743,7 @@ void iwl_restore_stations(struct iwl_priv *priv) | |||
585 | if (!found) | 743 | if (!found) |
586 | IWL_DEBUG_INFO(priv, "Restoring all known stations .... no stations to be restored.\n"); | 744 | IWL_DEBUG_INFO(priv, "Restoring all known stations .... no stations to be restored.\n"); |
587 | else | 745 | else |
588 | IWL_DEBUG_INFO(priv, "Restoring all known stations .... in progress.\n"); | 746 | IWL_DEBUG_INFO(priv, "Restoring all known stations .... complete.\n"); |
589 | } | 747 | } |
590 | EXPORT_SYMBOL(iwl_restore_stations); | 748 | EXPORT_SYMBOL(iwl_restore_stations); |
591 | 749 | ||
@@ -1010,9 +1168,22 @@ static inline void iwl_dump_lq_cmd(struct iwl_priv *priv, | |||
1010 | } | 1168 | } |
1011 | #endif | 1169 | #endif |
1012 | 1170 | ||
1171 | /** | ||
1172 | * iwl_send_lq_cmd() - Send link quality command | ||
1173 | * @init: This command is sent as part of station initialization right | ||
1174 | * after station has been added. | ||
1175 | * | ||
1176 | * The link quality command is sent as the last step of station creation. | ||
1177 | * This is the special case in which init is set and we call a callback in | ||
1178 | * this case to clear the state indicating that station creation is in | ||
1179 | * progress. | ||
1180 | */ | ||
1013 | int iwl_send_lq_cmd(struct iwl_priv *priv, | 1181 | int iwl_send_lq_cmd(struct iwl_priv *priv, |
1014 | struct iwl_link_quality_cmd *lq, u8 flags) | 1182 | struct iwl_link_quality_cmd *lq, u8 flags, bool init) |
1015 | { | 1183 | { |
1184 | int ret = 0; | ||
1185 | unsigned long flags_spin; | ||
1186 | |||
1016 | struct iwl_host_cmd cmd = { | 1187 | struct iwl_host_cmd cmd = { |
1017 | .id = REPLY_TX_LINK_QUALITY_CMD, | 1188 | .id = REPLY_TX_LINK_QUALITY_CMD, |
1018 | .len = sizeof(struct iwl_link_quality_cmd), | 1189 | .len = sizeof(struct iwl_link_quality_cmd), |
@@ -1028,167 +1199,31 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, | |||
1028 | lq->sta_id = IWL_AP_ID; | 1199 | lq->sta_id = IWL_AP_ID; |
1029 | 1200 | ||
1030 | iwl_dump_lq_cmd(priv, lq); | 1201 | iwl_dump_lq_cmd(priv, lq); |
1202 | BUG_ON(init && (cmd.flags & CMD_ASYNC)); | ||
1031 | 1203 | ||
1032 | if (iwl_is_associated(priv) && priv->assoc_station_added) | 1204 | iwl_dump_lq_cmd(priv, lq); |
1033 | return iwl_send_cmd(priv, &cmd); | 1205 | ret = iwl_send_cmd(priv, &cmd); |
1206 | if (ret || (cmd.flags & CMD_ASYNC)) | ||
1207 | return ret; | ||
1034 | 1208 | ||
1209 | if (init) { | ||
1210 | IWL_DEBUG_INFO(priv, "init LQ command complete, clearing sta addition status for sta %d \n", | ||
1211 | lq->sta_id); | ||
1212 | spin_lock_irqsave(&priv->sta_lock, flags_spin); | ||
1213 | priv->stations[lq->sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; | ||
1214 | spin_unlock_irqrestore(&priv->sta_lock, flags_spin); | ||
1215 | } | ||
1035 | return 0; | 1216 | return 0; |
1036 | } | 1217 | } |
1037 | EXPORT_SYMBOL(iwl_send_lq_cmd); | 1218 | EXPORT_SYMBOL(iwl_send_lq_cmd); |
1038 | 1219 | ||
1039 | /** | 1220 | /** |
1040 | * iwl_sta_init_lq - Initialize a station's hardware rate table | ||
1041 | * | ||
1042 | * The uCode's station table contains a table of fallback rates | ||
1043 | * for automatic fallback during transmission. | ||
1044 | * | ||
1045 | * NOTE: This sets up a default set of values. These will be replaced later | ||
1046 | * if the driver's iwl-agn-rs rate scaling algorithm is used, instead of | ||
1047 | * rc80211_simple. | ||
1048 | * | ||
1049 | * NOTE: Run REPLY_ADD_STA command to set up station table entry, before | ||
1050 | * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, | ||
1051 | * which requires station table entry to exist). | ||
1052 | */ | ||
1053 | static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, bool is_ap) | ||
1054 | { | ||
1055 | int i, r; | ||
1056 | struct iwl_link_quality_cmd link_cmd = { | ||
1057 | .reserved1 = 0, | ||
1058 | }; | ||
1059 | u32 rate_flags; | ||
1060 | |||
1061 | /* Set up the rate scaling to start at selected rate, fall back | ||
1062 | * all the way down to 1M in IEEE order, and then spin on 1M */ | ||
1063 | if (is_ap) | ||
1064 | r = IWL_RATE_54M_INDEX; | ||
1065 | else if (priv->band == IEEE80211_BAND_5GHZ) | ||
1066 | r = IWL_RATE_6M_INDEX; | ||
1067 | else | ||
1068 | r = IWL_RATE_1M_INDEX; | ||
1069 | |||
1070 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { | ||
1071 | rate_flags = 0; | ||
1072 | if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE) | ||
1073 | rate_flags |= RATE_MCS_CCK_MSK; | ||
1074 | |||
1075 | rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) << | ||
1076 | RATE_MCS_ANT_POS; | ||
1077 | |||
1078 | link_cmd.rs_table[i].rate_n_flags = | ||
1079 | iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags); | ||
1080 | r = iwl_get_prev_ieee_rate(r); | ||
1081 | } | ||
1082 | |||
1083 | link_cmd.general_params.single_stream_ant_msk = | ||
1084 | first_antenna(priv->hw_params.valid_tx_ant); | ||
1085 | link_cmd.general_params.dual_stream_ant_msk = 3; | ||
1086 | link_cmd.agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; | ||
1087 | link_cmd.agg_params.agg_time_limit = | ||
1088 | cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); | ||
1089 | |||
1090 | /* Update the rate scaling for control frame Tx to AP */ | ||
1091 | link_cmd.sta_id = is_ap ? IWL_AP_ID : priv->hw_params.bcast_sta_id; | ||
1092 | |||
1093 | iwl_send_cmd_pdu_async(priv, REPLY_TX_LINK_QUALITY_CMD, | ||
1094 | sizeof(link_cmd), &link_cmd, NULL); | ||
1095 | } | ||
1096 | |||
1097 | /** | ||
1098 | * iwl_rxon_add_station - add station into station table. | ||
1099 | * | ||
1100 | * there is only one AP station with id= IWL_AP_ID | ||
1101 | * NOTE: mutex must be held before calling this function | ||
1102 | */ | ||
1103 | int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap) | ||
1104 | { | ||
1105 | struct ieee80211_sta *sta; | ||
1106 | struct ieee80211_sta_ht_cap ht_config; | ||
1107 | struct ieee80211_sta_ht_cap *cur_ht_config = NULL; | ||
1108 | u8 sta_id; | ||
1109 | |||
1110 | /* | ||
1111 | * Set HT capabilities. It is ok to set this struct even if not using | ||
1112 | * HT config: the priv->current_ht_config.is_ht flag will just be false | ||
1113 | */ | ||
1114 | rcu_read_lock(); | ||
1115 | sta = ieee80211_find_sta(priv->vif, addr); | ||
1116 | if (sta) { | ||
1117 | memcpy(&ht_config, &sta->ht_cap, sizeof(ht_config)); | ||
1118 | cur_ht_config = &ht_config; | ||
1119 | } | ||
1120 | rcu_read_unlock(); | ||
1121 | |||
1122 | /* Add station to device's station table */ | ||
1123 | sta_id = iwl_add_station(priv, addr, is_ap, CMD_SYNC, cur_ht_config); | ||
1124 | |||
1125 | /* Set up default rate scaling table in device's station table */ | ||
1126 | iwl_sta_init_lq(priv, addr, is_ap); | ||
1127 | |||
1128 | return sta_id; | ||
1129 | } | ||
1130 | EXPORT_SYMBOL(iwl_rxon_add_station); | ||
1131 | |||
1132 | /** | ||
1133 | * iwl_sta_init_bcast_lq - Initialize a bcast station's hardware rate table | ||
1134 | * | ||
1135 | * NOTE: Run REPLY_ADD_STA command to set up station table entry, before | ||
1136 | * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, | ||
1137 | * which requires station table entry to exist). | ||
1138 | */ | ||
1139 | static void iwl_sta_init_bcast_lq(struct iwl_priv *priv) | ||
1140 | { | ||
1141 | int i, r; | ||
1142 | struct iwl_link_quality_cmd link_cmd = { | ||
1143 | .reserved1 = 0, | ||
1144 | }; | ||
1145 | u32 rate_flags; | ||
1146 | |||
1147 | /* Set up the rate scaling to start at selected rate, fall back | ||
1148 | * all the way down to 1M in IEEE order, and then spin on 1M */ | ||
1149 | if (priv->band == IEEE80211_BAND_5GHZ) | ||
1150 | r = IWL_RATE_6M_INDEX; | ||
1151 | else | ||
1152 | r = IWL_RATE_1M_INDEX; | ||
1153 | |||
1154 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { | ||
1155 | rate_flags = 0; | ||
1156 | if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE) | ||
1157 | rate_flags |= RATE_MCS_CCK_MSK; | ||
1158 | |||
1159 | rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) << | ||
1160 | RATE_MCS_ANT_POS; | ||
1161 | |||
1162 | link_cmd.rs_table[i].rate_n_flags = | ||
1163 | iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags); | ||
1164 | r = iwl_get_prev_ieee_rate(r); | ||
1165 | } | ||
1166 | |||
1167 | link_cmd.general_params.single_stream_ant_msk = | ||
1168 | first_antenna(priv->hw_params.valid_tx_ant); | ||
1169 | link_cmd.general_params.dual_stream_ant_msk = 3; | ||
1170 | link_cmd.agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; | ||
1171 | link_cmd.agg_params.agg_time_limit = | ||
1172 | cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); | ||
1173 | |||
1174 | /* Update the rate scaling for control frame Tx to AP */ | ||
1175 | link_cmd.sta_id = priv->hw_params.bcast_sta_id; | ||
1176 | |||
1177 | iwl_send_cmd_pdu_async(priv, REPLY_TX_LINK_QUALITY_CMD, | ||
1178 | sizeof(link_cmd), &link_cmd, NULL); | ||
1179 | } | ||
1180 | |||
1181 | |||
1182 | /** | ||
1183 | * iwl_add_bcast_station - add broadcast station into station table. | 1221 | * iwl_add_bcast_station - add broadcast station into station table. |
1184 | */ | 1222 | */ |
1185 | void iwl_add_bcast_station(struct iwl_priv *priv) | 1223 | void iwl_add_bcast_station(struct iwl_priv *priv) |
1186 | { | 1224 | { |
1187 | IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n"); | 1225 | IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n"); |
1188 | iwl_add_station(priv, iwl_bcast_addr, false, CMD_SYNC, NULL); | 1226 | iwl_add_local_station(priv, iwl_bcast_addr, true); |
1189 | |||
1190 | /* Set up default rate scaling table in device's station table */ | ||
1191 | iwl_sta_init_bcast_lq(priv); | ||
1192 | } | 1227 | } |
1193 | EXPORT_SYMBOL(iwl_add_bcast_station); | 1228 | EXPORT_SYMBOL(iwl_add_bcast_station); |
1194 | 1229 | ||
@@ -1198,7 +1233,14 @@ EXPORT_SYMBOL(iwl_add_bcast_station); | |||
1198 | void iwl3945_add_bcast_station(struct iwl_priv *priv) | 1233 | void iwl3945_add_bcast_station(struct iwl_priv *priv) |
1199 | { | 1234 | { |
1200 | IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n"); | 1235 | IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n"); |
1201 | iwl_add_station(priv, iwl_bcast_addr, false, CMD_SYNC, NULL); | 1236 | iwl_add_local_station(priv, iwl_bcast_addr, false); |
1237 | /* | ||
1238 | * It is assumed that when station is added more initialization | ||
1239 | * needs to be done, but for 3945 it is not the case and we can | ||
1240 | * just release station table access right here. | ||
1241 | */ | ||
1242 | priv->stations[priv->hw_params.bcast_sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; | ||
1243 | |||
1202 | } | 1244 | } |
1203 | EXPORT_SYMBOL(iwl3945_add_bcast_station); | 1245 | EXPORT_SYMBOL(iwl3945_add_bcast_station); |
1204 | 1246 | ||
@@ -1221,6 +1263,13 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr) | |||
1221 | /* If we are a client station in a BSS network, use the special | 1263 | /* If we are a client station in a BSS network, use the special |
1222 | * AP station entry (that's the only station we communicate with) */ | 1264 | * AP station entry (that's the only station we communicate with) */ |
1223 | case NL80211_IFTYPE_STATION: | 1265 | case NL80211_IFTYPE_STATION: |
1266 | /* | ||
1267 | * If addition of station not complete yet, which means | ||
1268 | * that rate scaling has not been initialized, then return | ||
1269 | * the broadcast station. | ||
1270 | */ | ||
1271 | if (!(priv->stations[IWL_AP_ID].used & IWL_STA_UCODE_ACTIVE)) | ||
1272 | return priv->hw_params.bcast_sta_id; | ||
1224 | return IWL_AP_ID; | 1273 | return IWL_AP_ID; |
1225 | 1274 | ||
1226 | /* If we are an AP, then find the station, or use BCAST */ | 1275 | /* If we are an AP, then find the station, or use BCAST */ |
@@ -1237,13 +1286,6 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr) | |||
1237 | if (sta_id != IWL_INVALID_STATION) | 1286 | if (sta_id != IWL_INVALID_STATION) |
1238 | return sta_id; | 1287 | return sta_id; |
1239 | 1288 | ||
1240 | /* Create new station table entry */ | ||
1241 | sta_id = iwl_add_station(priv, hdr->addr1, false, | ||
1242 | CMD_ASYNC, NULL); | ||
1243 | |||
1244 | if (sta_id != IWL_INVALID_STATION) | ||
1245 | return sta_id; | ||
1246 | |||
1247 | IWL_DEBUG_DROP(priv, "Station %pM not in station map. " | 1289 | IWL_DEBUG_DROP(priv, "Station %pM not in station map. " |
1248 | "Defaulting to broadcast...\n", | 1290 | "Defaulting to broadcast...\n", |
1249 | hdr->addr1); | 1291 | hdr->addr1); |
@@ -1353,3 +1395,19 @@ void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) | |||
1353 | 1395 | ||
1354 | iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); | 1396 | iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); |
1355 | } | 1397 | } |
1398 | |||
1399 | int iwl_mac_sta_remove(struct ieee80211_hw *hw, | ||
1400 | struct ieee80211_vif *vif, | ||
1401 | struct ieee80211_sta *sta) | ||
1402 | { | ||
1403 | int ret; | ||
1404 | struct iwl_priv *priv = hw->priv; | ||
1405 | IWL_DEBUG_INFO(priv, "received request to remove station %pM\n", | ||
1406 | sta->addr); | ||
1407 | ret = iwl_remove_station(priv, sta); | ||
1408 | if (ret) | ||
1409 | IWL_ERR(priv, "Error removing station %pM\n", | ||
1410 | sta->addr); | ||
1411 | return ret; | ||
1412 | } | ||
1413 | EXPORT_SYMBOL(iwl_mac_sta_remove); | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.h b/drivers/net/wireless/iwlwifi/iwl-sta.h index 50367e83defd..87a34997a758 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sta.h +++ b/drivers/net/wireless/iwlwifi/iwl-sta.h | |||
@@ -57,10 +57,8 @@ void iwl_update_tkip_key(struct iwl_priv *priv, | |||
57 | struct ieee80211_key_conf *keyconf, | 57 | struct ieee80211_key_conf *keyconf, |
58 | const u8 *addr, u32 iv32, u16 *phase1key); | 58 | const u8 *addr, u32 iv32, u16 *phase1key); |
59 | 59 | ||
60 | int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap); | ||
61 | void iwl_add_bcast_station(struct iwl_priv *priv); | 60 | void iwl_add_bcast_station(struct iwl_priv *priv); |
62 | void iwl3945_add_bcast_station(struct iwl_priv *priv); | 61 | void iwl3945_add_bcast_station(struct iwl_priv *priv); |
63 | int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, bool is_ap); | ||
64 | void iwl_restore_stations(struct iwl_priv *priv); | 62 | void iwl_restore_stations(struct iwl_priv *priv); |
65 | void iwl_clear_ucode_stations(struct iwl_priv *priv, bool force); | 63 | void iwl_clear_ucode_stations(struct iwl_priv *priv, bool force); |
66 | int iwl_get_free_ucode_key_index(struct iwl_priv *priv); | 64 | int iwl_get_free_ucode_key_index(struct iwl_priv *priv); |
@@ -68,8 +66,13 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr); | |||
68 | int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr); | 66 | int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr); |
69 | int iwl_send_add_sta(struct iwl_priv *priv, | 67 | int iwl_send_add_sta(struct iwl_priv *priv, |
70 | struct iwl_addsta_cmd *sta, u8 flags); | 68 | struct iwl_addsta_cmd *sta, u8 flags); |
71 | u8 iwl_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap, u8 flags, | 69 | int iwl_add_local_station(struct iwl_priv *priv, const u8 *addr, bool init_rs); |
72 | struct ieee80211_sta_ht_cap *ht_info); | 70 | int iwl_add_station_common(struct iwl_priv *priv, const u8 *addr, |
71 | bool is_ap, | ||
72 | struct ieee80211_sta_ht_cap *ht_info, | ||
73 | u8 *sta_id_r); | ||
74 | int iwl_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | ||
75 | struct ieee80211_sta *sta); | ||
73 | void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid); | 76 | void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid); |
74 | int iwl_sta_rx_agg_start(struct iwl_priv *priv, | 77 | int iwl_sta_rx_agg_start(struct iwl_priv *priv, |
75 | const u8 *addr, int tid, u16 ssn); | 78 | const u8 *addr, int tid, u16 ssn); |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 6d3e6a85f932..6687b9456554 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -3116,12 +3116,13 @@ void iwl3945_post_associate(struct iwl_priv *priv) | |||
3116 | case NL80211_IFTYPE_ADHOC: | 3116 | case NL80211_IFTYPE_ADHOC: |
3117 | 3117 | ||
3118 | priv->assoc_id = 1; | 3118 | priv->assoc_id = 1; |
3119 | iwl_add_station(priv, priv->bssid, 0, CMD_SYNC, NULL); | 3119 | iwl_add_local_station(priv, priv->bssid, false); |
3120 | iwl3945_sync_sta(priv, IWL_STA_ID, | 3120 | iwl3945_sync_sta(priv, IWL_STA_ID, |
3121 | (priv->band == IEEE80211_BAND_5GHZ) ? | 3121 | (priv->band == IEEE80211_BAND_5GHZ) ? |
3122 | IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP, | 3122 | IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP, |
3123 | CMD_ASYNC); | 3123 | CMD_ASYNC); |
3124 | iwl3945_rate_scale_init(priv->hw, IWL_STA_ID); | 3124 | iwl3945_rate_scale_init(priv->hw, IWL_STA_ID); |
3125 | |||
3125 | iwl3945_send_beacon_cmd(priv); | 3126 | iwl3945_send_beacon_cmd(priv); |
3126 | 3127 | ||
3127 | break; | 3128 | break; |
@@ -3306,7 +3307,7 @@ void iwl3945_config_ap(struct iwl_priv *priv) | |||
3306 | /* restore RXON assoc */ | 3307 | /* restore RXON assoc */ |
3307 | priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; | 3308 | priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; |
3308 | iwlcore_commit_rxon(priv); | 3309 | iwlcore_commit_rxon(priv); |
3309 | iwl_add_station(priv, iwl_bcast_addr, 0, CMD_SYNC, NULL); | 3310 | iwl_add_local_station(priv, iwl_bcast_addr, false); |
3310 | } | 3311 | } |
3311 | iwl3945_send_beacon_cmd(priv); | 3312 | iwl3945_send_beacon_cmd(priv); |
3312 | 3313 | ||
@@ -3373,6 +3374,38 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
3373 | return ret; | 3374 | return ret; |
3374 | } | 3375 | } |
3375 | 3376 | ||
3377 | static int iwl3945_mac_sta_add(struct ieee80211_hw *hw, | ||
3378 | struct ieee80211_vif *vif, | ||
3379 | struct ieee80211_sta *sta) | ||
3380 | { | ||
3381 | struct iwl_priv *priv = hw->priv; | ||
3382 | int ret; | ||
3383 | bool is_ap = priv->iw_mode == NL80211_IFTYPE_STATION; | ||
3384 | u8 sta_id; | ||
3385 | |||
3386 | IWL_DEBUG_INFO(priv, "received request to add station %pM\n", | ||
3387 | sta->addr); | ||
3388 | |||
3389 | ret = iwl_add_station_common(priv, sta->addr, is_ap, &sta->ht_cap, | ||
3390 | &sta_id); | ||
3391 | if (ret) { | ||
3392 | IWL_ERR(priv, "Unable to add station %pM (%d)\n", | ||
3393 | sta->addr, ret); | ||
3394 | /* Should we return success if return code is EEXIST ? */ | ||
3395 | return ret; | ||
3396 | } | ||
3397 | |||
3398 | /* Initialize rate scaling */ | ||
3399 | IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM \n", | ||
3400 | sta->addr); | ||
3401 | iwl3945_rs_rate_init(priv, sta, sta_id); | ||
3402 | |||
3403 | return 0; | ||
3404 | |||
3405 | |||
3406 | |||
3407 | return ret; | ||
3408 | } | ||
3376 | /***************************************************************************** | 3409 | /***************************************************************************** |
3377 | * | 3410 | * |
3378 | * sysfs attributes | 3411 | * sysfs attributes |
@@ -3812,7 +3845,9 @@ static struct ieee80211_ops iwl3945_hw_ops = { | |||
3812 | .conf_tx = iwl_mac_conf_tx, | 3845 | .conf_tx = iwl_mac_conf_tx, |
3813 | .reset_tsf = iwl_mac_reset_tsf, | 3846 | .reset_tsf = iwl_mac_reset_tsf, |
3814 | .bss_info_changed = iwl_bss_info_changed, | 3847 | .bss_info_changed = iwl_bss_info_changed, |
3815 | .hw_scan = iwl_mac_hw_scan | 3848 | .hw_scan = iwl_mac_hw_scan, |
3849 | .sta_add = iwl3945_mac_sta_add, | ||
3850 | .sta_remove = iwl_mac_sta_remove, | ||
3816 | }; | 3851 | }; |
3817 | 3852 | ||
3818 | static int iwl3945_init_drv(struct iwl_priv *priv) | 3853 | static int iwl3945_init_drv(struct iwl_priv *priv) |