1 /****************************************************************************** 2 * 3 * Copyright(c) 2019 - 2020 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 #ifndef __PHL_SOUND_H__ 16 #define __PHL_SOUND_H__ 17 18 #define MAX_SND_GRP_NUM 4 19 #define MAX_SND_HE_BFRP_NUM 2 20 #define MAX_SND_HE_BFRP_USER_NUM 4 21 #define MAX_SND_VHT_BFRP_NUM 3 22 23 #define SND_PROC_DEFAULT_PERIOD 200 /* ms */ 24 #define SND_PROC_DEFAULT_TIMEOUT 10 /* ms */ 25 26 /* MAX_NUM_STA_SND_GRP :phl sounding design limit = 4, hw/fw support maximum 8 STA in a sounding frame exchange*/ 27 #define MAX_NUM_STA_SND_GRP 4 28 29 enum snd_type { 30 PHL_SND_TYPE_INVALID, 31 PHL_SND_TYPE_VHT_HW, 32 PHL_SND_TYPE_VHT_SW, 33 PHL_SND_TYPE_HE_HW, 34 PHL_SND_TYPE_HE_SW 35 }; 36 37 enum snd_fb_type { 38 PHL_SND_FB_TYPE_SU, 39 PHL_SND_FB_TYPE_MU, 40 PHL_SND_FB_TYPE_CQI 41 }; 42 43 enum snd_status { 44 PHL_SND_STS_PENDING, 45 PHL_SND_STS_ON_PROC, 46 PHL_SND_STS_SUCCESS, 47 PHL_SND_STS_FAILURE 48 }; 49 50 enum snd_grp_tier { 51 PHL_SND_GRP_TIER_0, /* TIER_0 Group will free sounding resource in state SND_PROC_TERMINATE or group removed*/ 52 PHL_SND_GRP_TIER_1 /* TIER_1 Group will free sounding resource in next SND_PROC_IDLE*/ 53 }; 54 55 enum snd_test_flag { 56 PHL_SND_TEST_F_NONE = 0, /* default value */ 57 PHL_SND_TEST_F_ONE_TIME = BIT(0), /* Test mode : only sounding one time */ 58 PHL_SND_TEST_F_FIX_STA = BIT(1), /* forced SND STAs (skip grouping and check TP) */ 59 PHL_SND_TEST_F_GRP_SND_PARA = BIT(2), /* Fixed SND STA's Feedback Type or BW from snd->fix_param */ 60 PHL_SND_TEST_F_GRP_EN_BF_FIX = BIT(3), /* Enable grp->en_fix_mode in grouping function */ 61 PHL_SND_TEST_F_PASS_STS_CHK = BIT(4) /* by pass sounding status check when post config */ 62 }; 63 64 struct npda_dialog_token { 65 u8 reserved:1; 66 u8 he:1; 67 u8 token:6; 68 }; 69 70 struct vht_ndpa_sta_info { 71 u16 aid12:12; 72 #define VHT_NDPA_FB_TYPE_SU 0 73 #define VHT_NDPA_FB_TYPE_MU 1 74 u16 feedback_type:1; 75 u16 nc:3; 76 }; 77 78 struct he_ndpa_sta_info { 79 u32 aid:11; 80 u32 bw:14; 81 u32 fb_ng:2; 82 u32 disambiguation:1; 83 u32 cb:1; 84 u32 nc:3; 85 }; 86 87 struct phl_snd_sta { 88 u8 valid; 89 u16 macid; 90 enum channel_width bw; /* Sounding BW */ 91 enum snd_fb_type snd_fb_t; /* Sounding feedback type : SU/MU/CQI */ 92 u32 npda_sta_info; /* VHT/HE NDPA STA info*/ 93 enum snd_status snd_sts; 94 /* Query resource in SND PROC */ 95 void *bf_entry;/* HAL BF Entry for sounding */ 96 }; 97 98 99 struct phl_snd_grp { 100 u8 gidx; 101 enum snd_type snd_type; 102 enum snd_grp_tier grp_tier; 103 u8 wrole_idx; 104 u8 band; 105 u8 num_sta; 106 struct phl_snd_sta sta[MAX_NUM_STA_SND_GRP]; 107 enum snd_status snd_sts; 108 u8 en_fix_mode; /* post confg forced mode setting */ 109 /** 110 * en_swap_mode : Only TIER_0 MU group support. When swap mode is enable, 111 * each MU Entry will use two CSI MU buffer. Therefore, it cannan skip Disable 112 * MU in Preconfig when next round sounding 113 **/ 114 u8 en_swap_mode; 115 u8 skip_post_cfg;/* 1: SKIP ALL; BIT1:Skip Group, BIT2:Skip GID, BIT3:Skip STA */ 116 }; 117 118 119 /* for whole phl snd fsm module fixed mode, only worked if snd_param->test_flag != 0 */ 120 struct phl_snd_fix_param { 121 u8 en_fix_gidx; 122 u8 en_fix_fb_type; 123 u8 en_fix_sta; 124 u8 en_fix_snd_bw; 125 u8 grp_idx; 126 enum snd_fb_type snd_fb_type; 127 u16 sta_macid[MAX_NUM_STA_SND_GRP]; 128 enum channel_width bw[MAX_NUM_STA_SND_GRP]; 129 u8 f_ru_tbl_20[MAX_SND_HE_BFRP_USER_NUM][MAX_SND_HE_BFRP_USER_NUM]; 130 u8 f_ru_tbl_80[MAX_SND_HE_BFRP_USER_NUM][MAX_SND_HE_BFRP_USER_NUM]; 131 }; 132 133 struct phl_sound_param { 134 void *m_wrole; 135 struct phl_snd_grp snd_grp[MAX_SND_GRP_NUM]; 136 u32 grp_used_map; 137 u8 cur_proc_grp_idx; 138 u8 pre_proc_grp_idx; 139 u8 snd_func_grp_num; 140 u8 snd_dialog_token; 141 u8 snd_proc_timeout_ms; 142 u32 proc_start_time; 143 u8 snd_proc_period; 144 bool bypass_snd_sts_chk; 145 u32 test_flag; 146 struct phl_snd_fix_param fix_param; 147 u8 snd_fail_counter; 148 }; 149 struct phl_snd_ops 150 { 151 enum rtw_phl_status (*snd_send_ndpa)(void *drv_priv, 152 struct rtw_wifi_role_t *wrole, 153 u8 *snd_dialog_tkn, 154 u32 *ndpa_sta, 155 enum channel_width snd_bw); 156 }; 157 158 struct phl_sound_obj { 159 #ifdef CONFIG_FSM 160 struct fsm_main *fsm; 161 struct fsm_obj *fsm_obj; 162 #endif 163 struct phl_sound_param snd_param; 164 struct phl_snd_ops ops; 165 166 struct phl_info_t *phl_info; 167 void *iface; 168 169 u8 snd_in_progress; 170 u8 is_terminated; 171 172 _os_lock snd_lock; 173 /* snd test */ 174 u8 wrole_idx; 175 176 /* snd cmd disp related */ 177 u8 msg_busy; 178 _os_lock cmd_lock; 179 }; 180 #ifdef CONFIG_FSM 181 enum rtw_phl_status phl_snd_new_obj( 182 struct fsm_main *fsm, 183 struct phl_info_t *phl_info); 184 185 #endif 186 /* phl sounding intern api*/ 187 enum rtw_phl_status phl_snd_func_snd_init(struct phl_info_t *phl_info); 188 189 enum rtw_phl_status phl_snd_func_pre_config(struct phl_info_t *phl_info); 190 191 /* phl sounding extern api*/ 192 enum rtw_phl_status 193 rtw_phl_sound_start(void *phl, u8 wrole_idx, u8 st_dlg_tkn, u8 period, u8 test_flag); 194 195 enum rtw_phl_status 196 rtw_phl_sound_abort(void *phl); 197 198 enum rtw_phl_status 199 rtw_phl_sound_down_ev(void *phl); 200 201 void rtw_phl_snd_fix_tx_he_mu(struct phl_info_t *phl_info, u8 gid, bool en); 202 203 /* snd func grp */ 204 struct phl_snd_grp * 205 phl_snd_get_grp_byidx(struct phl_info_t *phl_info, u8 gidx); 206 207 void 208 phl_snd_func_remove_grp_all(struct phl_info_t *phl_info); 209 210 enum rtw_phl_status 211 phl_snd_func_grouping(struct phl_info_t *phl_info, u8 wroleidx); 212 213 /* snd proc resource */ 214 enum rtw_phl_status 215 phl_snd_proc_get_res( 216 struct phl_info_t *phl_info, struct phl_snd_grp *grp, u8 *nsta); 217 218 enum rtw_phl_status 219 phl_snd_proc_release_res(struct phl_info_t *phl_info, struct phl_snd_grp *grp); 220 221 /* snd proc precfg */ 222 enum rtw_phl_status 223 phl_snd_proc_precfg(struct phl_info_t *phl_info, struct phl_snd_grp *grp); 224 225 226 /* snd proc busy cmd to fw */ 227 enum rtw_phl_status 228 phl_snd_proc_start_sounding_fw(struct phl_info_t *phl_info, 229 struct phl_snd_grp *grp); 230 231 /* snd proc postcfg */ 232 enum rtw_phl_status 233 phl_snd_proc_postcfg(struct phl_info_t *phl_info, struct phl_snd_grp *grp); 234 235 enum rtw_phl_status 236 phl_snd_proc_chk_condition(struct phl_info_t *phl_info, struct phl_snd_grp *grp); 237 238 void 239 phl_snd_proc_chk_prev_grp(struct phl_info_t *phl_info, 240 struct phl_snd_grp *grp); 241 242 enum rtw_phl_status 243 phl_snd_polling_pri_sta_sts(struct phl_info_t *phl_info, 244 struct phl_snd_grp *grp); 245 void 246 phl_snd_mac_ctrl(struct phl_info_t *phl_info, 247 struct rtw_wifi_role_t *wrole, u8 ctrl); 248 #endif 249