1 | /** @file wlan_exp_common.c |
---|
2 | * @brief Experiment Framework (Common) |
---|
3 | * |
---|
4 | * This contains the code for WLAN Experimental Framework. |
---|
5 | * |
---|
6 | * @copyright Copyright 2013-2019, Mango Communications. All rights reserved. |
---|
7 | * Distributed under the Mango Communications Reference Design License |
---|
8 | * See LICENSE.txt included in the design archive or |
---|
9 | * at http://mangocomm.com/802.11/license |
---|
10 | * |
---|
11 | * This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11) |
---|
12 | */ |
---|
13 | |
---|
14 | #include "wlan_mac_high_sw_config.h" |
---|
15 | #include "wlan_mac_common.h" |
---|
16 | |
---|
17 | #if WLAN_SW_CONFIG_ENABLE_WLAN_EXP |
---|
18 | |
---|
19 | // Xilinx / Standard library includes |
---|
20 | #include "wlan_platform_common.h" |
---|
21 | #include "wlan_platform_high.h" |
---|
22 | #include "xil_io.h" |
---|
23 | #include "string.h" |
---|
24 | |
---|
25 | // WLAN includes |
---|
26 | #include "wlan_mac_high.h" |
---|
27 | |
---|
28 | // WLAN Exp includes |
---|
29 | #include "wlan_exp_common.h" |
---|
30 | |
---|
31 | // Declared in wlan_mac_high.c |
---|
32 | extern platform_high_dev_info_t platform_high_dev_info; |
---|
33 | |
---|
34 | u8 wlan_exp_print_level = WLAN_EXP_DEFAULT_DEBUG_PRINT_LEVEL; |
---|
35 | |
---|
36 | const char* print_type_node = "NODE"; |
---|
37 | const char* print_type_transport = "TRANSPORT"; |
---|
38 | const char* print_type_event_log = "EVENT LOG"; |
---|
39 | const char* print_type_counts = "COUNTS"; |
---|
40 | const char* print_type_ltg = "LTG"; |
---|
41 | const char* print_type_queue = "QUEUE"; |
---|
42 | |
---|
43 | /******************************************************************** |
---|
44 | * WLAN Exp Print Header |
---|
45 | * |
---|
46 | * This prints a small header prior to other prints. It is no intended to be called |
---|
47 | * directly, but instead via the wlan_exp_printf macro. |
---|
48 | * |
---|
49 | * @param u8 level - WLAN_EXP_PRINT_NONE, WLAN_EXP_PRINT_ERROR, WLAN_EXP_PRINT_WARNING, |
---|
50 | * WLAN_EXP_PRINT_INFO, or WLAN_EXP_PRINT_DEBUG |
---|
51 | * |
---|
52 | * @return None |
---|
53 | * |
---|
54 | ********************************************************************/ |
---|
55 | void wlan_exp_print_header(u8 level, const char* type, char* filename, u32 line) { |
---|
56 | char* basename = NULL; |
---|
57 | |
---|
58 | if (type != NULL) { |
---|
59 | xil_printf("%s", type); |
---|
60 | |
---|
61 | if ((level <= WLAN_EXP_PRINT_WARNING) || (wlan_exp_print_level == WLAN_EXP_PRINT_DEBUG)) { |
---|
62 | basename = strrchr(filename, '/') ? strrchr(filename, '/') + 1 : filename; |
---|
63 | } |
---|
64 | |
---|
65 | if (wlan_exp_print_level == WLAN_EXP_PRINT_DEBUG) { |
---|
66 | xil_printf(" (%s:%d): ", basename, line); |
---|
67 | } else { |
---|
68 | xil_printf(": "); |
---|
69 | } |
---|
70 | |
---|
71 | switch (level) { |
---|
72 | case WLAN_EXP_PRINT_ERROR: |
---|
73 | xil_printf("ERROR (%s:%d): ", basename, line); |
---|
74 | break; |
---|
75 | |
---|
76 | case WLAN_EXP_PRINT_WARNING: |
---|
77 | xil_printf("WARNING (%s:%d): ", basename, line); |
---|
78 | break; |
---|
79 | } |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | /******************************************************************** |
---|
84 | * WLAN Exp MAC Address |
---|
85 | * |
---|
86 | * This prints a 6-byte MAC address, depending on the current print level |
---|
87 | * |
---|
88 | * @param u8 level - WLAN_EXP_PRINT_NONE, WLAN_EXP_PRINT_ERROR, WLAN_EXP_PRINT_WARNING, |
---|
89 | * WLAN_EXP_PRINT_INFO, or WLAN_EXP_PRINT_DEBUG |
---|
90 | * @param u8* mac_address - first byte of MAC address |
---|
91 | * |
---|
92 | * @return None |
---|
93 | * |
---|
94 | ********************************************************************/ |
---|
95 | void wlan_exp_print_mac_address(u8 level, u8* mac_address) { |
---|
96 | if (level <= wlan_exp_print_level) { |
---|
97 | xil_printf("%02x:%02x:%02x:%02x:%02x:%02x\n", mac_address[0], mac_address[1], mac_address[2], |
---|
98 | mac_address[3], mac_address[4], mac_address[5]); |
---|
99 | } |
---|
100 | } |
---|
101 | |
---|
102 | /******************************************************************** |
---|
103 | * Set print level |
---|
104 | * |
---|
105 | * Sets the level of prints across wlan_exp. |
---|
106 | * |
---|
107 | * WLAN_EXP_PRINT_NONE: Stop all wlan_exp prints |
---|
108 | * WLAN_EXP_PRINT_ERROR: Only print the most extreme error conditions |
---|
109 | * WLAN_EXP_PRINT_WARNING: Print warnings and errors |
---|
110 | * WLAN_EXP_PRINT_INFO: Print informational messages in addition to warnings and errors |
---|
111 | * WLAN_EXP_PRINT_DEBUG: Include all wlan_exp prints for debugging. This may negatively |
---|
112 | * impact the performance of the node. |
---|
113 | * |
---|
114 | * @param u8 level - WLAN_EXP_PRINT_NONE, WLAN_EXP_PRINT_ERROR, WLAN_EXP_PRINT_WARNING, |
---|
115 | * WLAN_EXP_PRINT_INFO, or WLAN_EXP_PRINT_DEBUG |
---|
116 | * @param u8* mac_address - first byte of MAC address |
---|
117 | * |
---|
118 | * @return None |
---|
119 | * |
---|
120 | ********************************************************************/ |
---|
121 | void wlan_exp_set_print_level(u8 level) { |
---|
122 | switch (level) { |
---|
123 | case WLAN_EXP_PRINT_NONE: |
---|
124 | case WLAN_EXP_PRINT_ERROR: |
---|
125 | case WLAN_EXP_PRINT_WARNING: |
---|
126 | case WLAN_EXP_PRINT_INFO: |
---|
127 | case WLAN_EXP_PRINT_DEBUG: |
---|
128 | wlan_exp_print_level = level; |
---|
129 | break; |
---|
130 | |
---|
131 | default: |
---|
132 | xil_printf("Unsupported print level. Setting to WLAN_EXP_PRINT_ERROR.\n"); |
---|
133 | wlan_exp_print_level = WLAN_EXP_PRINT_ERROR; |
---|
134 | break; |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | |
---|
139 | /******************************************************************** |
---|
140 | * WLAN Exp Null Callback |
---|
141 | * |
---|
142 | * This function is part of the callback system for processing commands. |
---|
143 | * |
---|
144 | * @param void* param - Parameters for the callback |
---|
145 | * |
---|
146 | * @return int - WLAN_SUCCESS |
---|
147 | * |
---|
148 | ********************************************************************/ |
---|
149 | int wlan_exp_null_callback(void* param){ |
---|
150 | wlan_exp_printf(WLAN_EXP_PRINT_INFO, print_type_node, "WLAN Exp NULL callback\n"); |
---|
151 | return WLAN_SUCCESS; |
---|
152 | } |
---|
153 | |
---|
154 | /****************************************************************************/ |
---|
155 | /** |
---|
156 | * Get MAC Address |
---|
157 | * |
---|
158 | * This function will populate the MAC address buffer, dest, with the MAC |
---|
159 | * address coming over the network (big endian). This uses the same formating |
---|
160 | * as the HW address parameter from transport.c |
---|
161 | * |
---|
162 | * @param src - Source buffer of MAC address (u32, byte swapped) |
---|
163 | * dest - Destination buffer of MAC address |
---|
164 | * |
---|
165 | * @return None. |
---|
166 | * |
---|
167 | * @note None. |
---|
168 | * |
---|
169 | ****************************************************************************/ |
---|
170 | void wlan_exp_get_mac_addr(u32* src, u8* dest) { |
---|
171 | dest[0] = (src[0] >> 16) & 0xFF; |
---|
172 | dest[1] = (src[0] >> 24) & 0xFF; |
---|
173 | dest[2] = (src[1] >> 0) & 0xFF; |
---|
174 | dest[3] = (src[1] >> 8) & 0xFF; |
---|
175 | dest[4] = (src[1] >> 16) & 0xFF; |
---|
176 | dest[5] = (src[1] >> 24) & 0xFF; |
---|
177 | } |
---|
178 | |
---|
179 | #endif // End WLAN_SW_CONFIG_ENABLE_WLAN_EXP |
---|