hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
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
/******************************************************************************
 *
 * Copyright(c) 2020 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.
 *
 *****************************************************************************/
#include "phl_headers.h"
 
#ifdef CONFIG_CMD_DISP
enum rtw_phl_status
rtw_phl_connect_prepare(void *phl,
                        enum phl_band_idx band_idx,
                        struct rtw_wifi_role_t *wrole,
                        struct rtw_wifi_role_link_t *rlink,
                        u8 *addr)
{
   enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct phl_msg msg = {0};
   struct phl_msg_attribute attr = {0};
 
   if (rtw_phl_role_is_client_category(wrole))
       SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_CONNECT);
   else if (rtw_phl_role_is_ap_category(wrole))
       SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_AP_ADD_DEL_STA);
 
   SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_CONNECT_START);
   msg.band_idx = band_idx;
   msg.inbuf = (u8 *)wrole;
   msg.rsvd[0].ptr = (u8 *)rlink;
 
   phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
   if(phl_status != RTW_PHL_STATUS_SUCCESS){
       PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
             __FUNCTION__);
       goto exit;
   }
 
exit:
   return phl_status;
}
 
enum rtw_phl_status
rtw_phl_connect_linked(void *phl,
                       enum phl_band_idx band_idx,
                       struct rtw_wifi_role_t *wrole,
                       struct rtw_phl_stainfo_t *sta,
                       u8 *sta_addr)
{
   enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct phl_msg msg = {0};
   struct phl_msg_attribute attr = {0};
 
   if (rtw_phl_role_is_client_category(wrole))
       SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_CONNECT);
   else if (rtw_phl_role_is_ap_category(wrole))
       SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_AP_ADD_DEL_STA);
 
   SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_CONNECT_LINKED);
   msg.band_idx = band_idx;
   msg.rsvd[0].ptr = sta;
   msg.rsvd[1].ptr = sta_addr;
 
   phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
   if(phl_status != RTW_PHL_STATUS_SUCCESS){
       PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
             __FUNCTION__);
       goto exit;
   }
 
exit:
   return phl_status;
}
 
enum rtw_phl_status rtw_phl_connected(void *phl,
                     enum phl_band_idx band_idx,
                     struct rtw_wifi_role_t *wrole,
                     struct rtw_phl_stainfo_t *sta)
{
   enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct phl_msg msg = {0};
   struct phl_msg_attribute attr = {0};
 
   if (rtw_phl_role_is_client_category(wrole))
       SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_CONNECT);
   else if (rtw_phl_role_is_ap_category(wrole))
       SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_AP_ADD_DEL_STA);
 
   SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_CONNECT_END);
   msg.band_idx = band_idx;
   msg.rsvd[0].ptr = sta;
 
   phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
   if(phl_status != RTW_PHL_STATUS_SUCCESS){
       PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
             __FUNCTION__);
       goto exit;
   }
 
exit:
   return phl_status;
}
 
enum rtw_phl_status rtw_phl_disconnect(void *phl,
                      enum phl_band_idx band_idx,
                      struct rtw_wifi_role_t *wrole,
                      bool is_disconnect)
{
   enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct phl_msg msg = {0};
   struct phl_msg_attribute attr = {0};
 
 
   if (rtw_phl_role_is_client_category(wrole)) {
       if (is_disconnect)
           SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_DISCONNECT);
       else
           SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_CONNECT);
   } else if (rtw_phl_role_is_ap_category(wrole))
       SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_AP_ADD_DEL_STA);
 
   if (is_disconnect)
       SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_DISCONNECT_PREPARE);
   else
       SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_DISCONNECT);
 
   msg.band_idx = band_idx;
   msg.rsvd[0].ptr = (u8*)wrole;
 
   phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
   if(phl_status != RTW_PHL_STATUS_SUCCESS){
       PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
             __FUNCTION__);
       goto exit;
   }
 
