/** @file wlan_exp_common.c * @brief Experiment Framework (Common) * * This contains the code for WLAN Experimental Framework. * * @copyright Copyright 2013-2019, Mango Communications. All rights reserved. * Distributed under the Mango Communications Reference Design License * See LICENSE.txt included in the design archive or * at http://mangocomm.com/802.11/license * * This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11) */ #include "wlan_mac_high_sw_config.h" #include "wlan_mac_common.h" #if WLAN_SW_CONFIG_ENABLE_WLAN_EXP // Xilinx / Standard library includes #include "wlan_platform_common.h" #include "wlan_platform_high.h" #include "xil_io.h" #include "string.h" // WLAN includes #include "wlan_mac_high.h" // WLAN Exp includes #include "wlan_exp_common.h" // Declared in wlan_mac_high.c extern platform_high_dev_info_t platform_high_dev_info; u8 wlan_exp_print_level = WLAN_EXP_DEFAULT_DEBUG_PRINT_LEVEL; const char* print_type_node = "NODE"; const char* print_type_transport = "TRANSPORT"; const char* print_type_event_log = "EVENT LOG"; const char* print_type_counts = "COUNTS"; const char* print_type_ltg = "LTG"; const char* print_type_queue = "QUEUE"; /******************************************************************** * WLAN Exp Print Header * * This prints a small header prior to other prints. It is no intended to be called * directly, but instead via the wlan_exp_printf macro. * * @param u8 level - WLAN_EXP_PRINT_NONE, WLAN_EXP_PRINT_ERROR, WLAN_EXP_PRINT_WARNING, * WLAN_EXP_PRINT_INFO, or WLAN_EXP_PRINT_DEBUG * * @return None * ********************************************************************/ void wlan_exp_print_header(u8 level, const char* type, char* filename, u32 line) { char* basename = NULL; if (type != NULL) { xil_printf("%s", type); if ((level <= WLAN_EXP_PRINT_WARNING) || (wlan_exp_print_level == WLAN_EXP_PRINT_DEBUG)) { basename = strrchr(filename, '/') ? strrchr(filename, '/') + 1 : filename; } if (wlan_exp_print_level == WLAN_EXP_PRINT_DEBUG) { xil_printf(" (%s:%d): ", basename, line); } else { xil_printf(": "); } switch (level) { case WLAN_EXP_PRINT_ERROR: xil_printf("ERROR (%s:%d): ", basename, line); break; case WLAN_EXP_PRINT_WARNING: xil_printf("WARNING (%s:%d): ", basename, line); break; } } } /******************************************************************** * WLAN Exp MAC Address * * This prints a 6-byte MAC address, depending on the current print level * * @param u8 level - WLAN_EXP_PRINT_NONE, WLAN_EXP_PRINT_ERROR, WLAN_EXP_PRINT_WARNING, * WLAN_EXP_PRINT_INFO, or WLAN_EXP_PRINT_DEBUG * @param u8* mac_address - first byte of MAC address * * @return None * ********************************************************************/ void wlan_exp_print_mac_address(u8 level, u8* mac_address) { if (level <= wlan_exp_print_level) { xil_printf("%02x:%02x:%02x:%02x:%02x:%02x\n", mac_address[0], mac_address[1], mac_address[2], mac_address[3], mac_address[4], mac_address[5]); } } /******************************************************************** * Set print level * * Sets the level of prints across wlan_exp. * * WLAN_EXP_PRINT_NONE: Stop all wlan_exp prints * WLAN_EXP_PRINT_ERROR: Only print the most extreme error conditions * WLAN_EXP_PRINT_WARNING: Print warnings and errors * WLAN_EXP_PRINT_INFO: Print informational messages in addition to warnings and errors * WLAN_EXP_PRINT_DEBUG: Include all wlan_exp prints for debugging. This may negatively * impact the performance of the node. * * @param u8 level - WLAN_EXP_PRINT_NONE, WLAN_EXP_PRINT_ERROR, WLAN_EXP_PRINT_WARNING, * WLAN_EXP_PRINT_INFO, or WLAN_EXP_PRINT_DEBUG * @param u8* mac_address - first byte of MAC address * * @return None * ********************************************************************/ void wlan_exp_set_print_level(u8 level) { switch (level) { case WLAN_EXP_PRINT_NONE: case WLAN_EXP_PRINT_ERROR: case WLAN_EXP_PRINT_WARNING: case WLAN_EXP_PRINT_INFO: case WLAN_EXP_PRINT_DEBUG: wlan_exp_print_level = level; break; default: xil_printf("Unsupported print level. Setting to WLAN_EXP_PRINT_ERROR.\n"); wlan_exp_print_level = WLAN_EXP_PRINT_ERROR; break; } } /******************************************************************** * WLAN Exp Null Callback * * This function is part of the callback system for processing commands. * * @param void* param - Parameters for the callback * * @return int - WLAN_SUCCESS * ********************************************************************/ int wlan_exp_null_callback(void* param){ wlan_exp_printf(WLAN_EXP_PRINT_INFO, print_type_node, "WLAN Exp NULL callback\n"); return WLAN_SUCCESS; } /****************************************************************************/ /** * Get MAC Address * * This function will populate the MAC address buffer, dest, with the MAC * address coming over the network (big endian). This uses the same formating * as the HW address parameter from transport.c * * @param src - Source buffer of MAC address (u32, byte swapped) * dest - Destination buffer of MAC address * * @return None. * * @note None. * ****************************************************************************/ void wlan_exp_get_mac_addr(u32* src, u8* dest) { dest[0] = (src[0] >> 16) & 0xFF; dest[1] = (src[0] >> 24) & 0xFF; dest[2] = (src[1] >> 0) & 0xFF; dest[3] = (src[1] >> 8) & 0xFF; dest[4] = (src[1] >> 16) & 0xFF; dest[5] = (src[1] >> 24) & 0xFF; } #endif // End WLAN_SW_CONFIG_ENABLE_WLAN_EXP