tzh
2024-08-15 d4a1bd480003f3e1a0590bc46fbcb24f05652ca7
longan/kernel/linux-4.9/drivers/net/wireless/aic8800/aic8800_fdrv/rwnx_msg_tx.c
old mode 100644new mode 100755
....@@ -19,6 +19,7 @@
1919 #include "rwnx_compat.h"
2020 #include "rwnx_cmds.h"
2121 #include "aicwf_txrxif.h"
22
+#include "rwnx_wakelock.h"
2223
2324 const struct mac_addr mac_addr_bcst = {{0xFFFF, 0xFFFF, 0xFFFF}};
2425
....@@ -227,6 +228,7 @@
227228
228229 //RWNX_DBG(RWNX_FN_ENTRY_STR);
229230
231
+ rwnx_wakeup_lock_timeout(rwnx_hw->ws_tx, jiffies_to_msecs(5));
230232 #ifdef AICWF_USB_SUPPORT
231233 if (rwnx_hw->usbdev->state == USB_DOWN_ST) {
232234 rwnx_msg_free(rwnx_hw, msg_params);
....@@ -286,8 +288,13 @@
286288 empty = list_empty(&rwnx_hw->cmd_mgr->cmds);
287289 spin_unlock_bh(&rwnx_hw->cmd_mgr->lock);
288290 if (!empty) {
289
- udelay(100);
290
- printk("check cmdqueue empty\n");
291
+ if (in_softirq()) {
292
+ printk("in_softirq:check cmdqueue empty\n");
293
+ mdelay(10);
294
+ } else {
295
+ printk("check cmdqueue empty\n");
296
+ msleep(50);
297
+ }
291298 }
292299 } while (!empty);//wait for cmd queue empty
293300 }
....@@ -320,6 +327,7 @@
320327
321328 RWNX_DBG(RWNX_FN_ENTRY_STR);
322329
330
+ rwnx_wakeup_lock_timeout(rwnx_hw->ws_tx, jiffies_to_msecs(5));
323331 msg = container_of((void *)msg_params, struct lmac_msg, param);
324332
325333 //nonblock = is_non_blocking_msg(msg->id);
....@@ -646,7 +654,8 @@
646654 }
647655
648656 int rwnx_send_roc(struct rwnx_hw *rwnx_hw, struct rwnx_vif *vif,
649
- struct ieee80211_channel *chan, unsigned int duration)
657
+ struct ieee80211_channel *chan, unsigned int duration,
658
+ struct mm_remain_on_channel_cfm *roc_cfm)
650659 {
651660 struct mm_remain_on_channel_req *req;
652661 struct cfg80211_chan_def chandef;
....@@ -674,7 +683,7 @@
674683 req->tx_power = chan_to_fw_pwr(chan->max_power);
675684
676685 /* Send the MM_REMAIN_ON_CHANNEL_REQ message to LMAC FW */
677
- return rwnx_send_msg(rwnx_hw, req, 1, MM_REMAIN_ON_CHANNEL_CFM, NULL);
686
+ return rwnx_send_msg(rwnx_hw, req, 1, MM_REMAIN_ON_CHANNEL_CFM, roc_cfm);
678687 }
679688
680689 int rwnx_send_cancel_roc(struct rwnx_hw *rwnx_hw)
....@@ -919,6 +928,8 @@
919928 rf_calib_req->param_alpha = 0x0c34c008;
920929 rf_calib_req->bt_calib_en = 0;
921930 rf_calib_req->bt_calib_param = 0x264203;
931
+ rf_calib_req->xtal_cap = 0;
932
+ rf_calib_req->xtal_cap_fine = 0;
922933
923934 /* Send the MM_SET_RF_CALIB_REQ message to UMAC FW */
924935 error = rwnx_send_msg(rwnx_hw, rf_calib_req, 1, MM_SET_RF_CALIB_CFM, cfm);
....@@ -949,28 +960,173 @@
949960 return error;
950961 };
951962
952
-int rwnx_send_get_sta_txinfo_req(struct rwnx_hw *rwnx_hw, u8_l sta_idx, struct mm_get_sta_txinfo_cfm *cfm)
963
+int rwnx_send_get_sta_info_req(struct rwnx_hw *rwnx_hw, u8_l sta_idx, struct mm_get_sta_info_cfm *cfm)
953964 {
954
- struct mm_get_sta_txinfo_req *get_txinfo_req;
965
+ struct mm_get_sta_info_req *get_info_req;
955966 int error;
956967
957968
958
- /* Build the MM_GET_STA_TXINFO_REQ message */
959
- get_txinfo_req = rwnx_msg_zalloc(MM_GET_STA_TXINFO_REQ, TASK_MM, DRV_TASK_ID,
960
- sizeof(struct mm_get_sta_txinfo_req));
969
+ /* Build the MM_GET_STA_INFO_REQ message */
970
+ get_info_req = rwnx_msg_zalloc(MM_GET_STA_INFO_REQ, TASK_MM, DRV_TASK_ID,
971
+ sizeof(struct mm_get_sta_info_req));
961972
962
- if (!get_txinfo_req) {
973
+ if (!get_info_req) {
963974 return -ENOMEM;
964975 }
965976
966
- get_txinfo_req->sta_idx = 1;
977
+ get_info_req->sta_idx = sta_idx;
967978
968
- /* Send the MM_GET_STA_TXINFO_REQ message to UMAC FW */
969
- error = rwnx_send_msg(rwnx_hw, get_txinfo_req, 1, MM_GET_STA_TXINFO_CFM, cfm);
979
+ /* Send the MM_GET_STA_INFO_REQ message to UMAC FW */
980
+ error = rwnx_send_msg(rwnx_hw, get_info_req, 1, MM_GET_STA_INFO_CFM, cfm);
970981
971982 return error;
972983 };
973984
985
+int rwnx_send_set_stack_start_req(struct rwnx_hw *rwnx_hw, u8_l on, u8_l efuse_valid, u8_l set_vendor_info,
986
+ u8_l fwtrace_redir_en, struct mm_set_stack_start_cfm *cfm)
987
+{
988
+ struct mm_set_stack_start_req *req;
989
+ int error;
990
+
991
+ /* Build the MM_SET_STACK_START_REQ message */
992
+ req = rwnx_msg_zalloc(MM_SET_STACK_START_REQ, TASK_MM, DRV_TASK_ID, sizeof(struct mm_set_stack_start_req));
993
+
994
+ if (!req) {
995
+ return -ENOMEM;
996
+ }
997
+
998
+ req->is_stack_start = on;
999
+ req->efuse_valid = efuse_valid;
1000
+ req->set_vendor_info = set_vendor_info;
1001
+ req->fwtrace_redir = fwtrace_redir_en;
1002
+ /* Send the MM_SET_STACK_START_REQ message to UMAC FW */
1003
+ error = rwnx_send_msg(rwnx_hw, req, 1, MM_SET_STACK_START_CFM, cfm);
1004
+
1005
+ return error;
1006
+}
1007
+
1008
+int rwnx_send_txop_req(struct rwnx_hw *rwnx_hw, uint16_t *txop, u8_l long_nav_en, u8_l cfe_en)
1009
+{
1010
+ struct mm_set_txop_req *req;
1011
+ int error;
1012
+
1013
+ /* Build the MM_SET_TXOP_REQ message */
1014
+ req = rwnx_msg_zalloc(MM_SET_TXOP_REQ, TASK_MM, DRV_TASK_ID, sizeof(struct mm_set_txop_req));
1015
+
1016
+ if (!req) {
1017
+ return -ENOMEM;
1018
+ }
1019
+
1020
+ req->txop_bk = txop[0];
1021
+ req->txop_be = txop[1];
1022
+ req->txop_vi = txop[2];
1023
+ req->txop_vo = txop[3];
1024
+ req->long_nav_en = long_nav_en;
1025
+ req->cfe_en = cfe_en;
1026
+ /* Send the MM_SET_TXOP_REQ message to UMAC FW */
1027
+ error = rwnx_send_msg(rwnx_hw, req, 1, MM_SET_TXOP_CFM, NULL);
1028
+
1029
+ return error;
1030
+}
1031
+
1032
+int rwnx_send_get_fw_version_req(struct rwnx_hw *rwnx_hw, struct mm_get_fw_version_cfm *cfm)
1033
+{
1034
+ void *req;
1035
+ int error;
1036
+
1037
+ /* Build the MM_GET_FW_VERSION_REQ message */
1038
+ req = rwnx_msg_zalloc(MM_GET_FW_VERSION_REQ, TASK_MM, DRV_TASK_ID, sizeof(u8));
1039
+
1040
+ if (!req) {
1041
+ return -ENOMEM;
1042
+ }
1043
+
1044
+ /* Send the MM_GET_FW_VERSION_REQ message to UMAC FW */
1045
+ error = rwnx_send_msg(rwnx_hw, req, 1, MM_GET_FW_VERSION_CFM, cfm);
1046
+
1047
+ return error;
1048
+}
1049
+
1050
+
1051
+int rwnx_send_txpwr_idx_req(struct rwnx_hw *rwnx_hw)
1052
+{
1053
+ struct mm_set_txpwr_idx_req *txpwr_idx_req;
1054
+ txpwr_idx_conf_t *txpwr_idx;
1055
+ int error;
1056
+
1057
+ RWNX_DBG(RWNX_FN_ENTRY_STR);
1058
+
1059
+ /* Build the MM_SET_TXPWR_IDX_REQ message */
1060
+ txpwr_idx_req = rwnx_msg_zalloc(MM_SET_TXPWR_IDX_REQ, TASK_MM, DRV_TASK_ID,
1061
+ sizeof(struct mm_set_txpwr_idx_req));
1062
+
1063
+ if (!txpwr_idx_req) {
1064
+ return -ENOMEM;
1065
+ }
1066
+
1067
+ txpwr_idx = &txpwr_idx_req->txpwr_idx;
1068
+ txpwr_idx->enable = 1;
1069
+ txpwr_idx->dsss = 9;
1070
+ txpwr_idx->ofdmlowrate_2g4 = 8;
1071
+ txpwr_idx->ofdm64qam_2g4 = 8;
1072
+ txpwr_idx->ofdm256qam_2g4 = 8;
1073
+ txpwr_idx->ofdm1024qam_2g4 = 8;
1074
+ txpwr_idx->ofdmlowrate_5g = 11;
1075
+ txpwr_idx->ofdm64qam_5g = 10;
1076
+ txpwr_idx->ofdm256qam_5g = 9;
1077
+ txpwr_idx->ofdm1024qam_5g = 9;
1078
+
1079
+ get_userconfig_txpwr_idx(txpwr_idx);
1080
+
1081
+ if (txpwr_idx->enable == 0) {
1082
+ rwnx_msg_free(rwnx_hw, txpwr_idx_req);
1083
+ return 0;
1084
+ } else {
1085
+ /* Send the MM_SET_TXPWR_IDX_REQ message to UMAC FW */
1086
+ error = rwnx_send_msg(rwnx_hw, txpwr_idx_req, 1, MM_SET_TXPWR_IDX_CFM, NULL);
1087
+
1088
+ return error;
1089
+ }
1090
+};
1091
+
1092
+int rwnx_send_txpwr_ofst_req(struct rwnx_hw *rwnx_hw)
1093
+{
1094
+ struct mm_set_txpwr_ofst_req *txpwr_ofst_req;
1095
+ txpwr_ofst_conf_t *txpwr_ofst;
1096
+ int error;
1097
+
1098
+ RWNX_DBG(RWNX_FN_ENTRY_STR);
1099
+
1100
+ /* Build the MM_SET_TXPWR_OFST_REQ message */
1101
+ txpwr_ofst_req = rwnx_msg_zalloc(MM_SET_TXPWR_OFST_REQ, TASK_MM, DRV_TASK_ID,
1102
+ sizeof(struct mm_set_txpwr_ofst_req));
1103
+
1104
+ if (!txpwr_ofst_req) {
1105
+ return -ENOMEM;
1106
+ }
1107
+
1108
+ txpwr_ofst = &txpwr_ofst_req->txpwr_ofst;
1109
+ txpwr_ofst->enable = 1;
1110
+ txpwr_ofst->chan_1_4 = 0;
1111
+ txpwr_ofst->chan_5_9 = 0;
1112
+ txpwr_ofst->chan_10_13 = 0;
1113
+ txpwr_ofst->chan_36_64 = 0;
1114
+ txpwr_ofst->chan_100_120 = 0;
1115
+ txpwr_ofst->chan_122_140 = 0;
1116
+ txpwr_ofst->chan_142_165 = 0;
1117
+
1118
+ get_userconfig_txpwr_ofst(txpwr_ofst);
1119
+
1120
+ if (txpwr_ofst->enable == 0) {
1121
+ rwnx_msg_free(rwnx_hw, txpwr_ofst_req);
1122
+ return 0;
1123
+ } else {
1124
+ /* Send the MM_SET_TXPWR_OFST_REQ message to UMAC FW */
1125
+ error = rwnx_send_msg(rwnx_hw, txpwr_ofst_req, 1, MM_SET_TXPWR_OFST_CFM, NULL);
1126
+
1127
+ return error;
1128
+ }
1129
+};
9741130
9751131 /******************************************************************************
9761132 * Control messages handling functions (FULLMAC only)
....@@ -1040,13 +1196,10 @@
10401196 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
10411197 if (wiphy->bands[NL80211_BAND_2GHZ]->iftype_data != NULL) {
10421198 he_cap = &wiphy->bands[NL80211_BAND_2GHZ]->iftype_data->he_cap;
1043
- }
10441199 #endif
10451200 #if defined(CONFIG_HE_FOR_OLD_KERNEL)
10461201 if (1) {
10471202 he_cap = &rwnx_he_capa.he_cap;
1048
- #else
1049
- {
10501203 #endif
10511204 req->he_supp = he_cap->has_he;
10521205 for (i = 0; i < ARRAY_SIZE(he_cap->he_cap_elem.mac_cap_info); i++) {
....@@ -1699,7 +1852,7 @@
16991852 if (!memcmp(P2P_WILDCARD_SSID, param->ssids[i].ssid,
17001853 P2P_WILDCARD_SSID_LEN)) {
17011854 printk("p2p scanu:%d,%d,%d\n", rwnx_vif->vif_index, rwnx_vif->is_p2p_vif, rwnx_hw->is_p2p_alive);
1702
- if (rwnx_vif->is_p2p_vif && !rwnx_hw->is_p2p_alive) {
1855
+ if (rwnx_vif == rwnx_hw->p2p_dev_vif && !rwnx_vif->up) {
17031856 err = rwnx_send_add_if (rwnx_hw, rwnx_vif->wdev.address,
17041857 RWNX_VIF_TYPE(rwnx_vif), false, &add_if_cfm);
17051858 if (err)