1 /******************************************************************************
2 *
3 * Copyright(c) 2019 Realtek Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 *****************************************************************************/
15 #define _HAL_DBCC_C_
16 #include "hal_headers.h"
17
18 #ifdef CONFIG_DBCC_SUPPORT
19 enum rtw_hal_status
rtw_hal_dbcc_pre_cfg(void * hal,struct rtw_phl_com_t * phl_com,bool dbcc_en)20 rtw_hal_dbcc_pre_cfg(void *hal, struct rtw_phl_com_t *phl_com, bool dbcc_en)
21 {
22 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
23 struct rtw_hal_com_t *hal_com = hal_info->hal_com;
24 enum rtw_hal_status hsts = RTW_HAL_STATUS_FAILURE;
25
26 hal_com->dbcc_en = (dbcc_en) ? true : false;
27
28 /*mac_dbcc_pre_cfg*/
29 hsts = rtw_hal_mac_dbcc_pre_cfg(phl_com, hal_info, dbcc_en);
30 if (hsts != RTW_HAL_STATUS_SUCCESS) {
31 PHL_ASSERT("%s mac_dbcc_pre_cfg failed\n", __func__);
32 hal_com->dbcc_en = false;
33 goto exit_func;
34 }
35 /*phy_dbcc_pre_cfg*/
36 hsts = rtw_hal_phy_dbcc_pre_cfg(hal_info, phl_com, dbcc_en);
37 if (hsts != RTW_HAL_STATUS_SUCCESS) {
38 PHL_ASSERT("%s phy_dbcc_pre_cfg failed\n", __func__);
39 hal_com->dbcc_en = false;
40 goto exit_func;
41 }
42
43 PHL_INFO("%s-%s done and success\n", __func__, (dbcc_en) ? "EN" : "DIS");
44
45 exit_func:
46
47 return hsts;
48 }
49
50 enum rtw_hal_status
rtw_hal_dbcc_cfg(void * hal,struct rtw_phl_com_t * phl_com,bool dbcc_en)51 rtw_hal_dbcc_cfg(void *hal, struct rtw_phl_com_t *phl_com, bool dbcc_en)
52 {
53 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
54 struct rtw_hal_com_t *hal_com = hal_info->hal_com;
55 enum rtw_hal_status hsts = RTW_HAL_STATUS_FAILURE;
56
57 /*if(phl_com->drv_mode == RTW_DRV_MODE_MP)*/
58
59 if(hal_info->hal_com->chip_id ==CHIP_WIFI6_8852B)
60 {
61 PHL_ASSERT("%s 8852B doesn't support dbcc\n", __func__);
62 hal_com->dbcc_en = false;
63 goto exit_func;
64 }
65
66 #if 1
67 /* band 0 tx pause */
68 rtw_hal_tx_pause(hal_com, HW_BAND_0, true, PAUSE_RSON_DBCC);
69 #else
70 /* mac-id pause - rtw_hal_mac_set_macid_pause */
71 rtw_hal_mac_set_macid_pause(hal_info->hal_com, 0, true);
72 rtw_hal_mac_set_macid_pause(hal_info->hal_com, 1, true);
73 #endif
74 /* FW tx pause , BT tx pause*/
75 /* bb cca pause */
76 rtw_hal_bb_ctrl_rx_cca(hal_info->hal_com, false, HW_PHY_0);
77
78 /*mac_dbcc_cfg*/
79 hsts = rtw_hal_mac_dbcc_cfg(phl_com, hal_info, dbcc_en);
80 if (hsts != RTW_HAL_STATUS_SUCCESS) {
81 PHL_ASSERT("%s mac_dbcc_cfg failed\n", __func__);
82 hal_com->dbcc_en = false;
83 goto exit_func;
84 }
85
86 /*bb_dbcc_cfg*/
87 hsts = rtw_hal_phy_dbcc_cfg(hal_info, phl_com, dbcc_en);
88 if (hsts != RTW_HAL_STATUS_SUCCESS) {
89 PHL_ASSERT("%s phy_dbcc_cfg failed\n", __func__);
90 hal_com->dbcc_en = false;
91 goto exit_func;
92 }
93
94 #if 1
95 /* band 0 tx unpause */
96 rtw_hal_tx_pause(hal_com, HW_BAND_0, false, PAUSE_RSON_DBCC);
97 #else
98 /* mac-id unpause - rtw_hal_mac_set_macid_pause */
99 rtw_hal_mac_set_macid_pause(hal_info->hal_com, 0, false);
100 rtw_hal_mac_set_macid_pause(hal_info->hal_com, 1, false);
101 #endif
102
103 /* FW tx unpause , BT tx unpause*/
104 /* bb cca unpause */
105 rtw_hal_bb_ctrl_rx_cca(hal_info->hal_com, true, HW_PHY_0);
106
107 PHL_INFO("%s-%s done and success\n", __func__, (dbcc_en) ? "EN" : "DIS");
108
109 /*mac role recovery*/
110 /*if (has_ap)*/
111 /*mac_port_cfg(BCN_EN-MAC_AX_PCFG_TX_SW)*/
112 /*mac_port_cfg(BCN_DIS-MAC_AX_PCFG_MBSSID_EN)*/
113 exit_func:
114
115 return hsts;
116 }
117
118 enum rtw_hal_status
rtw_hal_clean_tx_queue(void * hal)119 rtw_hal_clean_tx_queue(void *hal)
120 {
121 #if 0
122 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
123 struct rtw_hal_com_t *hal_com = hal_info->hal_com;
124 u32 start_time;
125
126 start_time = _os_get_cur_time_ms();
127
128 // set retry limit =1 -rtw_hal_mac_set_rty_lmt
129 /* rtw_hal_mac_set_rty_lmt(hal_com, sta->macid,
130 rts_txcnt_lmt_sel, rts_txcnt_lmt,
131 data_txcnt_lmt_sel, data_tx_cnt_lmt);*/
132
133 //polling mac_is_txq_empty - rtw_hal_mac_is_txq_empty
134 //chk_allq_empty - rtw_hal_mac_is_allq_empty
135
136 //polling TX idle
137 //FW tx pause/unpause
138
139 // if (has ap)
140 //polling HIQ & WLCPU queue,
141 //disable beacon TX mode
142 //mac_port_cfg(BCN_DIS-MAC_AX_PCFG_TX_SW)
143 //mac_port_cfg(BCN_DIS-MAC_AX_PCFG_MBSSID_EN)
144
145 PHL_INFO("[DBCC] %s: pass %u ms\n", __FUNCTION__,
146 _get_passing_time_ms(start_time));
147 #endif
148 return RTW_HAL_STATUS_SUCCESS;
149 }
150
151 enum rtw_hal_status
rtw_hal_dbcc_tx_cnt(void * hal,struct rtw_phl_com_t * phl_com,u8 band)152 rtw_hal_dbcc_tx_cnt(void *hal, struct rtw_phl_com_t *phl_com, u8 band)
153 {
154 #if 1 /* no rtw_hal_mac_get_tx_cnt api */
155 return RTW_HAL_STATUS_SUCCESS;
156 #else
157 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
158
159 return rtw_hal_mac_get_tx_cnt(hal_info, band, MAC_AX_TX_ALLTYPE, NULL);
160 #endif
161 }
162
163 enum rtw_hal_status
rtw_hal_dbcc_reset_tx_cnt(void * hal,struct rtw_phl_com_t * phl_com,u8 band)164 rtw_hal_dbcc_reset_tx_cnt(void *hal, struct rtw_phl_com_t *phl_com, u8 band)
165 {
166 #if 1 /* no rtw_hal_mac_set_reset_tx_cnt */
167 return RTW_HAL_STATUS_SUCCESS;
168 #else
169 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
170
171 return rtw_hal_mac_set_reset_tx_cnt(hal_info, band);
172 #endif
173 }
174 #endif /*CONFIG_DBCC_SUPPORT*/
175