hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
/******************************************************************************
 *
 * Copyright(c) 2021 Realtek Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 *****************************************************************************/
#define _PHL_PS_C_
#include "phl_headers.h"
#ifdef CONFIG_POWER_SAVE
const char *phl_ps_op_mode_to_str(u8 op_mode)
{
   switch (op_mode) {
   case PS_OP_MODE_DISABLED:
       return "Disabled";
   case PS_OP_MODE_FORCE_ENABLED:
       return "Force Enabled";
   case PS_OP_MODE_AUTO:
       return "Auto";
   default:
       return "-";
   }
}
 
const char *phl_ps_ps_mode_to_str(u8 ps_mode)
{
   switch (ps_mode) {
   case PS_MODE_IPS:
       return "IPS";
   case PS_MODE_LPS:
       return "LPS";
   default:
       return "NONE";
   }
}
 
#define case_pwr_lvl(src) \
   case PS_PWR_LVL_##src: return #src
const char *phl_ps_pwr_lvl_to_str(u8 pwr_lvl)
{
   switch (pwr_lvl) {
   case_pwr_lvl(PWROFF);
   case_pwr_lvl(PWR_GATED);
   case_pwr_lvl(CLK_GATED);
   case_pwr_lvl(RF_OFF);
   case_pwr_lvl(PWRON);
   case_pwr_lvl(MAX);
   default:
       return "Undefined";
   }
}
 
u8 phl_ps_judge_pwr_lvl(u8 ps_cap, u8 ps_mode, u8 ps_en)
{
   if (!ps_en)
       return PS_PWR_LVL_PWRON;
 
   if (ps_mode == PS_MODE_IPS) {
       if (ps_cap & PS_CAP_PWR_OFF)
           return PS_PWR_LVL_PWROFF;
       else if (ps_cap & PS_CAP_PWR_GATED)
           return PS_PWR_LVL_PWR_GATED;
       else if (ps_cap & PS_CAP_CLK_GATED)
           return PS_PWR_LVL_CLK_GATED;
       else if (ps_cap & PS_CAP_RF_OFF)
           return PS_PWR_LVL_RF_OFF;
       else
           return PS_PWR_LVL_PWROFF; /* ips default support power off */
   } else if (ps_mode == PS_MODE_LPS) {
       if (ps_cap & PS_CAP_PWR_GATED)
           return PS_PWR_LVL_PWR_GATED;
       else if (ps_cap & PS_CAP_CLK_GATED)
           return PS_PWR_LVL_CLK_GATED;
       else if (ps_cap & PS_CAP_RF_OFF)
           return PS_PWR_LVL_RF_OFF;
       else if (ps_cap & PS_CAP_PWRON)
           return PS_PWR_LVL_PWRON;
       else
           return PS_PWR_LVL_PWRON; /* lps default support protocol */
   } else {
       PHL_TRACE(COMP_PHL_PS, _PHL_WARNING_, "[PS], %s(): unknown ps mode!\n", __func__);
   }
 
   return PS_PWR_LVL_PWRON;
}
 
static void _ps_ntfy_before_pwr_cfg(struct phl_info_t *phl_info, u8 ps_mode,
           u8 cur_pwr_lvl, u8 req_pwr_lvl)
{
   PHL_TRACE(COMP_PHL_PS, _PHL_DEBUG_, "[PS], %s(): \n", __func__);
 
   if (cur_pwr_lvl == PS_PWR_LVL_PWRON) { /* enter ps */
       if (req_pwr_lvl == PS_PWR_LVL_PWROFF) {
           #ifdef CONFIG_BTCOEX
           rtw_hal_btc_radio_state_ntfy(phl_info->hal, BTC_RFCTRL_WL_OFF);
           #endif
           #if defined(CONFIG_PCI_HCI) && defined(RTW_WKARD_DYNAMIC_LTR)
           phl_ltr_sw_ctrl_ntfy(phl_info->phl_com, false);
           #endif
       } else if (req_pwr_lvl <= PS_PWR_LVL_RF_OFF) {
           #ifdef CONFIG_BTCOEX
           rtw_hal_btc_radio_state_ntfy(phl_info->hal, BTC_RFCTRL_FW_CTRL);
           #endif
           #if defined(CONFIG_PCI_HCI) && defined(RTW_WKARD_DYNAMIC_LTR)
           if (req_pwr_lvl == PS_PWR_LVL_PWR_GATED)
               phl_ltr_sw_ctrl_ntfy(phl_info->phl_com, false);
           #endif
       }
   }
}
 
