aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2014-04-22 15:02:03 -0400
committerJohn W. Linville <linville@tuxdriver.com>2014-04-22 15:02:03 -0400
commit22b3b9578da730272d5ca2f3bbf718c7324ff27e (patch)
treedcdb3a13f5ceb89b124e0745097699575ccd5a9f /drivers/net/wireless
parentbf4c69f7dd8e0c3427262cc11652227ec7256a75 (diff)
parent4bfee8e8c13fc9477eb9420efd5a5d12e32ac614 (diff)
Merge branch 'for-linville' of git://github.com/kvalo/ath
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/ath/ath10k/bmi.c13
-rw-r--r--drivers/net/wireless/ath/ath10k/bmi.h2
-rw-r--r--drivers/net/wireless/ath/ath10k/ce.c356
-rw-r--r--drivers/net/wireless/ath/ath10k/ce.h15
-rw-r--r--drivers/net/wireless/ath/ath10k/core.c85
-rw-r--r--drivers/net/wireless/ath/ath10k/core.h18
-rw-r--r--drivers/net/wireless/ath/ath10k/debug.c109
-rw-r--r--drivers/net/wireless/ath/ath10k/htc.c12
-rw-r--r--drivers/net/wireless/ath/ath10k/htt.h21
-rw-r--r--drivers/net/wireless/ath/ath10k/htt_rx.c513
-rw-r--r--drivers/net/wireless/ath/ath10k/hw.h1
-rw-r--r--drivers/net/wireless/ath/ath10k/mac.c763
-rw-r--r--drivers/net/wireless/ath/ath10k/pci.c219
-rw-r--r--drivers/net/wireless/ath/ath10k/pci.h3
-rw-r--r--drivers/net/wireless/ath/ath10k/txrx.c183
-rw-r--r--drivers/net/wireless/ath/ath10k/txrx.h1
-rw-r--r--drivers/net/wireless/ath/ath10k/wmi.c62
-rw-r--r--drivers/net/wireless/ath/ath10k/wmi.h98
-rw-r--r--drivers/net/wireless/ath/ath6kl/Kconfig30
-rw-r--r--drivers/net/wireless/ath/ath6kl/cfg80211.c9
-rw-r--r--drivers/net/wireless/ath/ath6kl/core.c6
-rw-r--r--drivers/net/wireless/ath/ath6kl/debug.c4
-rw-r--r--drivers/net/wireless/ath/ath6kl/debug.h2
-rw-r--r--drivers/net/wireless/ath/ath6kl/hif.c3
-rw-r--r--drivers/net/wireless/ath/ath6kl/hif.h4
-rw-r--r--drivers/net/wireless/ath/ath6kl/htc_mbox.c23
-rw-r--r--drivers/net/wireless/ath/ath6kl/htc_pipe.c10
-rw-r--r--drivers/net/wireless/ath/ath6kl/init.c1
-rw-r--r--drivers/net/wireless/ath/ath6kl/main.c10
-rw-r--r--drivers/net/wireless/ath/ath6kl/sdio.c17
-rw-r--r--drivers/net/wireless/ath/ath6kl/target.h2
-rw-r--r--drivers/net/wireless/ath/ath6kl/txrx.c31
-rw-r--r--drivers/net/wireless/ath/ath6kl/usb.c2
-rw-r--r--drivers/net/wireless/ath/ath6kl/wmi.c19
-rw-r--r--drivers/net/wireless/ath/ath6kl/wmi.h1
35 files changed, 1499 insertions, 1149 deletions
diff --git a/drivers/net/wireless/ath/ath10k/bmi.c b/drivers/net/wireless/ath/ath10k/bmi.c
index a1f099628850..17d221abd58c 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.c
+++ b/drivers/net/wireless/ath/ath10k/bmi.c
@@ -175,7 +175,7 @@ int ath10k_bmi_write_memory(struct ath10k *ar,
175 return 0; 175 return 0;
176} 176}
177 177
178int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 *param) 178int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 param, u32 *result)
179{ 179{
180 struct bmi_cmd cmd; 180 struct bmi_cmd cmd;
181 union bmi_resp resp; 181 union bmi_resp resp;
@@ -184,7 +184,7 @@ int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 *param)
184 int ret; 184 int ret;
185 185
186 ath10k_dbg(ATH10K_DBG_BMI, "bmi execute address 0x%x param 0x%x\n", 186 ath10k_dbg(ATH10K_DBG_BMI, "bmi execute address 0x%x param 0x%x\n",
187 address, *param); 187 address, param);
188 188
189 if (ar->bmi.done_sent) { 189 if (ar->bmi.done_sent) {
190 ath10k_warn("command disallowed\n"); 190 ath10k_warn("command disallowed\n");
@@ -193,7 +193,7 @@ int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 *param)
193 193
194 cmd.id = __cpu_to_le32(BMI_EXECUTE); 194 cmd.id = __cpu_to_le32(BMI_EXECUTE);
195 cmd.execute.addr = __cpu_to_le32(address); 195 cmd.execute.addr = __cpu_to_le32(address);
196 cmd.execute.param = __cpu_to_le32(*param); 196 cmd.execute.param = __cpu_to_le32(param);
197 197
198 ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, cmdlen, &resp, &resplen); 198 ret = ath10k_hif_exchange_bmi_msg(ar, &cmd, cmdlen, &resp, &resplen);
199 if (ret) { 199 if (ret) {
@@ -204,10 +204,13 @@ int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 *param)
204 if (resplen < sizeof(resp.execute)) { 204 if (resplen < sizeof(resp.execute)) {
205 ath10k_warn("invalid execute response length (%d)\n", 205 ath10k_warn("invalid execute response length (%d)\n",
206 resplen); 206 resplen);
207 return ret; 207 return -EIO;
208 } 208 }
209 209
210 *param = __le32_to_cpu(resp.execute.result); 210 *result = __le32_to_cpu(resp.execute.result);
211
212 ath10k_dbg(ATH10K_DBG_BMI, "bmi execute result 0x%x\n", *result);
213
211 return 0; 214 return 0;
212} 215}
213 216
diff --git a/drivers/net/wireless/ath/ath10k/bmi.h b/drivers/net/wireless/ath/ath10k/bmi.h
index 8d81ce1cec21..3a9bdf51c96a 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.h
+++ b/drivers/net/wireless/ath/ath10k/bmi.h
@@ -217,7 +217,7 @@ int ath10k_bmi_write_memory(struct ath10k *ar, u32 address,
217 ret; \ 217 ret; \
218 }) 218 })
219 219
220int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 *param); 220int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 param, u32 *result);
221int ath10k_bmi_lz_stream_start(struct ath10k *ar, u32 address); 221int ath10k_bmi_lz_stream_start(struct ath10k *ar, u32 address);
222int ath10k_bmi_lz_data(struct ath10k *ar, const void *buffer, u32 length); 222int ath10k_bmi_lz_data(struct ath10k *ar, const void *buffer, u32 length);
223int ath10k_bmi_fast_download(struct ath10k *ar, u32 address, 223int ath10k_bmi_fast_download(struct ath10k *ar, u32 address,
diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
index a79499c82350..1e4cad8632b5 100644
--- a/drivers/net/wireless/ath/ath10k/ce.c
+++ b/drivers/net/wireless/ath/ath10k/ce.c
@@ -840,35 +840,17 @@ void ath10k_ce_recv_cb_register(struct ath10k_ce_pipe *ce_state,
840 840
841static int ath10k_ce_init_src_ring(struct ath10k *ar, 841static int ath10k_ce_init_src_ring(struct ath10k *ar,
842 unsigned int ce_id, 842 unsigned int ce_id,
843 struct ath10k_ce_pipe *ce_state,
844 const struct ce_attr *attr) 843 const struct ce_attr *attr)
845{ 844{
846 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 845 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
847 struct ath10k_ce_ring *src_ring; 846 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
848 unsigned int nentries = attr->src_nentries; 847 struct ath10k_ce_ring *src_ring = ce_state->src_ring;
849 unsigned int ce_nbytes; 848 u32 nentries, ctrl_addr = ath10k_ce_base_address(ce_id);
850 u32 ctrl_addr = ath10k_ce_base_address(ce_id);
851 dma_addr_t base_addr;
852 char *ptr;
853
854 nentries = roundup_pow_of_two(nentries);
855
856 if (ce_state->src_ring) {
857 WARN_ON(ce_state->src_ring->nentries != nentries);
858 return 0;
859 }
860 849
861 ce_nbytes = sizeof(struct ath10k_ce_ring) + (nentries * sizeof(void *)); 850 nentries = roundup_pow_of_two(attr->src_nentries);
862 ptr = kzalloc(ce_nbytes, GFP_KERNEL);
863 if (ptr == NULL)
864 return -ENOMEM;
865 851
866 ce_state->src_ring = (struct ath10k_ce_ring *)ptr; 852 memset(src_ring->per_transfer_context, 0,
867 src_ring = ce_state->src_ring; 853 nentries * sizeof(*src_ring->per_transfer_context));
868
869 ptr += sizeof(struct ath10k_ce_ring);
870 src_ring->nentries = nentries;
871 src_ring->nentries_mask = nentries - 1;
872 854
873 src_ring->sw_index = ath10k_ce_src_ring_read_index_get(ar, ctrl_addr); 855 src_ring->sw_index = ath10k_ce_src_ring_read_index_get(ar, ctrl_addr);
874 src_ring->sw_index &= src_ring->nentries_mask; 856 src_ring->sw_index &= src_ring->nentries_mask;
@@ -878,21 +860,87 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar,
878 ath10k_ce_src_ring_write_index_get(ar, ctrl_addr); 860 ath10k_ce_src_ring_write_index_get(ar, ctrl_addr);
879 src_ring->write_index &= src_ring->nentries_mask; 861 src_ring->write_index &= src_ring->nentries_mask;
880 862
881 src_ring->per_transfer_context = (void **)ptr; 863 ath10k_ce_src_ring_base_addr_set(ar, ctrl_addr,
864 src_ring->base_addr_ce_space);
865 ath10k_ce_src_ring_size_set(ar, ctrl_addr, nentries);
866 ath10k_ce_src_ring_dmax_set(ar, ctrl_addr, attr->src_sz_max);
867 ath10k_ce_src_ring_byte_swap_set(ar, ctrl_addr, 0);
868 ath10k_ce_src_ring_lowmark_set(ar, ctrl_addr, 0);
869 ath10k_ce_src_ring_highmark_set(ar, ctrl_addr, nentries);
870
871 ath10k_dbg(ATH10K_DBG_BOOT,
872 "boot init ce src ring id %d entries %d base_addr %p\n",
873 ce_id, nentries, src_ring->base_addr_owner_space);
874
875 return 0;
876}
877
878static int ath10k_ce_init_dest_ring(struct ath10k *ar,
879 unsigned int ce_id,
880 const struct ce_attr *attr)
881{
882 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
883 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
884 struct ath10k_ce_ring *dest_ring = ce_state->dest_ring;
885 u32 nentries, ctrl_addr = ath10k_ce_base_address(ce_id);
886
887 nentries = roundup_pow_of_two(attr->dest_nentries);
888
889 memset(dest_ring->per_transfer_context, 0,
890 nentries * sizeof(*dest_ring->per_transfer_context));
891
892 dest_ring->sw_index = ath10k_ce_dest_ring_read_index_get(ar, ctrl_addr);
893 dest_ring->sw_index &= dest_ring->nentries_mask;
894 dest_ring->write_index =
895 ath10k_ce_dest_ring_write_index_get(ar, ctrl_addr);
896 dest_ring->write_index &= dest_ring->nentries_mask;
897
898 ath10k_ce_dest_ring_base_addr_set(ar, ctrl_addr,
899 dest_ring->base_addr_ce_space);
900 ath10k_ce_dest_ring_size_set(ar, ctrl_addr, nentries);
901 ath10k_ce_dest_ring_byte_swap_set(ar, ctrl_addr, 0);
902 ath10k_ce_dest_ring_lowmark_set(ar, ctrl_addr, 0);
903 ath10k_ce_dest_ring_highmark_set(ar, ctrl_addr, nentries);
904
905 ath10k_dbg(ATH10K_DBG_BOOT,
906 "boot ce dest ring id %d entries %d base_addr %p\n",
907 ce_id, nentries, dest_ring->base_addr_owner_space);
908
909 return 0;
910}
911
912static struct ath10k_ce_ring *
913ath10k_ce_alloc_src_ring(struct ath10k *ar, unsigned int ce_id,
914 const struct ce_attr *attr)
915{
916 struct ath10k_ce_ring *src_ring;
917 u32 nentries = attr->src_nentries;
918 dma_addr_t base_addr;
919
920 nentries = roundup_pow_of_two(nentries);
921
922 src_ring = kzalloc(sizeof(*src_ring) +
923 (nentries *
924 sizeof(*src_ring->per_transfer_context)),
925 GFP_KERNEL);
926 if (src_ring == NULL)
927 return ERR_PTR(-ENOMEM);
928
929 src_ring->nentries = nentries;
930 src_ring->nentries_mask = nentries - 1;
882 931
883 /* 932 /*
884 * Legacy platforms that do not support cache 933 * Legacy platforms that do not support cache
885 * coherent DMA are unsupported 934 * coherent DMA are unsupported
886 */ 935 */
887 src_ring->base_addr_owner_space_unaligned = 936 src_ring->base_addr_owner_space_unaligned =
888 pci_alloc_consistent(ar_pci->pdev, 937 dma_alloc_coherent(ar->dev,
889 (nentries * sizeof(struct ce_desc) + 938 (nentries * sizeof(struct ce_desc) +
890 CE_DESC_RING_ALIGN), 939 CE_DESC_RING_ALIGN),
891 &base_addr); 940 &base_addr, GFP_KERNEL);
892 if (!src_ring->base_addr_owner_space_unaligned) { 941 if (!src_ring->base_addr_owner_space_unaligned) {
893 kfree(ce_state->src_ring); 942 kfree(src_ring);
894 ce_state->src_ring = NULL; 943 return ERR_PTR(-ENOMEM);
895 return -ENOMEM;
896 } 944 }
897 945
898 src_ring->base_addr_ce_space_unaligned = base_addr; 946 src_ring->base_addr_ce_space_unaligned = base_addr;
@@ -912,88 +960,54 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar,
912 kmalloc((nentries * sizeof(struct ce_desc) + 960 kmalloc((nentries * sizeof(struct ce_desc) +
913 CE_DESC_RING_ALIGN), GFP_KERNEL); 961 CE_DESC_RING_ALIGN), GFP_KERNEL);
914 if (!src_ring->shadow_base_unaligned) { 962 if (!src_ring->shadow_base_unaligned) {
915 pci_free_consistent(ar_pci->pdev, 963 dma_free_coherent(ar->dev,
916 (nentries * sizeof(struct ce_desc) + 964 (nentries * sizeof(struct ce_desc) +
917 CE_DESC_RING_ALIGN), 965 CE_DESC_RING_ALIGN),
918 src_ring->base_addr_owner_space, 966 src_ring->base_addr_owner_space,
919 src_ring->base_addr_ce_space); 967 src_ring->base_addr_ce_space);
920 kfree(ce_state->src_ring); 968 kfree(src_ring);
921 ce_state->src_ring = NULL; 969 return ERR_PTR(-ENOMEM);
922 return -ENOMEM;
923 } 970 }
924 971
925 src_ring->shadow_base = PTR_ALIGN( 972 src_ring->shadow_base = PTR_ALIGN(
926 src_ring->shadow_base_unaligned, 973 src_ring->shadow_base_unaligned,
927 CE_DESC_RING_ALIGN); 974 CE_DESC_RING_ALIGN);
928 975
929 ath10k_ce_src_ring_base_addr_set(ar, ctrl_addr, 976 return src_ring;
930 src_ring->base_addr_ce_space);
931 ath10k_ce_src_ring_size_set(ar, ctrl_addr, nentries);
932 ath10k_ce_src_ring_dmax_set(ar, ctrl_addr, attr->src_sz_max);
933 ath10k_ce_src_ring_byte_swap_set(ar, ctrl_addr, 0);
934 ath10k_ce_src_ring_lowmark_set(ar, ctrl_addr, 0);
935 ath10k_ce_src_ring_highmark_set(ar, ctrl_addr, nentries);
936
937 ath10k_dbg(ATH10K_DBG_BOOT,
938 "boot ce src ring id %d entries %d base_addr %p\n",
939 ce_id, nentries, src_ring->base_addr_owner_space);
940
941 return 0;
942} 977}
943 978
944static int ath10k_ce_init_dest_ring(struct ath10k *ar, 979static struct ath10k_ce_ring *
945 unsigned int ce_id, 980ath10k_ce_alloc_dest_ring(struct ath10k *ar, unsigned int ce_id,
946 struct ath10k_ce_pipe *ce_state, 981 const struct ce_attr *attr)
947 const struct ce_attr *attr)
948{ 982{
949 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
950 struct ath10k_ce_ring *dest_ring; 983 struct ath10k_ce_ring *dest_ring;
951 unsigned int nentries = attr->dest_nentries; 984 u32 nentries;
952 unsigned int ce_nbytes;
953 u32 ctrl_addr = ath10k_ce_base_address(ce_id);
954 dma_addr_t base_addr; 985 dma_addr_t base_addr;
955 char *ptr;
956 986
957 nentries = roundup_pow_of_two(nentries); 987 nentries = roundup_pow_of_two(attr->dest_nentries);
958 988
959 if (ce_state->dest_ring) { 989 dest_ring = kzalloc(sizeof(*dest_ring) +
960 WARN_ON(ce_state->dest_ring->nentries != nentries); 990 (nentries *
961 return 0; 991 sizeof(*dest_ring->per_transfer_context)),
962 } 992 GFP_KERNEL);
963 993 if (dest_ring == NULL)
964 ce_nbytes = sizeof(struct ath10k_ce_ring) + (nentries * sizeof(void *)); 994 return ERR_PTR(-ENOMEM);
965 ptr = kzalloc(ce_nbytes, GFP_KERNEL);
966 if (ptr == NULL)
967 return -ENOMEM;
968
969 ce_state->dest_ring = (struct ath10k_ce_ring *)ptr;
970 dest_ring = ce_state->dest_ring;
971 995
972 ptr += sizeof(struct ath10k_ce_ring);
973 dest_ring->nentries = nentries; 996 dest_ring->nentries = nentries;
974 dest_ring->nentries_mask = nentries - 1; 997 dest_ring->nentries_mask = nentries - 1;
975 998
976 dest_ring->sw_index = ath10k_ce_dest_ring_read_index_get(ar, ctrl_addr);
977 dest_ring->sw_index &= dest_ring->nentries_mask;
978 dest_ring->write_index =
979 ath10k_ce_dest_ring_write_index_get(ar, ctrl_addr);
980 dest_ring->write_index &= dest_ring->nentries_mask;
981
982 dest_ring->per_transfer_context = (void **)ptr;
983
984 /* 999 /*
985 * Legacy platforms that do not support cache 1000 * Legacy platforms that do not support cache
986 * coherent DMA are unsupported 1001 * coherent DMA are unsupported
987 */ 1002 */
988 dest_ring->base_addr_owner_space_unaligned = 1003 dest_ring->base_addr_owner_space_unaligned =
989 pci_alloc_consistent(ar_pci->pdev, 1004 dma_alloc_coherent(ar->dev,
990 (nentries * sizeof(struct ce_desc) + 1005 (nentries * sizeof(struct ce_desc) +
991 CE_DESC_RING_ALIGN), 1006 CE_DESC_RING_ALIGN),
992 &base_addr); 1007 &base_addr, GFP_KERNEL);
993 if (!dest_ring->base_addr_owner_space_unaligned) { 1008 if (!dest_ring->base_addr_owner_space_unaligned) {
994 kfree(ce_state->dest_ring); 1009 kfree(dest_ring);
995 ce_state->dest_ring = NULL; 1010 return ERR_PTR(-ENOMEM);
996 return -ENOMEM;
997 } 1011 }
998 1012
999 dest_ring->base_addr_ce_space_unaligned = base_addr; 1013 dest_ring->base_addr_ce_space_unaligned = base_addr;
@@ -1012,39 +1026,7 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar,
1012 dest_ring->base_addr_ce_space_unaligned, 1026 dest_ring->base_addr_ce_space_unaligned,
1013 CE_DESC_RING_ALIGN); 1027 CE_DESC_RING_ALIGN);
1014 1028
1015 ath10k_ce_dest_ring_base_addr_set(ar, ctrl_addr, 1029 return dest_ring;
1016 dest_ring->base_addr_ce_space);
1017 ath10k_ce_dest_ring_size_set(ar, ctrl_addr, nentries);
1018 ath10k_ce_dest_ring_byte_swap_set(ar, ctrl_addr, 0);
1019 ath10k_ce_dest_ring_lowmark_set(ar, ctrl_addr, 0);
1020 ath10k_ce_dest_ring_highmark_set(ar, ctrl_addr, nentries);
1021
1022 ath10k_dbg(ATH10K_DBG_BOOT,
1023 "boot ce dest ring id %d entries %d base_addr %p\n",
1024 ce_id, nentries, dest_ring->base_addr_owner_space);
1025
1026 return 0;
1027}
1028
1029static struct ath10k_ce_pipe *ath10k_ce_init_state(struct ath10k *ar,
1030 unsigned int ce_id,
1031 const struct ce_attr *attr)
1032{
1033 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1034 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
1035 u32 ctrl_addr = ath10k_ce_base_address(ce_id);
1036
1037 spin_lock_bh(&ar_pci->ce_lock);
1038
1039 ce_state->ar = ar;
1040 ce_state->id = ce_id;
1041 ce_state->ctrl_addr = ctrl_addr;
1042 ce_state->attr_flags = attr->flags;
1043 ce_state->src_sz_max = attr->src_sz_max;
1044
1045 spin_unlock_bh(&ar_pci->ce_lock);
1046
1047 return ce_state;
1048} 1030}
1049 1031
1050/* 1032/*
@@ -1054,11 +1036,11 @@ static struct ath10k_ce_pipe *ath10k_ce_init_state(struct ath10k *ar,
1054 * initialization. It may be that only one side or the other is 1036 * initialization. It may be that only one side or the other is
1055 * initialized by software/firmware. 1037 * initialized by software/firmware.
1056 */ 1038 */
1057struct ath10k_ce_pipe *ath10k_ce_init(struct ath10k *ar, 1039int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id,
1058 unsigned int ce_id, 1040 const struct ce_attr *attr)
1059 const struct ce_attr *attr)
1060{ 1041{
1061 struct ath10k_ce_pipe *ce_state; 1042 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1043 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
1062 int ret; 1044 int ret;
1063 1045
1064 /* 1046 /*
@@ -1074,64 +1056,128 @@ struct ath10k_ce_pipe *ath10k_ce_init(struct ath10k *ar,
1074 1056
1075 ret = ath10k_pci_wake(ar); 1057 ret = ath10k_pci_wake(ar);
1076 if (ret) 1058 if (ret)
1077 return NULL; 1059 return ret;
1078 1060
1079 ce_state = ath10k_ce_init_state(ar, ce_id, attr); 1061 spin_lock_bh(&ar_pci->ce_lock);
1080 if (!ce_state) { 1062 ce_state->ar = ar;
1081 ath10k_err("Failed to initialize CE state for ID: %d\n", ce_id); 1063 ce_state->id = ce_id;
1082 goto out; 1064 ce_state->ctrl_addr = ath10k_ce_base_address(ce_id);
1083 } 1065 ce_state->attr_flags = attr->flags;
1066 ce_state->src_sz_max = attr->src_sz_max;
1067 spin_unlock_bh(&ar_pci->ce_lock);
1084 1068
1085 if (attr->src_nentries) { 1069 if (attr->src_nentries) {
1086 ret = ath10k_ce_init_src_ring(ar, ce_id, ce_state, attr); 1070 ret = ath10k_ce_init_src_ring(ar, ce_id, attr);
1087 if (ret) { 1071 if (ret) {
1088 ath10k_err("Failed to initialize CE src ring for ID: %d (%d)\n", 1072 ath10k_err("Failed to initialize CE src ring for ID: %d (%d)\n",
1089 ce_id, ret); 1073 ce_id, ret);
1090 ath10k_ce_deinit(ce_state);
1091 ce_state = NULL;
1092 goto out; 1074 goto out;
1093 } 1075 }
1094 } 1076 }
1095 1077
1096 if (attr->dest_nentries) { 1078 if (attr->dest_nentries) {
1097 ret = ath10k_ce_init_dest_ring(ar, ce_id, ce_state, attr); 1079 ret = ath10k_ce_init_dest_ring(ar, ce_id, attr);
1098 if (ret) { 1080 if (ret) {
1099 ath10k_err("Failed to initialize CE dest ring for ID: %d (%d)\n", 1081 ath10k_err("Failed to initialize CE dest ring for ID: %d (%d)\n",
1100 ce_id, ret); 1082 ce_id, ret);
1101 ath10k_ce_deinit(ce_state);
1102 ce_state = NULL;
1103 goto out; 1083 goto out;
1104 } 1084 }
1105 } 1085 }
1106 1086
1107out: 1087out:
1108 ath10k_pci_sleep(ar); 1088 ath10k_pci_sleep(ar);
1109 return ce_state; 1089 return ret;
1110} 1090}
1111 1091
1112void ath10k_ce_deinit(struct ath10k_ce_pipe *ce_state) 1092static void ath10k_ce_deinit_src_ring(struct ath10k *ar, unsigned int ce_id)
1093{
1094 u32 ctrl_addr = ath10k_ce_base_address(ce_id);
1095
1096 ath10k_ce_src_ring_base_addr_set(ar, ctrl_addr, 0);
1097 ath10k_ce_src_ring_size_set(ar, ctrl_addr, 0);
1098 ath10k_ce_src_ring_dmax_set(ar, ctrl_addr, 0);
1099 ath10k_ce_src_ring_highmark_set(ar, ctrl_addr, 0);
1100}
1101
1102static void ath10k_ce_deinit_dest_ring(struct ath10k *ar, unsigned int ce_id)
1103{
1104 u32 ctrl_addr = ath10k_ce_base_address(ce_id);
1105
1106 ath10k_ce_dest_ring_base_addr_set(ar, ctrl_addr, 0);
1107 ath10k_ce_dest_ring_size_set(ar, ctrl_addr, 0);
1108 ath10k_ce_dest_ring_highmark_set(ar, ctrl_addr, 0);
1109}
1110
1111void ath10k_ce_deinit_pipe(struct ath10k *ar, unsigned int ce_id)
1112{
1113 int ret;
1114
1115 ret = ath10k_pci_wake(ar);
1116 if (ret)
1117 return;
1118
1119 ath10k_ce_deinit_src_ring(ar, ce_id);
1120 ath10k_ce_deinit_dest_ring(ar, ce_id);
1121
1122 ath10k_pci_sleep(ar);
1123}
1124
1125int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id,
1126 const struct ce_attr *attr)
1127{
1128 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1129 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
1130 int ret;
1131
1132 if (attr->src_nentries) {
1133 ce_state->src_ring = ath10k_ce_alloc_src_ring(ar, ce_id, attr);
1134 if (IS_ERR(ce_state->src_ring)) {
1135 ret = PTR_ERR(ce_state->src_ring);
1136 ath10k_err("failed to allocate copy engine source ring %d: %d\n",
1137 ce_id, ret);
1138 ce_state->src_ring = NULL;
1139 return ret;
1140 }
1141 }
1142
1143 if (attr->dest_nentries) {
1144 ce_state->dest_ring = ath10k_ce_alloc_dest_ring(ar, ce_id,
1145 attr);
1146 if (IS_ERR(ce_state->dest_ring)) {
1147 ret = PTR_ERR(ce_state->dest_ring);
1148 ath10k_err("failed to allocate copy engine destination ring %d: %d\n",
1149 ce_id, ret);
1150 ce_state->dest_ring = NULL;
1151 return ret;
1152 }
1153 }
1154
1155 return 0;
1156}
1157
1158void ath10k_ce_free_pipe(struct ath10k *ar, int ce_id)
1113{ 1159{
1114 struct ath10k *ar = ce_state->ar;
1115 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1160 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1161 struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
1116 1162
1117 if (ce_state->src_ring) { 1163 if (ce_state->src_ring) {
1118 kfree(ce_state->src_ring->shadow_base_unaligned); 1164 kfree(ce_state->src_ring->shadow_base_unaligned);
1119 pci_free_consistent(ar_pci->pdev, 1165 dma_free_coherent(ar->dev,
1120 (ce_state->src_ring->nentries * 1166 (ce_state->src_ring->nentries *
1121 sizeof(struct ce_desc) + 1167 sizeof(struct ce_desc) +
1122 CE_DESC_RING_ALIGN), 1168 CE_DESC_RING_ALIGN),
1123 ce_state->src_ring->base_addr_owner_space, 1169 ce_state->src_ring->base_addr_owner_space,
1124 ce_state->src_ring->base_addr_ce_space); 1170 ce_state->src_ring->base_addr_ce_space);
1125 kfree(ce_state->src_ring); 1171 kfree(ce_state->src_ring);
1126 } 1172 }
1127 1173
1128 if (ce_state->dest_ring) { 1174 if (ce_state->dest_ring) {
1129 pci_free_consistent(ar_pci->pdev, 1175 dma_free_coherent(ar->dev,
1130 (ce_state->dest_ring->nentries * 1176 (ce_state->dest_ring->nentries *
1131 sizeof(struct ce_desc) + 1177 sizeof(struct ce_desc) +
1132 CE_DESC_RING_ALIGN), 1178 CE_DESC_RING_ALIGN),
1133 ce_state->dest_ring->base_addr_owner_space, 1179 ce_state->dest_ring->base_addr_owner_space,
1134 ce_state->dest_ring->base_addr_ce_space); 1180 ce_state->dest_ring->base_addr_ce_space);
1135 kfree(ce_state->dest_ring); 1181 kfree(ce_state->dest_ring);
1136 } 1182 }
1137 1183
diff --git a/drivers/net/wireless/ath/ath10k/ce.h b/drivers/net/wireless/ath/ath10k/ce.h
index 8eb7f99ed992..fd0bc3561e42 100644
--- a/drivers/net/wireless/ath/ath10k/ce.h
+++ b/drivers/net/wireless/ath/ath10k/ce.h
@@ -104,7 +104,8 @@ struct ath10k_ce_ring {
104 void *shadow_base_unaligned; 104 void *shadow_base_unaligned;
105 struct ce_desc *shadow_base; 105 struct ce_desc *shadow_base;
106 106
107 void **per_transfer_context; 107 /* keep last */
108 void *per_transfer_context[0];
108}; 109};
109 110
110struct ath10k_ce_pipe { 111struct ath10k_ce_pipe {
@@ -210,10 +211,12 @@ int ath10k_ce_completed_send_next(struct ath10k_ce_pipe *ce_state,
210 211
211/*==================CE Engine Initialization=======================*/ 212/*==================CE Engine Initialization=======================*/
212 213
213/* Initialize an instance of a CE */ 214int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id,
214struct ath10k_ce_pipe *ath10k_ce_init(struct ath10k *ar, 215 const struct ce_attr *attr);
215 unsigned int ce_id, 216void ath10k_ce_deinit_pipe(struct ath10k *ar, unsigned int ce_id);
216 const struct ce_attr *attr); 217int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id,
218 const struct ce_attr *attr);
219void ath10k_ce_free_pipe(struct ath10k *ar, int ce_id);
217 220
218/*==================CE Engine Shutdown=======================*/ 221/*==================CE Engine Shutdown=======================*/
219/* 222/*
@@ -236,8 +239,6 @@ int ath10k_ce_cancel_send_next(struct ath10k_ce_pipe *ce_state,
236 unsigned int *nbytesp, 239 unsigned int *nbytesp,
237 unsigned int *transfer_idp); 240 unsigned int *transfer_idp);
238 241
239void ath10k_ce_deinit(struct ath10k_ce_pipe *ce_state);
240
241/*==================CE Interrupt Handlers====================*/ 242/*==================CE Interrupt Handlers====================*/
242void ath10k_ce_per_engine_service_any(struct ath10k *ar); 243void ath10k_ce_per_engine_service_any(struct ath10k *ar);
243void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id); 244void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id);
diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index ebc5fc2ede75..6abde37fb339 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -249,30 +249,40 @@ exit:
249 249
250static int ath10k_download_and_run_otp(struct ath10k *ar) 250static int ath10k_download_and_run_otp(struct ath10k *ar)
251{ 251{
252 u32 address = ar->hw_params.patch_load_addr; 252 u32 result, address = ar->hw_params.patch_load_addr;
253 u32 exec_param;
254 int ret; 253 int ret;
255 254
256 /* OTP is optional */ 255 /* OTP is optional */
257 256
258 if (!ar->otp_data || !ar->otp_len) 257 if (!ar->otp_data || !ar->otp_len) {
258 ath10k_warn("Not running otp, calibration will be incorrect (otp-data %p otp_len %zd)!\n",
259 ar->otp_data, ar->otp_len);
259 return 0; 260 return 0;
261 }
262
263 ath10k_dbg(ATH10K_DBG_BOOT, "boot upload otp to 0x%x len %zd\n",
264 address, ar->otp_len);
260 265
261 ret = ath10k_bmi_fast_download(ar, address, ar->otp_data, ar->otp_len); 266 ret = ath10k_bmi_fast_download(ar, address, ar->otp_data, ar->otp_len);
262 if (ret) { 267 if (ret) {
263 ath10k_err("could not write otp (%d)\n", ret); 268 ath10k_err("could not write otp (%d)\n", ret);
264 goto exit; 269 return ret;
265 } 270 }
266 271
267 exec_param = 0; 272 ret = ath10k_bmi_execute(ar, address, 0, &result);
268 ret = ath10k_bmi_execute(ar, address, &exec_param);
269 if (ret) { 273 if (ret) {
270 ath10k_err("could not execute otp (%d)\n", ret); 274 ath10k_err("could not execute otp (%d)\n", ret);
271 goto exit; 275 return ret;
272 } 276 }
273 277
274exit: 278 ath10k_dbg(ATH10K_DBG_BOOT, "boot otp execute result %d\n", result);
275 return ret; 279
280 if (result != 0) {
281 ath10k_err("otp calibration failed: %d", result);
282 return -EINVAL;
283 }
284
285 return 0;
276} 286}
277 287
278static int ath10k_download_fw(struct ath10k *ar) 288static int ath10k_download_fw(struct ath10k *ar)
@@ -389,8 +399,8 @@ static int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name)
389 /* first fetch the firmware file (firmware-*.bin) */ 399 /* first fetch the firmware file (firmware-*.bin) */
390 ar->firmware = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, name); 400 ar->firmware = ath10k_fetch_fw_file(ar, ar->hw_params.fw.dir, name);
391 if (IS_ERR(ar->firmware)) { 401 if (IS_ERR(ar->firmware)) {
392 ath10k_err("Could not fetch firmware file '%s': %ld\n", 402 ath10k_err("could not fetch firmware file '%s/%s': %ld\n",
393 name, PTR_ERR(ar->firmware)); 403 ar->hw_params.fw.dir, name, PTR_ERR(ar->firmware));
394 return PTR_ERR(ar->firmware); 404 return PTR_ERR(ar->firmware);
395 } 405 }
396 406
@@ -401,14 +411,14 @@ static int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name)
401 magic_len = strlen(ATH10K_FIRMWARE_MAGIC) + 1; 411 magic_len = strlen(ATH10K_FIRMWARE_MAGIC) + 1;
402 412
403 if (len < magic_len) { 413 if (len < magic_len) {
404 ath10k_err("firmware image too small to contain magic: %zu\n", 414 ath10k_err("firmware file '%s/%s' too small to contain magic: %zu\n",
405 len); 415 ar->hw_params.fw.dir, name, len);
406 ret = -EINVAL; 416 ret = -EINVAL;
407 goto err; 417 goto err;
408 } 418 }
409 419
410 if (memcmp(data, ATH10K_FIRMWARE_MAGIC, magic_len) != 0) { 420 if (memcmp(data, ATH10K_FIRMWARE_MAGIC, magic_len) != 0) {
411 ath10k_err("Invalid firmware magic\n"); 421 ath10k_err("invalid firmware magic\n");
412 ret = -EINVAL; 422 ret = -EINVAL;
413 goto err; 423 goto err;
414 } 424 }
@@ -430,7 +440,7 @@ static int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name)
430 data += sizeof(*hdr); 440 data += sizeof(*hdr);
431 441
432 if (len < ie_len) { 442 if (len < ie_len) {
433 ath10k_err("Invalid length for FW IE %d (%zu < %zu)\n", 443 ath10k_err("invalid length for FW IE %d (%zu < %zu)\n",
434 ie_id, len, ie_len); 444 ie_id, len, ie_len);
435 ret = -EINVAL; 445 ret = -EINVAL;
436 goto err; 446 goto err;
@@ -513,8 +523,8 @@ static int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name)
513 } 523 }
514 524
515 if (!ar->firmware_data || !ar->firmware_len) { 525 if (!ar->firmware_data || !ar->firmware_len) {
516 ath10k_warn("No ATH10K_FW_IE_FW_IMAGE found from %s, skipping\n", 526 ath10k_warn("No ATH10K_FW_IE_FW_IMAGE found from '%s/%s', skipping\n",
517 name); 527 ar->hw_params.fw.dir, name);
518 ret = -ENOMEDIUM; 528 ret = -ENOMEDIUM;
519 goto err; 529 goto err;
520 } 530 }
@@ -531,7 +541,9 @@ static int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name)
531 ar->hw_params.fw.board); 541 ar->hw_params.fw.board);
532 if (IS_ERR(ar->board)) { 542 if (IS_ERR(ar->board)) {
533 ret = PTR_ERR(ar->board); 543 ret = PTR_ERR(ar->board);
534 ath10k_err("could not fetch board data (%d)\n", ret); 544 ath10k_err("could not fetch board data '%s/%s' (%d)\n",
545 ar->hw_params.fw.dir, ar->hw_params.fw.board,
546 ret);
535 goto err; 547 goto err;
536 } 548 }
537 549
@@ -549,19 +561,21 @@ static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
549{ 561{
550 int ret; 562 int ret;
551 563
564 ar->fw_api = 2;
565 ath10k_dbg(ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
566
552 ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API2_FILE); 567 ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API2_FILE);
553 if (ret == 0) { 568 if (ret == 0)
554 ar->fw_api = 2; 569 goto success;
555 goto out; 570
556 } 571 ar->fw_api = 1;
572 ath10k_dbg(ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
557 573
558 ret = ath10k_core_fetch_firmware_api_1(ar); 574 ret = ath10k_core_fetch_firmware_api_1(ar);
559 if (ret) 575 if (ret)
560 return ret; 576 return ret;
561 577
562 ar->fw_api = 1; 578success:
563
564out:
565 ath10k_dbg(ATH10K_DBG_BOOT, "using fw api %d\n", ar->fw_api); 579 ath10k_dbg(ATH10K_DBG_BOOT, "using fw api %d\n", ar->fw_api);
566 580
567 return 0; 581 return 0;
@@ -572,16 +586,22 @@ static int ath10k_init_download_firmware(struct ath10k *ar)
572 int ret; 586 int ret;
573 587
574 ret = ath10k_download_board_data(ar); 588 ret = ath10k_download_board_data(ar);
575 if (ret) 589 if (ret) {
590 ath10k_err("failed to download board data: %d\n", ret);
576 return ret; 591 return ret;
592 }
577 593
578 ret = ath10k_download_and_run_otp(ar); 594 ret = ath10k_download_and_run_otp(ar);
579 if (ret) 595 if (ret) {
596 ath10k_err("failed to run otp: %d\n", ret);
580 return ret; 597 return ret;
598 }
581 599
582 ret = ath10k_download_fw(ar); 600 ret = ath10k_download_fw(ar);
583 if (ret) 601 if (ret) {
602 ath10k_err("failed to download firmware: %d\n", ret);
584 return ret; 603 return ret;
604 }
585 605
586 return ret; 606 return ret;
587} 607}
@@ -835,9 +855,12 @@ int ath10k_core_start(struct ath10k *ar)
835 INIT_LIST_HEAD(&ar->arvifs); 855 INIT_LIST_HEAD(&ar->arvifs);
836 856
837 if (!test_bit(ATH10K_FLAG_FIRST_BOOT_DONE, &ar->dev_flags)) 857 if (!test_bit(ATH10K_FLAG_FIRST_BOOT_DONE, &ar->dev_flags))
838 ath10k_info("%s (0x%x) fw %s api %d htt %d.%d\n", 858 ath10k_info("%s (0x%08x, 0x%08x) fw %s api %d htt %d.%d\n",
839 ar->hw_params.name, ar->target_version, 859 ar->hw_params.name,
840 ar->hw->wiphy->fw_version, ar->fw_api, 860 ar->target_version,
861 ar->chip_id,
862 ar->hw->wiphy->fw_version,
863 ar->fw_api,
841 ar->htt.target_version_major, 864 ar->htt.target_version_major,
842 ar->htt.target_version_minor); 865 ar->htt.target_version_minor);
843 866
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index 0e71979d837c..2c1dfd719146 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -119,6 +119,7 @@ struct ath10k_peer_stat {
119 u8 peer_macaddr[ETH_ALEN]; 119 u8 peer_macaddr[ETH_ALEN];
120 u32 peer_rssi; 120 u32 peer_rssi;
121 u32 peer_tx_rate; 121 u32 peer_tx_rate;
122 u32 peer_rx_rate; /* 10x only */
122}; 123};
123 124
124struct ath10k_target_stats { 125struct ath10k_target_stats {
@@ -130,6 +131,12 @@ struct ath10k_target_stats {
130 u32 cycle_count; 131 u32 cycle_count;
131 u32 phy_err_count; 132 u32 phy_err_count;
132 u32 chan_tx_power; 133 u32 chan_tx_power;
134 u32 ack_rx_bad;
135 u32 rts_bad;
136 u32 rts_good;
137 u32 fcs_bad;
138 u32 no_beacons;
139 u32 mib_int_count;
133 140
134 /* PDEV TX stats */ 141 /* PDEV TX stats */
135 s32 comp_queued; 142 s32 comp_queued;
@@ -260,6 +267,8 @@ struct ath10k_vif {
260 u8 fixed_rate; 267 u8 fixed_rate;
261 u8 fixed_nss; 268 u8 fixed_nss;
262 u8 force_sgi; 269 u8 force_sgi;
270 bool use_cts_prot;
271 int num_legacy_stations;
263}; 272};
264 273
265struct ath10k_vif_iter { 274struct ath10k_vif_iter {
@@ -419,13 +428,18 @@ struct ath10k {
419 struct cfg80211_chan_def chandef; 428 struct cfg80211_chan_def chandef;
420 429
421 int free_vdev_map; 430 int free_vdev_map;
431 bool promisc;
432 bool monitor;
422 int monitor_vdev_id; 433 int monitor_vdev_id;
423 bool monitor_enabled; 434 bool monitor_started;
424 bool monitor_present;
425 unsigned int filter_flags; 435 unsigned int filter_flags;
426 unsigned long dev_flags; 436 unsigned long dev_flags;
427 u32 dfs_block_radar_events; 437 u32 dfs_block_radar_events;
428 438
439 /* protected by conf_mutex */
440 bool radar_enabled;
441 int num_started_vdevs;
442
429 struct wmi_pdev_set_wmm_params_arg wmm_params; 443 struct wmi_pdev_set_wmm_params_arg wmm_params;
430 struct completion install_key_done; 444 struct completion install_key_done;
431 445
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 6debd281350a..1b7ff4ba122c 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -161,7 +161,7 @@ void ath10k_debug_read_target_stats(struct ath10k *ar,
161 u8 *tmp = ev->data; 161 u8 *tmp = ev->data;
162 struct ath10k_target_stats *stats; 162 struct ath10k_target_stats *stats;
163 int num_pdev_stats, num_vdev_stats, num_peer_stats; 163 int num_pdev_stats, num_vdev_stats, num_peer_stats;
164 struct wmi_pdev_stats *ps; 164 struct wmi_pdev_stats_10x *ps;
165 int i; 165 int i;
166 166
167 spin_lock_bh(&ar->data_lock); 167 spin_lock_bh(&ar->data_lock);
@@ -173,7 +173,7 @@ void ath10k_debug_read_target_stats(struct ath10k *ar,
173 num_peer_stats = __le32_to_cpu(ev->num_peer_stats); /* 0 or max peers */ 173 num_peer_stats = __le32_to_cpu(ev->num_peer_stats); /* 0 or max peers */
174 174
175 if (num_pdev_stats) { 175 if (num_pdev_stats) {
176 ps = (struct wmi_pdev_stats *)tmp; 176 ps = (struct wmi_pdev_stats_10x *)tmp;
177 177
178 stats->ch_noise_floor = __le32_to_cpu(ps->chan_nf); 178 stats->ch_noise_floor = __le32_to_cpu(ps->chan_nf);
179 stats->tx_frame_count = __le32_to_cpu(ps->tx_frame_count); 179 stats->tx_frame_count = __le32_to_cpu(ps->tx_frame_count);
@@ -228,7 +228,18 @@ void ath10k_debug_read_target_stats(struct ath10k *ar,
228 stats->phy_err_drop = __le32_to_cpu(ps->wal.rx.phy_err_drop); 228 stats->phy_err_drop = __le32_to_cpu(ps->wal.rx.phy_err_drop);
229 stats->mpdu_errs = __le32_to_cpu(ps->wal.rx.mpdu_errs); 229 stats->mpdu_errs = __le32_to_cpu(ps->wal.rx.mpdu_errs);
230 230
231 tmp += sizeof(struct wmi_pdev_stats); 231 if (test_bit(ATH10K_FW_FEATURE_WMI_10X,
232 ar->fw_features)) {
233 stats->ack_rx_bad = __le32_to_cpu(ps->ack_rx_bad);
234 stats->rts_bad = __le32_to_cpu(ps->rts_bad);
235 stats->rts_good = __le32_to_cpu(ps->rts_good);
236 stats->fcs_bad = __le32_to_cpu(ps->fcs_bad);
237 stats->no_beacons = __le32_to_cpu(ps->no_beacons);
238 stats->mib_int_count = __le32_to_cpu(ps->mib_int_count);
239 tmp += sizeof(struct wmi_pdev_stats_10x);
240 } else {
241 tmp += sizeof(struct wmi_pdev_stats_old);
242 }
232 } 243 }
233 244
234 /* 0 or max vdevs */ 245 /* 0 or max vdevs */
@@ -243,22 +254,29 @@ void ath10k_debug_read_target_stats(struct ath10k *ar,
243 } 254 }
244 255
245 if (num_peer_stats) { 256 if (num_peer_stats) {
246 struct wmi_peer_stats *peer_stats; 257 struct wmi_peer_stats_10x *peer_stats;
247 struct ath10k_peer_stat *s; 258 struct ath10k_peer_stat *s;
248 259
249 stats->peers = num_peer_stats; 260 stats->peers = num_peer_stats;
250 261
251 for (i = 0; i < num_peer_stats; i++) { 262 for (i = 0; i < num_peer_stats; i++) {
252 peer_stats = (struct wmi_peer_stats *)tmp; 263 peer_stats = (struct wmi_peer_stats_10x *)tmp;
253 s = &stats->peer_stat[i]; 264 s = &stats->peer_stat[i];
254 265
255 WMI_MAC_ADDR_TO_CHAR_ARRAY(&peer_stats->peer_macaddr, 266 memcpy(s->peer_macaddr, &peer_stats->peer_macaddr.addr,
256 s->peer_macaddr); 267 ETH_ALEN);
257 s->peer_rssi = __le32_to_cpu(peer_stats->peer_rssi); 268 s->peer_rssi = __le32_to_cpu(peer_stats->peer_rssi);
258 s->peer_tx_rate = 269 s->peer_tx_rate =
259 __le32_to_cpu(peer_stats->peer_tx_rate); 270 __le32_to_cpu(peer_stats->peer_tx_rate);
260 271 if (test_bit(ATH10K_FW_FEATURE_WMI_10X,
261 tmp += sizeof(struct wmi_peer_stats); 272 ar->fw_features)) {
273 s->peer_rx_rate =
274 __le32_to_cpu(peer_stats->peer_rx_rate);
275 tmp += sizeof(struct wmi_peer_stats_10x);
276
277 } else {
278 tmp += sizeof(struct wmi_peer_stats_old);
279 }
262 } 280 }
263 } 281 }
264 282
@@ -272,7 +290,7 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,
272 struct ath10k *ar = file->private_data; 290 struct ath10k *ar = file->private_data;
273 struct ath10k_target_stats *fw_stats; 291 struct ath10k_target_stats *fw_stats;
274 char *buf = NULL; 292 char *buf = NULL;
275 unsigned int len = 0, buf_len = 2500; 293 unsigned int len = 0, buf_len = 8000;
276 ssize_t ret_cnt = 0; 294 ssize_t ret_cnt = 0;
277 long left; 295 long left;
278 int i; 296 int i;
@@ -320,6 +338,16 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,
320 "Cycle count", fw_stats->cycle_count); 338 "Cycle count", fw_stats->cycle_count);
321 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n", 339 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
322 "PHY error count", fw_stats->phy_err_count); 340 "PHY error count", fw_stats->phy_err_count);
341 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
342 "RTS bad count", fw_stats->rts_bad);
343 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
344 "RTS good count", fw_stats->rts_good);
345 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
346 "FCS bad count", fw_stats->fcs_bad);
347 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
348 "No beacon count", fw_stats->no_beacons);
349 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
350 "MIB int count", fw_stats->mib_int_count);
323 351
324 len += scnprintf(buf + len, buf_len - len, "\n"); 352 len += scnprintf(buf + len, buf_len - len, "\n");
325 len += scnprintf(buf + len, buf_len - len, "%30s\n", 353 len += scnprintf(buf + len, buf_len - len, "%30s\n",
@@ -411,8 +439,8 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,
411 "MPDU errors (FCS, MIC, ENC)", fw_stats->mpdu_errs); 439 "MPDU errors (FCS, MIC, ENC)", fw_stats->mpdu_errs);
412 440
413 len += scnprintf(buf + len, buf_len - len, "\n"); 441 len += scnprintf(buf + len, buf_len - len, "\n");
414 len += scnprintf(buf + len, buf_len - len, "%30s\n", 442 len += scnprintf(buf + len, buf_len - len, "%30s (%d)\n",
415 "ath10k PEER stats"); 443 "ath10k PEER stats", fw_stats->peers);
416 len += scnprintf(buf + len, buf_len - len, "%30s\n\n", 444 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
417 "================="); 445 "=================");
418 446
@@ -425,6 +453,9 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,
425 len += scnprintf(buf + len, buf_len - len, "%30s %u\n", 453 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
426 "Peer TX rate", 454 "Peer TX rate",
427 fw_stats->peer_stat[i].peer_tx_rate); 455 fw_stats->peer_stat[i].peer_tx_rate);
456 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
457 "Peer RX rate",
458 fw_stats->peer_stat[i].peer_rx_rate);
428 len += scnprintf(buf + len, buf_len - len, "\n"); 459 len += scnprintf(buf + len, buf_len - len, "\n");
429 } 460 }
430 spin_unlock_bh(&ar->data_lock); 461 spin_unlock_bh(&ar->data_lock);
@@ -451,27 +482,37 @@ static ssize_t ath10k_read_simulate_fw_crash(struct file *file,
451 char __user *user_buf, 482 char __user *user_buf,
452 size_t count, loff_t *ppos) 483 size_t count, loff_t *ppos)
453{ 484{
454 const char buf[] = "To simulate firmware crash write the keyword" 485 const char buf[] = "To simulate firmware crash write one of the"
455 " `crash` to this file.\nThis will force firmware" 486 " keywords to this file:\n `soft` - this will send"
456 " to report a crash to the host system.\n"; 487 " WMI_FORCE_FW_HANG_ASSERT to firmware if FW"
488 " supports that command.\n `hard` - this will send"
489 " to firmware command with illegal parameters"
490 " causing firmware crash.\n";
491
457 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); 492 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
458} 493}
459 494
495/* Simulate firmware crash:
496 * 'soft': Call wmi command causing firmware hang. This firmware hang is
497 * recoverable by warm firmware reset.
498 * 'hard': Force firmware crash by setting any vdev parameter for not allowed
499 * vdev id. This is hard firmware crash because it is recoverable only by cold
500 * firmware reset.
501 */
460static ssize_t ath10k_write_simulate_fw_crash(struct file *file, 502static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
461 const char __user *user_buf, 503 const char __user *user_buf,
462 size_t count, loff_t *ppos) 504 size_t count, loff_t *ppos)
463{ 505{
464 struct ath10k *ar = file->private_data; 506 struct ath10k *ar = file->private_data;
465 char buf[32] = {}; 507 char buf[32];
466 int ret; 508 int ret;
467 509
468 mutex_lock(&ar->conf_mutex); 510 mutex_lock(&ar->conf_mutex);
469 511
470 simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); 512 simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
471 if (strcmp(buf, "crash") && strcmp(buf, "crash\n")) { 513
472 ret = -EINVAL; 514 /* make sure that buf is null terminated */
473 goto exit; 515 buf[sizeof(buf) - 1] = 0;
474 }
475 516
476 if (ar->state != ATH10K_STATE_ON && 517 if (ar->state != ATH10K_STATE_ON &&
477 ar->state != ATH10K_STATE_RESTARTED) { 518 ar->state != ATH10K_STATE_RESTARTED) {
@@ -479,14 +520,30 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
479 goto exit; 520 goto exit;
480 } 521 }
481 522
482 ath10k_info("simulating firmware crash\n"); 523 /* drop the possible '\n' from the end */
524 if (buf[count - 1] == '\n') {
525 buf[count - 1] = 0;
526 count--;
527 }
483 528
484 ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0); 529 if (!strcmp(buf, "soft")) {
485 if (ret) 530 ath10k_info("simulating soft firmware crash\n");
486 ath10k_warn("failed to force fw hang (%d)\n", ret); 531 ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0);
532 } else if (!strcmp(buf, "hard")) {
533 ath10k_info("simulating hard firmware crash\n");
534 ret = ath10k_wmi_vdev_set_param(ar, TARGET_NUM_VDEVS + 1,
535 ar->wmi.vdev_param->rts_threshold, 0);
536 } else {
537 ret = -EINVAL;
538 goto exit;
539 }
540
541 if (ret) {
542 ath10k_warn("failed to simulate firmware crash: %d\n", ret);
543 goto exit;
544 }
487 545
488 if (ret == 0) 546 ret = count;
489 ret = count;
490 547
491exit: 548exit:
492 mutex_unlock(&ar->conf_mutex); 549 mutex_unlock(&ar->conf_mutex);
diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
index 7f1bccd3597f..5b58dbb17416 100644
--- a/drivers/net/wireless/ath/ath10k/htc.c
+++ b/drivers/net/wireless/ath/ath10k/htc.c
@@ -157,6 +157,9 @@ int ath10k_htc_send(struct ath10k_htc *htc,
157 goto err_pull; 157 goto err_pull;
158 } 158 }
159 ep->tx_credits -= credits; 159 ep->tx_credits -= credits;
160 ath10k_dbg(ATH10K_DBG_HTC,
161 "htc ep %d consumed %d credits (total %d)\n",
162 eid, credits, ep->tx_credits);
160 spin_unlock_bh(&htc->tx_lock); 163 spin_unlock_bh(&htc->tx_lock);
161 } 164 }
162 165
@@ -185,6 +188,9 @@ err_credits:
185 if (ep->tx_credit_flow_enabled) { 188 if (ep->tx_credit_flow_enabled) {
186 spin_lock_bh(&htc->tx_lock); 189 spin_lock_bh(&htc->tx_lock);
187 ep->tx_credits += credits; 190 ep->tx_credits += credits;
191 ath10k_dbg(ATH10K_DBG_HTC,
192 "htc ep %d reverted %d credits back (total %d)\n",
193 eid, credits, ep->tx_credits);
188 spin_unlock_bh(&htc->tx_lock); 194 spin_unlock_bh(&htc->tx_lock);
189 195
190 if (ep->ep_ops.ep_tx_credits) 196 if (ep->ep_ops.ep_tx_credits)
@@ -234,12 +240,12 @@ ath10k_htc_process_credit_report(struct ath10k_htc *htc,
234 if (report->eid >= ATH10K_HTC_EP_COUNT) 240 if (report->eid >= ATH10K_HTC_EP_COUNT)
235 break; 241 break;
236 242
237 ath10k_dbg(ATH10K_DBG_HTC, "ep %d got %d credits\n",
238 report->eid, report->credits);
239
240 ep = &htc->endpoint[report->eid]; 243 ep = &htc->endpoint[report->eid];
241 ep->tx_credits += report->credits; 244 ep->tx_credits += report->credits;
242 245
246 ath10k_dbg(ATH10K_DBG_HTC, "htc ep %d got %d credits (total %d)\n",
247 report->eid, report->credits, ep->tx_credits);
248
243 if (ep->ep_ops.ep_tx_credits) { 249 if (ep->ep_ops.ep_tx_credits) {
244 spin_unlock_bh(&htc->tx_lock); 250 spin_unlock_bh(&htc->tx_lock);
245 ep->ep_ops.ep_tx_credits(htc->ar); 251 ep->ep_ops.ep_tx_credits(htc->ar);
diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h
index 654867fc1ae7..645a563e3fb9 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -21,6 +21,7 @@
21#include <linux/bug.h> 21#include <linux/bug.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/dmapool.h> 23#include <linux/dmapool.h>
24#include <net/mac80211.h>
24 25
25#include "htc.h" 26#include "htc.h"
26#include "rx_desc.h" 27#include "rx_desc.h"
@@ -1172,23 +1173,6 @@ struct htt_peer_unmap_event {
1172 u16 peer_id; 1173 u16 peer_id;
1173}; 1174};
1174 1175
1175struct htt_rx_info {
1176 struct sk_buff *skb;
1177 enum htt_rx_mpdu_status status;
1178 enum htt_rx_mpdu_encrypt_type encrypt_type;
1179 s8 signal;
1180 struct {
1181 u8 info0;
1182 u32 info1;
1183 u32 info2;
1184 } rate;
1185
1186 u32 tsf;
1187 bool fcs_err;
1188 bool amsdu_more;
1189 bool mic_err;
1190};
1191
1192struct ath10k_htt_txbuf { 1176struct ath10k_htt_txbuf {
1193 struct htt_data_tx_desc_frag frags[2]; 1177 struct htt_data_tx_desc_frag frags[2];
1194 struct ath10k_htc_hdr htc_hdr; 1178 struct ath10k_htc_hdr htc_hdr;
@@ -1289,6 +1273,9 @@ struct ath10k_htt {
1289 struct tasklet_struct txrx_compl_task; 1273 struct tasklet_struct txrx_compl_task;
1290 struct sk_buff_head tx_compl_q; 1274 struct sk_buff_head tx_compl_q;
1291 struct sk_buff_head rx_compl_q; 1275 struct sk_buff_head rx_compl_q;
1276
1277 /* rx_status template */
1278 struct ieee80211_rx_status rx_status;
1292}; 1279};
1293 1280
1294#define RX_HTT_HDR_STATUS_LEN 64 1281#define RX_HTT_HDR_STATUS_LEN 64
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index cdcbe2de95f9..f85a3cf6da31 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -297,6 +297,7 @@ static void ath10k_htt_rx_free_msdu_chain(struct sk_buff *skb)
297 } 297 }
298} 298}
299 299
300/* return: < 0 fatal error, 0 - non chained msdu, 1 chained msdu */
300static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt, 301static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
301 u8 **fw_desc, int *fw_desc_len, 302 u8 **fw_desc, int *fw_desc_len,
302 struct sk_buff **head_msdu, 303 struct sk_buff **head_msdu,
@@ -310,7 +311,7 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
310 311
311 if (htt->rx_confused) { 312 if (htt->rx_confused) {
312 ath10k_warn("htt is confused. refusing rx\n"); 313 ath10k_warn("htt is confused. refusing rx\n");
313 return 0; 314 return -1;
314 } 315 }
315 316
316 msdu = *head_msdu = ath10k_htt_rx_netbuf_pop(htt); 317 msdu = *head_msdu = ath10k_htt_rx_netbuf_pop(htt);
@@ -442,6 +443,9 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
442 } 443 }
443 *tail_msdu = msdu; 444 *tail_msdu = msdu;
444 445
446 if (*head_msdu == NULL)
447 msdu_chaining = -1;
448
445 /* 449 /*
446 * Don't refill the ring yet. 450 * Don't refill the ring yet.
447 * 451 *
@@ -636,6 +640,190 @@ struct amsdu_subframe_hdr {
636 __be16 len; 640 __be16 len;
637} __packed; 641} __packed;
638 642
643static const u8 rx_legacy_rate_idx[] = {
644 3, /* 0x00 - 11Mbps */
645 2, /* 0x01 - 5.5Mbps */
646 1, /* 0x02 - 2Mbps */
647 0, /* 0x03 - 1Mbps */
648 3, /* 0x04 - 11Mbps */
649 2, /* 0x05 - 5.5Mbps */
650 1, /* 0x06 - 2Mbps */
651 0, /* 0x07 - 1Mbps */
652 10, /* 0x08 - 48Mbps */
653 8, /* 0x09 - 24Mbps */
654 6, /* 0x0A - 12Mbps */
655 4, /* 0x0B - 6Mbps */
656 11, /* 0x0C - 54Mbps */
657 9, /* 0x0D - 36Mbps */
658 7, /* 0x0E - 18Mbps */
659 5, /* 0x0F - 9Mbps */
660};
661
662static void ath10k_htt_rx_h_rates(struct ath10k *ar,
663 enum ieee80211_band band,
664 u8 info0, u32 info1, u32 info2,
665 struct ieee80211_rx_status *status)
666{
667 u8 cck, rate, rate_idx, bw, sgi, mcs, nss;
668 u8 preamble = 0;
669
670 /* Check if valid fields */
671 if (!(info0 & HTT_RX_INDICATION_INFO0_START_VALID))
672 return;
673
674 preamble = MS(info1, HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE);
675
676 switch (preamble) {
677 case HTT_RX_LEGACY:
678 cck = info0 & HTT_RX_INDICATION_INFO0_LEGACY_RATE_CCK;
679 rate = MS(info0, HTT_RX_INDICATION_INFO0_LEGACY_RATE);
680 rate_idx = 0;
681
682 if (rate < 0x08 || rate > 0x0F)
683 break;
684
685 switch (band) {
686 case IEEE80211_BAND_2GHZ:
687 if (cck)
688 rate &= ~BIT(3);
689 rate_idx = rx_legacy_rate_idx[rate];
690 break;
691 case IEEE80211_BAND_5GHZ:
692 rate_idx = rx_legacy_rate_idx[rate];
693 /* We are using same rate table registering
694 HW - ath10k_rates[]. In case of 5GHz skip
695 CCK rates, so -4 here */
696 rate_idx -= 4;
697 break;
698 default:
699 break;
700 }
701
702 status->rate_idx = rate_idx;
703 break;
704 case HTT_RX_HT:
705 case HTT_RX_HT_WITH_TXBF:
706 /* HT-SIG - Table 20-11 in info1 and info2 */
707 mcs = info1 & 0x1F;
708 nss = mcs >> 3;
709 bw = (info1 >> 7) & 1;
710 sgi = (info2 >> 7) & 1;
711
712 status->rate_idx = mcs;
713 status->flag |= RX_FLAG_HT;
714 if (sgi)
715 status->flag |= RX_FLAG_SHORT_GI;
716 if (bw)
717 status->flag |= RX_FLAG_40MHZ;
718 break;
719 case HTT_RX_VHT:
720 case HTT_RX_VHT_WITH_TXBF:
721 /* VHT-SIG-A1 in info 1, VHT-SIG-A2 in info2
722 TODO check this */
723 mcs = (info2 >> 4) & 0x0F;
724 nss = ((info1 >> 10) & 0x07) + 1;
725 bw = info1 & 3;
726 sgi = info2 & 1;
727
728 status->rate_idx = mcs;
729 status->vht_nss = nss;
730
731 if (sgi)
732 status->flag |= RX_FLAG_SHORT_GI;
733
734 switch (bw) {
735 /* 20MHZ */
736 case 0:
737 break;
738 /* 40MHZ */
739 case 1:
740 status->flag |= RX_FLAG_40MHZ;
741 break;
742 /* 80MHZ */
743 case 2:
744 status->vht_flag |= RX_VHT_FLAG_80MHZ;
745 }
746
747 status->flag |= RX_FLAG_VHT;
748 break;
749 default:
750 break;
751 }
752}
753
754static void ath10k_htt_rx_h_protected(struct ath10k_htt *htt,
755 struct ieee80211_rx_status *rx_status,
756 struct sk_buff *skb,
757 enum htt_rx_mpdu_encrypt_type enctype)
758{
759 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
760
761
762 if (enctype == HTT_RX_MPDU_ENCRYPT_NONE) {
763 rx_status->flag &= ~(RX_FLAG_DECRYPTED |
764 RX_FLAG_IV_STRIPPED |
765 RX_FLAG_MMIC_STRIPPED);
766 return;
767 }
768
769 rx_status->flag |= RX_FLAG_DECRYPTED |
770 RX_FLAG_IV_STRIPPED |
771 RX_FLAG_MMIC_STRIPPED;
772 hdr->frame_control = __cpu_to_le16(__le16_to_cpu(hdr->frame_control) &
773 ~IEEE80211_FCTL_PROTECTED);
774}
775
776static bool ath10k_htt_rx_h_channel(struct ath10k *ar,
777 struct ieee80211_rx_status *status)
778{
779 struct ieee80211_channel *ch;
780
781 spin_lock_bh(&ar->data_lock);
782 ch = ar->scan_channel;
783 if (!ch)
784 ch = ar->rx_channel;
785 spin_unlock_bh(&ar->data_lock);
786
787 if (!ch)
788 return false;
789
790 status->band = ch->band;
791 status->freq = ch->center_freq;
792
793 return true;
794}
795
796static void ath10k_process_rx(struct ath10k *ar,
797 struct ieee80211_rx_status *rx_status,
798 struct sk_buff *skb)
799{
800 struct ieee80211_rx_status *status;
801
802 status = IEEE80211_SKB_RXCB(skb);
803 *status = *rx_status;
804
805 ath10k_dbg(ATH10K_DBG_DATA,
806 "rx skb %p len %u %s%s%s%s%s %srate_idx %u vht_nss %u freq %u band %u flag 0x%x fcs-err %imic-err %i\n",
807 skb,
808 skb->len,
809 status->flag == 0 ? "legacy" : "",
810 status->flag & RX_FLAG_HT ? "ht" : "",
811 status->flag & RX_FLAG_VHT ? "vht" : "",
812 status->flag & RX_FLAG_40MHZ ? "40" : "",
813 status->vht_flag & RX_VHT_FLAG_80MHZ ? "80" : "",
814 status->flag & RX_FLAG_SHORT_GI ? "sgi " : "",
815 status->rate_idx,
816 status->vht_nss,
817 status->freq,
818 status->band, status->flag,
819 !!(status->flag & RX_FLAG_FAILED_FCS_CRC),
820 !!(status->flag & RX_FLAG_MMIC_ERROR));
821 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "rx skb: ",
822 skb->data, skb->len);
823
824 ieee80211_rx(ar->hw, skb);
825}
826
639static int ath10k_htt_rx_nwifi_hdrlen(struct ieee80211_hdr *hdr) 827static int ath10k_htt_rx_nwifi_hdrlen(struct ieee80211_hdr *hdr)
640{ 828{
641 /* nwifi header is padded to 4 bytes. this fixes 4addr rx */ 829 /* nwifi header is padded to 4 bytes. this fixes 4addr rx */
@@ -643,11 +831,12 @@ static int ath10k_htt_rx_nwifi_hdrlen(struct ieee80211_hdr *hdr)
643} 831}
644 832
645static void ath10k_htt_rx_amsdu(struct ath10k_htt *htt, 833static void ath10k_htt_rx_amsdu(struct ath10k_htt *htt,
646 struct htt_rx_info *info) 834 struct ieee80211_rx_status *rx_status,
835 struct sk_buff *skb_in)
647{ 836{
648 struct htt_rx_desc *rxd; 837 struct htt_rx_desc *rxd;
838 struct sk_buff *skb = skb_in;
649 struct sk_buff *first; 839 struct sk_buff *first;
650 struct sk_buff *skb = info->skb;
651 enum rx_msdu_decap_format fmt; 840 enum rx_msdu_decap_format fmt;
652 enum htt_rx_mpdu_encrypt_type enctype; 841 enum htt_rx_mpdu_encrypt_type enctype;
653 struct ieee80211_hdr *hdr; 842 struct ieee80211_hdr *hdr;
@@ -728,24 +917,27 @@ static void ath10k_htt_rx_amsdu(struct ath10k_htt *htt,
728 break; 917 break;
729 } 918 }
730 919
731 info->skb = skb; 920 skb_in = skb;
732 info->encrypt_type = enctype; 921 ath10k_htt_rx_h_protected(htt, rx_status, skb_in, enctype);
733 skb = skb->next; 922 skb = skb->next;
734 info->skb->next = NULL; 923 skb_in->next = NULL;
735 924
736 if (skb) 925 if (skb)
737 info->amsdu_more = true; 926 rx_status->flag |= RX_FLAG_AMSDU_MORE;
927 else
928 rx_status->flag &= ~RX_FLAG_AMSDU_MORE;
738 929
739 ath10k_process_rx(htt->ar, info); 930 ath10k_process_rx(htt->ar, rx_status, skb_in);
740 } 931 }
741 932
742 /* FIXME: It might be nice to re-assemble the A-MSDU when there's a 933 /* FIXME: It might be nice to re-assemble the A-MSDU when there's a
743 * monitor interface active for sniffing purposes. */ 934 * monitor interface active for sniffing purposes. */
744} 935}
745 936
746static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info) 937static void ath10k_htt_rx_msdu(struct ath10k_htt *htt,
938 struct ieee80211_rx_status *rx_status,
939 struct sk_buff *skb)
747{ 940{
748 struct sk_buff *skb = info->skb;
749 struct htt_rx_desc *rxd; 941 struct htt_rx_desc *rxd;
750 struct ieee80211_hdr *hdr; 942 struct ieee80211_hdr *hdr;
751 enum rx_msdu_decap_format fmt; 943 enum rx_msdu_decap_format fmt;
@@ -808,66 +1000,9 @@ static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info)
808 break; 1000 break;
809 } 1001 }
810 1002
811 info->skb = skb; 1003 ath10k_htt_rx_h_protected(htt, rx_status, skb, enctype);
812 info->encrypt_type = enctype;
813
814 ath10k_process_rx(htt->ar, info);
815}
816
817static bool ath10k_htt_rx_has_decrypt_err(struct sk_buff *skb)
818{
819 struct htt_rx_desc *rxd;
820 u32 flags;
821
822 rxd = (void *)skb->data - sizeof(*rxd);
823 flags = __le32_to_cpu(rxd->attention.flags);
824
825 if (flags & RX_ATTENTION_FLAGS_DECRYPT_ERR)
826 return true;
827
828 return false;
829}
830
831static bool ath10k_htt_rx_has_fcs_err(struct sk_buff *skb)
832{
833 struct htt_rx_desc *rxd;
834 u32 flags;
835
836 rxd = (void *)skb->data - sizeof(*rxd);
837 flags = __le32_to_cpu(rxd->attention.flags);
838
839 if (flags & RX_ATTENTION_FLAGS_FCS_ERR)
840 return true;
841
842 return false;
843}
844
845static bool ath10k_htt_rx_has_mic_err(struct sk_buff *skb)
846{
847 struct htt_rx_desc *rxd;
848 u32 flags;
849
850 rxd = (void *)skb->data - sizeof(*rxd);
851 flags = __le32_to_cpu(rxd->attention.flags);
852
853 if (flags & RX_ATTENTION_FLAGS_TKIP_MIC_ERR)
854 return true;
855
856 return false;
857}
858
859static bool ath10k_htt_rx_is_mgmt(struct sk_buff *skb)
860{
861 struct htt_rx_desc *rxd;
862 u32 flags;
863
864 rxd = (void *)skb->data - sizeof(*rxd);
865 flags = __le32_to_cpu(rxd->attention.flags);
866
867 if (flags & RX_ATTENTION_FLAGS_MGMT_TYPE)
868 return true;
869 1004
870 return false; 1005 ath10k_process_rx(htt->ar, rx_status, skb);
871} 1006}
872 1007
873static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb) 1008static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb)
@@ -952,21 +1087,73 @@ static int ath10k_unchain_msdu(struct sk_buff *msdu_head)
952 return 0; 1087 return 0;
953} 1088}
954 1089
1090static bool ath10k_htt_rx_amsdu_allowed(struct ath10k_htt *htt,
1091 struct sk_buff *head,
1092 enum htt_rx_mpdu_status status,
1093 bool channel_set,
1094 u32 attention)
1095{
1096 if (head->len == 0) {
1097 ath10k_dbg(ATH10K_DBG_HTT,
1098 "htt rx dropping due to zero-len\n");
1099 return false;
1100 }
1101
1102 if (attention & RX_ATTENTION_FLAGS_DECRYPT_ERR) {
1103 ath10k_dbg(ATH10K_DBG_HTT,
1104 "htt rx dropping due to decrypt-err\n");
1105 return false;
1106 }
1107
1108 if (!channel_set) {
1109 ath10k_warn("no channel configured; ignoring frame!\n");
1110 return false;
1111 }
1112
1113 /* Skip mgmt frames while we handle this in WMI */
1114 if (status == HTT_RX_IND_MPDU_STATUS_MGMT_CTRL ||
1115 attention & RX_ATTENTION_FLAGS_MGMT_TYPE) {
1116 ath10k_dbg(ATH10K_DBG_HTT, "htt rx mgmt ctrl\n");
1117 return false;
1118 }
1119
1120 if (status != HTT_RX_IND_MPDU_STATUS_OK &&
1121 status != HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR &&
1122 status != HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER &&
1123 !htt->ar->monitor_started) {
1124 ath10k_dbg(ATH10K_DBG_HTT,
1125 "htt rx ignoring frame w/ status %d\n",
1126 status);
1127 return false;
1128 }
1129
1130 if (test_bit(ATH10K_CAC_RUNNING, &htt->ar->dev_flags)) {
1131 ath10k_dbg(ATH10K_DBG_HTT,
1132 "htt rx CAC running\n");
1133 return false;
1134 }
1135
1136 return true;
1137}
1138
955static void ath10k_htt_rx_handler(struct ath10k_htt *htt, 1139static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
956 struct htt_rx_indication *rx) 1140 struct htt_rx_indication *rx)
957{ 1141{
958 struct htt_rx_info info; 1142 struct ieee80211_rx_status *rx_status = &htt->rx_status;
959 struct htt_rx_indication_mpdu_range *mpdu_ranges; 1143 struct htt_rx_indication_mpdu_range *mpdu_ranges;
1144 struct htt_rx_desc *rxd;
1145 enum htt_rx_mpdu_status status;
960 struct ieee80211_hdr *hdr; 1146 struct ieee80211_hdr *hdr;
961 int num_mpdu_ranges; 1147 int num_mpdu_ranges;
1148 u32 attention;
962 int fw_desc_len; 1149 int fw_desc_len;
963 u8 *fw_desc; 1150 u8 *fw_desc;
1151 bool channel_set;
964 int i, j; 1152 int i, j;
1153 int ret;
965 1154
966 lockdep_assert_held(&htt->rx_ring.lock); 1155 lockdep_assert_held(&htt->rx_ring.lock);
967 1156
968 memset(&info, 0, sizeof(info));
969
970 fw_desc_len = __le16_to_cpu(rx->prefix.fw_rx_desc_bytes); 1157 fw_desc_len = __le16_to_cpu(rx->prefix.fw_rx_desc_bytes);
971 fw_desc = (u8 *)&rx->fw_desc; 1158 fw_desc = (u8 *)&rx->fw_desc;
972 1159
@@ -974,106 +1161,90 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
974 HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES); 1161 HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES);
975 mpdu_ranges = htt_rx_ind_get_mpdu_ranges(rx); 1162 mpdu_ranges = htt_rx_ind_get_mpdu_ranges(rx);
976 1163
1164 /* Fill this once, while this is per-ppdu */
1165 if (rx->ppdu.info0 & HTT_RX_INDICATION_INFO0_START_VALID) {
1166 memset(rx_status, 0, sizeof(*rx_status));
1167 rx_status->signal = ATH10K_DEFAULT_NOISE_FLOOR +
1168 rx->ppdu.combined_rssi;
1169 }
1170
1171 if (rx->ppdu.info0 & HTT_RX_INDICATION_INFO0_END_VALID) {
1172 /* TSF available only in 32-bit */
1173 rx_status->mactime = __le32_to_cpu(rx->ppdu.tsf) & 0xffffffff;
1174 rx_status->flag |= RX_FLAG_MACTIME_END;
1175 }
1176
1177 channel_set = ath10k_htt_rx_h_channel(htt->ar, rx_status);
1178
1179 if (channel_set) {
1180 ath10k_htt_rx_h_rates(htt->ar, rx_status->band,
1181 rx->ppdu.info0,
1182 __le32_to_cpu(rx->ppdu.info1),
1183 __le32_to_cpu(rx->ppdu.info2),
1184 rx_status);
1185 }
1186
977 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt rx ind: ", 1187 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt rx ind: ",
978 rx, sizeof(*rx) + 1188 rx, sizeof(*rx) +
979 (sizeof(struct htt_rx_indication_mpdu_range) * 1189 (sizeof(struct htt_rx_indication_mpdu_range) *
980 num_mpdu_ranges)); 1190 num_mpdu_ranges));
981 1191
982 for (i = 0; i < num_mpdu_ranges; i++) { 1192 for (i = 0; i < num_mpdu_ranges; i++) {
983 info.status = mpdu_ranges[i].mpdu_range_status; 1193 status = mpdu_ranges[i].mpdu_range_status;
984 1194
985 for (j = 0; j < mpdu_ranges[i].mpdu_count; j++) { 1195 for (j = 0; j < mpdu_ranges[i].mpdu_count; j++) {
986 struct sk_buff *msdu_head, *msdu_tail; 1196 struct sk_buff *msdu_head, *msdu_tail;
987 enum htt_rx_mpdu_status status;
988 int msdu_chaining;
989 1197
990 msdu_head = NULL; 1198 msdu_head = NULL;
991 msdu_tail = NULL; 1199 msdu_tail = NULL;
992 msdu_chaining = ath10k_htt_rx_amsdu_pop(htt, 1200 ret = ath10k_htt_rx_amsdu_pop(htt,
993 &fw_desc, 1201 &fw_desc,
994 &fw_desc_len, 1202 &fw_desc_len,
995 &msdu_head, 1203 &msdu_head,
996 &msdu_tail); 1204 &msdu_tail);
997 1205
998 if (!msdu_head) { 1206 if (ret < 0) {
999 ath10k_warn("htt rx no data!\n"); 1207 ath10k_warn("failed to pop amsdu from htt rx ring %d\n",
1000 continue; 1208 ret);
1001 }
1002
1003 if (msdu_head->len == 0) {
1004 ath10k_dbg(ATH10K_DBG_HTT,
1005 "htt rx dropping due to zero-len\n");
1006 ath10k_htt_rx_free_msdu_chain(msdu_head);
1007 continue;
1008 }
1009
1010 if (ath10k_htt_rx_has_decrypt_err(msdu_head)) {
1011 ath10k_dbg(ATH10K_DBG_HTT,
1012 "htt rx dropping due to decrypt-err\n");
1013 ath10k_htt_rx_free_msdu_chain(msdu_head); 1209 ath10k_htt_rx_free_msdu_chain(msdu_head);
1014 continue; 1210 continue;
1015 } 1211 }
1016 1212
1017 status = info.status; 1213 rxd = container_of((void *)msdu_head->data,
1018 1214 struct htt_rx_desc,
1019 /* Skip mgmt frames while we handle this in WMI */ 1215 msdu_payload);
1020 if (status == HTT_RX_IND_MPDU_STATUS_MGMT_CTRL || 1216 attention = __le32_to_cpu(rxd->attention.flags);
1021 ath10k_htt_rx_is_mgmt(msdu_head)) {
1022 ath10k_dbg(ATH10K_DBG_HTT, "htt rx mgmt ctrl\n");
1023 ath10k_htt_rx_free_msdu_chain(msdu_head);
1024 continue;
1025 }
1026 1217
1027 if (status != HTT_RX_IND_MPDU_STATUS_OK && 1218 if (!ath10k_htt_rx_amsdu_allowed(htt, msdu_head,
1028 status != HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR && 1219 status,
1029 status != HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER && 1220 channel_set,
1030 !htt->ar->monitor_enabled) { 1221 attention)) {
1031 ath10k_dbg(ATH10K_DBG_HTT,
1032 "htt rx ignoring frame w/ status %d\n",
1033 status);
1034 ath10k_htt_rx_free_msdu_chain(msdu_head); 1222 ath10k_htt_rx_free_msdu_chain(msdu_head);
1035 continue; 1223 continue;
1036 } 1224 }
1037 1225
1038 if (test_bit(ATH10K_CAC_RUNNING, &htt->ar->dev_flags)) { 1226 if (ret > 0 &&
1039 ath10k_dbg(ATH10K_DBG_HTT, 1227 ath10k_unchain_msdu(msdu_head) < 0) {
1040 "htt rx CAC running\n");
1041 ath10k_htt_rx_free_msdu_chain(msdu_head); 1228 ath10k_htt_rx_free_msdu_chain(msdu_head);
1042 continue; 1229 continue;
1043 } 1230 }
1044 1231
1045 if (msdu_chaining && 1232 if (attention & RX_ATTENTION_FLAGS_FCS_ERR)
1046 (ath10k_unchain_msdu(msdu_head) < 0)) { 1233 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
1047 ath10k_htt_rx_free_msdu_chain(msdu_head); 1234 else
1048 continue; 1235 rx_status->flag &= ~RX_FLAG_FAILED_FCS_CRC;
1049 }
1050
1051 info.skb = msdu_head;
1052 info.fcs_err = ath10k_htt_rx_has_fcs_err(msdu_head);
1053 info.mic_err = ath10k_htt_rx_has_mic_err(msdu_head);
1054
1055 if (info.fcs_err)
1056 ath10k_dbg(ATH10K_DBG_HTT,
1057 "htt rx has FCS err\n");
1058
1059 if (info.mic_err)
1060 ath10k_dbg(ATH10K_DBG_HTT,
1061 "htt rx has MIC err\n");
1062
1063 info.signal = ATH10K_DEFAULT_NOISE_FLOOR;
1064 info.signal += rx->ppdu.combined_rssi;
1065 1236
1066 info.rate.info0 = rx->ppdu.info0; 1237 if (attention & RX_ATTENTION_FLAGS_TKIP_MIC_ERR)
1067 info.rate.info1 = __le32_to_cpu(rx->ppdu.info1); 1238 rx_status->flag |= RX_FLAG_MMIC_ERROR;
1068 info.rate.info2 = __le32_to_cpu(rx->ppdu.info2); 1239 else
1069 info.tsf = __le32_to_cpu(rx->ppdu.tsf); 1240 rx_status->flag &= ~RX_FLAG_MMIC_ERROR;
1070 1241
1071 hdr = ath10k_htt_rx_skb_get_hdr(msdu_head); 1242 hdr = ath10k_htt_rx_skb_get_hdr(msdu_head);
1072 1243
1073 if (ath10k_htt_rx_hdr_is_amsdu(hdr)) 1244 if (ath10k_htt_rx_hdr_is_amsdu(hdr))
1074 ath10k_htt_rx_amsdu(htt, &info); 1245 ath10k_htt_rx_amsdu(htt, rx_status, msdu_head);
1075 else 1246 else
1076 ath10k_htt_rx_msdu(htt, &info); 1247 ath10k_htt_rx_msdu(htt, rx_status, msdu_head);
1077 } 1248 }
1078 } 1249 }
1079 1250
@@ -1084,11 +1255,12 @@ static void ath10k_htt_rx_frag_handler(struct ath10k_htt *htt,
1084 struct htt_rx_fragment_indication *frag) 1255 struct htt_rx_fragment_indication *frag)
1085{ 1256{
1086 struct sk_buff *msdu_head, *msdu_tail; 1257 struct sk_buff *msdu_head, *msdu_tail;
1258 enum htt_rx_mpdu_encrypt_type enctype;
1087 struct htt_rx_desc *rxd; 1259 struct htt_rx_desc *rxd;
1088 enum rx_msdu_decap_format fmt; 1260 enum rx_msdu_decap_format fmt;
1089 struct htt_rx_info info = {}; 1261 struct ieee80211_rx_status *rx_status = &htt->rx_status;
1090 struct ieee80211_hdr *hdr; 1262 struct ieee80211_hdr *hdr;
1091 int msdu_chaining; 1263 int ret;
1092 bool tkip_mic_err; 1264 bool tkip_mic_err;
1093 bool decrypt_err; 1265 bool decrypt_err;
1094 u8 *fw_desc; 1266 u8 *fw_desc;
@@ -1102,19 +1274,15 @@ static void ath10k_htt_rx_frag_handler(struct ath10k_htt *htt,
1102 msdu_tail = NULL; 1274 msdu_tail = NULL;
1103 1275
1104 spin_lock_bh(&htt->rx_ring.lock); 1276 spin_lock_bh(&htt->rx_ring.lock);
1105 msdu_chaining = ath10k_htt_rx_amsdu_pop(htt, &fw_desc, &fw_desc_len, 1277 ret = ath10k_htt_rx_amsdu_pop(htt, &fw_desc, &fw_desc_len,
1106 &msdu_head, &msdu_tail); 1278 &msdu_head, &msdu_tail);
1107 spin_unlock_bh(&htt->rx_ring.lock); 1279 spin_unlock_bh(&htt->rx_ring.lock);
1108 1280
1109 ath10k_dbg(ATH10K_DBG_HTT_DUMP, "htt rx frag ahead\n"); 1281 ath10k_dbg(ATH10K_DBG_HTT_DUMP, "htt rx frag ahead\n");
1110 1282
1111 if (!msdu_head) { 1283 if (ret) {
1112 ath10k_warn("htt rx frag no data\n"); 1284 ath10k_warn("failed to pop amsdu from httr rx ring for fragmented rx %d\n",
1113 return; 1285 ret);
1114 }
1115
1116 if (msdu_chaining || msdu_head != msdu_tail) {
1117 ath10k_warn("aggregation with fragmentation?!\n");
1118 ath10k_htt_rx_free_msdu_chain(msdu_head); 1286 ath10k_htt_rx_free_msdu_chain(msdu_head);
1119 return; 1287 return;
1120 } 1288 }
@@ -1136,57 +1304,54 @@ static void ath10k_htt_rx_frag_handler(struct ath10k_htt *htt,
1136 goto end; 1304 goto end;
1137 } 1305 }
1138 1306
1139 info.skb = msdu_head; 1307 enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0),
1140 info.status = HTT_RX_IND_MPDU_STATUS_OK; 1308 RX_MPDU_START_INFO0_ENCRYPT_TYPE);
1141 info.encrypt_type = MS(__le32_to_cpu(rxd->mpdu_start.info0), 1309 ath10k_htt_rx_h_protected(htt, rx_status, msdu_head, enctype);
1142 RX_MPDU_START_INFO0_ENCRYPT_TYPE); 1310 msdu_head->ip_summed = ath10k_htt_rx_get_csum_state(msdu_head);
1143 info.skb->ip_summed = ath10k_htt_rx_get_csum_state(info.skb);
1144 1311
1145 if (tkip_mic_err) { 1312 if (tkip_mic_err)
1146 ath10k_warn("tkip mic error\n"); 1313 ath10k_warn("tkip mic error\n");
1147 info.status = HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR;
1148 }
1149 1314
1150 if (decrypt_err) { 1315 if (decrypt_err) {
1151 ath10k_warn("decryption err in fragmented rx\n"); 1316 ath10k_warn("decryption err in fragmented rx\n");
1152 dev_kfree_skb_any(info.skb); 1317 dev_kfree_skb_any(msdu_head);
1153 goto end; 1318 goto end;
1154 } 1319 }
1155 1320
1156 if (info.encrypt_type != HTT_RX_MPDU_ENCRYPT_NONE) { 1321 if (enctype != HTT_RX_MPDU_ENCRYPT_NONE) {
1157 hdrlen = ieee80211_hdrlen(hdr->frame_control); 1322 hdrlen = ieee80211_hdrlen(hdr->frame_control);
1158 paramlen = ath10k_htt_rx_crypto_param_len(info.encrypt_type); 1323 paramlen = ath10k_htt_rx_crypto_param_len(enctype);
1159 1324
1160 /* It is more efficient to move the header than the payload */ 1325 /* It is more efficient to move the header than the payload */
1161 memmove((void *)info.skb->data + paramlen, 1326 memmove((void *)msdu_head->data + paramlen,
1162 (void *)info.skb->data, 1327 (void *)msdu_head->data,
1163 hdrlen); 1328 hdrlen);
1164 skb_pull(info.skb, paramlen); 1329 skb_pull(msdu_head, paramlen);
1165 hdr = (struct ieee80211_hdr *)info.skb->data; 1330 hdr = (struct ieee80211_hdr *)msdu_head->data;
1166 } 1331 }
1167 1332
1168 /* remove trailing FCS */ 1333 /* remove trailing FCS */
1169 trim = 4; 1334 trim = 4;
1170 1335
1171 /* remove crypto trailer */ 1336 /* remove crypto trailer */
1172 trim += ath10k_htt_rx_crypto_tail_len(info.encrypt_type); 1337 trim += ath10k_htt_rx_crypto_tail_len(enctype);
1173 1338
1174 /* last fragment of TKIP frags has MIC */ 1339 /* last fragment of TKIP frags has MIC */
1175 if (!ieee80211_has_morefrags(hdr->frame_control) && 1340 if (!ieee80211_has_morefrags(hdr->frame_control) &&
1176 info.encrypt_type == HTT_RX_MPDU_ENCRYPT_TKIP_WPA) 1341 enctype == HTT_RX_MPDU_ENCRYPT_TKIP_WPA)
1177 trim += 8; 1342 trim += 8;
1178 1343
1179 if (trim > info.skb->len) { 1344 if (trim > msdu_head->len) {
1180 ath10k_warn("htt rx fragment: trailer longer than the frame itself? drop\n"); 1345 ath10k_warn("htt rx fragment: trailer longer than the frame itself? drop\n");
1181 dev_kfree_skb_any(info.skb); 1346 dev_kfree_skb_any(msdu_head);
1182 goto end; 1347 goto end;
1183 } 1348 }
1184 1349
1185 skb_trim(info.skb, info.skb->len - trim); 1350 skb_trim(msdu_head, msdu_head->len - trim);
1186 1351
1187 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt rx frag mpdu: ", 1352 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt rx frag mpdu: ",
1188 info.skb->data, info.skb->len); 1353 msdu_head->data, msdu_head->len);
1189 ath10k_process_rx(htt->ar, &info); 1354 ath10k_process_rx(htt->ar, rx_status, msdu_head);
1190 1355
1191end: 1356end:
1192 if (fw_desc_len > 0) { 1357 if (fw_desc_len > 0) {
diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h
index 35fc44e281f5..007e855f4ba9 100644
--- a/drivers/net/wireless/ath/ath10k/hw.h
+++ b/drivers/net/wireless/ath/ath10k/hw.h
@@ -28,6 +28,7 @@
28#define QCA988X_HW_2_0_CHIP_ID_REV 0x2 28#define QCA988X_HW_2_0_CHIP_ID_REV 0x2
29#define QCA988X_HW_2_0_FW_DIR "ath10k/QCA988X/hw2.0" 29#define QCA988X_HW_2_0_FW_DIR "ath10k/QCA988X/hw2.0"
30#define QCA988X_HW_2_0_FW_FILE "firmware.bin" 30#define QCA988X_HW_2_0_FW_FILE "firmware.bin"
31#define QCA988X_HW_2_0_FW_2_FILE "firmware-2.bin"
31#define QCA988X_HW_2_0_OTP_FILE "otp.bin" 32#define QCA988X_HW_2_0_OTP_FILE "otp.bin"
32#define QCA988X_HW_2_0_BOARD_DATA_FILE "board.bin" 33#define QCA988X_HW_2_0_BOARD_DATA_FILE "board.bin"
33#define QCA988X_HW_2_0_PATCH_LOAD_ADDR 0x1234 34#define QCA988X_HW_2_0_PATCH_LOAD_ADDR 0x1234
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 511a2f81e7af..8385a7ad02ac 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -165,7 +165,7 @@ static int ath10k_clear_peer_keys(struct ath10k_vif *arvif,
165 first_errno = ret; 165 first_errno = ret;
166 166
167 if (ret) 167 if (ret)
168 ath10k_warn("could not remove peer wep key %d (%d)\n", 168 ath10k_warn("failed to remove peer wep key %d: %d\n",
169 i, ret); 169 i, ret);
170 170
171 peer->keys[i] = NULL; 171 peer->keys[i] = NULL;
@@ -213,7 +213,8 @@ static int ath10k_clear_vdev_key(struct ath10k_vif *arvif,
213 first_errno = ret; 213 first_errno = ret;
214 214
215 if (ret) 215 if (ret)
216 ath10k_warn("could not remove key for %pM\n", addr); 216 ath10k_warn("failed to remove key for %pM: %d\n",
217 addr, ret);
217 } 218 }
218 219
219 return first_errno; 220 return first_errno;
@@ -323,14 +324,14 @@ static int ath10k_peer_create(struct ath10k *ar, u32 vdev_id, const u8 *addr)
323 324
324 ret = ath10k_wmi_peer_create(ar, vdev_id, addr); 325 ret = ath10k_wmi_peer_create(ar, vdev_id, addr);
325 if (ret) { 326 if (ret) {
326 ath10k_warn("Failed to create wmi peer %pM on vdev %i: %i\n", 327 ath10k_warn("failed to create wmi peer %pM on vdev %i: %i\n",
327 addr, vdev_id, ret); 328 addr, vdev_id, ret);
328 return ret; 329 return ret;
329 } 330 }
330 331
331 ret = ath10k_wait_for_peer_created(ar, vdev_id, addr); 332 ret = ath10k_wait_for_peer_created(ar, vdev_id, addr);
332 if (ret) { 333 if (ret) {
333 ath10k_warn("Failed to wait for created wmi peer %pM on vdev %i: %i\n", 334 ath10k_warn("failed to wait for created wmi peer %pM on vdev %i: %i\n",
334 addr, vdev_id, ret); 335 addr, vdev_id, ret);
335 return ret; 336 return ret;
336 } 337 }
@@ -351,7 +352,7 @@ static int ath10k_mac_set_kickout(struct ath10k_vif *arvif)
351 ret = ath10k_wmi_pdev_set_param(ar, param, 352 ret = ath10k_wmi_pdev_set_param(ar, param,
352 ATH10K_KICKOUT_THRESHOLD); 353 ATH10K_KICKOUT_THRESHOLD);
353 if (ret) { 354 if (ret) {
354 ath10k_warn("Failed to set kickout threshold on vdev %i: %d\n", 355 ath10k_warn("failed to set kickout threshold on vdev %i: %d\n",
355 arvif->vdev_id, ret); 356 arvif->vdev_id, ret);
356 return ret; 357 return ret;
357 } 358 }
@@ -360,7 +361,7 @@ static int ath10k_mac_set_kickout(struct ath10k_vif *arvif)
360 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, param, 361 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, param,
361 ATH10K_KEEPALIVE_MIN_IDLE); 362 ATH10K_KEEPALIVE_MIN_IDLE);
362 if (ret) { 363 if (ret) {
363 ath10k_warn("Failed to set keepalive minimum idle time on vdev %i : %d\n", 364 ath10k_warn("failed to set keepalive minimum idle time on vdev %i: %d\n",
364 arvif->vdev_id, ret); 365 arvif->vdev_id, ret);
365 return ret; 366 return ret;
366 } 367 }
@@ -369,7 +370,7 @@ static int ath10k_mac_set_kickout(struct ath10k_vif *arvif)
369 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, param, 370 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, param,
370 ATH10K_KEEPALIVE_MAX_IDLE); 371 ATH10K_KEEPALIVE_MAX_IDLE);
371 if (ret) { 372 if (ret) {
372 ath10k_warn("Failed to set keepalive maximum idle time on vdev %i: %d\n", 373 ath10k_warn("failed to set keepalive maximum idle time on vdev %i: %d\n",
373 arvif->vdev_id, ret); 374 arvif->vdev_id, ret);
374 return ret; 375 return ret;
375 } 376 }
@@ -378,7 +379,7 @@ static int ath10k_mac_set_kickout(struct ath10k_vif *arvif)
378 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, param, 379 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, param,
379 ATH10K_KEEPALIVE_MAX_UNRESPONSIVE); 380 ATH10K_KEEPALIVE_MAX_UNRESPONSIVE);
380 if (ret) { 381 if (ret) {
381 ath10k_warn("Failed to set keepalive maximum unresponsive time on vdev %i: %d\n", 382 ath10k_warn("failed to set keepalive maximum unresponsive time on vdev %i: %d\n",
382 arvif->vdev_id, ret); 383 arvif->vdev_id, ret);
383 return ret; 384 return ret;
384 } 385 }
@@ -488,92 +489,20 @@ static inline int ath10k_vdev_setup_sync(struct ath10k *ar)
488 return 0; 489 return 0;
489} 490}
490 491
491static int ath10k_vdev_start(struct ath10k_vif *arvif) 492static bool ath10k_monitor_is_enabled(struct ath10k *ar)
492{ 493{
493 struct ath10k *ar = arvif->ar;
494 struct cfg80211_chan_def *chandef = &ar->chandef;
495 struct wmi_vdev_start_request_arg arg = {};
496 int ret = 0;
497
498 lockdep_assert_held(&ar->conf_mutex); 494 lockdep_assert_held(&ar->conf_mutex);
499 495
500 reinit_completion(&ar->vdev_setup_done);
501
502 arg.vdev_id = arvif->vdev_id;
503 arg.dtim_period = arvif->dtim_period;
504 arg.bcn_intval = arvif->beacon_interval;
505
506 arg.channel.freq = chandef->chan->center_freq;
507 arg.channel.band_center_freq1 = chandef->center_freq1;
508 arg.channel.mode = chan_to_phymode(chandef);
509
510 arg.channel.min_power = 0;
511 arg.channel.max_power = chandef->chan->max_power * 2;
512 arg.channel.max_reg_power = chandef->chan->max_reg_power * 2;
513 arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain * 2;
514
515 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
516 arg.ssid = arvif->u.ap.ssid;
517 arg.ssid_len = arvif->u.ap.ssid_len;
518 arg.hidden_ssid = arvif->u.ap.hidden_ssid;
519
520 /* For now allow DFS for AP mode */
521 arg.channel.chan_radar =
522 !!(chandef->chan->flags & IEEE80211_CHAN_RADAR);
523 } else if (arvif->vdev_type == WMI_VDEV_TYPE_IBSS) {
524 arg.ssid = arvif->vif->bss_conf.ssid;
525 arg.ssid_len = arvif->vif->bss_conf.ssid_len;
526 }
527
528 ath10k_dbg(ATH10K_DBG_MAC, 496 ath10k_dbg(ATH10K_DBG_MAC,
529 "mac vdev %d start center_freq %d phymode %s\n", 497 "mac monitor refs: promisc %d monitor %d cac %d\n",
530 arg.vdev_id, arg.channel.freq, 498 ar->promisc, ar->monitor,
531 ath10k_wmi_phymode_str(arg.channel.mode)); 499 test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags));
532
533 ret = ath10k_wmi_vdev_start(ar, &arg);
534 if (ret) {
535 ath10k_warn("WMI vdev %i start failed: ret %d\n",
536 arg.vdev_id, ret);
537 return ret;
538 }
539
540 ret = ath10k_vdev_setup_sync(ar);
541 if (ret) {
542 ath10k_warn("vdev %i setup failed %d\n",
543 arg.vdev_id, ret);
544 return ret;
545 }
546
547 return ret;
548}
549
550static int ath10k_vdev_stop(struct ath10k_vif *arvif)
551{
552 struct ath10k *ar = arvif->ar;
553 int ret;
554 500
555 lockdep_assert_held(&ar->conf_mutex); 501 return ar->promisc || ar->monitor ||
556 502 test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags);
557 reinit_completion(&ar->vdev_setup_done);
558
559 ret = ath10k_wmi_vdev_stop(ar, arvif->vdev_id);
560 if (ret) {
561 ath10k_warn("WMI vdev %i stop failed: ret %d\n",
562 arvif->vdev_id, ret);
563 return ret;
564 }
565
566 ret = ath10k_vdev_setup_sync(ar);
567 if (ret) {
568 ath10k_warn("vdev %i setup sync failed %d\n",
569 arvif->vdev_id, ret);
570 return ret;
571 }
572
573 return ret;
574} 503}
575 504
576static int ath10k_monitor_start(struct ath10k *ar, int vdev_id) 505static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
577{ 506{
578 struct cfg80211_chan_def *chandef = &ar->chandef; 507 struct cfg80211_chan_def *chandef = &ar->chandef;
579 struct ieee80211_channel *channel = chandef->chan; 508 struct ieee80211_channel *channel = chandef->chan;
@@ -582,11 +511,6 @@ static int ath10k_monitor_start(struct ath10k *ar, int vdev_id)
582 511
583 lockdep_assert_held(&ar->conf_mutex); 512 lockdep_assert_held(&ar->conf_mutex);
584 513
585 if (!ar->monitor_present) {
586 ath10k_warn("mac montor stop -- monitor is not present\n");
587 return -EINVAL;
588 }
589
590 arg.vdev_id = vdev_id; 514 arg.vdev_id = vdev_id;
591 arg.channel.freq = channel->center_freq; 515 arg.channel.freq = channel->center_freq;
592 arg.channel.band_center_freq1 = chandef->center_freq1; 516 arg.channel.band_center_freq1 = chandef->center_freq1;
@@ -604,88 +528,75 @@ static int ath10k_monitor_start(struct ath10k *ar, int vdev_id)
604 528
605 ret = ath10k_wmi_vdev_start(ar, &arg); 529 ret = ath10k_wmi_vdev_start(ar, &arg);
606 if (ret) { 530 if (ret) {
607 ath10k_warn("Monitor vdev %i start failed: ret %d\n", 531 ath10k_warn("failed to request monitor vdev %i start: %d\n",
608 vdev_id, ret); 532 vdev_id, ret);
609 return ret; 533 return ret;
610 } 534 }
611 535
612 ret = ath10k_vdev_setup_sync(ar); 536 ret = ath10k_vdev_setup_sync(ar);
613 if (ret) { 537 if (ret) {
614 ath10k_warn("Monitor vdev %i setup failed %d\n", 538 ath10k_warn("failed to synchronize setup for monitor vdev %i: %d\n",
615 vdev_id, ret); 539 vdev_id, ret);
616 return ret; 540 return ret;
617 } 541 }
618 542
619 ret = ath10k_wmi_vdev_up(ar, vdev_id, 0, ar->mac_addr); 543 ret = ath10k_wmi_vdev_up(ar, vdev_id, 0, ar->mac_addr);
620 if (ret) { 544 if (ret) {
621 ath10k_warn("Monitor vdev %i up failed: %d\n", 545 ath10k_warn("failed to put up monitor vdev %i: %d\n",
622 vdev_id, ret); 546 vdev_id, ret);
623 goto vdev_stop; 547 goto vdev_stop;
624 } 548 }
625 549
626 ar->monitor_vdev_id = vdev_id; 550 ar->monitor_vdev_id = vdev_id;
627 ar->monitor_enabled = true;
628 551
552 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor vdev %i started\n",
553 ar->monitor_vdev_id);
629 return 0; 554 return 0;
630 555
631vdev_stop: 556vdev_stop:
632 ret = ath10k_wmi_vdev_stop(ar, ar->monitor_vdev_id); 557 ret = ath10k_wmi_vdev_stop(ar, ar->monitor_vdev_id);
633 if (ret) 558 if (ret)
634 ath10k_warn("Monitor vdev %i stop failed: %d\n", 559 ath10k_warn("failed to stop monitor vdev %i after start failure: %d\n",
635 ar->monitor_vdev_id, ret); 560 ar->monitor_vdev_id, ret);
636 561
637 return ret; 562 return ret;
638} 563}
639 564
640static int ath10k_monitor_stop(struct ath10k *ar) 565static int ath10k_monitor_vdev_stop(struct ath10k *ar)
641{ 566{
642 int ret = 0; 567 int ret = 0;
643 568
644 lockdep_assert_held(&ar->conf_mutex); 569 lockdep_assert_held(&ar->conf_mutex);
645 570
646 if (!ar->monitor_present) {
647 ath10k_warn("mac montor stop -- monitor is not present\n");
648 return -EINVAL;
649 }
650
651 if (!ar->monitor_enabled) {
652 ath10k_warn("mac montor stop -- monitor is not enabled\n");
653 return -EINVAL;
654 }
655
656 ret = ath10k_wmi_vdev_down(ar, ar->monitor_vdev_id); 571 ret = ath10k_wmi_vdev_down(ar, ar->monitor_vdev_id);
657 if (ret) 572 if (ret)
658 ath10k_warn("Monitor vdev %i down failed: %d\n", 573 ath10k_warn("failed to put down monitor vdev %i: %d\n",
659 ar->monitor_vdev_id, ret); 574 ar->monitor_vdev_id, ret);
660 575
661 ret = ath10k_wmi_vdev_stop(ar, ar->monitor_vdev_id); 576 ret = ath10k_wmi_vdev_stop(ar, ar->monitor_vdev_id);
662 if (ret) 577 if (ret)
663 ath10k_warn("Monitor vdev %i stop failed: %d\n", 578 ath10k_warn("failed to to request monitor vdev %i stop: %d\n",
664 ar->monitor_vdev_id, ret); 579 ar->monitor_vdev_id, ret);
665 580
666 ret = ath10k_vdev_setup_sync(ar); 581 ret = ath10k_vdev_setup_sync(ar);
667 if (ret) 582 if (ret)
668 ath10k_warn("Monitor_down sync failed, vdev %i: %d\n", 583 ath10k_warn("failed to synchronise monitor vdev %i: %d\n",
669 ar->monitor_vdev_id, ret); 584 ar->monitor_vdev_id, ret);
670 585
671 ar->monitor_enabled = false; 586 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor vdev %i stopped\n",
587 ar->monitor_vdev_id);
672 return ret; 588 return ret;
673} 589}
674 590
675static int ath10k_monitor_create(struct ath10k *ar) 591static int ath10k_monitor_vdev_create(struct ath10k *ar)
676{ 592{
677 int bit, ret = 0; 593 int bit, ret = 0;
678 594
679 lockdep_assert_held(&ar->conf_mutex); 595 lockdep_assert_held(&ar->conf_mutex);
680 596
681 if (ar->monitor_present) {
682 ath10k_warn("Monitor mode already enabled\n");
683 return 0;
684 }
685
686 bit = ffs(ar->free_vdev_map); 597 bit = ffs(ar->free_vdev_map);
687 if (bit == 0) { 598 if (bit == 0) {
688 ath10k_warn("No free VDEV slots\n"); 599 ath10k_warn("failed to find free vdev id for monitor vdev\n");
689 return -ENOMEM; 600 return -ENOMEM;
690 } 601 }
691 602
@@ -696,7 +607,7 @@ static int ath10k_monitor_create(struct ath10k *ar)
696 WMI_VDEV_TYPE_MONITOR, 607 WMI_VDEV_TYPE_MONITOR,
697 0, ar->mac_addr); 608 0, ar->mac_addr);
698 if (ret) { 609 if (ret) {
699 ath10k_warn("WMI vdev %i monitor create failed: ret %d\n", 610 ath10k_warn("failed to request monitor vdev %i creation: %d\n",
700 ar->monitor_vdev_id, ret); 611 ar->monitor_vdev_id, ret);
701 goto vdev_fail; 612 goto vdev_fail;
702 } 613 }
@@ -704,7 +615,6 @@ static int ath10k_monitor_create(struct ath10k *ar)
704 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor vdev %d created\n", 615 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor vdev %d created\n",
705 ar->monitor_vdev_id); 616 ar->monitor_vdev_id);
706 617
707 ar->monitor_present = true;
708 return 0; 618 return 0;
709 619
710vdev_fail: 620vdev_fail:
@@ -715,48 +625,123 @@ vdev_fail:
715 return ret; 625 return ret;
716} 626}
717 627
718static int ath10k_monitor_destroy(struct ath10k *ar) 628static int ath10k_monitor_vdev_delete(struct ath10k *ar)
719{ 629{
720 int ret = 0; 630 int ret = 0;
721 631
722 lockdep_assert_held(&ar->conf_mutex); 632 lockdep_assert_held(&ar->conf_mutex);
723 633
724 if (!ar->monitor_present)
725 return 0;
726
727 ret = ath10k_wmi_vdev_delete(ar, ar->monitor_vdev_id); 634 ret = ath10k_wmi_vdev_delete(ar, ar->monitor_vdev_id);
728 if (ret) { 635 if (ret) {
729 ath10k_warn("WMI vdev %i monitor delete failed: %d\n", 636 ath10k_warn("failed to request wmi monitor vdev %i removal: %d\n",
730 ar->monitor_vdev_id, ret); 637 ar->monitor_vdev_id, ret);
731 return ret; 638 return ret;
732 } 639 }
733 640
734 ar->free_vdev_map |= 1 << (ar->monitor_vdev_id); 641 ar->free_vdev_map |= 1 << (ar->monitor_vdev_id);
735 ar->monitor_present = false;
736 642
737 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor vdev %d deleted\n", 643 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor vdev %d deleted\n",
738 ar->monitor_vdev_id); 644 ar->monitor_vdev_id);
739 return ret; 645 return ret;
740} 646}
741 647
742static int ath10k_start_cac(struct ath10k *ar) 648static int ath10k_monitor_start(struct ath10k *ar)
743{ 649{
744 int ret; 650 int ret;
745 651
746 lockdep_assert_held(&ar->conf_mutex); 652 lockdep_assert_held(&ar->conf_mutex);
747 653
748 set_bit(ATH10K_CAC_RUNNING, &ar->dev_flags); 654 if (!ath10k_monitor_is_enabled(ar)) {
655 ath10k_warn("trying to start monitor with no references\n");
656 return 0;
657 }
658
659 if (ar->monitor_started) {
660 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor already started\n");
661 return 0;
662 }
749 663
750 ret = ath10k_monitor_create(ar); 664 ret = ath10k_monitor_vdev_create(ar);
751 if (ret) { 665 if (ret) {
752 clear_bit(ATH10K_CAC_RUNNING, &ar->dev_flags); 666 ath10k_warn("failed to create monitor vdev: %d\n", ret);
753 return ret; 667 return ret;
754 } 668 }
755 669
756 ret = ath10k_monitor_start(ar, ar->monitor_vdev_id); 670 ret = ath10k_monitor_vdev_start(ar, ar->monitor_vdev_id);
757 if (ret) { 671 if (ret) {
672 ath10k_warn("failed to start monitor vdev: %d\n", ret);
673 ath10k_monitor_vdev_delete(ar);
674 return ret;
675 }
676
677 ar->monitor_started = true;
678 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor started\n");
679
680 return 0;
681}
682
683static void ath10k_monitor_stop(struct ath10k *ar)
684{
685 int ret;
686
687 lockdep_assert_held(&ar->conf_mutex);
688
689 if (ath10k_monitor_is_enabled(ar)) {
690 ath10k_dbg(ATH10K_DBG_MAC,
691 "mac monitor will be stopped later\n");
692 return;
693 }
694
695 if (!ar->monitor_started) {
696 ath10k_dbg(ATH10K_DBG_MAC,
697 "mac monitor probably failed to start earlier\n");
698 return;
699 }
700
701 ret = ath10k_monitor_vdev_stop(ar);
702 if (ret)
703 ath10k_warn("failed to stop monitor vdev: %d\n", ret);
704
705 ret = ath10k_monitor_vdev_delete(ar);
706 if (ret)
707 ath10k_warn("failed to delete monitor vdev: %d\n", ret);
708
709 ar->monitor_started = false;
710 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor stopped\n");
711}
712
713static int ath10k_recalc_rtscts_prot(struct ath10k_vif *arvif)
714{
715 struct ath10k *ar = arvif->ar;
716 u32 vdev_param, rts_cts = 0;
717
718 lockdep_assert_held(&ar->conf_mutex);
719
720 vdev_param = ar->wmi.vdev_param->enable_rtscts;
721
722 if (arvif->use_cts_prot || arvif->num_legacy_stations > 0)
723 rts_cts |= SM(WMI_RTSCTS_ENABLED, WMI_RTSCTS_SET);
724
725 if (arvif->num_legacy_stations > 0)
726 rts_cts |= SM(WMI_RTSCTS_ACROSS_SW_RETRIES,
727 WMI_RTSCTS_PROFILE);
728
729 return ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
730 rts_cts);
731}
732
733static int ath10k_start_cac(struct ath10k *ar)
734{
735 int ret;
736
737 lockdep_assert_held(&ar->conf_mutex);
738
739 set_bit(ATH10K_CAC_RUNNING, &ar->dev_flags);
740
741 ret = ath10k_monitor_start(ar);
742 if (ret) {
743 ath10k_warn("failed to start monitor (cac): %d\n", ret);
758 clear_bit(ATH10K_CAC_RUNNING, &ar->dev_flags); 744 clear_bit(ATH10K_CAC_RUNNING, &ar->dev_flags);
759 ath10k_monitor_destroy(ar);
760 return ret; 745 return ret;
761 } 746 }
762 747
@@ -774,58 +759,26 @@ static int ath10k_stop_cac(struct ath10k *ar)
774 if (!test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) 759 if (!test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags))
775 return 0; 760 return 0;
776 761
777 ath10k_monitor_stop(ar);
778 ath10k_monitor_destroy(ar);
779 clear_bit(ATH10K_CAC_RUNNING, &ar->dev_flags); 762 clear_bit(ATH10K_CAC_RUNNING, &ar->dev_flags);
763 ath10k_monitor_stop(ar);
780 764
781 ath10k_dbg(ATH10K_DBG_MAC, "mac cac finished\n"); 765 ath10k_dbg(ATH10K_DBG_MAC, "mac cac finished\n");
782 766
783 return 0; 767 return 0;
784} 768}
785 769
786static const char *ath10k_dfs_state(enum nl80211_dfs_state dfs_state) 770static void ath10k_recalc_radar_detection(struct ath10k *ar)
787{
788 switch (dfs_state) {
789 case NL80211_DFS_USABLE:
790 return "USABLE";
791 case NL80211_DFS_UNAVAILABLE:
792 return "UNAVAILABLE";
793 case NL80211_DFS_AVAILABLE:
794 return "AVAILABLE";
795 default:
796 WARN_ON(1);
797 return "bug";
798 }
799}
800
801static void ath10k_config_radar_detection(struct ath10k *ar)
802{ 771{
803 struct ieee80211_channel *chan = ar->hw->conf.chandef.chan;
804 bool radar = ar->hw->conf.radar_enabled;
805 bool chan_radar = !!(chan->flags & IEEE80211_CHAN_RADAR);
806 enum nl80211_dfs_state dfs_state = chan->dfs_state;
807 int ret; 772 int ret;
808 773
809 lockdep_assert_held(&ar->conf_mutex); 774 lockdep_assert_held(&ar->conf_mutex);
810 775
811 ath10k_dbg(ATH10K_DBG_MAC,
812 "mac radar config update: chan %dMHz radar %d chan radar %d chan state %s\n",
813 chan->center_freq, radar, chan_radar,
814 ath10k_dfs_state(dfs_state));
815
816 /*
817 * It's safe to call it even if CAC is not started.
818 * This call here guarantees changing channel, etc. will stop CAC.
819 */
820 ath10k_stop_cac(ar); 776 ath10k_stop_cac(ar);
821 777
822 if (!radar) 778 if (!ar->radar_enabled)
823 return;
824
825 if (!chan_radar)
826 return; 779 return;
827 780
828 if (dfs_state != NL80211_DFS_USABLE) 781 if (ar->num_started_vdevs > 0)
829 return; 782 return;
830 783
831 ret = ath10k_start_cac(ar); 784 ret = ath10k_start_cac(ar);
@@ -835,11 +788,106 @@ static void ath10k_config_radar_detection(struct ath10k *ar)
835 * radiation is not allowed, make this channel DFS_UNAVAILABLE 788 * radiation is not allowed, make this channel DFS_UNAVAILABLE
836 * by indicating that radar was detected. 789 * by indicating that radar was detected.
837 */ 790 */
838 ath10k_warn("failed to start CAC (%d)\n", ret); 791 ath10k_warn("failed to start CAC: %d\n", ret);
839 ieee80211_radar_detected(ar->hw); 792 ieee80211_radar_detected(ar->hw);
840 } 793 }
841} 794}
842 795
796static int ath10k_vdev_start(struct ath10k_vif *arvif)
797{
798 struct ath10k *ar = arvif->ar;
799 struct cfg80211_chan_def *chandef = &ar->chandef;
800 struct wmi_vdev_start_request_arg arg = {};
801 int ret = 0;
802
803 lockdep_assert_held(&ar->conf_mutex);
804
805 reinit_completion(&ar->vdev_setup_done);
806
807 arg.vdev_id = arvif->vdev_id;
808 arg.dtim_period = arvif->dtim_period;
809 arg.bcn_intval = arvif->beacon_interval;
810
811 arg.channel.freq = chandef->chan->center_freq;
812 arg.channel.band_center_freq1 = chandef->center_freq1;
813 arg.channel.mode = chan_to_phymode(chandef);
814
815 arg.channel.min_power = 0;
816 arg.channel.max_power = chandef->chan->max_power * 2;
817 arg.channel.max_reg_power = chandef->chan->max_reg_power * 2;
818 arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain * 2;
819
820 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
821 arg.ssid = arvif->u.ap.ssid;
822 arg.ssid_len = arvif->u.ap.ssid_len;
823 arg.hidden_ssid = arvif->u.ap.hidden_ssid;
824
825 /* For now allow DFS for AP mode */
826 arg.channel.chan_radar =
827 !!(chandef->chan->flags & IEEE80211_CHAN_RADAR);
828 } else if (arvif->vdev_type == WMI_VDEV_TYPE_IBSS) {
829 arg.ssid = arvif->vif->bss_conf.ssid;
830 arg.ssid_len = arvif->vif->bss_conf.ssid_len;
831 }
832
833 ath10k_dbg(ATH10K_DBG_MAC,
834 "mac vdev %d start center_freq %d phymode %s\n",
835 arg.vdev_id, arg.channel.freq,
836 ath10k_wmi_phymode_str(arg.channel.mode));
837
838 ret = ath10k_wmi_vdev_start(ar, &arg);
839 if (ret) {
840 ath10k_warn("failed to start WMI vdev %i: %d\n",
841 arg.vdev_id, ret);
842 return ret;
843 }
844
845 ret = ath10k_vdev_setup_sync(ar);
846 if (ret) {
847 ath10k_warn("failed to synchronise setup for vdev %i: %d\n",
848 arg.vdev_id, ret);
849 return ret;
850 }
851
852 ar->num_started_vdevs++;
853 ath10k_recalc_radar_detection(ar);
854
855 return ret;
856}
857
858static int ath10k_vdev_stop(struct ath10k_vif *arvif)
859{
860 struct ath10k *ar = arvif->ar;
861 int ret;
862
863 lockdep_assert_held(&ar->conf_mutex);
864
865 reinit_completion(&ar->vdev_setup_done);
866
867 ret = ath10k_wmi_vdev_stop(ar, arvif->vdev_id);
868 if (ret) {
869 ath10k_warn("failed to stop WMI vdev %i: %d\n",
870 arvif->vdev_id, ret);
871 return ret;
872 }
873
874 ret = ath10k_vdev_setup_sync(ar);
875 if (ret) {
876 ath10k_warn("failed to syncronise setup for vdev %i: %d\n",
877 arvif->vdev_id, ret);
878 return ret;
879 }
880
881 WARN_ON(ar->num_started_vdevs == 0);
882
883 if (ar->num_started_vdevs != 0) {
884 ar->num_started_vdevs--;
885 ath10k_recalc_radar_detection(ar);
886 }
887
888 return ret;
889}
890
843static void ath10k_control_beaconing(struct ath10k_vif *arvif, 891static void ath10k_control_beaconing(struct ath10k_vif *arvif,
844 struct ieee80211_bss_conf *info) 892 struct ieee80211_bss_conf *info)
845{ 893{
@@ -880,7 +928,7 @@ static void ath10k_control_beaconing(struct ath10k_vif *arvif,
880 ret = ath10k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid, 928 ret = ath10k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid,
881 arvif->bssid); 929 arvif->bssid);
882 if (ret) { 930 if (ret) {
883 ath10k_warn("Failed to bring up vdev %d: %i\n", 931 ath10k_warn("failed to bring up vdev %d: %i\n",
884 arvif->vdev_id, ret); 932 arvif->vdev_id, ret);
885 ath10k_vdev_stop(arvif); 933 ath10k_vdev_stop(arvif);
886 return; 934 return;
@@ -904,7 +952,7 @@ static void ath10k_control_ibss(struct ath10k_vif *arvif,
904 if (!info->ibss_joined) { 952 if (!info->ibss_joined) {
905 ret = ath10k_peer_delete(arvif->ar, arvif->vdev_id, self_peer); 953 ret = ath10k_peer_delete(arvif->ar, arvif->vdev_id, self_peer);
906 if (ret) 954 if (ret)
907 ath10k_warn("Failed to delete IBSS self peer:%pM for VDEV:%d ret:%d\n", 955 ath10k_warn("failed to delete IBSS self peer %pM for vdev %d: %d\n",
908 self_peer, arvif->vdev_id, ret); 956 self_peer, arvif->vdev_id, ret);
909 957
910 if (is_zero_ether_addr(arvif->bssid)) 958 if (is_zero_ether_addr(arvif->bssid))
@@ -913,7 +961,7 @@ static void ath10k_control_ibss(struct ath10k_vif *arvif,
913 ret = ath10k_peer_delete(arvif->ar, arvif->vdev_id, 961 ret = ath10k_peer_delete(arvif->ar, arvif->vdev_id,
914 arvif->bssid); 962 arvif->bssid);
915 if (ret) { 963 if (ret) {
916 ath10k_warn("Failed to delete IBSS BSSID peer:%pM for VDEV:%d ret:%d\n", 964 ath10k_warn("failed to delete IBSS BSSID peer %pM for vdev %d: %d\n",
917 arvif->bssid, arvif->vdev_id, ret); 965 arvif->bssid, arvif->vdev_id, ret);
918 return; 966 return;
919 } 967 }
@@ -925,7 +973,7 @@ static void ath10k_control_ibss(struct ath10k_vif *arvif,
925 973
926 ret = ath10k_peer_create(arvif->ar, arvif->vdev_id, self_peer); 974 ret = ath10k_peer_create(arvif->ar, arvif->vdev_id, self_peer);
927 if (ret) { 975 if (ret) {
928 ath10k_warn("Failed to create IBSS self peer:%pM for VDEV:%d ret:%d\n", 976 ath10k_warn("failed to create IBSS self peer %pM for vdev %d: %d\n",
929 self_peer, arvif->vdev_id, ret); 977 self_peer, arvif->vdev_id, ret);
930 return; 978 return;
931 } 979 }
@@ -934,7 +982,7 @@ static void ath10k_control_ibss(struct ath10k_vif *arvif,
934 ret = ath10k_wmi_vdev_set_param(arvif->ar, arvif->vdev_id, vdev_param, 982 ret = ath10k_wmi_vdev_set_param(arvif->ar, arvif->vdev_id, vdev_param,
935 ATH10K_DEFAULT_ATIM); 983 ATH10K_DEFAULT_ATIM);
936 if (ret) 984 if (ret)
937 ath10k_warn("Failed to set IBSS ATIM for VDEV:%d ret:%d\n", 985 ath10k_warn("failed to set IBSS ATIM for vdev %d: %d\n",
938 arvif->vdev_id, ret); 986 arvif->vdev_id, ret);
939} 987}
940 988
@@ -961,7 +1009,7 @@ static int ath10k_mac_vif_setup_ps(struct ath10k_vif *arvif)
961 ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id, param, 1009 ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id, param,
962 conf->dynamic_ps_timeout); 1010 conf->dynamic_ps_timeout);
963 if (ret) { 1011 if (ret) {
964 ath10k_warn("Failed to set inactivity time for vdev %d: %i\n", 1012 ath10k_warn("failed to set inactivity time for vdev %d: %i\n",
965 arvif->vdev_id, ret); 1013 arvif->vdev_id, ret);
966 return ret; 1014 return ret;
967 } 1015 }
@@ -974,8 +1022,8 @@ static int ath10k_mac_vif_setup_ps(struct ath10k_vif *arvif)
974 1022
975 ret = ath10k_wmi_set_psmode(ar, arvif->vdev_id, psmode); 1023 ret = ath10k_wmi_set_psmode(ar, arvif->vdev_id, psmode);
976 if (ret) { 1024 if (ret) {
977 ath10k_warn("Failed to set PS Mode: %d for VDEV: %d\n", 1025 ath10k_warn("failed to set PS Mode %d for vdev %d: %d\n",
978 psmode, arvif->vdev_id); 1026 psmode, arvif->vdev_id, ret);
979 return ret; 1027 return ret;
980 } 1028 }
981 1029
@@ -1429,7 +1477,7 @@ static void ath10k_bss_assoc(struct ieee80211_hw *hw,
1429 1477
1430 ap_sta = ieee80211_find_sta(vif, bss_conf->bssid); 1478 ap_sta = ieee80211_find_sta(vif, bss_conf->bssid);
1431 if (!ap_sta) { 1479 if (!ap_sta) {
1432 ath10k_warn("Failed to find station entry for %pM, vdev %i\n", 1480 ath10k_warn("failed to find station entry for bss %pM vdev %i\n",
1433 bss_conf->bssid, arvif->vdev_id); 1481 bss_conf->bssid, arvif->vdev_id);
1434 rcu_read_unlock(); 1482 rcu_read_unlock();
1435 return; 1483 return;
@@ -1442,7 +1490,7 @@ static void ath10k_bss_assoc(struct ieee80211_hw *hw,
1442 ret = ath10k_peer_assoc_prepare(ar, arvif, ap_sta, 1490 ret = ath10k_peer_assoc_prepare(ar, arvif, ap_sta,
1443 bss_conf, &peer_arg); 1491 bss_conf, &peer_arg);
1444 if (ret) { 1492 if (ret) {
1445 ath10k_warn("Peer assoc prepare failed for %pM vdev %i\n: %d", 1493 ath10k_warn("failed to prepare peer assoc for %pM vdev %i: %d\n",
1446 bss_conf->bssid, arvif->vdev_id, ret); 1494 bss_conf->bssid, arvif->vdev_id, ret);
1447 rcu_read_unlock(); 1495 rcu_read_unlock();
1448 return; 1496 return;
@@ -1452,7 +1500,7 @@ static void ath10k_bss_assoc(struct ieee80211_hw *hw,
1452 1500
1453 ret = ath10k_wmi_peer_assoc(ar, &peer_arg); 1501 ret = ath10k_wmi_peer_assoc(ar, &peer_arg);
1454 if (ret) { 1502 if (ret) {
1455 ath10k_warn("Peer assoc failed for %pM vdev %i\n: %d", 1503 ath10k_warn("failed to run peer assoc for %pM vdev %i: %d\n",
1456 bss_conf->bssid, arvif->vdev_id, ret); 1504 bss_conf->bssid, arvif->vdev_id, ret);
1457 return; 1505 return;
1458 } 1506 }
@@ -1473,7 +1521,7 @@ static void ath10k_bss_assoc(struct ieee80211_hw *hw,
1473 1521
1474 ret = ath10k_wmi_vdev_up(ar, arvif->vdev_id, arvif->aid, arvif->bssid); 1522 ret = ath10k_wmi_vdev_up(ar, arvif->vdev_id, arvif->aid, arvif->bssid);
1475 if (ret) { 1523 if (ret) {
1476 ath10k_warn("VDEV: %d up failed: ret %d\n", 1524 ath10k_warn("failed to set vdev %d up: %d\n",
1477 arvif->vdev_id, ret); 1525 arvif->vdev_id, ret);
1478 return; 1526 return;
1479 } 1527 }
@@ -1524,7 +1572,7 @@ static void ath10k_bss_disassoc(struct ieee80211_hw *hw,
1524} 1572}
1525 1573
1526static int ath10k_station_assoc(struct ath10k *ar, struct ath10k_vif *arvif, 1574static int ath10k_station_assoc(struct ath10k *ar, struct ath10k_vif *arvif,
1527 struct ieee80211_sta *sta) 1575 struct ieee80211_sta *sta, bool reassoc)
1528{ 1576{
1529 struct wmi_peer_assoc_complete_arg peer_arg; 1577 struct wmi_peer_assoc_complete_arg peer_arg;
1530 int ret = 0; 1578 int ret = 0;
@@ -1533,34 +1581,46 @@ static int ath10k_station_assoc(struct ath10k *ar, struct ath10k_vif *arvif,
1533 1581
1534 ret = ath10k_peer_assoc_prepare(ar, arvif, sta, NULL, &peer_arg); 1582 ret = ath10k_peer_assoc_prepare(ar, arvif, sta, NULL, &peer_arg);
1535 if (ret) { 1583 if (ret) {
1536 ath10k_warn("WMI peer assoc prepare failed for %pM vdev %i: %i\n", 1584 ath10k_warn("failed to prepare WMI peer assoc for %pM vdev %i: %i\n",
1537 sta->addr, arvif->vdev_id, ret); 1585 sta->addr, arvif->vdev_id, ret);
1538 return ret; 1586 return ret;
1539 } 1587 }
1540 1588
1589 peer_arg.peer_reassoc = reassoc;
1541 ret = ath10k_wmi_peer_assoc(ar, &peer_arg); 1590 ret = ath10k_wmi_peer_assoc(ar, &peer_arg);
1542 if (ret) { 1591 if (ret) {
1543 ath10k_warn("Peer assoc failed for STA %pM vdev %i: %d\n", 1592 ath10k_warn("failed to run peer assoc for STA %pM vdev %i: %d\n",
1544 sta->addr, arvif->vdev_id, ret); 1593 sta->addr, arvif->vdev_id, ret);
1545 return ret; 1594 return ret;
1546 } 1595 }
1547 1596
1548 ret = ath10k_setup_peer_smps(ar, arvif, sta->addr, &sta->ht_cap); 1597 ret = ath10k_setup_peer_smps(ar, arvif, sta->addr, &sta->ht_cap);
1549 if (ret) { 1598 if (ret) {
1550 ath10k_warn("failed to setup peer SMPS for vdev: %d\n", ret); 1599 ath10k_warn("failed to setup peer SMPS for vdev %d: %d\n",
1600 arvif->vdev_id, ret);
1551 return ret; 1601 return ret;
1552 } 1602 }
1553 1603
1604 if (!sta->wme) {
1605 arvif->num_legacy_stations++;
1606 ret = ath10k_recalc_rtscts_prot(arvif);
1607 if (ret) {
1608 ath10k_warn("failed to recalculate rts/cts prot for vdev %d: %d\n",
1609 arvif->vdev_id, ret);
1610 return ret;
1611 }
1612 }
1613
1554 ret = ath10k_install_peer_wep_keys(arvif, sta->addr); 1614 ret = ath10k_install_peer_wep_keys(arvif, sta->addr);
1555 if (ret) { 1615 if (ret) {
1556 ath10k_warn("could not install peer wep keys for vdev %i: %d\n", 1616 ath10k_warn("failed to install peer wep keys for vdev %i: %d\n",
1557 arvif->vdev_id, ret); 1617 arvif->vdev_id, ret);
1558 return ret; 1618 return ret;
1559 } 1619 }
1560 1620
1561 ret = ath10k_peer_assoc_qos_ap(ar, arvif, sta); 1621 ret = ath10k_peer_assoc_qos_ap(ar, arvif, sta);
1562 if (ret) { 1622 if (ret) {
1563 ath10k_warn("could not set qos params for STA %pM for vdev %i: %d\n", 1623 ath10k_warn("failed to set qos params for STA %pM for vdev %i: %d\n",
1564 sta->addr, arvif->vdev_id, ret); 1624 sta->addr, arvif->vdev_id, ret);
1565 return ret; 1625 return ret;
1566 } 1626 }
@@ -1575,9 +1635,19 @@ static int ath10k_station_disassoc(struct ath10k *ar, struct ath10k_vif *arvif,
1575 1635
1576 lockdep_assert_held(&ar->conf_mutex); 1636 lockdep_assert_held(&ar->conf_mutex);
1577 1637
1638 if (!sta->wme) {
1639 arvif->num_legacy_stations--;
1640 ret = ath10k_recalc_rtscts_prot(arvif);
1641 if (ret) {
1642 ath10k_warn("failed to recalculate rts/cts prot for vdev %d: %d\n",
1643 arvif->vdev_id, ret);
1644 return ret;
1645 }
1646 }
1647
1578 ret = ath10k_clear_peer_keys(arvif, sta->addr); 1648 ret = ath10k_clear_peer_keys(arvif, sta->addr);
1579 if (ret) { 1649 if (ret) {
1580 ath10k_warn("could not clear all peer wep keys for vdev %i: %d\n", 1650 ath10k_warn("failed to clear all peer wep keys for vdev %i: %d\n",
1581 arvif->vdev_id, ret); 1651 arvif->vdev_id, ret);
1582 return ret; 1652 return ret;
1583 } 1653 }
@@ -1685,19 +1755,44 @@ static int ath10k_update_channel_list(struct ath10k *ar)
1685 return ret; 1755 return ret;
1686} 1756}
1687 1757
1758static enum wmi_dfs_region
1759ath10k_mac_get_dfs_region(enum nl80211_dfs_regions dfs_region)
1760{
1761 switch (dfs_region) {
1762 case NL80211_DFS_UNSET:
1763 return WMI_UNINIT_DFS_DOMAIN;
1764 case NL80211_DFS_FCC:
1765 return WMI_FCC_DFS_DOMAIN;
1766 case NL80211_DFS_ETSI:
1767 return WMI_ETSI_DFS_DOMAIN;
1768 case NL80211_DFS_JP:
1769 return WMI_MKK4_DFS_DOMAIN;
1770 }
1771 return WMI_UNINIT_DFS_DOMAIN;
1772}
1773
1688static void ath10k_regd_update(struct ath10k *ar) 1774static void ath10k_regd_update(struct ath10k *ar)
1689{ 1775{
1690 struct reg_dmn_pair_mapping *regpair; 1776 struct reg_dmn_pair_mapping *regpair;
1691 int ret; 1777 int ret;
1778 enum wmi_dfs_region wmi_dfs_reg;
1779 enum nl80211_dfs_regions nl_dfs_reg;
1692 1780
1693 lockdep_assert_held(&ar->conf_mutex); 1781 lockdep_assert_held(&ar->conf_mutex);
1694 1782
1695 ret = ath10k_update_channel_list(ar); 1783 ret = ath10k_update_channel_list(ar);
1696 if (ret) 1784 if (ret)
1697 ath10k_warn("could not update channel list (%d)\n", ret); 1785 ath10k_warn("failed to update channel list: %d\n", ret);
1698 1786
1699 regpair = ar->ath_common.regulatory.regpair; 1787 regpair = ar->ath_common.regulatory.regpair;
1700 1788
1789 if (config_enabled(CONFIG_ATH10K_DFS_CERTIFIED) && ar->dfs_detector) {
1790 nl_dfs_reg = ar->dfs_detector->region;
1791 wmi_dfs_reg = ath10k_mac_get_dfs_region(nl_dfs_reg);
1792 } else {
1793 wmi_dfs_reg = WMI_UNINIT_DFS_DOMAIN;
1794 }
1795
1701 /* Target allows setting up per-band regdomain but ath_common provides 1796 /* Target allows setting up per-band regdomain but ath_common provides
1702 * a combined one only */ 1797 * a combined one only */
1703 ret = ath10k_wmi_pdev_set_regdomain(ar, 1798 ret = ath10k_wmi_pdev_set_regdomain(ar,
@@ -1705,9 +1800,10 @@ static void ath10k_regd_update(struct ath10k *ar)
1705 regpair->reg_domain, /* 2ghz */ 1800 regpair->reg_domain, /* 2ghz */
1706 regpair->reg_domain, /* 5ghz */ 1801 regpair->reg_domain, /* 5ghz */
1707 regpair->reg_2ghz_ctl, 1802 regpair->reg_2ghz_ctl,
1708 regpair->reg_5ghz_ctl); 1803 regpair->reg_5ghz_ctl,
1804 wmi_dfs_reg);
1709 if (ret) 1805 if (ret)
1710 ath10k_warn("could not set pdev regdomain (%d)\n", ret); 1806 ath10k_warn("failed to set pdev regdomain: %d\n", ret);
1711} 1807}
1712 1808
1713static void ath10k_reg_notifier(struct wiphy *wiphy, 1809static void ath10k_reg_notifier(struct wiphy *wiphy,
@@ -1725,7 +1821,7 @@ static void ath10k_reg_notifier(struct wiphy *wiphy,
1725 result = ar->dfs_detector->set_dfs_domain(ar->dfs_detector, 1821 result = ar->dfs_detector->set_dfs_domain(ar->dfs_detector,
1726 request->dfs_region); 1822 request->dfs_region);
1727 if (!result) 1823 if (!result)
1728 ath10k_warn("dfs region 0x%X not supported, will trigger radar for every pulse\n", 1824 ath10k_warn("DFS region 0x%X not supported, will trigger radar for every pulse\n",
1729 request->dfs_region); 1825 request->dfs_region);
1730 } 1826 }
1731 1827
@@ -1759,10 +1855,10 @@ static u8 ath10k_tx_h_get_vdev_id(struct ath10k *ar,
1759 if (info->control.vif) 1855 if (info->control.vif)
1760 return ath10k_vif_to_arvif(info->control.vif)->vdev_id; 1856 return ath10k_vif_to_arvif(info->control.vif)->vdev_id;
1761 1857
1762 if (ar->monitor_enabled) 1858 if (ar->monitor_started)
1763 return ar->monitor_vdev_id; 1859 return ar->monitor_vdev_id;
1764 1860
1765 ath10k_warn("could not resolve vdev id\n"); 1861 ath10k_warn("failed to resolve vdev id\n");
1766 return 0; 1862 return 0;
1767} 1863}
1768 1864
@@ -1803,7 +1899,9 @@ static void ath10k_tx_wep_key_work(struct work_struct *work)
1803 arvif->ar->wmi.vdev_param->def_keyid, 1899 arvif->ar->wmi.vdev_param->def_keyid,
1804 keyidx); 1900 keyidx);
1805 if (ret) { 1901 if (ret) {
1806 ath10k_warn("could not update wep keyidx (%d)\n", ret); 1902 ath10k_warn("failed to update wep key index for vdev %d: %d\n",
1903 arvif->vdev_id,
1904 ret);
1807 return; 1905 return;
1808 } 1906 }
1809 1907
@@ -1879,7 +1977,7 @@ static void ath10k_tx_htt(struct ath10k *ar, struct sk_buff *skb)
1879 ar->fw_features)) { 1977 ar->fw_features)) {
1880 if (skb_queue_len(&ar->wmi_mgmt_tx_queue) >= 1978 if (skb_queue_len(&ar->wmi_mgmt_tx_queue) >=
1881 ATH10K_MAX_NUM_MGMT_PENDING) { 1979 ATH10K_MAX_NUM_MGMT_PENDING) {
1882 ath10k_warn("wmi mgmt_tx queue limit reached\n"); 1980 ath10k_warn("reached WMI management tranmist queue limit\n");
1883 ret = -EBUSY; 1981 ret = -EBUSY;
1884 goto exit; 1982 goto exit;
1885 } 1983 }
@@ -1903,7 +2001,7 @@ static void ath10k_tx_htt(struct ath10k *ar, struct sk_buff *skb)
1903 2001
1904exit: 2002exit:
1905 if (ret) { 2003 if (ret) {
1906 ath10k_warn("tx failed (%d). dropping packet.\n", ret); 2004 ath10k_warn("failed to transmit packet, dropping: %d\n", ret);
1907 ieee80211_free_txskb(ar->hw, skb); 2005 ieee80211_free_txskb(ar->hw, skb);
1908 } 2006 }
1909} 2007}
@@ -1964,7 +2062,7 @@ void ath10k_offchan_tx_work(struct work_struct *work)
1964 if (!peer) { 2062 if (!peer) {
1965 ret = ath10k_peer_create(ar, vdev_id, peer_addr); 2063 ret = ath10k_peer_create(ar, vdev_id, peer_addr);
1966 if (ret) 2064 if (ret)
1967 ath10k_warn("peer %pM on vdev %d not created (%d)\n", 2065 ath10k_warn("failed to create peer %pM on vdev %d: %d\n",
1968 peer_addr, vdev_id, ret); 2066 peer_addr, vdev_id, ret);
1969 } 2067 }
1970 2068
@@ -1984,7 +2082,7 @@ void ath10k_offchan_tx_work(struct work_struct *work)
1984 if (!peer) { 2082 if (!peer) {
1985 ret = ath10k_peer_delete(ar, vdev_id, peer_addr); 2083 ret = ath10k_peer_delete(ar, vdev_id, peer_addr);
1986 if (ret) 2084 if (ret)
1987 ath10k_warn("peer %pM on vdev %d not deleted (%d)\n", 2085 ath10k_warn("failed to delete peer %pM on vdev %d: %d\n",
1988 peer_addr, vdev_id, ret); 2086 peer_addr, vdev_id, ret);
1989 } 2087 }
1990 2088
@@ -2018,7 +2116,8 @@ void ath10k_mgmt_over_wmi_tx_work(struct work_struct *work)
2018 2116
2019 ret = ath10k_wmi_mgmt_tx(ar, skb); 2117 ret = ath10k_wmi_mgmt_tx(ar, skb);
2020 if (ret) { 2118 if (ret) {
2021 ath10k_warn("wmi mgmt_tx failed (%d)\n", ret); 2119 ath10k_warn("failed to transmit management frame via WMI: %d\n",
2120 ret);
2022 ieee80211_free_txskb(ar->hw, skb); 2121 ieee80211_free_txskb(ar->hw, skb);
2023 } 2122 }
2024 } 2123 }
@@ -2043,7 +2142,7 @@ void ath10k_reset_scan(unsigned long ptr)
2043 return; 2142 return;
2044 } 2143 }
2045 2144
2046 ath10k_warn("scan timeout. resetting. fw issue?\n"); 2145 ath10k_warn("scan timed out, firmware problem?\n");
2047 2146
2048 if (ar->scan.is_roc) 2147 if (ar->scan.is_roc)
2049 ieee80211_remain_on_channel_expired(ar->hw); 2148 ieee80211_remain_on_channel_expired(ar->hw);
@@ -2079,7 +2178,7 @@ static int ath10k_abort_scan(struct ath10k *ar)
2079 2178
2080 ret = ath10k_wmi_stop_scan(ar, &arg); 2179 ret = ath10k_wmi_stop_scan(ar, &arg);
2081 if (ret) { 2180 if (ret) {
2082 ath10k_warn("could not submit wmi stop scan (%d)\n", ret); 2181 ath10k_warn("failed to stop wmi scan: %d\n", ret);
2083 spin_lock_bh(&ar->data_lock); 2182 spin_lock_bh(&ar->data_lock);
2084 ar->scan.in_progress = false; 2183 ar->scan.in_progress = false;
2085 ath10k_offchan_tx_purge(ar); 2184 ath10k_offchan_tx_purge(ar);
@@ -2099,7 +2198,7 @@ static int ath10k_abort_scan(struct ath10k *ar)
2099 2198
2100 spin_lock_bh(&ar->data_lock); 2199 spin_lock_bh(&ar->data_lock);
2101 if (ar->scan.in_progress) { 2200 if (ar->scan.in_progress) {
2102 ath10k_warn("could not stop scan. its still in progress\n"); 2201 ath10k_warn("failed to stop scan, it's still in progress\n");
2103 ar->scan.in_progress = false; 2202 ar->scan.in_progress = false;
2104 ath10k_offchan_tx_purge(ar); 2203 ath10k_offchan_tx_purge(ar);
2105 ret = -ETIMEDOUT; 2204 ret = -ETIMEDOUT;
@@ -2194,7 +2293,13 @@ void ath10k_halt(struct ath10k *ar)
2194{ 2293{
2195 lockdep_assert_held(&ar->conf_mutex); 2294 lockdep_assert_held(&ar->conf_mutex);
2196 2295
2197 ath10k_stop_cac(ar); 2296 if (ath10k_monitor_is_enabled(ar)) {
2297 clear_bit(ATH10K_CAC_RUNNING, &ar->dev_flags);
2298 ar->promisc = false;
2299 ar->monitor = false;
2300 ath10k_monitor_stop(ar);
2301 }
2302
2198 del_timer_sync(&ar->scan.timeout); 2303 del_timer_sync(&ar->scan.timeout);
2199 ath10k_offchan_tx_purge(ar); 2304 ath10k_offchan_tx_purge(ar);
2200 ath10k_mgmt_over_wmi_tx_purge(ar); 2305 ath10k_mgmt_over_wmi_tx_purge(ar);
@@ -2226,14 +2331,14 @@ static int ath10k_start(struct ieee80211_hw *hw)
2226 2331
2227 ret = ath10k_hif_power_up(ar); 2332 ret = ath10k_hif_power_up(ar);
2228 if (ret) { 2333 if (ret) {
2229 ath10k_err("could not init hif (%d)\n", ret); 2334 ath10k_err("Could not init hif: %d\n", ret);
2230 ar->state = ATH10K_STATE_OFF; 2335 ar->state = ATH10K_STATE_OFF;
2231 goto exit; 2336 goto exit;
2232 } 2337 }
2233 2338
2234 ret = ath10k_core_start(ar); 2339 ret = ath10k_core_start(ar);
2235 if (ret) { 2340 if (ret) {
2236 ath10k_err("could not init core (%d)\n", ret); 2341 ath10k_err("Could not init core: %d\n", ret);
2237 ath10k_hif_power_down(ar); 2342 ath10k_hif_power_down(ar);
2238 ar->state = ATH10K_STATE_OFF; 2343 ar->state = ATH10K_STATE_OFF;
2239 goto exit; 2344 goto exit;
@@ -2246,13 +2351,11 @@ static int ath10k_start(struct ieee80211_hw *hw)
2246 2351
2247 ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->pmf_qos, 1); 2352 ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->pmf_qos, 1);
2248 if (ret) 2353 if (ret)
2249 ath10k_warn("could not enable WMI_PDEV_PARAM_PMF_QOS (%d)\n", 2354 ath10k_warn("failed to enable PMF QOS: %d\n", ret);
2250 ret);
2251 2355
2252 ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->dynamic_bw, 1); 2356 ret = ath10k_wmi_pdev_set_param(ar, ar->wmi.pdev_param->dynamic_bw, 1);
2253 if (ret) 2357 if (ret)
2254 ath10k_warn("could not init WMI_PDEV_PARAM_DYNAMIC_BW (%d)\n", 2358 ath10k_warn("failed to enable dynamic BW: %d\n", ret);
2255 ret);
2256 2359
2257 /* 2360 /*
2258 * By default FW set ARP frames ac to voice (6). In that case ARP 2361 * By default FW set ARP frames ac to voice (6). In that case ARP
@@ -2266,11 +2369,12 @@ static int ath10k_start(struct ieee80211_hw *hw)
2266 ret = ath10k_wmi_pdev_set_param(ar, 2369 ret = ath10k_wmi_pdev_set_param(ar,
2267 ar->wmi.pdev_param->arp_ac_override, 0); 2370 ar->wmi.pdev_param->arp_ac_override, 0);
2268 if (ret) { 2371 if (ret) {
2269 ath10k_warn("could not set arp ac override parameter: %d\n", 2372 ath10k_warn("failed to set arp ac override parameter: %d\n",
2270 ret); 2373 ret);
2271 goto exit; 2374 goto exit;
2272 } 2375 }
2273 2376
2377 ar->num_started_vdevs = 0;
2274 ath10k_regd_update(ar); 2378 ath10k_regd_update(ar);
2275 ret = 0; 2379 ret = 0;
2276 2380
@@ -2309,7 +2413,7 @@ static int ath10k_config_ps(struct ath10k *ar)
2309 list_for_each_entry(arvif, &ar->arvifs, list) { 2413 list_for_each_entry(arvif, &ar->arvifs, list) {
2310 ret = ath10k_mac_vif_setup_ps(arvif); 2414 ret = ath10k_mac_vif_setup_ps(arvif);
2311 if (ret) { 2415 if (ret) {
2312 ath10k_warn("could not setup powersave (%d)\n", ret); 2416 ath10k_warn("failed to setup powersave: %d\n", ret);
2313 break; 2417 break;
2314 } 2418 }
2315 } 2419 }
@@ -2343,7 +2447,6 @@ static const char *chandef_get_width(enum nl80211_chan_width width)
2343static void ath10k_config_chan(struct ath10k *ar) 2447static void ath10k_config_chan(struct ath10k *ar)
2344{ 2448{
2345 struct ath10k_vif *arvif; 2449 struct ath10k_vif *arvif;
2346 bool monitor_was_enabled;
2347 int ret; 2450 int ret;
2348 2451
2349 lockdep_assert_held(&ar->conf_mutex); 2452 lockdep_assert_held(&ar->conf_mutex);
@@ -2357,10 +2460,8 @@ static void ath10k_config_chan(struct ath10k *ar)
2357 2460
2358 /* First stop monitor interface. Some FW versions crash if there's a 2461 /* First stop monitor interface. Some FW versions crash if there's a
2359 * lone monitor interface. */ 2462 * lone monitor interface. */
2360 monitor_was_enabled = ar->monitor_enabled; 2463 if (ar->monitor_started)
2361 2464 ath10k_monitor_vdev_stop(ar);
2362 if (ar->monitor_enabled)
2363 ath10k_monitor_stop(ar);
2364 2465
2365 list_for_each_entry(arvif, &ar->arvifs, list) { 2466 list_for_each_entry(arvif, &ar->arvifs, list) {
2366 if (!arvif->is_started) 2467 if (!arvif->is_started)
@@ -2371,7 +2472,7 @@ static void ath10k_config_chan(struct ath10k *ar)
2371 2472
2372 ret = ath10k_vdev_stop(arvif); 2473 ret = ath10k_vdev_stop(arvif);
2373 if (ret) { 2474 if (ret) {
2374 ath10k_warn("could not stop vdev %d (%d)\n", 2475 ath10k_warn("failed to stop vdev %d: %d\n",
2375 arvif->vdev_id, ret); 2476 arvif->vdev_id, ret);
2376 continue; 2477 continue;
2377 } 2478 }
@@ -2388,7 +2489,7 @@ static void ath10k_config_chan(struct ath10k *ar)
2388 2489
2389 ret = ath10k_vdev_start(arvif); 2490 ret = ath10k_vdev_start(arvif);
2390 if (ret) { 2491 if (ret) {
2391 ath10k_warn("could not start vdev %d (%d)\n", 2492 ath10k_warn("failed to start vdev %d: %d\n",
2392 arvif->vdev_id, ret); 2493 arvif->vdev_id, ret);
2393 continue; 2494 continue;
2394 } 2495 }
@@ -2399,14 +2500,14 @@ static void ath10k_config_chan(struct ath10k *ar)
2399 ret = ath10k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid, 2500 ret = ath10k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid,
2400 arvif->bssid); 2501 arvif->bssid);
2401 if (ret) { 2502 if (ret) {
2402 ath10k_warn("could not bring vdev up %d (%d)\n", 2503 ath10k_warn("failed to bring vdev up %d: %d\n",
2403 arvif->vdev_id, ret); 2504 arvif->vdev_id, ret);
2404 continue; 2505 continue;
2405 } 2506 }
2406 } 2507 }
2407 2508
2408 if (monitor_was_enabled) 2509 if (ath10k_monitor_is_enabled(ar))
2409 ath10k_monitor_start(ar, ar->monitor_vdev_id); 2510 ath10k_monitor_vdev_start(ar, ar->monitor_vdev_id);
2410} 2511}
2411 2512
2412static int ath10k_config(struct ieee80211_hw *hw, u32 changed) 2513static int ath10k_config(struct ieee80211_hw *hw, u32 changed)
@@ -2420,15 +2521,17 @@ static int ath10k_config(struct ieee80211_hw *hw, u32 changed)
2420 2521
2421 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 2522 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
2422 ath10k_dbg(ATH10K_DBG_MAC, 2523 ath10k_dbg(ATH10K_DBG_MAC,
2423 "mac config channel %d mhz flags 0x%x\n", 2524 "mac config channel %dMHz flags 0x%x radar %d\n",
2424 conf->chandef.chan->center_freq, 2525 conf->chandef.chan->center_freq,
2425 conf->chandef.chan->flags); 2526 conf->chandef.chan->flags,
2527 conf->radar_enabled);
2426 2528
2427 spin_lock_bh(&ar->data_lock); 2529 spin_lock_bh(&ar->data_lock);
2428 ar->rx_channel = conf->chandef.chan; 2530 ar->rx_channel = conf->chandef.chan;
2429 spin_unlock_bh(&ar->data_lock); 2531 spin_unlock_bh(&ar->data_lock);
2430 2532
2431 ath10k_config_radar_detection(ar); 2533 ar->radar_enabled = conf->radar_enabled;
2534 ath10k_recalc_radar_detection(ar);
2432 2535
2433 if (!cfg80211_chandef_identical(&ar->chandef, &conf->chandef)) { 2536 if (!cfg80211_chandef_identical(&ar->chandef, &conf->chandef)) {
2434 ar->chandef = conf->chandef; 2537 ar->chandef = conf->chandef;
@@ -2444,14 +2547,14 @@ static int ath10k_config(struct ieee80211_hw *hw, u32 changed)
2444 ret = ath10k_wmi_pdev_set_param(ar, param, 2547 ret = ath10k_wmi_pdev_set_param(ar, param,
2445 hw->conf.power_level * 2); 2548 hw->conf.power_level * 2);
2446 if (ret) 2549 if (ret)
2447 ath10k_warn("mac failed to set 2g txpower %d (%d)\n", 2550 ath10k_warn("failed to set 2g txpower %d: %d\n",
2448 hw->conf.power_level, ret); 2551 hw->conf.power_level, ret);
2449 2552
2450 param = ar->wmi.pdev_param->txpower_limit5g; 2553 param = ar->wmi.pdev_param->txpower_limit5g;
2451 ret = ath10k_wmi_pdev_set_param(ar, param, 2554 ret = ath10k_wmi_pdev_set_param(ar, param,
2452 hw->conf.power_level * 2); 2555 hw->conf.power_level * 2);
2453 if (ret) 2556 if (ret)
2454 ath10k_warn("mac failed to set 5g txpower %d (%d)\n", 2557 ath10k_warn("failed to set 5g txpower %d: %d\n",
2455 hw->conf.power_level, ret); 2558 hw->conf.power_level, ret);
2456 } 2559 }
2457 2560
@@ -2459,10 +2562,19 @@ static int ath10k_config(struct ieee80211_hw *hw, u32 changed)
2459 ath10k_config_ps(ar); 2562 ath10k_config_ps(ar);
2460 2563
2461 if (changed & IEEE80211_CONF_CHANGE_MONITOR) { 2564 if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
2462 if (conf->flags & IEEE80211_CONF_MONITOR) 2565 if (conf->flags & IEEE80211_CONF_MONITOR && !ar->monitor) {
2463 ret = ath10k_monitor_create(ar); 2566 ar->monitor = true;
2464 else 2567 ret = ath10k_monitor_start(ar);
2465 ret = ath10k_monitor_destroy(ar); 2568 if (ret) {
2569 ath10k_warn("failed to start monitor (config): %d\n",
2570 ret);
2571 ar->monitor = false;
2572 }
2573 } else if (!(conf->flags & IEEE80211_CONF_MONITOR) &&
2574 ar->monitor) {
2575 ar->monitor = false;
2576 ath10k_monitor_stop(ar);
2577 }
2466 } 2578 }
2467 2579
2468 mutex_unlock(&ar->conf_mutex); 2580 mutex_unlock(&ar->conf_mutex);
@@ -2497,12 +2609,6 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
2497 INIT_WORK(&arvif->wep_key_work, ath10k_tx_wep_key_work); 2609 INIT_WORK(&arvif->wep_key_work, ath10k_tx_wep_key_work);
2498 INIT_LIST_HEAD(&arvif->list); 2610 INIT_LIST_HEAD(&arvif->list);
2499 2611
2500 if ((vif->type == NL80211_IFTYPE_MONITOR) && ar->monitor_present) {
2501 ath10k_warn("Only one monitor interface allowed\n");
2502 ret = -EBUSY;
2503 goto err;
2504 }
2505
2506 bit = ffs(ar->free_vdev_map); 2612 bit = ffs(ar->free_vdev_map);
2507 if (bit == 0) { 2613 if (bit == 0) {
2508 ret = -EBUSY; 2614 ret = -EBUSY;
@@ -2545,7 +2651,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
2545 ret = ath10k_wmi_vdev_create(ar, arvif->vdev_id, arvif->vdev_type, 2651 ret = ath10k_wmi_vdev_create(ar, arvif->vdev_id, arvif->vdev_type,
2546 arvif->vdev_subtype, vif->addr); 2652 arvif->vdev_subtype, vif->addr);
2547 if (ret) { 2653 if (ret) {
2548 ath10k_warn("WMI vdev %i create failed: ret %d\n", 2654 ath10k_warn("failed to create WMI vdev %i: %d\n",
2549 arvif->vdev_id, ret); 2655 arvif->vdev_id, ret);
2550 goto err; 2656 goto err;
2551 } 2657 }
@@ -2557,7 +2663,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
2557 ret = ath10k_wmi_vdev_set_param(ar, 0, vdev_param, 2663 ret = ath10k_wmi_vdev_set_param(ar, 0, vdev_param,
2558 arvif->def_wep_key_idx); 2664 arvif->def_wep_key_idx);
2559 if (ret) { 2665 if (ret) {
2560 ath10k_warn("Failed to set vdev %i default keyid: %d\n", 2666 ath10k_warn("failed to set vdev %i default key id: %d\n",
2561 arvif->vdev_id, ret); 2667 arvif->vdev_id, ret);
2562 goto err_vdev_delete; 2668 goto err_vdev_delete;
2563 } 2669 }
@@ -2567,7 +2673,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
2567 ATH10K_HW_TXRX_NATIVE_WIFI); 2673 ATH10K_HW_TXRX_NATIVE_WIFI);
2568 /* 10.X firmware does not support this VDEV parameter. Do not warn */ 2674 /* 10.X firmware does not support this VDEV parameter. Do not warn */
2569 if (ret && ret != -EOPNOTSUPP) { 2675 if (ret && ret != -EOPNOTSUPP) {
2570 ath10k_warn("Failed to set vdev %i TX encap: %d\n", 2676 ath10k_warn("failed to set vdev %i TX encapsulation: %d\n",
2571 arvif->vdev_id, ret); 2677 arvif->vdev_id, ret);
2572 goto err_vdev_delete; 2678 goto err_vdev_delete;
2573 } 2679 }
@@ -2575,14 +2681,14 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
2575 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { 2681 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
2576 ret = ath10k_peer_create(ar, arvif->vdev_id, vif->addr); 2682 ret = ath10k_peer_create(ar, arvif->vdev_id, vif->addr);
2577 if (ret) { 2683 if (ret) {
2578 ath10k_warn("Failed to create vdev %i peer for AP: %d\n", 2684 ath10k_warn("failed to create vdev %i peer for AP: %d\n",
2579 arvif->vdev_id, ret); 2685 arvif->vdev_id, ret);
2580 goto err_vdev_delete; 2686 goto err_vdev_delete;
2581 } 2687 }
2582 2688
2583 ret = ath10k_mac_set_kickout(arvif); 2689 ret = ath10k_mac_set_kickout(arvif);
2584 if (ret) { 2690 if (ret) {
2585 ath10k_warn("Failed to set vdev %i kickout parameters: %d\n", 2691 ath10k_warn("failed to set vdev %i kickout parameters: %d\n",
2586 arvif->vdev_id, ret); 2692 arvif->vdev_id, ret);
2587 goto err_peer_delete; 2693 goto err_peer_delete;
2588 } 2694 }
@@ -2594,7 +2700,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
2594 ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id, 2700 ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
2595 param, value); 2701 param, value);
2596 if (ret) { 2702 if (ret) {
2597 ath10k_warn("Failed to set vdev %i RX wake policy: %d\n", 2703 ath10k_warn("failed to set vdev %i RX wake policy: %d\n",
2598 arvif->vdev_id, ret); 2704 arvif->vdev_id, ret);
2599 goto err_peer_delete; 2705 goto err_peer_delete;
2600 } 2706 }
@@ -2604,7 +2710,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
2604 ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id, 2710 ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
2605 param, value); 2711 param, value);
2606 if (ret) { 2712 if (ret) {
2607 ath10k_warn("Failed to set vdev %i TX wake thresh: %d\n", 2713 ath10k_warn("failed to set vdev %i TX wake thresh: %d\n",
2608 arvif->vdev_id, ret); 2714 arvif->vdev_id, ret);
2609 goto err_peer_delete; 2715 goto err_peer_delete;
2610 } 2716 }
@@ -2614,7 +2720,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
2614 ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id, 2720 ret = ath10k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
2615 param, value); 2721 param, value);
2616 if (ret) { 2722 if (ret) {
2617 ath10k_warn("Failed to set vdev %i PSPOLL count: %d\n", 2723 ath10k_warn("failed to set vdev %i PSPOLL count: %d\n",
2618 arvif->vdev_id, ret); 2724 arvif->vdev_id, ret);
2619 goto err_peer_delete; 2725 goto err_peer_delete;
2620 } 2726 }
@@ -2622,21 +2728,18 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
2622 2728
2623 ret = ath10k_mac_set_rts(arvif, ar->hw->wiphy->rts_threshold); 2729 ret = ath10k_mac_set_rts(arvif, ar->hw->wiphy->rts_threshold);
2624 if (ret) { 2730 if (ret) {
2625 ath10k_warn("failed to set rts threshold for vdev %d (%d)\n", 2731 ath10k_warn("failed to set rts threshold for vdev %d: %d\n",
2626 arvif->vdev_id, ret); 2732 arvif->vdev_id, ret);
2627 goto err_peer_delete; 2733 goto err_peer_delete;
2628 } 2734 }
2629 2735
2630 ret = ath10k_mac_set_frag(arvif, ar->hw->wiphy->frag_threshold); 2736 ret = ath10k_mac_set_frag(arvif, ar->hw->wiphy->frag_threshold);
2631 if (ret) { 2737 if (ret) {
2632 ath10k_warn("failed to set frag threshold for vdev %d (%d)\n", 2738 ath10k_warn("failed to set frag threshold for vdev %d: %d\n",
2633 arvif->vdev_id, ret); 2739 arvif->vdev_id, ret);
2634 goto err_peer_delete; 2740 goto err_peer_delete;
2635 } 2741 }
2636 2742
2637 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR)
2638 ar->monitor_present = true;
2639
2640 mutex_unlock(&ar->conf_mutex); 2743 mutex_unlock(&ar->conf_mutex);
2641 return 0; 2744 return 0;
2642 2745
@@ -2679,7 +2782,7 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw,
2679 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { 2782 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
2680 ret = ath10k_peer_delete(arvif->ar, arvif->vdev_id, vif->addr); 2783 ret = ath10k_peer_delete(arvif->ar, arvif->vdev_id, vif->addr);
2681 if (ret) 2784 if (ret)
2682 ath10k_warn("Failed to remove peer for AP vdev %i: %d\n", 2785 ath10k_warn("failed to remove peer for AP vdev %i: %d\n",
2683 arvif->vdev_id, ret); 2786 arvif->vdev_id, ret);
2684 2787
2685 kfree(arvif->u.ap.noa_data); 2788 kfree(arvif->u.ap.noa_data);
@@ -2690,12 +2793,9 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw,
2690 2793
2691 ret = ath10k_wmi_vdev_delete(ar, arvif->vdev_id); 2794 ret = ath10k_wmi_vdev_delete(ar, arvif->vdev_id);
2692 if (ret) 2795 if (ret)
2693 ath10k_warn("WMI vdev %i delete failed: %d\n", 2796 ath10k_warn("failed to delete WMI vdev %i: %d\n",
2694 arvif->vdev_id, ret); 2797 arvif->vdev_id, ret);
2695 2798
2696 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR)
2697 ar->monitor_present = false;
2698
2699 ath10k_peer_cleanup(ar, arvif->vdev_id); 2799 ath10k_peer_cleanup(ar, arvif->vdev_id);
2700 2800
2701 mutex_unlock(&ar->conf_mutex); 2801 mutex_unlock(&ar->conf_mutex);
@@ -2728,28 +2828,17 @@ static void ath10k_configure_filter(struct ieee80211_hw *hw,
2728 *total_flags &= SUPPORTED_FILTERS; 2828 *total_flags &= SUPPORTED_FILTERS;
2729 ar->filter_flags = *total_flags; 2829 ar->filter_flags = *total_flags;
2730 2830
2731 /* Monitor must not be started if it wasn't created first. 2831 if (ar->filter_flags & FIF_PROMISC_IN_BSS && !ar->promisc) {
2732 * Promiscuous mode may be started on a non-monitor interface - in 2832 ar->promisc = true;
2733 * such case the monitor vdev is not created so starting the 2833 ret = ath10k_monitor_start(ar);
2734 * monitor makes no sense. Since ath10k uses no special RX filters 2834 if (ret) {
2735 * (only BSS filter in STA mode) there's no need for any special 2835 ath10k_warn("failed to start monitor (promisc): %d\n",
2736 * action here. */ 2836 ret);
2737 if ((ar->filter_flags & FIF_PROMISC_IN_BSS) && 2837 ar->promisc = false;
2738 !ar->monitor_enabled && ar->monitor_present) { 2838 }
2739 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor %d start\n", 2839 } else if (!(ar->filter_flags & FIF_PROMISC_IN_BSS) && ar->promisc) {
2740 ar->monitor_vdev_id); 2840 ar->promisc = false;
2741 2841 ath10k_monitor_stop(ar);
2742 ret = ath10k_monitor_start(ar, ar->monitor_vdev_id);
2743 if (ret)
2744 ath10k_warn("Unable to start monitor mode\n");
2745 } else if (!(ar->filter_flags & FIF_PROMISC_IN_BSS) &&
2746 ar->monitor_enabled && ar->monitor_present) {
2747 ath10k_dbg(ATH10K_DBG_MAC, "mac monitor %d stop\n",
2748 ar->monitor_vdev_id);
2749
2750 ret = ath10k_monitor_stop(ar);
2751 if (ret)
2752 ath10k_warn("Unable to stop monitor mode\n");
2753 } 2842 }
2754 2843
2755 mutex_unlock(&ar->conf_mutex); 2844 mutex_unlock(&ar->conf_mutex);
@@ -2780,7 +2869,7 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2780 arvif->vdev_id, arvif->beacon_interval); 2869 arvif->vdev_id, arvif->beacon_interval);
2781 2870
2782 if (ret) 2871 if (ret)
2783 ath10k_warn("Failed to set beacon interval for vdev %d: %i\n", 2872 ath10k_warn("failed to set beacon interval for vdev %d: %i\n",
2784 arvif->vdev_id, ret); 2873 arvif->vdev_id, ret);
2785 } 2874 }
2786 2875
@@ -2793,7 +2882,7 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2793 ret = ath10k_wmi_pdev_set_param(ar, pdev_param, 2882 ret = ath10k_wmi_pdev_set_param(ar, pdev_param,
2794 WMI_BEACON_STAGGERED_MODE); 2883 WMI_BEACON_STAGGERED_MODE);
2795 if (ret) 2884 if (ret)
2796 ath10k_warn("Failed to set beacon mode for vdev %d: %i\n", 2885 ath10k_warn("failed to set beacon mode for vdev %d: %i\n",
2797 arvif->vdev_id, ret); 2886 arvif->vdev_id, ret);
2798 } 2887 }
2799 2888
@@ -2808,7 +2897,7 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2808 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param, 2897 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
2809 arvif->dtim_period); 2898 arvif->dtim_period);
2810 if (ret) 2899 if (ret)
2811 ath10k_warn("Failed to set dtim period for vdev %d: %i\n", 2900 ath10k_warn("failed to set dtim period for vdev %d: %i\n",
2812 arvif->vdev_id, ret); 2901 arvif->vdev_id, ret);
2813 } 2902 }
2814 2903
@@ -2829,7 +2918,7 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2829 ret = ath10k_peer_create(ar, arvif->vdev_id, 2918 ret = ath10k_peer_create(ar, arvif->vdev_id,
2830 info->bssid); 2919 info->bssid);
2831 if (ret) 2920 if (ret)
2832 ath10k_warn("Failed to add peer %pM for vdev %d when changing bssid: %i\n", 2921 ath10k_warn("failed to add peer %pM for vdev %d when changing bssid: %i\n",
2833 info->bssid, arvif->vdev_id, ret); 2922 info->bssid, arvif->vdev_id, ret);
2834 2923
2835 if (vif->type == NL80211_IFTYPE_STATION) { 2924 if (vif->type == NL80211_IFTYPE_STATION) {
@@ -2868,20 +2957,13 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2868 ath10k_control_beaconing(arvif, info); 2957 ath10k_control_beaconing(arvif, info);
2869 2958
2870 if (changed & BSS_CHANGED_ERP_CTS_PROT) { 2959 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
2871 u32 cts_prot; 2960 arvif->use_cts_prot = info->use_cts_prot;
2872 if (info->use_cts_prot)
2873 cts_prot = 1;
2874 else
2875 cts_prot = 0;
2876
2877 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev %d cts_prot %d\n", 2961 ath10k_dbg(ATH10K_DBG_MAC, "mac vdev %d cts_prot %d\n",
2878 arvif->vdev_id, cts_prot); 2962 arvif->vdev_id, info->use_cts_prot);
2879 2963
2880 vdev_param = ar->wmi.vdev_param->enable_rtscts; 2964 ret = ath10k_recalc_rtscts_prot(arvif);
2881 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
2882 cts_prot);
2883 if (ret) 2965 if (ret)
2884 ath10k_warn("Failed to set CTS prot for vdev %d: %d\n", 2966 ath10k_warn("failed to recalculate rts/cts prot for vdev %d: %d\n",
2885 arvif->vdev_id, ret); 2967 arvif->vdev_id, ret);
2886 } 2968 }
2887 2969
@@ -2900,7 +2982,7 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2900 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param, 2982 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
2901 slottime); 2983 slottime);
2902 if (ret) 2984 if (ret)
2903 ath10k_warn("Failed to set erp slot for vdev %d: %i\n", 2985 ath10k_warn("failed to set erp slot for vdev %d: %i\n",
2904 arvif->vdev_id, ret); 2986 arvif->vdev_id, ret);
2905 } 2987 }
2906 2988
@@ -2919,7 +3001,7 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
2919 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param, 3001 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
2920 preamble); 3002 preamble);
2921 if (ret) 3003 if (ret)
2922 ath10k_warn("Failed to set preamble for vdev %d: %i\n", 3004 ath10k_warn("failed to set preamble for vdev %d: %i\n",
2923 arvif->vdev_id, ret); 3005 arvif->vdev_id, ret);
2924 } 3006 }
2925 3007
@@ -2990,7 +3072,7 @@ static int ath10k_hw_scan(struct ieee80211_hw *hw,
2990 3072
2991 ret = ath10k_start_scan(ar, &arg); 3073 ret = ath10k_start_scan(ar, &arg);
2992 if (ret) { 3074 if (ret) {
2993 ath10k_warn("could not start hw scan (%d)\n", ret); 3075 ath10k_warn("failed to start hw scan: %d\n", ret);
2994 spin_lock_bh(&ar->data_lock); 3076 spin_lock_bh(&ar->data_lock);
2995 ar->scan.in_progress = false; 3077 ar->scan.in_progress = false;
2996 spin_unlock_bh(&ar->data_lock); 3078 spin_unlock_bh(&ar->data_lock);
@@ -3010,8 +3092,7 @@ static void ath10k_cancel_hw_scan(struct ieee80211_hw *hw,
3010 mutex_lock(&ar->conf_mutex); 3092 mutex_lock(&ar->conf_mutex);
3011 ret = ath10k_abort_scan(ar); 3093 ret = ath10k_abort_scan(ar);
3012 if (ret) { 3094 if (ret) {
3013 ath10k_warn("couldn't abort scan (%d). forcefully sending scan completion to mac80211\n", 3095 ath10k_warn("failed to abort scan: %d\n", ret);
3014 ret);
3015 ieee80211_scan_completed(hw, 1 /* aborted */); 3096 ieee80211_scan_completed(hw, 1 /* aborted */);
3016 } 3097 }
3017 mutex_unlock(&ar->conf_mutex); 3098 mutex_unlock(&ar->conf_mutex);
@@ -3089,7 +3170,7 @@ static int ath10k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3089 3170
3090 if (!peer) { 3171 if (!peer) {
3091 if (cmd == SET_KEY) { 3172 if (cmd == SET_KEY) {
3092 ath10k_warn("cannot install key for non-existent peer %pM\n", 3173 ath10k_warn("failed to install key for non-existent peer %pM\n",
3093 peer_addr); 3174 peer_addr);
3094 ret = -EOPNOTSUPP; 3175 ret = -EOPNOTSUPP;
3095 goto exit; 3176 goto exit;
@@ -3112,7 +3193,7 @@ static int ath10k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3112 3193
3113 ret = ath10k_install_key(arvif, key, cmd, peer_addr); 3194 ret = ath10k_install_key(arvif, key, cmd, peer_addr);
3114 if (ret) { 3195 if (ret) {
3115 ath10k_warn("key installation failed for vdev %i peer %pM: %d\n", 3196 ath10k_warn("failed to install key for vdev %i peer %pM: %d\n",
3116 arvif->vdev_id, peer_addr, ret); 3197 arvif->vdev_id, peer_addr, ret);
3117 goto exit; 3198 goto exit;
3118 } 3199 }
@@ -3127,7 +3208,7 @@ static int ath10k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3127 peer->keys[key->keyidx] = NULL; 3208 peer->keys[key->keyidx] = NULL;
3128 else if (peer == NULL) 3209 else if (peer == NULL)
3129 /* impossible unless FW goes crazy */ 3210 /* impossible unless FW goes crazy */
3130 ath10k_warn("peer %pM disappeared!\n", peer_addr); 3211 ath10k_warn("Peer %pM disappeared!\n", peer_addr);
3131 spin_unlock_bh(&ar->data_lock); 3212 spin_unlock_bh(&ar->data_lock);
3132 3213
3133exit: 3214exit:
@@ -3195,6 +3276,16 @@ static void ath10k_sta_rc_update_wk(struct work_struct *wk)
3195 sta->addr, smps, err); 3276 sta->addr, smps, err);
3196 } 3277 }
3197 3278
3279 if (changed & IEEE80211_RC_SUPP_RATES_CHANGED) {
3280 ath10k_dbg(ATH10K_DBG_MAC, "mac update sta %pM supp rates\n",
3281 sta->addr);
3282
3283 err = ath10k_station_assoc(ar, arvif, sta, true);
3284 if (err)
3285 ath10k_warn("failed to reassociate station: %pM\n",
3286 sta->addr);
3287 }
3288
3198 mutex_unlock(&ar->conf_mutex); 3289 mutex_unlock(&ar->conf_mutex);
3199} 3290}
3200 3291
@@ -3236,7 +3327,7 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
3236 max_num_peers = TARGET_NUM_PEERS; 3327 max_num_peers = TARGET_NUM_PEERS;
3237 3328
3238 if (ar->num_peers >= max_num_peers) { 3329 if (ar->num_peers >= max_num_peers) {
3239 ath10k_warn("Number of peers exceeded: peers number %d (max peers %d)\n", 3330 ath10k_warn("number of peers exceeded: peers number %d (max peers %d)\n",
3240 ar->num_peers, max_num_peers); 3331 ar->num_peers, max_num_peers);
3241 ret = -ENOBUFS; 3332 ret = -ENOBUFS;
3242 goto exit; 3333 goto exit;
@@ -3248,7 +3339,7 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
3248 3339
3249 ret = ath10k_peer_create(ar, arvif->vdev_id, sta->addr); 3340 ret = ath10k_peer_create(ar, arvif->vdev_id, sta->addr);
3250 if (ret) 3341 if (ret)
3251 ath10k_warn("Failed to add peer %pM for vdev %d when adding a new sta: %i\n", 3342 ath10k_warn("failed to add peer %pM for vdev %d when adding a new sta: %i\n",
3252 sta->addr, arvif->vdev_id, ret); 3343 sta->addr, arvif->vdev_id, ret);
3253 } else if ((old_state == IEEE80211_STA_NONE && 3344 } else if ((old_state == IEEE80211_STA_NONE &&
3254 new_state == IEEE80211_STA_NOTEXIST)) { 3345 new_state == IEEE80211_STA_NOTEXIST)) {
@@ -3260,7 +3351,7 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
3260 arvif->vdev_id, sta->addr); 3351 arvif->vdev_id, sta->addr);
3261 ret = ath10k_peer_delete(ar, arvif->vdev_id, sta->addr); 3352 ret = ath10k_peer_delete(ar, arvif->vdev_id, sta->addr);
3262 if (ret) 3353 if (ret)
3263 ath10k_warn("Failed to delete peer %pM for vdev %d: %i\n", 3354 ath10k_warn("failed to delete peer %pM for vdev %d: %i\n",
3264 sta->addr, arvif->vdev_id, ret); 3355 sta->addr, arvif->vdev_id, ret);
3265 3356
3266 if (vif->type == NL80211_IFTYPE_STATION) 3357 if (vif->type == NL80211_IFTYPE_STATION)
@@ -3275,9 +3366,9 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
3275 ath10k_dbg(ATH10K_DBG_MAC, "mac sta %pM associated\n", 3366 ath10k_dbg(ATH10K_DBG_MAC, "mac sta %pM associated\n",
3276 sta->addr); 3367 sta->addr);
3277 3368
3278 ret = ath10k_station_assoc(ar, arvif, sta); 3369 ret = ath10k_station_assoc(ar, arvif, sta, false);
3279 if (ret) 3370 if (ret)
3280 ath10k_warn("Failed to associate station %pM for vdev %i: %i\n", 3371 ath10k_warn("failed to associate station %pM for vdev %i: %i\n",
3281 sta->addr, arvif->vdev_id, ret); 3372 sta->addr, arvif->vdev_id, ret);
3282 } else if (old_state == IEEE80211_STA_ASSOC && 3373 } else if (old_state == IEEE80211_STA_ASSOC &&
3283 new_state == IEEE80211_STA_AUTH && 3374 new_state == IEEE80211_STA_AUTH &&
@@ -3291,7 +3382,7 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
3291 3382
3292 ret = ath10k_station_disassoc(ar, arvif, sta); 3383 ret = ath10k_station_disassoc(ar, arvif, sta);
3293 if (ret) 3384 if (ret)
3294 ath10k_warn("Failed to disassociate station: %pM vdev %i ret %i\n", 3385 ath10k_warn("failed to disassociate station: %pM vdev %i: %i\n",
3295 sta->addr, arvif->vdev_id, ret); 3386 sta->addr, arvif->vdev_id, ret);
3296 } 3387 }
3297exit: 3388exit:
@@ -3339,7 +3430,7 @@ static int ath10k_conf_tx_uapsd(struct ath10k *ar, struct ieee80211_vif *vif,
3339 WMI_STA_PS_PARAM_UAPSD, 3430 WMI_STA_PS_PARAM_UAPSD,
3340 arvif->u.sta.uapsd); 3431 arvif->u.sta.uapsd);
3341 if (ret) { 3432 if (ret) {
3342 ath10k_warn("could not set uapsd params %d\n", ret); 3433 ath10k_warn("failed to set uapsd params: %d\n", ret);
3343 goto exit; 3434 goto exit;
3344 } 3435 }
3345 3436
@@ -3352,7 +3443,7 @@ static int ath10k_conf_tx_uapsd(struct ath10k *ar, struct ieee80211_vif *vif,
3352 WMI_STA_PS_PARAM_RX_WAKE_POLICY, 3443 WMI_STA_PS_PARAM_RX_WAKE_POLICY,
3353 value); 3444 value);
3354 if (ret) 3445 if (ret)
3355 ath10k_warn("could not set rx wake param %d\n", ret); 3446 ath10k_warn("failed to set rx wake param: %d\n", ret);
3356 3447
3357exit: 3448exit:
3358 return ret; 3449 return ret;
@@ -3402,13 +3493,13 @@ static int ath10k_conf_tx(struct ieee80211_hw *hw,
3402 /* FIXME: FW accepts wmm params per hw, not per vif */ 3493 /* FIXME: FW accepts wmm params per hw, not per vif */
3403 ret = ath10k_wmi_pdev_set_wmm_params(ar, &ar->wmm_params); 3494 ret = ath10k_wmi_pdev_set_wmm_params(ar, &ar->wmm_params);
3404 if (ret) { 3495 if (ret) {
3405 ath10k_warn("could not set wmm params %d\n", ret); 3496 ath10k_warn("failed to set wmm params: %d\n", ret);
3406 goto exit; 3497 goto exit;
3407 } 3498 }
3408 3499
3409 ret = ath10k_conf_tx_uapsd(ar, vif, ac, params->uapsd); 3500 ret = ath10k_conf_tx_uapsd(ar, vif, ac, params->uapsd);
3410 if (ret) 3501 if (ret)
3411 ath10k_warn("could not set sta uapsd %d\n", ret); 3502 ath10k_warn("failed to set sta uapsd: %d\n", ret);
3412 3503
3413exit: 3504exit:
3414 mutex_unlock(&ar->conf_mutex); 3505 mutex_unlock(&ar->conf_mutex);
@@ -3461,7 +3552,7 @@ static int ath10k_remain_on_channel(struct ieee80211_hw *hw,
3461 3552
3462 ret = ath10k_start_scan(ar, &arg); 3553 ret = ath10k_start_scan(ar, &arg);
3463 if (ret) { 3554 if (ret) {
3464 ath10k_warn("could not start roc scan (%d)\n", ret); 3555 ath10k_warn("failed to start roc scan: %d\n", ret);
3465 spin_lock_bh(&ar->data_lock); 3556 spin_lock_bh(&ar->data_lock);
3466 ar->scan.in_progress = false; 3557 ar->scan.in_progress = false;
3467 spin_unlock_bh(&ar->data_lock); 3558 spin_unlock_bh(&ar->data_lock);
@@ -3470,7 +3561,7 @@ static int ath10k_remain_on_channel(struct ieee80211_hw *hw,
3470 3561
3471 ret = wait_for_completion_timeout(&ar->scan.on_channel, 3*HZ); 3562 ret = wait_for_completion_timeout(&ar->scan.on_channel, 3*HZ);
3472 if (ret == 0) { 3563 if (ret == 0) {
3473 ath10k_warn("could not switch to channel for roc scan\n"); 3564 ath10k_warn("failed to switch to channel for roc scan\n");
3474 ath10k_abort_scan(ar); 3565 ath10k_abort_scan(ar);
3475 ret = -ETIMEDOUT; 3566 ret = -ETIMEDOUT;
3476 goto exit; 3567 goto exit;
@@ -3511,7 +3602,7 @@ static int ath10k_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
3511 3602
3512 ret = ath10k_mac_set_rts(arvif, value); 3603 ret = ath10k_mac_set_rts(arvif, value);
3513 if (ret) { 3604 if (ret) {
3514 ath10k_warn("could not set rts threshold for vdev %d (%d)\n", 3605 ath10k_warn("failed to set rts threshold for vdev %d: %d\n",
3515 arvif->vdev_id, ret); 3606 arvif->vdev_id, ret);
3516 break; 3607 break;
3517 } 3608 }
@@ -3534,7 +3625,7 @@ static int ath10k_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
3534 3625
3535 ret = ath10k_mac_set_rts(arvif, value); 3626 ret = ath10k_mac_set_rts(arvif, value);
3536 if (ret) { 3627 if (ret) {
3537 ath10k_warn("could not set fragmentation threshold for vdev %d (%d)\n", 3628 ath10k_warn("failed to set fragmentation threshold for vdev %d: %d\n",
3538 arvif->vdev_id, ret); 3629 arvif->vdev_id, ret);
3539 break; 3630 break;
3540 } 3631 }
@@ -3573,7 +3664,7 @@ static void ath10k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
3573 }), ATH10K_FLUSH_TIMEOUT_HZ); 3664 }), ATH10K_FLUSH_TIMEOUT_HZ);
3574 3665
3575 if (ret <= 0 || skip) 3666 if (ret <= 0 || skip)
3576 ath10k_warn("tx not flushed (skip %i ar-state %i): %i\n", 3667 ath10k_warn("failed to flush transmit queue (skip %i ar-state %i): %i\n",
3577 skip, ar->state, ret); 3668 skip, ar->state, ret);
3578 3669
3579skip: 3670skip:
@@ -3608,7 +3699,7 @@ static int ath10k_suspend(struct ieee80211_hw *hw,
3608 3699
3609 ret = ath10k_hif_suspend(ar); 3700 ret = ath10k_hif_suspend(ar);
3610 if (ret) { 3701 if (ret) {
3611 ath10k_warn("could not suspend hif (%d)\n", ret); 3702 ath10k_warn("failed to suspend hif: %d\n", ret);
3612 goto resume; 3703 goto resume;
3613 } 3704 }
3614 3705
@@ -3617,7 +3708,7 @@ static int ath10k_suspend(struct ieee80211_hw *hw,
3617resume: 3708resume:
3618 ret = ath10k_wmi_pdev_resume_target(ar); 3709 ret = ath10k_wmi_pdev_resume_target(ar);
3619 if (ret) 3710 if (ret)
3620 ath10k_warn("could not resume target (%d)\n", ret); 3711 ath10k_warn("failed to resume target: %d\n", ret);
3621 3712
3622 ret = 1; 3713 ret = 1;
3623exit: 3714exit:
@@ -3634,14 +3725,14 @@ static int ath10k_resume(struct ieee80211_hw *hw)
3634 3725
3635 ret = ath10k_hif_resume(ar); 3726 ret = ath10k_hif_resume(ar);
3636 if (ret) { 3727 if (ret) {
3637 ath10k_warn("could not resume hif (%d)\n", ret); 3728 ath10k_warn("failed to resume hif: %d\n", ret);
3638 ret = 1; 3729 ret = 1;
3639 goto exit; 3730 goto exit;
3640 } 3731 }
3641 3732
3642 ret = ath10k_wmi_pdev_resume_target(ar); 3733 ret = ath10k_wmi_pdev_resume_target(ar);
3643 if (ret) { 3734 if (ret) {
3644 ath10k_warn("could not resume target (%d)\n", ret); 3735 ath10k_warn("failed to resume target: %d\n", ret);
3645 ret = 1; 3736 ret = 1;
3646 goto exit; 3737 goto exit;
3647 } 3738 }
@@ -3964,7 +4055,7 @@ static int ath10k_set_fixed_rate_param(struct ath10k_vif *arvif,
3964 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, 4055 ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id,
3965 vdev_param, fixed_rate); 4056 vdev_param, fixed_rate);
3966 if (ret) { 4057 if (ret) {
3967 ath10k_warn("Could not set fixed_rate param 0x%02x: %d\n", 4058 ath10k_warn("failed to set fixed rate param 0x%02x: %d\n",
3968 fixed_rate, ret); 4059 fixed_rate, ret);
3969 ret = -EINVAL; 4060 ret = -EINVAL;
3970 goto exit; 4061 goto exit;
@@ -3977,7 +4068,7 @@ static int ath10k_set_fixed_rate_param(struct ath10k_vif *arvif,
3977 vdev_param, fixed_nss); 4068 vdev_param, fixed_nss);
3978 4069
3979 if (ret) { 4070 if (ret) {
3980 ath10k_warn("Could not set fixed_nss param %d: %d\n", 4071 ath10k_warn("failed to set fixed nss param %d: %d\n",
3981 fixed_nss, ret); 4072 fixed_nss, ret);
3982 ret = -EINVAL; 4073 ret = -EINVAL;
3983 goto exit; 4074 goto exit;
@@ -3990,7 +4081,7 @@ static int ath10k_set_fixed_rate_param(struct ath10k_vif *arvif,
3990 force_sgi); 4081 force_sgi);
3991 4082
3992 if (ret) { 4083 if (ret) {
3993 ath10k_warn("Could not set sgi param %d: %d\n", 4084 ath10k_warn("failed to set sgi param %d: %d\n",
3994 force_sgi, ret); 4085 force_sgi, ret);
3995 ret = -EINVAL; 4086 ret = -EINVAL;
3996 goto exit; 4087 goto exit;
@@ -4026,7 +4117,7 @@ static int ath10k_set_bitrate_mask(struct ieee80211_hw *hw,
4026 } 4117 }
4027 4118
4028 if (fixed_rate == WMI_FIXED_RATE_NONE && force_sgi) { 4119 if (fixed_rate == WMI_FIXED_RATE_NONE && force_sgi) {
4029 ath10k_warn("Could not force SGI usage for default rate settings\n"); 4120 ath10k_warn("failed to force SGI usage for default rate settings\n");
4030 return -EINVAL; 4121 return -EINVAL;
4031 } 4122 }
4032 4123
@@ -4072,8 +4163,8 @@ static void ath10k_sta_rc_update(struct ieee80211_hw *hw,
4072 bw = WMI_PEER_CHWIDTH_80MHZ; 4163 bw = WMI_PEER_CHWIDTH_80MHZ;
4073 break; 4164 break;
4074 case IEEE80211_STA_RX_BW_160: 4165 case IEEE80211_STA_RX_BW_160:
4075 ath10k_warn("mac sta rc update for %pM: invalid bw %d\n", 4166 ath10k_warn("Invalid bandwith %d in rc update for %pM\n",
4076 sta->addr, sta->bandwidth); 4167 sta->bandwidth, sta->addr);
4077 bw = WMI_PEER_CHWIDTH_20MHZ; 4168 bw = WMI_PEER_CHWIDTH_20MHZ;
4078 break; 4169 break;
4079 } 4170 }
@@ -4099,8 +4190,8 @@ static void ath10k_sta_rc_update(struct ieee80211_hw *hw,
4099 smps = WMI_PEER_SMPS_DYNAMIC; 4190 smps = WMI_PEER_SMPS_DYNAMIC;
4100 break; 4191 break;
4101 case IEEE80211_SMPS_NUM_MODES: 4192 case IEEE80211_SMPS_NUM_MODES:
4102 ath10k_warn("mac sta rc update for %pM: invalid smps: %d\n", 4193 ath10k_warn("Invalid smps %d in sta rc update for %pM\n",
4103 sta->addr, sta->smps_mode); 4194 sta->smps_mode, sta->addr);
4104 smps = WMI_PEER_SMPS_PS_NONE; 4195 smps = WMI_PEER_SMPS_PS_NONE;
4105 break; 4196 break;
4106 } 4197 }
@@ -4108,15 +4199,6 @@ static void ath10k_sta_rc_update(struct ieee80211_hw *hw,
4108 arsta->smps = smps; 4199 arsta->smps = smps;
4109 } 4200 }
4110 4201
4111 if (changed & IEEE80211_RC_SUPP_RATES_CHANGED) {
4112 /* FIXME: Not implemented. Probably the only way to do it would
4113 * be to re-assoc the peer. */
4114 changed &= ~IEEE80211_RC_SUPP_RATES_CHANGED;
4115 ath10k_dbg(ATH10K_DBG_MAC,
4116 "mac sta rc update for %pM: changing supported rates not implemented\n",
4117 sta->addr);
4118 }
4119
4120 arsta->changed |= changed; 4202 arsta->changed |= changed;
4121 4203
4122 spin_unlock_bh(&ar->data_lock); 4204 spin_unlock_bh(&ar->data_lock);
@@ -4516,7 +4598,6 @@ int ath10k_mac_register(struct ath10k *ar)
4516 IEEE80211_HW_REPORTS_TX_ACK_STATUS | 4598 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
4517 IEEE80211_HW_HAS_RATE_CONTROL | 4599 IEEE80211_HW_HAS_RATE_CONTROL |
4518 IEEE80211_HW_SUPPORTS_STATIC_SMPS | 4600 IEEE80211_HW_SUPPORTS_STATIC_SMPS |
4519 IEEE80211_HW_WANT_MONITOR_VIF |
4520 IEEE80211_HW_AP_LINK_PS | 4601 IEEE80211_HW_AP_LINK_PS |
4521 IEEE80211_HW_SPECTRUM_MGMT; 4602 IEEE80211_HW_SPECTRUM_MGMT;
4522 4603
@@ -4570,19 +4651,19 @@ int ath10k_mac_register(struct ath10k *ar)
4570 NL80211_DFS_UNSET); 4651 NL80211_DFS_UNSET);
4571 4652
4572 if (!ar->dfs_detector) 4653 if (!ar->dfs_detector)
4573 ath10k_warn("dfs pattern detector init failed\n"); 4654 ath10k_warn("failed to initialise DFS pattern detector\n");
4574 } 4655 }
4575 4656
4576 ret = ath_regd_init(&ar->ath_common.regulatory, ar->hw->wiphy, 4657 ret = ath_regd_init(&ar->ath_common.regulatory, ar->hw->wiphy,
4577 ath10k_reg_notifier); 4658 ath10k_reg_notifier);
4578 if (ret) { 4659 if (ret) {
4579 ath10k_err("Regulatory initialization failed: %i\n", ret); 4660 ath10k_err("failed to initialise regulatory: %i\n", ret);
4580 goto err_free; 4661 goto err_free;
4581 } 4662 }
4582 4663
4583 ret = ieee80211_register_hw(ar->hw); 4664 ret = ieee80211_register_hw(ar->hw);
4584 if (ret) { 4665 if (ret) {
4585 ath10k_err("ieee80211 registration failed: %d\n", ret); 4666 ath10k_err("failed to register ieee80211: %d\n", ret);
4586 goto err_free; 4667 goto err_free;
4587 } 4668 }
4588 4669
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 9d242d801d9d..bf1083d52e61 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -39,15 +39,27 @@ enum ath10k_pci_irq_mode {
39 ATH10K_PCI_IRQ_MSI = 2, 39 ATH10K_PCI_IRQ_MSI = 2,
40}; 40};
41 41
42static unsigned int ath10k_target_ps; 42enum ath10k_pci_reset_mode {
43 ATH10K_PCI_RESET_AUTO = 0,
44 ATH10K_PCI_RESET_WARM_ONLY = 1,
45};
46
47static unsigned int ath10k_pci_target_ps;
43static unsigned int ath10k_pci_irq_mode = ATH10K_PCI_IRQ_AUTO; 48static unsigned int ath10k_pci_irq_mode = ATH10K_PCI_IRQ_AUTO;
49static unsigned int ath10k_pci_reset_mode = ATH10K_PCI_RESET_AUTO;
44 50
45module_param(ath10k_target_ps, uint, 0644); 51module_param_named(target_ps, ath10k_pci_target_ps, uint, 0644);
46MODULE_PARM_DESC(ath10k_target_ps, "Enable ath10k Target (SoC) PS option"); 52MODULE_PARM_DESC(target_ps, "Enable ath10k Target (SoC) PS option");
47 53
48module_param_named(irq_mode, ath10k_pci_irq_mode, uint, 0644); 54module_param_named(irq_mode, ath10k_pci_irq_mode, uint, 0644);
49MODULE_PARM_DESC(irq_mode, "0: auto, 1: legacy, 2: msi (default: 0)"); 55MODULE_PARM_DESC(irq_mode, "0: auto, 1: legacy, 2: msi (default: 0)");
50 56
57module_param_named(reset_mode, ath10k_pci_reset_mode, uint, 0644);
58MODULE_PARM_DESC(reset_mode, "0: auto, 1: warm only (default: 0)");
59
60/* how long wait to wait for target to initialise, in ms */
61#define ATH10K_PCI_TARGET_WAIT 3000
62
51#define QCA988X_2_0_DEVICE_ID (0x003c) 63#define QCA988X_2_0_DEVICE_ID (0x003c)
52 64
53static DEFINE_PCI_DEVICE_TABLE(ath10k_pci_id_table) = { 65static DEFINE_PCI_DEVICE_TABLE(ath10k_pci_id_table) = {
@@ -346,9 +358,10 @@ static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, void *data,
346 * 2) Buffer in DMA-able space 358 * 2) Buffer in DMA-able space
347 */ 359 */
348 orig_nbytes = nbytes; 360 orig_nbytes = nbytes;
349 data_buf = (unsigned char *)pci_alloc_consistent(ar_pci->pdev, 361 data_buf = (unsigned char *)dma_alloc_coherent(ar->dev,
350 orig_nbytes, 362 orig_nbytes,
351 &ce_data_base); 363 &ce_data_base,
364 GFP_ATOMIC);
352 365
353 if (!data_buf) { 366 if (!data_buf) {
354 ret = -ENOMEM; 367 ret = -ENOMEM;
@@ -442,12 +455,12 @@ done:
442 __le32_to_cpu(((__le32 *)data_buf)[i]); 455 __le32_to_cpu(((__le32 *)data_buf)[i]);
443 } 456 }
444 } else 457 } else
445 ath10k_dbg(ATH10K_DBG_PCI, "%s failure (0x%x)\n", 458 ath10k_warn("failed to read diag value at 0x%x: %d\n",
446 __func__, address); 459 address, ret);
447 460
448 if (data_buf) 461 if (data_buf)
449 pci_free_consistent(ar_pci->pdev, orig_nbytes, 462 dma_free_coherent(ar->dev, orig_nbytes, data_buf,
450 data_buf, ce_data_base); 463 ce_data_base);
451 464
452 return ret; 465 return ret;
453} 466}
@@ -490,9 +503,10 @@ static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address,
490 * 2) Buffer in DMA-able space 503 * 2) Buffer in DMA-able space
491 */ 504 */
492 orig_nbytes = nbytes; 505 orig_nbytes = nbytes;
493 data_buf = (unsigned char *)pci_alloc_consistent(ar_pci->pdev, 506 data_buf = (unsigned char *)dma_alloc_coherent(ar->dev,
494 orig_nbytes, 507 orig_nbytes,
495 &ce_data_base); 508 &ce_data_base,
509 GFP_ATOMIC);
496 if (!data_buf) { 510 if (!data_buf) {
497 ret = -ENOMEM; 511 ret = -ENOMEM;
498 goto done; 512 goto done;
@@ -588,13 +602,13 @@ static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address,
588 602
589done: 603done:
590 if (data_buf) { 604 if (data_buf) {
591 pci_free_consistent(ar_pci->pdev, orig_nbytes, data_buf, 605 dma_free_coherent(ar->dev, orig_nbytes, data_buf,
592 ce_data_base); 606 ce_data_base);
593 } 607 }
594 608
595 if (ret != 0) 609 if (ret != 0)
596 ath10k_dbg(ATH10K_DBG_PCI, "%s failure (0x%x)\n", __func__, 610 ath10k_warn("failed to write diag value at 0x%x: %d\n",
597 address); 611 address, ret);
598 612
599 return ret; 613 return ret;
600} 614}
@@ -803,6 +817,9 @@ unlock:
803static u16 ath10k_pci_hif_get_free_queue_number(struct ath10k *ar, u8 pipe) 817static u16 ath10k_pci_hif_get_free_queue_number(struct ath10k *ar, u8 pipe)
804{ 818{
805 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 819 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
820
821 ath10k_dbg(ATH10K_DBG_PCI, "pci hif get free queue number\n");
822
806 return ath10k_ce_num_free_src_entries(ar_pci->pipe_info[pipe].ce_hdl); 823 return ath10k_ce_num_free_src_entries(ar_pci->pipe_info[pipe].ce_hdl);
807} 824}
808 825
@@ -854,6 +871,8 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar)
854static void ath10k_pci_hif_send_complete_check(struct ath10k *ar, u8 pipe, 871static void ath10k_pci_hif_send_complete_check(struct ath10k *ar, u8 pipe,
855 int force) 872 int force)
856{ 873{
874 ath10k_dbg(ATH10K_DBG_PCI, "pci hif send complete check\n");
875
857 if (!force) { 876 if (!force) {
858 int resources; 877 int resources;
859 /* 878 /*
@@ -880,7 +899,7 @@ static void ath10k_pci_hif_set_callbacks(struct ath10k *ar,
880{ 899{
881 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 900 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
882 901
883 ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__); 902 ath10k_dbg(ATH10K_DBG_PCI, "pci hif set callbacks\n");
884 903
885 memcpy(&ar_pci->msg_callbacks_current, callbacks, 904 memcpy(&ar_pci->msg_callbacks_current, callbacks,
886 sizeof(ar_pci->msg_callbacks_current)); 905 sizeof(ar_pci->msg_callbacks_current));
@@ -938,6 +957,8 @@ static int ath10k_pci_hif_map_service_to_pipe(struct ath10k *ar,
938{ 957{
939 int ret = 0; 958 int ret = 0;
940 959
960 ath10k_dbg(ATH10K_DBG_PCI, "pci hif map service\n");
961
941 /* polling for received messages not supported */ 962 /* polling for received messages not supported */
942 *dl_is_polled = 0; 963 *dl_is_polled = 0;
943 964
@@ -997,6 +1018,8 @@ static void ath10k_pci_hif_get_default_pipe(struct ath10k *ar,
997{ 1018{
998 int ul_is_polled, dl_is_polled; 1019 int ul_is_polled, dl_is_polled;
999 1020
1021 ath10k_dbg(ATH10K_DBG_PCI, "pci hif get default pipe\n");
1022
1000 (void)ath10k_pci_hif_map_service_to_pipe(ar, 1023 (void)ath10k_pci_hif_map_service_to_pipe(ar,
1001 ATH10K_HTC_SVC_ID_RSVD_CTRL, 1024 ATH10K_HTC_SVC_ID_RSVD_CTRL,
1002 ul_pipe, 1025 ul_pipe,
@@ -1098,6 +1121,8 @@ static int ath10k_pci_hif_start(struct ath10k *ar)
1098 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1121 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1099 int ret, ret_early; 1122 int ret, ret_early;
1100 1123
1124 ath10k_dbg(ATH10K_DBG_BOOT, "boot hif start\n");
1125
1101 ath10k_pci_free_early_irq(ar); 1126 ath10k_pci_free_early_irq(ar);
1102 ath10k_pci_kill_tasklet(ar); 1127 ath10k_pci_kill_tasklet(ar);
1103 1128
@@ -1233,18 +1258,10 @@ static void ath10k_pci_buffer_cleanup(struct ath10k *ar)
1233 1258
1234static void ath10k_pci_ce_deinit(struct ath10k *ar) 1259static void ath10k_pci_ce_deinit(struct ath10k *ar)
1235{ 1260{
1236 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1261 int i;
1237 struct ath10k_pci_pipe *pipe_info;
1238 int pipe_num;
1239 1262
1240 for (pipe_num = 0; pipe_num < CE_COUNT; pipe_num++) { 1263 for (i = 0; i < CE_COUNT; i++)
1241 pipe_info = &ar_pci->pipe_info[pipe_num]; 1264 ath10k_ce_deinit_pipe(ar, i);
1242 if (pipe_info->ce_hdl) {
1243 ath10k_ce_deinit(pipe_info->ce_hdl);
1244 pipe_info->ce_hdl = NULL;
1245 pipe_info->buf_sz = 0;
1246 }
1247 }
1248} 1265}
1249 1266
1250static void ath10k_pci_hif_stop(struct ath10k *ar) 1267static void ath10k_pci_hif_stop(struct ath10k *ar)
@@ -1252,7 +1269,7 @@ static void ath10k_pci_hif_stop(struct ath10k *ar)
1252 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1269 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1253 int ret; 1270 int ret;
1254 1271
1255 ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__); 1272 ath10k_dbg(ATH10K_DBG_BOOT, "boot hif stop\n");
1256 1273
1257 ret = ath10k_ce_disable_interrupts(ar); 1274 ret = ath10k_ce_disable_interrupts(ar);
1258 if (ret) 1275 if (ret)
@@ -1697,30 +1714,49 @@ static int ath10k_pci_init_config(struct ath10k *ar)
1697 return 0; 1714 return 0;
1698} 1715}
1699 1716
1717static int ath10k_pci_alloc_ce(struct ath10k *ar)
1718{
1719 int i, ret;
1720
1721 for (i = 0; i < CE_COUNT; i++) {
1722 ret = ath10k_ce_alloc_pipe(ar, i, &host_ce_config_wlan[i]);
1723 if (ret) {
1724 ath10k_err("failed to allocate copy engine pipe %d: %d\n",
1725 i, ret);
1726 return ret;
1727 }
1728 }
1700 1729
1730 return 0;
1731}
1732
1733static void ath10k_pci_free_ce(struct ath10k *ar)
1734{
1735 int i;
1736
1737 for (i = 0; i < CE_COUNT; i++)
1738 ath10k_ce_free_pipe(ar, i);
1739}
1701 1740
1702static int ath10k_pci_ce_init(struct ath10k *ar) 1741static int ath10k_pci_ce_init(struct ath10k *ar)
1703{ 1742{
1704 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1743 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1705 struct ath10k_pci_pipe *pipe_info; 1744 struct ath10k_pci_pipe *pipe_info;
1706 const struct ce_attr *attr; 1745 const struct ce_attr *attr;
1707 int pipe_num; 1746 int pipe_num, ret;
1708 1747
1709 for (pipe_num = 0; pipe_num < CE_COUNT; pipe_num++) { 1748 for (pipe_num = 0; pipe_num < CE_COUNT; pipe_num++) {
1710 pipe_info = &ar_pci->pipe_info[pipe_num]; 1749 pipe_info = &ar_pci->pipe_info[pipe_num];
1750 pipe_info->ce_hdl = &ar_pci->ce_states[pipe_num];
1711 pipe_info->pipe_num = pipe_num; 1751 pipe_info->pipe_num = pipe_num;
1712 pipe_info->hif_ce_state = ar; 1752 pipe_info->hif_ce_state = ar;
1713 attr = &host_ce_config_wlan[pipe_num]; 1753 attr = &host_ce_config_wlan[pipe_num];
1714 1754
1715 pipe_info->ce_hdl = ath10k_ce_init(ar, pipe_num, attr); 1755 ret = ath10k_ce_init_pipe(ar, pipe_num, attr);
1716 if (pipe_info->ce_hdl == NULL) { 1756 if (ret) {
1717 ath10k_err("failed to initialize CE for pipe: %d\n", 1757 ath10k_err("failed to initialize copy engine pipe %d: %d\n",
1718 pipe_num); 1758 pipe_num, ret);
1719 1759 return ret;
1720 /* It is safe to call it here. It checks if ce_hdl is
1721 * valid for each pipe */
1722 ath10k_pci_ce_deinit(ar);
1723 return -1;
1724 } 1760 }
1725 1761
1726 if (pipe_num == CE_COUNT - 1) { 1762 if (pipe_num == CE_COUNT - 1) {
@@ -1741,16 +1777,15 @@ static int ath10k_pci_ce_init(struct ath10k *ar)
1741static void ath10k_pci_fw_interrupt_handler(struct ath10k *ar) 1777static void ath10k_pci_fw_interrupt_handler(struct ath10k *ar)
1742{ 1778{
1743 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 1779 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1744 u32 fw_indicator_address, fw_indicator; 1780 u32 fw_indicator;
1745 1781
1746 ath10k_pci_wake(ar); 1782 ath10k_pci_wake(ar);
1747 1783
1748 fw_indicator_address = ar_pci->fw_indicator_address; 1784 fw_indicator = ath10k_pci_read32(ar, FW_INDICATOR_ADDRESS);
1749 fw_indicator = ath10k_pci_read32(ar, fw_indicator_address);
1750 1785
1751 if (fw_indicator & FW_IND_EVENT_PENDING) { 1786 if (fw_indicator & FW_IND_EVENT_PENDING) {
1752 /* ACK: clear Target-side pending event */ 1787 /* ACK: clear Target-side pending event */
1753 ath10k_pci_write32(ar, fw_indicator_address, 1788 ath10k_pci_write32(ar, FW_INDICATOR_ADDRESS,
1754 fw_indicator & ~FW_IND_EVENT_PENDING); 1789 fw_indicator & ~FW_IND_EVENT_PENDING);
1755 1790
1756 if (ar_pci->started) { 1791 if (ar_pci->started) {
@@ -1769,11 +1804,10 @@ static void ath10k_pci_fw_interrupt_handler(struct ath10k *ar)
1769 1804
1770static int ath10k_pci_warm_reset(struct ath10k *ar) 1805static int ath10k_pci_warm_reset(struct ath10k *ar)
1771{ 1806{
1772 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1773 int ret = 0; 1807 int ret = 0;
1774 u32 val; 1808 u32 val;
1775 1809
1776 ath10k_dbg(ATH10K_DBG_BOOT, "boot performing warm chip reset\n"); 1810 ath10k_dbg(ATH10K_DBG_BOOT, "boot warm reset\n");
1777 1811
1778 ret = ath10k_do_pci_wake(ar); 1812 ret = ath10k_do_pci_wake(ar);
1779 if (ret) { 1813 if (ret) {
@@ -1801,7 +1835,7 @@ static int ath10k_pci_warm_reset(struct ath10k *ar)
1801 msleep(100); 1835 msleep(100);
1802 1836
1803 /* clear fw indicator */ 1837 /* clear fw indicator */
1804 ath10k_pci_write32(ar, ar_pci->fw_indicator_address, 0); 1838 ath10k_pci_write32(ar, FW_INDICATOR_ADDRESS, 0);
1805 1839
1806 /* clear target LF timer interrupts */ 1840 /* clear target LF timer interrupts */
1807 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS + 1841 val = ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS +
@@ -1934,7 +1968,9 @@ static int __ath10k_pci_hif_power_up(struct ath10k *ar, bool cold_reset)
1934 irq_mode = "legacy"; 1968 irq_mode = "legacy";
1935 1969
1936 if (!test_bit(ATH10K_FLAG_FIRST_BOOT_DONE, &ar->dev_flags)) 1970 if (!test_bit(ATH10K_FLAG_FIRST_BOOT_DONE, &ar->dev_flags))
1937 ath10k_info("pci irq %s\n", irq_mode); 1971 ath10k_info("pci irq %s irq_mode %d reset_mode %d\n",
1972 irq_mode, ath10k_pci_irq_mode,
1973 ath10k_pci_reset_mode);
1938 1974
1939 return 0; 1975 return 0;
1940 1976
@@ -1956,6 +1992,8 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar)
1956{ 1992{
1957 int ret; 1993 int ret;
1958 1994
1995 ath10k_dbg(ATH10K_DBG_BOOT, "boot hif power up\n");
1996
1959 /* 1997 /*
1960 * Hardware CUS232 version 2 has some issues with cold reset and the 1998 * Hardware CUS232 version 2 has some issues with cold reset and the
1961 * preferred (and safer) way to perform a device reset is through a 1999 * preferred (and safer) way to perform a device reset is through a
@@ -1966,9 +2004,14 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar)
1966 */ 2004 */
1967 ret = __ath10k_pci_hif_power_up(ar, false); 2005 ret = __ath10k_pci_hif_power_up(ar, false);
1968 if (ret) { 2006 if (ret) {
1969 ath10k_warn("failed to power up target using warm reset (%d), trying cold reset\n", 2007 ath10k_warn("failed to power up target using warm reset: %d\n",
1970 ret); 2008 ret);
1971 2009
2010 if (ath10k_pci_reset_mode == ATH10K_PCI_RESET_WARM_ONLY)
2011 return ret;
2012
2013 ath10k_warn("trying cold reset\n");
2014
1972 ret = __ath10k_pci_hif_power_up(ar, true); 2015 ret = __ath10k_pci_hif_power_up(ar, true);
1973 if (ret) { 2016 if (ret) {
1974 ath10k_err("failed to power up target using cold reset too (%d)\n", 2017 ath10k_err("failed to power up target using cold reset too (%d)\n",
@@ -1984,12 +2027,14 @@ static void ath10k_pci_hif_power_down(struct ath10k *ar)
1984{ 2027{
1985 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2028 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
1986 2029
2030 ath10k_dbg(ATH10K_DBG_BOOT, "boot hif power down\n");
2031
1987 ath10k_pci_free_early_irq(ar); 2032 ath10k_pci_free_early_irq(ar);
1988 ath10k_pci_kill_tasklet(ar); 2033 ath10k_pci_kill_tasklet(ar);
1989 ath10k_pci_deinit_irq(ar); 2034 ath10k_pci_deinit_irq(ar);
2035 ath10k_pci_ce_deinit(ar);
1990 ath10k_pci_warm_reset(ar); 2036 ath10k_pci_warm_reset(ar);
1991 2037
1992 ath10k_pci_ce_deinit(ar);
1993 if (!test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features)) 2038 if (!test_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features))
1994 ath10k_do_pci_sleep(ar); 2039 ath10k_do_pci_sleep(ar);
1995} 2040}
@@ -2137,7 +2182,6 @@ static irqreturn_t ath10k_pci_interrupt_handler(int irq, void *arg)
2137static void ath10k_pci_early_irq_tasklet(unsigned long data) 2182static void ath10k_pci_early_irq_tasklet(unsigned long data)
2138{ 2183{
2139 struct ath10k *ar = (struct ath10k *)data; 2184 struct ath10k *ar = (struct ath10k *)data;
2140 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
2141 u32 fw_ind; 2185 u32 fw_ind;
2142 int ret; 2186 int ret;
2143 2187
@@ -2148,9 +2192,9 @@ static void ath10k_pci_early_irq_tasklet(unsigned long data)
2148 return; 2192 return;
2149 } 2193 }
2150 2194
2151 fw_ind = ath10k_pci_read32(ar, ar_pci->fw_indicator_address); 2195 fw_ind = ath10k_pci_read32(ar, FW_INDICATOR_ADDRESS);
2152 if (fw_ind & FW_IND_EVENT_PENDING) { 2196 if (fw_ind & FW_IND_EVENT_PENDING) {
2153 ath10k_pci_write32(ar, ar_pci->fw_indicator_address, 2197 ath10k_pci_write32(ar, FW_INDICATOR_ADDRESS,
2154 fw_ind & ~FW_IND_EVENT_PENDING); 2198 fw_ind & ~FW_IND_EVENT_PENDING);
2155 2199
2156 /* Some structures are unavailable during early boot or at 2200 /* Some structures are unavailable during early boot or at
@@ -2385,33 +2429,50 @@ static int ath10k_pci_deinit_irq(struct ath10k *ar)
2385static int ath10k_pci_wait_for_target_init(struct ath10k *ar) 2429static int ath10k_pci_wait_for_target_init(struct ath10k *ar)
2386{ 2430{
2387 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); 2431 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
2388 int wait_limit = 300; /* 3 sec */ 2432 unsigned long timeout;
2389 int ret; 2433 int ret;
2434 u32 val;
2435
2436 ath10k_dbg(ATH10K_DBG_BOOT, "boot waiting target to initialise\n");
2390 2437
2391 ret = ath10k_pci_wake(ar); 2438 ret = ath10k_pci_wake(ar);
2392 if (ret) { 2439 if (ret) {
2393 ath10k_err("failed to wake up target: %d\n", ret); 2440 ath10k_err("failed to wake up target for init: %d\n", ret);
2394 return ret; 2441 return ret;
2395 } 2442 }
2396 2443
2397 while (wait_limit-- && 2444 timeout = jiffies + msecs_to_jiffies(ATH10K_PCI_TARGET_WAIT);
2398 !(ioread32(ar_pci->mem + FW_INDICATOR_ADDRESS) & 2445
2399 FW_IND_INITIALIZED)) { 2446 do {
2447 val = ath10k_pci_read32(ar, FW_INDICATOR_ADDRESS);
2448
2449 ath10k_dbg(ATH10K_DBG_BOOT, "boot target indicator %x\n", val);
2450
2451 /* target should never return this */
2452 if (val == 0xffffffff)
2453 continue;
2454
2455 if (val & FW_IND_INITIALIZED)
2456 break;
2457
2400 if (ar_pci->num_msi_intrs == 0) 2458 if (ar_pci->num_msi_intrs == 0)
2401 /* Fix potential race by repeating CORE_BASE writes */ 2459 /* Fix potential race by repeating CORE_BASE writes */
2402 iowrite32(PCIE_INTR_FIRMWARE_MASK | 2460 ath10k_pci_soc_write32(ar, PCIE_INTR_ENABLE_ADDRESS,
2403 PCIE_INTR_CE_MASK_ALL, 2461 PCIE_INTR_FIRMWARE_MASK |
2404 ar_pci->mem + (SOC_CORE_BASE_ADDRESS | 2462 PCIE_INTR_CE_MASK_ALL);
2405 PCIE_INTR_ENABLE_ADDRESS)); 2463
2406 mdelay(10); 2464 mdelay(10);
2407 } 2465 } while (time_before(jiffies, timeout));
2408 2466
2409 if (wait_limit < 0) { 2467 if (val == 0xffffffff || !(val & FW_IND_INITIALIZED)) {
2410 ath10k_err("target stalled\n"); 2468 ath10k_err("failed to receive initialized event from target: %08x\n",
2411 ret = -EIO; 2469 val);
2470 ret = -ETIMEDOUT;
2412 goto out; 2471 goto out;
2413 } 2472 }
2414 2473
2474 ath10k_dbg(ATH10K_DBG_BOOT, "boot target initialised\n");
2475
2415out: 2476out:
2416 ath10k_pci_sleep(ar); 2477 ath10k_pci_sleep(ar);
2417 return ret; 2478 return ret;
@@ -2422,6 +2483,8 @@ static int ath10k_pci_cold_reset(struct ath10k *ar)
2422 int i, ret; 2483 int i, ret;
2423 u32 val; 2484 u32 val;
2424 2485
2486 ath10k_dbg(ATH10K_DBG_BOOT, "boot cold reset\n");
2487
2425 ret = ath10k_do_pci_wake(ar); 2488 ret = ath10k_do_pci_wake(ar);
2426 if (ret) { 2489 if (ret) {
2427 ath10k_err("failed to wake up target: %d\n", 2490 ath10k_err("failed to wake up target: %d\n",
@@ -2453,6 +2516,9 @@ static int ath10k_pci_cold_reset(struct ath10k *ar)
2453 } 2516 }
2454 2517
2455 ath10k_do_pci_sleep(ar); 2518 ath10k_do_pci_sleep(ar);
2519
2520 ath10k_dbg(ATH10K_DBG_BOOT, "boot cold reset complete\n");
2521
2456 return 0; 2522 return 0;
2457} 2523}
2458 2524
@@ -2484,7 +2550,7 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
2484 struct ath10k_pci *ar_pci; 2550 struct ath10k_pci *ar_pci;
2485 u32 lcr_val, chip_id; 2551 u32 lcr_val, chip_id;
2486 2552
2487 ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__); 2553 ath10k_dbg(ATH10K_DBG_PCI, "pci probe\n");
2488 2554
2489 ar_pci = kzalloc(sizeof(*ar_pci), GFP_KERNEL); 2555 ar_pci = kzalloc(sizeof(*ar_pci), GFP_KERNEL);
2490 if (ar_pci == NULL) 2556 if (ar_pci == NULL)
@@ -2503,7 +2569,7 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
2503 goto err_ar_pci; 2569 goto err_ar_pci;
2504 } 2570 }
2505 2571
2506 if (ath10k_target_ps) 2572 if (ath10k_pci_target_ps)
2507 set_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features); 2573 set_bit(ATH10K_PCI_FEATURE_SOC_POWER_SAVE, ar_pci->features);
2508 2574
2509 ath10k_pci_dump_features(ar_pci); 2575 ath10k_pci_dump_features(ar_pci);
@@ -2516,7 +2582,6 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
2516 } 2582 }
2517 2583
2518 ar_pci->ar = ar; 2584 ar_pci->ar = ar;
2519 ar_pci->fw_indicator_address = FW_INDICATOR_ADDRESS;
2520 atomic_set(&ar_pci->keep_awake_count, 0); 2585 atomic_set(&ar_pci->keep_awake_count, 0);
2521 2586
2522 pci_set_drvdata(pdev, ar); 2587 pci_set_drvdata(pdev, ar);
@@ -2594,16 +2659,24 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
2594 2659
2595 ath10k_do_pci_sleep(ar); 2660 ath10k_do_pci_sleep(ar);
2596 2661
2662 ret = ath10k_pci_alloc_ce(ar);
2663 if (ret) {
2664 ath10k_err("failed to allocate copy engine pipes: %d\n", ret);
2665 goto err_iomap;
2666 }
2667
2597 ath10k_dbg(ATH10K_DBG_BOOT, "boot pci_mem 0x%p\n", ar_pci->mem); 2668 ath10k_dbg(ATH10K_DBG_BOOT, "boot pci_mem 0x%p\n", ar_pci->mem);
2598 2669
2599 ret = ath10k_core_register(ar, chip_id); 2670 ret = ath10k_core_register(ar, chip_id);
2600 if (ret) { 2671 if (ret) {
2601 ath10k_err("failed to register driver core: %d\n", ret); 2672 ath10k_err("failed to register driver core: %d\n", ret);
2602 goto err_iomap; 2673 goto err_free_ce;
2603 } 2674 }
2604 2675
2605 return 0; 2676 return 0;
2606 2677
2678err_free_ce:
2679 ath10k_pci_free_ce(ar);
2607err_iomap: 2680err_iomap:
2608 pci_iounmap(pdev, mem); 2681 pci_iounmap(pdev, mem);
2609err_master: 2682err_master:
@@ -2626,7 +2699,7 @@ static void ath10k_pci_remove(struct pci_dev *pdev)
2626 struct ath10k *ar = pci_get_drvdata(pdev); 2699 struct ath10k *ar = pci_get_drvdata(pdev);
2627 struct ath10k_pci *ar_pci; 2700 struct ath10k_pci *ar_pci;
2628 2701
2629 ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__); 2702 ath10k_dbg(ATH10K_DBG_PCI, "pci remove\n");
2630 2703
2631 if (!ar) 2704 if (!ar)
2632 return; 2705 return;
@@ -2639,6 +2712,7 @@ static void ath10k_pci_remove(struct pci_dev *pdev)
2639 tasklet_kill(&ar_pci->msi_fw_err); 2712 tasklet_kill(&ar_pci->msi_fw_err);
2640 2713
2641 ath10k_core_unregister(ar); 2714 ath10k_core_unregister(ar);
2715 ath10k_pci_free_ce(ar);
2642 2716
2643 pci_iounmap(pdev, ar_pci->mem); 2717 pci_iounmap(pdev, ar_pci->mem);
2644 pci_release_region(pdev, BAR_NUM); 2718 pci_release_region(pdev, BAR_NUM);
@@ -2680,6 +2754,5 @@ module_exit(ath10k_pci_exit);
2680MODULE_AUTHOR("Qualcomm Atheros"); 2754MODULE_AUTHOR("Qualcomm Atheros");
2681MODULE_DESCRIPTION("Driver support for Atheros QCA988X PCIe devices"); 2755MODULE_DESCRIPTION("Driver support for Atheros QCA988X PCIe devices");
2682MODULE_LICENSE("Dual BSD/GPL"); 2756MODULE_LICENSE("Dual BSD/GPL");
2683MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_FW_FILE); 2757MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_FW_2_FILE);
2684MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_OTP_FILE);
2685MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_BOARD_DATA_FILE); 2758MODULE_FIRMWARE(QCA988X_HW_2_0_FW_DIR "/" QCA988X_HW_2_0_BOARD_DATA_FILE);
diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h
index b43fdb4f7319..dfdebb4157aa 100644
--- a/drivers/net/wireless/ath/ath10k/pci.h
+++ b/drivers/net/wireless/ath/ath10k/pci.h
@@ -189,9 +189,6 @@ struct ath10k_pci {
189 189
190 struct ath10k_hif_cb msg_callbacks_current; 190 struct ath10k_hif_cb msg_callbacks_current;
191 191
192 /* Target address used to signal a pending firmware event */
193 u32 fw_indicator_address;
194
195 /* Copy Engine used for Diagnostic Accesses */ 192 /* Copy Engine used for Diagnostic Accesses */
196 struct ath10k_ce_pipe *ce_diag; 193 struct ath10k_ce_pipe *ce_diag;
197 194
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
index 0541dd939ce9..82669a77e553 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -100,189 +100,6 @@ exit:
100 wake_up(&htt->empty_tx_wq); 100 wake_up(&htt->empty_tx_wq);
101} 101}
102 102
103static const u8 rx_legacy_rate_idx[] = {
104 3, /* 0x00 - 11Mbps */
105 2, /* 0x01 - 5.5Mbps */
106 1, /* 0x02 - 2Mbps */
107 0, /* 0x03 - 1Mbps */
108 3, /* 0x04 - 11Mbps */
109 2, /* 0x05 - 5.5Mbps */
110 1, /* 0x06 - 2Mbps */
111 0, /* 0x07 - 1Mbps */
112 10, /* 0x08 - 48Mbps */
113 8, /* 0x09 - 24Mbps */
114 6, /* 0x0A - 12Mbps */
115 4, /* 0x0B - 6Mbps */
116 11, /* 0x0C - 54Mbps */
117 9, /* 0x0D - 36Mbps */
118 7, /* 0x0E - 18Mbps */
119 5, /* 0x0F - 9Mbps */
120};
121
122static void process_rx_rates(struct ath10k *ar, struct htt_rx_info *info,
123 enum ieee80211_band band,
124 struct ieee80211_rx_status *status)
125{
126 u8 cck, rate, rate_idx, bw, sgi, mcs, nss;
127 u8 info0 = info->rate.info0;
128 u32 info1 = info->rate.info1;
129 u32 info2 = info->rate.info2;
130 u8 preamble = 0;
131
132 /* Check if valid fields */
133 if (!(info0 & HTT_RX_INDICATION_INFO0_START_VALID))
134 return;
135
136 preamble = MS(info1, HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE);
137
138 switch (preamble) {
139 case HTT_RX_LEGACY:
140 cck = info0 & HTT_RX_INDICATION_INFO0_LEGACY_RATE_CCK;
141 rate = MS(info0, HTT_RX_INDICATION_INFO0_LEGACY_RATE);
142 rate_idx = 0;
143
144 if (rate < 0x08 || rate > 0x0F)
145 break;
146
147 switch (band) {
148 case IEEE80211_BAND_2GHZ:
149 if (cck)
150 rate &= ~BIT(3);
151 rate_idx = rx_legacy_rate_idx[rate];
152 break;
153 case IEEE80211_BAND_5GHZ:
154 rate_idx = rx_legacy_rate_idx[rate];
155 /* We are using same rate table registering
156 HW - ath10k_rates[]. In case of 5GHz skip
157 CCK rates, so -4 here */
158 rate_idx -= 4;
159 break;
160 default:
161 break;
162 }
163
164 status->rate_idx = rate_idx;
165 break;
166 case HTT_RX_HT:
167 case HTT_RX_HT_WITH_TXBF:
168 /* HT-SIG - Table 20-11 in info1 and info2 */
169 mcs = info1 & 0x1F;
170 nss = mcs >> 3;
171 bw = (info1 >> 7) & 1;
172 sgi = (info2 >> 7) & 1;
173
174 status->rate_idx = mcs;
175 status->flag |= RX_FLAG_HT;
176 if (sgi)
177 status->flag |= RX_FLAG_SHORT_GI;
178 if (bw)
179 status->flag |= RX_FLAG_40MHZ;
180 break;
181 case HTT_RX_VHT:
182 case HTT_RX_VHT_WITH_TXBF:
183 /* VHT-SIG-A1 in info 1, VHT-SIG-A2 in info2
184 TODO check this */
185 mcs = (info2 >> 4) & 0x0F;
186 nss = ((info1 >> 10) & 0x07) + 1;
187 bw = info1 & 3;
188 sgi = info2 & 1;
189
190 status->rate_idx = mcs;
191 status->vht_nss = nss;
192
193 if (sgi)
194 status->flag |= RX_FLAG_SHORT_GI;
195
196 switch (bw) {
197 /* 20MHZ */
198 case 0:
199 break;
200 /* 40MHZ */
201 case 1:
202 status->flag |= RX_FLAG_40MHZ;
203 break;
204 /* 80MHZ */
205 case 2:
206 status->vht_flag |= RX_VHT_FLAG_80MHZ;
207 }
208
209 status->flag |= RX_FLAG_VHT;
210 break;
211 default:
212 break;
213 }
214}
215
216void ath10k_process_rx(struct ath10k *ar, struct htt_rx_info *info)
217{
218 struct ieee80211_rx_status *status;
219 struct ieee80211_channel *ch;
220 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)info->skb->data;
221
222 status = IEEE80211_SKB_RXCB(info->skb);
223 memset(status, 0, sizeof(*status));
224
225 if (info->encrypt_type != HTT_RX_MPDU_ENCRYPT_NONE) {
226 status->flag |= RX_FLAG_DECRYPTED | RX_FLAG_IV_STRIPPED |
227 RX_FLAG_MMIC_STRIPPED;
228 hdr->frame_control = __cpu_to_le16(
229 __le16_to_cpu(hdr->frame_control) &
230 ~IEEE80211_FCTL_PROTECTED);
231 }
232
233 if (info->mic_err)
234 status->flag |= RX_FLAG_MMIC_ERROR;
235
236 if (info->fcs_err)
237 status->flag |= RX_FLAG_FAILED_FCS_CRC;
238
239 if (info->amsdu_more)
240 status->flag |= RX_FLAG_AMSDU_MORE;
241
242 status->signal = info->signal;
243
244 spin_lock_bh(&ar->data_lock);
245 ch = ar->scan_channel;
246 if (!ch)
247 ch = ar->rx_channel;
248 spin_unlock_bh(&ar->data_lock);
249
250 if (!ch) {
251 ath10k_warn("no channel configured; ignoring frame!\n");
252 dev_kfree_skb_any(info->skb);
253 return;
254 }
255
256 process_rx_rates(ar, info, ch->band, status);
257 status->band = ch->band;
258 status->freq = ch->center_freq;
259
260 if (info->rate.info0 & HTT_RX_INDICATION_INFO0_END_VALID) {
261 /* TSF available only in 32-bit */
262 status->mactime = info->tsf & 0xffffffff;
263 status->flag |= RX_FLAG_MACTIME_END;
264 }
265
266 ath10k_dbg(ATH10K_DBG_DATA,
267 "rx skb %p len %u %s%s%s%s%s %srate_idx %u vht_nss %u freq %u band %u flag 0x%x fcs-err %i\n",
268 info->skb,
269 info->skb->len,
270 status->flag == 0 ? "legacy" : "",
271 status->flag & RX_FLAG_HT ? "ht" : "",
272 status->flag & RX_FLAG_VHT ? "vht" : "",
273 status->flag & RX_FLAG_40MHZ ? "40" : "",
274 status->vht_flag & RX_VHT_FLAG_80MHZ ? "80" : "",
275 status->flag & RX_FLAG_SHORT_GI ? "sgi " : "",
276 status->rate_idx,
277 status->vht_nss,
278 status->freq,
279 status->band, status->flag, info->fcs_err);
280 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "rx skb: ",
281 info->skb->data, info->skb->len);
282
283 ieee80211_rx(ar->hw, info->skb);
284}
285
286struct ath10k_peer *ath10k_peer_find(struct ath10k *ar, int vdev_id, 103struct ath10k_peer *ath10k_peer_find(struct ath10k *ar, int vdev_id,
287 const u8 *addr) 104 const u8 *addr)
288{ 105{
diff --git a/drivers/net/wireless/ath/ath10k/txrx.h b/drivers/net/wireless/ath/ath10k/txrx.h
index 356dc9c04c9e..aee3e20058f8 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.h
+++ b/drivers/net/wireless/ath/ath10k/txrx.h
@@ -21,7 +21,6 @@
21 21
22void ath10k_txrx_tx_unref(struct ath10k_htt *htt, 22void ath10k_txrx_tx_unref(struct ath10k_htt *htt,
23 const struct htt_tx_done *tx_done); 23 const struct htt_tx_done *tx_done);
24void ath10k_process_rx(struct ath10k *ar, struct htt_rx_info *info);
25 24
26struct ath10k_peer *ath10k_peer_find(struct ath10k *ar, int vdev_id, 25struct ath10k_peer *ath10k_peer_find(struct ath10k *ar, int vdev_id,
27 const u8 *addr); 26 const u8 *addr);
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
index cb1f7b5bcf4c..fe4d5f1c672f 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -1362,13 +1362,10 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
1362 struct sk_buff *bcn; 1362 struct sk_buff *bcn;
1363 int ret, vdev_id = 0; 1363 int ret, vdev_id = 0;
1364 1364
1365 ath10k_dbg(ATH10K_DBG_MGMT, "WMI_HOST_SWBA_EVENTID\n");
1366
1367 ev = (struct wmi_host_swba_event *)skb->data; 1365 ev = (struct wmi_host_swba_event *)skb->data;
1368 map = __le32_to_cpu(ev->vdev_map); 1366 map = __le32_to_cpu(ev->vdev_map);
1369 1367
1370 ath10k_dbg(ATH10K_DBG_MGMT, "host swba:\n" 1368 ath10k_dbg(ATH10K_DBG_MGMT, "mgmt swba vdev_map 0x%x\n",
1371 "-vdev map 0x%x\n",
1372 ev->vdev_map); 1369 ev->vdev_map);
1373 1370
1374 for (; map; map >>= 1, vdev_id++) { 1371 for (; map; map >>= 1, vdev_id++) {
@@ -1385,12 +1382,7 @@ static void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
1385 bcn_info = &ev->bcn_info[i]; 1382 bcn_info = &ev->bcn_info[i];
1386 1383
1387 ath10k_dbg(ATH10K_DBG_MGMT, 1384 ath10k_dbg(ATH10K_DBG_MGMT,
1388 "-bcn_info[%d]:\n" 1385 "mgmt event bcn_info %d tim_len %d mcast %d changed %d num_ps_pending %d bitmap 0x%08x%08x%08x%08x\n",
1389 "--tim_len %d\n"
1390 "--tim_mcast %d\n"
1391 "--tim_changed %d\n"
1392 "--tim_num_ps_pending %d\n"
1393 "--tim_bitmap 0x%08x%08x%08x%08x\n",
1394 i, 1386 i,
1395 __le32_to_cpu(bcn_info->tim_info.tim_len), 1387 __le32_to_cpu(bcn_info->tim_info.tim_len),
1396 __le32_to_cpu(bcn_info->tim_info.tim_mcast), 1388 __le32_to_cpu(bcn_info->tim_info.tim_mcast),
@@ -2393,8 +2385,9 @@ int ath10k_wmi_connect_htc_service(struct ath10k *ar)
2393 return 0; 2385 return 0;
2394} 2386}
2395 2387
2396int ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g, 2388static int ath10k_wmi_main_pdev_set_regdomain(struct ath10k *ar, u16 rd,
2397 u16 rd5g, u16 ctl2g, u16 ctl5g) 2389 u16 rd2g, u16 rd5g, u16 ctl2g,
2390 u16 ctl5g)
2398{ 2391{
2399 struct wmi_pdev_set_regdomain_cmd *cmd; 2392 struct wmi_pdev_set_regdomain_cmd *cmd;
2400 struct sk_buff *skb; 2393 struct sk_buff *skb;
@@ -2418,6 +2411,46 @@ int ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g,
2418 ar->wmi.cmd->pdev_set_regdomain_cmdid); 2411 ar->wmi.cmd->pdev_set_regdomain_cmdid);
2419} 2412}
2420 2413
2414static int ath10k_wmi_10x_pdev_set_regdomain(struct ath10k *ar, u16 rd,
2415 u16 rd2g, u16 rd5g,
2416 u16 ctl2g, u16 ctl5g,
2417 enum wmi_dfs_region dfs_reg)
2418{
2419 struct wmi_pdev_set_regdomain_cmd_10x *cmd;
2420 struct sk_buff *skb;
2421
2422 skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
2423 if (!skb)
2424 return -ENOMEM;
2425
2426 cmd = (struct wmi_pdev_set_regdomain_cmd_10x *)skb->data;
2427 cmd->reg_domain = __cpu_to_le32(rd);
2428 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
2429 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
2430 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
2431 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
2432 cmd->dfs_domain = __cpu_to_le32(dfs_reg);
2433
2434 ath10k_dbg(ATH10K_DBG_WMI,
2435 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n",
2436 rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg);
2437
2438 return ath10k_wmi_cmd_send(ar, skb,
2439 ar->wmi.cmd->pdev_set_regdomain_cmdid);
2440}
2441
2442int ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g,
2443 u16 rd5g, u16 ctl2g, u16 ctl5g,
2444 enum wmi_dfs_region dfs_reg)
2445{
2446 if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features))
2447 return ath10k_wmi_10x_pdev_set_regdomain(ar, rd, rd2g, rd5g,
2448 ctl2g, ctl5g, dfs_reg);
2449 else
2450 return ath10k_wmi_main_pdev_set_regdomain(ar, rd, rd2g, rd5g,
2451 ctl2g, ctl5g);
2452}
2453
2421int ath10k_wmi_pdev_set_channel(struct ath10k *ar, 2454int ath10k_wmi_pdev_set_channel(struct ath10k *ar,
2422 const struct wmi_channel_arg *arg) 2455 const struct wmi_channel_arg *arg)
2423{ 2456{
@@ -3456,8 +3489,9 @@ int ath10k_wmi_peer_assoc(struct ath10k *ar,
3456 __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set); 3489 __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
3457 3490
3458 ath10k_dbg(ATH10K_DBG_WMI, 3491 ath10k_dbg(ATH10K_DBG_WMI,
3459 "wmi peer assoc vdev %d addr %pM\n", 3492 "wmi peer assoc vdev %d addr %pM (%s)\n",
3460 arg->vdev_id, arg->addr); 3493 arg->vdev_id, arg->addr,
3494 arg->peer_reassoc ? "reassociate" : "new");
3461 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_assoc_cmdid); 3495 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->peer_assoc_cmdid);
3462} 3496}
3463 3497
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
index 4fcc96aa9513..ae838221af65 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -198,16 +198,6 @@ struct wmi_mac_addr {
198 } __packed; 198 } __packed;
199} __packed; 199} __packed;
200 200
201/* macro to convert MAC address from WMI word format to char array */
202#define WMI_MAC_ADDR_TO_CHAR_ARRAY(pwmi_mac_addr, c_macaddr) do { \
203 (c_macaddr)[0] = ((pwmi_mac_addr)->word0) & 0xff; \
204 (c_macaddr)[1] = (((pwmi_mac_addr)->word0) >> 8) & 0xff; \
205 (c_macaddr)[2] = (((pwmi_mac_addr)->word0) >> 16) & 0xff; \
206 (c_macaddr)[3] = (((pwmi_mac_addr)->word0) >> 24) & 0xff; \
207 (c_macaddr)[4] = ((pwmi_mac_addr)->word1) & 0xff; \
208 (c_macaddr)[5] = (((pwmi_mac_addr)->word1) >> 8) & 0xff; \
209 } while (0)
210
211struct wmi_cmd_map { 201struct wmi_cmd_map {
212 u32 init_cmdid; 202 u32 init_cmdid;
213 u32 start_scan_cmdid; 203 u32 start_scan_cmdid;
@@ -2185,6 +2175,31 @@ struct wmi_pdev_set_regdomain_cmd {
2185 __le32 conformance_test_limit_5G; 2175 __le32 conformance_test_limit_5G;
2186} __packed; 2176} __packed;
2187 2177
2178enum wmi_dfs_region {
2179 /* Uninitialized dfs domain */
2180 WMI_UNINIT_DFS_DOMAIN = 0,
2181
2182 /* FCC3 dfs domain */
2183 WMI_FCC_DFS_DOMAIN = 1,
2184
2185 /* ETSI dfs domain */
2186 WMI_ETSI_DFS_DOMAIN = 2,
2187
2188 /*Japan dfs domain */
2189 WMI_MKK4_DFS_DOMAIN = 3,
2190};
2191
2192struct wmi_pdev_set_regdomain_cmd_10x {
2193 __le32 reg_domain;
2194 __le32 reg_domain_2G;
2195 __le32 reg_domain_5G;
2196 __le32 conformance_test_limit_2G;
2197 __le32 conformance_test_limit_5G;
2198
2199 /* dfs domain from wmi_dfs_region */
2200 __le32 dfs_domain;
2201} __packed;
2202
2188/* Command to set/unset chip in quiet mode */ 2203/* Command to set/unset chip in quiet mode */
2189struct wmi_pdev_set_quiet_cmd { 2204struct wmi_pdev_set_quiet_cmd {
2190 /* period in TUs */ 2205 /* period in TUs */
@@ -2210,6 +2225,19 @@ enum ath10k_protmode {
2210 ATH10K_PROT_RTSCTS = 2, /* RTS-CTS */ 2225 ATH10K_PROT_RTSCTS = 2, /* RTS-CTS */
2211}; 2226};
2212 2227
2228enum wmi_rtscts_profile {
2229 WMI_RTSCTS_FOR_NO_RATESERIES = 0,
2230 WMI_RTSCTS_FOR_SECOND_RATESERIES,
2231 WMI_RTSCTS_ACROSS_SW_RETRIES
2232};
2233
2234#define WMI_RTSCTS_ENABLED 1
2235#define WMI_RTSCTS_SET_MASK 0x0f
2236#define WMI_RTSCTS_SET_LSB 0
2237
2238#define WMI_RTSCTS_PROFILE_MASK 0xf0
2239#define WMI_RTSCTS_PROFILE_LSB 4
2240
2213enum wmi_beacon_gen_mode { 2241enum wmi_beacon_gen_mode {
2214 WMI_BEACON_STAGGERED_MODE = 0, 2242 WMI_BEACON_STAGGERED_MODE = 0,
2215 WMI_BEACON_BURST_MODE = 1 2243 WMI_BEACON_BURST_MODE = 1
@@ -2682,6 +2710,9 @@ struct wal_dbg_tx_stats {
2682 /* wal pdev resets */ 2710 /* wal pdev resets */
2683 __le32 pdev_resets; 2711 __le32 pdev_resets;
2684 2712
2713 /* frames dropped due to non-availability of stateless TIDs */
2714 __le32 stateless_tid_alloc_failure;
2715
2685 __le32 phy_underrun; 2716 __le32 phy_underrun;
2686 2717
2687 /* MPDU is more than txop limit */ 2718 /* MPDU is more than txop limit */
@@ -2738,13 +2769,21 @@ enum wmi_stats_id {
2738 WMI_REQUEST_AP_STAT = 0x02 2769 WMI_REQUEST_AP_STAT = 0x02
2739}; 2770};
2740 2771
2772struct wlan_inst_rssi_args {
2773 __le16 cfg_retry_count;
2774 __le16 retry_count;
2775};
2776
2741struct wmi_request_stats_cmd { 2777struct wmi_request_stats_cmd {
2742 __le32 stats_id; 2778 __le32 stats_id;
2743 2779
2744 /* 2780 __le32 vdev_id;
2745 * Space to add parameters like 2781
2746 * peer mac addr 2782 /* peer MAC address */
2747 */ 2783 struct wmi_mac_addr peer_macaddr;
2784
2785 /* Instantaneous RSSI arguments */
2786 struct wlan_inst_rssi_args inst_rssi_args;
2748} __packed; 2787} __packed;
2749 2788
2750/* Suspend option */ 2789/* Suspend option */
@@ -2795,7 +2834,7 @@ struct wmi_stats_event {
2795 * PDEV statistics 2834 * PDEV statistics
2796 * TODO: add all PDEV stats here 2835 * TODO: add all PDEV stats here
2797 */ 2836 */
2798struct wmi_pdev_stats { 2837struct wmi_pdev_stats_old {
2799 __le32 chan_nf; /* Channel noise floor */ 2838 __le32 chan_nf; /* Channel noise floor */
2800 __le32 tx_frame_count; /* TX frame count */ 2839 __le32 tx_frame_count; /* TX frame count */
2801 __le32 rx_frame_count; /* RX frame count */ 2840 __le32 rx_frame_count; /* RX frame count */
@@ -2806,6 +2845,23 @@ struct wmi_pdev_stats {
2806 struct wal_dbg_stats wal; /* WAL dbg stats */ 2845 struct wal_dbg_stats wal; /* WAL dbg stats */
2807} __packed; 2846} __packed;
2808 2847
2848struct wmi_pdev_stats_10x {
2849 __le32 chan_nf; /* Channel noise floor */
2850 __le32 tx_frame_count; /* TX frame count */
2851 __le32 rx_frame_count; /* RX frame count */
2852 __le32 rx_clear_count; /* rx clear count */
2853 __le32 cycle_count; /* cycle count */
2854 __le32 phy_err_count; /* Phy error count */
2855 __le32 chan_tx_pwr; /* channel tx power */
2856 struct wal_dbg_stats wal; /* WAL dbg stats */
2857 __le32 ack_rx_bad;
2858 __le32 rts_bad;
2859 __le32 rts_good;
2860 __le32 fcs_bad;
2861 __le32 no_beacons;
2862 __le32 mib_int_count;
2863} __packed;
2864
2809/* 2865/*
2810 * VDEV statistics 2866 * VDEV statistics
2811 * TODO: add all VDEV stats here 2867 * TODO: add all VDEV stats here
@@ -2818,10 +2874,17 @@ struct wmi_vdev_stats {
2818 * peer statistics. 2874 * peer statistics.
2819 * TODO: add more stats 2875 * TODO: add more stats
2820 */ 2876 */
2821struct wmi_peer_stats { 2877struct wmi_peer_stats_old {
2878 struct wmi_mac_addr peer_macaddr;
2879 __le32 peer_rssi;
2880 __le32 peer_tx_rate;
2881} __packed;
2882
2883struct wmi_peer_stats_10x {
2822 struct wmi_mac_addr peer_macaddr; 2884 struct wmi_mac_addr peer_macaddr;
2823 __le32 peer_rssi; 2885 __le32 peer_rssi;
2824 __le32 peer_tx_rate; 2886 __le32 peer_tx_rate;
2887 __le32 peer_rx_rate;
2825} __packed; 2888} __packed;
2826 2889
2827struct wmi_vdev_create_cmd { 2890struct wmi_vdev_create_cmd {
@@ -4202,7 +4265,8 @@ int ath10k_wmi_pdev_set_channel(struct ath10k *ar,
4202int ath10k_wmi_pdev_suspend_target(struct ath10k *ar, u32 suspend_opt); 4265int ath10k_wmi_pdev_suspend_target(struct ath10k *ar, u32 suspend_opt);
4203int ath10k_wmi_pdev_resume_target(struct ath10k *ar); 4266int ath10k_wmi_pdev_resume_target(struct ath10k *ar);
4204int ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g, 4267int ath10k_wmi_pdev_set_regdomain(struct ath10k *ar, u16 rd, u16 rd2g,
4205 u16 rd5g, u16 ctl2g, u16 ctl5g); 4268 u16 rd5g, u16 ctl2g, u16 ctl5g,
4269 enum wmi_dfs_region dfs_reg);
4206int ath10k_wmi_pdev_set_param(struct ath10k *ar, u32 id, u32 value); 4270int ath10k_wmi_pdev_set_param(struct ath10k *ar, u32 id, u32 value);
4207int ath10k_wmi_cmd_init(struct ath10k *ar); 4271int ath10k_wmi_cmd_init(struct ath10k *ar);
4208int ath10k_wmi_start_scan(struct ath10k *ar, const struct wmi_start_scan_arg *); 4272int ath10k_wmi_start_scan(struct ath10k *ar, const struct wmi_start_scan_arg *);
diff --git a/drivers/net/wireless/ath/ath6kl/Kconfig b/drivers/net/wireless/ath/ath6kl/Kconfig
index e39e5860a2e9..9c125ff083f7 100644
--- a/drivers/net/wireless/ath/ath6kl/Kconfig
+++ b/drivers/net/wireless/ath/ath6kl/Kconfig
@@ -1,11 +1,19 @@
1config ATH6KL 1config ATH6KL
2 tristate "Atheros mobile chipsets support" 2 tristate "Atheros mobile chipsets support"
3 depends on CFG80211
4 ---help---
5 This module adds core support for wireless adapters based on
6 Atheros AR6003 and AR6004 chipsets. You still need separate
7 bus drivers for USB and SDIO to be able to use real devices.
8
9 If you choose to build it as a module, it will be called
10 ath6kl_core. Please note that AR6002 and AR6001 are not
11 supported by this driver.
3 12
4config ATH6KL_SDIO 13config ATH6KL_SDIO
5 tristate "Atheros ath6kl SDIO support" 14 tristate "Atheros ath6kl SDIO support"
6 depends on ATH6KL 15 depends on ATH6KL
7 depends on MMC 16 depends on MMC
8 depends on CFG80211
9 ---help--- 17 ---help---
10 This module adds support for wireless adapters based on 18 This module adds support for wireless adapters based on
11 Atheros AR6003 and AR6004 chipsets running over SDIO. If you 19 Atheros AR6003 and AR6004 chipsets running over SDIO. If you
@@ -17,25 +25,31 @@ config ATH6KL_USB
17 tristate "Atheros ath6kl USB support" 25 tristate "Atheros ath6kl USB support"
18 depends on ATH6KL 26 depends on ATH6KL
19 depends on USB 27 depends on USB
20 depends on CFG80211
21 ---help--- 28 ---help---
22 This module adds support for wireless adapters based on 29 This module adds support for wireless adapters based on
23 Atheros AR6004 chipset running over USB. This is still under 30 Atheros AR6004 chipset and chipsets based on it running over
24 implementation and it isn't functional. If you choose to 31 USB. If you choose to build it as a module, it will be
25 build it as a module, it will be called ath6kl_usb. 32 called ath6kl_usb.
26 33
27config ATH6KL_DEBUG 34config ATH6KL_DEBUG
28 bool "Atheros ath6kl debugging" 35 bool "Atheros ath6kl debugging"
29 depends on ATH6KL 36 depends on ATH6KL
30 ---help--- 37 ---help---
31 Enables debug support 38 Enables ath6kl debug support, including debug messages
39 enabled with debug_mask module parameter and debugfs
40 interface.
41
42 If unsure, say Y to make it easier to debug problems.
32 43
33config ATH6KL_TRACING 44config ATH6KL_TRACING
34 bool "Atheros ath6kl tracing support" 45 bool "Atheros ath6kl tracing support"
35 depends on ATH6KL 46 depends on ATH6KL
36 depends on EVENT_TRACING 47 depends on EVENT_TRACING
37 ---help--- 48 ---help---
38 Select this to ath6kl use tracing infrastructure. 49 Select this to ath6kl use tracing infrastructure which, for
50 example, can be enabled with help of trace-cmd. All debug
51 messages and commands are delivered to using individually
52 enablable trace points.
39 53
40 If unsure, say Y to make it easier to debug problems. 54 If unsure, say Y to make it easier to debug problems.
41 55
@@ -47,3 +61,5 @@ config ATH6KL_REGDOMAIN
47 Enabling this makes it possible to change the regdomain in 61 Enabling this makes it possible to change the regdomain in
48 the firmware. This can be only enabled if regulatory requirements 62 the firmware. This can be only enabled if regulatory requirements
49 are taken into account. 63 are taken into account.
64
65 If unsure, say N.
diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index c2c6f4604958..09285084bcd3 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -724,8 +724,9 @@ ath6kl_add_bss_if_needed(struct ath6kl_vif *vif,
724 ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, 724 ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
725 "added bss %pM to cfg80211\n", bssid); 725 "added bss %pM to cfg80211\n", bssid);
726 kfree(ie); 726 kfree(ie);
727 } else 727 } else {
728 ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "cfg80211 already has a bss\n"); 728 ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "cfg80211 already has a bss\n");
729 }
729 730
730 return bss; 731 return bss;
731} 732}
@@ -970,7 +971,6 @@ static int ath6kl_set_probed_ssids(struct ath6kl *ar,
970 ssid_list[i].flag, 971 ssid_list[i].flag,
971 ssid_list[i].ssid.ssid_len, 972 ssid_list[i].ssid.ssid_len,
972 ssid_list[i].ssid.ssid); 973 ssid_list[i].ssid.ssid);
973
974 } 974 }
975 975
976 /* Make sure no old entries are left behind */ 976 /* Make sure no old entries are left behind */
@@ -1897,7 +1897,6 @@ static int ath6kl_wow_usr(struct ath6kl *ar, struct ath6kl_vif *vif,
1897 1897
1898 /* Configure the patterns that we received from the user. */ 1898 /* Configure the patterns that we received from the user. */
1899 for (i = 0; i < wow->n_patterns; i++) { 1899 for (i = 0; i < wow->n_patterns; i++) {
1900
1901 /* 1900 /*
1902 * Convert given nl80211 specific mask value to equivalent 1901 * Convert given nl80211 specific mask value to equivalent
1903 * driver specific mask value and send it to the chip along 1902 * driver specific mask value and send it to the chip along
@@ -2850,8 +2849,9 @@ static int ath6kl_start_ap(struct wiphy *wiphy, struct net_device *dev,
2850 if (p.prwise_crypto_type == 0) { 2849 if (p.prwise_crypto_type == 0) {
2851 p.prwise_crypto_type = NONE_CRYPT; 2850 p.prwise_crypto_type = NONE_CRYPT;
2852 ath6kl_set_cipher(vif, 0, true); 2851 ath6kl_set_cipher(vif, 0, true);
2853 } else if (info->crypto.n_ciphers_pairwise == 1) 2852 } else if (info->crypto.n_ciphers_pairwise == 1) {
2854 ath6kl_set_cipher(vif, info->crypto.ciphers_pairwise[0], true); 2853 ath6kl_set_cipher(vif, info->crypto.ciphers_pairwise[0], true);
2854 }
2855 2855
2856 switch (info->crypto.cipher_group) { 2856 switch (info->crypto.cipher_group) {
2857 case WLAN_CIPHER_SUITE_WEP40: 2857 case WLAN_CIPHER_SUITE_WEP40:
@@ -2897,7 +2897,6 @@ static int ath6kl_start_ap(struct wiphy *wiphy, struct net_device *dev,
2897 } 2897 }
2898 2898
2899 if (info->inactivity_timeout) { 2899 if (info->inactivity_timeout) {
2900
2901 inactivity_timeout = info->inactivity_timeout; 2900 inactivity_timeout = info->inactivity_timeout;
2902 2901
2903 if (ar->hw.flags & ATH6KL_HW_AP_INACTIVITY_MINS) 2902 if (ar->hw.flags & ATH6KL_HW_AP_INACTIVITY_MINS)
diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c
index 4b46adbe8c92..b0b652042760 100644
--- a/drivers/net/wireless/ath/ath6kl/core.c
+++ b/drivers/net/wireless/ath/ath6kl/core.c
@@ -45,9 +45,9 @@ module_param(testmode, uint, 0644);
45module_param(recovery_enable, uint, 0644); 45module_param(recovery_enable, uint, 0644);
46module_param(heart_beat_poll, uint, 0644); 46module_param(heart_beat_poll, uint, 0644);
47MODULE_PARM_DESC(recovery_enable, "Enable recovery from firmware error"); 47MODULE_PARM_DESC(recovery_enable, "Enable recovery from firmware error");
48MODULE_PARM_DESC(heart_beat_poll, "Enable fw error detection periodic" \ 48MODULE_PARM_DESC(heart_beat_poll,
49 "polling. This also specifies the polling interval in" \ 49 "Enable fw error detection periodic polling in msecs - Also set recovery_enable for this to be effective");
50 "msecs. Set reocvery_enable for this to be effective"); 50
51 51
52void ath6kl_core_tx_complete(struct ath6kl *ar, struct sk_buff *skb) 52void ath6kl_core_tx_complete(struct ath6kl *ar, struct sk_buff *skb)
53{ 53{
diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
index dbfd17d0a5fa..55c4064dd506 100644
--- a/drivers/net/wireless/ath/ath6kl/debug.c
+++ b/drivers/net/wireless/ath/ath6kl/debug.c
@@ -172,7 +172,6 @@ void ath6kl_dump_registers(struct ath6kl_device *dev,
172 struct ath6kl_irq_proc_registers *irq_proc_reg, 172 struct ath6kl_irq_proc_registers *irq_proc_reg,
173 struct ath6kl_irq_enable_reg *irq_enable_reg) 173 struct ath6kl_irq_enable_reg *irq_enable_reg)
174{ 174{
175
176 ath6kl_dbg(ATH6KL_DBG_IRQ, ("<------- Register Table -------->\n")); 175 ath6kl_dbg(ATH6KL_DBG_IRQ, ("<------- Register Table -------->\n"));
177 176
178 if (irq_proc_reg != NULL) { 177 if (irq_proc_reg != NULL) {
@@ -219,7 +218,6 @@ void ath6kl_dump_registers(struct ath6kl_device *dev,
219 "GMBOX lookahead alias 1: 0x%x\n", 218 "GMBOX lookahead alias 1: 0x%x\n",
220 irq_proc_reg->rx_gmbox_lkahd_alias[1]); 219 irq_proc_reg->rx_gmbox_lkahd_alias[1]);
221 } 220 }
222
223 } 221 }
224 222
225 if (irq_enable_reg != NULL) { 223 if (irq_enable_reg != NULL) {
@@ -1396,7 +1394,6 @@ static ssize_t ath6kl_create_qos_write(struct file *file,
1396 const char __user *user_buf, 1394 const char __user *user_buf,
1397 size_t count, loff_t *ppos) 1395 size_t count, loff_t *ppos)
1398{ 1396{
1399
1400 struct ath6kl *ar = file->private_data; 1397 struct ath6kl *ar = file->private_data;
1401 struct ath6kl_vif *vif; 1398 struct ath6kl_vif *vif;
1402 char buf[200]; 1399 char buf[200];
@@ -1575,7 +1572,6 @@ static ssize_t ath6kl_delete_qos_write(struct file *file,
1575 const char __user *user_buf, 1572 const char __user *user_buf,
1576 size_t count, loff_t *ppos) 1573 size_t count, loff_t *ppos)
1577{ 1574{
1578
1579 struct ath6kl *ar = file->private_data; 1575 struct ath6kl *ar = file->private_data;
1580 struct ath6kl_vif *vif; 1576 struct ath6kl_vif *vif;
1581 char buf[100]; 1577 char buf[100];
diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h
index ca9ba005f287..e194c10d9f00 100644
--- a/drivers/net/wireless/ath/ath6kl/debug.h
+++ b/drivers/net/wireless/ath/ath6kl/debug.h
@@ -97,8 +97,8 @@ static inline void ath6kl_dump_registers(struct ath6kl_device *dev,
97 struct ath6kl_irq_proc_registers *irq_proc_reg, 97 struct ath6kl_irq_proc_registers *irq_proc_reg,
98 struct ath6kl_irq_enable_reg *irq_en_reg) 98 struct ath6kl_irq_enable_reg *irq_en_reg)
99{ 99{
100
101} 100}
101
102static inline void dump_cred_dist_stats(struct htc_target *target) 102static inline void dump_cred_dist_stats(struct htc_target *target)
103{ 103{
104} 104}
diff --git a/drivers/net/wireless/ath/ath6kl/hif.c b/drivers/net/wireless/ath/ath6kl/hif.c
index fea7709b5dda..18c070850a09 100644
--- a/drivers/net/wireless/ath/ath6kl/hif.c
+++ b/drivers/net/wireless/ath/ath6kl/hif.c
@@ -37,7 +37,6 @@ static int ath6kl_hif_cp_scat_dma_buf(struct hif_scatter_req *req,
37 buf = req->virt_dma_buf; 37 buf = req->virt_dma_buf;
38 38
39 for (i = 0; i < req->scat_entries; i++) { 39 for (i = 0; i < req->scat_entries; i++) {
40
41 if (from_dma) 40 if (from_dma)
42 memcpy(req->scat_list[i].buf, buf, 41 memcpy(req->scat_list[i].buf, buf,
43 req->scat_list[i].len); 42 req->scat_list[i].len);
@@ -116,7 +115,6 @@ static void ath6kl_hif_dump_fw_crash(struct ath6kl *ar)
116 le32_to_cpu(regdump_val[i + 2]), 115 le32_to_cpu(regdump_val[i + 2]),
117 le32_to_cpu(regdump_val[i + 3])); 116 le32_to_cpu(regdump_val[i + 3]));
118 } 117 }
119
120} 118}
121 119
122static int ath6kl_hif_proc_dbg_intr(struct ath6kl_device *dev) 120static int ath6kl_hif_proc_dbg_intr(struct ath6kl_device *dev)
@@ -701,5 +699,4 @@ int ath6kl_hif_setup(struct ath6kl_device *dev)
701 699
702fail_setup: 700fail_setup:
703 return status; 701 return status;
704
705} 702}
diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h
index 61f6b21fb0ae..dc6bd8cd9b83 100644
--- a/drivers/net/wireless/ath/ath6kl/hif.h
+++ b/drivers/net/wireless/ath/ath6kl/hif.h
@@ -197,9 +197,9 @@ struct hif_scatter_req {
197 /* bounce buffer for upper layers to copy to/from */ 197 /* bounce buffer for upper layers to copy to/from */
198 u8 *virt_dma_buf; 198 u8 *virt_dma_buf;
199 199
200 struct hif_scatter_item scat_list[1];
201
202 u32 scat_q_depth; 200 u32 scat_q_depth;
201
202 struct hif_scatter_item scat_list[0];
203}; 203};
204 204
205struct ath6kl_irq_proc_registers { 205struct ath6kl_irq_proc_registers {
diff --git a/drivers/net/wireless/ath/ath6kl/htc_mbox.c b/drivers/net/wireless/ath/ath6kl/htc_mbox.c
index 65e5b719093d..e481f14b9878 100644
--- a/drivers/net/wireless/ath/ath6kl/htc_mbox.c
+++ b/drivers/net/wireless/ath/ath6kl/htc_mbox.c
@@ -112,9 +112,9 @@ static void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_info,
112 if (cur_ep_dist->endpoint == ENDPOINT_0) 112 if (cur_ep_dist->endpoint == ENDPOINT_0)
113 continue; 113 continue;
114 114
115 if (cur_ep_dist->svc_id == WMI_CONTROL_SVC) 115 if (cur_ep_dist->svc_id == WMI_CONTROL_SVC) {
116 cur_ep_dist->cred_norm = cur_ep_dist->cred_per_msg; 116 cur_ep_dist->cred_norm = cur_ep_dist->cred_per_msg;
117 else { 117 } else {
118 /* 118 /*
119 * For the remaining data endpoints, we assume that 119 * For the remaining data endpoints, we assume that
120 * each cred_per_msg are the same. We use a simple 120 * each cred_per_msg are the same. We use a simple
@@ -129,7 +129,6 @@ static void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_info,
129 count = (count * 3) >> 2; 129 count = (count * 3) >> 2;
130 count = max(count, cur_ep_dist->cred_per_msg); 130 count = max(count, cur_ep_dist->cred_per_msg);
131 cur_ep_dist->cred_norm = count; 131 cur_ep_dist->cred_norm = count;
132
133 } 132 }
134 133
135 ath6kl_dbg(ATH6KL_DBG_CREDIT, 134 ath6kl_dbg(ATH6KL_DBG_CREDIT,
@@ -549,7 +548,6 @@ static int htc_check_credits(struct htc_target *target,
549 enum htc_endpoint_id eid, unsigned int len, 548 enum htc_endpoint_id eid, unsigned int len,
550 int *req_cred) 549 int *req_cred)
551{ 550{
552
553 *req_cred = (len > target->tgt_cred_sz) ? 551 *req_cred = (len > target->tgt_cred_sz) ?
554 DIV_ROUND_UP(len, target->tgt_cred_sz) : 1; 552 DIV_ROUND_UP(len, target->tgt_cred_sz) : 1;
555 553
@@ -608,7 +606,6 @@ static void ath6kl_htc_tx_pkts_get(struct htc_target *target,
608 unsigned int len; 606 unsigned int len;
609 607
610 while (true) { 608 while (true) {
611
612 flags = 0; 609 flags = 0;
613 610
614 if (list_empty(&endpoint->txq)) 611 if (list_empty(&endpoint->txq))
@@ -889,7 +886,6 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target,
889 ac = target->dev->ar->ep2ac_map[endpoint->eid]; 886 ac = target->dev->ar->ep2ac_map[endpoint->eid];
890 887
891 while (true) { 888 while (true) {
892
893 if (list_empty(&endpoint->txq)) 889 if (list_empty(&endpoint->txq))
894 break; 890 break;
895 891
@@ -1190,7 +1186,6 @@ static void ath6kl_htc_mbox_flush_txep(struct htc_target *target,
1190 list_add_tail(&packet->list, &container); 1186 list_add_tail(&packet->list, &container);
1191 htc_tx_complete(endpoint, &container); 1187 htc_tx_complete(endpoint, &container);
1192 } 1188 }
1193
1194} 1189}
1195 1190
1196static void ath6kl_htc_flush_txep_all(struct htc_target *target) 1191static void ath6kl_htc_flush_txep_all(struct htc_target *target)
@@ -1394,7 +1389,6 @@ static int ath6kl_htc_rx_setup(struct htc_target *target,
1394 1389
1395 ep_cb = ep->ep_cb; 1390 ep_cb = ep->ep_cb;
1396 for (j = 0; j < n_msg; j++) { 1391 for (j = 0; j < n_msg; j++) {
1397
1398 /* 1392 /*
1399 * Reset flag, any packets allocated using the 1393 * Reset flag, any packets allocated using the
1400 * rx_alloc() API cannot be recycled on 1394 * rx_alloc() API cannot be recycled on
@@ -1424,9 +1418,9 @@ static int ath6kl_htc_rx_setup(struct htc_target *target,
1424 } 1418 }
1425 } 1419 }
1426 1420
1427 if (list_empty(&ep->rx_bufq)) 1421 if (list_empty(&ep->rx_bufq)) {
1428 packet = NULL; 1422 packet = NULL;
1429 else { 1423 } else {
1430 packet = list_first_entry(&ep->rx_bufq, 1424 packet = list_first_entry(&ep->rx_bufq,
1431 struct htc_packet, list); 1425 struct htc_packet, list);
1432 list_del(&packet->list); 1426 list_del(&packet->list);
@@ -1487,7 +1481,6 @@ static int ath6kl_htc_rx_alloc(struct htc_target *target,
1487 spin_lock_bh(&target->rx_lock); 1481 spin_lock_bh(&target->rx_lock);
1488 1482
1489 for (i = 0; i < msg; i++) { 1483 for (i = 0; i < msg; i++) {
1490
1491 htc_hdr = (struct htc_frame_hdr *)&lk_ahds[i]; 1484 htc_hdr = (struct htc_frame_hdr *)&lk_ahds[i];
1492 1485
1493 if (htc_hdr->eid >= ENDPOINT_MAX) { 1486 if (htc_hdr->eid >= ENDPOINT_MAX) {
@@ -1708,7 +1701,6 @@ static int htc_parse_trailer(struct htc_target *target,
1708 lk_ahd = (struct htc_lookahead_report *) record_buf; 1701 lk_ahd = (struct htc_lookahead_report *) record_buf;
1709 if ((lk_ahd->pre_valid == ((~lk_ahd->post_valid) & 0xFF)) && 1702 if ((lk_ahd->pre_valid == ((~lk_ahd->post_valid) & 0xFF)) &&
1710 next_lk_ahds) { 1703 next_lk_ahds) {
1711
1712 ath6kl_dbg(ATH6KL_DBG_HTC, 1704 ath6kl_dbg(ATH6KL_DBG_HTC,
1713 "htc rx lk_ahd found pre_valid 0x%x post_valid 0x%x\n", 1705 "htc rx lk_ahd found pre_valid 0x%x post_valid 0x%x\n",
1714 lk_ahd->pre_valid, lk_ahd->post_valid); 1706 lk_ahd->pre_valid, lk_ahd->post_valid);
@@ -1755,7 +1747,6 @@ static int htc_parse_trailer(struct htc_target *target,
1755 } 1747 }
1756 1748
1757 return 0; 1749 return 0;
1758
1759} 1750}
1760 1751
1761static int htc_proc_trailer(struct htc_target *target, 1752static int htc_proc_trailer(struct htc_target *target,
@@ -1776,7 +1767,6 @@ static int htc_proc_trailer(struct htc_target *target,
1776 status = 0; 1767 status = 0;
1777 1768
1778 while (len > 0) { 1769 while (len > 0) {
1779
1780 if (len < sizeof(struct htc_record_hdr)) { 1770 if (len < sizeof(struct htc_record_hdr)) {
1781 status = -ENOMEM; 1771 status = -ENOMEM;
1782 break; 1772 break;
@@ -2098,7 +2088,6 @@ static int ath6kl_htc_rx_fetch(struct htc_target *target,
2098 } 2088 }
2099 2089
2100 if (!fetched_pkts) { 2090 if (!fetched_pkts) {
2101
2102 packet = list_first_entry(rx_pktq, struct htc_packet, 2091 packet = list_first_entry(rx_pktq, struct htc_packet,
2103 list); 2092 list);
2104 2093
@@ -2173,7 +2162,6 @@ int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target,
2173 look_aheads[0] = msg_look_ahead; 2162 look_aheads[0] = msg_look_ahead;
2174 2163
2175 while (true) { 2164 while (true) {
2176
2177 /* 2165 /*
2178 * First lookahead sets the expected endpoint IDs for all 2166 * First lookahead sets the expected endpoint IDs for all
2179 * packets in a bundle. 2167 * packets in a bundle.
@@ -2825,8 +2813,9 @@ static int ath6kl_htc_reset(struct htc_target *target)
2825 packet->buf = packet->buf_start; 2813 packet->buf = packet->buf_start;
2826 packet->endpoint = ENDPOINT_0; 2814 packet->endpoint = ENDPOINT_0;
2827 list_add_tail(&packet->list, &target->free_ctrl_rxbuf); 2815 list_add_tail(&packet->list, &target->free_ctrl_rxbuf);
2828 } else 2816 } else {
2829 list_add_tail(&packet->list, &target->free_ctrl_txbuf); 2817 list_add_tail(&packet->list, &target->free_ctrl_txbuf);
2818 }
2830 } 2819 }
2831 2820
2832 return 0; 2821 return 0;
diff --git a/drivers/net/wireless/ath/ath6kl/htc_pipe.c b/drivers/net/wireless/ath/ath6kl/htc_pipe.c
index 67aa924ed8b3..756fe52a12c8 100644
--- a/drivers/net/wireless/ath/ath6kl/htc_pipe.c
+++ b/drivers/net/wireless/ath/ath6kl/htc_pipe.c
@@ -137,7 +137,6 @@ static void get_htc_packet_credit_based(struct htc_target *target,
137 credits_required = 0; 137 credits_required = 0;
138 138
139 } else { 139 } else {
140
141 if (ep->cred_dist.credits < credits_required) 140 if (ep->cred_dist.credits < credits_required)
142 break; 141 break;
143 142
@@ -169,7 +168,6 @@ static void get_htc_packet_credit_based(struct htc_target *target,
169 /* queue this packet into the caller's queue */ 168 /* queue this packet into the caller's queue */
170 list_add_tail(&packet->list, queue); 169 list_add_tail(&packet->list, queue);
171 } 170 }
172
173} 171}
174 172
175static void get_htc_packet(struct htc_target *target, 173static void get_htc_packet(struct htc_target *target,
@@ -279,7 +277,6 @@ static int htc_issue_packets(struct htc_target *target,
279 list_add(&packet->list, pkt_queue); 277 list_add(&packet->list, pkt_queue);
280 break; 278 break;
281 } 279 }
282
283 } 280 }
284 281
285 if (status != 0) { 282 if (status != 0) {
@@ -385,7 +382,6 @@ static enum htc_send_queue_result htc_try_send(struct htc_target *target,
385 */ 382 */
386 list_for_each_entry_safe(packet, tmp_pkt, 383 list_for_each_entry_safe(packet, tmp_pkt,
387 txq, list) { 384 txq, list) {
388
389 ath6kl_dbg(ATH6KL_DBG_HTC, 385 ath6kl_dbg(ATH6KL_DBG_HTC,
390 "%s: Indicat overflowed TX pkts: %p\n", 386 "%s: Indicat overflowed TX pkts: %p\n",
391 __func__, packet); 387 __func__, packet);
@@ -403,7 +399,6 @@ static enum htc_send_queue_result htc_try_send(struct htc_target *target,
403 list_move_tail(&packet->list, 399 list_move_tail(&packet->list,
404 &send_queue); 400 &send_queue);
405 } 401 }
406
407 } 402 }
408 403
409 if (list_empty(&send_queue)) { 404 if (list_empty(&send_queue)) {
@@ -454,7 +449,6 @@ static enum htc_send_queue_result htc_try_send(struct htc_target *target,
454 * enough transmit resources. 449 * enough transmit resources.
455 */ 450 */
456 while (true) { 451 while (true) {
457
458 if (get_queue_depth(&ep->txq) == 0) 452 if (get_queue_depth(&ep->txq) == 0)
459 break; 453 break;
460 454
@@ -495,8 +489,8 @@ static enum htc_send_queue_result htc_try_send(struct htc_target *target,
495 } 489 }
496 490
497 spin_lock_bh(&target->tx_lock); 491 spin_lock_bh(&target->tx_lock);
498
499 } 492 }
493
500 /* done with this endpoint, we can clear the count */ 494 /* done with this endpoint, we can clear the count */
501 ep->tx_proc_cnt = 0; 495 ep->tx_proc_cnt = 0;
502 spin_unlock_bh(&target->tx_lock); 496 spin_unlock_bh(&target->tx_lock);
@@ -1106,7 +1100,6 @@ free_skb:
1106 dev_kfree_skb(skb); 1100 dev_kfree_skb(skb);
1107 1101
1108 return status; 1102 return status;
1109
1110} 1103}
1111 1104
1112static void htc_flush_rx_queue(struct htc_target *target, 1105static void htc_flush_rx_queue(struct htc_target *target,
@@ -1258,7 +1251,6 @@ static int ath6kl_htc_pipe_conn_service(struct htc_target *target,
1258 tx_alloc = 0; 1251 tx_alloc = 0;
1259 1252
1260 } else { 1253 } else {
1261
1262 tx_alloc = htc_get_credit_alloc(target, conn_req->svc_id); 1254 tx_alloc = htc_get_credit_alloc(target, conn_req->svc_id);
1263 if (tx_alloc == 0) { 1255 if (tx_alloc == 0) {
1264 status = -ENOMEM; 1256 status = -ENOMEM;
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 4f316bdcbab5..d5ef211f261c 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -1192,7 +1192,6 @@ static int ath6kl_upload_board_file(struct ath6kl *ar)
1192 1192
1193 if (board_ext_address && 1193 if (board_ext_address &&
1194 ar->fw_board_len == (board_data_size + board_ext_data_size)) { 1194 ar->fw_board_len == (board_data_size + board_ext_data_size)) {
1195
1196 /* write extended board data */ 1195 /* write extended board data */
1197 ath6kl_dbg(ATH6KL_DBG_BOOT, 1196 ath6kl_dbg(ATH6KL_DBG_BOOT,
1198 "writing extended board data to 0x%x (%d B)\n", 1197 "writing extended board data to 0x%x (%d B)\n",
diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c
index 5839fc23bdc7..d56554674da4 100644
--- a/drivers/net/wireless/ath/ath6kl/main.c
+++ b/drivers/net/wireless/ath/ath6kl/main.c
@@ -571,7 +571,6 @@ void ath6kl_scan_complete_evt(struct ath6kl_vif *vif, int status)
571 571
572static int ath6kl_commit_ch_switch(struct ath6kl_vif *vif, u16 channel) 572static int ath6kl_commit_ch_switch(struct ath6kl_vif *vif, u16 channel)
573{ 573{
574
575 struct ath6kl *ar = vif->ar; 574 struct ath6kl *ar = vif->ar;
576 575
577 vif->profile.ch = cpu_to_le16(channel); 576 vif->profile.ch = cpu_to_le16(channel);
@@ -600,7 +599,6 @@ static int ath6kl_commit_ch_switch(struct ath6kl_vif *vif, u16 channel)
600 599
601static void ath6kl_check_ch_switch(struct ath6kl *ar, u16 channel) 600static void ath6kl_check_ch_switch(struct ath6kl *ar, u16 channel)
602{ 601{
603
604 struct ath6kl_vif *vif; 602 struct ath6kl_vif *vif;
605 int res = 0; 603 int res = 0;
606 604
@@ -692,9 +690,9 @@ void ath6kl_tkip_micerr_event(struct ath6kl_vif *vif, u8 keyid, bool ismcast)
692 cfg80211_michael_mic_failure(vif->ndev, sta->mac, 690 cfg80211_michael_mic_failure(vif->ndev, sta->mac,
693 NL80211_KEYTYPE_PAIRWISE, keyid, 691 NL80211_KEYTYPE_PAIRWISE, keyid,
694 tsc, GFP_KERNEL); 692 tsc, GFP_KERNEL);
695 } else 693 } else {
696 ath6kl_cfg80211_tkip_micerr_event(vif, keyid, ismcast); 694 ath6kl_cfg80211_tkip_micerr_event(vif, keyid, ismcast);
697 695 }
698} 696}
699 697
700static void ath6kl_update_target_stats(struct ath6kl_vif *vif, u8 *ptr, u32 len) 698static void ath6kl_update_target_stats(struct ath6kl_vif *vif, u8 *ptr, u32 len)
@@ -1093,8 +1091,9 @@ static int ath6kl_open(struct net_device *dev)
1093 if (test_bit(CONNECTED, &vif->flags)) { 1091 if (test_bit(CONNECTED, &vif->flags)) {
1094 netif_carrier_on(dev); 1092 netif_carrier_on(dev);
1095 netif_wake_queue(dev); 1093 netif_wake_queue(dev);
1096 } else 1094 } else {
1097 netif_carrier_off(dev); 1095 netif_carrier_off(dev);
1096 }
1098 1097
1099 return 0; 1098 return 0;
1100} 1099}
@@ -1146,7 +1145,6 @@ static int ath6kl_set_features(struct net_device *dev,
1146 dev->features = features | NETIF_F_RXCSUM; 1145 dev->features = features | NETIF_F_RXCSUM;
1147 return err; 1146 return err;
1148 } 1147 }
1149
1150 } 1148 }
1151 1149
1152 return err; 1150 return err;
diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c
index 7126bdd4236c..339d89f14d32 100644
--- a/drivers/net/wireless/ath/ath6kl/sdio.c
+++ b/drivers/net/wireless/ath/ath6kl/sdio.c
@@ -348,7 +348,7 @@ static int ath6kl_sdio_alloc_prep_scat_req(struct ath6kl_sdio *ar_sdio,
348 int i, scat_req_sz, scat_list_sz, size; 348 int i, scat_req_sz, scat_list_sz, size;
349 u8 *virt_buf; 349 u8 *virt_buf;
350 350
351 scat_list_sz = (n_scat_entry - 1) * sizeof(struct hif_scatter_item); 351 scat_list_sz = n_scat_entry * sizeof(struct hif_scatter_item);
352 scat_req_sz = sizeof(*s_req) + scat_list_sz; 352 scat_req_sz = sizeof(*s_req) + scat_list_sz;
353 353
354 if (!virt_scat) 354 if (!virt_scat)
@@ -425,8 +425,9 @@ static int ath6kl_sdio_read_write_sync(struct ath6kl *ar, u32 addr, u8 *buf,
425 memcpy(tbuf, buf, len); 425 memcpy(tbuf, buf, len);
426 426
427 bounced = true; 427 bounced = true;
428 } else 428 } else {
429 tbuf = buf; 429 tbuf = buf;
430 }
430 431
431 ret = ath6kl_sdio_io(ar_sdio->func, request, addr, tbuf, len); 432 ret = ath6kl_sdio_io(ar_sdio->func, request, addr, tbuf, len);
432 if ((request & HIF_READ) && bounced) 433 if ((request & HIF_READ) && bounced)
@@ -441,9 +442,9 @@ static int ath6kl_sdio_read_write_sync(struct ath6kl *ar, u32 addr, u8 *buf,
441static void __ath6kl_sdio_write_async(struct ath6kl_sdio *ar_sdio, 442static void __ath6kl_sdio_write_async(struct ath6kl_sdio *ar_sdio,
442 struct bus_request *req) 443 struct bus_request *req)
443{ 444{
444 if (req->scat_req) 445 if (req->scat_req) {
445 ath6kl_sdio_scat_rw(ar_sdio, req); 446 ath6kl_sdio_scat_rw(ar_sdio, req);
446 else { 447 } else {
447 void *context; 448 void *context;
448 int status; 449 int status;
449 450
@@ -656,7 +657,6 @@ static void ath6kl_sdio_scatter_req_add(struct ath6kl *ar,
656 list_add_tail(&s_req->list, &ar_sdio->scat_req); 657 list_add_tail(&s_req->list, &ar_sdio->scat_req);
657 658
658 spin_unlock_bh(&ar_sdio->scat_lock); 659 spin_unlock_bh(&ar_sdio->scat_lock);
659
660} 660}
661 661
662/* scatter gather read write request */ 662/* scatter gather read write request */
@@ -674,9 +674,9 @@ static int ath6kl_sdio_async_rw_scatter(struct ath6kl *ar,
674 "hif-scatter: total len: %d scatter entries: %d\n", 674 "hif-scatter: total len: %d scatter entries: %d\n",
675 scat_req->len, scat_req->scat_entries); 675 scat_req->len, scat_req->scat_entries);
676 676
677 if (request & HIF_SYNCHRONOUS) 677 if (request & HIF_SYNCHRONOUS) {
678 status = ath6kl_sdio_scat_rw(ar_sdio, scat_req->busrequest); 678 status = ath6kl_sdio_scat_rw(ar_sdio, scat_req->busrequest);
679 else { 679 } else {
680 spin_lock_bh(&ar_sdio->wr_async_lock); 680 spin_lock_bh(&ar_sdio->wr_async_lock);
681 list_add_tail(&scat_req->busrequest->list, &ar_sdio->wr_asyncq); 681 list_add_tail(&scat_req->busrequest->list, &ar_sdio->wr_asyncq);
682 spin_unlock_bh(&ar_sdio->wr_async_lock); 682 spin_unlock_bh(&ar_sdio->wr_async_lock);
@@ -856,7 +856,6 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow)
856 856
857 if (ar->suspend_mode == WLAN_POWER_STATE_WOW || 857 if (ar->suspend_mode == WLAN_POWER_STATE_WOW ||
858 (!ar->suspend_mode && wow)) { 858 (!ar->suspend_mode && wow)) {
859
860 ret = ath6kl_set_sdio_pm_caps(ar); 859 ret = ath6kl_set_sdio_pm_caps(ar);
861 if (ret) 860 if (ret)
862 goto cut_pwr; 861 goto cut_pwr;
@@ -878,7 +877,6 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow)
878 877
879 if (ar->suspend_mode == WLAN_POWER_STATE_DEEP_SLEEP || 878 if (ar->suspend_mode == WLAN_POWER_STATE_DEEP_SLEEP ||
880 !ar->suspend_mode || try_deepsleep) { 879 !ar->suspend_mode || try_deepsleep) {
881
882 flags = sdio_get_host_pm_caps(func); 880 flags = sdio_get_host_pm_caps(func);
883 if (!(flags & MMC_PM_KEEP_POWER)) 881 if (!(flags & MMC_PM_KEEP_POWER))
884 goto cut_pwr; 882 goto cut_pwr;
@@ -1061,7 +1059,6 @@ static int ath6kl_sdio_bmi_credits(struct ath6kl *ar)
1061 1059
1062 timeout = jiffies + msecs_to_jiffies(BMI_COMMUNICATION_TIMEOUT); 1060 timeout = jiffies + msecs_to_jiffies(BMI_COMMUNICATION_TIMEOUT);
1063 while (time_before(jiffies, timeout) && !ar->bmi.cmd_credits) { 1061 while (time_before(jiffies, timeout) && !ar->bmi.cmd_credits) {
1064
1065 /* 1062 /*
1066 * Hit the credit counter with a 4-byte access, the first byte 1063 * Hit the credit counter with a 4-byte access, the first byte
1067 * read will hit the counter and cause a decrement, while the 1064 * read will hit the counter and cause a decrement, while the
diff --git a/drivers/net/wireless/ath/ath6kl/target.h b/drivers/net/wireless/ath/ath6kl/target.h
index a580a629a0da..d5eeeae7711b 100644
--- a/drivers/net/wireless/ath/ath6kl/target.h
+++ b/drivers/net/wireless/ath/ath6kl/target.h
@@ -289,7 +289,7 @@ struct host_interest {
289 u32 hi_hp_rx_traffic_ratio; /* 0xd8 */ 289 u32 hi_hp_rx_traffic_ratio; /* 0xd8 */
290 290
291 /* test applications flags */ 291 /* test applications flags */
292 u32 hi_test_apps_related ; /* 0xdc */ 292 u32 hi_test_apps_related; /* 0xdc */
293 /* location of test script */ 293 /* location of test script */
294 u32 hi_ota_testscript; /* 0xe0 */ 294 u32 hi_ota_testscript; /* 0xe0 */
295 /* location of CAL data */ 295 /* location of CAL data */
diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c b/drivers/net/wireless/ath/ath6kl/txrx.c
index ebb24045a8ae..40432fe7a5d2 100644
--- a/drivers/net/wireless/ath/ath6kl/txrx.c
+++ b/drivers/net/wireless/ath/ath6kl/txrx.c
@@ -125,8 +125,9 @@ static bool ath6kl_process_uapsdq(struct ath6kl_sta *conn,
125 *flags |= WMI_DATA_HDR_FLAGS_UAPSD; 125 *flags |= WMI_DATA_HDR_FLAGS_UAPSD;
126 spin_unlock_bh(&conn->psq_lock); 126 spin_unlock_bh(&conn->psq_lock);
127 return false; 127 return false;
128 } else if (!conn->apsd_info) 128 } else if (!conn->apsd_info) {
129 return false; 129 return false;
130 }
130 131
131 if (test_bit(WMM_ENABLED, &vif->flags)) { 132 if (test_bit(WMM_ENABLED, &vif->flags)) {
132 ether_type = be16_to_cpu(datap->h_proto); 133 ether_type = be16_to_cpu(datap->h_proto);
@@ -316,8 +317,9 @@ int ath6kl_control_tx(void *devt, struct sk_buff *skb,
316 cookie = NULL; 317 cookie = NULL;
317 ath6kl_err("wmi ctrl ep full, dropping pkt : 0x%p, len:%d\n", 318 ath6kl_err("wmi ctrl ep full, dropping pkt : 0x%p, len:%d\n",
318 skb, skb->len); 319 skb, skb->len);
319 } else 320 } else {
320 cookie = ath6kl_alloc_cookie(ar); 321 cookie = ath6kl_alloc_cookie(ar);
322 }
321 323
322 if (cookie == NULL) { 324 if (cookie == NULL) {
323 spin_unlock_bh(&ar->lock); 325 spin_unlock_bh(&ar->lock);
@@ -359,7 +361,7 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev)
359 struct ath6kl_vif *vif = netdev_priv(dev); 361 struct ath6kl_vif *vif = netdev_priv(dev);
360 u32 map_no = 0; 362 u32 map_no = 0;
361 u16 htc_tag = ATH6KL_DATA_PKT_TAG; 363 u16 htc_tag = ATH6KL_DATA_PKT_TAG;
362 u8 ac = 99 ; /* initialize to unmapped ac */ 364 u8 ac = 99; /* initialize to unmapped ac */
363 bool chk_adhoc_ps_mapping = false; 365 bool chk_adhoc_ps_mapping = false;
364 int ret; 366 int ret;
365 struct wmi_tx_meta_v2 meta_v2; 367 struct wmi_tx_meta_v2 meta_v2;
@@ -449,8 +451,9 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev)
449 if (ret) 451 if (ret)
450 goto fail_tx; 452 goto fail_tx;
451 } 453 }
452 } else 454 } else {
453 goto fail_tx; 455 goto fail_tx;
456 }
454 457
455 spin_lock_bh(&ar->lock); 458 spin_lock_bh(&ar->lock);
456 459
@@ -702,7 +705,6 @@ void ath6kl_tx_complete(struct htc_target *target,
702 705
703 /* reap completed packets */ 706 /* reap completed packets */
704 while (!list_empty(packet_queue)) { 707 while (!list_empty(packet_queue)) {
705
706 packet = list_first_entry(packet_queue, struct htc_packet, 708 packet = list_first_entry(packet_queue, struct htc_packet,
707 list); 709 list);
708 list_del(&packet->list); 710 list_del(&packet->list);
@@ -1089,8 +1091,9 @@ static void aggr_deque_frms(struct aggr_info_conn *agg_conn, u8 tid,
1089 else 1091 else
1090 skb_queue_tail(&rxtid->q, node->skb); 1092 skb_queue_tail(&rxtid->q, node->skb);
1091 node->skb = NULL; 1093 node->skb = NULL;
1092 } else 1094 } else {
1093 stats->num_hole++; 1095 stats->num_hole++;
1096 }
1094 1097
1095 rxtid->seq_next = ATH6KL_NEXT_SEQ_NO(rxtid->seq_next); 1098 rxtid->seq_next = ATH6KL_NEXT_SEQ_NO(rxtid->seq_next);
1096 idx = AGGR_WIN_IDX(rxtid->seq_next, rxtid->hold_q_sz); 1099 idx = AGGR_WIN_IDX(rxtid->seq_next, rxtid->hold_q_sz);
@@ -1211,7 +1214,7 @@ static bool aggr_process_recv_frm(struct aggr_info_conn *agg_conn, u8 tid,
1211 return is_queued; 1214 return is_queued;
1212 1215
1213 spin_lock_bh(&rxtid->lock); 1216 spin_lock_bh(&rxtid->lock);
1214 for (idx = 0 ; idx < rxtid->hold_q_sz; idx++) { 1217 for (idx = 0; idx < rxtid->hold_q_sz; idx++) {
1215 if (rxtid->hold_q[idx].skb) { 1218 if (rxtid->hold_q[idx].skb) {
1216 /* 1219 /*
1217 * There is a frame in the queue and no 1220 * There is a frame in the queue and no
@@ -1265,7 +1268,6 @@ static void ath6kl_uapsd_trigger_frame_rx(struct ath6kl_vif *vif,
1265 is_apsdq_empty_at_start = is_apsdq_empty; 1268 is_apsdq_empty_at_start = is_apsdq_empty;
1266 1269
1267 while ((!is_apsdq_empty) && (num_frames_to_deliver)) { 1270 while ((!is_apsdq_empty) && (num_frames_to_deliver)) {
1268
1269 spin_lock_bh(&conn->psq_lock); 1271 spin_lock_bh(&conn->psq_lock);
1270 skb = skb_dequeue(&conn->apsdq); 1272 skb = skb_dequeue(&conn->apsdq);
1271 is_apsdq_empty = skb_queue_empty(&conn->apsdq); 1273 is_apsdq_empty = skb_queue_empty(&conn->apsdq);
@@ -1606,16 +1608,18 @@ void ath6kl_rx(struct htc_target *target, struct htc_packet *packet)
1606 if (!conn) 1608 if (!conn)
1607 return; 1609 return;
1608 aggr_conn = conn->aggr_conn; 1610 aggr_conn = conn->aggr_conn;
1609 } else 1611 } else {
1610 aggr_conn = vif->aggr_cntxt->aggr_conn; 1612 aggr_conn = vif->aggr_cntxt->aggr_conn;
1613 }
1611 1614
1612 if (aggr_process_recv_frm(aggr_conn, tid, seq_no, 1615 if (aggr_process_recv_frm(aggr_conn, tid, seq_no,
1613 is_amsdu, skb)) { 1616 is_amsdu, skb)) {
1614 /* aggregation code will handle the skb */ 1617 /* aggregation code will handle the skb */
1615 return; 1618 return;
1616 } 1619 }
1617 } else if (!is_broadcast_ether_addr(datap->h_dest)) 1620 } else if (!is_broadcast_ether_addr(datap->h_dest)) {
1618 vif->net_stats.multicast++; 1621 vif->net_stats.multicast++;
1622 }
1619 1623
1620 ath6kl_deliver_frames_to_nw_stack(vif->ndev, skb); 1624 ath6kl_deliver_frames_to_nw_stack(vif->ndev, skb);
1621} 1625}
@@ -1710,8 +1714,9 @@ void aggr_recv_addba_req_evt(struct ath6kl_vif *vif, u8 tid_mux, u16 seq_no,
1710 sta = ath6kl_find_sta_by_aid(vif->ar, aid); 1714 sta = ath6kl_find_sta_by_aid(vif->ar, aid);
1711 if (sta) 1715 if (sta)
1712 aggr_conn = sta->aggr_conn; 1716 aggr_conn = sta->aggr_conn;
1713 } else 1717 } else {
1714 aggr_conn = vif->aggr_cntxt->aggr_conn; 1718 aggr_conn = vif->aggr_cntxt->aggr_conn;
1719 }
1715 1720
1716 if (!aggr_conn) 1721 if (!aggr_conn)
1717 return; 1722 return;
@@ -1766,7 +1771,6 @@ void aggr_conn_init(struct ath6kl_vif *vif, struct aggr_info *aggr_info,
1766 skb_queue_head_init(&rxtid->q); 1771 skb_queue_head_init(&rxtid->q);
1767 spin_lock_init(&rxtid->lock); 1772 spin_lock_init(&rxtid->lock);
1768 } 1773 }
1769
1770} 1774}
1771 1775
1772struct aggr_info *aggr_init(struct ath6kl_vif *vif) 1776struct aggr_info *aggr_init(struct ath6kl_vif *vif)
@@ -1806,8 +1810,9 @@ void aggr_recv_delba_req_evt(struct ath6kl_vif *vif, u8 tid_mux)
1806 sta = ath6kl_find_sta_by_aid(vif->ar, aid); 1810 sta = ath6kl_find_sta_by_aid(vif->ar, aid);
1807 if (sta) 1811 if (sta)
1808 aggr_conn = sta->aggr_conn; 1812 aggr_conn = sta->aggr_conn;
1809 } else 1813 } else {
1810 aggr_conn = vif->aggr_cntxt->aggr_conn; 1814 aggr_conn = vif->aggr_cntxt->aggr_conn;
1815 }
1811 1816
1812 if (!aggr_conn) 1817 if (!aggr_conn)
1813 return; 1818 return;
diff --git a/drivers/net/wireless/ath/ath6kl/usb.c b/drivers/net/wireless/ath/ath6kl/usb.c
index 56c3fd5cef65..3afc5a463d06 100644
--- a/drivers/net/wireless/ath/ath6kl/usb.c
+++ b/drivers/net/wireless/ath/ath6kl/usb.c
@@ -236,7 +236,6 @@ static void ath6kl_usb_free_pipe_resources(struct ath6kl_usb_pipe *pipe)
236 break; 236 break;
237 kfree(urb_context); 237 kfree(urb_context);
238 } 238 }
239
240} 239}
241 240
242static void ath6kl_usb_cleanup_pipe_resources(struct ath6kl_usb *ar_usb) 241static void ath6kl_usb_cleanup_pipe_resources(struct ath6kl_usb *ar_usb)
@@ -245,7 +244,6 @@ static void ath6kl_usb_cleanup_pipe_resources(struct ath6kl_usb *ar_usb)
245 244
246 for (i = 0; i < ATH6KL_USB_PIPE_MAX; i++) 245 for (i = 0; i < ATH6KL_USB_PIPE_MAX; i++)
247 ath6kl_usb_free_pipe_resources(&ar_usb->pipes[i]); 246 ath6kl_usb_free_pipe_resources(&ar_usb->pipes[i]);
248
249} 247}
250 248
251static u8 ath6kl_usb_get_logical_pipe_num(struct ath6kl_usb *ar_usb, 249static u8 ath6kl_usb_get_logical_pipe_num(struct ath6kl_usb *ar_usb,
diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c
index 8b4ce28e3ce8..0c0e1e36e40f 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.c
+++ b/drivers/net/wireless/ath/ath6kl/wmi.c
@@ -289,8 +289,9 @@ int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx,
289 ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) + 289 ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) +
290 sizeof(struct ath6kl_llc_snap_hdr), 290 sizeof(struct ath6kl_llc_snap_hdr),
291 layer2_priority); 291 layer2_priority);
292 } else 292 } else {
293 usr_pri = layer2_priority & 0x7; 293 usr_pri = layer2_priority & 0x7;
294 }
294 295
295 /* 296 /*
296 * Queue the EAPOL frames in the same WMM_AC_VO queue 297 * Queue the EAPOL frames in the same WMM_AC_VO queue
@@ -359,8 +360,9 @@ int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb)
359 hdr_size = roundup(sizeof(struct ieee80211_qos_hdr), 360 hdr_size = roundup(sizeof(struct ieee80211_qos_hdr),
360 sizeof(u32)); 361 sizeof(u32));
361 skb_pull(skb, hdr_size); 362 skb_pull(skb, hdr_size);
362 } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) 363 } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) {
363 skb_pull(skb, sizeof(struct ieee80211_hdr_3addr)); 364 skb_pull(skb, sizeof(struct ieee80211_hdr_3addr));
365 }
364 366
365 datap = skb->data; 367 datap = skb->data;
366 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap); 368 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap);
@@ -936,7 +938,6 @@ ath6kl_regd_find_country_by_rd(u16 regdmn)
936 938
937static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) 939static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len)
938{ 940{
939
940 struct ath6kl_wmi_regdomain *ev; 941 struct ath6kl_wmi_regdomain *ev;
941 struct country_code_to_enum_rd *country = NULL; 942 struct country_code_to_enum_rd *country = NULL;
942 struct reg_dmn_pair_mapping *regpair = NULL; 943 struct reg_dmn_pair_mapping *regpair = NULL;
@@ -946,10 +947,9 @@ static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len)
946 ev = (struct ath6kl_wmi_regdomain *) datap; 947 ev = (struct ath6kl_wmi_regdomain *) datap;
947 reg_code = le32_to_cpu(ev->reg_code); 948 reg_code = le32_to_cpu(ev->reg_code);
948 949
949 if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG) 950 if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG) {
950 country = ath6kl_regd_find_country((u16) reg_code); 951 country = ath6kl_regd_find_country((u16) reg_code);
951 else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) { 952 } else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) {
952
953 regpair = ath6kl_get_regpair((u16) reg_code); 953 regpair = ath6kl_get_regpair((u16) reg_code);
954 country = ath6kl_regd_find_country_by_rd((u16) reg_code); 954 country = ath6kl_regd_find_country_by_rd((u16) reg_code);
955 if (regpair) 955 if (regpair)
@@ -1499,7 +1499,6 @@ static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len,
1499 1499
1500 if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && 1500 if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) &&
1501 (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { 1501 (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) {
1502
1503 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1502 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1504 tsinfo = le16_to_cpu(ts->tsinfo); 1503 tsinfo = le16_to_cpu(ts->tsinfo);
1505 tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1504 tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
@@ -1530,7 +1529,6 @@ static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len,
1530 * for delete qos stream from AP 1529 * for delete qos stream from AP
1531 */ 1530 */
1532 else if (reply->cac_indication == CAC_INDICATION_DELETE) { 1531 else if (reply->cac_indication == CAC_INDICATION_DELETE) {
1533
1534 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1532 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1535 tsinfo = le16_to_cpu(ts->tsinfo); 1533 tsinfo = le16_to_cpu(ts->tsinfo);
1536 ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1534 ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
@@ -2479,7 +2477,6 @@ static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx)
2479 goto free_data_skb; 2477 goto free_data_skb;
2480 2478
2481 for (index = 0; index < num_pri_streams; index++) { 2479 for (index = 0; index < num_pri_streams; index++) {
2482
2483 if (WARN_ON(!data_sync_bufs[index].skb)) 2480 if (WARN_ON(!data_sync_bufs[index].skb))
2484 goto free_data_skb; 2481 goto free_data_skb;
2485 2482
@@ -2704,7 +2701,6 @@ static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi *wmi)
2704 2701
2705 for (i = 0; i < WMM_NUM_AC; i++) { 2702 for (i = 0; i < WMM_NUM_AC; i++) {
2706 if (stream_exist & (1 << i)) { 2703 if (stream_exist & (1 << i)) {
2707
2708 /* 2704 /*
2709 * FIXME: Is this lock & unlock inside 2705 * FIXME: Is this lock & unlock inside
2710 * for loop correct? may need rework. 2706 * for loop correct? may need rework.
@@ -2870,8 +2866,9 @@ int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx,
2870 if (host_mode == ATH6KL_HOST_MODE_ASLEEP) { 2866 if (host_mode == ATH6KL_HOST_MODE_ASLEEP) {
2871 ath6kl_wmi_relinquish_implicit_pstream_credits(wmi); 2867 ath6kl_wmi_relinquish_implicit_pstream_credits(wmi);
2872 cmd->asleep = cpu_to_le32(1); 2868 cmd->asleep = cpu_to_le32(1);
2873 } else 2869 } else {
2874 cmd->awake = cpu_to_le32(1); 2870 cmd->awake = cpu_to_le32(1);
2871 }
2875 2872
2876 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, 2873 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2877 WMI_SET_HOST_SLEEP_MODE_CMDID, 2874 WMI_SET_HOST_SLEEP_MODE_CMDID,
diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h
index b5f226503baf..1f05ecd97c91 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.h
+++ b/drivers/net/wireless/ath/ath6kl/wmi.h
@@ -898,7 +898,6 @@ struct wmi_start_scan_cmd {
898 * flags here 898 * flags here
899 */ 899 */
900enum wmi_scan_ctrl_flags_bits { 900enum wmi_scan_ctrl_flags_bits {
901
902 /* set if can scan in the connect cmd */ 901 /* set if can scan in the connect cmd */
903 CONNECT_SCAN_CTRL_FLAGS = 0x01, 902 CONNECT_SCAN_CTRL_FLAGS = 0x01,
904 903