diff options
author | Luciano Coelho <luciano.coelho@intel.com> | 2014-05-13 09:52:54 -0400 |
---|---|---|
committer | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2014-05-15 12:50:27 -0400 |
commit | cf52023ccdcef90779085d49acc92d76cf4d3f47 (patch) | |
tree | 8b1cdf7d4fc46b0f7f34e6775b1a30b1b7b3e002 | |
parent | 4d66449a273e44b9bb1a5fc1cd5937c1905ebebe (diff) |
iwlwifi: mvm: combine p2p and station mac context functions
Instead of having two nearly identical functions to send the mac
context commands, use a single way that can handle both the p2p and
!p2p cases.
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c | 90 |
1 files changed, 32 insertions, 58 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c index d5f50afe942a..2c51e40179b5 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c +++ b/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c | |||
@@ -693,14 +693,37 @@ static int iwl_mvm_mac_ctxt_send_cmd(struct iwl_mvm *mvm, | |||
693 | return ret; | 693 | return ret; |
694 | } | 694 | } |
695 | 695 | ||
696 | /* | 696 | static int iwl_mvm_mac_ctxt_cmd_sta(struct iwl_mvm *mvm, |
697 | * Fill the specific data for mac context of type station or p2p client | 697 | struct ieee80211_vif *vif, |
698 | */ | 698 | u32 action, bool force_assoc_off) |
699 | static void iwl_mvm_mac_ctxt_cmd_fill_sta(struct iwl_mvm *mvm, | ||
700 | struct ieee80211_vif *vif, | ||
701 | struct iwl_mac_data_sta *ctxt_sta, | ||
702 | bool force_assoc_off) | ||
703 | { | 699 | { |
700 | struct iwl_mac_ctx_cmd cmd = {}; | ||
701 | struct iwl_mac_data_sta *ctxt_sta; | ||
702 | |||
703 | WARN_ON(vif->type != NL80211_IFTYPE_STATION); | ||
704 | |||
705 | /* Fill the common data for all mac context types */ | ||
706 | iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action); | ||
707 | |||
708 | if (vif->p2p) { | ||
709 | struct ieee80211_p2p_noa_attr *noa = | ||
710 | &vif->bss_conf.p2p_noa_attr; | ||
711 | |||
712 | cmd.p2p_sta.ctwin = cpu_to_le32(noa->oppps_ctwindow & | ||
713 | IEEE80211_P2P_OPPPS_CTWINDOW_MASK); | ||
714 | ctxt_sta = &cmd.p2p_sta.sta; | ||
715 | } else { | ||
716 | /* Allow beacons to pass through as long as we are not | ||
717 | * associated, or we do not have dtim period information. | ||
718 | */ | ||
719 | if (!vif->bss_conf.assoc || !vif->bss_conf.dtim_period) | ||
720 | cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_BEACON); | ||
721 | else | ||
722 | cmd.filter_flags &= ~cpu_to_le32(MAC_FILTER_IN_BEACON); | ||
723 | |||
724 | ctxt_sta = &cmd.sta; | ||
725 | } | ||
726 | |||
704 | /* We need the dtim_period to set the MAC as associated */ | 727 | /* We need the dtim_period to set the MAC as associated */ |
705 | if (vif->bss_conf.assoc && vif->bss_conf.dtim_period && | 728 | if (vif->bss_conf.assoc && vif->bss_conf.dtim_period && |
706 | !force_assoc_off) { | 729 | !force_assoc_off) { |
@@ -752,51 +775,6 @@ static void iwl_mvm_mac_ctxt_cmd_fill_sta(struct iwl_mvm *mvm, | |||
752 | 775 | ||
753 | ctxt_sta->listen_interval = cpu_to_le32(mvm->hw->conf.listen_interval); | 776 | ctxt_sta->listen_interval = cpu_to_le32(mvm->hw->conf.listen_interval); |
754 | ctxt_sta->assoc_id = cpu_to_le32(vif->bss_conf.aid); | 777 | ctxt_sta->assoc_id = cpu_to_le32(vif->bss_conf.aid); |
755 | } | ||
756 | |||
757 | static int iwl_mvm_mac_ctxt_cmd_station(struct iwl_mvm *mvm, | ||
758 | struct ieee80211_vif *vif, | ||
759 | u32 action) | ||
760 | { | ||
761 | struct iwl_mac_ctx_cmd cmd = {}; | ||
762 | |||
763 | WARN_ON(vif->type != NL80211_IFTYPE_STATION || vif->p2p); | ||
764 | |||
765 | /* Fill the common data for all mac context types */ | ||
766 | iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action); | ||
767 | |||
768 | /* Allow beacons to pass through as long as we are not associated,or we | ||
769 | * do not have dtim period information */ | ||
770 | if (!vif->bss_conf.assoc || !vif->bss_conf.dtim_period) | ||
771 | cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_BEACON); | ||
772 | else | ||
773 | cmd.filter_flags &= ~cpu_to_le32(MAC_FILTER_IN_BEACON); | ||
774 | |||
775 | /* Fill the data specific for station mode */ | ||
776 | iwl_mvm_mac_ctxt_cmd_fill_sta(mvm, vif, &cmd.sta, | ||
777 | action == FW_CTXT_ACTION_ADD); | ||
778 | |||
779 | return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd); | ||
780 | } | ||
781 | |||
782 | static int iwl_mvm_mac_ctxt_cmd_p2p_client(struct iwl_mvm *mvm, | ||
783 | struct ieee80211_vif *vif, | ||
784 | u32 action) | ||
785 | { | ||
786 | struct iwl_mac_ctx_cmd cmd = {}; | ||
787 | struct ieee80211_p2p_noa_attr *noa = &vif->bss_conf.p2p_noa_attr; | ||
788 | |||
789 | WARN_ON(vif->type != NL80211_IFTYPE_STATION || !vif->p2p); | ||
790 | |||
791 | /* Fill the common data for all mac context types */ | ||
792 | iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action); | ||
793 | |||
794 | /* Fill the data specific for station mode */ | ||
795 | iwl_mvm_mac_ctxt_cmd_fill_sta(mvm, vif, &cmd.p2p_sta.sta, | ||
796 | action == FW_CTXT_ACTION_ADD); | ||
797 | |||
798 | cmd.p2p_sta.ctwin = cpu_to_le32(noa->oppps_ctwindow & | ||
799 | IEEE80211_P2P_OPPPS_CTWINDOW_MASK); | ||
800 | 778 | ||
801 | return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd); | 779 | return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd); |
802 | } | 780 | } |
@@ -1138,12 +1116,8 @@ static int iwl_mvm_mac_ctx_send(struct iwl_mvm *mvm, struct ieee80211_vif *vif, | |||
1138 | { | 1116 | { |
1139 | switch (vif->type) { | 1117 | switch (vif->type) { |
1140 | case NL80211_IFTYPE_STATION: | 1118 | case NL80211_IFTYPE_STATION: |
1141 | if (!vif->p2p) | 1119 | return iwl_mvm_mac_ctxt_cmd_sta(mvm, vif, action, |
1142 | return iwl_mvm_mac_ctxt_cmd_station(mvm, vif, | 1120 | action == FW_CTXT_ACTION_ADD); |
1143 | action); | ||
1144 | else | ||
1145 | return iwl_mvm_mac_ctxt_cmd_p2p_client(mvm, vif, | ||
1146 | action); | ||
1147 | break; | 1121 | break; |
1148 | case NL80211_IFTYPE_AP: | 1122 | case NL80211_IFTYPE_AP: |
1149 | if (!vif->p2p) | 1123 | if (!vif->p2p) |