exit:
   return phl_status;
}
#else /* CONFIG_CMD_DISP */
enum rtw_phl_status
rtw_phl_connect_prepare(void *phl,
                        struct rtw_wifi_role_t *wrole,
                        struct rtw_wifi_role_link_t *rlink,
                        u8 *addr)
{
   enum rtw_phl_status psts = RTW_PHL_STATUS_FAILURE;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
 
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, ">>> rtw_phl_connect_prepare()\n");
   wrole->mstate = MLME_LINKING;
   psts = phl_mr_info_upt(phl_info, rlink);
   if (psts != RTW_PHL_STATUS_SUCCESS) {
       PHL_ERR("%s mr info upt failed\n", __func__);
       goto _exit;
   }
 
   psts = rtw_phl_mr_rx_filter_opt(phl, rlink);
   if (psts != RTW_PHL_STATUS_SUCCESS) {
       PHL_ERR("%s set mr_rx_filter_opt failed\n", __func__);
       goto _exit;
   }
 
   PHL_DUMP_MR_EX(phl_info);
_exit:
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "<<< rtw_phl_connect_prepare()\n");
   return psts;
}
 
enum rtw_phl_status rtw_phl_connected(void *phl,
                     struct rtw_wifi_role_t *wrole,
                     struct rtw_phl_stainfo_t *sta)
{
   enum rtw_phl_status psts = RTW_PHL_STATUS_FAILURE;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
 
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, ">>> rtw_phl_connected()\n");
   psts = phl_mr_info_upt(phl_info, sta->rlink);
   if (psts != RTW_PHL_STATUS_SUCCESS) {
       PHL_ERR("%s mr info upt failed\n", __func__);
       goto _exit;
   }
 
   psts = rtw_phl_mr_rx_filter_opt(phl, sta->rlink);
   if (psts != RTW_PHL_STATUS_SUCCESS) {
       PHL_ERR("%s set mr_rx_filter_opt failed\n", __func__);
       goto _exit;
   }
   psts = phl_mr_tsf_sync(phl, wrole, sta->rlink, PHL_ROLE_MSTS_STA_CONN_END);
   if (psts != RTW_PHL_STATUS_SUCCESS) {
       PHL_ERR("%s set mr_tsf_sync failed\n", __func__);
       goto _exit;
   }
   PHL_DUMP_MR_EX(phl_info);
_exit:
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "<<< rtw_phl_connected()\n");
   return psts;
}
enum rtw_phl_status rtw_phl_disconnect_prepare(void *phl,
               struct rtw_wifi_role_t *wrole)
{
   enum rtw_phl_status psts = RTW_PHL_STATUS_SUCCESS;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct rtw_wifi_role_link_t *rlink = NULL;
   u8 idx = 0;
 
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, ">>> rtw_phl_disconnect_prepare()\n");
 
   for (idx = 0; idx < wrole->rlink_num; idx++) {
       rlink = get_rlink(wrole, idx);
   }
 
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "<<< rtw_phl_disconnect_prepare()\n");
   return psts;
}
 
enum rtw_phl_status
rtw_phl_disconnect(void *phl,
                   struct rtw_wifi_role_t *wrole)
{
   enum rtw_phl_status psts = RTW_PHL_STATUS_SUCCESS;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct rtw_wifi_role_link_t *rlink = NULL;
   u8 idx = 0;
 
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, ">>> rtw_phl_disconnect()\n");
   for (idx = 0; idx < wrole->rlink_num; idx++) {
       rlink = get_rlink(wrole, idx);
 
       psts = phl_mr_info_upt(phl_info, rlink);
       if (psts != RTW_PHL_STATUS_SUCCESS) {
           PHL_ERR("%s mr info upt failed\n", __func__);
           goto _exit;
       }
 
       psts = rtw_phl_mr_rx_filter_opt(phl, rlink);
       if (psts != RTW_PHL_STATUS_SUCCESS) {
           PHL_ERR("%s set mr_rx_filter_opt failed\n", __func__);
           goto _exit;
       }
 
       psts = phl_mr_tsf_sync(phl, wrole, rlink, PHL_ROLE_MSTS_STA_DIS_CONN);
       if (psts != RTW_PHL_STATUS_SUCCESS) {
           PHL_ERR("%s set mr_tsf_sync failed\n", __func__);
           goto _exit;
       }
       rtw_hal_disconnect_notify(phl_info->hal, &rlink->chandef);
   }
 
   PHL_DUMP_MR_EX(phl_info);
