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 _PHL_SER_DBG_CMD_C_
16 #include "../phl_headers.h"
17
18 struct phl_ser_cmd_info {
19 char name[16];
20 u8 id;
21 };
22
23 enum PHL_SER_CMD_ID {
24 PHL_SER_STATE,
25 PHL_SER_CMAC,
26 PHL_SER_DMAC,
27 };
28
29 struct phl_ser_cmd_info phl_ser_cmd_i[] = {
30 {"state", PHL_SER_STATE},
31 {"cmac", PHL_SER_CMAC},
32 {"dmac", PHL_SER_DMAC}
33 };
34
35 /* echo phl ser state */
_phl_ser_cmd_state(struct phl_info_t * phl_info,u32 * used,char input[][MAX_ARGV],u32 input_num,char * output,u32 out_len)36 void _phl_ser_cmd_state(struct phl_info_t *phl_info, u32 *used, char input[][MAX_ARGV],
37 u32 input_num, char *output, u32 out_len)
38 {
39 struct rtw_stats *ser_stat = &phl_info->phl_com->phl_stats;
40
41 PHL_DBG_MON_INFO(out_len, *used, output + *used,
42 out_len - *used, "\n[SER statistic]\
43 \nRTW_PHL_SER_L0_RESET = %d\
44 \nRTW_PHL_SER_PAUSE_TRX (M1) = %d\
45 \nRTW_PHL_SER_DO_RECOVERY (M3) = %d\
46 \nRTW_PHL_SER_READY (M5) = %d\
47 \nRTW_PHL_SER_L2_RESET = %d\
48 \nRTW_PHL_SER_EVENT_CHK = %d\
49 \nRTW_PHL_SER_DUMP_FW_LOG = %d\
50 \nRTW_PHL_SER_LOG_ONLY = %d\n",
51 (int)ser_stat->ser_event[RTW_PHL_SER_L0_RESET],
52 (int)ser_stat->ser_event[RTW_PHL_SER_PAUSE_TRX],
53 (int)ser_stat->ser_event[RTW_PHL_SER_DO_RECOVERY],
54 (int)ser_stat->ser_event[RTW_PHL_SER_READY],
55 (int)ser_stat->ser_event[RTW_PHL_SER_L2_RESET],
56 (int)ser_stat->ser_event[RTW_PHL_SER_EVENT_CHK],
57 (int)ser_stat->ser_event[RTW_PHL_SER_DUMP_FW_LOG],
58 (int)ser_stat->ser_event[RTW_PHL_SER_LOG_ONLY]);
59
60 }
61
62 /* echo phl ser cmac */
_phl_ser_cmd_cmac(struct phl_info_t * phl_info,u32 * used,char input[][MAX_ARGV],u32 input_num,char * output,u32 out_len)63 void _phl_ser_cmd_cmac(struct phl_info_t *phl_info, u32 *used, char input[][MAX_ARGV],
64 u32 input_num, char *output, u32 out_len )
65 {
66 enum rtw_hal_status status = RTW_HAL_STATUS_FAILURE;
67 struct hal_info_t *hal_info = (struct hal_info_t *)(phl_info->hal);
68
69 status = rtw_hal_trigger_cmac_err(hal_info);
70 PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
71 "\nSER CMAC Reset (status = 0x%x) \n", (int)status);
72 }
73
74 /* echo phl ser dmac */
_phl_ser_cmd_dmac(struct phl_info_t * phl_info,u32 * used,char input[][MAX_ARGV],u32 input_num,char * output,u32 out_len)75 void _phl_ser_cmd_dmac(struct phl_info_t *phl_info, u32 *used, char input[][MAX_ARGV],
76 u32 input_num, char *output, u32 out_len )
77 {
78 enum rtw_hal_status status = RTW_HAL_STATUS_FAILURE;
79 struct hal_info_t *hal_info = (struct hal_info_t *)(phl_info->hal);
80
81 status = rtw_hal_trigger_dmac_err(hal_info);
82 PHL_DBG_MON_INFO(out_len, *used, output + *used, out_len - *used,
83 "\nSER DMAC Reset (status = 0x%x) \n", (int)status);
84 }
85
phl_ser_cmd_parser(struct phl_info_t * phl_info,char input[][MAX_ARGV],u32 input_num,char * output,u32 out_len)86 void phl_ser_cmd_parser(struct phl_info_t *phl_info, char input[][MAX_ARGV],
87 u32 input_num, char *output, u32 out_len)
88 {
89 u32 used = 0;
90 u8 id = 0;
91 u32 i;
92 u32 array_size = sizeof(phl_ser_cmd_i) / sizeof(struct phl_ser_cmd_info);
93
94 PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used, "\n");
95
96 /* Parsing cmd ID */
97 if (input_num) {
98 for (i = 0; i < array_size; i++) {
99 if (!_os_strcmp(phl_ser_cmd_i[i].name, input[1])) {
100 id = phl_ser_cmd_i[i].id;
101 break;
102 }
103 }
104 }
105
106 switch (id) {
107 case PHL_SER_STATE:
108 _phl_ser_cmd_state(phl_info, &used, input, input_num,
109 output, out_len);
110 break;
111 case PHL_SER_CMAC:
112 _phl_ser_cmd_cmac(phl_info, &used, input, input_num,
113 output, out_len);
114 break;
115 case PHL_SER_DMAC:
116 _phl_ser_cmd_dmac(phl_info, &used, input, input_num,
117 output, out_len);
118 break;
119 default:
120 PHL_DBG_MON_INFO(out_len, used, output + used, out_len - used,
121 "command not supported !!\n");
122 break;
123 }
124 }
125