tzh
2024-08-15 d4a1bd480003f3e1a0590bc46fbcb24f05652ca7
longan/kernel/linux-4.9/drivers/net/wireless/aic8800/aic8800_fdrv/rwnx_msg_rx.c
old mode 100644new mode 100755
....@@ -23,6 +23,7 @@
2323 #include "rwnx_events.h"
2424 #include "rwnx_compat.h"
2525 #include "aicwf_txrxif.h"
26
+#include "rwnx_msg_rx.h"
2627
2728 static int rwnx_freq_to_idx(struct rwnx_hw *rwnx_hw, int freq)
2829 {
....@@ -61,16 +62,13 @@
6162 struct rwnx_vif *rwnx_vif;
6263 int chan_idx = ((struct mm_channel_pre_switch_ind *)msg->param)->chan_index;
6364
64
- RWNX_DBG(RWNX_FN_ENTRY_STR);
65
-
6665 REG_SW_SET_PROFILING_CHAN(rwnx_hw, SW_PROF_CHAN_CTXT_PSWTCH_BIT);
6766
6867 #ifdef CONFIG_RWNX_FULLMAC
6968 list_for_each_entry(rwnx_vif, &rwnx_hw->vifs, list) {
70
- if (rwnx_vif->up && rwnx_vif->ch_index == chan_idx) {
71
- printk("rwnx_txq_vif_stop\r\n");
72
- rwnx_txq_vif_stop(rwnx_vif, RWNX_TXQ_STOP_CHAN, rwnx_hw);
73
- }
69
+ if (rwnx_vif->up && rwnx_vif->ch_index == chan_idx) {
70
+ rwnx_txq_vif_stop(rwnx_vif, RWNX_TXQ_STOP_CHAN, rwnx_hw);
71
+ }
7472 }
7573 #endif /* CONFIG_RWNX_FULLMAC */
7674
....@@ -88,8 +86,6 @@
8886 bool roc = ((struct mm_channel_switch_ind *)msg->param)->roc;
8987 bool roc_tdls = ((struct mm_channel_switch_ind *)msg->param)->roc_tdls;
9088
91
- RWNX_DBG(RWNX_FN_ENTRY_STR);
92
-
9389 REG_SW_SET_PROFILING_CHAN(rwnx_hw, SW_PROF_CHAN_CTXT_SWTCH_BIT);
9490
9591 #ifdef CONFIG_RWNX_FULLMAC
....@@ -97,16 +93,16 @@
9793 u8 vif_index = ((struct mm_channel_switch_ind *)msg->param)->vif_index;
9894 list_for_each_entry(rwnx_vif, &rwnx_hw->vifs, list) {
9995 if (rwnx_vif->vif_index == vif_index) {
100
- rwnx_vif->roc_tdls = true;
101
- rwnx_txq_tdls_sta_start(rwnx_vif, RWNX_TXQ_STOP_CHAN, rwnx_hw);
96
+ rwnx_vif->roc_tdls = true;
97
+ rwnx_txq_tdls_sta_start(rwnx_vif, RWNX_TXQ_STOP_CHAN, rwnx_hw);
10298 }
103
- }
104
- } else if (!roc) {
105
- list_for_each_entry(rwnx_vif, &rwnx_hw->vifs, list) {
106
- if (rwnx_vif->up && rwnx_vif->ch_index == chan_idx) {
107
- rwnx_txq_vif_start(rwnx_vif, RWNX_TXQ_STOP_CHAN, rwnx_hw);
10899 }
109
- }
100
+ } else if (!roc) {
101
+ list_for_each_entry(rwnx_vif, &rwnx_hw->vifs, list) {
102
+ if (rwnx_vif->up && rwnx_vif->ch_index == chan_idx) {
103
+ rwnx_txq_vif_start(rwnx_vif, RWNX_TXQ_STOP_CHAN, rwnx_hw);
104
+ }
105
+ }
110106 } else {
111107 /* Retrieve the allocated RoC element */
112108 struct rwnx_roc_elem *roc_elem = rwnx_hw->roc_elem;
....@@ -116,16 +112,19 @@
116112 /* For debug purpose (use ftrace kernel option) */
117113 //trace_switch_roc(rwnx_vif->vif_index);
118114
119
- /* If mgmt_roc is true, remain on channel has been started by ourself */
120
- if (!roc_elem->mgmt_roc) {
121
- /* Inform the host that we have switch on the indicated off-channel */
122
- cfg80211_ready_on_channel(roc_elem->wdev, (u64)(rwnx_hw->roc_cookie_cnt),
115
+ if (roc_elem) {
116
+ /* If mgmt_roc is true, remain on channel has been started by ourself */
117
+ if (!roc_elem->mgmt_roc) {
118
+ /* Inform the host that we have switch on the indicated off-channel */
119
+ cfg80211_ready_on_channel(roc_elem->wdev, (u64)(rwnx_hw->roc_cookie_cnt),
123120 roc_elem->chan, roc_elem->duration, GFP_ATOMIC);
121
+ }
122
+
123
+ /* Keep in mind that we have switched on the channel */
124
+ roc_elem->on_chan = true;
125
+ } else {
126
+ printk("roc_elem == null\n");
124127 }
125
-
126
- /* Keep in mind that we have switched on the channel */
127
- roc_elem->on_chan = true;
128
-
129128 // Enable traffic on OFF channel queue
130129 rwnx_txq_offchan_start(rwnx_hw);
131130 }
....@@ -210,13 +209,18 @@
210209 /* Retrieve the allocated RoC element */
211210 struct rwnx_roc_elem *roc_elem = rwnx_hw->roc_elem;
212211 /* Get VIF on which RoC has been started */
213
- struct rwnx_vif *rwnx_vif = container_of(roc_elem->wdev, struct rwnx_vif, wdev);
212
+ struct rwnx_vif *rwnx_vif;
214213
215214 RWNX_DBG(RWNX_FN_ENTRY_STR);
216215
217
- /* For debug purpose (use ftrace kernel option) */
218
- trace_roc_exp(rwnx_vif->vif_index);
216
+ if (!roc_elem)
217
+ return 0;
219218
219
+ rwnx_vif = container_of(roc_elem->wdev, struct rwnx_vif, wdev);
220
+ /* For debug purpose (use ftrace kernel option) */
221
+#ifdef CREATE_TRACE_POINTS
222
+ trace_roc_exp(rwnx_vif->vif_index);
223
+#endif
220224 /* If mgmt_roc is true, remain on channel has been started by ourself */
221225 /* If RoC has been cancelled before we switched on channel, do not call cfg80211 */
222226 if (!roc_elem->mgmt_roc && roc_elem->on_chan) {
....@@ -251,7 +255,7 @@
251255 int ps_state = ((struct mm_p2p_vif_ps_change_ind *)msg->param)->ps_state;
252256 struct rwnx_vif *vif_entry;
253257
254
- RWNX_DBG(RWNX_FN_ENTRY_STR);
258
+ //RWNX_DBG(RWNX_FN_ENTRY_STR);
255259
256260 #ifdef CONFIG_RWNX_FULLMAC
257261 vif_entry = rwnx_hw->vif_table[vif_idx];
....@@ -269,6 +273,7 @@
269273 if (ps_state == MM_PS_MODE_OFF) {
270274 // Start TX queues for provided VIF
271275 rwnx_txq_vif_start(vif_entry, RWNX_TXQ_STOP_VIF_PS, rwnx_hw);
276
+ tasklet_schedule(&rwnx_hw->task);
272277 } else {
273278 // Stop TX queues for provided VIF
274279 rwnx_txq_vif_stop(vif_entry, RWNX_TXQ_STOP_VIF_PS, rwnx_hw);
....@@ -288,8 +293,6 @@
288293 int idx = rwnx_freq_to_idx(rwnx_hw, ind->freq);
289294 // Get the survey
290295 struct rwnx_survey_info *rwnx_survey;
291
-
292
- RWNX_DBG(RWNX_FN_ENTRY_STR);
293296
294297 if (idx > ARRAY_SIZE(rwnx_hw->survey))
295298 return 0;
....@@ -359,6 +362,22 @@
359362 ind->num_packets, GFP_ATOMIC);
360363 }
361364 #endif /* CONFIG_RWNX_FULLMAC */
365
+
366
+ return 0;
367
+}
368
+
369
+static inline int rwnx_apm_staloss_ind(struct rwnx_hw *rwnx_hw,
370
+ struct rwnx_cmd *cmd,
371
+ struct ipc_e2a_msg *msg)
372
+{
373
+ struct mm_apm_staloss_ind *ind = (struct mm_apm_staloss_ind *)msg->param;
374
+
375
+ RWNX_DBG(RWNX_FN_ENTRY_STR);
376
+
377
+ memcpy(rwnx_hw->sta_mac_addr, ind->mac_addr, 6);
378
+ rwnx_hw->apm_vif_idx = ind->vif_idx;
379
+
380
+ queue_work(rwnx_hw->apmStaloss_wq, &rwnx_hw->apmStalossWork);
362381
363382 return 0;
364383 }
....@@ -473,8 +492,6 @@
473492 struct mm_ps_change_ind *ind = (struct mm_ps_change_ind *)msg->param;
474493 struct rwnx_sta *sta = &rwnx_hw->sta_table[ind->sta_idx];
475494
476
- RWNX_DBG(RWNX_FN_ENTRY_STR);
477
-
478495 if (ind->sta_idx >= (NX_REMOTE_STA_MAX + NX_VIRT_DEV_MAX)) {
479496 wiphy_err(rwnx_hw->wiphy, "Invalid sta index reported by fw %d\n",
480497 ind->sta_idx);
....@@ -490,7 +507,8 @@
490507 } else if (rwnx_hw->adding_sta) {
491508 sta->ps.active = ind->ps_state ? true : false;
492509 } else {
493
- netdev_err(rwnx_hw->vif_table[sta->vif_idx]->ndev,
510
+ if (rwnx_hw->vif_table[sta->vif_idx]->ndev)
511
+ netdev_err(rwnx_hw->vif_table[sta->vif_idx]->ndev,
494512 "Ignore PS mode change on invalid sta\n");
495513 }
496514
....@@ -555,8 +573,6 @@
555573 {
556574 RWNX_DBG(RWNX_FN_ENTRY_STR);
557575
558
- scanning = 0;
559
- //rwnx_ipc_elem_var_deallocs(rwnx_hw, &rwnx_hw->scan_ie);
560576 if (rwnx_hw->scan_request) {
561577 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
562578 struct cfg80211_scan_info info = {
....@@ -570,6 +586,7 @@
570586 }
571587
572588 rwnx_hw->scan_request = NULL;
589
+ scanning = 0;
573590
574591 return 0;
575592 }
....@@ -587,7 +604,6 @@
587604 size_t ielen;
588605 u16 capability, beacon_interval;
589606 u16 len = ind->length;
590
- RWNX_DBG(RWNX_FN_ENTRY_STR);
591607
592608 chan = ieee80211_get_channel(rwnx_hw->wiphy, ind->center_freq);
593609
....@@ -597,9 +613,14 @@
597613 ts = ktime_to_timespec(ktime_get_boottime());
598614 tsf = (u64)ts.tv_sec * 1000000 + div_u64(ts.tv_nsec, 1000);
599615 mgmt->u.probe_resp.timestamp = ((u64)ts.tv.sec*1000000) + ts.tv.nsec/1000;
600
-#else
616
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)
601617 struct timespec ts;
602618 ts = ktime_to_timespec(ktime_get_boottime());
619
+ tsf = (u64)ts.tv_sec * 1000000 + div_u64(ts.tv_nsec, 1000);
620
+ mgmt->u.probe_resp.timestamp = tsf;
621
+#else
622
+ struct timespec64 ts;
623
+ ts = ktime_to_timespec64(ktime_get_boottime());
603624 tsf = (u64)ts.tv_sec * 1000000 + div_u64(ts.tv_nsec, 1000);
604625 mgmt->u.probe_resp.timestamp = tsf;
605626 #endif
....@@ -613,7 +634,7 @@
613634 CFG80211_BSS_FTYPE_UNKNOWN,
614635 #endif
615636 mgmt->bssid, tsf, capability, beacon_interval,
616
- ie, ielen, ind->rssi * 100, GFP_KERNEL);
637
+ ie, ielen, ind->rssi * 100, GFP_ATOMIC);
617638 }
618639
619640 if (bss != NULL)
....@@ -719,9 +740,9 @@
719740 memcpy(sta->ac_param, ind->ac_param, sizeof(sta->ac_param));
720741 rwnx_txq_sta_init(rwnx_hw, sta, txq_status);
721742 rwnx_txq_tdls_vif_init(rwnx_vif);
722
- #if 0
743
+#ifdef CONFIG_DEBUG_FS
723744 rwnx_dbgfs_register_rc_stat(rwnx_hw, sta);
724
- #endif
745
+#endif
725746 rwnx_mu_group_sta_init(sta, NULL);
726747 /* Look for TDLS Channel Switch Prohibited flag in the Extended Capability
727748 * Information Element*/
....@@ -730,6 +751,9 @@
730751 extcap = (void *)(extcap_ie);
731752 rwnx_vif->tdls_chsw_prohibited = extcap->ext_capab[4] & WLAN_EXT_CAPA5_TDLS_CH_SW_PROHIBITED;
732753 }
754
+
755
+ if (rwnx_vif->wep_enabled)
756
+ rwnx_vif->wep_auth_err = false;
733757
734758 #ifdef CONFIG_RWNX_BFMER
735759 /* If Beamformer feature is activated, check if features can be used
....@@ -819,7 +843,7 @@
819843 {
820844 struct sm_disconnect_ind *ind = (struct sm_disconnect_ind *)msg->param;
821845 struct rwnx_vif *rwnx_vif = rwnx_hw->vif_table[ind->vif_idx];
822
- struct net_device *dev = rwnx_vif->ndev;
846
+ struct net_device *dev;
823847 #ifdef AICWF_RX_REORDER
824848 struct reord_ctrl_info *reord_info, *tmp;
825849 u8 *macaddr;
....@@ -828,6 +852,10 @@
828852
829853 RWNX_DBG(RWNX_FN_ENTRY_STR);
830854 dhcped = 0;
855
+
856
+ if (!rwnx_vif)
857
+ return 0;
858
+ dev = rwnx_vif->ndev;
831859
832860 if (rwnx_vif->wdev.iftype == NL80211_IFTYPE_P2P_CLIENT)
833861 rwnx_hw->is_p2p_connected = 0;
....@@ -856,7 +884,6 @@
856884 macaddr = rwnx_vif->ndev->dev_addr;
857885 printk("deinit:macaddr:%x,%x,%x,%x,%x,%x\r\n", macaddr[0], macaddr[1], macaddr[2], \
858886 macaddr[3], macaddr[4], macaddr[5]);
859
-
860887 spin_lock_bh(&rx_priv->stas_reord_lock);
861888 list_for_each_entry_safe(reord_info, tmp, &rx_priv->stas_reord_list, list) {
862889 macaddr = rwnx_vif->ndev->dev_addr;
....@@ -893,7 +920,7 @@
893920 struct sm_external_auth_required_ind *ind =
894921 (struct sm_external_auth_required_ind *)msg->param;
895922 struct rwnx_vif *rwnx_vif = rwnx_hw->vif_table[ind->vif_idx];
896
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
923
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) || defined(CONFIG_WPA3_FOR_OLD_KERNEL)
897924 struct net_device *dev = rwnx_vif->ndev;
898925 struct cfg80211_external_auth_params params;
899926
....@@ -989,8 +1016,9 @@
9891016 }
9901017
9911018 rwnx_txq_sta_init(rwnx_hw, rwnx_sta, txq_status);
1019
+#ifdef CONFIG_DEBUG_FS
9921020 rwnx_dbgfs_register_rc_stat(rwnx_hw, rwnx_sta);
993
-
1021
+#endif
9941022 #ifdef CONFIG_RWNX_BFMER
9951023 // TODO: update indication to contains vht capabilties
9961024 if (rwnx_hw->mod_params->bfmer)
....@@ -1011,7 +1039,9 @@
10111039 list_del_init(&rwnx_sta->list);
10121040
10131041 rwnx_txq_sta_deinit(rwnx_hw, rwnx_sta);
1042
+#ifdef CONFIG_DEBUG_FS
10141043 rwnx_dbgfs_unregister_rc_stat(rwnx_hw, rwnx_sta);
1044
+#endif
10151045 } else {
10161046 WARN_ON(0);
10171047 }
....@@ -1027,7 +1057,9 @@
10271057 list_del_init(&rwnx_sta->list);
10281058
10291059 rwnx_txq_sta_deinit(rwnx_hw, rwnx_sta);
1060
+#ifdef CONFIG_DEBUG_FS
10301061 rwnx_dbgfs_unregister_rc_stat(rwnx_hw, rwnx_sta);
1062
+#endif
10311063 } else {
10321064 WARN_ON(0);
10331065 }
....@@ -1064,7 +1096,9 @@
10641096 /* Check if element has been deleted */
10651097 if (ind->delete) {
10661098 if (found) {
1099
+#ifdef CREATE_TRACE_POINTS
10671100 trace_mesh_delete_path(mesh_path);
1101
+#endif
10681102 /* Remove element from list */
10691103 list_del_init(&mesh_path->list);
10701104 /* Free the element */
....@@ -1074,7 +1108,9 @@
10741108 if (found) {
10751109 // Update the Next Hop STA
10761110 mesh_path->p_nhop_sta = &rwnx_hw->sta_table[ind->nhop_sta_idx];
1111
+#ifdef CREATE_TRACE_POINTS
10771112 trace_mesh_update_path(mesh_path);
1113
+#endif
10781114 } else {
10791115 // Allocate a Mesh Path structure
10801116 mesh_path = (struct rwnx_mesh_path *)kmalloc(sizeof(struct rwnx_mesh_path), GFP_ATOMIC);
....@@ -1088,8 +1124,9 @@
10881124
10891125 // Insert the path in the list of path
10901126 list_add_tail(&mesh_path->list, &rwnx_vif->ap.mpath_list);
1091
-
1127
+#ifdef CREATE_TRACE_POINTS
10921128 trace_mesh_create_path(mesh_path);
1129
+#endif
10931130 }
10941131 }
10951132 }
....@@ -1164,8 +1201,6 @@
11641201 {
11651202 RWNX_DBG(RWNX_FN_ENTRY_STR);
11661203
1167
- rwnx_error_ind(rwnx_hw);
1168
-
11691204 return 0;
11701205 }
11711206
....@@ -1185,6 +1220,7 @@
11851220 [MSG_I(MM_P2P_NOA_UPD_IND)] = rwnx_rx_p2p_noa_upd_ind,
11861221 [MSG_I(MM_RSSI_STATUS_IND)] = rwnx_rx_rssi_status_ind,
11871222 [MSG_I(MM_PKTLOSS_IND)] = rwnx_rx_pktloss_notify_ind,
1223
+ [MSG_I(MM_APM_STALOSS_IND)] = rwnx_apm_staloss_ind,
11881224 };
11891225
11901226 static msg_cb_fct scan_hdlrs[MSG_I(SCANU_MAX)] = {
....@@ -1247,3 +1283,44 @@
12471283 rwnx_hw->cmd_mgr->msgind(rwnx_hw->cmd_mgr, msg,
12481284 msg_hdlrs[MSG_T(msg->id)][MSG_I(msg->id)]);
12491285 }
1286
+
1287
+void rwnx_rx_handle_print(struct rwnx_hw *rwnx_hw, u8 *msg, u32 len)
1288
+{
1289
+ u8 *data_end = NULL;
1290
+ (void)data_end;
1291
+
1292
+ if (!rwnx_hw || !rwnx_hw->fwlog_en) {
1293
+ pr_err("FWLOG-OVFL: %s", msg);
1294
+ return;
1295
+ }
1296
+
1297
+ printk("FWLOG: %s", msg);
1298
+
1299
+#ifdef CONFIG_RWNX_DEBUGFS
1300
+ data_end = rwnx_hw->debugfs.fw_log.buf.dataend;
1301
+
1302
+ if (!rwnx_hw->debugfs.fw_log.buf.data)
1303
+ return ;
1304
+
1305
+ //printk("end=%lx, len=%d\n", (unsigned long)rwnx_hw->debugfs.fw_log.buf.end, len);
1306
+
1307
+ spin_lock_bh(&rwnx_hw->debugfs.fw_log.lock);
1308
+
1309
+ if (rwnx_hw->debugfs.fw_log.buf.end + len > data_end) {
1310
+ int rem = data_end - rwnx_hw->debugfs.fw_log.buf.end;
1311
+ memcpy(rwnx_hw->debugfs.fw_log.buf.end, msg, rem);
1312
+ memcpy(rwnx_hw->debugfs.fw_log.buf.data, &msg[rem], len - rem);
1313
+ rwnx_hw->debugfs.fw_log.buf.end = rwnx_hw->debugfs.fw_log.buf.data + (len - rem);
1314
+ } else {
1315
+ memcpy(rwnx_hw->debugfs.fw_log.buf.end, msg, len);
1316
+ rwnx_hw->debugfs.fw_log.buf.end += len;
1317
+ }
1318
+
1319
+ rwnx_hw->debugfs.fw_log.buf.size += len;
1320
+ if (rwnx_hw->debugfs.fw_log.buf.size > FW_LOG_SIZE)
1321
+ rwnx_hw->debugfs.fw_log.buf.size = FW_LOG_SIZE;
1322
+
1323
+ spin_unlock_bh(&rwnx_hw->debugfs.fw_log.lock);
1324
+#endif
1325
+}
1326
+