static void _ps_ntfy_after_pwr_cfg(struct phl_info_t *phl_info, u8 ps_mode,
           u8 cur_pwr_lvl, u8 req_pwr_lvl, u8 cfg_ok)
{
   PHL_TRACE(COMP_PHL_PS, _PHL_DEBUG_, "[PS], %s(): \n", __func__);
 
   if (cur_pwr_lvl > req_pwr_lvl) { /* enter ps */
       if (!cfg_ok) { /* fail */
           if (req_pwr_lvl == PS_PWR_LVL_PWROFF) { /* driver ips */
               #ifdef CONFIG_BTCOEX
               rtw_hal_btc_radio_state_ntfy(phl_info->hal, BTC_RFCTRL_WL_ON);
               #endif
               #if defined(CONFIG_PCI_HCI) && defined(RTW_WKARD_DYNAMIC_LTR)
               phl_ltr_sw_ctrl_ntfy(phl_info->phl_com, true);
               #endif
           } else { /* fw control */
               #ifdef CONFIG_BTCOEX
               if (ps_mode == PS_MODE_LPS)
                   rtw_hal_btc_radio_state_ntfy(phl_info->hal, BTC_RFCTRL_LPS_WL_ON);
               else
                   rtw_hal_btc_radio_state_ntfy(phl_info->hal, BTC_RFCTRL_WL_ON);
               #endif
               #if defined(CONFIG_PCI_HCI) && defined(RTW_WKARD_DYNAMIC_LTR)
               phl_ltr_sw_ctrl_ntfy(phl_info->phl_com, true);
               #endif
           }
       }
   } else { /* leave ps */
       if (cfg_ok) { /* ok */
           if (cur_pwr_lvl == PS_PWR_LVL_PWROFF) { /* driver ips */
               if (req_pwr_lvl == PS_PWR_LVL_PWRON) {
                   #ifdef CONFIG_BTCOEX
                   rtw_hal_btc_radio_state_ntfy(phl_info->hal, BTC_RFCTRL_WL_ON);
                   #endif
                   #if defined(CONFIG_PCI_HCI) && defined(RTW_WKARD_DYNAMIC_LTR)
                   phl_ltr_sw_ctrl_ntfy(phl_info->phl_com, true);
                   #endif
               }
           } else { /* fw control */
               if (req_pwr_lvl == PS_PWR_LVL_PWRON) {
                   #ifdef CONFIG_BTCOEX
                   if (ps_mode == PS_MODE_LPS)
                       rtw_hal_btc_radio_state_ntfy(phl_info->hal, BTC_RFCTRL_LPS_WL_ON);
                   else
                       rtw_hal_btc_radio_state_ntfy(phl_info->hal, BTC_RFCTRL_WL_ON);
                   #endif
                   #if defined(CONFIG_PCI_HCI) && defined(RTW_WKARD_DYNAMIC_LTR)
                   phl_ltr_sw_ctrl_ntfy(phl_info->phl_com, true);
                   #endif
               }
           }
       }
   }
}
 
