hc
2024-05-08 f309769f8af08599af39b6de4f675784ce76530d
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
/******************************************************************************
 *
 * Copyright(c) 2007 - 2017  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.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
 * wlanfae <wlanfae@realtek.com>
 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
 * Hsinchu 300, Taiwan.
 *
 * Larry Finger <Larry.Finger@lwfinger.net>
 *
 *****************************************************************************/
 
#ifndef __ODM_DBG_H__
#define __ODM_DBG_H__
 
/*#define DEBUG_VERSION    "1.1"*/ /*2015.07.29 YuChen*/
/*#define DEBUG_VERSION    "1.2"*/ /*2015.08.28 Dino*/
/*#define DEBUG_VERSION    "1.3"*/ /*2016.04.28 YuChen*/
/*#define DEBUG_VERSION    "1.4"*/ /*2017.03.13 Dino*/
/*#define DEBUG_VERSION "2.0"*/ /*2018.01.10 Dino*/
/*2020.07.03 fix cck report bug due to 8723F coding error*/
#define DEBUG_VERSION "4.6"
 
/*@
 * ============================================================
 *  Definition
 * ============================================================
 */
 
/*@FW DBG MSG*/
#define    RATE_DECISION        1
#define    INIT_RA_TABLE        2
#define    RATE_UP            4
#define    RATE_DOWN        8
#define    TRY_DONE        16
#define    RA_H2C            32
#define    F_RATE_AP_RPT        64
#define    DBC_FW_CLM        9
 
#define PHYDM_SNPRINT_SIZE    64
/* @----------------------------------------------------------------------------
 * Define the tracing components
 *
 * -----------------------------------------------------------------------------
 * BB FW Functions
 */
#define    PHYDM_FW_COMP_RA    BIT(0)
#define    PHYDM_FW_COMP_MU    BIT(1)
#define    PHYDM_FW_COMP_PATH_DIV    BIT(2)
#define    PHYDM_FW_COMP_PT    BIT(3)
 
/*@------------------------Export Marco Definition---------------------------*/
 