_exit:
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "<<< rtw_phl_disconnect()\n");
   return psts;
}
#endif
 
#ifdef CONFIG_AP_CMD_DISPR
enum rtw_phl_status rtw_phl_ap_started(void *phl,
           enum phl_band_idx band_idx,
           struct rtw_wifi_role_t *wrole)
{
   enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct phl_msg msg = {0};
   struct phl_msg_attribute attr = {0};
 
   SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_AP_START);
   SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_AP_START);
   msg.band_idx = band_idx;
 
   phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
   if(phl_status != RTW_PHL_STATUS_SUCCESS){
       PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
             __FUNCTION__);
       goto exit;
   }
 
exit:
   return phl_status;
}
 
enum rtw_phl_status rtw_phl_ap_stop(void *phl,
           enum phl_band_idx band_idx,
           struct rtw_wifi_role_t *wrole)
{
   enum rtw_phl_status phl_status = RTW_PHL_STATUS_FAILURE;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct phl_msg msg = {0};
   struct phl_msg_attribute attr = {0};
 
   SET_MSG_MDL_ID_FIELD(msg.msg_id, PHL_FG_MDL_AP_STOP);
   SET_MSG_EVT_ID_FIELD(msg.msg_id, MSG_EVT_AP_STOP_PREPARE);
   msg.band_idx = band_idx;
   msg.rsvd[0].ptr = (u8*)wrole;
 
   phl_status = phl_disp_eng_send_msg(phl_info, &msg, &attr, NULL);
   if(phl_status != RTW_PHL_STATUS_SUCCESS){
       PHL_TRACE(COMP_PHL_DBG, _PHL_ERR_, "%s: Dispr send msg fail!\n",
             __FUNCTION__);
       goto exit;
   }
 
exit:
   return phl_status;
}
#else  /* CONFIG_AP_CMD_DISPR */
 
enum rtw_phl_status rtw_phl_ap_started(void *phl, struct rtw_wifi_role_t *wrole)
{
   enum rtw_phl_status psts = RTW_PHL_STATUS_FAILURE;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct rtw_wifi_role_link_t *rlink = NULL;
   u8 idx = 0;
 
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, ">>> rtw_phl_ap_started()\n");
   for (idx = 0; idx < wrole->rlink_num; idx++) {
       rlink = get_rlink(wrole, idx);
 
       psts = phl_mr_info_upt(phl_info, rlink);
       if (psts != RTW_PHL_STATUS_SUCCESS) {
           PHL_ERR("%s mr info upt failed\n", __func__);
           goto _exit;
       }
       psts = rtw_phl_mr_rx_filter_opt(phl, rlink);
       if (psts != RTW_PHL_STATUS_SUCCESS) {
           PHL_ERR("%s set mr_rx_filter_opt failed\n", __func__);
           goto _exit;
       }
 
       psts = phl_mr_tsf_sync(phl, wrole, rlink, PHL_ROLE_MSTS_AP_START);
 
       if (psts != RTW_PHL_STATUS_SUCCESS) {
           PHL_ERR("%s set mr_tsf_sync failed\n", __func__);
           goto _exit;
       }
   }
 
   PHL_DUMP_MR_EX(phl_info);
 
_exit:
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "<<< rtw_phl_ap_started()\n");
   return psts;
}
 