enum rtw_phl_status
phl_ps_cfg_pwr_lvl(struct phl_info_t *phl_info, u8 ps_mode, u8 cur_pwr_lvl, u8 req_pwr_lvl)
{
   enum rtw_hal_status hstatus = RTW_HAL_STATUS_SUCCESS;
 
   PHL_TRACE(COMP_PHL_PS, _PHL_INFO_, "[PS], %s(): from %s to %s.\n",
           __func__, phl_ps_pwr_lvl_to_str(cur_pwr_lvl), phl_ps_pwr_lvl_to_str(req_pwr_lvl));
 
   if (cur_pwr_lvl == req_pwr_lvl)
       PHL_TRACE(COMP_PHL_PS, _PHL_WARNING_, "[PS], %s(): pwr lvl is not change!\n", __func__);
 
   _ps_ntfy_before_pwr_cfg(phl_info, ps_mode, cur_pwr_lvl, req_pwr_lvl);
 
   hstatus = rtw_hal_ps_pwr_lvl_cfg(phl_info->phl_com, phl_info->hal,
               req_pwr_lvl);
 
   _ps_ntfy_after_pwr_cfg(phl_info, ps_mode, cur_pwr_lvl, req_pwr_lvl,
                          (hstatus == RTW_HAL_STATUS_SUCCESS ? true : false));
 
   return (hstatus == RTW_HAL_STATUS_SUCCESS) ? RTW_PHL_STATUS_SUCCESS : RTW_PHL_STATUS_FAILURE;
}
 
 
static void _ps_ntfy_before_lps_proto_cfg(struct phl_info_t *phl_info, u8 lps_en)
{
   PHL_TRACE(COMP_PHL_PS, _PHL_INFO_, "[PS], %s(): \n", __func__);
 
   if (lps_en) { /* enter lps */
       #ifdef CONFIG_BTCOEX
       rtw_hal_btc_radio_state_ntfy(phl_info->hal, BTC_RFCTRL_LPS_WL_ON);
       #endif
   }
}
 
static void
_ps_ntfy_after_lps_proto_cfg(struct phl_info_t *phl_info, u8 lps_en, u8 cfg_ok)
{
   PHL_TRACE(COMP_PHL_PS, _PHL_INFO_, "[PS], %s(): \n", __func__);
 
   if (lps_en) { /* enter lps */
       if (!cfg_ok) { /* fail */
           #ifdef CONFIG_BTCOEX
           rtw_hal_btc_radio_state_ntfy(phl_info->hal, BTC_RFCTRL_WL_ON);
           #endif
       }
   } else { /* leave lps */
       if (cfg_ok) { /* ok */
           #ifdef CONFIG_BTCOEX
           rtw_hal_btc_radio_state_ntfy(phl_info->hal, BTC_RFCTRL_WL_ON);
           #endif
       }
   }
}
 
static void _phl_lps_role_config_tbtt_agg(struct phl_info_t *phl_info,
   struct rtw_wifi_role_t *cur_wrole, u32 tbtt_agg_val)
{
   u8 role_idx;
   struct rtw_wifi_role_t * wrole;
   u32 tbtt_agg = tbtt_agg_val;
 
   if (cur_wrole == NULL) {
       PHL_ERR("%s cur role is NULL\n", __func__);
       return;
   }
 
   for (role_idx = 0; role_idx < MAX_WIFI_ROLE_NUMBER; role_idx++) {
       wrole = rtw_phl_get_wrole_by_ridx(phl_info->phl_com, role_idx);
       if(wrole == NULL || !wrole->active)
           continue;
 
       if (wrole == cur_wrole)
           continue;
 
       PHL_INFO("%s role %d config tbtt agg = %d\n", __func__, role_idx, tbtt_agg_val);
       rtw_hal_role_cfg_ex(phl_info->hal, wrole, PCFG_TBTT_AGG, &tbtt_agg);
   }
}
 
static void _phl_ips_role_config_tbtt_agg(struct phl_info_t *phl_info,
    u32 tbtt_agg_val)
{
   u8 role_idx;
   struct rtw_wifi_role_t *wrole;
   u32 tbtt_agg = tbtt_agg_val;
 
   for (role_idx = 0; role_idx < MAX_WIFI_ROLE_NUMBER; role_idx++) {
       wrole = rtw_phl_get_wrole_by_ridx(phl_info->phl_com, role_idx);
       if (wrole == NULL || !wrole->active)
           continue;
 
       PHL_INFO("%s role %d config tbtt agg = %d\n", __func__, role_idx,
            tbtt_agg_val);
       rtw_hal_role_cfg_ex(phl_info->hal, wrole, PCFG_TBTT_AGG, &tbtt_agg);
   }
}
 
