/* BEGIN_ICS_COPYRIGHT5 **************************************** Copyright (c) 2015-2017, Intel Corporation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ** END_ICS_COPYRIGHT5 ****************************************/ //==============================================================================// // // // FILE NAME // // cs_utility.c // // // // DESCRIPTION // // This file contains miscellaneous utility routiness. // // // // DATA STRUCTURES // // None // // // // FUNCTIONS // // bm_log write out logging information // // // // DEPENDENCIES // // // // HISTORY // // // // NAME DATE REMARKS // // sjb 04/09/04 Initial creation of file. // // // //==============================================================================// #include #include #include #include "cs_log.h" #include "cs_queue.h" #include "stl_mad_priv.h" #include "ib_mad.h" #include "ib_sa.h" #include "stl_pa_priv.h" #include "sm_l.h" #include "stl_sa_priv.h" #include "mai_g.h" #include "sm_dbsync.h" #include "if3.h" uint32_t cs_log_masks[VIEO_LAST_MOD_ID+1] = { DEFAULT_LOG_MASK, // VIEO_NONE_MOD_ID for vs_syslog_output_message 0, // VIEO_CS_MOD_ID /* Library Modules */ DEFAULT_LOG_MASK, // VIEO_MAI_MOD_ID DEFAULT_LOG_MASK, // VIEO_CAL_MOD_ID DEFAULT_LOG_MASK, // VIEO_DRIVER_MOD_ID DEFAULT_LOG_MASK, // VIEO_IF3_MOD_ID DEFAULT_LOG_MASK, // VIEO_SM_MOD_ID /* Subnet Mgr */ DEFAULT_LOG_MASK, // VIEO_SA_MOD_ID /* Subnet Administrator */ DEFAULT_LOG_MASK, // VIEO_PM_MOD_ID /* Performance Mgr */ DEFAULT_LOG_MASK, // VIEO_PA_MOD_ID /* Performance Administrator */ DEFAULT_LOG_MASK, // VIEO_BM_MOD_ID /* Baseboard Mgr */ DEFAULT_LOG_MASK, // VIEO_FE_MOD_ID /* Fabric Executive */ DEFAULT_LOG_MASK, // VIEO_APP_MOD_ID /* Generic VIEO mod id */ }; // module name in form of "name: ", useful for messages where name is optional // for VIEO_NONE_MOD_ID, returns "" const char * cs_log_get_module_prefix(uint32_t modid) { switch (modid) { case VIEO_NONE_MOD_ID: return ""; case VIEO_CS_MOD_ID: return "CS: "; case VIEO_MAI_MOD_ID: return "MAI: "; case VIEO_CAL_MOD_ID: return "CAL: "; case VIEO_DRIVER_MOD_ID:return "DVR: "; case VIEO_IF3_MOD_ID: return "IF3: "; case VIEO_SM_MOD_ID: return "SM: "; case VIEO_SA_MOD_ID: return "SA: "; case VIEO_PM_MOD_ID: return "PM: "; case VIEO_PA_MOD_ID: return "PA: "; case VIEO_BM_MOD_ID: return "BM: "; case VIEO_FE_MOD_ID: return "FE: "; case VIEO_APP_MOD_ID: return "APP: "; default: return "Unkwn: "; } } // module name in simple form, useful to put in middle of other messages // names provided also match prefixes used in LogMask config file names // for VIEO_NONE_MOD_ID, returns "NONE" const char * cs_log_get_module_name(uint32_t modid) { switch (modid) { case VIEO_NONE_MOD_ID: return "NONE"; case VIEO_CS_MOD_ID: return "CS"; case VIEO_MAI_MOD_ID: return "MAI"; case VIEO_CAL_MOD_ID: return "CAL"; case VIEO_DRIVER_MOD_ID:return "DVR"; case VIEO_IF3_MOD_ID: return "IF3"; case VIEO_SM_MOD_ID: return "SM"; case VIEO_SA_MOD_ID: return "SA"; case VIEO_PM_MOD_ID: return "PM"; case VIEO_PA_MOD_ID: return "PA"; case VIEO_BM_MOD_ID: return "BM"; case VIEO_FE_MOD_ID: return "FE"; case VIEO_APP_MOD_ID: return "APP"; default: return "Unkwn"; } } // convert module name to modid // names provided also match prefixes used in LogMask config file names uint32_t cs_log_get_module_id(const char * mod) { uint32_t modid; for (modid = 0 ; modid <= VIEO_LAST_MOD_ID; modid++) { if (modid == VIEO_NONE_MOD_ID) continue; if (0 == strcmp(cs_log_get_module_name(modid), mod)) return modid; } return 0; // VIEO_NONE_MOD_ID } const char* cs_log_get_sev_name(uint32_t sev) { switch (sev) { case VS_LOG_NONE: return ""; case VS_LOG_FATAL: return "FATAL"; case VS_LOG_CSM_ERROR: return "ERROR"; case VS_LOG_CSM_WARN: return "WARN "; case VS_LOG_CSM_NOTICE: return "NOTIC"; case VS_LOG_CSM_INFO: return "INFO "; case VS_LOG_ERROR: return "ERROR"; case VS_LOG_WARN: return "WARN "; case VS_LOG_NOTICE: return "NOTIC"; case VS_LOG_INFINI_INFO:return "PROGR"; case VS_LOG_INFO: return "INFO "; case VS_LOG_VERBOSE: return "VBOSE"; case VS_LOG_DATA: return "DATA "; case VS_LOG_DEBUG1: return "DBG1 "; case VS_LOG_DEBUG2: return "DBG2 "; case VS_LOG_DEBUG3: return "DBG3 "; case VS_LOG_DEBUG4: return "DBG4 "; case VS_LOG_ENTER: return "ENTER"; case VS_LOG_ARGS: return "ARGS "; case VS_LOG_EXIT: return "EXIT "; default: return "UNKWN"; } } // translate level and mode to a sev_mask and a mod_mask of modules // which sev_mask should be set for. modules not in mod_mask // should get a sev_mask of 0 static void cs_log_translate_level(uint32_t level, int mode, uint32_t *mod_mask, uint32_t *sev_mask) { switch(level) { case 5: /* All of the modules on. */ *mod_mask = VS_MOD_ALL; break; default: *mod_mask = (VS_MOD_ALL & ~(1< MIN_SWITCH_PORTS) { tiers++; subnet_size /= (MIN_SWITCH_PORTS/2); } return tiers; } // assuming a fat tree topology with switches of size MIN_SWITCH_PORTS // compute number of switches in a typical FBB fabric uint32_t cs_numSwitches(uint32_t subnet_size) { // edge switches (and intermediate tiers) uint32_t edge_sw = (subnet_size + (MIN_SWITCH_PORTS/2)-1)/(MIN_SWITCH_PORTS/2); uint32_t tiers = cs_numTiers(subnet_size); // core/spine is half as many switches as edge return (edge_sw * (tiers-1)) + (edge_sw/2); } // assuming a fat tree topology with switches of size MIN_SWITCH_PORTS // compute number of node records (1 per CA port, 1 per switch) // in a typical FBB fabric uint32_t cs_numNodeRecords(uint32_t subnet_size) { return subnet_size + cs_numSwitches(subnet_size); } // assuming a fat tree topology with switches of size MIN_SWITCH_PORTS // compute number of port records (1 per CA port, 1 per switch port) // in a typical FBB fabric // (this will be slightly high for larger switches since there will // be fewer switches (less switch port 0), less tiers and potentially // fewer ISLs (hence fewer switch ports). uint32_t cs_numPortRecords(uint32_t subnet_size) { // +1 is for port 0 of switch chips return subnet_size + cs_numSwitches(subnet_size) * (MIN_SWITCH_PORTS+1); } // assuming a fat tree topology with switches of size MIN_SWITCH_PORTS // compute number of links records (ISL and CA to Switch) // in a typical FBB fabric uint32_t cs_numLinkRecords(uint32_t subnet_size) { // standard switching tiers calculation is a hair too low, so increase // the number of switching tiers to accommodate the number of links records. return (cs_numTiers(subnet_size) + 2)*subnet_size; }