#define config_phydm_read_txagc_check(data) (data != INVALID_TXAGC_DATA)
 
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
   #if (DBG_CMD_SUPPORT == 1)
       extern    VOID DCMD_Printf(const char *pMsg);
   #else
       #define DCMD_Printf(_pMsg)
   #endif
 
   #if OS_WIN_FROM_WIN10(OS_VERSION)
   #define    pr_debug(fmt, ...) DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, fmt, ##__VA_ARGS__)
   #else
   #define    pr_debug        DbgPrint
   #endif
 
   #define    dcmd_printf        DCMD_Printf
   #define    dcmd_scanf        DCMD_Scanf
   #define    RT_PRINTK        pr_debug
   #define    PRINT_MAX_SIZE        512
   #define PHYDM_SNPRINTF        RT_SPRINTF
   #define    PHYDM_TRACE(_MSG_)     EXhalPHYDMoutsrc_Print(_MSG_)
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE) && defined(DM_ODM_CE_MAC80211)
   #define PHYDM_SNPRINTF        snprintf
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
   #undef    pr_debug
   #define pr_debug        printk
   #define RT_PRINTK(fmt, args...)    pr_debug(fmt, ## args)
   #define    RT_DISP(dbgtype, dbgflag, printstr)
   #define RT_TRACE(adapter, comp, drv_level, fmt, args...)    \
       RTW_INFO(fmt, ## args)
   #define PHYDM_SNPRINTF        snprintf
#elif (DM_ODM_SUPPORT_TYPE == ODM_IOT)
   #define pr_debug(fmt, args...)        RTW_PRINT_MSG(fmt, ## args)
   #define RT_DEBUG(comp, drv_level, fmt, args...)    \
       RTW_PRINT_MSG(fmt, ## args)
   #define PHYDM_SNPRINTF        snprintf
#else
   #define pr_debug    panic_printk
   /*@#define RT_PRINTK(fmt, args...)    pr_debug("%s(): " fmt, __FUNCTION__, ## args);*/
   #define RT_PRINTK(fmt, args...)    pr_debug(fmt, ## args)
   #define PHYDM_SNPRINTF        snprintf
#endif
 
#ifndef ASSERT
   #define ASSERT(expr)
#endif
 
#if DBG
#if (DM_ODM_SUPPORT_TYPE == ODM_AP)
#define PHYDM_DBG(dm, comp, fmt, args...)            \
   do {                            \
       if ((comp) & dm->debug_components) {          \
           pr_debug("[PHYDM] ");            \
           RT_PRINTK(fmt, ## args);        \
       }                        \
   } while (0)
 
#define PHYDM_DBG_F(dm, comp, fmt, args...)            \
   do {                            \
       if ((comp) & dm->debug_components) {        \
           RT_PRINTK(fmt, ## args);        \
       }                        \
   } while (0)
 
#define PHYDM_PRINT_ADDR(dm, comp, title_str, addr)        \
   do {                            \
       if ((comp) & dm->debug_components) {        \
           int __i;                \
           u8 *__ptr = (u8 *)addr;            \
           pr_debug("[PHYDM] ");            \
           pr_debug(title_str);            \
           pr_debug(" ");                \
           for (__i = 0; __i < 6; __i++)        \
               pr_debug("%02X%s", __ptr[__i], (__i == 5) ? "" : "-");\
           pr_debug("\n");                \
       }                        \
   } while (0)
#elif (DM_ODM_SUPPORT_TYPE == ODM_WIN)
 
static __inline void PHYDM_DBG(PDM_ODM_T dm, int comp, char *fmt, ...)
{
   RT_STATUS rt_status;
   va_list args;
   char buf[PRINT_MAX_SIZE] = {0};
 
   if ((comp & dm->debug_components) == 0)
       return;
 
   if (fmt == NULL)
       return;
 
   va_start(args, fmt);
   rt_status = (RT_STATUS)RtlStringCbVPrintfA(buf, PRINT_MAX_SIZE, fmt, args);
   va_end(args);
 
   if (rt_status != RT_STATUS_SUCCESS) {
       DbgPrint("Failed (%d) to print message to buffer\n", rt_status);
       return;
   }
 
   #if OS_WIN_FROM_WIN10(OS_VERSION)
   DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, "%s", buf);
   #else
   DbgPrint("%s", buf);
   #endif
}
 
static __inline void PHYDM_DBG_F(PDM_ODM_T dm, int comp, char *fmt, ...)
{
   RT_STATUS rt_status;
   va_list args;
   char buf[PRINT_MAX_SIZE] = {0};
 
   if ((comp & dm->debug_components) == 0)
       return;
 
   if (fmt == NULL)
       return;
 
   va_start(args, fmt);
   rt_status = (RT_STATUS)RtlStringCbVPrintfA(buf, PRINT_MAX_SIZE, fmt, args);
   va_end(args);
 
   if (rt_status != RT_STATUS_SUCCESS) {
       /*@DbgPrint("DM Print Fail\n");*/
       return;
   }
 
   #if OS_WIN_FROM_WIN10(OS_VERSION)
   DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, "%s", buf);
   #else
   DbgPrint("%s", buf);
   #endif
}
 
#define PHYDM_PRINT_ADDR(p_dm, comp, title_str, ptr)        \
   do {                            \
       if ((comp) & p_dm->debug_components) {        \
                               \
           int __i;                \
           u8 *__ptr = (u8 *)ptr;            \
           pr_debug("[PHYDM] ");            \
           pr_debug(title_str);            \
           pr_debug(" ");                \
           for (__i = 0; __i < 6; __i++)        \
               pr_debug("%02X%s", __ptr[__i], (__i == 5) ? "" : "-");    \
           pr_debug("\n");                \
       }    \
   } while (0)
#elif (DM_ODM_SUPPORT_TYPE == ODM_IOT)
 
#define PHYDM_DBG(dm, comp, fmt, args...)            \
   do {                            \
       if ((comp) & dm->debug_components) {        \
           RT_DEBUG(COMP_PHYDM, \
                DBG_DMESG, "[PHYDM] " fmt, ##args);    \
       }                        \
   } while (0)
 
#define PHYDM_DBG_F(dm, comp, fmt, args...)            \
   do {                            \
       if ((comp) & dm->debug_components) {        \
           RT_DEBUG(COMP_PHYDM, \
                DBG_DMESG, fmt, ##args);    \
       }    \
   } while (0)
 
#define PHYDM_PRINT_ADDR(dm, comp, title_str, addr)        \
   do {                            \
       if ((comp) & dm->debug_components) {        \
           RT_DEBUG(COMP_PHYDM, \
                DBG_DMESG, "[PHYDM] " title_str "%pM\n",    \
                addr);                \
       }                        \
   } while (0)
 
#elif defined(DM_ODM_CE_MAC80211_V2)
 
#define PHYDM_DBG(dm, comp, fmt, args...)
#define PHYDM_DBG_F(dm, comp, fmt, args...)
#define PHYDM_PRINT_ADDR(dm, comp, title_str, addr)
 
#else
 
#define PHYDM_DBG(dm, comp, fmt, args...)            \
   do {                            \
       struct dm_struct *__dm = (dm);            \
       if ((comp) & __dm->debug_components) {        \
           RT_TRACE(((struct rtl_priv *)__dm->adapter),\
                COMP_PHYDM, DBG_DMESG,        \
                "[PHYDM] " fmt, ##args);    \
       }                        \
   } while (0)
 
#define PHYDM_DBG_F(dm, comp, fmt, args...)            \
   do {                            \
       struct dm_struct *__dm = (dm);            \
       if ((comp) & __dm->debug_components) {        \
           RT_TRACE(((struct rtl_priv *)__dm->adapter),\
                COMP_PHYDM, DBG_DMESG, fmt, ##args);    \
       }    \
   } while (0)
 
#define PHYDM_PRINT_ADDR(dm, comp, title_str, addr)        \
   do {                            \
       struct dm_struct *__dm = (dm);            \
       if ((comp) & __dm->debug_components) {        \
           RT_TRACE(((struct rtl_priv *)__dm->adapter),\
                COMP_PHYDM, DBG_DMESG,        \
                "[PHYDM] " title_str "%pM\n", addr);\
       }                        \
   } while (0)
#endif
 
#else /*@#if DBG*/
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
static __inline void PHYDM_DBG(struct dm_struct *dm, int comp, char *fmt, ...)
{
   RT_STATUS rt_status;
   va_list args;
   char buf[PRINT_MAX_SIZE] = {0};
 
   if ((comp & dm->debug_components) == 0)
       return;
 
   if (fmt == NULL)
       return;
 
   va_start(args, fmt);
   rt_status = (RT_STATUS)RtlStringCbVPrintfA(buf, PRINT_MAX_SIZE, fmt, args);
   va_end(args);
 
   if (rt_status != RT_STATUS_SUCCESS) {
       DbgPrint("Failed (%d) to print message to buffer\n", rt_status);
       return;
   }
 
   PHYDM_TRACE(buf);
}
static __inline void PHYDM_DBG_F(struct dm_struct *dm, int comp, char *fmt, ...)
{
}
#else
#define PHYDM_DBG(dm, comp, fmt, args...)
#define PHYDM_DBG_F(dm, comp, fmt, args...)
#endif
#define PHYDM_PRINT_ADDR(dm, comp, title_str, ptr)
 
#endif
 
#define    DBGPORT_PRI_3    3    /*@Debug function (the highest priority)*/
#define    DBGPORT_PRI_2    2    /*@Check hang function & Strong function*/
#define    DBGPORT_PRI_1    1    /*Watch dog function*/
#define    DBGPORT_RELEASE    0    /*@Init value (the lowest priority)*/
 
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
#define    PHYDM_DBGPRINT        0
#define    PHYDM_SSCANF(x, y, z)    dcmd_scanf(x, y, z)
#define    PDM_VAST_SNPF        PDM_SNPF
#if (PHYDM_DBGPRINT == 1)
#define    PDM_SNPF(msg)    \
   do {\
       rsprintf msg;\
       pr_debug("%s", output);\
   } while (0)
#else
 
static __inline void PDM_SNPF(u32 out_len, u32 used, char *buff, int len,
                 char *fmt, ...)
{
   RT_STATUS rt_status;
   va_list args;
   char buf[PRINT_MAX_SIZE] = {0};
 
   if (fmt == NULL)
       return;
 
   va_start(args, fmt);
   rt_status = (RT_STATUS)RtlStringCbVPrintfA(buf, PRINT_MAX_SIZE, fmt, args);
   va_end(args);
 
   if (rt_status != RT_STATUS_SUCCESS) {
       /*@DbgPrint("DM Print Fail\n");*/
       return;
   }
 
   DCMD_Printf(buf);
}
 
 
 
#endif    /*@#if (PHYDM_DBGPRINT == 1)*/
#else    /*@(DM_ODM_SUPPORT_TYPE & (ODM_CE | ODM_AP))*/
   #if (DM_ODM_SUPPORT_TYPE == ODM_CE) || defined(__OSK__)
   #define    PHYDM_DBGPRINT    0
   #else
   #define    PHYDM_DBGPRINT    1
   #endif
#define    MAX_ARGC        20
#define    MAX_ARGV        16
#define    DCMD_DECIMAL        "%d"
#define    DCMD_CHAR        "%c"
#define    DCMD_HEX        "%x"
 
#define    PHYDM_SSCANF(x, y, z)    sscanf(x, y, z)
 
#if (DM_ODM_SUPPORT_TYPE & ODM_AP)
#define PDM_VAST_SNPF(out_len, used, buff, len, fmt, args...) RT_PRINTK(fmt, ## args)
 
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
#define    PDM_VAST_SNPF(out_len, used, buff, len, fmt, args...)    \
   do {                                \
       RT_DEBUG(COMP_PHYDM, DBG_DMESG, fmt, ##args);        \
   } while (0)
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
#define    PDM_VAST_SNPF(out_len, used, buff, len, fmt, args...)
#else
#define    PDM_VAST_SNPF(out_len, used, buff, len, fmt, args...)    \
       RT_TRACE(((struct rtl_priv *)dm->adapter), COMP_PHYDM, \
           DBG_DMESG, fmt, ##args)
#endif
 
#if (PHYDM_DBGPRINT == 1)
#define    PDM_SNPF(out_len, used, buff, len, fmt, args...)        \
   do {                                \
       snprintf(buff, len, fmt, ##args);            \
       pr_debug("%s", output);                    \
   } while (0)
#else
#define    PDM_SNPF(out_len, used, buff, len, fmt, args...)        \
   do {                                \
       u32 *__pdm_snpf_u = &(used);                \
       if (out_len > *__pdm_snpf_u)                \
           *__pdm_snpf_u += snprintf(buff, len, fmt, ##args);\
   } while (0)
#endif
#endif
/* @1 ============================================================
 * 1  enumeration
 * 1 ============================================================
 */
 
enum auto_detection_state { /*@Fast antenna training*/
   AD_LEGACY_MODE    = 0,
   AD_HT_MODE    = 1,
   AD_VHT_MODE    = 2
};
 
/*@
 * ============================================================
 * 1  structure
 * ============================================================
 */
 
#ifdef CONFIG_PHYDM_DEBUG_FUNCTION
u8 phydm_get_l_sig_rate(void *dm_void, u8 rate_idx_l_sig);
#endif
 
void phydm_init_debug_setting(struct dm_struct *dm);
 
void phydm_bb_dbg_port_header_sel(void *dm_void, u32 header_idx);
 
u32 phydm_get_bb_dbg_port_idx(void *dm_void);
 
u8 phydm_set_bb_dbg_port(void *dm_void, u8 curr_dbg_priority, u32 debug_port);
 
void phydm_release_bb_dbg_port(void *dm_void);
 
u32 phydm_get_bb_dbg_port_val(void *dm_void);
 
void phydm_reset_rx_rate_distribution(struct dm_struct *dm);
 
void phydm_rx_rate_distribution(void *dm_void);
 
u16 phydm_rx_avg_phy_rate(void *dm_void);
 
void phydm_show_phy_hitogram(void *dm_void);
 
void phydm_get_avg_phystatus_val(void *dm_void);
 
void phydm_get_phy_statistic(void *dm_void);
 
void phydm_dm_summary(void *dm_void, u8 macid);
 
void phydm_basic_dbg_message(void *dm_void);
 
void phydm_basic_profile(void *dm_void, u32 *_used, char *output,
            u32 *_out_len);
#if (DM_ODM_SUPPORT_TYPE & (ODM_CE | ODM_AP))
s32 phydm_cmd(struct dm_struct *dm, char *input, u32 in_len, u8 flag,
         char *output, u32 out_len);
#endif
void phydm_cmd_parser(struct dm_struct *dm, char input[][16], u32 input_num,
             u8 flag, char *output, u32 out_len);
 
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
void phydm_basic_dbg_msg_cli_win(void *dm_void, char *buf);
 
void phydm_sbd_check(
   struct dm_struct *dm);
 
void phydm_sbd_callback(
   struct phydm_timer_list *timer);
 
void phydm_sbd_workitem_callback(
   void *context);
#endif
 
void phydm_fw_trace_en_h2c(void *dm_void, boolean enable,
              u32 fw_debug_component, u32 monitor_mode, u32 macid);
 
void phydm_fw_trace_handler(void *dm_void, u8 *cmd_buf, u8 cmd_len);
 
void phydm_fw_trace_handler_code(void *dm_void, u8 *buffer, u8 cmd_len);
 
void phydm_fw_trace_handler_8051(void *dm_void, u8 *cmd_buf, u8 cmd_len);
 
#endif /* @__ODM_DBG_H__ */