enum rtw_phl_status rtw_phl_ap_stop(void *phl, struct rtw_wifi_role_t *wrole)
{
   enum rtw_phl_status psts = RTW_PHL_STATUS_FAILURE;
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct rtw_wifi_role_link_t *rlink = NULL;
   u8 idx = 0;
 
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, ">>> rtw_phl_ap_stop()\n");
   wrole->mstate = MLME_NO_LINK;
   for (idx = 0; idx < wrole->rlink_num; idx++) {
       rlink = get_rlink(wrole, idx);
 
       psts = phl_mr_info_upt(phl_info, rlink);
       if (psts != RTW_PHL_STATUS_SUCCESS) {
           PHL_ERR("%s mr info upt failed\n", __func__);
           goto _exit;
       }
       psts = rtw_phl_mr_rx_filter_opt(phl, rlink);
       if (psts != RTW_PHL_STATUS_SUCCESS) {
           PHL_ERR("%s set mr_rx_filter_opt failed\n", __func__);
           goto _exit;
       }
 
       psts = phl_mr_tsf_sync(phl, wrole, rlink, PHL_ROLE_MSTS_AP_STOP);
       if (psts != RTW_PHL_STATUS_SUCCESS) {
           PHL_ERR("%s set mr_tsf_sync failed\n", __func__);
           goto _exit;
       }
       #ifdef RTW_PHL_BCN
           psts = rtw_phl_free_bcn_entry(phl_info, rlink);
           if (psts != RTW_PHL_STATUS_SUCCESS) {
               PHL_ERR("%s phl_free_bcn_entry failed\n", __func__);
               goto _exit;
           }
       #endif
 
       rtw_hal_disconnect_notify(phl_info->hal, &rlink->chandef);
   }
 
   PHL_DUMP_MR_EX(phl_info);
_exit:
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "<<< rtw_phl_ap_stop()\n");
   return psts;
}
#endif
 
#ifdef CONFIG_IBSS_CMD_DISPR
enum rtw_phl_status rtw_phl_ibss_started(void *phl, struct rtw_wifi_role_t *wrole)
{
   PHL_ERR("%s failed, cmd dispatcher not support\n", __func__);
   return RTW_PHL_STATUS_FAILURE;
}
#else  /* CONFIG_IBSS_CMD_DISPR */
enum rtw_phl_status rtw_phl_ibss_started(void *phl, struct rtw_wifi_role_t *wrole)
{
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct rtw_wifi_role_link_t *rlink = NULL;
 
   if (wrole->rlink_num == 1) {
       rlink = &wrole->rlink[wrole->rlink_num-1];
 
       #ifdef RTW_WKARD_IBSS_SNIFFER_MODE
           rtw_hal_set_rxfltr_opt_by_mode(phl_info->hal,
                                          rlink->hw_band,
                                          RX_FLTR_OPT_MODE_SNIFFER);
       #endif
   }
 
   return RTW_PHL_STATUS_SUCCESS;
}
#endif
 
#ifdef RTW_WKARD_P2P_LISTEN
enum rtw_phl_status rtw_phl_p2p_listen_start(void *phl, struct rtw_wifi_role_t *wrole)
{
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct rtw_wifi_role_link_t *rlink = NULL;
   u8 idx = 0;
 
   for (idx = 0; idx < wrole->rlink_num; idx++) {
       rlink = get_rlink(wrole, idx);
 
       rtw_hal_set_rxfltr_opt_by_mode(phl_info->hal, rlink->hw_band,
               RX_FLTR_OPT_MODE_SNIFFER);
   }
 
   return RTW_PHL_STATUS_SUCCESS;
}
 
enum rtw_phl_status rtw_phl_p2p_listen_end(void *phl, struct rtw_wifi_role_t *wrole)
{
   struct phl_info_t *phl_info = (struct phl_info_t *)phl;
   struct rtw_wifi_role_link_t *rlink = NULL;
   u8 idx = 0;
 
   for (idx = 0; idx < wrole->rlink_num; idx++) {
       rlink = get_rlink(wrole, idx);
 
       /* restore rx filter mode */
       rtw_phl_mr_rx_filter_opt(phl_info, rlink);
   }
 
   return RTW_PHL_STATUS_SUCCESS;
}
#endif /* RTW_WKARD_P2P_LISTEN */