diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-09-09 08:42:50 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-09-11 15:53:39 -0400 |
commit | de1ede7ac3bd300f9aa565d0f93f6cf9ba74bb1a (patch) | |
tree | 82e48b4140e9444104639a97aa55be03c5020466 | |
parent | 5825fe100d654fff89aa67a1e202af1f8a7f0ad0 (diff) |
mac80211: make BA session handling independent of STA mode
The aggregation handling isn't dependent on anything related to our
STA-mode implementation, and doesn't need to depend on it for frame
processing. This patch moves the relevant code to ht.c and adds a
hook in rx.c. For now, the relevant action frames are only processed
in STA/IBSS modes, but that's now something we can easily change.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | net/mac80211/ht.c | 303 | ||||
-rw-r--r-- | net/mac80211/ieee80211_i.h | 39 | ||||
-rw-r--r-- | net/mac80211/mlme.c | 340 | ||||
-rw-r--r-- | net/mac80211/rx.c | 60 |
4 files changed, 380 insertions, 362 deletions
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c index c72b3fe3ccdb..7e93e1079ade 100644 --- a/net/mac80211/ht.c +++ b/net/mac80211/ht.c | |||
@@ -66,9 +66,10 @@ int ieee80211_ht_addt_info_ie_to_ht_bss_info( | |||
66 | return 0; | 66 | return 0; |
67 | } | 67 | } |
68 | 68 | ||
69 | void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata, const u8 *da, | 69 | static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata, |
70 | u16 tid, u8 dialog_token, u16 start_seq_num, | 70 | const u8 *da, u16 tid, |
71 | u16 agg_size, u16 timeout) | 71 | u8 dialog_token, u16 start_seq_num, |
72 | u16 agg_size, u16 timeout) | ||
72 | { | 73 | { |
73 | struct ieee80211_local *local = sdata->local; | 74 | struct ieee80211_local *local = sdata->local; |
74 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 75 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
@@ -115,8 +116,55 @@ void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata, const u8 | |||
115 | ieee80211_sta_tx(sdata, skb, 0); | 116 | ieee80211_sta_tx(sdata, skb, 0); |
116 | } | 117 | } |
117 | 118 | ||
118 | void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, const u8 *da, u16 tid, | 119 | static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *da, u16 tid, |
119 | u16 initiator, u16 reason_code) | 120 | u8 dialog_token, u16 status, u16 policy, |
121 | u16 buf_size, u16 timeout) | ||
122 | { | ||
123 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | ||
124 | struct ieee80211_local *local = sdata->local; | ||
125 | struct sk_buff *skb; | ||
126 | struct ieee80211_mgmt *mgmt; | ||
127 | u16 capab; | ||
128 | |||
129 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); | ||
130 | |||
131 | if (!skb) { | ||
132 | printk(KERN_DEBUG "%s: failed to allocate buffer " | ||
133 | "for addba resp frame\n", sdata->dev->name); | ||
134 | return; | ||
135 | } | ||
136 | |||
137 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
138 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | ||
139 | memset(mgmt, 0, 24); | ||
140 | memcpy(mgmt->da, da, ETH_ALEN); | ||
141 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | ||
142 | if (sdata->vif.type == IEEE80211_IF_TYPE_AP) | ||
143 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); | ||
144 | else | ||
145 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | ||
146 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
147 | IEEE80211_STYPE_ACTION); | ||
148 | |||
149 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_resp)); | ||
150 | mgmt->u.action.category = WLAN_CATEGORY_BACK; | ||
151 | mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP; | ||
152 | mgmt->u.action.u.addba_resp.dialog_token = dialog_token; | ||
153 | |||
154 | capab = (u16)(policy << 1); /* bit 1 aggregation policy */ | ||
155 | capab |= (u16)(tid << 2); /* bit 5:2 TID number */ | ||
156 | capab |= (u16)(buf_size << 6); /* bit 15:6 max size of aggregation */ | ||
157 | |||
158 | mgmt->u.action.u.addba_resp.capab = cpu_to_le16(capab); | ||
159 | mgmt->u.action.u.addba_resp.timeout = cpu_to_le16(timeout); | ||
160 | mgmt->u.action.u.addba_resp.status = cpu_to_le16(status); | ||
161 | |||
162 | ieee80211_sta_tx(sdata, skb, 0); | ||
163 | } | ||
164 | |||
165 | static void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, | ||
166 | const u8 *da, u16 tid, | ||
167 | u16 initiator, u16 reason_code) | ||
120 | { | 168 | { |
121 | struct ieee80211_local *local = sdata->local; | 169 | struct ieee80211_local *local = sdata->local; |
122 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 170 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
@@ -263,7 +311,7 @@ void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *r | |||
263 | * add Block Ack response will arrive from the recipient. | 311 | * add Block Ack response will arrive from the recipient. |
264 | * If this timer expires sta_addba_resp_timer_expired will be executed. | 312 | * If this timer expires sta_addba_resp_timer_expired will be executed. |
265 | */ | 313 | */ |
266 | void sta_addba_resp_timer_expired(unsigned long data) | 314 | static void sta_addba_resp_timer_expired(unsigned long data) |
267 | { | 315 | { |
268 | /* not an elegant detour, but there is no choice as the timer passes | 316 | /* not an elegant detour, but there is no choice as the timer passes |
269 | * only one argument, and both sta_info and TID are needed, so init | 317 | * only one argument, and both sta_info and TID are needed, so init |
@@ -699,3 +747,246 @@ void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, | |||
699 | tasklet_schedule(&local->tasklet); | 747 | tasklet_schedule(&local->tasklet); |
700 | } | 748 | } |
701 | EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe); | 749 | EXPORT_SYMBOL(ieee80211_stop_tx_ba_cb_irqsafe); |
750 | |||
751 | /* | ||
752 | * After accepting the AddBA Request we activated a timer, | ||
753 | * resetting it after each frame that arrives from the originator. | ||
754 | * if this timer expires ieee80211_sta_stop_rx_ba_session will be executed. | ||
755 | */ | ||
756 | static void sta_rx_agg_session_timer_expired(unsigned long data) | ||
757 | { | ||
758 | /* not an elegant detour, but there is no choice as the timer passes | ||
759 | * only one argument, and various sta_info are needed here, so init | ||
760 | * flow in sta_info_create gives the TID as data, while the timer_to_id | ||
761 | * array gives the sta through container_of */ | ||
762 | u8 *ptid = (u8 *)data; | ||
763 | u8 *timer_to_id = ptid - *ptid; | ||
764 | struct sta_info *sta = container_of(timer_to_id, struct sta_info, | ||
765 | timer_to_tid[0]); | ||
766 | |||
767 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
768 | printk(KERN_DEBUG "rx session timer expired on tid %d\n", (u16)*ptid); | ||
769 | #endif | ||
770 | ieee80211_sta_stop_rx_ba_session(sta->sdata, sta->addr, | ||
771 | (u16)*ptid, WLAN_BACK_TIMER, | ||
772 | WLAN_REASON_QSTA_TIMEOUT); | ||
773 | } | ||
774 | |||
775 | void ieee80211_process_addba_request(struct ieee80211_local *local, | ||
776 | struct sta_info *sta, | ||
777 | struct ieee80211_mgmt *mgmt, | ||
778 | size_t len) | ||
779 | { | ||
780 | struct ieee80211_hw *hw = &local->hw; | ||
781 | struct ieee80211_conf *conf = &hw->conf; | ||
782 | struct tid_ampdu_rx *tid_agg_rx; | ||
783 | u16 capab, tid, timeout, ba_policy, buf_size, start_seq_num, status; | ||
784 | u8 dialog_token; | ||
785 | int ret = -EOPNOTSUPP; | ||
786 | DECLARE_MAC_BUF(mac); | ||
787 | |||
788 | /* extract session parameters from addba request frame */ | ||
789 | dialog_token = mgmt->u.action.u.addba_req.dialog_token; | ||
790 | timeout = le16_to_cpu(mgmt->u.action.u.addba_req.timeout); | ||
791 | start_seq_num = | ||
792 | le16_to_cpu(mgmt->u.action.u.addba_req.start_seq_num) >> 4; | ||
793 | |||
794 | capab = le16_to_cpu(mgmt->u.action.u.addba_req.capab); | ||
795 | ba_policy = (capab & IEEE80211_ADDBA_PARAM_POLICY_MASK) >> 1; | ||
796 | tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; | ||
797 | buf_size = (capab & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) >> 6; | ||
798 | |||
799 | status = WLAN_STATUS_REQUEST_DECLINED; | ||
800 | |||
801 | /* sanity check for incoming parameters: | ||
802 | * check if configuration can support the BA policy | ||
803 | * and if buffer size does not exceeds max value */ | ||
804 | if (((ba_policy != 1) | ||
805 | && (!(conf->ht_conf.cap & IEEE80211_HT_CAP_DELAY_BA))) | ||
806 | || (buf_size > IEEE80211_MAX_AMPDU_BUF)) { | ||
807 | status = WLAN_STATUS_INVALID_QOS_PARAM; | ||
808 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
809 | if (net_ratelimit()) | ||
810 | printk(KERN_DEBUG "AddBA Req with bad params from " | ||
811 | "%s on tid %u. policy %d, buffer size %d\n", | ||
812 | print_mac(mac, mgmt->sa), tid, ba_policy, | ||
813 | buf_size); | ||
814 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
815 | goto end_no_lock; | ||
816 | } | ||
817 | /* determine default buffer size */ | ||
818 | if (buf_size == 0) { | ||
819 | struct ieee80211_supported_band *sband; | ||
820 | |||
821 | sband = local->hw.wiphy->bands[conf->channel->band]; | ||
822 | buf_size = IEEE80211_MIN_AMPDU_BUF; | ||
823 | buf_size = buf_size << sband->ht_info.ampdu_factor; | ||
824 | } | ||
825 | |||
826 | |||
827 | /* examine state machine */ | ||
828 | spin_lock_bh(&sta->lock); | ||
829 | |||
830 | if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_IDLE) { | ||
831 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
832 | if (net_ratelimit()) | ||
833 | printk(KERN_DEBUG "unexpected AddBA Req from " | ||
834 | "%s on tid %u\n", | ||
835 | print_mac(mac, mgmt->sa), tid); | ||
836 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
837 | goto end; | ||
838 | } | ||
839 | |||
840 | /* prepare A-MPDU MLME for Rx aggregation */ | ||
841 | sta->ampdu_mlme.tid_rx[tid] = | ||
842 | kmalloc(sizeof(struct tid_ampdu_rx), GFP_ATOMIC); | ||
843 | if (!sta->ampdu_mlme.tid_rx[tid]) { | ||
844 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
845 | if (net_ratelimit()) | ||
846 | printk(KERN_ERR "allocate rx mlme to tid %d failed\n", | ||
847 | tid); | ||
848 | #endif | ||
849 | goto end; | ||
850 | } | ||
851 | /* rx timer */ | ||
852 | sta->ampdu_mlme.tid_rx[tid]->session_timer.function = | ||
853 | sta_rx_agg_session_timer_expired; | ||
854 | sta->ampdu_mlme.tid_rx[tid]->session_timer.data = | ||
855 | (unsigned long)&sta->timer_to_tid[tid]; | ||
856 | init_timer(&sta->ampdu_mlme.tid_rx[tid]->session_timer); | ||
857 | |||
858 | tid_agg_rx = sta->ampdu_mlme.tid_rx[tid]; | ||
859 | |||
860 | /* prepare reordering buffer */ | ||
861 | tid_agg_rx->reorder_buf = | ||
862 | kmalloc(buf_size * sizeof(struct sk_buff *), GFP_ATOMIC); | ||
863 | if (!tid_agg_rx->reorder_buf) { | ||
864 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
865 | if (net_ratelimit()) | ||
866 | printk(KERN_ERR "can not allocate reordering buffer " | ||
867 | "to tid %d\n", tid); | ||
868 | #endif | ||
869 | kfree(sta->ampdu_mlme.tid_rx[tid]); | ||
870 | goto end; | ||
871 | } | ||
872 | memset(tid_agg_rx->reorder_buf, 0, | ||
873 | buf_size * sizeof(struct sk_buff *)); | ||
874 | |||
875 | if (local->ops->ampdu_action) | ||
876 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_START, | ||
877 | sta->addr, tid, &start_seq_num); | ||
878 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
879 | printk(KERN_DEBUG "Rx A-MPDU request on tid %d result %d\n", tid, ret); | ||
880 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
881 | |||
882 | if (ret) { | ||
883 | kfree(tid_agg_rx->reorder_buf); | ||
884 | kfree(tid_agg_rx); | ||
885 | sta->ampdu_mlme.tid_rx[tid] = NULL; | ||
886 | goto end; | ||
887 | } | ||
888 | |||
889 | /* change state and send addba resp */ | ||
890 | sta->ampdu_mlme.tid_state_rx[tid] = HT_AGG_STATE_OPERATIONAL; | ||
891 | tid_agg_rx->dialog_token = dialog_token; | ||
892 | tid_agg_rx->ssn = start_seq_num; | ||
893 | tid_agg_rx->head_seq_num = start_seq_num; | ||
894 | tid_agg_rx->buf_size = buf_size; | ||
895 | tid_agg_rx->timeout = timeout; | ||
896 | tid_agg_rx->stored_mpdu_num = 0; | ||
897 | status = WLAN_STATUS_SUCCESS; | ||
898 | end: | ||
899 | spin_unlock_bh(&sta->lock); | ||
900 | |||
901 | end_no_lock: | ||
902 | ieee80211_send_addba_resp(sta->sdata, sta->addr, tid, | ||
903 | dialog_token, status, 1, buf_size, timeout); | ||
904 | } | ||
905 | |||
906 | void ieee80211_process_addba_resp(struct ieee80211_local *local, | ||
907 | struct sta_info *sta, | ||
908 | struct ieee80211_mgmt *mgmt, | ||
909 | size_t len) | ||
910 | { | ||
911 | struct ieee80211_hw *hw = &local->hw; | ||
912 | u16 capab; | ||
913 | u16 tid; | ||
914 | u8 *state; | ||
915 | |||
916 | capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab); | ||
917 | tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; | ||
918 | |||
919 | state = &sta->ampdu_mlme.tid_state_tx[tid]; | ||
920 | |||
921 | spin_lock_bh(&sta->lock); | ||
922 | |||
923 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { | ||
924 | spin_unlock_bh(&sta->lock); | ||
925 | return; | ||
926 | } | ||
927 | |||
928 | if (mgmt->u.action.u.addba_resp.dialog_token != | ||
929 | sta->ampdu_mlme.tid_tx[tid]->dialog_token) { | ||
930 | spin_unlock_bh(&sta->lock); | ||
931 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
932 | printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid); | ||
933 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
934 | return; | ||
935 | } | ||
936 | |||
937 | del_timer_sync(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer); | ||
938 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
939 | printk(KERN_DEBUG "switched off addBA timer for tid %d \n", tid); | ||
940 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
941 | if (le16_to_cpu(mgmt->u.action.u.addba_resp.status) | ||
942 | == WLAN_STATUS_SUCCESS) { | ||
943 | *state |= HT_ADDBA_RECEIVED_MSK; | ||
944 | sta->ampdu_mlme.addba_req_num[tid] = 0; | ||
945 | |||
946 | if (*state == HT_AGG_STATE_OPERATIONAL) | ||
947 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); | ||
948 | |||
949 | spin_unlock_bh(&sta->lock); | ||
950 | } else { | ||
951 | sta->ampdu_mlme.addba_req_num[tid]++; | ||
952 | /* this will allow the state check in stop_BA_session */ | ||
953 | *state = HT_AGG_STATE_OPERATIONAL; | ||
954 | spin_unlock_bh(&sta->lock); | ||
955 | ieee80211_stop_tx_ba_session(hw, sta->addr, tid, | ||
956 | WLAN_BACK_INITIATOR); | ||
957 | } | ||
958 | } | ||
959 | |||
960 | void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata, | ||
961 | struct sta_info *sta, | ||
962 | struct ieee80211_mgmt *mgmt, size_t len) | ||
963 | { | ||
964 | struct ieee80211_local *local = sdata->local; | ||
965 | u16 tid, params; | ||
966 | u16 initiator; | ||
967 | DECLARE_MAC_BUF(mac); | ||
968 | |||
969 | params = le16_to_cpu(mgmt->u.action.u.delba.params); | ||
970 | tid = (params & IEEE80211_DELBA_PARAM_TID_MASK) >> 12; | ||
971 | initiator = (params & IEEE80211_DELBA_PARAM_INITIATOR_MASK) >> 11; | ||
972 | |||
973 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
974 | if (net_ratelimit()) | ||
975 | printk(KERN_DEBUG "delba from %s (%s) tid %d reason code %d\n", | ||
976 | print_mac(mac, mgmt->sa), | ||
977 | initiator ? "initiator" : "recipient", tid, | ||
978 | mgmt->u.action.u.delba.reason_code); | ||
979 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
980 | |||
981 | if (initiator == WLAN_BACK_INITIATOR) | ||
982 | ieee80211_sta_stop_rx_ba_session(sdata, sta->addr, tid, | ||
983 | WLAN_BACK_INITIATOR, 0); | ||
984 | else { /* WLAN_BACK_RECIPIENT */ | ||
985 | spin_lock_bh(&sta->lock); | ||
986 | sta->ampdu_mlme.tid_state_tx[tid] = | ||
987 | HT_AGG_STATE_OPERATIONAL; | ||
988 | spin_unlock_bh(&sta->lock); | ||
989 | ieee80211_stop_tx_ba_session(&local->hw, sta->addr, tid, | ||
990 | WLAN_BACK_RECIPIENT); | ||
991 | } | ||
992 | } | ||
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index b10e70715db0..60ec7ad27643 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -909,22 +909,6 @@ int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason); | |||
909 | void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, | 909 | void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, |
910 | u32 changed); | 910 | u32 changed); |
911 | u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); | 911 | u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); |
912 | int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie, | ||
913 | struct ieee80211_ht_info *ht_info); | ||
914 | int ieee80211_ht_addt_info_ie_to_ht_bss_info( | ||
915 | struct ieee80211_ht_addt_info *ht_add_info_ie, | ||
916 | struct ieee80211_ht_bss_info *bss_info); | ||
917 | void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata, const u8 *da, | ||
918 | u16 tid, u8 dialog_token, u16 start_seq_num, | ||
919 | u16 agg_size, u16 timeout); | ||
920 | void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, const u8 *da, u16 tid, | ||
921 | u16 initiator, u16 reason_code); | ||
922 | void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn); | ||
923 | |||
924 | void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *da, | ||
925 | u16 tid, u16 initiator, u16 reason); | ||
926 | void sta_addba_resp_timer_expired(unsigned long data); | ||
927 | void ieee80211_sta_tear_down_BA_sessions(struct ieee80211_sub_if_data *sdata, u8 *addr); | ||
928 | u64 ieee80211_sta_get_rates(struct ieee80211_local *local, | 912 | u64 ieee80211_sta_get_rates(struct ieee80211_local *local, |
929 | struct ieee802_11_elems *elems, | 913 | struct ieee802_11_elems *elems, |
930 | enum ieee80211_band band); | 914 | enum ieee80211_band band); |
@@ -977,6 +961,29 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev); | |||
977 | int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); | 961 | int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); |
978 | int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); | 962 | int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev); |
979 | 963 | ||
964 | /* HT */ | ||
965 | int ieee80211_ht_cap_ie_to_ht_info(struct ieee80211_ht_cap *ht_cap_ie, | ||
966 | struct ieee80211_ht_info *ht_info); | ||
967 | int ieee80211_ht_addt_info_ie_to_ht_bss_info( | ||
968 | struct ieee80211_ht_addt_info *ht_add_info_ie, | ||
969 | struct ieee80211_ht_bss_info *bss_info); | ||
970 | void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u16 ssn); | ||
971 | |||
972 | void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *da, | ||
973 | u16 tid, u16 initiator, u16 reason); | ||
974 | void ieee80211_sta_tear_down_BA_sessions(struct ieee80211_sub_if_data *sdata, u8 *addr); | ||
975 | void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata, | ||
976 | struct sta_info *sta, | ||
977 | struct ieee80211_mgmt *mgmt, size_t len); | ||
978 | void ieee80211_process_addba_resp(struct ieee80211_local *local, | ||
979 | struct sta_info *sta, | ||
980 | struct ieee80211_mgmt *mgmt, | ||
981 | size_t len); | ||
982 | void ieee80211_process_addba_request(struct ieee80211_local *local, | ||
983 | struct sta_info *sta, | ||
984 | struct ieee80211_mgmt *mgmt, | ||
985 | size_t len); | ||
986 | |||
980 | /* utility functions/constants */ | 987 | /* utility functions/constants */ |
981 | extern void *mac80211_wiphy_privid; /* for wiphy privid */ | 988 | extern void *mac80211_wiphy_privid; /* for wiphy privid */ |
982 | extern const unsigned char rfc1042_header[6]; | 989 | extern const unsigned char rfc1042_header[6]; |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index c22dcd605e48..25f90f7ccf3e 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -445,52 +445,6 @@ static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, | |||
445 | ieee80211_sta_tx(sdata, skb, 0); | 445 | ieee80211_sta_tx(sdata, skb, 0); |
446 | } | 446 | } |
447 | 447 | ||
448 | static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *da, u16 tid, | ||
449 | u8 dialog_token, u16 status, u16 policy, | ||
450 | u16 buf_size, u16 timeout) | ||
451 | { | ||
452 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | ||
453 | struct ieee80211_local *local = sdata->local; | ||
454 | struct sk_buff *skb; | ||
455 | struct ieee80211_mgmt *mgmt; | ||
456 | u16 capab; | ||
457 | |||
458 | skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom); | ||
459 | |||
460 | if (!skb) { | ||
461 | printk(KERN_DEBUG "%s: failed to allocate buffer " | ||
462 | "for addba resp frame\n", sdata->dev->name); | ||
463 | return; | ||
464 | } | ||
465 | |||
466 | skb_reserve(skb, local->hw.extra_tx_headroom); | ||
467 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); | ||
468 | memset(mgmt, 0, 24); | ||
469 | memcpy(mgmt->da, da, ETH_ALEN); | ||
470 | memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); | ||
471 | if (sdata->vif.type == IEEE80211_IF_TYPE_AP) | ||
472 | memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); | ||
473 | else | ||
474 | memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); | ||
475 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | ||
476 | IEEE80211_STYPE_ACTION); | ||
477 | |||
478 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_resp)); | ||
479 | mgmt->u.action.category = WLAN_CATEGORY_BACK; | ||
480 | mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP; | ||
481 | mgmt->u.action.u.addba_resp.dialog_token = dialog_token; | ||
482 | |||
483 | capab = (u16)(policy << 1); /* bit 1 aggregation policy */ | ||
484 | capab |= (u16)(tid << 2); /* bit 5:2 TID number */ | ||
485 | capab |= (u16)(buf_size << 6); /* bit 15:6 max size of aggregation */ | ||
486 | |||
487 | mgmt->u.action.u.addba_resp.capab = cpu_to_le16(capab); | ||
488 | mgmt->u.action.u.addba_resp.timeout = cpu_to_le16(timeout); | ||
489 | mgmt->u.action.u.addba_resp.status = cpu_to_le16(status); | ||
490 | |||
491 | ieee80211_sta_tx(sdata, skb, 0); | ||
492 | } | ||
493 | |||
494 | static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_data *sdata, | 448 | static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_data *sdata, |
495 | struct ieee80211_msrment_ie *request_ie, | 449 | struct ieee80211_msrment_ie *request_ie, |
496 | const u8 *da, const u8 *bssid, | 450 | const u8 *da, const u8 *bssid, |
@@ -1057,278 +1011,6 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, | |||
1057 | elems.challenge_len + 2, 1); | 1011 | elems.challenge_len + 2, 1); |
1058 | } | 1012 | } |
1059 | 1013 | ||
1060 | /* | ||
1061 | * After accepting the AddBA Request we activated a timer, | ||
1062 | * resetting it after each frame that arrives from the originator. | ||
1063 | * if this timer expires ieee80211_sta_stop_rx_ba_session will be executed. | ||
1064 | */ | ||
1065 | static void sta_rx_agg_session_timer_expired(unsigned long data) | ||
1066 | { | ||
1067 | /* not an elegant detour, but there is no choice as the timer passes | ||
1068 | * only one argument, and various sta_info are needed here, so init | ||
1069 | * flow in sta_info_create gives the TID as data, while the timer_to_id | ||
1070 | * array gives the sta through container_of */ | ||
1071 | u8 *ptid = (u8 *)data; | ||
1072 | u8 *timer_to_id = ptid - *ptid; | ||
1073 | struct sta_info *sta = container_of(timer_to_id, struct sta_info, | ||
1074 | timer_to_tid[0]); | ||
1075 | |||
1076 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1077 | printk(KERN_DEBUG "rx session timer expired on tid %d\n", (u16)*ptid); | ||
1078 | #endif | ||
1079 | ieee80211_sta_stop_rx_ba_session(sta->sdata, sta->addr, | ||
1080 | (u16)*ptid, WLAN_BACK_TIMER, | ||
1081 | WLAN_REASON_QSTA_TIMEOUT); | ||
1082 | } | ||
1083 | |||
1084 | static void ieee80211_sta_process_addba_request(struct ieee80211_local *local, | ||
1085 | struct ieee80211_mgmt *mgmt, | ||
1086 | size_t len) | ||
1087 | { | ||
1088 | struct ieee80211_hw *hw = &local->hw; | ||
1089 | struct ieee80211_conf *conf = &hw->conf; | ||
1090 | struct sta_info *sta; | ||
1091 | struct tid_ampdu_rx *tid_agg_rx; | ||
1092 | u16 capab, tid, timeout, ba_policy, buf_size, start_seq_num, status; | ||
1093 | u8 dialog_token; | ||
1094 | int ret = -EOPNOTSUPP; | ||
1095 | DECLARE_MAC_BUF(mac); | ||
1096 | |||
1097 | rcu_read_lock(); | ||
1098 | |||
1099 | sta = sta_info_get(local, mgmt->sa); | ||
1100 | if (!sta) { | ||
1101 | rcu_read_unlock(); | ||
1102 | return; | ||
1103 | } | ||
1104 | |||
1105 | /* extract session parameters from addba request frame */ | ||
1106 | dialog_token = mgmt->u.action.u.addba_req.dialog_token; | ||
1107 | timeout = le16_to_cpu(mgmt->u.action.u.addba_req.timeout); | ||
1108 | start_seq_num = | ||
1109 | le16_to_cpu(mgmt->u.action.u.addba_req.start_seq_num) >> 4; | ||
1110 | |||
1111 | capab = le16_to_cpu(mgmt->u.action.u.addba_req.capab); | ||
1112 | ba_policy = (capab & IEEE80211_ADDBA_PARAM_POLICY_MASK) >> 1; | ||
1113 | tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; | ||
1114 | buf_size = (capab & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) >> 6; | ||
1115 | |||
1116 | status = WLAN_STATUS_REQUEST_DECLINED; | ||
1117 | |||
1118 | /* sanity check for incoming parameters: | ||
1119 | * check if configuration can support the BA policy | ||
1120 | * and if buffer size does not exceeds max value */ | ||
1121 | if (((ba_policy != 1) | ||
1122 | && (!(conf->ht_conf.cap & IEEE80211_HT_CAP_DELAY_BA))) | ||
1123 | || (buf_size > IEEE80211_MAX_AMPDU_BUF)) { | ||
1124 | status = WLAN_STATUS_INVALID_QOS_PARAM; | ||
1125 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1126 | if (net_ratelimit()) | ||
1127 | printk(KERN_DEBUG "AddBA Req with bad params from " | ||
1128 | "%s on tid %u. policy %d, buffer size %d\n", | ||
1129 | print_mac(mac, mgmt->sa), tid, ba_policy, | ||
1130 | buf_size); | ||
1131 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1132 | goto end_no_lock; | ||
1133 | } | ||
1134 | /* determine default buffer size */ | ||
1135 | if (buf_size == 0) { | ||
1136 | struct ieee80211_supported_band *sband; | ||
1137 | |||
1138 | sband = local->hw.wiphy->bands[conf->channel->band]; | ||
1139 | buf_size = IEEE80211_MIN_AMPDU_BUF; | ||
1140 | buf_size = buf_size << sband->ht_info.ampdu_factor; | ||
1141 | } | ||
1142 | |||
1143 | |||
1144 | /* examine state machine */ | ||
1145 | spin_lock_bh(&sta->lock); | ||
1146 | |||
1147 | if (sta->ampdu_mlme.tid_state_rx[tid] != HT_AGG_STATE_IDLE) { | ||
1148 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1149 | if (net_ratelimit()) | ||
1150 | printk(KERN_DEBUG "unexpected AddBA Req from " | ||
1151 | "%s on tid %u\n", | ||
1152 | print_mac(mac, mgmt->sa), tid); | ||
1153 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1154 | goto end; | ||
1155 | } | ||
1156 | |||
1157 | /* prepare A-MPDU MLME for Rx aggregation */ | ||
1158 | sta->ampdu_mlme.tid_rx[tid] = | ||
1159 | kmalloc(sizeof(struct tid_ampdu_rx), GFP_ATOMIC); | ||
1160 | if (!sta->ampdu_mlme.tid_rx[tid]) { | ||
1161 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1162 | if (net_ratelimit()) | ||
1163 | printk(KERN_ERR "allocate rx mlme to tid %d failed\n", | ||
1164 | tid); | ||
1165 | #endif | ||
1166 | goto end; | ||
1167 | } | ||
1168 | /* rx timer */ | ||
1169 | sta->ampdu_mlme.tid_rx[tid]->session_timer.function = | ||
1170 | sta_rx_agg_session_timer_expired; | ||
1171 | sta->ampdu_mlme.tid_rx[tid]->session_timer.data = | ||
1172 | (unsigned long)&sta->timer_to_tid[tid]; | ||
1173 | init_timer(&sta->ampdu_mlme.tid_rx[tid]->session_timer); | ||
1174 | |||
1175 | tid_agg_rx = sta->ampdu_mlme.tid_rx[tid]; | ||
1176 | |||
1177 | /* prepare reordering buffer */ | ||
1178 | tid_agg_rx->reorder_buf = | ||
1179 | kmalloc(buf_size * sizeof(struct sk_buff *), GFP_ATOMIC); | ||
1180 | if (!tid_agg_rx->reorder_buf) { | ||
1181 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1182 | if (net_ratelimit()) | ||
1183 | printk(KERN_ERR "can not allocate reordering buffer " | ||
1184 | "to tid %d\n", tid); | ||
1185 | #endif | ||
1186 | kfree(sta->ampdu_mlme.tid_rx[tid]); | ||
1187 | goto end; | ||
1188 | } | ||
1189 | memset(tid_agg_rx->reorder_buf, 0, | ||
1190 | buf_size * sizeof(struct sk_buff *)); | ||
1191 | |||
1192 | if (local->ops->ampdu_action) | ||
1193 | ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_RX_START, | ||
1194 | sta->addr, tid, &start_seq_num); | ||
1195 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1196 | printk(KERN_DEBUG "Rx A-MPDU request on tid %d result %d\n", tid, ret); | ||
1197 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1198 | |||
1199 | if (ret) { | ||
1200 | kfree(tid_agg_rx->reorder_buf); | ||
1201 | kfree(tid_agg_rx); | ||
1202 | sta->ampdu_mlme.tid_rx[tid] = NULL; | ||
1203 | goto end; | ||
1204 | } | ||
1205 | |||
1206 | /* change state and send addba resp */ | ||
1207 | sta->ampdu_mlme.tid_state_rx[tid] = HT_AGG_STATE_OPERATIONAL; | ||
1208 | tid_agg_rx->dialog_token = dialog_token; | ||
1209 | tid_agg_rx->ssn = start_seq_num; | ||
1210 | tid_agg_rx->head_seq_num = start_seq_num; | ||
1211 | tid_agg_rx->buf_size = buf_size; | ||
1212 | tid_agg_rx->timeout = timeout; | ||
1213 | tid_agg_rx->stored_mpdu_num = 0; | ||
1214 | status = WLAN_STATUS_SUCCESS; | ||
1215 | end: | ||
1216 | spin_unlock_bh(&sta->lock); | ||
1217 | |||
1218 | end_no_lock: | ||
1219 | ieee80211_send_addba_resp(sta->sdata, sta->addr, tid, | ||
1220 | dialog_token, status, 1, buf_size, timeout); | ||
1221 | rcu_read_unlock(); | ||
1222 | } | ||
1223 | |||
1224 | static void ieee80211_sta_process_addba_resp(struct ieee80211_local *local, | ||
1225 | struct ieee80211_mgmt *mgmt, | ||
1226 | size_t len) | ||
1227 | { | ||
1228 | struct ieee80211_hw *hw = &local->hw; | ||
1229 | struct sta_info *sta; | ||
1230 | u16 capab; | ||
1231 | u16 tid; | ||
1232 | u8 *state; | ||
1233 | |||
1234 | rcu_read_lock(); | ||
1235 | |||
1236 | sta = sta_info_get(local, mgmt->sa); | ||
1237 | if (!sta) { | ||
1238 | rcu_read_unlock(); | ||
1239 | return; | ||
1240 | } | ||
1241 | |||
1242 | capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab); | ||
1243 | tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; | ||
1244 | |||
1245 | state = &sta->ampdu_mlme.tid_state_tx[tid]; | ||
1246 | |||
1247 | spin_lock_bh(&sta->lock); | ||
1248 | |||
1249 | if (!(*state & HT_ADDBA_REQUESTED_MSK)) { | ||
1250 | spin_unlock_bh(&sta->lock); | ||
1251 | goto addba_resp_exit; | ||
1252 | } | ||
1253 | |||
1254 | if (mgmt->u.action.u.addba_resp.dialog_token != | ||
1255 | sta->ampdu_mlme.tid_tx[tid]->dialog_token) { | ||
1256 | spin_unlock_bh(&sta->lock); | ||
1257 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1258 | printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid); | ||
1259 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1260 | goto addba_resp_exit; | ||
1261 | } | ||
1262 | |||
1263 | del_timer_sync(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer); | ||
1264 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1265 | printk(KERN_DEBUG "switched off addBA timer for tid %d \n", tid); | ||
1266 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1267 | if (le16_to_cpu(mgmt->u.action.u.addba_resp.status) | ||
1268 | == WLAN_STATUS_SUCCESS) { | ||
1269 | *state |= HT_ADDBA_RECEIVED_MSK; | ||
1270 | sta->ampdu_mlme.addba_req_num[tid] = 0; | ||
1271 | |||
1272 | if (*state == HT_AGG_STATE_OPERATIONAL) | ||
1273 | ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); | ||
1274 | |||
1275 | spin_unlock_bh(&sta->lock); | ||
1276 | } else { | ||
1277 | sta->ampdu_mlme.addba_req_num[tid]++; | ||
1278 | /* this will allow the state check in stop_BA_session */ | ||
1279 | *state = HT_AGG_STATE_OPERATIONAL; | ||
1280 | spin_unlock_bh(&sta->lock); | ||
1281 | ieee80211_stop_tx_ba_session(hw, sta->addr, tid, | ||
1282 | WLAN_BACK_INITIATOR); | ||
1283 | } | ||
1284 | |||
1285 | addba_resp_exit: | ||
1286 | rcu_read_unlock(); | ||
1287 | } | ||
1288 | |||
1289 | static void ieee80211_sta_process_delba(struct ieee80211_sub_if_data *sdata, | ||
1290 | struct ieee80211_mgmt *mgmt, size_t len) | ||
1291 | { | ||
1292 | struct ieee80211_local *local = sdata->local; | ||
1293 | struct sta_info *sta; | ||
1294 | u16 tid, params; | ||
1295 | u16 initiator; | ||
1296 | DECLARE_MAC_BUF(mac); | ||
1297 | |||
1298 | rcu_read_lock(); | ||
1299 | |||
1300 | sta = sta_info_get(local, mgmt->sa); | ||
1301 | if (!sta) { | ||
1302 | rcu_read_unlock(); | ||
1303 | return; | ||
1304 | } | ||
1305 | |||
1306 | params = le16_to_cpu(mgmt->u.action.u.delba.params); | ||
1307 | tid = (params & IEEE80211_DELBA_PARAM_TID_MASK) >> 12; | ||
1308 | initiator = (params & IEEE80211_DELBA_PARAM_INITIATOR_MASK) >> 11; | ||
1309 | |||
1310 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
1311 | if (net_ratelimit()) | ||
1312 | printk(KERN_DEBUG "delba from %s (%s) tid %d reason code %d\n", | ||
1313 | print_mac(mac, mgmt->sa), | ||
1314 | initiator ? "initiator" : "recipient", tid, | ||
1315 | mgmt->u.action.u.delba.reason_code); | ||
1316 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
1317 | |||
1318 | if (initiator == WLAN_BACK_INITIATOR) | ||
1319 | ieee80211_sta_stop_rx_ba_session(sdata, sta->addr, tid, | ||
1320 | WLAN_BACK_INITIATOR, 0); | ||
1321 | else { /* WLAN_BACK_RECIPIENT */ | ||
1322 | spin_lock_bh(&sta->lock); | ||
1323 | sta->ampdu_mlme.tid_state_tx[tid] = | ||
1324 | HT_AGG_STATE_OPERATIONAL; | ||
1325 | spin_unlock_bh(&sta->lock); | ||
1326 | ieee80211_stop_tx_ba_session(&local->hw, sta->addr, tid, | ||
1327 | WLAN_BACK_RECIPIENT); | ||
1328 | } | ||
1329 | rcu_read_unlock(); | ||
1330 | } | ||
1331 | |||
1332 | static void ieee80211_sta_process_measurement_req(struct ieee80211_sub_if_data *sdata, | 1014 | static void ieee80211_sta_process_measurement_req(struct ieee80211_sub_if_data *sdata, |
1333 | struct ieee80211_mgmt *mgmt, | 1015 | struct ieee80211_mgmt *mgmt, |
1334 | size_t len) | 1016 | size_t len) |
@@ -2207,28 +1889,6 @@ static void ieee80211_rx_mgmt_action(struct ieee80211_sub_if_data *sdata, | |||
2207 | break; | 1889 | break; |
2208 | } | 1890 | } |
2209 | break; | 1891 | break; |
2210 | case WLAN_CATEGORY_BACK: | ||
2211 | switch (mgmt->u.action.u.addba_req.action_code) { | ||
2212 | case WLAN_ACTION_ADDBA_REQ: | ||
2213 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
2214 | sizeof(mgmt->u.action.u.addba_req))) | ||
2215 | break; | ||
2216 | ieee80211_sta_process_addba_request(local, mgmt, len); | ||
2217 | break; | ||
2218 | case WLAN_ACTION_ADDBA_RESP: | ||
2219 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
2220 | sizeof(mgmt->u.action.u.addba_resp))) | ||
2221 | break; | ||
2222 | ieee80211_sta_process_addba_resp(local, mgmt, len); | ||
2223 | break; | ||
2224 | case WLAN_ACTION_DELBA: | ||
2225 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
2226 | sizeof(mgmt->u.action.u.delba))) | ||
2227 | break; | ||
2228 | ieee80211_sta_process_delba(sdata, mgmt, len); | ||
2229 | break; | ||
2230 | } | ||
2231 | break; | ||
2232 | case PLINK_CATEGORY: | 1892 | case PLINK_CATEGORY: |
2233 | if (ieee80211_vif_is_mesh(&sdata->vif)) | 1893 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
2234 | mesh_rx_plink_frame(sdata, mgmt, len, rx_status); | 1894 | mesh_rx_plink_frame(sdata, mgmt, len, rx_status); |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 7e09b30dd393..71cce0bcc5be 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -1511,6 +1511,65 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx) | |||
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | static ieee80211_rx_result debug_noinline | 1513 | static ieee80211_rx_result debug_noinline |
1514 | ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | ||
1515 | { | ||
1516 | struct ieee80211_local *local = rx->local; | ||
1517 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); | ||
1518 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; | ||
1519 | int len = rx->skb->len; | ||
1520 | |||
1521 | if (!ieee80211_is_action(mgmt->frame_control)) | ||
1522 | return RX_CONTINUE; | ||
1523 | |||
1524 | if (!rx->sta) | ||
1525 | return RX_DROP_MONITOR; | ||
1526 | |||
1527 | if (!(rx->flags & IEEE80211_RX_RA_MATCH)) | ||
1528 | return RX_DROP_MONITOR; | ||
1529 | |||
1530 | /* all categories we currently handle have action_code */ | ||
1531 | if (len < IEEE80211_MIN_ACTION_SIZE + 1) | ||
1532 | return RX_DROP_MONITOR; | ||
1533 | |||
1534 | /* | ||
1535 | * FIXME: revisit this, I'm sure we should handle most | ||
1536 | * of these frames in other modes as well! | ||
1537 | */ | ||
1538 | if (sdata->vif.type != IEEE80211_IF_TYPE_STA && | ||
1539 | sdata->vif.type != IEEE80211_IF_TYPE_IBSS) | ||
1540 | return RX_DROP_MONITOR; | ||
1541 | |||
1542 | switch (mgmt->u.action.category) { | ||
1543 | case WLAN_CATEGORY_BACK: | ||
1544 | switch (mgmt->u.action.u.addba_req.action_code) { | ||
1545 | case WLAN_ACTION_ADDBA_REQ: | ||
1546 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
1547 | sizeof(mgmt->u.action.u.addba_req))) | ||
1548 | return RX_DROP_MONITOR; | ||
1549 | ieee80211_process_addba_request(local, rx->sta, mgmt, len); | ||
1550 | break; | ||
1551 | case WLAN_ACTION_ADDBA_RESP: | ||
1552 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
1553 | sizeof(mgmt->u.action.u.addba_resp))) | ||
1554 | return RX_DROP_MONITOR; | ||
1555 | ieee80211_process_addba_resp(local, rx->sta, mgmt, len); | ||
1556 | break; | ||
1557 | case WLAN_ACTION_DELBA: | ||
1558 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
1559 | sizeof(mgmt->u.action.u.delba))) | ||
1560 | return RX_DROP_MONITOR; | ||
1561 | ieee80211_process_delba(sdata, rx->sta, mgmt, len); | ||
1562 | break; | ||
1563 | } | ||
1564 | rx->sta->rx_packets++; | ||
1565 | dev_kfree_skb(rx->skb); | ||
1566 | return RX_QUEUED; | ||
1567 | } | ||
1568 | |||
1569 | return RX_CONTINUE; | ||
1570 | } | ||
1571 | |||
1572 | static ieee80211_rx_result debug_noinline | ||
1514 | ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) | 1573 | ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) |
1515 | { | 1574 | { |
1516 | struct ieee80211_sub_if_data *sdata; | 1575 | struct ieee80211_sub_if_data *sdata; |
@@ -1689,6 +1748,7 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | |||
1689 | CALL_RXH(ieee80211_rx_h_mesh_fwding); | 1748 | CALL_RXH(ieee80211_rx_h_mesh_fwding); |
1690 | CALL_RXH(ieee80211_rx_h_data) | 1749 | CALL_RXH(ieee80211_rx_h_data) |
1691 | CALL_RXH(ieee80211_rx_h_ctrl) | 1750 | CALL_RXH(ieee80211_rx_h_ctrl) |
1751 | CALL_RXH(ieee80211_rx_h_action) | ||
1692 | CALL_RXH(ieee80211_rx_h_mgmt) | 1752 | CALL_RXH(ieee80211_rx_h_mgmt) |
1693 | 1753 | ||
1694 | #undef CALL_RXH | 1754 | #undef CALL_RXH |