enum rtw_phl_status
phl_ps_ips_cfg(struct phl_info_t *phl_info, struct ps_cfg *cfg, u8 en)
{
   u32 tbtt_agg = en ? 0 : RTW_MAC_TBTT_AGG_DEF;
   struct rtw_hal_ips_info ips_info = {0};
 
   /* avoid waking up at each TBTT under disconnected standby */
   _phl_ips_role_config_tbtt_agg(phl_info, tbtt_agg);
 
   ips_info.en = en;
   ips_info.macid = cfg->macid;
 
   return rtw_hal_ps_ips_cfg(phl_info->hal, &ips_info);
}
 
enum rtw_phl_status
phl_ps_lps_cfg(struct phl_info_t *phl_info, struct ps_cfg *cfg, u8 en)
{
   enum rtw_phl_status status = RTW_PHL_STATUS_SUCCESS;
   struct rtw_hal_lps_info lps_info;
   struct rtw_wifi_role_t *wrole = NULL;
   struct rtw_phl_stainfo_t *sta = NULL;
 
   sta = rtw_phl_get_stainfo_by_macid(phl_info, cfg->macid);
   if (sta != NULL) {
       wrole = sta->wrole;
   } else {
       PHL_TRACE(COMP_PHL_PS, _PHL_WARNING_, "[PS], %s(): cannot get sta!\n", __func__);
   }
 
   if (RTW_PHL_STATUS_SUCCESS != phl_snd_cmd_ntfy_ps(phl_info, wrole, en)) {
       status = RTW_PHL_STATUS_FAILURE;
       return status;
   }
 
   if (en) {
       PHL_TRACE(COMP_PHL_PS, _PHL_INFO_, "[PS], %s(): enter lps, macid %d.\n", __func__, cfg->macid);
       _phl_lps_role_config_tbtt_agg(phl_info, wrole, 0);
   } else {
       PHL_TRACE(COMP_PHL_PS, _PHL_INFO_, "[PS], %s(): leave lps, macid %d.\n", __func__, cfg->macid);
       _phl_lps_role_config_tbtt_agg(phl_info, wrole, RTW_MAC_TBTT_AGG_DEF);
   }
 
   lps_info.en = en;
   lps_info.macid = cfg->macid;
   lps_info.listen_bcn_mode = cfg->listen_bcn_mode;
   lps_info.awake_interval = cfg->awake_interval;
   lps_info.smart_ps_mode = cfg->smart_ps_mode;
 
   _ps_ntfy_before_lps_proto_cfg(phl_info, en);
 
   if (rtw_hal_ps_lps_cfg(phl_info->hal, &lps_info) != RTW_HAL_STATUS_SUCCESS) {
       PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): config lps fail.\n", __func__);
       rtw_hal_notification(phl_info->hal, MSG_EVT_DBG_TX_DUMP, HW_PHY_0);
       status = RTW_PHL_STATUS_FAILURE;
   }
 
   _ps_ntfy_after_lps_proto_cfg(phl_info, en, (status == RTW_PHL_STATUS_SUCCESS ? true : false));
 
   return status;
}
 
static enum rtw_phl_status _lps_enter_proto_cfg(struct phl_info_t *phl_info, struct ps_cfg *cfg)
{
   enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
   struct rtw_pkt_ofld_null_info null_info = {0};
   struct rtw_phl_stainfo_t *phl_sta = NULL;
   void *d = phl_to_drvpriv(phl_info);
 
   PHL_TRACE(COMP_PHL_PS, _PHL_INFO_, "[PS], %s(): \n", __func__);
 
#ifdef CONFIG_PHL_PS_FW_DBG
   rtw_hal_cfg_fw_ps_log(phl_info->hal, true);
#endif
 
   phl_sta = rtw_phl_get_stainfo_by_macid(phl_info, cfg->macid);
   if (phl_sta == NULL)
       return RTW_PHL_STATUS_FAILURE;
 
