aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-11-11 08:37:22 -0500
committerDavid S. Miller <davem@davemloft.net>2017-11-11 08:37:22 -0500
commit7c5556decd0a629e9ee02e93653f75ba7b7da03c (patch)
treebc56819788e9226efc04a1d1710b99fa6d4512e4
parent39b175211053c7a6a4d794c42e225994f1c069c2 (diff)
parentfdd0bd88ceaecf729db103ac8836af5805dd2dc1 (diff)
Merge tag 'wireless-drivers-next-for-davem-2017-11-11' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next
Kalle Valo says: ==================== wireless-drivers-next patches for 4.15 Last minute patches before the merge window. Not really anything special standing out, mostly fixes or cleanup and some minor new features. Major changes: iwlwifi * some new PCI IDs ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h10
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c162
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h2
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c157
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c40
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h3
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h31
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c11
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c19
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c33
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c18
-rw-r--r--drivers/net/wireless/intel/iwlegacy/4965-rs.c2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/cfg/8000.c51
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/api/paging.h24
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/file.h2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/img.h8
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/paging.c103
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-config.h3
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-csr.h2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-drv.c6
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-trans.h42
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/fw.c15
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c62
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mvm.h4
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/ops.c1
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rs.c10
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c23
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/sta.c50
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tx.c3
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/drv.c10
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/trans.c7
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/tx.c1
-rw-r--r--drivers/net/wireless/intersil/orinoco/orinoco_usb.c2
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/cfg80211.c64
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/commands.c276
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/commands.h9
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/core.c3
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/core.h5
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/event.c83
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/qlink.h138
-rw-r--r--drivers/net/wireless/ralink/rt2x00/rt2x00debug.c7
-rw-r--r--drivers/net/wireless/ralink/rt2x00/rt2x00dump.h2
-rw-r--r--drivers/net/wireless/ralink/rt2x00/rt2x00usb.c6
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/base.c2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/core.c12
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/pci.c275
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/pci.h31
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c10
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/wifi.h11
-rw-r--r--drivers/net/wireless/rsi/rsi_91x_ps.c1
-rw-r--r--drivers/net/wireless/zydas/zd1201.c3
66 files changed, 995 insertions, 904 deletions
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
index 163ddc49f951..0b76a615708e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
@@ -71,6 +71,7 @@ struct brcmf_bus_dcmd {
71 * @wowl_config: specify if dongle is configured for wowl when going to suspend 71 * @wowl_config: specify if dongle is configured for wowl when going to suspend
72 * @get_ramsize: obtain size of device memory. 72 * @get_ramsize: obtain size of device memory.
73 * @get_memdump: obtain device memory dump in provided buffer. 73 * @get_memdump: obtain device memory dump in provided buffer.
74 * @get_fwname: obtain firmware name.
74 * 75 *
75 * This structure provides an abstract interface towards the 76 * This structure provides an abstract interface towards the
76 * bus specific driver. For control messages to common driver 77 * bus specific driver. For control messages to common driver
@@ -87,6 +88,8 @@ struct brcmf_bus_ops {
87 void (*wowl_config)(struct device *dev, bool enabled); 88 void (*wowl_config)(struct device *dev, bool enabled);
88 size_t (*get_ramsize)(struct device *dev); 89 size_t (*get_ramsize)(struct device *dev);
89 int (*get_memdump)(struct device *dev, void *data, size_t len); 90 int (*get_memdump)(struct device *dev, void *data, size_t len);
91 int (*get_fwname)(struct device *dev, uint chip, uint chiprev,
92 unsigned char *fw_name);
90}; 93};
91 94
92 95
@@ -224,6 +227,13 @@ int brcmf_bus_get_memdump(struct brcmf_bus *bus, void *data, size_t len)
224 return bus->ops->get_memdump(bus->dev, data, len); 227 return bus->ops->get_memdump(bus->dev, data, len);
225} 228}
226 229
230static inline
231int brcmf_bus_get_fwname(struct brcmf_bus *bus, uint chip, uint chiprev,
232 unsigned char *fw_name)
233{
234 return bus->ops->get_fwname(bus->dev, chip, chiprev, fw_name);
235}
236
227/* 237/*
228 * interface functions from common layer 238 * interface functions from common layer
229 */ 239 */
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 4bfd43a80273..6e70df978159 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -472,47 +472,6 @@ send_key_to_dongle(struct brcmf_if *ifp, struct brcmf_wsec_key *key)
472 return err; 472 return err;
473} 473}
474 474
475static s32
476brcmf_configure_arp_nd_offload(struct brcmf_if *ifp, bool enable)
477{
478 s32 err;
479 u32 mode;
480
481 if (enable)
482 mode = BRCMF_ARP_OL_AGENT | BRCMF_ARP_OL_PEER_AUTO_REPLY;
483 else
484 mode = 0;
485
486 /* Try to set and enable ARP offload feature, this may fail, then it */
487 /* is simply not supported and err 0 will be returned */
488 err = brcmf_fil_iovar_int_set(ifp, "arp_ol", mode);
489 if (err) {
490 brcmf_dbg(TRACE, "failed to set ARP offload mode to 0x%x, err = %d\n",
491 mode, err);
492 err = 0;
493 } else {
494 err = brcmf_fil_iovar_int_set(ifp, "arpoe", enable);
495 if (err) {
496 brcmf_dbg(TRACE, "failed to configure (%d) ARP offload err = %d\n",
497 enable, err);
498 err = 0;
499 } else
500 brcmf_dbg(TRACE, "successfully configured (%d) ARP offload to 0x%x\n",
501 enable, mode);
502 }
503
504 err = brcmf_fil_iovar_int_set(ifp, "ndoe", enable);
505 if (err) {
506 brcmf_dbg(TRACE, "failed to configure (%d) ND offload err = %d\n",
507 enable, err);
508 err = 0;
509 } else
510 brcmf_dbg(TRACE, "successfully configured (%d) ND offload to 0x%x\n",
511 enable, mode);
512
513 return err;
514}
515
516static void 475static void
517brcmf_cfg80211_update_proto_addr_mode(struct wireless_dev *wdev) 476brcmf_cfg80211_update_proto_addr_mode(struct wireless_dev *wdev)
518{ 477{
@@ -1084,7 +1043,6 @@ brcmf_do_escan(struct brcmf_if *ifp, struct cfg80211_scan_request *request)
1084{ 1043{
1085 struct brcmf_cfg80211_info *cfg = ifp->drvr->config; 1044 struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
1086 s32 err; 1045 s32 err;
1087 u32 passive_scan;
1088 struct brcmf_scan_results *results; 1046 struct brcmf_scan_results *results;
1089 struct escan_info *escan = &cfg->escan_info; 1047 struct escan_info *escan = &cfg->escan_info;
1090 1048
@@ -1092,13 +1050,7 @@ brcmf_do_escan(struct brcmf_if *ifp, struct cfg80211_scan_request *request)
1092 escan->ifp = ifp; 1050 escan->ifp = ifp;
1093 escan->wiphy = cfg->wiphy; 1051 escan->wiphy = cfg->wiphy;
1094 escan->escan_state = WL_ESCAN_STATE_SCANNING; 1052 escan->escan_state = WL_ESCAN_STATE_SCANNING;
1095 passive_scan = cfg->active_scan ? 0 : 1; 1053
1096 err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_PASSIVE_SCAN,
1097 passive_scan);
1098 if (err) {
1099 brcmf_err("error (%d)\n", err);
1100 return err;
1101 }
1102 brcmf_scan_config_mpc(ifp, 0); 1054 brcmf_scan_config_mpc(ifp, 0);
1103 results = (struct brcmf_scan_results *)cfg->escan_info.escan_buf; 1055 results = (struct brcmf_scan_results *)cfg->escan_info.escan_buf;
1104 results->version = 0; 1056 results->version = 0;
@@ -1112,21 +1064,16 @@ brcmf_do_escan(struct brcmf_if *ifp, struct cfg80211_scan_request *request)
1112} 1064}
1113 1065
1114static s32 1066static s32
1115brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif, 1067brcmf_cfg80211_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
1116 struct cfg80211_scan_request *request,
1117 struct cfg80211_ssid *this_ssid)
1118{ 1068{
1119 struct brcmf_if *ifp = vif->ifp;
1120 struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); 1069 struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
1121 struct cfg80211_ssid *ssids; 1070 struct brcmf_cfg80211_vif *vif;
1122 u32 passive_scan; 1071 s32 err = 0;
1123 bool escan_req;
1124 bool spec_scan;
1125 s32 err;
1126 struct brcmf_ssid_le ssid_le;
1127 u32 SSID_len;
1128 1072
1129 brcmf_dbg(SCAN, "START ESCAN\n"); 1073 brcmf_dbg(TRACE, "Enter\n");
1074 vif = container_of(request->wdev, struct brcmf_cfg80211_vif, wdev);
1075 if (!check_vif_up(vif))
1076 return -EIO;
1130 1077
1131 if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) { 1078 if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) {
1132 brcmf_err("Scanning already: status (%lu)\n", cfg->scan_status); 1079 brcmf_err("Scanning already: status (%lu)\n", cfg->scan_status);
@@ -1142,8 +1089,8 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
1142 cfg->scan_status); 1089 cfg->scan_status);
1143 return -EAGAIN; 1090 return -EAGAIN;
1144 } 1091 }
1145 if (test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) { 1092 if (test_bit(BRCMF_VIF_STATUS_CONNECTING, &vif->sme_state)) {
1146 brcmf_err("Connecting: status (%lu)\n", ifp->vif->sme_state); 1093 brcmf_err("Connecting: status (%lu)\n", vif->sme_state);
1147 return -EAGAIN; 1094 return -EAGAIN;
1148 } 1095 }
1149 1096
@@ -1151,96 +1098,38 @@ brcmf_cfg80211_escan(struct wiphy *wiphy, struct brcmf_cfg80211_vif *vif,
1151 if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif) 1098 if (vif == cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif)
1152 vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif; 1099 vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
1153 1100
1154 escan_req = false; 1101 brcmf_dbg(SCAN, "START ESCAN\n");
1155 if (request) {
1156 /* scan bss */
1157 ssids = request->ssids;
1158 escan_req = true;
1159 } else {
1160 /* scan in ibss */
1161 /* we don't do escan in ibss */
1162 ssids = this_ssid;
1163 }
1164 1102
1165 cfg->scan_request = request; 1103 cfg->scan_request = request;
1166 set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status); 1104 set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
1167 if (escan_req) {
1168 cfg->escan_info.run = brcmf_run_escan;
1169 err = brcmf_p2p_scan_prep(wiphy, request, vif);
1170 if (err)
1171 goto scan_out;
1172 1105
1173 err = brcmf_do_escan(vif->ifp, request); 1106 cfg->escan_info.run = brcmf_run_escan;
1174 if (err) 1107 err = brcmf_p2p_scan_prep(wiphy, request, vif);
1175 goto scan_out; 1108 if (err)
1176 } else { 1109 goto scan_out;
1177 brcmf_dbg(SCAN, "ssid \"%s\", ssid_len (%d)\n",
1178 ssids->ssid, ssids->ssid_len);
1179 memset(&ssid_le, 0, sizeof(ssid_le));
1180 SSID_len = min_t(u8, sizeof(ssid_le.SSID), ssids->ssid_len);
1181 ssid_le.SSID_len = cpu_to_le32(0);
1182 spec_scan = false;
1183 if (SSID_len) {
1184 memcpy(ssid_le.SSID, ssids->ssid, SSID_len);
1185 ssid_le.SSID_len = cpu_to_le32(SSID_len);
1186 spec_scan = true;
1187 } else
1188 brcmf_dbg(SCAN, "Broadcast scan\n");
1189 1110
1190 passive_scan = cfg->active_scan ? 0 : 1; 1111 err = brcmf_vif_set_mgmt_ie(vif, BRCMF_VNDR_IE_PRBREQ_FLAG,
1191 err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_PASSIVE_SCAN, 1112 request->ie, request->ie_len);
1192 passive_scan); 1113 if (err)
1193 if (err) { 1114 goto scan_out;
1194 brcmf_err("WLC_SET_PASSIVE_SCAN error (%d)\n", err);
1195 goto scan_out;
1196 }
1197 brcmf_scan_config_mpc(ifp, 0);
1198 err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SCAN, &ssid_le,
1199 sizeof(ssid_le));
1200 if (err) {
1201 if (err == -EBUSY)
1202 brcmf_dbg(INFO, "BUSY: scan for \"%s\" canceled\n",
1203 ssid_le.SSID);
1204 else
1205 brcmf_err("WLC_SCAN error (%d)\n", err);
1206 1115
1207 brcmf_scan_config_mpc(ifp, 1); 1116 err = brcmf_do_escan(vif->ifp, request);
1208 goto scan_out; 1117 if (err)
1209 } 1118 goto scan_out;
1210 }
1211 1119
1212 /* Arm scan timeout timer */ 1120 /* Arm scan timeout timer */
1213 mod_timer(&cfg->escan_timeout, jiffies + 1121 mod_timer(&cfg->escan_timeout,
1214 BRCMF_ESCAN_TIMER_INTERVAL_MS * HZ / 1000); 1122 jiffies + msecs_to_jiffies(BRCMF_ESCAN_TIMER_INTERVAL_MS));
1215 1123
1216 return 0; 1124 return 0;
1217 1125
1218scan_out: 1126scan_out:
1127 brcmf_err("scan error (%d)\n", err);
1219 clear_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status); 1128 clear_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
1220 cfg->scan_request = NULL; 1129 cfg->scan_request = NULL;
1221 return err; 1130 return err;
1222} 1131}
1223 1132
1224static s32
1225brcmf_cfg80211_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
1226{
1227 struct brcmf_cfg80211_vif *vif;
1228 s32 err = 0;
1229
1230 brcmf_dbg(TRACE, "Enter\n");
1231 vif = container_of(request->wdev, struct brcmf_cfg80211_vif, wdev);
1232 if (!check_vif_up(vif))
1233 return -EIO;
1234
1235 err = brcmf_cfg80211_escan(wiphy, vif, request, NULL);
1236
1237 if (err)
1238 brcmf_err("scan error (%d)\n", err);
1239
1240 brcmf_dbg(TRACE, "Exit\n");
1241 return err;
1242}
1243
1244static s32 brcmf_set_rts(struct net_device *ndev, u32 rts_threshold) 1133static s32 brcmf_set_rts(struct net_device *ndev, u32 rts_threshold)
1245{ 1134{
1246 s32 err = 0; 1135 s32 err = 0;
@@ -5876,7 +5765,6 @@ static s32 wl_init_priv(struct brcmf_cfg80211_info *cfg)
5876 5765
5877 cfg->scan_request = NULL; 5766 cfg->scan_request = NULL;
5878 cfg->pwr_save = true; 5767 cfg->pwr_save = true;
5879 cfg->active_scan = true; /* we do active scan per default */
5880 cfg->dongle_up = false; /* dongle is not up yet */ 5768 cfg->dongle_up = false; /* dongle is not up yet */
5881 err = brcmf_init_priv_mem(cfg); 5769 err = brcmf_init_priv_mem(cfg);
5882 if (err) 5770 if (err)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
index 7b2835e5e434..b5b5f0f10b63 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
@@ -283,7 +283,6 @@ struct brcmf_cfg80211_wowl {
283 * @scan_status: scan activity on the dongle. 283 * @scan_status: scan activity on the dongle.
284 * @pub: common driver information. 284 * @pub: common driver information.
285 * @channel: current channel. 285 * @channel: current channel.
286 * @active_scan: current scan mode.
287 * @int_escan_map: bucket map for which internal e-scan is done. 286 * @int_escan_map: bucket map for which internal e-scan is done.
288 * @ibss_starter: indicates this sta is ibss starter. 287 * @ibss_starter: indicates this sta is ibss starter.
289 * @pwr_save: indicate whether dongle to support power save mode. 288 * @pwr_save: indicate whether dongle to support power save mode.
@@ -316,7 +315,6 @@ struct brcmf_cfg80211_info {
316 unsigned long scan_status; 315 unsigned long scan_status;
317 struct brcmf_pub *pub; 316 struct brcmf_pub *pub;
318 u32 channel; 317 u32 channel;
319 bool active_scan;
320 u32 int_escan_map; 318 u32 int_escan_map;
321 bool ibss_starter; 319 bool ibss_starter;
322 bool pwr_save; 320 bool pwr_save;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 7a2b49587b4d..6a59d0609d30 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -18,6 +18,7 @@
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/netdevice.h> 19#include <linux/netdevice.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/firmware.h>
21#include <brcmu_wifi.h> 22#include <brcmu_wifi.h>
22#include <brcmu_utils.h> 23#include <brcmu_utils.h>
23#include "core.h" 24#include "core.h"
@@ -28,6 +29,7 @@
28#include "tracepoint.h" 29#include "tracepoint.h"
29#include "common.h" 30#include "common.h"
30#include "of.h" 31#include "of.h"
32#include "firmware.h"
31 33
32MODULE_AUTHOR("Broadcom Corporation"); 34MODULE_AUTHOR("Broadcom Corporation");
33MODULE_DESCRIPTION("Broadcom 802.11 wireless LAN fullmac driver."); 35MODULE_DESCRIPTION("Broadcom 802.11 wireless LAN fullmac driver.");
@@ -104,12 +106,140 @@ void brcmf_c_set_joinpref_default(struct brcmf_if *ifp)
104 brcmf_err("Set join_pref error (%d)\n", err); 106 brcmf_err("Set join_pref error (%d)\n", err);
105} 107}
106 108
109static int brcmf_c_download(struct brcmf_if *ifp, u16 flag,
110 struct brcmf_dload_data_le *dload_buf,
111 u32 len)
112{
113 s32 err;
114
115 flag |= (DLOAD_HANDLER_VER << DLOAD_FLAG_VER_SHIFT);
116 dload_buf->flag = cpu_to_le16(flag);
117 dload_buf->dload_type = cpu_to_le16(DL_TYPE_CLM);
118 dload_buf->len = cpu_to_le32(len);
119 dload_buf->crc = cpu_to_le32(0);
120 len = sizeof(*dload_buf) + len - 1;
121
122 err = brcmf_fil_iovar_data_set(ifp, "clmload", dload_buf, len);
123
124 return err;
125}
126
127static int brcmf_c_get_clm_name(struct brcmf_if *ifp, u8 *clm_name)
128{
129 struct brcmf_bus *bus = ifp->drvr->bus_if;
130 struct brcmf_rev_info *ri = &ifp->drvr->revinfo;
131 u8 fw_name[BRCMF_FW_NAME_LEN];
132 u8 *ptr;
133 size_t len;
134 s32 err;
135
136 memset(fw_name, 0, BRCMF_FW_NAME_LEN);
137 err = brcmf_bus_get_fwname(bus, ri->chipnum, ri->chiprev, fw_name);
138 if (err) {
139 brcmf_err("get firmware name failed (%d)\n", err);
140 goto done;
141 }
142
143 /* generate CLM blob file name */
144 ptr = strrchr(fw_name, '.');
145 if (!ptr) {
146 err = -ENOENT;
147 goto done;
148 }
149
150 len = ptr - fw_name + 1;
151 if (len + strlen(".clm_blob") > BRCMF_FW_NAME_LEN) {
152 err = -E2BIG;
153 } else {
154 strlcpy(clm_name, fw_name, len);
155 strlcat(clm_name, ".clm_blob", BRCMF_FW_NAME_LEN);
156 }
157done:
158 return err;
159}
160
161static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
162{
163 struct device *dev = ifp->drvr->bus_if->dev;
164 struct brcmf_dload_data_le *chunk_buf;
165 const struct firmware *clm = NULL;
166 u8 clm_name[BRCMF_FW_NAME_LEN];
167 u32 chunk_len;
168 u32 datalen;
169 u32 cumulative_len;
170 u16 dl_flag = DL_BEGIN;
171 u32 status;
172 s32 err;
173
174 brcmf_dbg(TRACE, "Enter\n");
175
176 memset(clm_name, 0, BRCMF_FW_NAME_LEN);
177 err = brcmf_c_get_clm_name(ifp, clm_name);
178 if (err) {
179 brcmf_err("get CLM blob file name failed (%d)\n", err);
180 return err;
181 }
182
183 err = request_firmware(&clm, clm_name, dev);
184 if (err) {
185 if (err == -ENOENT) {
186 brcmf_dbg(INFO, "continue with CLM data currently present in firmware\n");
187 return 0;
188 }
189 brcmf_err("request CLM blob file failed (%d)\n", err);
190 return err;
191 }
192
193 chunk_buf = kzalloc(sizeof(*chunk_buf) + MAX_CHUNK_LEN - 1, GFP_KERNEL);
194 if (!chunk_buf) {
195 err = -ENOMEM;
196 goto done;
197 }
198
199 datalen = clm->size;
200 cumulative_len = 0;
201 do {
202 if (datalen > MAX_CHUNK_LEN) {
203 chunk_len = MAX_CHUNK_LEN;
204 } else {
205 chunk_len = datalen;
206 dl_flag |= DL_END;
207 }
208 memcpy(chunk_buf->data, clm->data + cumulative_len, chunk_len);
209
210 err = brcmf_c_download(ifp, dl_flag, chunk_buf, chunk_len);
211
212 dl_flag &= ~DL_BEGIN;
213
214 cumulative_len += chunk_len;
215 datalen -= chunk_len;
216 } while ((datalen > 0) && (err == 0));
217
218 if (err) {
219 brcmf_err("clmload (%zu byte file) failed (%d); ",
220 clm->size, err);
221 /* Retrieve clmload_status and print */
222 err = brcmf_fil_iovar_int_get(ifp, "clmload_status", &status);
223 if (err)
224 brcmf_err("get clmload_status failed (%d)\n", err);
225 else
226 brcmf_dbg(INFO, "clmload_status=%d\n", status);
227 err = -EIO;
228 }
229
230 kfree(chunk_buf);
231done:
232 release_firmware(clm);
233 return err;
234}
235
107int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) 236int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
108{ 237{
109 s8 eventmask[BRCMF_EVENTING_MASK_LEN]; 238 s8 eventmask[BRCMF_EVENTING_MASK_LEN];
110 u8 buf[BRCMF_DCMD_SMLEN]; 239 u8 buf[BRCMF_DCMD_SMLEN];
111 struct brcmf_rev_info_le revinfo; 240 struct brcmf_rev_info_le revinfo;
112 struct brcmf_rev_info *ri; 241 struct brcmf_rev_info *ri;
242 char *clmver;
113 char *ptr; 243 char *ptr;
114 s32 err; 244 s32 err;
115 245
@@ -148,6 +278,13 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
148 } 278 }
149 ri->result = err; 279 ri->result = err;
150 280
281 /* Do any CLM downloading */
282 err = brcmf_c_process_clm_blob(ifp);
283 if (err < 0) {
284 brcmf_err("download CLM blob file failed, %d\n", err);
285 goto done;
286 }
287
151 /* query for 'ver' to get version info from firmware */ 288 /* query for 'ver' to get version info from firmware */
152 memset(buf, 0, sizeof(buf)); 289 memset(buf, 0, sizeof(buf));
153 strcpy(buf, "ver"); 290 strcpy(buf, "ver");
@@ -167,6 +304,26 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
167 ptr = strrchr(buf, ' ') + 1; 304 ptr = strrchr(buf, ' ') + 1;
168 strlcpy(ifp->drvr->fwver, ptr, sizeof(ifp->drvr->fwver)); 305 strlcpy(ifp->drvr->fwver, ptr, sizeof(ifp->drvr->fwver));
169 306
307 /* Query for 'clmver' to get CLM version info from firmware */
308 memset(buf, 0, sizeof(buf));
309 err = brcmf_fil_iovar_data_get(ifp, "clmver", buf, sizeof(buf));
310 if (err) {
311 brcmf_dbg(TRACE, "retrieving clmver failed, %d\n", err);
312 } else {
313 clmver = (char *)buf;
314 /* store CLM version for adding it to revinfo debugfs file */
315 memcpy(ifp->drvr->clmver, clmver, sizeof(ifp->drvr->clmver));
316
317 /* Replace all newline/linefeed characters with space
318 * character
319 */
320 ptr = clmver;
321 while ((ptr = strnchr(ptr, '\n', sizeof(buf))) != NULL)
322 *ptr = ' ';
323
324 brcmf_dbg(INFO, "CLM version = %s\n", clmver);
325 }
326
170 /* set mpc */ 327 /* set mpc */
171 err = brcmf_fil_iovar_int_set(ifp, "mpc", 1); 328 err = brcmf_fil_iovar_int_set(ifp, "mpc", 1);
172 if (err) { 329 if (err) {
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 5cc3a07dda9e..930e423f83a8 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -71,6 +71,43 @@ struct brcmf_if *brcmf_get_ifp(struct brcmf_pub *drvr, int ifidx)
71 return ifp; 71 return ifp;
72} 72}
73 73
74void brcmf_configure_arp_nd_offload(struct brcmf_if *ifp, bool enable)
75{
76 s32 err;
77 u32 mode;
78
79 if (enable)
80 mode = BRCMF_ARP_OL_AGENT | BRCMF_ARP_OL_PEER_AUTO_REPLY;
81 else
82 mode = 0;
83
84 /* Try to set and enable ARP offload feature, this may fail, then it */
85 /* is simply not supported and err 0 will be returned */
86 err = brcmf_fil_iovar_int_set(ifp, "arp_ol", mode);
87 if (err) {
88 brcmf_dbg(TRACE, "failed to set ARP offload mode to 0x%x, err = %d\n",
89 mode, err);
90 } else {
91 err = brcmf_fil_iovar_int_set(ifp, "arpoe", enable);
92 if (err) {
93 brcmf_dbg(TRACE, "failed to configure (%d) ARP offload err = %d\n",
94 enable, err);
95 } else {
96 brcmf_dbg(TRACE, "successfully configured (%d) ARP offload to 0x%x\n",
97 enable, mode);
98 }
99 }
100
101 err = brcmf_fil_iovar_int_set(ifp, "ndoe", enable);
102 if (err) {
103 brcmf_dbg(TRACE, "failed to configure (%d) ND offload err = %d\n",
104 enable, err);
105 } else {
106 brcmf_dbg(TRACE, "successfully configured (%d) ND offload to 0x%x\n",
107 enable, mode);
108 }
109}
110
74static void _brcmf_set_multicast_list(struct work_struct *work) 111static void _brcmf_set_multicast_list(struct work_struct *work)
75{ 112{
76 struct brcmf_if *ifp; 113 struct brcmf_if *ifp;
@@ -134,6 +171,7 @@ static void _brcmf_set_multicast_list(struct work_struct *work)
134 if (err < 0) 171 if (err < 0)
135 brcmf_err("Setting BRCMF_C_SET_PROMISC failed, %d\n", 172 brcmf_err("Setting BRCMF_C_SET_PROMISC failed, %d\n",
136 err); 173 err);
174 brcmf_configure_arp_nd_offload(ifp, !cmd_value);
137} 175}
138 176
139#if IS_ENABLED(CONFIG_IPV6) 177#if IS_ENABLED(CONFIG_IPV6)
@@ -950,6 +988,8 @@ static int brcmf_revinfo_read(struct seq_file *s, void *data)
950 seq_printf(s, "anarev: %u\n", ri->anarev); 988 seq_printf(s, "anarev: %u\n", ri->anarev);
951 seq_printf(s, "nvramrev: %08x\n", ri->nvramrev); 989 seq_printf(s, "nvramrev: %08x\n", ri->nvramrev);
952 990
991 seq_printf(s, "clmver: %s\n", bus_if->drvr->clmver);
992
953 return 0; 993 return 0;
954} 994}
955 995
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
index a4dd313140f3..df8a1ecb9924 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
@@ -141,6 +141,8 @@ struct brcmf_pub {
141 struct notifier_block inetaddr_notifier; 141 struct notifier_block inetaddr_notifier;
142 struct notifier_block inet6addr_notifier; 142 struct notifier_block inet6addr_notifier;
143 struct brcmf_mp_device *settings; 143 struct brcmf_mp_device *settings;
144
145 u8 clmver[BRCMF_DCMD_SMLEN];
144}; 146};
145 147
146/* forward declarations */ 148/* forward declarations */
@@ -203,6 +205,7 @@ int brcmf_netdev_wait_pend8021x(struct brcmf_if *ifp);
203/* Return pointer to interface name */ 205/* Return pointer to interface name */
204char *brcmf_ifname(struct brcmf_if *ifp); 206char *brcmf_ifname(struct brcmf_if *ifp);
205struct brcmf_if *brcmf_get_ifp(struct brcmf_pub *drvr, int ifidx); 207struct brcmf_if *brcmf_get_ifp(struct brcmf_pub *drvr, int ifidx);
208void brcmf_configure_arp_nd_offload(struct brcmf_if *ifp, bool enable);
206int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked); 209int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
207struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bsscfgidx, s32 ifidx, 210struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bsscfgidx, s32 ifidx,
208 bool is_p2pdev, const char *name, u8 *mac_addr); 211 bool is_p2pdev, const char *name, u8 *mac_addr);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
index e0d22fedb2b4..4b290705e3e6 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
@@ -155,6 +155,21 @@
155#define BRCMF_MFP_CAPABLE 1 155#define BRCMF_MFP_CAPABLE 1
156#define BRCMF_MFP_REQUIRED 2 156#define BRCMF_MFP_REQUIRED 2
157 157
158/* MAX_CHUNK_LEN is the maximum length for data passing to firmware in each
159 * ioctl. It is relatively small because firmware has small maximum size input
160 * playload restriction for ioctls.
161 */
162#define MAX_CHUNK_LEN 1400
163
164#define DLOAD_HANDLER_VER 1 /* Downloader version */
165#define DLOAD_FLAG_VER_MASK 0xf000 /* Downloader version mask */
166#define DLOAD_FLAG_VER_SHIFT 12 /* Downloader version shift */
167
168#define DL_BEGIN 0x0002
169#define DL_END 0x0004
170
171#define DL_TYPE_CLM 2
172
158/* join preference types for join_pref iovar */ 173/* join preference types for join_pref iovar */
159enum brcmf_join_pref_types { 174enum brcmf_join_pref_types {
160 BRCMF_JOIN_PREF_RSSI = 1, 175 BRCMF_JOIN_PREF_RSSI = 1,
@@ -827,6 +842,22 @@ struct brcmf_pno_macaddr_le {
827}; 842};
828 843
829/** 844/**
845 * struct brcmf_dload_data_le - data passing to firmware for downloading
846 * @flag: flags related to download data.
847 * @dload_type: type of download data.
848 * @len: length in bytes of download data.
849 * @crc: crc of download data.
850 * @data: download data.
851 */
852struct brcmf_dload_data_le {
853 __le16 flag;
854 __le16 dload_type;
855 __le32 len;
856 __le32 crc;
857 u8 data[1];
858};
859
860/**
830 * struct brcmf_pno_bssid_le - bssid configuration for PNO scan. 861 * struct brcmf_pno_bssid_le - bssid configuration for PNO scan.
831 * 862 *
832 * @bssid: BSS network identifier. 863 * @bssid: BSS network identifier.
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
index 1c450c0727cb..2ee54133efa1 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
@@ -692,10 +692,7 @@ static s32 brcmf_p2p_escan(struct brcmf_p2p_info *p2p, u32 num_chans,
692 692
693 /* determine the scan engine parameters */ 693 /* determine the scan engine parameters */
694 sparams->bss_type = DOT11_BSSTYPE_ANY; 694 sparams->bss_type = DOT11_BSSTYPE_ANY;
695 if (p2p->cfg->active_scan) 695 sparams->scan_type = BRCMF_SCANTYPE_ACTIVE;
696 sparams->scan_type = 0;
697 else
698 sparams->scan_type = 1;
699 696
700 eth_broadcast_addr(sparams->bssid); 697 eth_broadcast_addr(sparams->bssid);
701 sparams->home_time = cpu_to_le32(P2PAPI_SCAN_HOME_TIME_MS); 698 sparams->home_time = cpu_to_le32(P2PAPI_SCAN_HOME_TIME_MS);
@@ -884,7 +881,7 @@ int brcmf_p2p_scan_prep(struct wiphy *wiphy,
884{ 881{
885 struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy); 882 struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
886 struct brcmf_p2p_info *p2p = &cfg->p2p; 883 struct brcmf_p2p_info *p2p = &cfg->p2p;
887 int err = 0; 884 int err;
888 885
889 if (brcmf_p2p_scan_is_p2p_request(request)) { 886 if (brcmf_p2p_scan_is_p2p_request(request)) {
890 /* find my listen channel */ 887 /* find my listen channel */
@@ -907,9 +904,7 @@ int brcmf_p2p_scan_prep(struct wiphy *wiphy,
907 /* override .run_escan() callback. */ 904 /* override .run_escan() callback. */
908 cfg->escan_info.run = brcmf_p2p_run_escan; 905 cfg->escan_info.run = brcmf_p2p_run_escan;
909 } 906 }
910 err = brcmf_vif_set_mgmt_ie(vif, BRCMF_VNDR_IE_PRBREQ_FLAG, 907 return 0;
911 request->ie, request->ie_len);
912 return err;
913} 908}
914 909
915 910
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index e6e9b00b79d7..3c87157f5b85 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -1350,6 +1350,24 @@ static int brcmf_pcie_get_memdump(struct device *dev, void *data, size_t len)
1350 return 0; 1350 return 0;
1351} 1351}
1352 1352
1353static int brcmf_pcie_get_fwname(struct device *dev, u32 chip, u32 chiprev,
1354 u8 *fw_name)
1355{
1356 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
1357 struct brcmf_pciedev *buspub = bus_if->bus_priv.pcie;
1358 struct brcmf_pciedev_info *devinfo = buspub->devinfo;
1359 int ret = 0;
1360
1361 if (devinfo->fw_name[0] != '\0')
1362 strlcpy(fw_name, devinfo->fw_name, BRCMF_FW_NAME_LEN);
1363 else
1364 ret = brcmf_fw_map_chip_to_name(chip, chiprev,
1365 brcmf_pcie_fwnames,
1366 ARRAY_SIZE(brcmf_pcie_fwnames),
1367 fw_name, NULL);
1368
1369 return ret;
1370}
1353 1371
1354static const struct brcmf_bus_ops brcmf_pcie_bus_ops = { 1372static const struct brcmf_bus_ops brcmf_pcie_bus_ops = {
1355 .txdata = brcmf_pcie_tx, 1373 .txdata = brcmf_pcie_tx,
@@ -1359,6 +1377,7 @@ static const struct brcmf_bus_ops brcmf_pcie_bus_ops = {
1359 .wowl_config = brcmf_pcie_wowl_config, 1377 .wowl_config = brcmf_pcie_wowl_config,
1360 .get_ramsize = brcmf_pcie_get_ramsize, 1378 .get_ramsize = brcmf_pcie_get_ramsize,
1361 .get_memdump = brcmf_pcie_get_memdump, 1379 .get_memdump = brcmf_pcie_get_memdump,
1380 .get_fwname = brcmf_pcie_get_fwname,
1362}; 1381};
1363 1382
1364 1383
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 5adce0e36fe5..b2256aa76eb6 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -260,10 +260,11 @@ struct rte_console {
260#define I_HMB_HOST_INT I_HMB_SW3 /* Miscellaneous Interrupt */ 260#define I_HMB_HOST_INT I_HMB_SW3 /* Miscellaneous Interrupt */
261 261
262/* tohostmailboxdata */ 262/* tohostmailboxdata */
263#define HMB_DATA_NAKHANDLED 1 /* retransmit NAK'd frame */ 263#define HMB_DATA_NAKHANDLED 0x0001 /* retransmit NAK'd frame */
264#define HMB_DATA_DEVREADY 2 /* talk to host after enable */ 264#define HMB_DATA_DEVREADY 0x0002 /* talk to host after enable */
265#define HMB_DATA_FC 4 /* per prio flowcontrol update flag */ 265#define HMB_DATA_FC 0x0004 /* per prio flowcontrol update flag */
266#define HMB_DATA_FWREADY 8 /* fw ready for protocol activity */ 266#define HMB_DATA_FWREADY 0x0008 /* fw ready for protocol activity */
267#define HMB_DATA_FWHALT 0x0010 /* firmware halted */
267 268
268#define HMB_DATA_FCDATA_MASK 0xff000000 269#define HMB_DATA_FCDATA_MASK 0xff000000
269#define HMB_DATA_FCDATA_SHIFT 24 270#define HMB_DATA_FCDATA_SHIFT 24
@@ -1094,6 +1095,10 @@ static u32 brcmf_sdio_hostmail(struct brcmf_sdio *bus)
1094 offsetof(struct sdpcmd_regs, tosbmailbox)); 1095 offsetof(struct sdpcmd_regs, tosbmailbox));
1095 bus->sdcnt.f1regdata += 2; 1096 bus->sdcnt.f1regdata += 2;
1096 1097
1098 /* dongle indicates the firmware has halted/crashed */
1099 if (hmb_data & HMB_DATA_FWHALT)
1100 brcmf_err("mailbox indicates firmware halted\n");
1101
1097 /* Dongle recomposed rx frames, accept them again */ 1102 /* Dongle recomposed rx frames, accept them again */
1098 if (hmb_data & HMB_DATA_NAKHANDLED) { 1103 if (hmb_data & HMB_DATA_NAKHANDLED) {
1099 brcmf_dbg(SDIO, "Dongle reports NAK handled, expect rtx of %d\n", 1104 brcmf_dbg(SDIO, "Dongle reports NAK handled, expect rtx of %d\n",
@@ -1151,6 +1156,7 @@ static u32 brcmf_sdio_hostmail(struct brcmf_sdio *bus)
1151 HMB_DATA_NAKHANDLED | 1156 HMB_DATA_NAKHANDLED |
1152 HMB_DATA_FC | 1157 HMB_DATA_FC |
1153 HMB_DATA_FWREADY | 1158 HMB_DATA_FWREADY |
1159 HMB_DATA_FWHALT |
1154 HMB_DATA_FCDATA_MASK | HMB_DATA_VERSION_MASK)) 1160 HMB_DATA_FCDATA_MASK | HMB_DATA_VERSION_MASK))
1155 brcmf_err("Unknown mailbox data content: 0x%02x\n", 1161 brcmf_err("Unknown mailbox data content: 0x%02x\n",
1156 hmb_data); 1162 hmb_data);
@@ -3979,6 +3985,24 @@ brcmf_sdio_watchdog(unsigned long data)
3979 } 3985 }
3980} 3986}
3981 3987
3988static int brcmf_sdio_get_fwname(struct device *dev, u32 chip, u32 chiprev,
3989 u8 *fw_name)
3990{
3991 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
3992 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
3993 int ret = 0;
3994
3995 if (sdiodev->fw_name[0] != '\0')
3996 strlcpy(fw_name, sdiodev->fw_name, BRCMF_FW_NAME_LEN);
3997 else
3998 ret = brcmf_fw_map_chip_to_name(chip, chiprev,
3999 brcmf_sdio_fwnames,
4000 ARRAY_SIZE(brcmf_sdio_fwnames),
4001 fw_name, NULL);
4002
4003 return ret;
4004}
4005
3982static const struct brcmf_bus_ops brcmf_sdio_bus_ops = { 4006static const struct brcmf_bus_ops brcmf_sdio_bus_ops = {
3983 .stop = brcmf_sdio_bus_stop, 4007 .stop = brcmf_sdio_bus_stop,
3984 .preinit = brcmf_sdio_bus_preinit, 4008 .preinit = brcmf_sdio_bus_preinit,
@@ -3989,6 +4013,7 @@ static const struct brcmf_bus_ops brcmf_sdio_bus_ops = {
3989 .wowl_config = brcmf_sdio_wowl_config, 4013 .wowl_config = brcmf_sdio_wowl_config,
3990 .get_ramsize = brcmf_sdio_bus_get_ramsize, 4014 .get_ramsize = brcmf_sdio_bus_get_ramsize,
3991 .get_memdump = brcmf_sdio_bus_get_memdump, 4015 .get_memdump = brcmf_sdio_bus_get_memdump,
4016 .get_fwname = brcmf_sdio_get_fwname,
3992}; 4017};
3993 4018
3994static void brcmf_sdio_firmware_callback(struct device *dev, int err, 4019static void brcmf_sdio_firmware_callback(struct device *dev, int err,
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index 11ffaa01599e..b27170c12482 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -1128,12 +1128,30 @@ static void brcmf_usb_wowl_config(struct device *dev, bool enabled)
1128 device_set_wakeup_enable(devinfo->dev, false); 1128 device_set_wakeup_enable(devinfo->dev, false);
1129} 1129}
1130 1130
1131static int brcmf_usb_get_fwname(struct device *dev, u32 chip, u32 chiprev,
1132 u8 *fw_name)
1133{
1134 struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev);
1135 int ret = 0;
1136
1137 if (devinfo->fw_name[0] != '\0')
1138 strlcpy(fw_name, devinfo->fw_name, BRCMF_FW_NAME_LEN);
1139 else
1140 ret = brcmf_fw_map_chip_to_name(chip, chiprev,
1141 brcmf_usb_fwnames,
1142 ARRAY_SIZE(brcmf_usb_fwnames),
1143 fw_name, NULL);
1144
1145 return ret;
1146}
1147
1131static const struct brcmf_bus_ops brcmf_usb_bus_ops = { 1148static const struct brcmf_bus_ops brcmf_usb_bus_ops = {
1132 .txdata = brcmf_usb_tx, 1149 .txdata = brcmf_usb_tx,
1133 .stop = brcmf_usb_down, 1150 .stop = brcmf_usb_down,
1134 .txctl = brcmf_usb_tx_ctlpkt, 1151 .txctl = brcmf_usb_tx_ctlpkt,
1135 .rxctl = brcmf_usb_rx_ctlpkt, 1152 .rxctl = brcmf_usb_rx_ctlpkt,
1136 .wowl_config = brcmf_usb_wowl_config, 1153 .wowl_config = brcmf_usb_wowl_config,
1154 .get_fwname = brcmf_usb_get_fwname,
1137}; 1155};
1138 1156
1139static int brcmf_usb_bus_setup(struct brcmf_usbdev_info *devinfo) 1157static int brcmf_usb_bus_setup(struct brcmf_usbdev_info *devinfo)
diff --git a/drivers/net/wireless/intel/iwlegacy/4965-rs.c b/drivers/net/wireless/intel/iwlegacy/4965-rs.c
index c055f6da11c6..365a4187fc37 100644
--- a/drivers/net/wireless/intel/iwlegacy/4965-rs.c
+++ b/drivers/net/wireless/intel/iwlegacy/4965-rs.c
@@ -2154,13 +2154,11 @@ il4965_rs_initialize_lq(struct il_priv *il, struct ieee80211_conf *conf,
2154 u8 use_green; 2154 u8 use_green;
2155 u8 active_tbl = 0; 2155 u8 active_tbl = 0;
2156 u8 valid_tx_ant; 2156 u8 valid_tx_ant;
2157 struct il_station_priv *sta_priv;
2158 2157
2159 if (!sta || !lq_sta) 2158 if (!sta || !lq_sta)
2160 return; 2159 return;
2161 2160
2162 use_green = il4965_rs_use_green(il, sta); 2161 use_green = il4965_rs_use_green(il, sta);
2163 sta_priv = (void *)sta->drv_priv;
2164 2162
2165 i = lq_sta->last_txrate_idx; 2163 i = lq_sta->last_txrate_idx;
2166 2164
diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/8000.c b/drivers/net/wireless/intel/iwlwifi/cfg/8000.c
index 1dce74afcd75..9bb7c19d48eb 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/8000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/8000.c
@@ -100,14 +100,6 @@
100#define NVM_HW_SECTION_NUM_FAMILY_8000 10 100#define NVM_HW_SECTION_NUM_FAMILY_8000 10
101#define DEFAULT_NVM_FILE_FAMILY_8000C "nvmData-8000C" 101#define DEFAULT_NVM_FILE_FAMILY_8000C "nvmData-8000C"
102 102
103/* Max SDIO RX/TX aggregation sizes of the ADDBA request/response */
104#define MAX_RX_AGG_SIZE_8260_SDIO 21
105#define MAX_TX_AGG_SIZE_8260_SDIO 40
106
107/* Max A-MPDU exponent for HT and VHT */
108#define MAX_HT_AMPDU_EXPONENT_8260_SDIO IEEE80211_HT_MAX_AMPDU_32K
109#define MAX_VHT_AMPDU_EXPONENT_8260_SDIO IEEE80211_VHT_MAX_AMPDU_32K
110
111static const struct iwl_base_params iwl8000_base_params = { 103static const struct iwl_base_params iwl8000_base_params = {
112 .eeprom_size = OTP_LOW_IMAGE_SIZE_FAMILY_8000, 104 .eeprom_size = OTP_LOW_IMAGE_SIZE_FAMILY_8000,
113 .num_of_queues = 31, 105 .num_of_queues = 31,
@@ -234,48 +226,5 @@ const struct iwl_cfg iwl4165_2ac_cfg = {
234 .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K, 226 .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K,
235}; 227};
236 228
237const struct iwl_cfg iwl8260_2ac_sdio_cfg = {
238 .name = "Intel(R) Dual Band Wireless-AC 8260",
239 .fw_name_pre = IWL8000_FW_PRE,
240 IWL_DEVICE_8260,
241 .ht_params = &iwl8000_ht_params,
242 .nvm_ver = IWL8000_NVM_VERSION,
243 .nvm_calib_ver = IWL8000_TX_POWER_VERSION,
244 .max_rx_agg_size = MAX_RX_AGG_SIZE_8260_SDIO,
245 .max_tx_agg_size = MAX_TX_AGG_SIZE_8260_SDIO,
246 .disable_dummy_notification = true,
247 .max_ht_ampdu_exponent = MAX_HT_AMPDU_EXPONENT_8260_SDIO,
248 .max_vht_ampdu_exponent = MAX_VHT_AMPDU_EXPONENT_8260_SDIO,
249};
250
251const struct iwl_cfg iwl8265_2ac_sdio_cfg = {
252 .name = "Intel(R) Dual Band Wireless-AC 8265",
253 .fw_name_pre = IWL8265_FW_PRE,
254 IWL_DEVICE_8265,
255 .ht_params = &iwl8000_ht_params,
256 .nvm_ver = IWL8000_NVM_VERSION,
257 .nvm_calib_ver = IWL8000_TX_POWER_VERSION,
258 .max_rx_agg_size = MAX_RX_AGG_SIZE_8260_SDIO,
259 .max_tx_agg_size = MAX_TX_AGG_SIZE_8260_SDIO,
260 .disable_dummy_notification = true,
261 .max_ht_ampdu_exponent = MAX_HT_AMPDU_EXPONENT_8260_SDIO,
262 .max_vht_ampdu_exponent = MAX_VHT_AMPDU_EXPONENT_8260_SDIO,
263};
264
265const struct iwl_cfg iwl4165_2ac_sdio_cfg = {
266 .name = "Intel(R) Dual Band Wireless-AC 4165",
267 .fw_name_pre = IWL8000_FW_PRE,
268 IWL_DEVICE_8000,
269 .ht_params = &iwl8000_ht_params,
270 .nvm_ver = IWL8000_NVM_VERSION,
271 .nvm_calib_ver = IWL8000_TX_POWER_VERSION,
272 .max_rx_agg_size = MAX_RX_AGG_SIZE_8260_SDIO,
273 .max_tx_agg_size = MAX_TX_AGG_SIZE_8260_SDIO,
274 .bt_shared_single_ant = true,
275 .disable_dummy_notification = true,
276 .max_ht_ampdu_exponent = MAX_HT_AMPDU_EXPONENT_8260_SDIO,
277 .max_vht_ampdu_exponent = MAX_VHT_AMPDU_EXPONENT_8260_SDIO,
278};
279
280MODULE_FIRMWARE(IWL8000_MODULE_FIRMWARE(IWL8000_UCODE_API_MAX)); 229MODULE_FIRMWARE(IWL8000_MODULE_FIRMWARE(IWL8000_UCODE_API_MAX));
281MODULE_FIRMWARE(IWL8265_MODULE_FIRMWARE(IWL8265_UCODE_API_MAX)); 230MODULE_FIRMWARE(IWL8265_MODULE_FIRMWARE(IWL8265_UCODE_API_MAX));
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/paging.h b/drivers/net/wireless/intel/iwlwifi/fw/api/paging.h
index e76f9cd4473d..721b9fed7201 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/paging.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/paging.h
@@ -81,28 +81,4 @@ struct iwl_fw_paging_cmd {
81 __le32 device_phy_addr[NUM_OF_FW_PAGING_BLOCKS]; 81 __le32 device_phy_addr[NUM_OF_FW_PAGING_BLOCKS];
82} __packed; /* FW_PAGING_BLOCK_CMD_API_S_VER_1 */ 82} __packed; /* FW_PAGING_BLOCK_CMD_API_S_VER_1 */
83 83
84/**
85 * enum iwl_fw_item_id - FW item IDs
86 *
87 * @IWL_FW_ITEM_ID_PAGING: Address of the pages that the FW will upload
88 * download
89 */
90enum iwl_fw_item_id {
91 IWL_FW_ITEM_ID_PAGING = 3,
92};
93
94/**
95 * struct iwl_fw_get_item_cmd - get an item from the fw
96 * @item_id: ID of item to obtain, see &enum iwl_fw_item_id
97 */
98struct iwl_fw_get_item_cmd {
99 __le32 item_id;
100} __packed; /* FW_GET_ITEM_CMD_API_S_VER_1 */
101
102struct iwl_fw_get_item_resp {
103 __le32 item_id;
104 __le32 item_byte_cnt;
105 __le32 item_val;
106} __packed; /* FW_GET_ITEM_RSP_S_VER_1 */
107
108#endif /* __iwl_fw_api_paging_h__ */ 84#endif /* __iwl_fw_api_paging_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h b/drivers/net/wireless/intel/iwlwifi/fw/file.h
index efd7fb65de8b..740d97093d1c 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/file.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h
@@ -136,7 +136,7 @@ enum iwl_ucode_tlv_type {
136 IWL_UCODE_TLV_N_SCAN_CHANNELS = 31, 136 IWL_UCODE_TLV_N_SCAN_CHANNELS = 31,
137 IWL_UCODE_TLV_PAGING = 32, 137 IWL_UCODE_TLV_PAGING = 32,
138 IWL_UCODE_TLV_SEC_RT_USNIFFER = 34, 138 IWL_UCODE_TLV_SEC_RT_USNIFFER = 34,
139 IWL_UCODE_TLV_SDIO_ADMA_ADDR = 35, 139 /* 35 is unused */
140 IWL_UCODE_TLV_FW_VERSION = 36, 140 IWL_UCODE_TLV_FW_VERSION = 36,
141 IWL_UCODE_TLV_FW_DBG_DEST = 38, 141 IWL_UCODE_TLV_FW_DBG_DEST = 38,
142 IWL_UCODE_TLV_FW_DBG_CONF = 39, 142 IWL_UCODE_TLV_FW_DBG_CONF = 39,
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/img.h b/drivers/net/wireless/intel/iwlwifi/fw/img.h
index e6bc9cb60700..985496cc01d0 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/img.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/img.h
@@ -138,11 +138,6 @@ struct fw_img {
138 u32 paging_mem_size; 138 u32 paging_mem_size;
139}; 139};
140 140
141struct iwl_sf_region {
142 u32 addr;
143 u32 size;
144};
145
146/* 141/*
147 * Block paging calculations 142 * Block paging calculations
148 */ 143 */
@@ -257,7 +252,6 @@ enum iwl_fw_type {
257 * @type: firmware type (&enum iwl_fw_type) 252 * @type: firmware type (&enum iwl_fw_type)
258 * @cipher_scheme: optional external cipher scheme. 253 * @cipher_scheme: optional external cipher scheme.
259 * @human_readable: human readable version 254 * @human_readable: human readable version
260 * @sdio_adma_addr: the default address to set for the ADMA in SDIO mode until
261 * we get the ALIVE from the uCode 255 * we get the ALIVE from the uCode
262 * @dbg_dest_tlv: points to the destination TLV for debug 256 * @dbg_dest_tlv: points to the destination TLV for debug
263 * @dbg_conf_tlv: array of pointers to configuration TLVs for debug 257 * @dbg_conf_tlv: array of pointers to configuration TLVs for debug
@@ -290,8 +284,6 @@ struct iwl_fw {
290 struct iwl_fw_cipher_scheme cs[IWL_UCODE_MAX_CS]; 284 struct iwl_fw_cipher_scheme cs[IWL_UCODE_MAX_CS];
291 u8 human_readable[FW_VER_HUMAN_READABLE_SZ]; 285 u8 human_readable[FW_VER_HUMAN_READABLE_SZ];
292 286
293 u32 sdio_adma_addr;
294
295 struct iwl_fw_dbg_dest_tlv *dbg_dest_tlv; 287 struct iwl_fw_dbg_dest_tlv *dbg_dest_tlv;
296 struct iwl_fw_dbg_conf_tlv *dbg_conf_tlv[FW_DBG_CONF_MAX]; 288 struct iwl_fw_dbg_conf_tlv *dbg_conf_tlv[FW_DBG_CONF_MAX];
297 size_t dbg_conf_tlv_len[FW_DBG_CONF_MAX]; 289 size_t dbg_conf_tlv_len[FW_DBG_CONF_MAX];
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/paging.c b/drivers/net/wireless/intel/iwlwifi/fw/paging.c
index 1610722b8099..1fec8e3a6b35 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/paging.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/paging.c
@@ -87,9 +87,6 @@ void iwl_free_fw_paging(struct iwl_fw_runtime *fwrt)
87 get_order(paging->fw_paging_size)); 87 get_order(paging->fw_paging_size));
88 paging->fw_paging_block = NULL; 88 paging->fw_paging_block = NULL;
89 } 89 }
90 kfree(fwrt->trans->paging_download_buf);
91 fwrt->trans->paging_download_buf = NULL;
92 fwrt->trans->paging_db = NULL;
93 90
94 memset(fwrt->fw_paging_db, 0, sizeof(fwrt->fw_paging_db)); 91 memset(fwrt->fw_paging_db, 0, sizeof(fwrt->fw_paging_db));
95} 92}
@@ -100,13 +97,11 @@ static int iwl_alloc_fw_paging_mem(struct iwl_fw_runtime *fwrt,
100{ 97{
101 struct page *block; 98 struct page *block;
102 dma_addr_t phys = 0; 99 dma_addr_t phys = 0;
103 int blk_idx, order, num_of_pages, size, dma_enabled; 100 int blk_idx, order, num_of_pages, size;
104 101
105 if (fwrt->fw_paging_db[0].fw_paging_block) 102 if (fwrt->fw_paging_db[0].fw_paging_block)
106 return 0; 103 return 0;
107 104
108 dma_enabled = is_device_dma_capable(fwrt->trans->dev);
109
110 /* ensure BLOCK_2_EXP_SIZE is power of 2 of PAGING_BLOCK_SIZE */ 105 /* ensure BLOCK_2_EXP_SIZE is power of 2 of PAGING_BLOCK_SIZE */
111 BUILD_BUG_ON(BIT(BLOCK_2_EXP_SIZE) != PAGING_BLOCK_SIZE); 106 BUILD_BUG_ON(BIT(BLOCK_2_EXP_SIZE) != PAGING_BLOCK_SIZE);
112 107
@@ -139,24 +134,18 @@ static int iwl_alloc_fw_paging_mem(struct iwl_fw_runtime *fwrt,
139 fwrt->fw_paging_db[blk_idx].fw_paging_block = block; 134 fwrt->fw_paging_db[blk_idx].fw_paging_block = block;
140 fwrt->fw_paging_db[blk_idx].fw_paging_size = size; 135 fwrt->fw_paging_db[blk_idx].fw_paging_size = size;
141 136
142 if (dma_enabled) { 137 phys = dma_map_page(fwrt->trans->dev, block, 0,
143 phys = dma_map_page(fwrt->trans->dev, block, 0, 138 PAGE_SIZE << order,
144 PAGE_SIZE << order, 139 DMA_BIDIRECTIONAL);
145 DMA_BIDIRECTIONAL); 140 if (dma_mapping_error(fwrt->trans->dev, phys)) {
146 if (dma_mapping_error(fwrt->trans->dev, phys)) { 141 /*
147 /* 142 * free the previous pages and the current one
148 * free the previous pages and the current one 143 * since we failed to map_page.
149 * since we failed to map_page. 144 */
150 */ 145 iwl_free_fw_paging(fwrt);
151 iwl_free_fw_paging(fwrt); 146 return -ENOMEM;
152 return -ENOMEM;
153 }
154 fwrt->fw_paging_db[blk_idx].fw_paging_phys = phys;
155 } else {
156 fwrt->fw_paging_db[blk_idx].fw_paging_phys =
157 PAGING_ADDR_SIG |
158 blk_idx << BLOCK_2_EXP_SIZE;
159 } 147 }
148 fwrt->fw_paging_db[blk_idx].fw_paging_phys = phys;
160 149
161 if (!blk_idx) 150 if (!blk_idx)
162 IWL_DEBUG_FW(fwrt, 151 IWL_DEBUG_FW(fwrt,
@@ -312,60 +301,6 @@ static int iwl_send_paging_cmd(struct iwl_fw_runtime *fwrt,
312 return iwl_trans_send_cmd(fwrt->trans, &hcmd); 301 return iwl_trans_send_cmd(fwrt->trans, &hcmd);
313} 302}
314 303
315/*
316 * Send paging item cmd to FW in case CPU2 has paging image
317 */
318static int iwl_trans_get_paging_item(struct iwl_fw_runtime *fwrt)
319{
320 int ret;
321 struct iwl_fw_get_item_cmd fw_get_item_cmd = {
322 .item_id = cpu_to_le32(IWL_FW_ITEM_ID_PAGING),
323 };
324 struct iwl_fw_get_item_resp *item_resp;
325 struct iwl_host_cmd cmd = {
326 .id = iwl_cmd_id(FW_GET_ITEM_CMD, IWL_ALWAYS_LONG_GROUP, 0),
327 .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
328 .data = { &fw_get_item_cmd, },
329 .len = { sizeof(fw_get_item_cmd), },
330 };
331
332 ret = iwl_trans_send_cmd(fwrt->trans, &cmd);
333 if (ret) {
334 IWL_ERR(fwrt,
335 "Paging: Failed to send FW_GET_ITEM_CMD cmd (err = %d)\n",
336 ret);
337 return ret;
338 }
339
340 item_resp = (void *)((struct iwl_rx_packet *)cmd.resp_pkt)->data;
341 if (item_resp->item_id != cpu_to_le32(IWL_FW_ITEM_ID_PAGING)) {
342 IWL_ERR(fwrt,
343 "Paging: got wrong item in FW_GET_ITEM_CMD resp (item_id = %u)\n",
344 le32_to_cpu(item_resp->item_id));
345 ret = -EIO;
346 goto exit;
347 }
348
349 /* Add an extra page for headers */
350 fwrt->trans->paging_download_buf = kzalloc(PAGING_BLOCK_SIZE +
351 FW_PAGING_SIZE,
352 GFP_KERNEL);
353 if (!fwrt->trans->paging_download_buf) {
354 ret = -ENOMEM;
355 goto exit;
356 }
357 fwrt->trans->paging_req_addr = le32_to_cpu(item_resp->item_val);
358 fwrt->trans->paging_db = fwrt->fw_paging_db;
359 IWL_DEBUG_FW(fwrt,
360 "Paging: got paging request address (paging_req_addr 0x%08x)\n",
361 fwrt->trans->paging_req_addr);
362
363exit:
364 iwl_free_resp(&cmd);
365
366 return ret;
367}
368
369int iwl_init_paging(struct iwl_fw_runtime *fwrt, enum iwl_ucode_type type) 304int iwl_init_paging(struct iwl_fw_runtime *fwrt, enum iwl_ucode_type type)
370{ 305{
371 const struct fw_img *fw = &fwrt->fw->img[type]; 306 const struct fw_img *fw = &fwrt->fw->img[type];
@@ -382,20 +317,6 @@ int iwl_init_paging(struct iwl_fw_runtime *fwrt, enum iwl_ucode_type type)
382 if (!fw->paging_mem_size) 317 if (!fw->paging_mem_size)
383 return 0; 318 return 0;
384 319
385 /*
386 * When dma is not enabled, the driver needs to copy / write
387 * the downloaded / uploaded page to / from the smem.
388 * This gets the location of the place were the pages are
389 * stored.
390 */
391 if (!is_device_dma_capable(fwrt->trans->dev)) {
392 ret = iwl_trans_get_paging_item(fwrt);
393 if (ret) {
394 IWL_ERR(fwrt, "failed to get FW paging item\n");
395 return ret;
396 }
397 }
398
399 ret = iwl_save_fw_paging(fwrt, fw); 320 ret = iwl_save_fw_paging(fwrt, fw);
400 if (ret) { 321 if (ret) {
401 IWL_ERR(fwrt, "failed to save the FW paging image\n"); 322 IWL_ERR(fwrt, "failed to save the FW paging image\n");
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-config.h b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
index 86a796025750..d1263a554420 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-config.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
@@ -467,9 +467,6 @@ extern const struct iwl_cfg iwl8260_2ac_cfg;
467extern const struct iwl_cfg iwl8265_2ac_cfg; 467extern const struct iwl_cfg iwl8265_2ac_cfg;
468extern const struct iwl_cfg iwl8275_2ac_cfg; 468extern const struct iwl_cfg iwl8275_2ac_cfg;
469extern const struct iwl_cfg iwl4165_2ac_cfg; 469extern const struct iwl_cfg iwl4165_2ac_cfg;
470extern const struct iwl_cfg iwl8260_2ac_sdio_cfg;
471extern const struct iwl_cfg iwl8265_2ac_sdio_cfg;
472extern const struct iwl_cfg iwl4165_2ac_sdio_cfg;
473extern const struct iwl_cfg iwl9160_2ac_cfg; 470extern const struct iwl_cfg iwl9160_2ac_cfg;
474extern const struct iwl_cfg iwl9260_2ac_cfg; 471extern const struct iwl_cfg iwl9260_2ac_cfg;
475extern const struct iwl_cfg iwl9270_2ac_cfg; 472extern const struct iwl_cfg iwl9270_2ac_cfg;
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
index b03e0f975b5a..4f0d070eda54 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-csr.h
@@ -218,7 +218,6 @@
218#define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */ 218#define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */
219#define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */ 219#define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */
220#define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */ 220#define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */
221#define CSR_INT_BIT_PAGING (1 << 24) /* SDIO PAGING */
222#define CSR_INT_BIT_RF_KILL (1 << 7) /* HW RFKILL switch GP_CNTRL[27] toggled */ 221#define CSR_INT_BIT_RF_KILL (1 << 7) /* HW RFKILL switch GP_CNTRL[27] toggled */
223#define CSR_INT_BIT_CT_KILL (1 << 6) /* Critical temp (chip too hot) rfkill */ 222#define CSR_INT_BIT_CT_KILL (1 << 6) /* Critical temp (chip too hot) rfkill */
224#define CSR_INT_BIT_SW_RX (1 << 3) /* Rx, command responses */ 223#define CSR_INT_BIT_SW_RX (1 << 3) /* Rx, command responses */
@@ -229,7 +228,6 @@
229 CSR_INT_BIT_HW_ERR | \ 228 CSR_INT_BIT_HW_ERR | \
230 CSR_INT_BIT_FH_TX | \ 229 CSR_INT_BIT_FH_TX | \
231 CSR_INT_BIT_SW_ERR | \ 230 CSR_INT_BIT_SW_ERR | \
232 CSR_INT_BIT_PAGING | \
233 CSR_INT_BIT_RF_KILL | \ 231 CSR_INT_BIT_RF_KILL | \
234 CSR_INT_BIT_SW_RX | \ 232 CSR_INT_BIT_SW_RX | \
235 CSR_INT_BIT_WAKEUP | \ 233 CSR_INT_BIT_WAKEUP | \
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index ccdb247d68c5..4b224d7d967c 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -1039,12 +1039,6 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
1039 drv->fw.img[usniffer_img].paging_mem_size = 1039 drv->fw.img[usniffer_img].paging_mem_size =
1040 paging_mem_size; 1040 paging_mem_size;
1041 break; 1041 break;
1042 case IWL_UCODE_TLV_SDIO_ADMA_ADDR:
1043 if (tlv_len != sizeof(u32))
1044 goto invalid_tlv_len;
1045 drv->fw.sdio_adma_addr =
1046 le32_to_cpup((__le32 *)tlv_data);
1047 break;
1048 case IWL_UCODE_TLV_FW_GSCAN_CAPA: 1042 case IWL_UCODE_TLV_FW_GSCAN_CAPA:
1049 /* 1043 /*
1050 * Don't return an error in case of a shorter tlv_len 1044 * Don't return an error in case of a shorter tlv_len
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index bba4f54cbbbb..ca0b5536a8a6 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -398,8 +398,6 @@ struct iwl_hcmd_arr {
398 * @command_groups: array of command groups, each member is an array of the 398 * @command_groups: array of command groups, each member is an array of the
399 * commands in the group; for debugging only 399 * commands in the group; for debugging only
400 * @command_groups_size: number of command groups, to avoid illegal access 400 * @command_groups_size: number of command groups, to avoid illegal access
401 * @sdio_adma_addr: the default address to set for the ADMA in SDIO mode until
402 * we get the ALIVE from the uCode
403 * @cb_data_offs: offset inside skb->cb to store transport data at, must have 401 * @cb_data_offs: offset inside skb->cb to store transport data at, must have
404 * space for at least two pointers 402 * space for at least two pointers
405 */ 403 */
@@ -419,8 +417,6 @@ struct iwl_trans_config {
419 const struct iwl_hcmd_arr *command_groups; 417 const struct iwl_hcmd_arr *command_groups;
420 int command_groups_size; 418 int command_groups_size;
421 419
422 u32 sdio_adma_addr;
423
424 u8 cb_data_offs; 420 u8 cb_data_offs;
425}; 421};
426 422
@@ -524,6 +520,9 @@ struct iwl_trans_txq_scd_cfg {
524 * @dump_data: return a vmalloc'ed buffer with debug data, maybe containing last 520 * @dump_data: return a vmalloc'ed buffer with debug data, maybe containing last
525 * TX'ed commands and similar. The buffer will be vfree'd by the caller. 521 * TX'ed commands and similar. The buffer will be vfree'd by the caller.
526 * Note that the transport must fill in the proper file headers. 522 * Note that the transport must fill in the proper file headers.
523 * @dump_regs: dump using IWL_ERR configuration space and memory mapped
524 * registers of the device to diagnose failure, e.g., when HW becomes
525 * inaccessible.
527 */ 526 */
528struct iwl_trans_ops { 527struct iwl_trans_ops {
529 528
@@ -531,8 +530,6 @@ struct iwl_trans_ops {
531 void (*op_mode_leave)(struct iwl_trans *iwl_trans); 530 void (*op_mode_leave)(struct iwl_trans *iwl_trans);
532 int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw, 531 int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw,
533 bool run_in_rfkill); 532 bool run_in_rfkill);
534 int (*update_sf)(struct iwl_trans *trans,
535 struct iwl_sf_region *st_fwrd_space);
536 void (*fw_alive)(struct iwl_trans *trans, u32 scd_addr); 533 void (*fw_alive)(struct iwl_trans *trans, u32 scd_addr);
537 void (*stop_device)(struct iwl_trans *trans, bool low_power); 534 void (*stop_device)(struct iwl_trans *trans, bool low_power);
538 535
@@ -593,6 +590,8 @@ struct iwl_trans_ops {
593 struct iwl_trans_dump_data *(*dump_data)(struct iwl_trans *trans, 590 struct iwl_trans_dump_data *(*dump_data)(struct iwl_trans *trans,
594 const struct iwl_fw_dbg_trigger_tlv 591 const struct iwl_fw_dbg_trigger_tlv
595 *trigger); 592 *trigger);
593
594 void (*dump_regs)(struct iwl_trans *trans);
596}; 595};
597 596
598/** 597/**
@@ -700,12 +699,6 @@ enum iwl_plat_pm_mode {
700 * @dbg_conf_tlv: array of pointers to configuration TLVs for debug 699 * @dbg_conf_tlv: array of pointers to configuration TLVs for debug
701 * @dbg_trigger_tlv: array of pointers to triggers TLVs for debug 700 * @dbg_trigger_tlv: array of pointers to triggers TLVs for debug
702 * @dbg_dest_reg_num: num of reg_ops in %dbg_dest_tlv 701 * @dbg_dest_reg_num: num of reg_ops in %dbg_dest_tlv
703 * @paging_req_addr: The location were the FW will upload / download the pages
704 * from. The address is set by the opmode
705 * @paging_db: Pointer to the opmode paging data base, the pointer is set by
706 * the opmode.
707 * @paging_download_buf: Buffer used for copying all of the pages before
708 * downloading them to the FW. The buffer is allocated in the opmode
709 * @system_pm_mode: the system-wide power management mode in use. 702 * @system_pm_mode: the system-wide power management mode in use.
710 * This mode is set dynamically, depending on the WoWLAN values 703 * This mode is set dynamically, depending on the WoWLAN values
711 * configured from the userspace at runtime. 704 * configured from the userspace at runtime.
@@ -754,14 +747,6 @@ struct iwl_trans {
754 struct iwl_fw_dbg_trigger_tlv * const *dbg_trigger_tlv; 747 struct iwl_fw_dbg_trigger_tlv * const *dbg_trigger_tlv;
755 u8 dbg_dest_reg_num; 748 u8 dbg_dest_reg_num;
756 749
757 /*
758 * Paging parameters - All of the parameters should be set by the
759 * opmode when paging is enabled
760 */
761 u32 paging_req_addr;
762 struct iwl_fw_paging *paging_db;
763 void *paging_download_buf;
764
765 enum iwl_plat_pm_mode system_pm_mode; 750 enum iwl_plat_pm_mode system_pm_mode;
766 enum iwl_plat_pm_mode runtime_pm_mode; 751 enum iwl_plat_pm_mode runtime_pm_mode;
767 bool suspending; 752 bool suspending;
@@ -828,17 +813,6 @@ static inline int iwl_trans_start_fw(struct iwl_trans *trans,
828 return trans->ops->start_fw(trans, fw, run_in_rfkill); 813 return trans->ops->start_fw(trans, fw, run_in_rfkill);
829} 814}
830 815
831static inline int iwl_trans_update_sf(struct iwl_trans *trans,
832 struct iwl_sf_region *st_fwrd_space)
833{
834 might_sleep();
835
836 if (trans->ops->update_sf)
837 return trans->ops->update_sf(trans, st_fwrd_space);
838
839 return 0;
840}
841
842static inline void _iwl_trans_stop_device(struct iwl_trans *trans, 816static inline void _iwl_trans_stop_device(struct iwl_trans *trans,
843 bool low_power) 817 bool low_power)
844{ 818{
@@ -896,6 +870,12 @@ iwl_trans_dump_data(struct iwl_trans *trans,
896 return trans->ops->dump_data(trans, trigger); 870 return trans->ops->dump_data(trans, trigger);
897} 871}
898 872
873static inline void iwl_trans_dump_regs(struct iwl_trans *trans)
874{
875 if (trans->ops->dump_regs)
876 trans->ops->dump_regs(trans);
877}
878
899static inline struct iwl_device_cmd * 879static inline struct iwl_device_cmd *
900iwl_trans_alloc_tx_cmd(struct iwl_trans *trans) 880iwl_trans_alloc_tx_cmd(struct iwl_trans *trans)
901{ 881{
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index 0296df625cd5..c0de7bb86cf7 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -196,8 +196,6 @@ static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait,
196 mvm->error_event_table[1] = 196 mvm->error_event_table[1] =
197 le32_to_cpu(lmac2->error_event_table_ptr); 197 le32_to_cpu(lmac2->error_event_table_ptr);
198 mvm->log_event_table = le32_to_cpu(lmac1->log_event_table_ptr); 198 mvm->log_event_table = le32_to_cpu(lmac1->log_event_table_ptr);
199 mvm->sf_space.addr = le32_to_cpu(lmac1->st_fwrd_addr);
200 mvm->sf_space.size = le32_to_cpu(lmac1->st_fwrd_size);
201 199
202 umac_error_event_table = le32_to_cpu(umac->error_info_addr); 200 umac_error_event_table = le32_to_cpu(umac->error_info_addr);
203 201
@@ -266,7 +264,6 @@ static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
266 int ret, i; 264 int ret, i;
267 enum iwl_ucode_type old_type = mvm->fwrt.cur_fw_img; 265 enum iwl_ucode_type old_type = mvm->fwrt.cur_fw_img;
268 static const u16 alive_cmd[] = { MVM_ALIVE }; 266 static const u16 alive_cmd[] = { MVM_ALIVE };
269 struct iwl_sf_region st_fwrd_space;
270 267
271 if (ucode_type == IWL_UCODE_REGULAR && 268 if (ucode_type == IWL_UCODE_REGULAR &&
272 iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_START_FROM_ALIVE) && 269 iwl_fw_dbg_conf_usniffer(mvm->fw, FW_DBG_START_FROM_ALIVE) &&
@@ -320,18 +317,6 @@ static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
320 return -EIO; 317 return -EIO;
321 } 318 }
322 319
323 /*
324 * update the sdio allocation according to the pointer we get in the
325 * alive notification.
326 */
327 st_fwrd_space.addr = mvm->sf_space.addr;
328 st_fwrd_space.size = mvm->sf_space.size;
329 ret = iwl_trans_update_sf(mvm->trans, &st_fwrd_space);
330 if (ret) {
331 IWL_ERR(mvm, "Failed to update SF size. ret %d\n", ret);
332 return ret;
333 }
334
335 iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr); 320 iwl_trans_fw_alive(mvm->trans, alive_data.scd_base_addr);
336 321
337 /* 322 /*
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 0b3d275fe177..3e92a117c0b8 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -4002,39 +4002,36 @@ out_unlock:
4002 4002
4003static void iwl_mvm_flush_no_vif(struct iwl_mvm *mvm, u32 queues, bool drop) 4003static void iwl_mvm_flush_no_vif(struct iwl_mvm *mvm, u32 queues, bool drop)
4004{ 4004{
4005 if (drop) { 4005 int i;
4006 if (iwl_mvm_has_new_tx_api(mvm))
4007 /* TODO new tx api */
4008 WARN_ONCE(1,
4009 "Need to implement flush TX queue\n");
4010 else
4011 iwl_mvm_flush_tx_path(mvm,
4012 iwl_mvm_flushable_queues(mvm) & queues,
4013 0);
4014 } else {
4015 if (iwl_mvm_has_new_tx_api(mvm)) {
4016 struct ieee80211_sta *sta;
4017 int i;
4018 4006
4007 if (!iwl_mvm_has_new_tx_api(mvm)) {
4008 if (drop) {
4019 mutex_lock(&mvm->mutex); 4009 mutex_lock(&mvm->mutex);
4020 4010 iwl_mvm_flush_tx_path(mvm,
4021 for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) { 4011 iwl_mvm_flushable_queues(mvm) & queues, 0);
4022 sta = rcu_dereference_protected(
4023 mvm->fw_id_to_mac_id[i],
4024 lockdep_is_held(&mvm->mutex));
4025 if (IS_ERR_OR_NULL(sta))
4026 continue;
4027
4028 iwl_mvm_wait_sta_queues_empty(mvm,
4029 iwl_mvm_sta_from_mac80211(sta));
4030 }
4031
4032 mutex_unlock(&mvm->mutex); 4012 mutex_unlock(&mvm->mutex);
4033 } else { 4013 } else {
4034 iwl_trans_wait_tx_queues_empty(mvm->trans, 4014 iwl_trans_wait_tx_queues_empty(mvm->trans, queues);
4035 queues);
4036 } 4015 }
4016 return;
4017 }
4018
4019 mutex_lock(&mvm->mutex);
4020 for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) {
4021 struct ieee80211_sta *sta;
4022
4023 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
4024 lockdep_is_held(&mvm->mutex));
4025 if (IS_ERR_OR_NULL(sta))
4026 continue;
4027
4028 if (drop)
4029 iwl_mvm_flush_sta_tids(mvm, i, 0xFF, 0);
4030 else
4031 iwl_mvm_wait_sta_queues_empty(mvm,
4032 iwl_mvm_sta_from_mac80211(sta));
4037 } 4033 }
4034 mutex_unlock(&mvm->mutex);
4038} 4035}
4039 4036
4040static void iwl_mvm_mac_flush(struct ieee80211_hw *hw, 4037static void iwl_mvm_mac_flush(struct ieee80211_hw *hw,
@@ -4294,9 +4291,7 @@ void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm,
4294 4291
4295 lockdep_assert_held(&mvm->mutex); 4292 lockdep_assert_held(&mvm->mutex);
4296 4293
4297 /* TODO - remove a000 disablement when we have RXQ config API */ 4294 if (!iwl_mvm_has_new_rx_api(mvm))
4298 if (!iwl_mvm_has_new_rx_api(mvm) ||
4299 mvm->trans->cfg->device_family == IWL_DEVICE_FAMILY_A000)
4300 return; 4295 return;
4301 4296
4302 notif->cookie = mvm->queue_sync_cookie; 4297 notif->cookie = mvm->queue_sync_cookie;
@@ -4305,6 +4300,13 @@ void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm,
4305 atomic_set(&mvm->queue_sync_counter, 4300 atomic_set(&mvm->queue_sync_counter,
4306 mvm->trans->num_rx_queues); 4301 mvm->trans->num_rx_queues);
4307 4302
4303 /* TODO - remove this when we have RXQ config API */
4304 if (mvm->trans->cfg->device_family == IWL_DEVICE_FAMILY_A000) {
4305 qmask = BIT(0);
4306 if (notif->sync)
4307 atomic_set(&mvm->queue_sync_counter, 1);
4308 }
4309
4308 ret = iwl_mvm_notify_rx_queue(mvm, qmask, (u8 *)notif, size); 4310 ret = iwl_mvm_notify_rx_queue(mvm, qmask, (u8 *)notif, size);
4309 if (ret) { 4311 if (ret) {
4310 IWL_ERR(mvm, "Failed to trigger RX queues sync (%d)\n", ret); 4312 IWL_ERR(mvm, "Failed to trigger RX queues sync (%d)\n", ret);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index e34b3eb8e08b..0e18c5066f04 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -652,6 +652,7 @@ struct iwl_mvm_baid_data {
652 u16 entries_per_queue; 652 u16 entries_per_queue;
653 unsigned long last_rx; 653 unsigned long last_rx;
654 struct timer_list session_timer; 654 struct timer_list session_timer;
655 struct iwl_mvm_baid_data __rcu **rcu_ptr;
655 struct iwl_mvm *mvm; 656 struct iwl_mvm *mvm;
656 struct iwl_mvm_reorder_buffer reorder_buf[IWL_MAX_RX_HW_QUEUES]; 657 struct iwl_mvm_reorder_buffer reorder_buf[IWL_MAX_RX_HW_QUEUES];
657 struct iwl_mvm_reorder_buf_entry entries[]; 658 struct iwl_mvm_reorder_buf_entry entries[];
@@ -754,7 +755,6 @@ struct iwl_mvm {
754 u32 log_event_table; 755 u32 log_event_table;
755 u32 umac_error_event_table; 756 u32 umac_error_event_table;
756 bool support_umac_log; 757 bool support_umac_log;
757 struct iwl_sf_region sf_space;
758 758
759 u32 ampdu_ref; 759 u32 ampdu_ref;
760 bool ampdu_toggle; 760 bool ampdu_toggle;
@@ -1854,7 +1854,7 @@ void iwl_mvm_tdls_ch_switch_work(struct work_struct *work);
1854void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm, 1854void iwl_mvm_sync_rx_queues_internal(struct iwl_mvm *mvm,
1855 struct iwl_mvm_internal_rxq_notif *notif, 1855 struct iwl_mvm_internal_rxq_notif *notif,
1856 u32 size); 1856 u32 size);
1857void iwl_mvm_reorder_timer_expired(unsigned long data); 1857void iwl_mvm_reorder_timer_expired(struct timer_list *t);
1858struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm); 1858struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm);
1859bool iwl_mvm_is_vif_assoc(struct iwl_mvm *mvm); 1859bool iwl_mvm_is_vif_assoc(struct iwl_mvm *mvm);
1860 1860
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index e82b4462722b..ce718e9c63ec 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -703,7 +703,6 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
703 trans_cfg.cb_data_offs = offsetof(struct ieee80211_tx_info, 703 trans_cfg.cb_data_offs = offsetof(struct ieee80211_tx_info,
704 driver_data[2]); 704 driver_data[2]);
705 705
706 trans_cfg.sdio_adma_addr = fw->sdio_adma_addr;
707 trans_cfg.sw_csum_tx = IWL_MVM_SW_TX_CSUM_OFFLOAD; 706 trans_cfg.sw_csum_tx = IWL_MVM_SW_TX_CSUM_OFFLOAD;
708 707
709 /* Set a short watchdog for the command queue */ 708 /* Set a short watchdog for the command queue */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
index 0fe723ca844e..c69515ed72df 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
@@ -67,12 +67,8 @@ static u8 rs_ht_to_legacy[] = {
67static const u8 ant_toggle_lookup[] = { 67static const u8 ant_toggle_lookup[] = {
68 [ANT_NONE] = ANT_NONE, 68 [ANT_NONE] = ANT_NONE,
69 [ANT_A] = ANT_B, 69 [ANT_A] = ANT_B,
70 [ANT_B] = ANT_C, 70 [ANT_B] = ANT_A,
71 [ANT_AB] = ANT_BC, 71 [ANT_AB] = ANT_AB,
72 [ANT_C] = ANT_A,
73 [ANT_AC] = ANT_AB,
74 [ANT_BC] = ANT_AC,
75 [ANT_ABC] = ANT_ABC,
76}; 72};
77 73
78#define IWL_DECLARE_RATE_INFO(r, s, rp, rn) \ 74#define IWL_DECLARE_RATE_INFO(r, s, rp, rn) \
@@ -975,7 +971,7 @@ static int rs_toggle_antenna(u32 valid_ant, struct rs_rate *rate)
975{ 971{
976 u8 new_ant_type; 972 u8 new_ant_type;
977 973
978 if (!rate->ant || rate->ant > ANT_ABC) 974 if (!rate->ant || WARN_ON_ONCE(rate->ant & ANT_C))
979 return 0; 975 return 0;
980 976
981 if (!rs_is_valid_ant(valid_ant, rate->ant)) 977 if (!rs_is_valid_ant(valid_ant, rate->ant))
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index b84756dc9d6c..76dc58381e1c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -460,9 +460,9 @@ set_timer:
460 } 460 }
461} 461}
462 462
463void iwl_mvm_reorder_timer_expired(unsigned long data) 463void iwl_mvm_reorder_timer_expired(struct timer_list *t)
464{ 464{
465 struct iwl_mvm_reorder_buffer *buf = (void *)data; 465 struct iwl_mvm_reorder_buffer *buf = from_timer(buf, t, reorder_timer);
466 struct iwl_mvm_baid_data *baid_data = 466 struct iwl_mvm_baid_data *baid_data =
467 iwl_mvm_baid_data_from_reorder_buf(buf); 467 iwl_mvm_baid_data_from_reorder_buf(buf);
468 struct iwl_mvm_reorder_buf_entry *entries = 468 struct iwl_mvm_reorder_buf_entry *entries =
@@ -719,6 +719,22 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
719 return false; 719 return false;
720 } 720 }
721 721
722 /*
723 * release immediately if there are no stored frames, and the sn is
724 * equal to the head.
725 * This can happen due to reorder timer, where NSSN is behind head_sn.
726 * When we released everything, and we got the next frame in the
727 * sequence, according to the NSSN we can't release immediately,
728 * while technically there is no hole and we can move forward.
729 */
730 if (!buffer->num_stored && sn == buffer->head_sn) {
731 if (!amsdu || last_subframe)
732 buffer->head_sn = ieee80211_sn_inc(buffer->head_sn);
733 /* No need to update AMSDU last SN - we are moving the head */
734 spin_unlock_bh(&buffer->lock);
735 return false;
736 }
737
722 index = sn % buffer->buf_size; 738 index = sn % buffer->buf_size;
723 739
724 /* 740 /*
@@ -818,6 +834,9 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi,
818 struct sk_buff *skb; 834 struct sk_buff *skb;
819 u8 crypt_len = 0; 835 u8 crypt_len = 0;
820 836
837 if (unlikely(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)))
838 return;
839
821 /* Dont use dev_alloc_skb(), we'll have enough headroom once 840 /* Dont use dev_alloc_skb(), we'll have enough headroom once
822 * ieee80211_hdr pulled. 841 * ieee80211_hdr pulled.
823 */ 842 */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index 23787cc9c89e..c19f98489d4e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -252,9 +252,11 @@ int iwl_mvm_sta_send_to_fw(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
252 return ret; 252 return ret;
253} 253}
254 254
255static void iwl_mvm_rx_agg_session_expired(unsigned long data) 255static void iwl_mvm_rx_agg_session_expired(struct timer_list *t)
256{ 256{
257 struct iwl_mvm_baid_data __rcu **rcu_ptr = (void *)data; 257 struct iwl_mvm_baid_data *data =
258 from_timer(data, t, session_timer);
259 struct iwl_mvm_baid_data __rcu **rcu_ptr = data->rcu_ptr;
258 struct iwl_mvm_baid_data *ba_data; 260 struct iwl_mvm_baid_data *ba_data;
259 struct ieee80211_sta *sta; 261 struct ieee80211_sta *sta;
260 struct iwl_mvm_sta *mvm_sta; 262 struct iwl_mvm_sta *mvm_sta;
@@ -644,8 +646,7 @@ int iwl_mvm_scd_queue_redirect(struct iwl_mvm *mvm, int queue, int tid,
644 646
645 /* Redirect to lower AC */ 647 /* Redirect to lower AC */
646 iwl_mvm_reconfig_scd(mvm, queue, iwl_mvm_ac_to_tx_fifo[ac], 648 iwl_mvm_reconfig_scd(mvm, queue, iwl_mvm_ac_to_tx_fifo[ac],
647 cmd.sta_id, tid, LINK_QUAL_AGG_FRAME_LIMIT_DEF, 649 cmd.sta_id, tid, IWL_FRAME_LIMIT, ssn);
648 ssn);
649 650
650 /* Update AC marking of the queue */ 651 /* Update AC marking of the queue */
651 spin_lock_bh(&mvm->queue_info_lock); 652 spin_lock_bh(&mvm->queue_info_lock);
@@ -1258,6 +1259,14 @@ static void iwl_mvm_realloc_queues_after_restart(struct iwl_mvm *mvm,
1258 mvm_sta->sta_id, 1259 mvm_sta->sta_id,
1259 i, wdg_timeout); 1260 i, wdg_timeout);
1260 tid_data->txq_id = txq_id; 1261 tid_data->txq_id = txq_id;
1262
1263 /*
1264 * Since we don't set the seq number after reset, and HW
1265 * sets it now, FW reset will cause the seq num to start
1266 * at 0 again, so driver will need to update it
1267 * internally as well, so it keeps in sync with real val
1268 */
1269 tid_data->seq_number = 0;
1261 } else { 1270 } else {
1262 u16 seq = IEEE80211_SEQ_TO_SN(tid_data->seq_number); 1271 u16 seq = IEEE80211_SEQ_TO_SN(tid_data->seq_number);
1263 1272
@@ -2153,10 +2162,8 @@ static void iwl_mvm_init_reorder_buffer(struct iwl_mvm *mvm,
2153 reorder_buf->head_sn = ssn; 2162 reorder_buf->head_sn = ssn;
2154 reorder_buf->buf_size = buf_size; 2163 reorder_buf->buf_size = buf_size;
2155 /* rx reorder timer */ 2164 /* rx reorder timer */
2156 reorder_buf->reorder_timer.function = 2165 timer_setup(&reorder_buf->reorder_timer,
2157 iwl_mvm_reorder_timer_expired; 2166 iwl_mvm_reorder_timer_expired, 0);
2158 reorder_buf->reorder_timer.data = (unsigned long)reorder_buf;
2159 init_timer(&reorder_buf->reorder_timer);
2160 spin_lock_init(&reorder_buf->lock); 2167 spin_lock_init(&reorder_buf->lock);
2161 reorder_buf->mvm = mvm; 2168 reorder_buf->mvm = mvm;
2162 reorder_buf->queue = i; 2169 reorder_buf->queue = i;
@@ -2279,9 +2286,9 @@ int iwl_mvm_sta_rx_agg(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
2279 baid_data->baid = baid; 2286 baid_data->baid = baid;
2280 baid_data->timeout = timeout; 2287 baid_data->timeout = timeout;
2281 baid_data->last_rx = jiffies; 2288 baid_data->last_rx = jiffies;
2282 setup_timer(&baid_data->session_timer, 2289 baid_data->rcu_ptr = &mvm->baid_map[baid];
2283 iwl_mvm_rx_agg_session_expired, 2290 timer_setup(&baid_data->session_timer,
2284 (unsigned long)&mvm->baid_map[baid]); 2291 iwl_mvm_rx_agg_session_expired, 0);
2285 baid_data->mvm = mvm; 2292 baid_data->mvm = mvm;
2286 baid_data->tid = tid; 2293 baid_data->tid = tid;
2287 baid_data->sta_id = mvm_sta->sta_id; 2294 baid_data->sta_id = mvm_sta->sta_id;
@@ -2544,12 +2551,6 @@ int iwl_mvm_sta_tx_agg_oper(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2544 BUILD_BUG_ON((sizeof(mvmsta->agg_tids) * BITS_PER_BYTE) 2551 BUILD_BUG_ON((sizeof(mvmsta->agg_tids) * BITS_PER_BYTE)
2545 != IWL_MAX_TID_COUNT); 2552 != IWL_MAX_TID_COUNT);
2546 2553
2547 if (!mvm->trans->cfg->gen2)
2548 buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF);
2549 else
2550 buf_size = min_t(int, buf_size,
2551 LINK_QUAL_AGG_FRAME_LIMIT_GEN2_DEF);
2552
2553 spin_lock_bh(&mvmsta->lock); 2554 spin_lock_bh(&mvmsta->lock);
2554 ssn = tid_data->ssn; 2555 ssn = tid_data->ssn;
2555 queue = tid_data->txq_id; 2556 queue = tid_data->txq_id;
@@ -2561,10 +2562,17 @@ int iwl_mvm_sta_tx_agg_oper(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2561 2562
2562 if (iwl_mvm_has_new_tx_api(mvm)) { 2563 if (iwl_mvm_has_new_tx_api(mvm)) {
2563 /* 2564 /*
2564 * If no queue iwl_mvm_sta_tx_agg_start() would have failed so 2565 * If there is no queue for this tid, iwl_mvm_sta_tx_agg_start()
2565 * no need to check queue's status 2566 * would have failed, so if we are here there is no need to
2567 * allocate a queue.
2568 * However, if aggregation size is different than the default
2569 * size, the scheduler should be reconfigured.
2570 * We cannot do this with the new TX API, so return unsupported
2571 * for now, until it will be offloaded to firmware..
2572 * Note that if SCD default value changes - this condition
2573 * should be updated as well.
2566 */ 2574 */
2567 if (buf_size < mvmsta->max_agg_bufsize) 2575 if (buf_size < IWL_FRAME_LIMIT)
2568 return -ENOTSUPP; 2576 return -ENOTSUPP;
2569 2577
2570 ret = iwl_mvm_sta_tx_agg(mvm, sta, tid, queue, true); 2578 ret = iwl_mvm_sta_tx_agg(mvm, sta, tid, queue, true);
@@ -2587,7 +2595,7 @@ int iwl_mvm_sta_tx_agg_oper(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
2587 * Only reconfig the SCD for the queue if the window size has 2595 * Only reconfig the SCD for the queue if the window size has
2588 * changed from current (become smaller) 2596 * changed from current (become smaller)
2589 */ 2597 */
2590 if (!alloc_queue && buf_size < mvmsta->max_agg_bufsize) { 2598 if (!alloc_queue && buf_size < IWL_FRAME_LIMIT) {
2591 /* 2599 /*
2592 * If reconfiguring an existing queue, it first must be 2600 * If reconfiguring an existing queue, it first must be
2593 * drained 2601 * drained
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index 00a0efab20e3..d88c3685a6dd 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -1594,8 +1594,7 @@ static void iwl_mvm_rx_tx_cmd_agg(struct iwl_mvm *mvm,
1594 mvmsta->tid_data[tid].tx_time = 1594 mvmsta->tid_data[tid].tx_time =
1595 le16_to_cpu(tx_resp->wireless_media_time); 1595 le16_to_cpu(tx_resp->wireless_media_time);
1596 mvmsta->tid_data[tid].lq_color = 1596 mvmsta->tid_data[tid].lq_color =
1597 (tx_resp->tlc_info & TX_RES_RATE_TABLE_COLOR_MSK) >> 1597 TX_RES_RATE_TABLE_COL_GET(tx_resp->tlc_info);
1598 TX_RES_RATE_TABLE_COLOR_POS;
1599 } 1598 }
1600 1599
1601 rcu_read_unlock(); 1600 rcu_read_unlock();
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index aa3c07192624..4a21c12276d7 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -467,6 +467,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
467 {IWL_PCI_DEVICE(0x24F3, 0x9110, iwl8260_2ac_cfg)}, 467 {IWL_PCI_DEVICE(0x24F3, 0x9110, iwl8260_2ac_cfg)},
468 {IWL_PCI_DEVICE(0x24F4, 0x8030, iwl8260_2ac_cfg)}, 468 {IWL_PCI_DEVICE(0x24F4, 0x8030, iwl8260_2ac_cfg)},
469 {IWL_PCI_DEVICE(0x24F4, 0x9030, iwl8260_2ac_cfg)}, 469 {IWL_PCI_DEVICE(0x24F4, 0x9030, iwl8260_2ac_cfg)},
470 {IWL_PCI_DEVICE(0x24F4, 0xC030, iwl8260_2ac_cfg)},
471 {IWL_PCI_DEVICE(0x24F4, 0xD030, iwl8260_2ac_cfg)},
470 {IWL_PCI_DEVICE(0x24F3, 0x8130, iwl8260_2ac_cfg)}, 472 {IWL_PCI_DEVICE(0x24F3, 0x8130, iwl8260_2ac_cfg)},
471 {IWL_PCI_DEVICE(0x24F3, 0x9130, iwl8260_2ac_cfg)}, 473 {IWL_PCI_DEVICE(0x24F3, 0x9130, iwl8260_2ac_cfg)},
472 {IWL_PCI_DEVICE(0x24F3, 0x8132, iwl8260_2ac_cfg)}, 474 {IWL_PCI_DEVICE(0x24F3, 0x8132, iwl8260_2ac_cfg)},
@@ -485,6 +487,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
485 {IWL_PCI_DEVICE(0x24F3, 0x0950, iwl8260_2ac_cfg)}, 487 {IWL_PCI_DEVICE(0x24F3, 0x0950, iwl8260_2ac_cfg)},
486 {IWL_PCI_DEVICE(0x24F3, 0x0930, iwl8260_2ac_cfg)}, 488 {IWL_PCI_DEVICE(0x24F3, 0x0930, iwl8260_2ac_cfg)},
487 {IWL_PCI_DEVICE(0x24F3, 0x0000, iwl8265_2ac_cfg)}, 489 {IWL_PCI_DEVICE(0x24F3, 0x0000, iwl8265_2ac_cfg)},
490 {IWL_PCI_DEVICE(0x24F3, 0x4010, iwl8260_2ac_cfg)},
488 {IWL_PCI_DEVICE(0x24FD, 0x0010, iwl8265_2ac_cfg)}, 491 {IWL_PCI_DEVICE(0x24FD, 0x0010, iwl8265_2ac_cfg)},
489 {IWL_PCI_DEVICE(0x24FD, 0x0110, iwl8265_2ac_cfg)}, 492 {IWL_PCI_DEVICE(0x24FD, 0x0110, iwl8265_2ac_cfg)},
490 {IWL_PCI_DEVICE(0x24FD, 0x1110, iwl8265_2ac_cfg)}, 493 {IWL_PCI_DEVICE(0x24FD, 0x1110, iwl8265_2ac_cfg)},
@@ -510,6 +513,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
510 {IWL_PCI_DEVICE(0x24FD, 0x3E01, iwl8275_2ac_cfg)}, 513 {IWL_PCI_DEVICE(0x24FD, 0x3E01, iwl8275_2ac_cfg)},
511 {IWL_PCI_DEVICE(0x24FD, 0x1012, iwl8275_2ac_cfg)}, 514 {IWL_PCI_DEVICE(0x24FD, 0x1012, iwl8275_2ac_cfg)},
512 {IWL_PCI_DEVICE(0x24FD, 0x0012, iwl8275_2ac_cfg)}, 515 {IWL_PCI_DEVICE(0x24FD, 0x0012, iwl8275_2ac_cfg)},
516 {IWL_PCI_DEVICE(0x24FD, 0x0014, iwl8265_2ac_cfg)},
517 {IWL_PCI_DEVICE(0x24FD, 0x9074, iwl8265_2ac_cfg)},
513 518
514/* 9000 Series */ 519/* 9000 Series */
515 {IWL_PCI_DEVICE(0x2526, 0x0000, iwl9260_2ac_cfg)}, 520 {IWL_PCI_DEVICE(0x2526, 0x0000, iwl9260_2ac_cfg)},
@@ -581,6 +586,11 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
581 {IWL_PCI_DEVICE(0x2720, 0x0070, iwla000_2ac_cfg_hr_cdb)}, 586 {IWL_PCI_DEVICE(0x2720, 0x0070, iwla000_2ac_cfg_hr_cdb)},
582 {IWL_PCI_DEVICE(0x2720, 0x0030, iwla000_2ac_cfg_hr_cdb)}, 587 {IWL_PCI_DEVICE(0x2720, 0x0030, iwla000_2ac_cfg_hr_cdb)},
583 {IWL_PCI_DEVICE(0x2720, 0x1080, iwla000_2ax_cfg_hr)}, 588 {IWL_PCI_DEVICE(0x2720, 0x1080, iwla000_2ax_cfg_hr)},
589 {IWL_PCI_DEVICE(0x2720, 0x0090, iwla000_2ac_cfg_hr_cdb)},
590 {IWL_PCI_DEVICE(0x2720, 0x0310, iwla000_2ac_cfg_hr_cdb)},
591 {IWL_PCI_DEVICE(0x40C0, 0x0000, iwla000_2ax_cfg_hr)},
592 {IWL_PCI_DEVICE(0x40C0, 0x0A10, iwla000_2ax_cfg_hr)},
593
584#endif /* CONFIG_IWLMVM */ 594#endif /* CONFIG_IWLMVM */
585 595
586 {0} 596 {0}
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 0008ea323be3..8d992d5ba064 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -88,7 +88,7 @@
88#define IWL_FW_MEM_EXTENDED_START 0x40000 88#define IWL_FW_MEM_EXTENDED_START 0x40000
89#define IWL_FW_MEM_EXTENDED_END 0x57FFF 89#define IWL_FW_MEM_EXTENDED_END 0x57FFF
90 90
91static void iwl_trans_pcie_err_dump(struct iwl_trans *trans) 91static void iwl_trans_pcie_dump_regs(struct iwl_trans *trans)
92{ 92{
93#define PCI_DUMP_SIZE 64 93#define PCI_DUMP_SIZE 64
94#define PREFIX_LEN 32 94#define PREFIX_LEN 32
@@ -736,7 +736,7 @@ static int iwl_pcie_load_firmware_chunk(struct iwl_trans *trans,
736 trans_pcie->ucode_write_complete, 5 * HZ); 736 trans_pcie->ucode_write_complete, 5 * HZ);
737 if (!ret) { 737 if (!ret) {
738 IWL_ERR(trans, "Failed to load firmware chunk!\n"); 738 IWL_ERR(trans, "Failed to load firmware chunk!\n");
739 iwl_trans_pcie_err_dump(trans); 739 iwl_trans_pcie_dump_regs(trans);
740 return -ETIMEDOUT; 740 return -ETIMEDOUT;
741 } 741 }
742 742
@@ -1956,7 +1956,7 @@ static bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans,
1956 (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | 1956 (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY |
1957 CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); 1957 CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000);
1958 if (unlikely(ret < 0)) { 1958 if (unlikely(ret < 0)) {
1959 iwl_trans_pcie_err_dump(trans); 1959 iwl_trans_pcie_dump_regs(trans);
1960 iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); 1960 iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI);
1961 WARN_ONCE(1, 1961 WARN_ONCE(1,
1962 "Timeout waiting for hardware access (CSR_GP_CNTRL 0x%08x)\n", 1962 "Timeout waiting for hardware access (CSR_GP_CNTRL 0x%08x)\n",
@@ -3021,6 +3021,7 @@ static void iwl_trans_pcie_resume(struct iwl_trans *trans)
3021 .ref = iwl_trans_pcie_ref, \ 3021 .ref = iwl_trans_pcie_ref, \
3022 .unref = iwl_trans_pcie_unref, \ 3022 .unref = iwl_trans_pcie_unref, \
3023 .dump_data = iwl_trans_pcie_dump_data, \ 3023 .dump_data = iwl_trans_pcie_dump_data, \
3024 .dump_regs = iwl_trans_pcie_dump_regs, \
3024 .d3_suspend = iwl_trans_pcie_d3_suspend, \ 3025 .d3_suspend = iwl_trans_pcie_d3_suspend, \
3025 .d3_resume = iwl_trans_pcie_d3_resume 3026 .d3_resume = iwl_trans_pcie_d3_resume
3026 3027
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
index e93c471ef9bf..b5c459cd70ce 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
@@ -1909,6 +1909,7 @@ static int iwl_pcie_send_hcmd_sync(struct iwl_trans *trans,
1909 } 1909 }
1910 1910
1911 if (test_bit(STATUS_FW_ERROR, &trans->status)) { 1911 if (test_bit(STATUS_FW_ERROR, &trans->status)) {
1912 iwl_trans_dump_regs(trans);
1912 IWL_ERR(trans, "FW error in SYNC CMD %s\n", 1913 IWL_ERR(trans, "FW error in SYNC CMD %s\n",
1913 iwl_get_cmd_string(trans, cmd->id)); 1914 iwl_get_cmd_string(trans, cmd->id));
1914 dump_stack(); 1915 dump_stack();
diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c
index 56f6e3b71f48..501180584b4b 100644
--- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c
+++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c
@@ -1457,7 +1457,6 @@ static void ezusb_bulk_in_callback(struct urb *urb)
1457 1457
1458static inline void ezusb_delete(struct ezusb_priv *upriv) 1458static inline void ezusb_delete(struct ezusb_priv *upriv)
1459{ 1459{
1460 struct net_device *dev;
1461 struct list_head *item; 1460 struct list_head *item;
1462 struct list_head *tmp_item; 1461 struct list_head *tmp_item;
1463 unsigned long flags; 1462 unsigned long flags;
@@ -1465,7 +1464,6 @@ static inline void ezusb_delete(struct ezusb_priv *upriv)
1465 BUG_ON(in_interrupt()); 1464 BUG_ON(in_interrupt());
1466 BUG_ON(!upriv); 1465 BUG_ON(!upriv);
1467 1466
1468 dev = upriv->dev;
1469 mutex_lock(&upriv->mtx); 1467 mutex_lock(&upriv->mtx);
1470 1468
1471 upriv->udev = NULL; /* No timer will be rearmed from here */ 1469 upriv->udev = NULL; /* No timer will be rearmed from here */
diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
index e70f5bd5e498..7d6dc76c930a 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
@@ -217,10 +217,10 @@ static int qtnf_mgmt_set_appie(struct qtnf_vif *vif,
217 int ret = 0; 217 int ret = 0;
218 218
219 if (!info->beacon_ies || !info->beacon_ies_len) { 219 if (!info->beacon_ies || !info->beacon_ies_len) {
220 ret = qtnf_cmd_send_mgmt_set_appie(vif, QLINK_MGMT_FRAME_BEACON, 220 ret = qtnf_cmd_send_mgmt_set_appie(vif, QLINK_IE_SET_BEACON_IES,
221 NULL, 0); 221 NULL, 0);
222 } else { 222 } else {
223 ret = qtnf_cmd_send_mgmt_set_appie(vif, QLINK_MGMT_FRAME_BEACON, 223 ret = qtnf_cmd_send_mgmt_set_appie(vif, QLINK_IE_SET_BEACON_IES,
224 info->beacon_ies, 224 info->beacon_ies,
225 info->beacon_ies_len); 225 info->beacon_ies_len);
226 } 226 }
@@ -230,11 +230,11 @@ static int qtnf_mgmt_set_appie(struct qtnf_vif *vif,
230 230
231 if (!info->proberesp_ies || !info->proberesp_ies_len) { 231 if (!info->proberesp_ies || !info->proberesp_ies_len) {
232 ret = qtnf_cmd_send_mgmt_set_appie(vif, 232 ret = qtnf_cmd_send_mgmt_set_appie(vif,
233 QLINK_MGMT_FRAME_PROBE_RESP, 233 QLINK_IE_SET_PROBE_RESP_IES,
234 NULL, 0); 234 NULL, 0);
235 } else { 235 } else {
236 ret = qtnf_cmd_send_mgmt_set_appie(vif, 236 ret = qtnf_cmd_send_mgmt_set_appie(vif,
237 QLINK_MGMT_FRAME_PROBE_RESP, 237 QLINK_IE_SET_PROBE_RESP_IES,
238 info->proberesp_ies, 238 info->proberesp_ies,
239 info->proberesp_ies_len); 239 info->proberesp_ies_len);
240 } 240 }
@@ -244,11 +244,11 @@ static int qtnf_mgmt_set_appie(struct qtnf_vif *vif,
244 244
245 if (!info->assocresp_ies || !info->assocresp_ies_len) { 245 if (!info->assocresp_ies || !info->assocresp_ies_len) {
246 ret = qtnf_cmd_send_mgmt_set_appie(vif, 246 ret = qtnf_cmd_send_mgmt_set_appie(vif,
247 QLINK_MGMT_FRAME_ASSOC_RESP, 247 QLINK_IE_SET_ASSOC_RESP,
248 NULL, 0); 248 NULL, 0);
249 } else { 249 } else {
250 ret = qtnf_cmd_send_mgmt_set_appie(vif, 250 ret = qtnf_cmd_send_mgmt_set_appie(vif,
251 QLINK_MGMT_FRAME_ASSOC_RESP, 251 QLINK_IE_SET_ASSOC_RESP,
252 info->assocresp_ies, 252 info->assocresp_ies,
253 info->assocresp_ies_len); 253 info->assocresp_ies_len);
254 } 254 }
@@ -271,26 +271,11 @@ static int qtnf_start_ap(struct wiphy *wiphy, struct net_device *dev,
271 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); 271 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
272 int ret; 272 int ret;
273 273
274 ret = qtnf_cmd_send_config_ap(vif, settings); 274 ret = qtnf_cmd_send_start_ap(vif, settings);
275 if (ret) {
276 pr_err("VIF%u.%u: failed to push config to FW\n",
277 vif->mac->macid, vif->vifid);
278 goto out;
279 }
280
281 ret = qtnf_mgmt_set_appie(vif, &settings->beacon);
282 if (ret) {
283 pr_err("VIF%u.%u: failed to add IEs to beacon\n",
284 vif->mac->macid, vif->vifid);
285 goto out;
286 }
287
288 ret = qtnf_cmd_send_start_ap(vif);
289 if (ret) 275 if (ret)
290 pr_err("VIF%u.%u: failed to start AP\n", vif->mac->macid, 276 pr_err("VIF%u.%u: failed to start AP\n", vif->mac->macid,
291 vif->vifid); 277 vif->vifid);
292 278
293out:
294 return ret; 279 return ret;
295} 280}
296 281
@@ -823,8 +808,7 @@ static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
823 if (!wiphy->bands[band]) 808 if (!wiphy->bands[band])
824 continue; 809 continue;
825 810
826 ret = qtnf_cmd_get_mac_chan_info(mac, 811 ret = qtnf_cmd_band_info_get(mac, wiphy->bands[band]);
827 wiphy->bands[band]);
828 if (ret) 812 if (ret)
829 pr_err("failed to get chan info for mac %u band %u\n", 813 pr_err("failed to get chan info for mac %u band %u\n",
830 mac_idx, band); 814 mac_idx, band);
@@ -832,33 +816,6 @@ static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
832 } 816 }
833} 817}
834 818
835void qtnf_band_setup_htvht_caps(struct qtnf_mac_info *macinfo,
836 struct ieee80211_supported_band *band)
837{
838 struct ieee80211_sta_ht_cap *ht_cap;
839 struct ieee80211_sta_vht_cap *vht_cap;
840
841 ht_cap = &band->ht_cap;
842 ht_cap->ht_supported = true;
843 memcpy(&ht_cap->cap, &macinfo->ht_cap.cap_info,
844 sizeof(u16));
845 ht_cap->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
846 ht_cap->ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
847 memcpy(&ht_cap->mcs, &macinfo->ht_cap.mcs,
848 sizeof(ht_cap->mcs));
849
850 if (macinfo->phymode_cap & QLINK_PHYMODE_AC) {
851 vht_cap = &band->vht_cap;
852 vht_cap->vht_supported = true;
853 memcpy(&vht_cap->cap,
854 &macinfo->vht_cap.vht_cap_info, sizeof(u32));
855 /* Update MCS support for VHT */
856 memcpy(&vht_cap->vht_mcs,
857 &macinfo->vht_cap.supp_mcs,
858 sizeof(struct ieee80211_vht_mcs_info));
859 }
860}
861
862struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus) 819struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus)
863{ 820{
864 struct wiphy *wiphy; 821 struct wiphy *wiphy;
@@ -919,9 +876,6 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac)
919 if (ret) 876 if (ret)
920 goto out; 877 goto out;
921 878
922 pr_info("MAC%u: phymode=%#x radar=%#x\n", mac->macid,
923 mac->macinfo.phymode_cap, mac->macinfo.radar_detect_widths);
924
925 wiphy->frag_threshold = mac->macinfo.frag_thr; 879 wiphy->frag_threshold = mac->macinfo.frag_thr;
926 wiphy->rts_threshold = mac->macinfo.rts_thr; 880 wiphy->rts_threshold = mac->macinfo.rts_thr;
927 wiphy->retry_short = mac->macinfo.sretry_limit; 881 wiphy->retry_short = mac->macinfo.sretry_limit;
@@ -953,6 +907,8 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac)
953 wiphy->available_antennas_rx = mac->macinfo.num_rx_chain; 907 wiphy->available_antennas_rx = mac->macinfo.num_rx_chain;
954 908
955 wiphy->max_ap_assoc_sta = mac->macinfo.max_ap_assoc_sta; 909 wiphy->max_ap_assoc_sta = mac->macinfo.max_ap_assoc_sta;
910 wiphy->ht_capa_mod_mask = &mac->macinfo.ht_cap_mod_mask;
911 wiphy->vht_capa_mod_mask = &mac->macinfo.vht_cap_mod_mask;
956 912
957 ether_addr_copy(wiphy->perm_addr, mac->macaddr); 913 ether_addr_copy(wiphy->perm_addr, mac->macaddr);
958 914
diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index b81f81bd1411..8bc8dd637315 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -147,56 +147,66 @@ static struct sk_buff *qtnf_cmd_alloc_new_cmdskb(u8 macid, u8 vifid, u16 cmd_no,
147 return cmd_skb; 147 return cmd_skb;
148} 148}
149 149
150int qtnf_cmd_send_start_ap(struct qtnf_vif *vif) 150static void qtnf_cmd_tlv_ie_set_add(struct sk_buff *cmd_skb, u8 frame_type,
151 const u8 *buf, size_t len)
151{ 152{
152 struct sk_buff *cmd_skb; 153 struct qlink_tlv_ie_set *tlv;
153 u16 res_code = QLINK_CMD_RESULT_OK;
154 int ret;
155 154
156 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 155 tlv = (struct qlink_tlv_ie_set *)skb_put(cmd_skb, sizeof(*tlv) + len);
157 QLINK_CMD_START_AP, 156 tlv->hdr.type = cpu_to_le16(QTN_TLV_ID_IE_SET);
158 sizeof(struct qlink_cmd)); 157 tlv->hdr.len = cpu_to_le16(len + sizeof(*tlv) - sizeof(tlv->hdr));
159 if (unlikely(!cmd_skb)) 158 tlv->type = frame_type;
160 return -ENOMEM; 159 tlv->flags = 0;
161 160
162 qtnf_bus_lock(vif->mac->bus); 161 if (len && buf)
162 memcpy(tlv->ie_data, buf, len);
163}
163 164
164 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 165static bool qtnf_cmd_start_ap_can_fit(const struct qtnf_vif *vif,
166 const struct cfg80211_ap_settings *s)
167{
168 unsigned int len = sizeof(struct qlink_cmd_start_ap);
165 169
166 if (unlikely(ret)) 170 len += s->ssid_len;
167 goto out; 171 len += s->beacon.head_len;
172 len += s->beacon.tail_len;
173 len += s->beacon.beacon_ies_len;
174 len += s->beacon.proberesp_ies_len;
175 len += s->beacon.assocresp_ies_len;
176 len += s->beacon.probe_resp_len;
168 177
169 if (unlikely(res_code != QLINK_CMD_RESULT_OK)) { 178 if (cfg80211_chandef_valid(&s->chandef))
170 pr_err("VIF%u.%u: CMD failed: %u\n", vif->mac->macid, 179 len += sizeof(struct qlink_tlv_chandef);
171 vif->vifid, res_code);
172 ret = -EFAULT;
173 goto out;
174 }
175 180
176 netif_carrier_on(vif->netdev); 181 if (len > (sizeof(struct qlink_cmd) + QTNF_MAX_CMD_BUF_SIZE)) {
182 pr_err("VIF%u.%u: can not fit AP settings: %u\n",
183 vif->mac->macid, vif->vifid, len);
184 return false;
185 }
177 186
178out: 187 return true;
179 qtnf_bus_unlock(vif->mac->bus);
180 return ret;
181} 188}
182 189
183int qtnf_cmd_send_config_ap(struct qtnf_vif *vif, 190int qtnf_cmd_send_start_ap(struct qtnf_vif *vif,
184 const struct cfg80211_ap_settings *s) 191 const struct cfg80211_ap_settings *s)
185{ 192{
186 struct sk_buff *cmd_skb; 193 struct sk_buff *cmd_skb;
187 struct qlink_cmd_config_ap *cmd; 194 struct qlink_cmd_start_ap *cmd;
188 struct qlink_auth_encr *aen; 195 struct qlink_auth_encr *aen;
189 u16 res_code = QLINK_CMD_RESULT_OK; 196 u16 res_code = QLINK_CMD_RESULT_OK;
190 int ret; 197 int ret;
191 int i; 198 int i;
192 199
200 if (!qtnf_cmd_start_ap_can_fit(vif, s))
201 return -E2BIG;
202
193 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 203 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
194 QLINK_CMD_CONFIG_AP, 204 QLINK_CMD_START_AP,
195 sizeof(*cmd)); 205 sizeof(*cmd));
196 if (unlikely(!cmd_skb)) 206 if (unlikely(!cmd_skb))
197 return -ENOMEM; 207 return -ENOMEM;
198 208
199 cmd = (struct qlink_cmd_config_ap *)cmd_skb->data; 209 cmd = (struct qlink_cmd_start_ap *)cmd_skb->data;
200 cmd->dtim_period = s->dtim_period; 210 cmd->dtim_period = s->dtim_period;
201 cmd->beacon_interval = cpu_to_le16(s->beacon_interval); 211 cmd->beacon_interval = cpu_to_le16(s->beacon_interval);
202 cmd->hidden_ssid = qlink_hidden_ssid_nl2q(s->hidden_ssid); 212 cmd->hidden_ssid = qlink_hidden_ssid_nl2q(s->hidden_ssid);
@@ -211,7 +221,6 @@ int qtnf_cmd_send_config_ap(struct qtnf_vif *vif,
211 aen = &cmd->aen; 221 aen = &cmd->aen;
212 aen->auth_type = s->auth_type; 222 aen->auth_type = s->auth_type;
213 aen->privacy = !!s->privacy; 223 aen->privacy = !!s->privacy;
214 aen->mfp = 0;
215 aen->wpa_versions = cpu_to_le32(s->crypto.wpa_versions); 224 aen->wpa_versions = cpu_to_le32(s->crypto.wpa_versions);
216 aen->cipher_group = cpu_to_le32(s->crypto.cipher_group); 225 aen->cipher_group = cpu_to_le32(s->crypto.cipher_group);
217 aen->n_ciphers_pairwise = cpu_to_le32(s->crypto.n_ciphers_pairwise); 226 aen->n_ciphers_pairwise = cpu_to_le32(s->crypto.n_ciphers_pairwise);
@@ -241,6 +250,39 @@ int qtnf_cmd_send_config_ap(struct qtnf_vif *vif,
241 qlink_chandef_cfg2q(&s->chandef, &chtlv->chan); 250 qlink_chandef_cfg2q(&s->chandef, &chtlv->chan);
242 } 251 }
243 252
253 qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_BEACON_HEAD,
254 s->beacon.head, s->beacon.head_len);
255 qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_BEACON_TAIL,
256 s->beacon.tail, s->beacon.tail_len);
257 qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_BEACON_IES,
258 s->beacon.beacon_ies, s->beacon.beacon_ies_len);
259 qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_PROBE_RESP,
260 s->beacon.probe_resp, s->beacon.probe_resp_len);
261 qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_PROBE_RESP_IES,
262 s->beacon.proberesp_ies,
263 s->beacon.proberesp_ies_len);
264 qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_ASSOC_RESP,
265 s->beacon.assocresp_ies,
266 s->beacon.assocresp_ies_len);
267
268 if (s->ht_cap) {
269 struct qlink_tlv_hdr *tlv = (struct qlink_tlv_hdr *)
270 skb_put(cmd_skb, sizeof(*tlv) + sizeof(*s->ht_cap));
271
272 tlv->type = cpu_to_le16(WLAN_EID_HT_CAPABILITY);
273 tlv->len = cpu_to_le16(sizeof(*s->ht_cap));
274 memcpy(tlv->val, s->ht_cap, sizeof(*s->ht_cap));
275 }
276
277 if (s->vht_cap) {
278 struct qlink_tlv_hdr *tlv = (struct qlink_tlv_hdr *)
279 skb_put(cmd_skb, sizeof(*tlv) + sizeof(*s->vht_cap));
280
281 tlv->type = cpu_to_le16(WLAN_EID_VHT_CAPABILITY);
282 tlv->len = cpu_to_le16(sizeof(*s->vht_cap));
283 memcpy(tlv->val, s->vht_cap, sizeof(*s->vht_cap));
284 }
285
244 qtnf_bus_lock(vif->mac->bus); 286 qtnf_bus_lock(vif->mac->bus);
245 287
246 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 288 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code);
@@ -255,6 +297,8 @@ int qtnf_cmd_send_config_ap(struct qtnf_vif *vif,
255 goto out; 297 goto out;
256 } 298 }
257 299
300 netif_carrier_on(vif->netdev);
301
258out: 302out:
259 qtnf_bus_unlock(vif->mac->bus); 303 qtnf_bus_unlock(vif->mac->bus);
260 return ret; 304 return ret;
@@ -380,11 +424,10 @@ int qtnf_cmd_send_mgmt_set_appie(struct qtnf_vif *vif, u8 frame_type,
380 const u8 *buf, size_t len) 424 const u8 *buf, size_t len)
381{ 425{
382 struct sk_buff *cmd_skb; 426 struct sk_buff *cmd_skb;
383 struct qlink_cmd_mgmt_append_ie *cmd;
384 u16 res_code = QLINK_CMD_RESULT_OK; 427 u16 res_code = QLINK_CMD_RESULT_OK;
385 int ret; 428 int ret;
386 429
387 if (sizeof(*cmd) + len > QTNF_MAX_CMD_BUF_SIZE) { 430 if (len > QTNF_MAX_CMD_BUF_SIZE) {
388 pr_warn("VIF%u.%u: %u frame is too big: %zu\n", vif->mac->macid, 431 pr_warn("VIF%u.%u: %u frame is too big: %zu\n", vif->mac->macid,
389 vif->vifid, frame_type, len); 432 vif->vifid, frame_type, len);
390 return -E2BIG; 433 return -E2BIG;
@@ -392,21 +435,13 @@ int qtnf_cmd_send_mgmt_set_appie(struct qtnf_vif *vif, u8 frame_type,
392 435
393 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, 436 cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid,
394 QLINK_CMD_MGMT_SET_APPIE, 437 QLINK_CMD_MGMT_SET_APPIE,
395 sizeof(*cmd)); 438 sizeof(struct qlink_cmd));
396 if (unlikely(!cmd_skb)) 439 if (unlikely(!cmd_skb))
397 return -ENOMEM; 440 return -ENOMEM;
398 441
399 qtnf_bus_lock(vif->mac->bus); 442 qtnf_cmd_tlv_ie_set_add(cmd_skb, frame_type, buf, len);
400
401 cmd = (struct qlink_cmd_mgmt_append_ie *)cmd_skb->data;
402 cmd->type = frame_type;
403 cmd->flags = 0;
404 443
405 /* If len == 0 then IE buf for specified frame type 444 qtnf_bus_lock(vif->mac->bus);
406 * should be cleared on EP.
407 */
408 if (len && buf)
409 qtnf_cmd_skb_put_buffer(cmd_skb, buf, len);
410 445
411 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); 446 ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code);
412 447
@@ -1090,7 +1125,6 @@ qtnf_cmd_resp_proc_mac_info(struct qtnf_wmac *mac,
1090 mac_info = &mac->macinfo; 1125 mac_info = &mac->macinfo;
1091 1126
1092 mac_info->bands_cap = resp_info->bands_cap; 1127 mac_info->bands_cap = resp_info->bands_cap;
1093 mac_info->phymode_cap = resp_info->phymode_cap;
1094 memcpy(&mac_info->dev_mac, &resp_info->dev_mac, 1128 memcpy(&mac_info->dev_mac, &resp_info->dev_mac,
1095 sizeof(mac_info->dev_mac)); 1129 sizeof(mac_info->dev_mac));
1096 1130
@@ -1110,24 +1144,56 @@ qtnf_cmd_resp_proc_mac_info(struct qtnf_wmac *mac,
1110 qlink_chan_width_mask_to_nl(le16_to_cpu( 1144 qlink_chan_width_mask_to_nl(le16_to_cpu(
1111 resp_info->radar_detect_widths)); 1145 resp_info->radar_detect_widths));
1112 1146
1113 memcpy(&mac_info->ht_cap, &resp_info->ht_cap, sizeof(mac_info->ht_cap)); 1147 memcpy(&mac_info->ht_cap_mod_mask, &resp_info->ht_cap_mod_mask,
1114 memcpy(&mac_info->vht_cap, &resp_info->vht_cap, 1148 sizeof(mac_info->ht_cap_mod_mask));
1115 sizeof(mac_info->vht_cap)); 1149 memcpy(&mac_info->vht_cap_mod_mask, &resp_info->vht_cap_mod_mask,
1150 sizeof(mac_info->vht_cap_mod_mask));
1151}
1152
1153static void qtnf_cmd_resp_band_fill_htcap(const u8 *info,
1154 struct ieee80211_sta_ht_cap *bcap)
1155{
1156 const struct ieee80211_ht_cap *ht_cap =
1157 (const struct ieee80211_ht_cap *)info;
1158
1159 bcap->ht_supported = true;
1160 bcap->cap = le16_to_cpu(ht_cap->cap_info);
1161 bcap->ampdu_factor =
1162 ht_cap->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR;
1163 bcap->ampdu_density =
1164 (ht_cap->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_DENSITY) >>
1165 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
1166 memcpy(&bcap->mcs, &ht_cap->mcs, sizeof(bcap->mcs));
1167}
1168
1169static void qtnf_cmd_resp_band_fill_vhtcap(const u8 *info,
1170 struct ieee80211_sta_vht_cap *bcap)
1171{
1172 const struct ieee80211_vht_cap *vht_cap =
1173 (const struct ieee80211_vht_cap *)info;
1174
1175 bcap->vht_supported = true;
1176 bcap->cap = le32_to_cpu(vht_cap->vht_cap_info);
1177 memcpy(&bcap->vht_mcs, &vht_cap->supp_mcs, sizeof(bcap->vht_mcs));
1116} 1178}
1117 1179
1118static int 1180static int
1119qtnf_cmd_resp_fill_channels_info(struct ieee80211_supported_band *band, 1181qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band,
1120 struct qlink_resp_get_chan_info *resp, 1182 struct qlink_resp_band_info_get *resp,
1121 size_t payload_len) 1183 size_t payload_len)
1122{ 1184{
1123 u16 tlv_type; 1185 u16 tlv_type;
1124 size_t tlv_len; 1186 size_t tlv_len;
1187 size_t tlv_dlen;
1125 const struct qlink_tlv_hdr *tlv; 1188 const struct qlink_tlv_hdr *tlv;
1126 const struct qlink_tlv_channel *qchan; 1189 const struct qlink_tlv_channel *qchan;
1127 struct ieee80211_channel *chan; 1190 struct ieee80211_channel *chan;
1128 unsigned int chidx = 0; 1191 unsigned int chidx = 0;
1129 u32 qflags; 1192 u32 qflags;
1130 1193
1194 memset(&band->ht_cap, 0, sizeof(band->ht_cap));
1195 memset(&band->vht_cap, 0, sizeof(band->vht_cap));
1196
1131 if (band->channels) { 1197 if (band->channels) {
1132 if (band->n_channels == resp->num_chans) { 1198 if (band->n_channels == resp->num_chans) {
1133 memset(band->channels, 0, 1199 memset(band->channels, 0,
@@ -1155,7 +1221,8 @@ qtnf_cmd_resp_fill_channels_info(struct ieee80211_supported_band *band,
1155 1221
1156 while (payload_len >= sizeof(*tlv)) { 1222 while (payload_len >= sizeof(*tlv)) {
1157 tlv_type = le16_to_cpu(tlv->type); 1223 tlv_type = le16_to_cpu(tlv->type);
1158 tlv_len = le16_to_cpu(tlv->len) + sizeof(*tlv); 1224 tlv_dlen = le16_to_cpu(tlv->len);
1225 tlv_len = tlv_dlen + sizeof(*tlv);
1159 1226
1160 if (tlv_len > payload_len) { 1227 if (tlv_len > payload_len) {
1161 pr_warn("malformed TLV 0x%.2X; LEN: %zu\n", 1228 pr_warn("malformed TLV 0x%.2X; LEN: %zu\n",
@@ -1241,13 +1308,32 @@ qtnf_cmd_resp_fill_channels_info(struct ieee80211_supported_band *band,
1241 chan->hw_value, chan->flags, chan->max_power, 1308 chan->hw_value, chan->flags, chan->max_power,
1242 chan->max_reg_power); 1309 chan->max_reg_power);
1243 break; 1310 break;
1311 case WLAN_EID_HT_CAPABILITY:
1312 if (unlikely(tlv_dlen !=
1313 sizeof(struct ieee80211_ht_cap))) {
1314 pr_err("bad HTCAP TLV len %zu\n", tlv_dlen);
1315 goto error_ret;
1316 }
1317
1318 qtnf_cmd_resp_band_fill_htcap(tlv->val, &band->ht_cap);
1319 break;
1320 case WLAN_EID_VHT_CAPABILITY:
1321 if (unlikely(tlv_dlen !=
1322 sizeof(struct ieee80211_vht_cap))) {
1323 pr_err("bad VHTCAP TLV len %zu\n", tlv_dlen);
1324 goto error_ret;
1325 }
1326
1327 qtnf_cmd_resp_band_fill_vhtcap(tlv->val,
1328 &band->vht_cap);
1329 break;
1244 default: 1330 default:
1245 pr_warn("unknown TLV type: %#x\n", tlv_type); 1331 pr_warn("unknown TLV type: %#x\n", tlv_type);
1246 break; 1332 break;
1247 } 1333 }
1248 1334
1249 payload_len -= tlv_len; 1335 payload_len -= tlv_len;
1250 tlv = (struct qlink_tlv_hdr *)((u8 *)tlv + tlv_len); 1336 tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_dlen);
1251 } 1337 }
1252 1338
1253 if (payload_len) { 1339 if (payload_len) {
@@ -1469,13 +1555,13 @@ out:
1469 return ret; 1555 return ret;
1470} 1556}
1471 1557
1472int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac, 1558int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
1473 struct ieee80211_supported_band *band) 1559 struct ieee80211_supported_band *band)
1474{ 1560{
1475 struct sk_buff *cmd_skb, *resp_skb = NULL; 1561 struct sk_buff *cmd_skb, *resp_skb = NULL;
1476 size_t info_len; 1562 size_t info_len;
1477 struct qlink_cmd_chans_info_get *cmd; 1563 struct qlink_cmd_band_info_get *cmd;
1478 struct qlink_resp_get_chan_info *resp; 1564 struct qlink_resp_band_info_get *resp;
1479 u16 res_code = QLINK_CMD_RESULT_OK; 1565 u16 res_code = QLINK_CMD_RESULT_OK;
1480 int ret = 0; 1566 int ret = 0;
1481 u8 qband; 1567 u8 qband;
@@ -1495,12 +1581,12 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
1495 } 1581 }
1496 1582
1497 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0, 1583 cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
1498 QLINK_CMD_CHANS_INFO_GET, 1584 QLINK_CMD_BAND_INFO_GET,
1499 sizeof(*cmd)); 1585 sizeof(*cmd));
1500 if (!cmd_skb) 1586 if (!cmd_skb)
1501 return -ENOMEM; 1587 return -ENOMEM;
1502 1588
1503 cmd = (struct qlink_cmd_chans_info_get *)cmd_skb->data; 1589 cmd = (struct qlink_cmd_band_info_get *)cmd_skb->data;
1504 cmd->band = qband; 1590 cmd->band = qband;
1505 1591
1506 qtnf_bus_lock(mac->bus); 1592 qtnf_bus_lock(mac->bus);
@@ -1517,7 +1603,7 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
1517 goto out; 1603 goto out;
1518 } 1604 }
1519 1605
1520 resp = (struct qlink_resp_get_chan_info *)resp_skb->data; 1606 resp = (struct qlink_resp_band_info_get *)resp_skb->data;
1521 if (resp->band != qband) { 1607 if (resp->band != qband) {
1522 pr_err("MAC%u: reply band %u != cmd band %u\n", mac->macid, 1608 pr_err("MAC%u: reply band %u != cmd band %u\n", mac->macid,
1523 resp->band, qband); 1609 resp->band, qband);
@@ -1525,7 +1611,7 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
1525 goto out; 1611 goto out;
1526 } 1612 }
1527 1613
1528 ret = qtnf_cmd_resp_fill_channels_info(band, resp, info_len); 1614 ret = qtnf_cmd_resp_fill_band_info(band, resp, info_len);
1529 1615
1530out: 1616out:
1531 qtnf_bus_unlock(mac->bus); 1617 qtnf_bus_unlock(mac->bus);
@@ -1942,17 +2028,36 @@ out:
1942 return ret; 2028 return ret;
1943} 2029}
1944 2030
2031static void qtnf_cmd_channel_tlv_add(struct sk_buff *cmd_skb,
2032 const struct ieee80211_channel *sc)
2033{
2034 struct qlink_tlv_channel *qchan;
2035 u32 flags = 0;
2036
2037 qchan = skb_put_zero(cmd_skb, sizeof(*qchan));
2038 qchan->hdr.type = cpu_to_le16(QTN_TLV_ID_CHANNEL);
2039 qchan->hdr.len = cpu_to_le16(sizeof(*qchan) - sizeof(qchan->hdr));
2040 qchan->center_freq = cpu_to_le16(sc->center_freq);
2041 qchan->hw_value = cpu_to_le16(sc->hw_value);
2042
2043 if (sc->flags & IEEE80211_CHAN_NO_IR)
2044 flags |= QLINK_CHAN_NO_IR;
2045
2046 if (sc->flags & IEEE80211_CHAN_RADAR)
2047 flags |= QLINK_CHAN_RADAR;
2048
2049 qchan->flags = cpu_to_le32(flags);
2050}
2051
1945int qtnf_cmd_send_scan(struct qtnf_wmac *mac) 2052int qtnf_cmd_send_scan(struct qtnf_wmac *mac)
1946{ 2053{
1947 struct sk_buff *cmd_skb; 2054 struct sk_buff *cmd_skb;
1948 u16 res_code = QLINK_CMD_RESULT_OK; 2055 u16 res_code = QLINK_CMD_RESULT_OK;
1949 struct ieee80211_channel *sc; 2056 struct ieee80211_channel *sc;
1950 struct cfg80211_scan_request *scan_req = mac->scan_req; 2057 struct cfg80211_scan_request *scan_req = mac->scan_req;
1951 struct qlink_tlv_channel *qchan;
1952 int n_channels; 2058 int n_channels;
1953 int count = 0; 2059 int count = 0;
1954 int ret; 2060 int ret;
1955 u32 flags;
1956 2061
1957 if (scan_req->n_ssids > QTNF_MAX_SSID_LIST_LENGTH) { 2062 if (scan_req->n_ssids > QTNF_MAX_SSID_LIST_LENGTH) {
1958 pr_err("MAC%u: too many SSIDs in scan request\n", mac->macid); 2063 pr_err("MAC%u: too many SSIDs in scan request\n", mac->macid);
@@ -1977,9 +2082,8 @@ int qtnf_cmd_send_scan(struct qtnf_wmac *mac)
1977 } 2082 }
1978 2083
1979 if (scan_req->ie_len != 0) 2084 if (scan_req->ie_len != 0)
1980 qtnf_cmd_skb_put_tlv_arr(cmd_skb, QTN_TLV_ID_IE_SET, 2085 qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_PROBE_REQ,
1981 scan_req->ie, 2086 scan_req->ie, scan_req->ie_len);
1982 scan_req->ie_len);
1983 2087
1984 if (scan_req->n_channels) { 2088 if (scan_req->n_channels) {
1985 n_channels = scan_req->n_channels; 2089 n_channels = scan_req->n_channels;
@@ -1995,22 +2099,8 @@ int qtnf_cmd_send_scan(struct qtnf_wmac *mac)
1995 pr_debug("MAC%u: scan chan=%d, freq=%d, flags=%#x\n", 2099 pr_debug("MAC%u: scan chan=%d, freq=%d, flags=%#x\n",
1996 mac->macid, sc->hw_value, sc->center_freq, 2100 mac->macid, sc->hw_value, sc->center_freq,
1997 sc->flags); 2101 sc->flags);
1998 qchan = skb_put_zero(cmd_skb, sizeof(*qchan));
1999 flags = 0;
2000
2001 qchan->hdr.type = cpu_to_le16(QTN_TLV_ID_CHANNEL);
2002 qchan->hdr.len = cpu_to_le16(sizeof(*qchan) -
2003 sizeof(struct qlink_tlv_hdr));
2004 qchan->center_freq = cpu_to_le16(sc->center_freq);
2005 qchan->hw_value = cpu_to_le16(sc->hw_value);
2006
2007 if (sc->flags & IEEE80211_CHAN_NO_IR)
2008 flags |= QLINK_CHAN_NO_IR;
2009
2010 if (sc->flags & IEEE80211_CHAN_RADAR)
2011 flags |= QLINK_CHAN_RADAR;
2012 2102
2013 qchan->flags = cpu_to_le32(flags); 2103 qtnf_cmd_channel_tlv_add(cmd_skb, sc);
2014 n_channels--; 2104 n_channels--;
2015 count++; 2105 count++;
2016 } 2106 }
@@ -2054,10 +2144,15 @@ int qtnf_cmd_send_connect(struct qtnf_vif *vif,
2054 2144
2055 ether_addr_copy(cmd->bssid, vif->bssid); 2145 ether_addr_copy(cmd->bssid, vif->bssid);
2056 2146
2057 if (sme->channel) 2147 if (sme->bssid_hint)
2058 cmd->channel = cpu_to_le16(sme->channel->hw_value); 2148 ether_addr_copy(cmd->bssid_hint, sme->bssid_hint);
2149 else
2150 eth_zero_addr(cmd->bssid_hint);
2151
2152 if (sme->prev_bssid)
2153 ether_addr_copy(cmd->prev_bssid, sme->prev_bssid);
2059 else 2154 else
2060 cmd->channel = 0; 2155 eth_zero_addr(cmd->prev_bssid);
2061 2156
2062 if ((sme->bg_scan_period > 0) && 2157 if ((sme->bg_scan_period > 0) &&
2063 (sme->bg_scan_period <= QTNF_MAX_BG_SCAN_PERIOD)) 2158 (sme->bg_scan_period <= QTNF_MAX_BG_SCAN_PERIOD))
@@ -2075,11 +2170,18 @@ int qtnf_cmd_send_connect(struct qtnf_vif *vif,
2075 connect_flags |= QLINK_STA_CONNECT_USE_RRM; 2170 connect_flags |= QLINK_STA_CONNECT_USE_RRM;
2076 2171
2077 cmd->flags = cpu_to_le32(connect_flags); 2172 cmd->flags = cpu_to_le32(connect_flags);
2173 memcpy(&cmd->ht_capa, &sme->ht_capa, sizeof(cmd->ht_capa));
2174 memcpy(&cmd->ht_capa_mask, &sme->ht_capa_mask,
2175 sizeof(cmd->ht_capa_mask));
2176 memcpy(&cmd->vht_capa, &sme->vht_capa, sizeof(cmd->vht_capa));
2177 memcpy(&cmd->vht_capa_mask, &sme->vht_capa_mask,
2178 sizeof(cmd->vht_capa_mask));
2179 cmd->pbss = sme->pbss;
2078 2180
2079 aen = &cmd->aen; 2181 aen = &cmd->aen;
2080 aen->auth_type = sme->auth_type; 2182 aen->auth_type = sme->auth_type;
2081 aen->privacy = !!sme->privacy; 2183 aen->privacy = !!sme->privacy;
2082 aen->mfp = sme->mfp; 2184 cmd->mfp = sme->mfp;
2083 aen->wpa_versions = cpu_to_le32(sme->crypto.wpa_versions); 2185 aen->wpa_versions = cpu_to_le32(sme->crypto.wpa_versions);
2084 aen->cipher_group = cpu_to_le32(sme->crypto.cipher_group); 2186 aen->cipher_group = cpu_to_le32(sme->crypto.cipher_group);
2085 aen->n_ciphers_pairwise = cpu_to_le32(sme->crypto.n_ciphers_pairwise); 2187 aen->n_ciphers_pairwise = cpu_to_le32(sme->crypto.n_ciphers_pairwise);
@@ -2103,9 +2205,11 @@ int qtnf_cmd_send_connect(struct qtnf_vif *vif,
2103 sme->ssid_len); 2205 sme->ssid_len);
2104 2206
2105 if (sme->ie_len != 0) 2207 if (sme->ie_len != 0)
2106 qtnf_cmd_skb_put_tlv_arr(cmd_skb, QTN_TLV_ID_IE_SET, 2208 qtnf_cmd_tlv_ie_set_add(cmd_skb, QLINK_IE_SET_ASSOC_REQ,
2107 sme->ie, 2209 sme->ie, sme->ie_len);
2108 sme->ie_len); 2210
2211 if (sme->channel)
2212 qtnf_cmd_channel_tlv_add(cmd_skb, sme->channel);
2109 2213
2110 qtnf_bus_lock(vif->mac->bus); 2214 qtnf_bus_lock(vif->mac->bus);
2111 2215
diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.h b/drivers/net/wireless/quantenna/qtnfmac/commands.h
index e87c4a484dd4..d981a76e5835 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.h
@@ -30,12 +30,11 @@ int qtnf_cmd_send_add_intf(struct qtnf_vif *vif, enum nl80211_iftype iftype,
30int qtnf_cmd_send_change_intf_type(struct qtnf_vif *vif, 30int qtnf_cmd_send_change_intf_type(struct qtnf_vif *vif,
31 enum nl80211_iftype iftype, u8 *mac_addr); 31 enum nl80211_iftype iftype, u8 *mac_addr);
32int qtnf_cmd_send_del_intf(struct qtnf_vif *vif); 32int qtnf_cmd_send_del_intf(struct qtnf_vif *vif);
33int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac, 33int qtnf_cmd_band_info_get(struct qtnf_wmac *mac,
34 struct ieee80211_supported_band *band); 34 struct ieee80211_supported_band *band);
35int qtnf_cmd_send_regulatory_config(struct qtnf_wmac *mac, const char *alpha2); 35int qtnf_cmd_send_regulatory_config(struct qtnf_wmac *mac, const char *alpha2);
36int qtnf_cmd_send_config_ap(struct qtnf_vif *vif, 36int qtnf_cmd_send_start_ap(struct qtnf_vif *vif,
37 const struct cfg80211_ap_settings *s); 37 const struct cfg80211_ap_settings *s);
38int qtnf_cmd_send_start_ap(struct qtnf_vif *vif);
39int qtnf_cmd_send_stop_ap(struct qtnf_vif *vif); 38int qtnf_cmd_send_stop_ap(struct qtnf_vif *vif);
40int qtnf_cmd_send_register_mgmt(struct qtnf_vif *vif, u16 frame_type, bool reg); 39int qtnf_cmd_send_register_mgmt(struct qtnf_vif *vif, u16 frame_type, bool reg);
41int qtnf_cmd_send_mgmt_frame(struct qtnf_vif *vif, u32 cookie, u16 flags, 40int qtnf_cmd_send_mgmt_frame(struct qtnf_vif *vif, u32 cookie, u16 flags,
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c
index 6a6e5ffb0348..2d2c1ea65cb2 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.c
@@ -171,7 +171,7 @@ static int qtnf_mac_init_single_band(struct wiphy *wiphy,
171 171
172 wiphy->bands[band]->band = band; 172 wiphy->bands[band]->band = band;
173 173
174 ret = qtnf_cmd_get_mac_chan_info(mac, wiphy->bands[band]); 174 ret = qtnf_cmd_band_info_get(mac, wiphy->bands[band]);
175 if (ret) { 175 if (ret) {
176 pr_err("MAC%u: band %u: failed to get chans info: %d\n", 176 pr_err("MAC%u: band %u: failed to get chans info: %d\n",
177 mac->macid, band, ret); 177 mac->macid, band, ret);
@@ -179,7 +179,6 @@ static int qtnf_mac_init_single_band(struct wiphy *wiphy,
179 } 179 }
180 180
181 qtnf_band_init_rates(wiphy->bands[band]); 181 qtnf_band_init_rates(wiphy->bands[band]);
182 qtnf_band_setup_htvht_caps(&mac->macinfo, wiphy->bands[band]);
183 182
184 return 0; 183 return 0;
185} 184}
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h b/drivers/net/wireless/quantenna/qtnfmac/core.h
index da2c24e2271d..1b7bc0318f3e 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.h
@@ -92,7 +92,6 @@ struct qtnf_vif {
92 92
93struct qtnf_mac_info { 93struct qtnf_mac_info {
94 u8 bands_cap; 94 u8 bands_cap;
95 u8 phymode_cap;
96 u8 dev_mac[ETH_ALEN]; 95 u8 dev_mac[ETH_ALEN];
97 u8 num_tx_chain; 96 u8 num_tx_chain;
98 u8 num_rx_chain; 97 u8 num_rx_chain;
@@ -103,8 +102,8 @@ struct qtnf_mac_info {
103 u8 sretry_limit; 102 u8 sretry_limit;
104 u8 coverage_class; 103 u8 coverage_class;
105 u8 radar_detect_widths; 104 u8 radar_detect_widths;
106 struct ieee80211_ht_cap ht_cap; 105 struct ieee80211_ht_cap ht_cap_mod_mask;
107 struct ieee80211_vht_cap vht_cap; 106 struct ieee80211_vht_cap vht_cap_mod_mask;
108 struct ieee80211_iface_limit *limits; 107 struct ieee80211_iface_limit *limits;
109 size_t n_limits; 108 size_t n_limits;
110}; 109};
diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.c b/drivers/net/wireless/quantenna/qtnfmac/event.c
index 4b29f9fb9c3c..4abc6d9ed560 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/event.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/event.c
@@ -65,34 +65,39 @@ qtnf_event_handle_sta_assoc(struct qtnf_wmac *mac, struct qtnf_vif *vif,
65 sinfo.assoc_req_ies_len = 0; 65 sinfo.assoc_req_ies_len = 0;
66 66
67 payload_len = len - sizeof(*sta_assoc); 67 payload_len = len - sizeof(*sta_assoc);
68 tlv = (struct qlink_tlv_hdr *)sta_assoc->ies; 68 tlv = (const struct qlink_tlv_hdr *)sta_assoc->ies;
69 69
70 while (payload_len >= sizeof(struct qlink_tlv_hdr)) { 70 while (payload_len >= sizeof(*tlv)) {
71 tlv_type = le16_to_cpu(tlv->type); 71 tlv_type = le16_to_cpu(tlv->type);
72 tlv_value_len = le16_to_cpu(tlv->len); 72 tlv_value_len = le16_to_cpu(tlv->len);
73 tlv_full_len = tlv_value_len + sizeof(struct qlink_tlv_hdr); 73 tlv_full_len = tlv_value_len + sizeof(struct qlink_tlv_hdr);
74 74
75 if (tlv_full_len > payload_len) { 75 if (tlv_full_len > payload_len)
76 pr_warn("VIF%u.%u: malformed TLV 0x%.2X; LEN: %u\n",
77 mac->macid, vif->vifid, tlv_type,
78 tlv_value_len);
79 return -EINVAL; 76 return -EINVAL;
80 }
81 77
82 if (tlv_type == QTN_TLV_ID_IE_SET) { 78 if (tlv_type == QTN_TLV_ID_IE_SET) {
83 sinfo.assoc_req_ies = tlv->val; 79 const struct qlink_tlv_ie_set *ie_set;
84 sinfo.assoc_req_ies_len = tlv_value_len; 80 unsigned int ie_len;
81
82 if (payload_len < sizeof(*ie_set))
83 return -EINVAL;
84
85 ie_set = (const struct qlink_tlv_ie_set *)tlv;
86 ie_len = tlv_value_len -
87 (sizeof(*ie_set) - sizeof(ie_set->hdr));
88
89 if (ie_set->type == QLINK_IE_SET_ASSOC_REQ && ie_len) {
90 sinfo.assoc_req_ies = ie_set->ie_data;
91 sinfo.assoc_req_ies_len = ie_len;
92 }
85 } 93 }
86 94
87 payload_len -= tlv_full_len; 95 payload_len -= tlv_full_len;
88 tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); 96 tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len);
89 } 97 }
90 98
91 if (payload_len) { 99 if (payload_len)
92 pr_warn("VIF%u.%u: malformed TLV buf; bytes left: %zu\n",
93 mac->macid, vif->vifid, payload_len);
94 return -EINVAL; 100 return -EINVAL;
95 }
96 101
97 cfg80211_new_sta(vif->netdev, sta_assoc->sta_addr, &sinfo, 102 cfg80211_new_sta(vif->netdev, sta_assoc->sta_addr, &sinfo,
98 GFP_KERNEL); 103 GFP_KERNEL);
@@ -247,13 +252,12 @@ qtnf_event_handle_scan_results(struct qtnf_vif *vif,
247 struct cfg80211_bss *bss; 252 struct cfg80211_bss *bss;
248 struct ieee80211_channel *channel; 253 struct ieee80211_channel *channel;
249 struct wiphy *wiphy = priv_to_wiphy(vif->mac); 254 struct wiphy *wiphy = priv_to_wiphy(vif->mac);
250 enum cfg80211_bss_frame_type frame_type; 255 enum cfg80211_bss_frame_type frame_type = CFG80211_BSS_FTYPE_UNKNOWN;
251 size_t payload_len; 256 size_t payload_len;
252 u16 tlv_type; 257 u16 tlv_type;
253 u16 tlv_value_len; 258 u16 tlv_value_len;
254 size_t tlv_full_len; 259 size_t tlv_full_len;
255 const struct qlink_tlv_hdr *tlv; 260 const struct qlink_tlv_hdr *tlv;
256
257 const u8 *ies = NULL; 261 const u8 *ies = NULL;
258 size_t ies_len = 0; 262 size_t ies_len = 0;
259 263
@@ -270,17 +274,6 @@ qtnf_event_handle_scan_results(struct qtnf_vif *vif,
270 return -EINVAL; 274 return -EINVAL;
271 } 275 }
272 276
273 switch (sr->frame_type) {
274 case QLINK_BSS_FTYPE_BEACON:
275 frame_type = CFG80211_BSS_FTYPE_BEACON;
276 break;
277 case QLINK_BSS_FTYPE_PRESP:
278 frame_type = CFG80211_BSS_FTYPE_PRESP;
279 break;
280 default:
281 frame_type = CFG80211_BSS_FTYPE_UNKNOWN;
282 }
283
284 payload_len = len - sizeof(*sr); 277 payload_len = len - sizeof(*sr);
285 tlv = (struct qlink_tlv_hdr *)sr->payload; 278 tlv = (struct qlink_tlv_hdr *)sr->payload;
286 279
@@ -289,27 +282,43 @@ qtnf_event_handle_scan_results(struct qtnf_vif *vif,
289 tlv_value_len = le16_to_cpu(tlv->len); 282 tlv_value_len = le16_to_cpu(tlv->len);
290 tlv_full_len = tlv_value_len + sizeof(struct qlink_tlv_hdr); 283 tlv_full_len = tlv_value_len + sizeof(struct qlink_tlv_hdr);
291 284
292 if (tlv_full_len > payload_len) { 285 if (tlv_full_len > payload_len)
293 pr_warn("VIF%u.%u: malformed TLV 0x%.2X; LEN: %u\n",
294 vif->mac->macid, vif->vifid, tlv_type,
295 tlv_value_len);
296 return -EINVAL; 286 return -EINVAL;
297 }
298 287
299 if (tlv_type == QTN_TLV_ID_IE_SET) { 288 if (tlv_type == QTN_TLV_ID_IE_SET) {
300 ies = tlv->val; 289 const struct qlink_tlv_ie_set *ie_set;
301 ies_len = tlv_value_len; 290 unsigned int ie_len;
291
292 if (payload_len < sizeof(*ie_set))
293 return -EINVAL;
294
295 ie_set = (const struct qlink_tlv_ie_set *)tlv;
296 ie_len = tlv_value_len -
297 (sizeof(*ie_set) - sizeof(ie_set->hdr));
298
299 switch (ie_set->type) {
300 case QLINK_IE_SET_BEACON_IES:
301 frame_type = CFG80211_BSS_FTYPE_BEACON;
302 break;
303 case QLINK_IE_SET_PROBE_RESP_IES:
304 frame_type = CFG80211_BSS_FTYPE_PRESP;
305 break;
306 default:
307 frame_type = CFG80211_BSS_FTYPE_UNKNOWN;
308 }
309
310 if (ie_len) {
311 ies = ie_set->ie_data;
312 ies_len = ie_len;
313 }
302 } 314 }
303 315
304 payload_len -= tlv_full_len; 316 payload_len -= tlv_full_len;
305 tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len); 317 tlv = (struct qlink_tlv_hdr *)(tlv->val + tlv_value_len);
306 } 318 }
307 319
308 if (payload_len) { 320 if (payload_len)
309 pr_warn("VIF%u.%u: malformed TLV buf; bytes left: %zu\n",
310 vif->mac->macid, vif->vifid, payload_len);
311 return -EINVAL; 321 return -EINVAL;
312 }
313 322
314 bss = cfg80211_inform_bss(wiphy, channel, frame_type, 323 bss = cfg80211_inform_bss(wiphy, channel, frame_type,
315 sr->bssid, get_unaligned_le64(&sr->tsf), 324 sr->bssid, get_unaligned_le64(&sr->tsf),
diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
index 0f582782682f..a432fb001c41 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h
+++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h
@@ -19,7 +19,7 @@
19 19
20#include <linux/ieee80211.h> 20#include <linux/ieee80211.h>
21 21
22#define QLINK_PROTO_VER 5 22#define QLINK_PROTO_VER 6
23 23
24#define QLINK_MACID_RSVD 0xFF 24#define QLINK_MACID_RSVD 0xFF
25#define QLINK_VIFID_RSVD 0xFF 25#define QLINK_VIFID_RSVD 0xFF
@@ -74,12 +74,6 @@ enum qlink_hw_capab {
74 QLINK_HW_CAPAB_STA_INACT_TIMEOUT = BIT(1), 74 QLINK_HW_CAPAB_STA_INACT_TIMEOUT = BIT(1),
75}; 75};
76 76
77enum qlink_phy_mode {
78 QLINK_PHYMODE_BGN = BIT(0),
79 QLINK_PHYMODE_AN = BIT(1),
80 QLINK_PHYMODE_AC = BIT(2),
81};
82
83enum qlink_iface_type { 77enum qlink_iface_type {
84 QLINK_IFTYPE_AP = 1, 78 QLINK_IFTYPE_AP = 1,
85 QLINK_IFTYPE_STATION = 2, 79 QLINK_IFTYPE_STATION = 2,
@@ -154,9 +148,9 @@ struct qlink_auth_encr {
154 __le16 control_port_ethertype; 148 __le16 control_port_ethertype;
155 u8 auth_type; 149 u8 auth_type;
156 u8 privacy; 150 u8 privacy;
157 u8 mfp;
158 u8 control_port; 151 u8 control_port;
159 u8 control_port_no_encrypt; 152 u8 control_port_no_encrypt;
153 u8 rsvd[2];
160} __packed; 154} __packed;
161 155
162/* QLINK Command messages related definitions 156/* QLINK Command messages related definitions
@@ -168,11 +162,12 @@ struct qlink_auth_encr {
168 * Commands are QLINK messages of type @QLINK_MSG_TYPE_CMD, sent by driver to 162 * Commands are QLINK messages of type @QLINK_MSG_TYPE_CMD, sent by driver to
169 * wireless network device for processing. Device is expected to send back a 163 * wireless network device for processing. Device is expected to send back a
170 * reply message of type &QLINK_MSG_TYPE_CMDRSP, containing at least command 164 * reply message of type &QLINK_MSG_TYPE_CMDRSP, containing at least command
171 * execution status (one of &enum qlink_cmd_result) at least. Reply message 165 * execution status (one of &enum qlink_cmd_result). Reply message
172 * may also contain data payload specific to the command type. 166 * may also contain data payload specific to the command type.
173 * 167 *
174 * @QLINK_CMD_CHANS_INFO_GET: for the specified MAC and specified band, get 168 * @QLINK_CMD_BAND_INFO_GET: for the specified MAC and specified band, get
175 * number of operational channels and information on each of the channel. 169 * the band's description including number of operational channels and
170 * info on each channel, HT/VHT capabilities, supported rates etc.
176 * This command is generic to a specified MAC, interface index must be set 171 * This command is generic to a specified MAC, interface index must be set
177 * to QLINK_VIFID_RSVD in command header. 172 * to QLINK_VIFID_RSVD in command header.
178 * @QLINK_CMD_REG_NOTIFY: notify device about regulatory domain change. This 173 * @QLINK_CMD_REG_NOTIFY: notify device about regulatory domain change. This
@@ -194,10 +189,9 @@ enum qlink_cmd_type {
194 QLINK_CMD_CHANGE_INTF = 0x0017, 189 QLINK_CMD_CHANGE_INTF = 0x0017,
195 QLINK_CMD_UPDOWN_INTF = 0x0018, 190 QLINK_CMD_UPDOWN_INTF = 0x0018,
196 QLINK_CMD_REG_NOTIFY = 0x0019, 191 QLINK_CMD_REG_NOTIFY = 0x0019,
197 QLINK_CMD_CHANS_INFO_GET = 0x001A, 192 QLINK_CMD_BAND_INFO_GET = 0x001A,
198 QLINK_CMD_CHAN_SWITCH = 0x001B, 193 QLINK_CMD_CHAN_SWITCH = 0x001B,
199 QLINK_CMD_CHAN_GET = 0x001C, 194 QLINK_CMD_CHAN_GET = 0x001C,
200 QLINK_CMD_CONFIG_AP = 0x0020,
201 QLINK_CMD_START_AP = 0x0021, 195 QLINK_CMD_START_AP = 0x0021,
202 QLINK_CMD_STOP_AP = 0x0022, 196 QLINK_CMD_STOP_AP = 0x0022,
203 QLINK_CMD_GET_STA_INFO = 0x0030, 197 QLINK_CMD_GET_STA_INFO = 0x0030,
@@ -304,21 +298,6 @@ struct qlink_cmd_mgmt_frame_tx {
304} __packed; 298} __packed;
305 299
306/** 300/**
307 * struct qlink_cmd_mgmt_append_ie - data for QLINK_CMD_MGMT_SET_APPIE command
308 *
309 * @type: type of MGMT frame to appent requested IEs to, one of
310 * &enum qlink_mgmt_frame_type.
311 * @flags: for future use.
312 * @ie_data: IEs data to append.
313 */
314struct qlink_cmd_mgmt_append_ie {
315 struct qlink_cmd chdr;
316 u8 type;
317 u8 flags;
318 u8 ie_data[0];
319} __packed;
320
321/**
322 * struct qlink_cmd_get_sta_info - data for QLINK_CMD_GET_STA_INFO command 301 * struct qlink_cmd_get_sta_info - data for QLINK_CMD_GET_STA_INFO command
323 * 302 *
324 * @sta_addr: MAC address of the STA statistics is requested for. 303 * @sta_addr: MAC address of the STA statistics is requested for.
@@ -425,20 +404,36 @@ enum qlink_sta_connect_flags {
425/** 404/**
426 * struct qlink_cmd_connect - data for QLINK_CMD_CONNECT command 405 * struct qlink_cmd_connect - data for QLINK_CMD_CONNECT command
427 * 406 *
428 * @flags: for future use. 407 * @bssid: BSSID of the BSS to connect to.
429 * @channel: channel which should be used to connect. 408 * @bssid_hint: recommended AP BSSID for initial connection to the BSS or
409 * 00:00:00:00:00:00 if not specified.
410 * @prev_bssid: previous BSSID, if specified (not 00:00:00:00:00:00) indicates
411 * a request to reassociate.
430 * @bg_scan_period: period of background scan. 412 * @bg_scan_period: period of background scan.
413 * @flags: one of &enum qlink_sta_connect_flags.
414 * @ht_capa: HT Capabilities overrides.
415 * @ht_capa_mask: The bits of ht_capa which are to be used.
416 * @vht_capa: VHT Capability overrides
417 * @vht_capa_mask: The bits of vht_capa which are to be used.
431 * @aen: authentication information. 418 * @aen: authentication information.
432 * @bssid: BSSID of the BSS to connect to. 419 * @mfp: whether to use management frame protection.
433 * @payload: variable portion of connection request. 420 * @payload: variable portion of connection request.
434 */ 421 */
435struct qlink_cmd_connect { 422struct qlink_cmd_connect {
436 struct qlink_cmd chdr; 423 struct qlink_cmd chdr;
437 __le32 flags; 424 u8 bssid[ETH_ALEN];
438 __le16 channel; 425 u8 bssid_hint[ETH_ALEN];
426 u8 prev_bssid[ETH_ALEN];
439 __le16 bg_scan_period; 427 __le16 bg_scan_period;
428 __le32 flags;
429 struct ieee80211_ht_cap ht_capa;
430 struct ieee80211_ht_cap ht_capa_mask;
431 struct ieee80211_vht_cap vht_capa;
432 struct ieee80211_vht_cap vht_capa_mask;
440 struct qlink_auth_encr aen; 433 struct qlink_auth_encr aen;
441 u8 bssid[ETH_ALEN]; 434 u8 mfp;
435 u8 pbss;
436 u8 rsvd[2];
442 u8 payload[0]; 437 u8 payload[0];
443} __packed; 438} __packed;
444 439
@@ -477,11 +472,11 @@ enum qlink_band {
477}; 472};
478 473
479/** 474/**
480 * struct qlink_cmd_chans_info_get - data for QLINK_CMD_CHANS_INFO_GET command 475 * struct qlink_cmd_band_info_get - data for QLINK_CMD_BAND_INFO_GET command
481 * 476 *
482 * @band: a PHY band for which channels info is needed, one of @enum qlink_band 477 * @band: a PHY band for which information is queried, one of @enum qlink_band
483 */ 478 */
484struct qlink_cmd_chans_info_get { 479struct qlink_cmd_band_info_get {
485 struct qlink_cmd chdr; 480 struct qlink_cmd chdr;
486 u8 band; 481 u8 band;
487} __packed; 482} __packed;
@@ -562,7 +557,7 @@ enum qlink_hidden_ssid {
562}; 557};
563 558
564/** 559/**
565 * struct qlink_cmd_config_ap - data for QLINK_CMD_CONFIG_AP command 560 * struct qlink_cmd_start_ap - data for QLINK_CMD_START_AP command
566 * 561 *
567 * @beacon_interval: beacon interval 562 * @beacon_interval: beacon interval
568 * @inactivity_timeout: station's inactivity period in seconds 563 * @inactivity_timeout: station's inactivity period in seconds
@@ -574,7 +569,7 @@ enum qlink_hidden_ssid {
574 * @aen: encryption info 569 * @aen: encryption info
575 * @info: variable configurations 570 * @info: variable configurations
576 */ 571 */
577struct qlink_cmd_config_ap { 572struct qlink_cmd_start_ap {
578 struct qlink_cmd chdr; 573 struct qlink_cmd chdr;
579 __le16 beacon_interval; 574 __le16 beacon_interval;
580 __le16 inactivity_timeout; 575 __le16 inactivity_timeout;
@@ -635,10 +630,9 @@ struct qlink_resp {
635 * specified WMAC). 630 * specified WMAC).
636 * @num_tx_chain: Number of transmit chains used by WMAC. 631 * @num_tx_chain: Number of transmit chains used by WMAC.
637 * @num_rx_chain: Number of receive chains used by WMAC. 632 * @num_rx_chain: Number of receive chains used by WMAC.
638 * @vht_cap: VHT capabilities. 633 * @vht_cap_mod_mask: mask specifying which VHT capabilities can be altered.
639 * @ht_cap: HT capabilities. 634 * @ht_cap_mod_mask: mask specifying which HT capabilities can be altered.
640 * @bands_cap: wireless bands WMAC can operate in, bitmap of &enum qlink_band. 635 * @bands_cap: wireless bands WMAC can operate in, bitmap of &enum qlink_band.
641 * @phymode_cap: PHY modes WMAC can operate in, bitmap of &enum qlink_phy_mode.
642 * @max_ap_assoc_sta: Maximum number of associations supported by WMAC. 636 * @max_ap_assoc_sta: Maximum number of associations supported by WMAC.
643 * @radar_detect_widths: bitmask of channels BW for which WMAC can detect radar. 637 * @radar_detect_widths: bitmask of channels BW for which WMAC can detect radar.
644 * @var_info: variable-length WMAC info data. 638 * @var_info: variable-length WMAC info data.
@@ -648,12 +642,12 @@ struct qlink_resp_get_mac_info {
648 u8 dev_mac[ETH_ALEN]; 642 u8 dev_mac[ETH_ALEN];
649 u8 num_tx_chain; 643 u8 num_tx_chain;
650 u8 num_rx_chain; 644 u8 num_rx_chain;
651 struct ieee80211_vht_cap vht_cap; 645 struct ieee80211_vht_cap vht_cap_mod_mask;
652 struct ieee80211_ht_cap ht_cap; 646 struct ieee80211_ht_cap ht_cap_mod_mask;
653 u8 bands_cap;
654 u8 phymode_cap;
655 __le16 max_ap_assoc_sta; 647 __le16 max_ap_assoc_sta;
656 __le16 radar_detect_widths; 648 __le16 radar_detect_widths;
649 u8 bands_cap;
650 u8 rsvd[1];
657 u8 var_info[0]; 651 u8 var_info[0];
658} __packed; 652} __packed;
659 653
@@ -730,17 +724,19 @@ struct qlink_resp_get_sta_info {
730} __packed; 724} __packed;
731 725
732/** 726/**
733 * struct qlink_resp_get_chan_info - response for QLINK_CMD_CHANS_INFO_GET cmd 727 * struct qlink_resp_band_info_get - response for QLINK_CMD_BAND_INFO_GET cmd
734 * 728 *
735 * @band: frequency band to which channels belong to, one of @enum qlink_band. 729 * @band: frequency band that the response describes, one of @enum qlink_band.
736 * @num_chans: total number of channels info data contained in reply data. 730 * @num_chans: total number of channels info TLVs contained in reply.
737 * @info: variable-length channels info. 731 * @num_bitrates: total number of bitrate TLVs contained in reply.
732 * @info: variable-length info portion.
738 */ 733 */
739struct qlink_resp_get_chan_info { 734struct qlink_resp_band_info_get {
740 struct qlink_resp rhdr; 735 struct qlink_resp rhdr;
741 u8 band; 736 u8 band;
742 u8 num_chans; 737 u8 num_chans;
743 u8 rsvd[2]; 738 u8 num_bitrates;
739 u8 rsvd[1];
744 u8 info[0]; 740 u8 info[0];
745} __packed; 741} __packed;
746 742
@@ -885,12 +881,6 @@ struct qlink_event_rxmgmt {
885 u8 frame_data[0]; 881 u8 frame_data[0];
886} __packed; 882} __packed;
887 883
888enum qlink_frame_type {
889 QLINK_BSS_FTYPE_UNKNOWN,
890 QLINK_BSS_FTYPE_BEACON,
891 QLINK_BSS_FTYPE_PRESP,
892};
893
894/** 884/**
895 * struct qlink_event_scan_result - data for QLINK_EVENT_SCAN_RESULTS event 885 * struct qlink_event_scan_result - data for QLINK_EVENT_SCAN_RESULTS event
896 * 886 *
@@ -900,7 +890,6 @@ enum qlink_frame_type {
900 * @capab: capabilities field. 890 * @capab: capabilities field.
901 * @bintval: beacon interval announced by discovered BSS. 891 * @bintval: beacon interval announced by discovered BSS.
902 * @signal: signal strength. 892 * @signal: signal strength.
903 * @frame_type: frame type used to get scan result, see &enum qlink_frame_type.
904 * @bssid: BSSID announced by discovered BSS. 893 * @bssid: BSSID announced by discovered BSS.
905 * @ssid_len: length of SSID announced by BSS. 894 * @ssid_len: length of SSID announced by BSS.
906 * @ssid: SSID announced by discovered BSS. 895 * @ssid: SSID announced by discovered BSS.
@@ -913,10 +902,10 @@ struct qlink_event_scan_result {
913 __le16 capab; 902 __le16 capab;
914 __le16 bintval; 903 __le16 bintval;
915 s8 signal; 904 s8 signal;
916 u8 frame_type;
917 u8 bssid[ETH_ALEN];
918 u8 ssid_len; 905 u8 ssid_len;
919 u8 ssid[IEEE80211_MAX_SSID_LEN]; 906 u8 ssid[IEEE80211_MAX_SSID_LEN];
907 u8 bssid[ETH_ALEN];
908 u8 rsvd[2];
920 u8 payload[0]; 909 u8 payload[0];
921} __packed; 910} __packed;
922 911
@@ -1151,6 +1140,33 @@ struct qlink_tlv_chandef {
1151 struct qlink_chandef chan; 1140 struct qlink_chandef chan;
1152} __packed; 1141} __packed;
1153 1142
1143enum qlink_ie_set_type {
1144 QLINK_IE_SET_UNKNOWN,
1145 QLINK_IE_SET_ASSOC_REQ,
1146 QLINK_IE_SET_ASSOC_RESP,
1147 QLINK_IE_SET_PROBE_REQ,
1148 QLINK_IE_SET_SCAN,
1149 QLINK_IE_SET_BEACON_HEAD,
1150 QLINK_IE_SET_BEACON_TAIL,
1151 QLINK_IE_SET_BEACON_IES,
1152 QLINK_IE_SET_PROBE_RESP,
1153 QLINK_IE_SET_PROBE_RESP_IES,
1154};
1155
1156/**
1157 * struct qlink_tlv_ie_set - data for QTN_TLV_ID_IE_SET
1158 *
1159 * @type: type of MGMT frame IEs belong to, one of &enum qlink_ie_set_type.
1160 * @flags: for future use.
1161 * @ie_data: IEs data.
1162 */
1163struct qlink_tlv_ie_set {
1164 struct qlink_tlv_hdr hdr;
1165 u8 type;
1166 u8 flags;
1167 u8 ie_data[0];
1168} __packed;
1169
1154struct qlink_chan_stats { 1170struct qlink_chan_stats {
1155 __le32 chan_num; 1171 __le32 chan_num;
1156 __le32 cca_tx; 1172 __le32 cca_tx;
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
index 51520a0e2138..f4fdad2ed319 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
@@ -164,13 +164,13 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
164 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); 164 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
165 struct sk_buff *skbcopy; 165 struct sk_buff *skbcopy;
166 struct rt2x00dump_hdr *dump_hdr; 166 struct rt2x00dump_hdr *dump_hdr;
167 struct timeval timestamp; 167 struct timespec64 timestamp;
168 u32 data_len; 168 u32 data_len;
169 169
170 if (likely(!test_bit(FRAME_DUMP_FILE_OPEN, &intf->frame_dump_flags))) 170 if (likely(!test_bit(FRAME_DUMP_FILE_OPEN, &intf->frame_dump_flags)))
171 return; 171 return;
172 172
173 do_gettimeofday(&timestamp); 173 ktime_get_ts64(&timestamp);
174 174
175 if (skb_queue_len(&intf->frame_dump_skbqueue) > 20) { 175 if (skb_queue_len(&intf->frame_dump_skbqueue) > 20) {
176 rt2x00_dbg(rt2x00dev, "txrx dump queue length exceeded\n"); 176 rt2x00_dbg(rt2x00dev, "txrx dump queue length exceeded\n");
@@ -200,7 +200,8 @@ void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
200 dump_hdr->queue_index = entry->queue->qid; 200 dump_hdr->queue_index = entry->queue->qid;
201 dump_hdr->entry_index = entry->entry_idx; 201 dump_hdr->entry_index = entry->entry_idx;
202 dump_hdr->timestamp_sec = cpu_to_le32(timestamp.tv_sec); 202 dump_hdr->timestamp_sec = cpu_to_le32(timestamp.tv_sec);
203 dump_hdr->timestamp_usec = cpu_to_le32(timestamp.tv_usec); 203 dump_hdr->timestamp_usec = cpu_to_le32(timestamp.tv_nsec /
204 NSEC_PER_USEC);
204 205
205 if (!(skbdesc->flags & SKBDESC_DESC_IN_SKB)) 206 if (!(skbdesc->flags & SKBDESC_DESC_IN_SKB))
206 skb_put_data(skbcopy, skbdesc->desc, skbdesc->desc_len); 207 skb_put_data(skbcopy, skbdesc->desc, skbdesc->desc_len);
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00dump.h b/drivers/net/wireless/ralink/rt2x00/rt2x00dump.h
index 4c0e01b5d515..3b14eef0b646 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00dump.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dump.h
@@ -106,7 +106,7 @@ enum rt2x00_dump_type {
106 */ 106 */
107struct rt2x00dump_hdr { 107struct rt2x00dump_hdr {
108 __le32 version; 108 __le32 version;
109#define DUMP_HEADER_VERSION 2 109#define DUMP_HEADER_VERSION 3
110 110
111 __le32 header_length; 111 __le32 header_length;
112 __le32 desc_length; 112 __le32 desc_length;
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
index e2f4f5778267..086aad22743d 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
@@ -57,7 +57,7 @@ int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev,
57 if (status >= 0) 57 if (status >= 0)
58 return 0; 58 return 0;
59 59
60 if (status == -ENODEV) { 60 if (status == -ENODEV || status == -ENOENT) {
61 /* Device has disappeared. */ 61 /* Device has disappeared. */
62 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); 62 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
63 break; 63 break;
@@ -321,7 +321,7 @@ static bool rt2x00usb_kick_tx_entry(struct queue_entry *entry, void *data)
321 321
322 status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC); 322 status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
323 if (status) { 323 if (status) {
324 if (status == -ENODEV) 324 if (status == -ENODEV || status == -ENOENT)
325 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); 325 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
326 set_bit(ENTRY_DATA_IO_FAILED, &entry->flags); 326 set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
327 rt2x00lib_dmadone(entry); 327 rt2x00lib_dmadone(entry);
@@ -410,7 +410,7 @@ static bool rt2x00usb_kick_rx_entry(struct queue_entry *entry, void *data)
410 410
411 status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC); 411 status = usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
412 if (status) { 412 if (status) {
413 if (status == -ENODEV) 413 if (status == -ENODEV || status == -ENOENT)
414 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); 414 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
415 set_bit(ENTRY_DATA_IO_FAILED, &entry->flags); 415 set_bit(ENTRY_DATA_IO_FAILED, &entry->flags);
416 rt2x00lib_dmadone(entry); 416 rt2x00lib_dmadone(entry);
diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
index 7e3107f9e37f..cad2272ae21b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -1630,7 +1630,6 @@ int rtl_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1630 struct ieee80211_sta *sta, u16 tid) 1630 struct ieee80211_sta *sta, u16 tid)
1631{ 1631{
1632 struct rtl_priv *rtlpriv = rtl_priv(hw); 1632 struct rtl_priv *rtlpriv = rtl_priv(hw);
1633 struct rtl_tid_data *tid_data;
1634 struct rtl_sta_info *sta_entry = NULL; 1633 struct rtl_sta_info *sta_entry = NULL;
1635 1634
1636 if (sta == NULL) 1635 if (sta == NULL)
@@ -1643,7 +1642,6 @@ int rtl_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1643 return -EINVAL; 1642 return -EINVAL;
1644 1643
1645 sta_entry = (struct rtl_sta_info *)sta->drv_priv; 1644 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1646 tid_data = &sta_entry->tids[tid];
1647 sta_entry->tids[tid].agg.agg_state = RTL_AGG_STOP; 1645 sta_entry->tids[tid].agg.agg_state = RTL_AGG_STOP;
1648 1646
1649 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); 1647 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c
index 1147327e6f52..3cb88825473e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -550,15 +550,13 @@ static int rtl_op_suspend(struct ieee80211_hw *hw,
550 struct rtl_priv *rtlpriv = rtl_priv(hw); 550 struct rtl_priv *rtlpriv = rtl_priv(hw);
551 struct rtl_hal *rtlhal = rtl_hal(rtlpriv); 551 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
552 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 552 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
553 struct timeval ts;
554 553
555 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n"); 554 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
556 if (WARN_ON(!wow)) 555 if (WARN_ON(!wow))
557 return -EINVAL; 556 return -EINVAL;
558 557
559 /* to resolve s4 can not wake up*/ 558 /* to resolve s4 can not wake up*/
560 do_gettimeofday(&ts); 559 rtlhal->last_suspend_sec = ktime_get_real_seconds();
561 rtlhal->last_suspend_sec = ts.tv_sec;
562 560
563 if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns) 561 if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns)
564 _rtl_add_wowlan_patterns(hw, wow); 562 _rtl_add_wowlan_patterns(hw, wow);
@@ -577,7 +575,7 @@ static int rtl_op_resume(struct ieee80211_hw *hw)
577 struct rtl_priv *rtlpriv = rtl_priv(hw); 575 struct rtl_priv *rtlpriv = rtl_priv(hw);
578 struct rtl_hal *rtlhal = rtl_hal(rtlpriv); 576 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
579 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 577 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
580 struct timeval ts; 578 time64_t now;
581 579
582 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n"); 580 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
583 rtlhal->driver_is_goingto_unload = false; 581 rtlhal->driver_is_goingto_unload = false;
@@ -585,8 +583,8 @@ static int rtl_op_resume(struct ieee80211_hw *hw)
585 rtlhal->wake_from_pnp_sleep = true; 583 rtlhal->wake_from_pnp_sleep = true;
586 584
587 /* to resovle s4 can not wake up*/ 585 /* to resovle s4 can not wake up*/
588 do_gettimeofday(&ts); 586 now = ktime_get_real_seconds();
589 if (ts.tv_sec - rtlhal->last_suspend_sec < 5) 587 if (now - rtlhal->last_suspend_sec < 5)
590 return -1; 588 return -1;
591 589
592 rtl_op_start(hw); 590 rtl_op_start(hw);
@@ -1748,7 +1746,7 @@ bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version,
1748 u8 faversion, u8 interface_type, 1746 u8 faversion, u8 interface_type,
1749 struct wlan_pwr_cfg pwrcfgcmd[]) 1747 struct wlan_pwr_cfg pwrcfgcmd[])
1750{ 1748{
1751 struct wlan_pwr_cfg cfg_cmd = {0}; 1749 struct wlan_pwr_cfg cfg_cmd;
1752 bool polling_bit = false; 1750 bool polling_bit = false;
1753 u32 ary_idx = 0; 1751 u32 ary_idx = 0;
1754 u8 value = 0; 1752 u8 value = 0;
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
index eb12818b46b3..c2575b0b9440 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -54,8 +54,7 @@ static const u8 ac_to_hwq[] = {
54 BK_QUEUE 54 BK_QUEUE
55}; 55};
56 56
57static u8 _rtl_mac_to_hwqueue(struct ieee80211_hw *hw, 57static u8 _rtl_mac_to_hwqueue(struct ieee80211_hw *hw, struct sk_buff *skb)
58 struct sk_buff *skb)
59{ 58{
60 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 59 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
61 __le16 fc = rtl_get_fc(skb); 60 __le16 fc = rtl_get_fc(skb);
@@ -104,20 +103,18 @@ static void _rtl_pci_update_default_setting(struct ieee80211_hw *hw)
104 break; 103 break;
105 104
106 case 3: 105 case 3:
107 /* 106 /* Always enable ASPM and Clock Req
108 * Always enable ASPM and Clock Req
109 * from initialization to halt. 107 * from initialization to halt.
110 * */ 108 */
111 ppsc->reg_rfps_level &= ~(RT_RF_LPS_LEVEL_ASPM); 109 ppsc->reg_rfps_level &= ~(RT_RF_LPS_LEVEL_ASPM);
112 ppsc->reg_rfps_level |= (RT_RF_PS_LEVEL_ALWAYS_ASPM | 110 ppsc->reg_rfps_level |= (RT_RF_PS_LEVEL_ALWAYS_ASPM |
113 RT_RF_OFF_LEVL_CLK_REQ); 111 RT_RF_OFF_LEVL_CLK_REQ);
114 break; 112 break;
115 113
116 case 4: 114 case 4:
117 /* 115 /* Always enable ASPM without Clock Req
118 * Always enable ASPM without Clock Req
119 * from initialization to halt. 116 * from initialization to halt.
120 * */ 117 */
121 ppsc->reg_rfps_level &= ~(RT_RF_LPS_LEVEL_ASPM | 118 ppsc->reg_rfps_level &= ~(RT_RF_LPS_LEVEL_ASPM |
122 RT_RF_OFF_LEVL_CLK_REQ); 119 RT_RF_OFF_LEVL_CLK_REQ);
123 ppsc->reg_rfps_level |= RT_RF_PS_LEVEL_ALWAYS_ASPM; 120 ppsc->reg_rfps_level |= RT_RF_PS_LEVEL_ALWAYS_ASPM;
@@ -146,32 +143,19 @@ static void _rtl_pci_update_default_setting(struct ieee80211_hw *hw)
146 143
147 /*Set HW definition to determine if it supports ASPM. */ 144 /*Set HW definition to determine if it supports ASPM. */
148 switch (rtlpci->const_support_pciaspm) { 145 switch (rtlpci->const_support_pciaspm) {
149 case 0:{ 146 case 0:
150 /*Not support ASPM. */ 147 /*Not support ASPM. */
151 bool support_aspm = false; 148 ppsc->support_aspm = false;
152 ppsc->support_aspm = support_aspm; 149 break;
153 break; 150 case 1:
154 } 151 /*Support ASPM. */
155 case 1:{ 152 ppsc->support_aspm = true;
156 /*Support ASPM. */ 153 ppsc->support_backdoor = true;
157 bool support_aspm = true; 154 break;
158 bool support_backdoor = true;
159 ppsc->support_aspm = support_aspm;
160
161 /*if (priv->oem_id == RT_CID_TOSHIBA &&
162 !priv->ndis_adapter.amd_l1_patch)
163 support_backdoor = false; */
164
165 ppsc->support_backdoor = support_backdoor;
166
167 break;
168 }
169 case 2: 155 case 2:
170 /*ASPM value set by chipset. */ 156 /*ASPM value set by chipset. */
171 if (pcibridge_vendor == PCI_BRIDGE_VENDOR_INTEL) { 157 if (pcibridge_vendor == PCI_BRIDGE_VENDOR_INTEL)
172 bool support_aspm = true; 158 ppsc->support_aspm = true;
173 ppsc->support_aspm = support_aspm;
174 }
175 break; 159 break;
176 default: 160 default:
177 pr_err("switch case %#x not processed\n", 161 pr_err("switch case %#x not processed\n",
@@ -180,10 +164,11 @@ static void _rtl_pci_update_default_setting(struct ieee80211_hw *hw)
180 } 164 }
181 165
182 /* toshiba aspm issue, toshiba will set aspm selfly 166 /* toshiba aspm issue, toshiba will set aspm selfly
183 * so we should not set aspm in driver */ 167 * so we should not set aspm in driver
168 */
184 pci_read_config_byte(rtlpci->pdev, 0x80, &init_aspm); 169 pci_read_config_byte(rtlpci->pdev, 0x80, &init_aspm);
185 if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8192SE && 170 if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8192SE &&
186 init_aspm == 0x43) 171 init_aspm == 0x43)
187 ppsc->support_aspm = false; 172 ppsc->support_aspm = false;
188} 173}
189 174
@@ -263,8 +248,7 @@ static void rtl_pci_disable_aspm(struct ieee80211_hw *hw)
263 udelay(50); 248 udelay(50);
264} 249}
265 250
266/* 251/*Enable RTL8192SE ASPM & Enable Pci Bridge ASPM for
267 *Enable RTL8192SE ASPM & Enable Pci Bridge ASPM for
268 *power saving We should follow the sequence to enable 252 *power saving We should follow the sequence to enable
269 *RTL8192SE first then enable Pci Bridge ASPM 253 *RTL8192SE first then enable Pci Bridge ASPM
270 *or the system will show bluescreen. 254 *or the system will show bluescreen.
@@ -334,7 +318,7 @@ static bool rtl_pci_get_amd_l1_patch(struct ieee80211_hw *hw)
334 318
335 bool status = false; 319 bool status = false;
336 u8 offset_e0; 320 u8 offset_e0;
337 unsigned offset_e4; 321 unsigned int offset_e4;
338 322
339 pci_write_config_byte(rtlpci->pdev, 0xe0, 0xa0); 323 pci_write_config_byte(rtlpci->pdev, 0xe0, 0xa0);
340 324
@@ -369,12 +353,12 @@ static bool rtl_pci_check_buddy_priv(struct ieee80211_hw *hw,
369 "tpcipriv->ndis_adapter.funcnumber %x\n", 353 "tpcipriv->ndis_adapter.funcnumber %x\n",
370 tpcipriv->ndis_adapter.funcnumber); 354 tpcipriv->ndis_adapter.funcnumber);
371 355
372 if ((pcipriv->ndis_adapter.busnumber == 356 if (pcipriv->ndis_adapter.busnumber ==
373 tpcipriv->ndis_adapter.busnumber) && 357 tpcipriv->ndis_adapter.busnumber &&
374 (pcipriv->ndis_adapter.devnumber == 358 pcipriv->ndis_adapter.devnumber ==
375 tpcipriv->ndis_adapter.devnumber) && 359 tpcipriv->ndis_adapter.devnumber &&
376 (pcipriv->ndis_adapter.funcnumber != 360 pcipriv->ndis_adapter.funcnumber !=
377 tpcipriv->ndis_adapter.funcnumber)) { 361 tpcipriv->ndis_adapter.funcnumber) {
378 find_buddy_priv = true; 362 find_buddy_priv = true;
379 break; 363 break;
380 } 364 }
@@ -407,7 +391,7 @@ static void rtl_pci_get_linkcontrol_field(struct ieee80211_hw *hw)
407} 391}
408 392
409static void rtl_pci_parse_configuration(struct pci_dev *pdev, 393static void rtl_pci_parse_configuration(struct pci_dev *pdev,
410 struct ieee80211_hw *hw) 394 struct ieee80211_hw *hw)
411{ 395{
412 struct rtl_priv *rtlpriv = rtl_priv(hw); 396 struct rtl_priv *rtlpriv = rtl_priv(hw);
413 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); 397 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
@@ -441,7 +425,6 @@ static void rtl_pci_init_aspm(struct ieee80211_hw *hw)
441 rtl_pci_enable_aspm(hw); 425 rtl_pci_enable_aspm(hw);
442 RT_SET_PS_LEVEL(ppsc, RT_RF_PS_LEVEL_ALWAYS_ASPM); 426 RT_SET_PS_LEVEL(ppsc, RT_RF_PS_LEVEL_ALWAYS_ASPM);
443 } 427 }
444
445} 428}
446 429
447static void _rtl_pci_io_handler_init(struct device *dev, 430static void _rtl_pci_io_handler_init(struct device *dev,
@@ -458,11 +441,11 @@ static void _rtl_pci_io_handler_init(struct device *dev,
458 rtlpriv->io.read8_sync = pci_read8_sync; 441 rtlpriv->io.read8_sync = pci_read8_sync;
459 rtlpriv->io.read16_sync = pci_read16_sync; 442 rtlpriv->io.read16_sync = pci_read16_sync;
460 rtlpriv->io.read32_sync = pci_read32_sync; 443 rtlpriv->io.read32_sync = pci_read32_sync;
461
462} 444}
463 445
464static bool _rtl_update_earlymode_info(struct ieee80211_hw *hw, 446static bool _rtl_update_earlymode_info(struct ieee80211_hw *hw,
465 struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc, u8 tid) 447 struct sk_buff *skb,
448 struct rtl_tcb_desc *tcb_desc, u8 tid)
466{ 449{
467 struct rtl_priv *rtlpriv = rtl_priv(hw); 450 struct rtl_priv *rtlpriv = rtl_priv(hw);
468 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 451 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -520,13 +503,15 @@ static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw)
520 (rtlpriv->buddy_priv && 503 (rtlpriv->buddy_priv &&
521 rtlpriv->buddy_priv->easy_concurrent_ctl.switch_in_process))) 504 rtlpriv->buddy_priv->easy_concurrent_ctl.switch_in_process)))
522 return; 505 return;
523 /* we juse use em for BE/BK/VI/VO */ 506 /* we just use em for BE/BK/VI/VO */
524 for (tid = 7; tid >= 0; tid--) { 507 for (tid = 7; tid >= 0; tid--) {
525 u8 hw_queue = ac_to_hwq[rtl_tid_to_ac(tid)]; 508 u8 hw_queue = ac_to_hwq[rtl_tid_to_ac(tid)];
526 struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue]; 509 struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
510
527 while (!mac->act_scanning && 511 while (!mac->act_scanning &&
528 rtlpriv->psc.rfpwr_state == ERFON) { 512 rtlpriv->psc.rfpwr_state == ERFON) {
529 struct rtl_tcb_desc tcb_desc; 513 struct rtl_tcb_desc tcb_desc;
514
530 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); 515 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
531 516
532 spin_lock_bh(&rtlpriv->locks.waitq_lock); 517 spin_lock_bh(&rtlpriv->locks.waitq_lock);
@@ -541,7 +526,8 @@ static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw)
541 spin_unlock_bh(&rtlpriv->locks.waitq_lock); 526 spin_unlock_bh(&rtlpriv->locks.waitq_lock);
542 527
543 /* Some macaddr can't do early mode. like 528 /* Some macaddr can't do early mode. like
544 * multicast/broadcast/no_qos data */ 529 * multicast/broadcast/no_qos data
530 */
545 info = IEEE80211_SKB_CB(skb); 531 info = IEEE80211_SKB_CB(skb);
546 if (info->flags & IEEE80211_TX_CTL_AMPDU) 532 if (info->flags & IEEE80211_TX_CTL_AMPDU)
547 _rtl_update_earlymode_info(hw, skb, 533 _rtl_update_earlymode_info(hw, skb,
@@ -552,7 +538,6 @@ static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw)
552 } 538 }
553} 539}
554 540
555
556static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio) 541static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio)
557{ 542{
558 struct rtl_priv *rtlpriv = rtl_priv(hw); 543 struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -603,7 +588,6 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio)
603 if (prio == TXCMD_QUEUE) { 588 if (prio == TXCMD_QUEUE) {
604 dev_kfree_skb(skb); 589 dev_kfree_skb(skb);
605 goto tx_status_ok; 590 goto tx_status_ok;
606
607 } 591 }
608 592
609 /* for sw LPS, just after NULL skb send out, we can 593 /* for sw LPS, just after NULL skb send out, we can
@@ -643,15 +627,12 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio)
643 ieee80211_tx_status_irqsafe(hw, skb); 627 ieee80211_tx_status_irqsafe(hw, skb);
644 628
645 if ((ring->entries - skb_queue_len(&ring->queue)) <= 4) { 629 if ((ring->entries - skb_queue_len(&ring->queue)) <= 4) {
646
647 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG, 630 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
648 "more desc left, wake skb_queue@%d, ring->idx = %d, skb_queue_len = 0x%x\n", 631 "more desc left, wake skb_queue@%d, ring->idx = %d, skb_queue_len = 0x%x\n",
649 prio, ring->idx, 632 prio, ring->idx,
650 skb_queue_len(&ring->queue)); 633 skb_queue_len(&ring->queue));
651 634
652 ieee80211_wake_queue(hw, 635 ieee80211_wake_queue(hw, skb_get_queue_mapping(skb));
653 skb_get_queue_mapping
654 (skb));
655 } 636 }
656tx_status_ok: 637tx_status_ok:
657 skb = NULL; 638 skb = NULL;
@@ -659,7 +640,7 @@ tx_status_ok:
659 640
660 if (((rtlpriv->link_info.num_rx_inperiod + 641 if (((rtlpriv->link_info.num_rx_inperiod +
661 rtlpriv->link_info.num_tx_inperiod) > 8) || 642 rtlpriv->link_info.num_tx_inperiod) > 8) ||
662 (rtlpriv->link_info.num_rx_inperiod > 2)) 643 rtlpriv->link_info.num_rx_inperiod > 2)
663 rtl_lps_leave(hw); 644 rtl_lps_leave(hw);
664} 645}
665 646
@@ -817,7 +798,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
817 new_skb = dev_alloc_skb(rtlpci->rxbuffersize); 798 new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
818 if (unlikely(!new_skb)) 799 if (unlikely(!new_skb))
819 goto no_new; 800 goto no_new;
820 memset(&rx_status , 0 , sizeof(rx_status)); 801 memset(&rx_status, 0, sizeof(rx_status));
821 rtlpriv->cfg->ops->query_rx_desc(hw, &stats, 802 rtlpriv->cfg->ops->query_rx_desc(hw, &stats,
822 &rx_status, (u8 *)pdesc, skb); 803 &rx_status, (u8 *)pdesc, skb);
823 804
@@ -847,12 +828,11 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
847 /* handle command packet here */ 828 /* handle command packet here */
848 if (rtlpriv->cfg->ops->rx_command_packet && 829 if (rtlpriv->cfg->ops->rx_command_packet &&
849 rtlpriv->cfg->ops->rx_command_packet(hw, &stats, skb)) { 830 rtlpriv->cfg->ops->rx_command_packet(hw, &stats, skb)) {
850 dev_kfree_skb_any(skb); 831 dev_kfree_skb_any(skb);
851 goto new_trx_end; 832 goto new_trx_end;
852 } 833 }
853 834
854 /* 835 /* NOTICE This can not be use for mac80211,
855 * NOTICE This can not be use for mac80211,
856 * this is done in mac80211 code, 836 * this is done in mac80211 code,
857 * if done here sec DHCP will fail 837 * if done here sec DHCP will fail
858 * skb_trim(skb, skb->len - 4); 838 * skb_trim(skb, skb->len - 4);
@@ -889,9 +869,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
889 /* for sw lps */ 869 /* for sw lps */
890 rtl_swlps_beacon(hw, (void *)skb->data, skb->len); 870 rtl_swlps_beacon(hw, (void *)skb->data, skb->len);
891 rtl_recognize_peer(hw, (void *)skb->data, skb->len); 871 rtl_recognize_peer(hw, (void *)skb->data, skb->len);
892 if ((rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP) && 872 if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP &&
893 (rtlpriv->rtlhal.current_bandtype == 873 rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G &&
894 BAND_ON_2_4G) &&
895 (ieee80211_is_beacon(fc) || 874 (ieee80211_is_beacon(fc) ||
896 ieee80211_is_probe_resp(fc))) { 875 ieee80211_is_probe_resp(fc))) {
897 dev_kfree_skb_any(skb); 876 dev_kfree_skb_any(skb);
@@ -913,7 +892,7 @@ new_trx_end:
913 } 892 }
914 if (((rtlpriv->link_info.num_rx_inperiod + 893 if (((rtlpriv->link_info.num_rx_inperiod +
915 rtlpriv->link_info.num_tx_inperiod) > 8) || 894 rtlpriv->link_info.num_tx_inperiod) > 8) ||
916 (rtlpriv->link_info.num_rx_inperiod > 2)) 895 rtlpriv->link_info.num_rx_inperiod > 2)
917 rtl_lps_leave(hw); 896 rtl_lps_leave(hw);
918 skb = new_skb; 897 skb = new_skb;
919no_new: 898no_new:
@@ -947,35 +926,34 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id)
947 unsigned long flags; 926 unsigned long flags;
948 u32 inta = 0; 927 u32 inta = 0;
949 u32 intb = 0; 928 u32 intb = 0;
929 u32 intc = 0;
930 u32 intd = 0;
950 irqreturn_t ret = IRQ_HANDLED; 931 irqreturn_t ret = IRQ_HANDLED;
951 932
952 if (rtlpci->irq_enabled == 0) 933 if (rtlpci->irq_enabled == 0)
953 return ret; 934 return ret;
954 935
955 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock , flags); 936 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
956 rtlpriv->cfg->ops->disable_interrupt(hw); 937 rtlpriv->cfg->ops->disable_interrupt(hw);
957 938
958 /*read ISR: 4/8bytes */ 939 /*read ISR: 4/8bytes */
959 rtlpriv->cfg->ops->interrupt_recognized(hw, &inta, &intb); 940 rtlpriv->cfg->ops->interrupt_recognized(hw, &inta, &intb, &intc, &intd);
960 941
961 /*Shared IRQ or HW disappared */ 942 /*Shared IRQ or HW disappeared */
962 if (!inta || inta == 0xffff) 943 if (!inta || inta == 0xffff)
963 goto done; 944 goto done;
964 945
965 /*<1> beacon related */ 946 /*<1> beacon related */
966 if (inta & rtlpriv->cfg->maps[RTL_IMR_TBDOK]) { 947 if (inta & rtlpriv->cfg->maps[RTL_IMR_TBDOK])
967 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 948 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
968 "beacon ok interrupt!\n"); 949 "beacon ok interrupt!\n");
969 }
970 950
971 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_TBDER])) { 951 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_TBDER]))
972 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 952 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
973 "beacon err interrupt!\n"); 953 "beacon err interrupt!\n");
974 }
975 954
976 if (inta & rtlpriv->cfg->maps[RTL_IMR_BDOK]) { 955 if (inta & rtlpriv->cfg->maps[RTL_IMR_BDOK])
977 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, "beacon interrupt!\n"); 956 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, "beacon interrupt!\n");
978 }
979 957
980 if (inta & rtlpriv->cfg->maps[RTL_IMR_BCNINT]) { 958 if (inta & rtlpriv->cfg->maps[RTL_IMR_BCNINT]) {
981 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 959 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
@@ -1031,6 +1009,16 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id)
1031 _rtl_pci_tx_isr(hw, VO_QUEUE); 1009 _rtl_pci_tx_isr(hw, VO_QUEUE);
1032 } 1010 }
1033 1011
1012 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8822BE) {
1013 if (intd & rtlpriv->cfg->maps[RTL_IMR_H2CDOK]) {
1014 rtlpriv->link_info.num_tx_inperiod++;
1015
1016 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
1017 "H2C TX OK interrupt!\n");
1018 _rtl_pci_tx_isr(hw, H2C_QUEUE);
1019 }
1020 }
1021
1034 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) { 1022 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) {
1035 if (inta & rtlpriv->cfg->maps[RTL_IMR_COMDOK]) { 1023 if (inta & rtlpriv->cfg->maps[RTL_IMR_COMDOK]) {
1036 rtlpriv->link_info.num_tx_inperiod++; 1024 rtlpriv->link_info.num_tx_inperiod++;
@@ -1130,7 +1118,7 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
1130 1118
1131 /*NB: the beacon data buffer must be 32-bit aligned. */ 1119 /*NB: the beacon data buffer must be 32-bit aligned. */
1132 pskb = ieee80211_beacon_get(hw, mac->vif); 1120 pskb = ieee80211_beacon_get(hw, mac->vif);
1133 if (pskb == NULL) 1121 if (!pskb)
1134 return; 1122 return;
1135 hdr = rtl_get_hdr(pskb); 1123 hdr = rtl_get_hdr(pskb);
1136 info = IEEE80211_SKB_CB(pskb); 1124 info = IEEE80211_SKB_CB(pskb);
@@ -1152,7 +1140,6 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
1152 rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN, 1140 rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN,
1153 &temp_one); 1141 &temp_one);
1154 } 1142 }
1155 return;
1156} 1143}
1157 1144
1158static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw) 1145static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw)
@@ -1165,14 +1152,15 @@ static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw)
1165 1152
1166 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) 1153 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE)
1167 desc_num = TX_DESC_NUM_92E; 1154 desc_num = TX_DESC_NUM_92E;
1155 else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8822BE)
1156 desc_num = TX_DESC_NUM_8822B;
1168 else 1157 else
1169 desc_num = RT_TXDESC_NUM; 1158 desc_num = RT_TXDESC_NUM;
1170 1159
1171 for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) 1160 for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++)
1172 rtlpci->txringcount[i] = desc_num; 1161 rtlpci->txringcount[i] = desc_num;
1173 1162
1174 /* 1163 /*we just alloc 2 desc for beacon queue,
1175 *we just alloc 2 desc for beacon queue,
1176 *because we just need first desc in hw beacon. 1164 *because we just need first desc in hw beacon.
1177 */ 1165 */
1178 rtlpci->txringcount[BEACON_QUEUE] = 2; 1166 rtlpci->txringcount[BEACON_QUEUE] = 2;
@@ -1189,7 +1177,7 @@ static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw)
1189} 1177}
1190 1178
1191static void _rtl_pci_init_struct(struct ieee80211_hw *hw, 1179static void _rtl_pci_init_struct(struct ieee80211_hw *hw,
1192 struct pci_dev *pdev) 1180 struct pci_dev *pdev)
1193{ 1181{
1194 struct rtl_priv *rtlpriv = rtl_priv(hw); 1182 struct rtl_priv *rtlpriv = rtl_priv(hw);
1195 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1183 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
@@ -1361,7 +1349,7 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw, int rxring_idx)
1361} 1349}
1362 1350
1363static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw, 1351static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw,
1364 unsigned int prio) 1352 unsigned int prio)
1365{ 1353{
1366 struct rtl_priv *rtlpriv = rtl_priv(hw); 1354 struct rtl_priv *rtlpriv = rtl_priv(hw);
1367 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1355 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
@@ -1378,8 +1366,7 @@ static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw,
1378 entry = (u8 *)(&ring->desc[ring->idx]); 1366 entry = (u8 *)(&ring->desc[ring->idx]);
1379 1367
1380 pci_unmap_single(rtlpci->pdev, 1368 pci_unmap_single(rtlpci->pdev,
1381 rtlpriv->cfg-> 1369 rtlpriv->cfg->ops->get_desc(hw, (u8 *)entry,
1382 ops->get_desc(hw, (u8 *)entry,
1383 true, 1370 true,
1384 HW_DESC_TXBUFF_ADDR), 1371 HW_DESC_TXBUFF_ADDR),
1385 skb->len, PCI_DMA_TODEVICE); 1372 skb->len, PCI_DMA_TODEVICE);
@@ -1451,8 +1438,7 @@ static int _rtl_pci_init_trx_ring(struct ieee80211_hw *hw)
1451 } 1438 }
1452 1439
1453 for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) { 1440 for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) {
1454 ret = _rtl_pci_init_tx_ring(hw, i, 1441 ret = _rtl_pci_init_tx_ring(hw, i, rtlpci->txringcount[i]);
1455 rtlpci->txringcount[i]);
1456 if (ret) 1442 if (ret)
1457 goto err_free_rings; 1443 goto err_free_rings;
1458 } 1444 }
@@ -1500,7 +1486,7 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
1500 /* force the rx_ring[RX_MPDU_QUEUE/ 1486 /* force the rx_ring[RX_MPDU_QUEUE/
1501 * RX_CMD_QUEUE].idx to the first one 1487 * RX_CMD_QUEUE].idx to the first one
1502 *new trx flow, do nothing 1488 *new trx flow, do nothing
1503 */ 1489 */
1504 if (!rtlpriv->use_new_trx_flow && 1490 if (!rtlpriv->use_new_trx_flow &&
1505 rtlpci->rx_ring[rxring_idx].desc) { 1491 rtlpci->rx_ring[rxring_idx].desc) {
1506 struct rtl_rx_desc *entry = NULL; 1492 struct rtl_rx_desc *entry = NULL;
@@ -1510,8 +1496,8 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
1510 entry = &rtlpci->rx_ring[rxring_idx].desc[i]; 1496 entry = &rtlpci->rx_ring[rxring_idx].desc[i];
1511 bufferaddress = 1497 bufferaddress =
1512 rtlpriv->cfg->ops->get_desc(hw, (u8 *)entry, 1498 rtlpriv->cfg->ops->get_desc(hw, (u8 *)entry,
1513 false , HW_DESC_RXBUFF_ADDR); 1499 false, HW_DESC_RXBUFF_ADDR);
1514 memset((u8 *)entry , 0 , 1500 memset((u8 *)entry, 0,
1515 sizeof(*rtlpci->rx_ring 1501 sizeof(*rtlpci->rx_ring
1516 [rxring_idx].desc));/*clear one entry*/ 1502 [rxring_idx].desc));/*clear one entry*/
1517 if (rtlpriv->use_new_trx_flow) { 1503 if (rtlpriv->use_new_trx_flow) {
@@ -1540,8 +1526,7 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
1540 rtlpci->rx_ring[rxring_idx].idx = 0; 1526 rtlpci->rx_ring[rxring_idx].idx = 0;
1541 } 1527 }
1542 1528
1543 /* 1529 /*after reset, release previous pending packet,
1544 *after reset, release previous pending packet,
1545 *and force the tx idx to the first one 1530 *and force the tx idx to the first one
1546 */ 1531 */
1547 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); 1532 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
@@ -1642,7 +1627,7 @@ static int rtl_pci_tx(struct ieee80211_hw *hw,
1642 1627
1643 if (rtlpriv->psc.sw_ps_enabled) { 1628 if (rtlpriv->psc.sw_ps_enabled) {
1644 if (ieee80211_is_data(fc) && !ieee80211_is_nullfunc(fc) && 1629 if (ieee80211_is_data(fc) && !ieee80211_is_nullfunc(fc) &&
1645 !ieee80211_has_pm(fc)) 1630 !ieee80211_has_pm(fc))
1646 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); 1631 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
1647 } 1632 }
1648 1633
@@ -1674,7 +1659,7 @@ static int rtl_pci_tx(struct ieee80211_hw *hw,
1674 own = (u8)rtlpriv->cfg->ops->get_desc(hw, (u8 *)pdesc, 1659 own = (u8)rtlpriv->cfg->ops->get_desc(hw, (u8 *)pdesc,
1675 true, HW_DESC_OWN); 1660 true, HW_DESC_OWN);
1676 1661
1677 if ((own == 1) && (hw_queue != BEACON_QUEUE)) { 1662 if (own == 1 && hw_queue != BEACON_QUEUE) {
1678 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1663 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1679 "No more TX desc@%d, ring->idx = %d, idx = %d, skb_queue_len = 0x%x\n", 1664 "No more TX desc@%d, ring->idx = %d, idx = %d, skb_queue_len = 0x%x\n",
1680 hw_queue, ring->idx, idx, 1665 hw_queue, ring->idx, idx,
@@ -1688,11 +1673,10 @@ static int rtl_pci_tx(struct ieee80211_hw *hw,
1688 1673
1689 if (rtlpriv->cfg->ops->get_available_desc && 1674 if (rtlpriv->cfg->ops->get_available_desc &&
1690 rtlpriv->cfg->ops->get_available_desc(hw, hw_queue) == 0) { 1675 rtlpriv->cfg->ops->get_available_desc(hw, hw_queue) == 0) {
1691 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1676 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1692 "get_available_desc fail\n"); 1677 "get_available_desc fail\n");
1693 spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, 1678 spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags);
1694 flags); 1679 return skb->len;
1695 return skb->len;
1696 } 1680 }
1697 1681
1698 if (ieee80211_is_data(fc)) 1682 if (ieee80211_is_data(fc))
@@ -1751,7 +1735,7 @@ static void rtl_pci_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
1751 ring = &pcipriv->dev.tx_ring[queue_id]; 1735 ring = &pcipriv->dev.tx_ring[queue_id];
1752 queue_len = skb_queue_len(&ring->queue); 1736 queue_len = skb_queue_len(&ring->queue);
1753 if (queue_len == 0 || queue_id == BEACON_QUEUE || 1737 if (queue_len == 0 || queue_id == BEACON_QUEUE ||
1754 queue_id == TXCMD_QUEUE) { 1738 queue_id == TXCMD_QUEUE) {
1755 queue_id--; 1739 queue_id--;
1756 continue; 1740 continue;
1757 } else { 1741 } else {
@@ -1761,7 +1745,7 @@ static void rtl_pci_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
1761 1745
1762 /* we just wait 1s for all queues */ 1746 /* we just wait 1s for all queues */
1763 if (rtlpriv->psc.rfpwr_state == ERFOFF || 1747 if (rtlpriv->psc.rfpwr_state == ERFOFF ||
1764 is_hal_stop(rtlhal) || i >= 200) 1748 is_hal_stop(rtlhal) || i >= 200)
1765 return; 1749 return;
1766 } 1750 }
1767} 1751}
@@ -1779,7 +1763,6 @@ static void rtl_pci_deinit(struct ieee80211_hw *hw)
1779 1763
1780 flush_workqueue(rtlpriv->works.rtl_wq); 1764 flush_workqueue(rtlpriv->works.rtl_wq);
1781 destroy_workqueue(rtlpriv->works.rtl_wq); 1765 destroy_workqueue(rtlpriv->works.rtl_wq);
1782
1783} 1766}
1784 1767
1785static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev) 1768static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev)
@@ -1837,7 +1820,7 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
1837 1820
1838 rtlpci->up_first_time = false; 1821 rtlpci->up_first_time = false;
1839 1822
1840 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "rtl_pci_start OK\n"); 1823 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%s OK\n", __func__);
1841 return 0; 1824 return 0;
1842} 1825}
1843 1826
@@ -1848,13 +1831,12 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
1848 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 1831 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
1849 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1832 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1850 unsigned long flags; 1833 unsigned long flags;
1851 u8 RFInProgressTimeOut = 0; 1834 u8 rf_timeout = 0;
1852 1835
1853 if (rtlpriv->cfg->ops->get_btc_status()) 1836 if (rtlpriv->cfg->ops->get_btc_status())
1854 rtlpriv->btcoexist.btc_ops->btc_halt_notify(); 1837 rtlpriv->btcoexist.btc_ops->btc_halt_notify();
1855 1838
1856 /* 1839 /*should be before disable interrupt&adapter
1857 *should be before disable interrupt&adapter
1858 *and will do it immediately. 1840 *and will do it immediately.
1859 */ 1841 */
1860 set_hal_stop(rtlhal); 1842 set_hal_stop(rtlhal);
@@ -1866,12 +1848,12 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
1866 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags); 1848 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags);
1867 while (ppsc->rfchange_inprogress) { 1849 while (ppsc->rfchange_inprogress) {
1868 spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flags); 1850 spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flags);
1869 if (RFInProgressTimeOut > 100) { 1851 if (rf_timeout > 100) {
1870 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags); 1852 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags);
1871 break; 1853 break;
1872 } 1854 }
1873 mdelay(1); 1855 mdelay(1);
1874 RFInProgressTimeOut++; 1856 rf_timeout++;
1875 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags); 1857 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags);
1876 } 1858 }
1877 ppsc->rfchange_inprogress = true; 1859 ppsc->rfchange_inprogress = true;
@@ -1891,7 +1873,7 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
1891} 1873}
1892 1874
1893static bool _rtl_pci_find_adapter(struct pci_dev *pdev, 1875static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
1894 struct ieee80211_hw *hw) 1876 struct ieee80211_hw *hw)
1895{ 1877{
1896 struct rtl_priv *rtlpriv = rtl_priv(hw); 1878 struct rtl_priv *rtlpriv = rtl_priv(hw);
1897 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); 1879 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
@@ -1946,13 +1928,12 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
1946 venderid, deviceid); 1928 venderid, deviceid);
1947 rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE; 1929 rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE;
1948 break; 1930 break;
1949
1950 } 1931 }
1951 } else if (deviceid == RTL_PCI_8723AE_DID) { 1932 } else if (deviceid == RTL_PCI_8723AE_DID) {
1952 rtlhal->hw_type = HARDWARE_TYPE_RTL8723AE; 1933 rtlhal->hw_type = HARDWARE_TYPE_RTL8723AE;
1953 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1934 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1954 "8723AE PCI-E is found - " 1935 "8723AE PCI-E is found - vid/did=%x/%x\n",
1955 "vid/did=%x/%x\n", venderid, deviceid); 1936 venderid, deviceid);
1956 } else if (deviceid == RTL_PCI_8192CET_DID || 1937 } else if (deviceid == RTL_PCI_8192CET_DID ||
1957 deviceid == RTL_PCI_8192CE_DID || 1938 deviceid == RTL_PCI_8192CE_DID ||
1958 deviceid == RTL_PCI_8191CE_DID || 1939 deviceid == RTL_PCI_8191CE_DID ||
@@ -1972,21 +1953,26 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
1972 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1953 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1973 "Find adapter, Hardware type is 8188EE\n"); 1954 "Find adapter, Hardware type is 8188EE\n");
1974 } else if (deviceid == RTL_PCI_8723BE_DID) { 1955 } else if (deviceid == RTL_PCI_8723BE_DID) {
1975 rtlhal->hw_type = HARDWARE_TYPE_RTL8723BE; 1956 rtlhal->hw_type = HARDWARE_TYPE_RTL8723BE;
1976 RT_TRACE(rtlpriv, COMP_INIT , DBG_LOUD, 1957 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1977 "Find adapter, Hardware type is 8723BE\n"); 1958 "Find adapter, Hardware type is 8723BE\n");
1978 } else if (deviceid == RTL_PCI_8192EE_DID) { 1959 } else if (deviceid == RTL_PCI_8192EE_DID) {
1979 rtlhal->hw_type = HARDWARE_TYPE_RTL8192EE; 1960 rtlhal->hw_type = HARDWARE_TYPE_RTL8192EE;
1980 RT_TRACE(rtlpriv, COMP_INIT , DBG_LOUD, 1961 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1981 "Find adapter, Hardware type is 8192EE\n"); 1962 "Find adapter, Hardware type is 8192EE\n");
1982 } else if (deviceid == RTL_PCI_8821AE_DID) { 1963 } else if (deviceid == RTL_PCI_8821AE_DID) {
1983 rtlhal->hw_type = HARDWARE_TYPE_RTL8821AE; 1964 rtlhal->hw_type = HARDWARE_TYPE_RTL8821AE;
1984 RT_TRACE(rtlpriv, COMP_INIT , DBG_LOUD, 1965 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1985 "Find adapter, Hardware type is 8821AE\n"); 1966 "Find adapter, Hardware type is 8821AE\n");
1986 } else if (deviceid == RTL_PCI_8812AE_DID) { 1967 } else if (deviceid == RTL_PCI_8812AE_DID) {
1987 rtlhal->hw_type = HARDWARE_TYPE_RTL8812AE; 1968 rtlhal->hw_type = HARDWARE_TYPE_RTL8812AE;
1988 RT_TRACE(rtlpriv, COMP_INIT , DBG_LOUD, 1969 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1989 "Find adapter, Hardware type is 8812AE\n"); 1970 "Find adapter, Hardware type is 8812AE\n");
1971 } else if (deviceid == RTL_PCI_8822BE_DID) {
1972 rtlhal->hw_type = HARDWARE_TYPE_RTL8822BE;
1973 rtlhal->bandset = BAND_ON_BOTH;
1974 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1975 "Find adapter, Hardware type is 8822BE\n");
1990 } else { 1976 } else {
1991 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1977 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1992 "Err: Unknown device - vid/did=%x/%x\n", 1978 "Err: Unknown device - vid/did=%x/%x\n",
@@ -2014,11 +2000,17 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
2014 } 2000 }
2015 } 2001 }
2016 2002
2017 /* 92ee use new trx flow */ 2003 switch (rtlhal->hw_type) {
2018 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) 2004 case HARDWARE_TYPE_RTL8192EE:
2005 case HARDWARE_TYPE_RTL8822BE:
2006 /* use new trx flow */
2019 rtlpriv->use_new_trx_flow = true; 2007 rtlpriv->use_new_trx_flow = true;
2020 else 2008 break;
2009
2010 default:
2021 rtlpriv->use_new_trx_flow = false; 2011 rtlpriv->use_new_trx_flow = false;
2012 break;
2013 }
2022 2014
2023 /*find bus info */ 2015 /*find bus info */
2024 pcipriv->ndis_adapter.busnumber = pdev->bus->number; 2016 pcipriv->ndis_adapter.busnumber = pdev->bus->number;
@@ -2109,7 +2101,7 @@ static int rtl_pci_intr_mode_msi(struct ieee80211_hw *hw)
2109 2101
2110 rtlpci->using_msi = true; 2102 rtlpci->using_msi = true;
2111 2103
2112 RT_TRACE(rtlpriv, COMP_INIT|COMP_INTR, DBG_DMESG, 2104 RT_TRACE(rtlpriv, COMP_INIT | COMP_INTR, DBG_DMESG,
2113 "MSI Interrupt Mode!\n"); 2105 "MSI Interrupt Mode!\n");
2114 return 0; 2106 return 0;
2115} 2107}
@@ -2127,7 +2119,7 @@ static int rtl_pci_intr_mode_legacy(struct ieee80211_hw *hw)
2127 return ret; 2119 return ret;
2128 2120
2129 rtlpci->using_msi = false; 2121 rtlpci->using_msi = false;
2130 RT_TRACE(rtlpriv, COMP_INIT|COMP_INTR, DBG_DMESG, 2122 RT_TRACE(rtlpriv, COMP_INIT | COMP_INTR, DBG_DMESG,
2131 "Pin-based Interrupt Mode!\n"); 2123 "Pin-based Interrupt Mode!\n");
2132 return 0; 2124 return 0;
2133} 2125}
@@ -2164,7 +2156,7 @@ static void platform_enable_dma64(struct pci_dev *pdev, bool dma64)
2164} 2156}
2165 2157
2166int rtl_pci_probe(struct pci_dev *pdev, 2158int rtl_pci_probe(struct pci_dev *pdev,
2167 const struct pci_device_id *id) 2159 const struct pci_device_id *id)
2168{ 2160{
2169 struct ieee80211_hw *hw = NULL; 2161 struct ieee80211_hw *hw = NULL;
2170 2162
@@ -2343,7 +2335,6 @@ fail1:
2343 pci_disable_device(pdev); 2335 pci_disable_device(pdev);
2344 2336
2345 return err; 2337 return err;
2346
2347} 2338}
2348EXPORT_SYMBOL(rtl_pci_probe); 2339EXPORT_SYMBOL(rtl_pci_probe);
2349 2340
@@ -2402,20 +2393,20 @@ EXPORT_SYMBOL(rtl_pci_disconnect);
2402 2393
2403#ifdef CONFIG_PM_SLEEP 2394#ifdef CONFIG_PM_SLEEP
2404/*************************************** 2395/***************************************
2405kernel pci power state define: 2396 * kernel pci power state define:
2406PCI_D0 ((pci_power_t __force) 0) 2397 * PCI_D0 ((pci_power_t __force) 0)
2407PCI_D1 ((pci_power_t __force) 1) 2398 * PCI_D1 ((pci_power_t __force) 1)
2408PCI_D2 ((pci_power_t __force) 2) 2399 * PCI_D2 ((pci_power_t __force) 2)
2409PCI_D3hot ((pci_power_t __force) 3) 2400 * PCI_D3hot ((pci_power_t __force) 3)
2410PCI_D3cold ((pci_power_t __force) 4) 2401 * PCI_D3cold ((pci_power_t __force) 4)
2411PCI_UNKNOWN ((pci_power_t __force) 5) 2402 * PCI_UNKNOWN ((pci_power_t __force) 5)
2412 2403
2413This function is called when system 2404 * This function is called when system
2414goes into suspend state mac80211 will 2405 * goes into suspend state mac80211 will
2415call rtl_mac_stop() from the mac80211 2406 * call rtl_mac_stop() from the mac80211
2416suspend function first, So there is 2407 * suspend function first, So there is
2417no need to call hw_disable here. 2408 * no need to call hw_disable here.
2418****************************************/ 2409 ****************************************/
2419int rtl_pci_suspend(struct device *dev) 2410int rtl_pci_suspend(struct device *dev)
2420{ 2411{
2421 struct pci_dev *pdev = to_pci_dev(dev); 2412 struct pci_dev *pdev = to_pci_dev(dev);
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.h b/drivers/net/wireless/realtek/rtlwifi/pci.h
index 1af92b34979d..e7d070e8da2d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.h
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.h
@@ -27,10 +27,9 @@
27#define __RTL_PCI_H__ 27#define __RTL_PCI_H__
28 28
29#include <linux/pci.h> 29#include <linux/pci.h>
30/* 30/* 1: MSDU packet queue,
311: MSDU packet queue, 31 * 2: Rx Command Queue
322: Rx Command Queue 32 */
33*/
34#define RTL_PCI_RX_MPDU_QUEUE 0 33#define RTL_PCI_RX_MPDU_QUEUE 0
35#define RTL_PCI_RX_CMD_QUEUE 1 34#define RTL_PCI_RX_CMD_QUEUE 1
36#define RTL_PCI_MAX_RX_QUEUE 2 35#define RTL_PCI_MAX_RX_QUEUE 2
@@ -40,6 +39,7 @@
40 39
41#define RT_TXDESC_NUM 128 40#define RT_TXDESC_NUM 128
42#define TX_DESC_NUM_92E 512 41#define TX_DESC_NUM_92E 512
42#define TX_DESC_NUM_8822B 512
43#define RT_TXDESC_NUM_BE_QUEUE 256 43#define RT_TXDESC_NUM_BE_QUEUE 256
44 44
45#define BK_QUEUE 0 45#define BK_QUEUE 0
@@ -51,6 +51,7 @@
51#define MGNT_QUEUE 6 51#define MGNT_QUEUE 6
52#define HIGH_QUEUE 7 52#define HIGH_QUEUE 7
53#define HCCA_QUEUE 8 53#define HCCA_QUEUE 8
54#define H2C_QUEUE TXCMD_QUEUE /* In 8822B */
54 55
55#define RTL_PCI_DEVICE(vend, dev, cfg) \ 56#define RTL_PCI_DEVICE(vend, dev, cfg) \
56 .vendor = (vend), \ 57 .vendor = (vend), \
@@ -108,6 +109,7 @@
108#define RTL_PCI_8192EE_DID 0x818B /*8192ee*/ 109#define RTL_PCI_8192EE_DID 0x818B /*8192ee*/
109#define RTL_PCI_8821AE_DID 0x8821 /*8821ae*/ 110#define RTL_PCI_8821AE_DID 0x8821 /*8821ae*/
110#define RTL_PCI_8812AE_DID 0x8812 /*8812ae*/ 111#define RTL_PCI_8812AE_DID 0x8812 /*8812ae*/
112#define RTL_PCI_8822BE_DID 0xB822 /*8822be*/
111 113
112/*8192 support 16 pages of IO registers*/ 114/*8192 support 16 pages of IO registers*/
113#define RTL_MEM_MAPPED_IO_RANGE_8190PCI 0x1000 115#define RTL_MEM_MAPPED_IO_RANGE_8190PCI 0x1000
@@ -209,7 +211,7 @@ struct rtl_pci {
209 211
210 /*irq */ 212 /*irq */
211 u8 irq_alloc; 213 u8 irq_alloc;
212 u32 irq_mask[2]; 214 u32 irq_mask[4]; /* 0-1: normal, 2: unused, 3: h2c */
213 u32 sys_irq_mask; 215 u32 sys_irq_mask;
214 216
215 /*Bcn control register setting */ 217 /*Bcn control register setting */
@@ -223,8 +225,9 @@ struct rtl_pci {
223 u8 const_hostpci_aspm_setting; 225 u8 const_hostpci_aspm_setting;
224 /*pci-e device */ 226 /*pci-e device */
225 u8 const_devicepci_aspm_setting; 227 u8 const_devicepci_aspm_setting;
226 /*If it supports ASPM, Offset[560h] = 0x40, 228 /* If it supports ASPM, Offset[560h] = 0x40,
227 otherwise Offset[560h] = 0x00. */ 229 * otherwise Offset[560h] = 0x00.
230 */
228 bool support_aspm; 231 bool support_aspm;
229 bool support_backdoor; 232 bool support_backdoor;
230 233
@@ -279,7 +282,7 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw);
279extern const struct rtl_intf_ops rtl_pci_ops; 282extern const struct rtl_intf_ops rtl_pci_ops;
280 283
281int rtl_pci_probe(struct pci_dev *pdev, 284int rtl_pci_probe(struct pci_dev *pdev,
282 const struct pci_device_id *id); 285 const struct pci_device_id *id);
283void rtl_pci_disconnect(struct pci_dev *pdev); 286void rtl_pci_disconnect(struct pci_dev *pdev);
284#ifdef CONFIG_PM_SLEEP 287#ifdef CONFIG_PM_SLEEP
285int rtl_pci_suspend(struct device *dev); 288int rtl_pci_suspend(struct device *dev);
@@ -287,34 +290,34 @@ int rtl_pci_resume(struct device *dev);
287#endif /* CONFIG_PM_SLEEP */ 290#endif /* CONFIG_PM_SLEEP */
288static inline u8 pci_read8_sync(struct rtl_priv *rtlpriv, u32 addr) 291static inline u8 pci_read8_sync(struct rtl_priv *rtlpriv, u32 addr)
289{ 292{
290 return readb((u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 293 return readb((u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
291} 294}
292 295
293static inline u16 pci_read16_sync(struct rtl_priv *rtlpriv, u32 addr) 296static inline u16 pci_read16_sync(struct rtl_priv *rtlpriv, u32 addr)
294{ 297{
295 return readw((u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 298 return readw((u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
296} 299}
297 300
298static inline u32 pci_read32_sync(struct rtl_priv *rtlpriv, u32 addr) 301static inline u32 pci_read32_sync(struct rtl_priv *rtlpriv, u32 addr)
299{ 302{
300 return readl((u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 303 return readl((u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
301} 304}
302 305
303static inline void pci_write8_async(struct rtl_priv *rtlpriv, u32 addr, u8 val) 306static inline void pci_write8_async(struct rtl_priv *rtlpriv, u32 addr, u8 val)
304{ 307{
305 writeb(val, (u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 308 writeb(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
306} 309}
307 310
308static inline void pci_write16_async(struct rtl_priv *rtlpriv, 311static inline void pci_write16_async(struct rtl_priv *rtlpriv,
309 u32 addr, u16 val) 312 u32 addr, u16 val)
310{ 313{
311 writew(val, (u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 314 writew(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
312} 315}
313 316
314static inline void pci_write32_async(struct rtl_priv *rtlpriv, 317static inline void pci_write32_async(struct rtl_priv *rtlpriv,
315 u32 addr, u32 val) 318 u32 addr, u32 val)
316{ 319{
317 writel(val, (u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 320 writel(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
318} 321}
319 322
320static inline u16 calc_fifo_space(u16 rp, u16 wp) 323static inline u16 calc_fifo_space(u16 rp, u16 wp)
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
index 2c671364c521..e30a18e64ff5 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
@@ -1472,7 +1472,8 @@ void rtl88ee_card_disable(struct ieee80211_hw *hw)
1472} 1472}
1473 1473
1474void rtl88ee_interrupt_recognized(struct ieee80211_hw *hw, 1474void rtl88ee_interrupt_recognized(struct ieee80211_hw *hw,
1475 u32 *p_inta, u32 *p_intb) 1475 u32 *p_inta, u32 *p_intb,
1476 u32 *p_intc, u32 *p_intd)
1476{ 1477{
1477 struct rtl_priv *rtlpriv = rtl_priv(hw); 1478 struct rtl_priv *rtlpriv = rtl_priv(hw);
1478 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1479 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h
index ab8488da9409..cdf49de1e6ed 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h
@@ -29,7 +29,8 @@
29void rtl88ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); 29void rtl88ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
30void rtl88ee_read_eeprom_info(struct ieee80211_hw *hw); 30void rtl88ee_read_eeprom_info(struct ieee80211_hw *hw);
31void rtl88ee_interrupt_recognized(struct ieee80211_hw *hw, 31void rtl88ee_interrupt_recognized(struct ieee80211_hw *hw,
32 u32 *p_inta, u32 *p_intb); 32 u32 *p_inta, u32 *p_intb,
33 u32 *p_intc, u32 *p_intd);
33int rtl88ee_hw_init(struct ieee80211_hw *hw); 34int rtl88ee_hw_init(struct ieee80211_hw *hw);
34void rtl88ee_card_disable(struct ieee80211_hw *hw); 35void rtl88ee_card_disable(struct ieee80211_hw *hw);
35void rtl88ee_enable_interrupt(struct ieee80211_hw *hw); 36void rtl88ee_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
index 9310fad69cd9..0f4c86a28716 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
@@ -1375,7 +1375,8 @@ void rtl92ce_card_disable(struct ieee80211_hw *hw)
1375} 1375}
1376 1376
1377void rtl92ce_interrupt_recognized(struct ieee80211_hw *hw, 1377void rtl92ce_interrupt_recognized(struct ieee80211_hw *hw,
1378 u32 *p_inta, u32 *p_intb) 1378 u32 *p_inta, u32 *p_intb,
1379 u32 *p_intc, u32 *p_intd)
1379{ 1380{
1380 struct rtl_priv *rtlpriv = rtl_priv(hw); 1381 struct rtl_priv *rtlpriv = rtl_priv(hw);
1381 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1382 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.h
index 7683c5dfe851..b5c8e2fc1ba2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.h
@@ -42,7 +42,8 @@ static inline u8 rtl92c_get_chnl_group(u8 chnl)
42void rtl92ce_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); 42void rtl92ce_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
43void rtl92ce_read_eeprom_info(struct ieee80211_hw *hw); 43void rtl92ce_read_eeprom_info(struct ieee80211_hw *hw);
44void rtl92ce_interrupt_recognized(struct ieee80211_hw *hw, 44void rtl92ce_interrupt_recognized(struct ieee80211_hw *hw,
45 u32 *p_inta, u32 *p_intb); 45 u32 *p_inta, u32 *p_intb,
46 u32 *p_intc, u32 *p_intd);
46int rtl92ce_hw_init(struct ieee80211_hw *hw); 47int rtl92ce_hw_init(struct ieee80211_hw *hw);
47void rtl92ce_card_disable(struct ieee80211_hw *hw); 48void rtl92ce_card_disable(struct ieee80211_hw *hw);
48void rtl92ce_enable_interrupt(struct ieee80211_hw *hw); 49void rtl92ce_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
index 5a67f85fa165..0da6c0136857 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
@@ -1356,7 +1356,8 @@ void rtl92de_card_disable(struct ieee80211_hw *hw)
1356} 1356}
1357 1357
1358void rtl92de_interrupt_recognized(struct ieee80211_hw *hw, 1358void rtl92de_interrupt_recognized(struct ieee80211_hw *hw,
1359 u32 *p_inta, u32 *p_intb) 1359 u32 *p_inta, u32 *p_intb,
1360 u32 *p_intc, u32 *p_intd)
1360{ 1361{
1361 struct rtl_priv *rtlpriv = rtl_priv(hw); 1362 struct rtl_priv *rtlpriv = rtl_priv(hw);
1362 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1363 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.h
index 85c565b86ae3..9236aa91273d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.h
@@ -29,7 +29,8 @@
29void rtl92de_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); 29void rtl92de_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
30void rtl92de_read_eeprom_info(struct ieee80211_hw *hw); 30void rtl92de_read_eeprom_info(struct ieee80211_hw *hw);
31void rtl92de_interrupt_recognized(struct ieee80211_hw *hw, 31void rtl92de_interrupt_recognized(struct ieee80211_hw *hw,
32 u32 *p_inta, u32 *p_intb); 32 u32 *p_inta, u32 *p_intb,
33 u32 *p_intc, u32 *p_intd);
33int rtl92de_hw_init(struct ieee80211_hw *hw); 34int rtl92de_hw_init(struct ieee80211_hw *hw);
34void rtl92de_card_disable(struct ieee80211_hw *hw); 35void rtl92de_card_disable(struct ieee80211_hw *hw);
35void rtl92de_enable_interrupt(struct ieee80211_hw *hw); 36void rtl92de_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
index 6fc3090c4b72..fe5da637e77a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
@@ -1694,7 +1694,8 @@ void rtl92ee_card_disable(struct ieee80211_hw *hw)
1694} 1694}
1695 1695
1696void rtl92ee_interrupt_recognized(struct ieee80211_hw *hw, 1696void rtl92ee_interrupt_recognized(struct ieee80211_hw *hw,
1697 u32 *p_inta, u32 *p_intb) 1697 u32 *p_inta, u32 *p_intb,
1698 u32 *p_intc, u32 *p_intd)
1698{ 1699{
1699 struct rtl_priv *rtlpriv = rtl_priv(hw); 1700 struct rtl_priv *rtlpriv = rtl_priv(hw);
1700 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1701 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.h
index cd6aeb44b996..cd6d3322f033 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.h
@@ -29,7 +29,8 @@
29void rtl92ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); 29void rtl92ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
30void rtl92ee_read_eeprom_info(struct ieee80211_hw *hw); 30void rtl92ee_read_eeprom_info(struct ieee80211_hw *hw);
31void rtl92ee_interrupt_recognized(struct ieee80211_hw *hw, 31void rtl92ee_interrupt_recognized(struct ieee80211_hw *hw,
32 u32 *p_inta, u32 *p_intb); 32 u32 *p_inta, u32 *p_intb,
33 u32 *p_intc, u32 *p_intd);
33int rtl92ee_hw_init(struct ieee80211_hw *hw); 34int rtl92ee_hw_init(struct ieee80211_hw *hw);
34void rtl92ee_card_disable(struct ieee80211_hw *hw); 35void rtl92ee_card_disable(struct ieee80211_hw *hw);
35void rtl92ee_enable_interrupt(struct ieee80211_hw *hw); 36void rtl92ee_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c
index 66be79ca4247..76bf089cced4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c
@@ -1559,7 +1559,7 @@ void rtl92se_card_disable(struct ieee80211_hw *hw)
1559} 1559}
1560 1560
1561void rtl92se_interrupt_recognized(struct ieee80211_hw *hw, u32 *p_inta, 1561void rtl92se_interrupt_recognized(struct ieee80211_hw *hw, u32 *p_inta,
1562 u32 *p_intb) 1562 u32 *p_intb, u32 *p_intc, u32 *p_intd)
1563{ 1563{
1564 struct rtl_priv *rtlpriv = rtl_priv(hw); 1564 struct rtl_priv *rtlpriv = rtl_priv(hw);
1565 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1565 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.h
index 3c93d30fcae7..607056010974 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.h
@@ -42,7 +42,8 @@ void rtl92se_get_hw_reg(struct ieee80211_hw *hw,
42 u8 variable, u8 *val); 42 u8 variable, u8 *val);
43void rtl92se_read_eeprom_info(struct ieee80211_hw *hw); 43void rtl92se_read_eeprom_info(struct ieee80211_hw *hw);
44void rtl92se_interrupt_recognized(struct ieee80211_hw *hw, 44void rtl92se_interrupt_recognized(struct ieee80211_hw *hw,
45 u32 *inta, u32 *intb); 45 u32 *p_inta, u32 *p_intb,
46 u32 *p_intc, u32 *p_intd);
46int rtl92se_hw_init(struct ieee80211_hw *hw); 47int rtl92se_hw_init(struct ieee80211_hw *hw);
47void rtl92se_card_disable(struct ieee80211_hw *hw); 48void rtl92se_card_disable(struct ieee80211_hw *hw);
48void rtl92se_enable_interrupt(struct ieee80211_hw *hw); 49void rtl92se_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
index 8cfd4993c90a..c3f98d58124c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
@@ -1340,7 +1340,8 @@ void rtl8723e_card_disable(struct ieee80211_hw *hw)
1340} 1340}
1341 1341
1342void rtl8723e_interrupt_recognized(struct ieee80211_hw *hw, 1342void rtl8723e_interrupt_recognized(struct ieee80211_hw *hw,
1343 u32 *p_inta, u32 *p_intb) 1343 u32 *p_inta, u32 *p_intb,
1344 u32 *p_intc, u32 *p_intd)
1344{ 1345{
1345 struct rtl_priv *rtlpriv = rtl_priv(hw); 1346 struct rtl_priv *rtlpriv = rtl_priv(hw);
1346 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1347 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.h
index 1e7063105c96..19e467a37c72 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.h
@@ -34,7 +34,8 @@ void rtl8723e_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
34void rtl8723e_read_eeprom_info(struct ieee80211_hw *hw); 34void rtl8723e_read_eeprom_info(struct ieee80211_hw *hw);
35 35
36void rtl8723e_interrupt_recognized(struct ieee80211_hw *hw, 36void rtl8723e_interrupt_recognized(struct ieee80211_hw *hw,
37 u32 *p_inta, u32 *p_intb); 37 u32 *p_inta, u32 *p_intb,
38 u32 *p_intc, u32 *p_intd);
38int rtl8723e_hw_init(struct ieee80211_hw *hw); 39int rtl8723e_hw_init(struct ieee80211_hw *hw);
39void rtl8723e_card_disable(struct ieee80211_hw *hw); 40void rtl8723e_card_disable(struct ieee80211_hw *hw);
40void rtl8723e_enable_interrupt(struct ieee80211_hw *hw); 41void rtl8723e_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index 239518bd31f1..7cd1ffa7d4a7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -1682,7 +1682,8 @@ void rtl8723be_card_disable(struct ieee80211_hw *hw)
1682} 1682}
1683 1683
1684void rtl8723be_interrupt_recognized(struct ieee80211_hw *hw, 1684void rtl8723be_interrupt_recognized(struct ieee80211_hw *hw,
1685 u32 *p_inta, u32 *p_intb) 1685 u32 *p_inta, u32 *p_intb,
1686 u32 *p_intc, u32 *p_intd)
1686{ 1687{
1687 struct rtl_priv *rtlpriv = rtl_priv(hw); 1688 struct rtl_priv *rtlpriv = rtl_priv(hw);
1688 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1689 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.h
index 54d7afa7297e..2215a792f6bf 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.h
@@ -30,7 +30,8 @@ void rtl8723be_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
30void rtl8723be_read_eeprom_info(struct ieee80211_hw *hw); 30void rtl8723be_read_eeprom_info(struct ieee80211_hw *hw);
31 31
32void rtl8723be_interrupt_recognized(struct ieee80211_hw *hw, 32void rtl8723be_interrupt_recognized(struct ieee80211_hw *hw,
33 u32 *p_inta, u32 *p_intb); 33 u32 *p_inta, u32 *p_intb,
34 u32 *p_intc, u32 *p_intd);
34int rtl8723be_hw_init(struct ieee80211_hw *hw); 35int rtl8723be_hw_init(struct ieee80211_hw *hw);
35void rtl8723be_card_disable(struct ieee80211_hw *hw); 36void rtl8723be_card_disable(struct ieee80211_hw *hw);
36void rtl8723be_enable_interrupt(struct ieee80211_hw *hw); 37void rtl8723be_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
index 60c82a5b51cd..43e18c4c1e68 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
@@ -1364,7 +1364,6 @@ static void _rtl8821ae_get_wakeup_reason(struct ieee80211_hw *hw)
1364 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1364 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1365 struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); 1365 struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv);
1366 u8 fw_reason = 0; 1366 u8 fw_reason = 0;
1367 struct timeval ts;
1368 1367
1369 fw_reason = rtl_read_byte(rtlpriv, REG_MCUTST_WOWLAN); 1368 fw_reason = rtl_read_byte(rtlpriv, REG_MCUTST_WOWLAN);
1370 1369
@@ -1373,20 +1372,16 @@ static void _rtl8821ae_get_wakeup_reason(struct ieee80211_hw *hw)
1373 1372
1374 ppsc->wakeup_reason = 0; 1373 ppsc->wakeup_reason = 0;
1375 1374
1376 rtlhal->last_suspend_sec = ts.tv_sec; 1375 rtlhal->last_suspend_sec = ktime_get_real_seconds();
1377 1376
1378 switch (fw_reason) { 1377 switch (fw_reason) {
1379 case FW_WOW_V2_PTK_UPDATE_EVENT: 1378 case FW_WOW_V2_PTK_UPDATE_EVENT:
1380 ppsc->wakeup_reason = WOL_REASON_PTK_UPDATE; 1379 ppsc->wakeup_reason = WOL_REASON_PTK_UPDATE;
1381 do_gettimeofday(&ts);
1382 ppsc->last_wakeup_time = ts.tv_sec*1000 + ts.tv_usec/1000;
1383 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 1380 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
1384 "It's a WOL PTK Key update event!\n"); 1381 "It's a WOL PTK Key update event!\n");
1385 break; 1382 break;
1386 case FW_WOW_V2_GTK_UPDATE_EVENT: 1383 case FW_WOW_V2_GTK_UPDATE_EVENT:
1387 ppsc->wakeup_reason = WOL_REASON_GTK_UPDATE; 1384 ppsc->wakeup_reason = WOL_REASON_GTK_UPDATE;
1388 do_gettimeofday(&ts);
1389 ppsc->last_wakeup_time = ts.tv_sec*1000 + ts.tv_usec/1000;
1390 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 1385 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
1391 "It's a WOL GTK Key update event!\n"); 1386 "It's a WOL GTK Key update event!\n");
1392 break; 1387 break;
@@ -2488,7 +2483,8 @@ void rtl8821ae_card_disable(struct ieee80211_hw *hw)
2488} 2483}
2489 2484
2490void rtl8821ae_interrupt_recognized(struct ieee80211_hw *hw, 2485void rtl8821ae_interrupt_recognized(struct ieee80211_hw *hw,
2491 u32 *p_inta, u32 *p_intb) 2486 u32 *p_inta, u32 *p_intb,
2487 u32 *p_intc, u32 *p_intd)
2492{ 2488{
2493 struct rtl_priv *rtlpriv = rtl_priv(hw); 2489 struct rtl_priv *rtlpriv = rtl_priv(hw);
2494 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 2490 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.h
index 50fa9c718189..284d259fe557 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.h
@@ -30,7 +30,8 @@ void rtl8821ae_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
30void rtl8821ae_read_eeprom_info(struct ieee80211_hw *hw); 30void rtl8821ae_read_eeprom_info(struct ieee80211_hw *hw);
31 31
32void rtl8821ae_interrupt_recognized(struct ieee80211_hw *hw, 32void rtl8821ae_interrupt_recognized(struct ieee80211_hw *hw,
33 u32 *p_inta, u32 *p_intb); 33 u32 *p_inta, u32 *p_intb,
34 u32 *p_intc, u32 *p_intd);
34int rtl8821ae_hw_init(struct ieee80211_hw *hw); 35int rtl8821ae_hw_init(struct ieee80211_hw *hw);
35void rtl8821ae_card_disable(struct ieee80211_hw *hw); 36void rtl8821ae_card_disable(struct ieee80211_hw *hw);
36void rtl8821ae_enable_interrupt(struct ieee80211_hw *hw); 37void rtl8821ae_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index 22afc14c3da6..92d4859ec906 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -709,6 +709,7 @@ enum rtl_var_map {
709 RTL_IMR_RXFOVW, /*Receive FIFO Overflow */ 709 RTL_IMR_RXFOVW, /*Receive FIFO Overflow */
710 RTL_IMR_RDU, /*Receive Descriptor Unavailable */ 710 RTL_IMR_RDU, /*Receive Descriptor Unavailable */
711 RTL_IMR_ATIMEND, /*For 92C,ATIM Window End Interrupt */ 711 RTL_IMR_ATIMEND, /*For 92C,ATIM Window End Interrupt */
712 RTL_IMR_H2CDOK, /*H2C Queue DMA OK Interrupt */
712 RTL_IMR_BDOK, /*Beacon Queue DMA OK Interrup */ 713 RTL_IMR_BDOK, /*Beacon Queue DMA OK Interrup */
713 RTL_IMR_HIGHDOK, /*High Queue DMA OK Interrupt */ 714 RTL_IMR_HIGHDOK, /*High Queue DMA OK Interrupt */
714 RTL_IMR_COMDOK, /*Command Queue DMA OK Interrupt*/ 715 RTL_IMR_COMDOK, /*Command Queue DMA OK Interrupt*/
@@ -1599,7 +1600,7 @@ struct rtl_hal {
1599 bool enter_pnp_sleep; 1600 bool enter_pnp_sleep;
1600 bool wake_from_pnp_sleep; 1601 bool wake_from_pnp_sleep;
1601 bool wow_enabled; 1602 bool wow_enabled;
1602 __kernel_time_t last_suspend_sec; 1603 time64_t last_suspend_sec;
1603 u32 wowlan_fwsize; 1604 u32 wowlan_fwsize;
1604 u8 *wowlan_firmware; 1605 u8 *wowlan_firmware;
1605 1606
@@ -1953,8 +1954,6 @@ struct rtl_ps_ctl {
1953 u8 gtk_offload_enable; 1954 u8 gtk_offload_enable;
1954 /* Used for WOL, indicates the reason for waking event.*/ 1955 /* Used for WOL, indicates the reason for waking event.*/
1955 u32 wakeup_reason; 1956 u32 wakeup_reason;
1956 /* Record the last waking time for comparison with setting key. */
1957 u64 last_wakeup_time;
1958}; 1957};
1959 1958
1960struct rtl_stats { 1959struct rtl_stats {
@@ -2100,7 +2099,8 @@ struct rtl_hal_ops {
2100 void (*read_chip_version)(struct ieee80211_hw *hw); 2099 void (*read_chip_version)(struct ieee80211_hw *hw);
2101 void (*read_eeprom_info) (struct ieee80211_hw *hw); 2100 void (*read_eeprom_info) (struct ieee80211_hw *hw);
2102 void (*interrupt_recognized) (struct ieee80211_hw *hw, 2101 void (*interrupt_recognized) (struct ieee80211_hw *hw,
2103 u32 *p_inta, u32 *p_intb); 2102 u32 *p_inta, u32 *p_intb,
2103 u32 *p_intc, u32 *p_intd);
2104 int (*hw_init) (struct ieee80211_hw *hw); 2104 int (*hw_init) (struct ieee80211_hw *hw);
2105 void (*hw_disable) (struct ieee80211_hw *hw); 2105 void (*hw_disable) (struct ieee80211_hw *hw);
2106 void (*hw_suspend) (struct ieee80211_hw *hw); 2106 void (*hw_suspend) (struct ieee80211_hw *hw);
@@ -2144,6 +2144,9 @@ struct rtl_hal_ops {
2144 void (*fill_tx_cmddesc) (struct ieee80211_hw *hw, u8 *pdesc, 2144 void (*fill_tx_cmddesc) (struct ieee80211_hw *hw, u8 *pdesc,
2145 bool firstseg, bool lastseg, 2145 bool firstseg, bool lastseg,
2146 struct sk_buff *skb); 2146 struct sk_buff *skb);
2147 void (*fill_tx_special_desc)(struct ieee80211_hw *hw,
2148 u8 *pdesc, u8 *pbd_desc,
2149 struct sk_buff *skb, u8 hw_queue);
2147 bool (*query_rx_desc) (struct ieee80211_hw *hw, 2150 bool (*query_rx_desc) (struct ieee80211_hw *hw,
2148 struct rtl_stats *stats, 2151 struct rtl_stats *stats,
2149 struct ieee80211_rx_status *rx_status, 2152 struct ieee80211_rx_status *rx_status,
diff --git a/drivers/net/wireless/rsi/rsi_91x_ps.c b/drivers/net/wireless/rsi/rsi_91x_ps.c
index 523f5329d2b7..01472fac8b9a 100644
--- a/drivers/net/wireless/rsi/rsi_91x_ps.c
+++ b/drivers/net/wireless/rsi/rsi_91x_ps.c
@@ -36,7 +36,6 @@ char *str_psstate(enum ps_state state)
36 default: 36 default:
37 return "INVALID_STATE"; 37 return "INVALID_STATE";
38 } 38 }
39 return "INVALID_STATE";
40} 39}
41 40
42static inline void rsi_modify_ps_state(struct rsi_hw *adapter, 41static inline void rsi_modify_ps_state(struct rsi_hw *adapter,
diff --git a/drivers/net/wireless/zydas/zd1201.c b/drivers/net/wireless/zydas/zd1201.c
index 581e8577a221..253403899fe9 100644
--- a/drivers/net/wireless/zydas/zd1201.c
+++ b/drivers/net/wireless/zydas/zd1201.c
@@ -230,8 +230,7 @@ static void zd1201_usbrx(struct urb *urb)
230 /* Info frame */ 230 /* Info frame */
231 if (type == ZD1201_PACKET_INQUIRE) { 231 if (type == ZD1201_PACKET_INQUIRE) {
232 int i = 0; 232 int i = 0;
233 unsigned short infotype, framelen, copylen; 233 unsigned short infotype, copylen;
234 framelen = le16_to_cpu(*(__le16*)&data[4]);
235 infotype = le16_to_cpu(*(__le16*)&data[6]); 234 infotype = le16_to_cpu(*(__le16*)&data[6]);
236 235
237 if (infotype == ZD1201_INF_LINKSTATUS) { 236 if (infotype == ZD1201_INF_LINKSTATUS) {