   _os_mem_cpy(d, &(null_info.a1[0]), &(phl_sta->mac_addr[0]),
       MAC_ADDRESS_LENGTH);
 
   _os_mem_cpy(d,&(null_info.a2[0]), &(phl_sta->wrole->mac_addr[0]),
           MAC_ADDRESS_LENGTH);
 
   _os_mem_cpy(d, &(null_info.a3[0]), &(phl_sta->mac_addr[0]),
           MAC_ADDRESS_LENGTH);
 
   status = RTW_PHL_PKT_OFLD_REQ(phl_info, cfg->macid,
               PKT_TYPE_NULL_DATA, cfg->token, &null_info);
   if (status != RTW_PHL_STATUS_SUCCESS) {
       PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): add null pkt ofld fail!\n", __func__);
       return status;
   }
 
   status = phl_ps_lps_cfg(phl_info, cfg, true);
   if (status != RTW_PHL_STATUS_SUCCESS) {
       PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): config lps fail!\n", __func__);
       return status;
   }
 
   return RTW_PHL_STATUS_SUCCESS;
}
 
static enum rtw_phl_status _lps_leave_proto_cfg(struct phl_info_t *phl_info, struct ps_cfg *cfg)
{
   enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
 
   PHL_TRACE(COMP_PHL_PS, _PHL_INFO_, "[PS], %s(): \n", __func__);
 
   status = phl_ps_lps_cfg(phl_info, cfg, false);
   if (status != RTW_PHL_STATUS_SUCCESS) {
       PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): config lps fail!\n", __func__);
       return status;
   }
 
   status = phl_pkt_ofld_cancel(phl_info, cfg->macid,
               PKT_TYPE_NULL_DATA, cfg->token);
   if (status != RTW_PHL_STATUS_SUCCESS) {
       PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): del null pkt ofld fail!\n", __func__);
       return status;
   }
 
   return RTW_PHL_STATUS_SUCCESS;
}
 
enum rtw_phl_status phl_ps_lps_proto_cfg(struct phl_info_t *phl_info, struct ps_cfg *cfg, bool lps_en)
{
   if (lps_en)
       return _lps_enter_proto_cfg(phl_info, cfg);
   else
       return _lps_leave_proto_cfg(phl_info, cfg);
}
 
enum rtw_phl_status phl_ps_lps_enter(struct phl_info_t *phl_info, struct ps_cfg *cfg)
{
   enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
 
   if (cfg->proto_cfg) {
       status = phl_ps_lps_proto_cfg(phl_info, cfg, true);
       if (status != RTW_PHL_STATUS_SUCCESS) {
           PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): config lps protocol fail!\n", __func__);
           return status;
       }
   }
 
   if (cfg->pwr_cfg) {
       status = phl_ps_cfg_pwr_lvl(phl_info, cfg->ps_mode, cfg->cur_pwr_lvl, cfg->pwr_lvl);
       if (status != RTW_PHL_STATUS_SUCCESS) {
           PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): config lps pwr lvl fail!\n", __func__);
           return status;
       }
   }
 
   return RTW_PHL_STATUS_SUCCESS;
}
 
enum rtw_phl_status phl_ps_lps_leave(struct phl_info_t *phl_info, struct ps_cfg *cfg)
{
   enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
 
   if (cfg->pwr_cfg) {
       status = phl_ps_cfg_pwr_lvl(phl_info, cfg->ps_mode, cfg->cur_pwr_lvl, cfg->pwr_lvl);
       if (status != RTW_PHL_STATUS_SUCCESS) {
           PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): config lps pwr lvl fail!\n", __func__);
           return status;
       }
   }
 
   if (cfg->proto_cfg) {
       status = phl_ps_lps_proto_cfg(phl_info, cfg, false);
       if (status != RTW_PHL_STATUS_SUCCESS) {
           PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): config lps protocol fail!\n", __func__);
           return status;
       }
   }
 
   return RTW_PHL_STATUS_SUCCESS;
}
 
enum rtw_phl_status phl_ps_ips_proto_cfg(struct phl_info_t *phl_info, struct ps_cfg *cfg, bool ips_en)
{
   /* ips protocol config */
   PHL_TRACE(COMP_PHL_PS, _PHL_INFO_, "[PS], %s(): \n", __func__);
 
   phl_ps_ips_cfg(phl_info, cfg, ips_en);
 
   return RTW_PHL_STATUS_SUCCESS;
}
 
enum rtw_phl_status phl_ps_ips_enter(struct phl_info_t *phl_info, struct ps_cfg *cfg)
{
   enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
 
   if (cfg->proto_cfg) {
       status = phl_ps_ips_proto_cfg(phl_info, cfg, true);
       if (status != RTW_PHL_STATUS_SUCCESS) {
           PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): config ips protocol fail!\n", __func__);
           return status;
       }
   }
 
   if (cfg->pwr_cfg) {
       status = phl_ps_cfg_pwr_lvl(phl_info, cfg->ps_mode, cfg->cur_pwr_lvl, cfg->pwr_lvl);
       if (status != RTW_PHL_STATUS_SUCCESS) {
           PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): config ips pwr lvl fail!\n", __func__);
           return status;
       }
   }
 
   return status;
}
 
enum rtw_phl_status phl_ps_ips_leave(struct phl_info_t *phl_info, struct ps_cfg *cfg)
{
   enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
 
   if (cfg->pwr_cfg) {
       status = phl_ps_cfg_pwr_lvl(phl_info, cfg->ps_mode, cfg->cur_pwr_lvl, cfg->pwr_lvl);
       if (status != RTW_PHL_STATUS_SUCCESS) {
           PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): config ips pwr lvl fail!\n", __func__);
           return status;
       }
   }
 
   if (cfg->proto_cfg) {
       status = phl_ps_ips_proto_cfg(phl_info, cfg, false);
       if (status != RTW_PHL_STATUS_SUCCESS) {
           PHL_TRACE(COMP_PHL_PS, _PHL_ERR_, "[PS], %s(): config ips protocol fail!\n", __func__);
           return status;
       }
   }
 
   return status;
}
 
enum rtw_phl_status
phl_ps_enter_ps(struct phl_info_t *phl_info, struct ps_cfg *cfg)
{
   enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
 
   PHL_TRACE(COMP_PHL_PS, _PHL_INFO_, "[PS], %s(): ps mode(%s), pwr lvl(%s), macid(%d), token(0x%x), proto_cfg(%d), pwr_cfg(%d)\n",
           __func__, phl_ps_ps_mode_to_str(cfg->ps_mode), phl_ps_pwr_lvl_to_str(cfg->pwr_lvl),
           cfg->macid, (cfg->token == NULL) ? 0xFF : *cfg->token, cfg->proto_cfg, cfg->pwr_cfg);
 
   if (cfg->ps_mode == PS_MODE_LPS)
       status = phl_ps_lps_enter(phl_info, cfg);
   else if (cfg->ps_mode == PS_MODE_IPS)
       status = phl_ps_ips_enter(phl_info, cfg);
 
   return status;
}
 
enum rtw_phl_status
phl_ps_leave_ps(struct phl_info_t *phl_info, struct ps_cfg *cfg)
{
   enum rtw_phl_status status = RTW_PHL_STATUS_FAILURE;
 
   PHL_TRACE(COMP_PHL_PS, _PHL_INFO_, "[PS], %s(): current ps mode(%s), pwr lvl(%s), macid(%d), token(0x%x), proto_cfg(%d), pwr_cfg(%d)\n",
           __func__, phl_ps_ps_mode_to_str(cfg->ps_mode), phl_ps_pwr_lvl_to_str(cfg->pwr_lvl),
           cfg->macid, (cfg->token == NULL) ? 0xFF : *cfg->token, cfg->proto_cfg, cfg->pwr_cfg);
 
   if (cfg->ps_mode == PS_MODE_LPS)
       status = phl_ps_lps_leave(phl_info, cfg);
   else if (cfg->ps_mode == PS_MODE_IPS)
       status = phl_ps_ips_leave(phl_info, cfg);
 
   return status;
}
#endif