diff options
author | 2016-06-23 17:10:33 +0300 | |
---|---|---|
committer | 2016-06-23 17:10:33 +0300 | |
commit | a215e9e300bc2870aa644d6c03d63d8d3e4e1644 (patch) | |
tree | 70f3ee7b4ac8e142cc63699374c3e8a02bd3a76d | |
parent | a36aff0da82e5391049559017ab9afb38b084d81 (diff) | |
parent | 6ea7b686a00192fc7e1e8e34160ec18e3de61d1a (diff) |
Merge FCS test
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py | 16 | ||||
-rwxr-xr-x | src/bp_sim.h | 6 | ||||
-rwxr-xr-x | src/common/basic_utils.cpp | 38 | ||||
-rwxr-xr-x | src/common/basic_utils.h | 10 | ||||
-rw-r--r-- | src/main_dpdk.cpp | 24 |
5 files changed, 81 insertions, 13 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py index 88a94865..3effa1f0 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py @@ -1047,12 +1047,7 @@ class CRxStats(CTRexStats): def __init__(self, ports): super(CRxStats, self).__init__() self.ports = ports - self.ports_speed = {} - def get_ports_speed(self): - for port in self.ports: - self.ports_speed[str(port)] = self.ports[port].get_speed_bps() - self.ports_speed['total'] = sum(self.ports_speed.values()) # calculates a diff between previous snapshot # and current one @@ -1170,8 +1165,8 @@ class CRxStats(CTRexStats): return # TX - self.get_ports_speed() for port in pg_current['tx_pkts'].keys(): + prev_tx_pps = pg_prev['tx_pps'].get(port) now_tx_pkts = pg_current['tx_pkts'].get(port) prev_tx_pkts = pg_prev['tx_pkts'].get(port) @@ -1180,19 +1175,20 @@ class CRxStats(CTRexStats): prev_tx_bps = pg_prev['tx_bps'].get(port) now_tx_bytes = pg_current['tx_bytes'].get(port) prev_tx_bytes = pg_prev['tx_bytes'].get(port) + pg_current['tx_bps'][port], pg_current['tx_bps_lpf'][port] = self.calc_bps(prev_tx_bps, now_tx_bytes, prev_tx_bytes, diff_sec) if pg_current['tx_bps'].get(port) != None and pg_current['tx_pps'].get(port) != None: pg_current['tx_bps_L1'][port] = calc_bps_L1(pg_current['tx_bps'][port], pg_current['tx_pps'][port]) pg_current['tx_bps_L1_lpf'][port] = calc_bps_L1(pg_current['tx_bps_lpf'][port], pg_current['tx_pps_lpf'][port]) - pg_current['tx_line_util'][port] = 100.0 * pg_current['tx_bps_L1'][port] / self.ports_speed[port] else: pg_current['tx_bps_L1'][port] = None pg_current['tx_bps_L1_lpf'][port] = None - pg_current['tx_line_util'][port] = None + # RX for port in pg_current['rx_pkts'].keys(): + prev_rx_pps = pg_prev['rx_pps'].get(port) now_rx_pkts = pg_current['rx_pkts'].get(port) prev_rx_pkts = pg_prev['rx_pkts'].get(port) @@ -1205,11 +1201,9 @@ class CRxStats(CTRexStats): if pg_current['rx_bps'].get(port) != None and pg_current['rx_pps'].get(port) != None: pg_current['rx_bps_L1'][port] = calc_bps_L1(pg_current['rx_bps'][port], pg_current['rx_pps'][port]) pg_current['rx_bps_L1_lpf'][port] = calc_bps_L1(pg_current['rx_bps_lpf'][port], pg_current['rx_pps_lpf'][port]) - pg_current['rx_line_util'][port] = 100.0 * pg_current['rx_bps_L1'][port] / self.ports_speed[port] else: pg_current['rx_bps_L1'][port] = None pg_current['rx_bps_L1_lpf'][port] = None - pg_current['rx_line_util'][port] = None def calc_pps (self, prev_bw, now, prev, diff_sec): @@ -1272,7 +1266,7 @@ class CRxStats(CTRexStats): stats[int(pg_id)][field][int(port)] = val if val != 'N/A' else StatNotAvailable(field) # BW values - for field in ['tx_pps', 'tx_bps', 'tx_bps_L1', 'rx_pps', 'rx_bps', 'rx_bps_L1', 'tx_line_util', 'rx_line_util']: + for field in ['tx_pps', 'tx_bps', 'tx_bps_L1', 'rx_pps', 'rx_bps', 'rx_bps_L1']: val = self.get([pg_id, field, 'total']) stats[int(pg_id)][field] = {'total': val if val != 'N/A' else StatNotAvailable(field)} for port in value[field].keys(): diff --git a/src/bp_sim.h b/src/bp_sim.h index 1f35faba..42ea2178 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -679,7 +679,13 @@ public: return (btGetMaskBit32(m_flags1,6,6) ? true:false); } + void setCoreDumpEnable(bool enable) { + btSetMaskBit32(m_flags1, 7, 7, (enable ? 1 : 0) ); + } + bool getCoreDumpEnable(){ + return (btGetMaskBit32(m_flags1, 7, 7) ? true : false); + } public: void Dump(FILE *fd); diff --git a/src/common/basic_utils.cpp b/src/common/basic_utils.cpp index 4f5578a6..b2277697 100755 --- a/src/common/basic_utils.cpp +++ b/src/common/basic_utils.cpp @@ -18,6 +18,7 @@ limitations under the License. #include <stdio.h> #include <string> #include <sstream> +#include <sys/resource.h> bool utl_is_file_exists (const std::string& name) { if (FILE *file = fopen(name.c_str(), "r")) { @@ -198,3 +199,40 @@ utl_generate_random_str(unsigned int &seed, int len) { return (ss.str()); } +/** + * define the coredump size + * allowed when crashing + * + * @param size - -1 means unlimited + * @param map_huge_pages - should the core map the huge TLB + * pages + */ +void utl_set_coredump_size(long size, bool map_huge_pages) { + int mask; + struct rlimit core_limits; + + if (size == -1) { + core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY; + } else { + core_limits.rlim_cur = core_limits.rlim_max = size; + } + + setrlimit(RLIMIT_CORE, &core_limits); + + /* set core dump mask */ + FILE *fp = fopen("/proc/self/coredump_filter", "wb"); + if (!fp) { + printf("failed to open /proc/self/coredump_filter\n"); + exit(-1); + } + + /* huge pages is the 5th bit */ + if (map_huge_pages) { + mask = 0x33; + } else { + mask = 0x13; + } + + fprintf(fp, "%08x\n", mask); + fclose(fp); +} diff --git a/src/common/basic_utils.h b/src/common/basic_utils.h index 63e858ab..1884e896 100755 --- a/src/common/basic_utils.h +++ b/src/common/basic_utils.h @@ -87,6 +87,16 @@ void utl_macaddr_to_str(const uint8_t *macaddr, std::string &output); std::string utl_generate_random_str(unsigned int &seed, int len); +/** + * define the coredump size + * allowed when crashing + * + * @param size - -1 means unlimited + * @param map_huge_pages - should the core map the huge TLB + * pages + */ +void utl_set_coredump_size(long size, bool map_huge_pages = false); + #endif diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index dcef2f38..4f8d8937 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -50,6 +50,7 @@ #include <rte_mbuf.h> #include <rte_random.h> #include <rte_version.h> + #include "bp_sim.h" #include "os_time.h" #include "common/arg/SimpleGlob.h" @@ -553,7 +554,9 @@ enum { OPT_HELP, OPT_PREFIX, OPT_MAC_SPLIT, OPT_SEND_DEBUG_PKT, - OPT_NO_WATCHDOG + OPT_NO_WATCHDOG, + OPT_ALLOW_COREDUMP + }; @@ -615,7 +618,8 @@ static CSimpleOpt::SOption parser_options[] = { OPT_MAC_SPLIT, "--mac-spread", SO_REQ_SEP }, { OPT_SEND_DEBUG_PKT, "--send-debug-pkt", SO_REQ_SEP }, { OPT_MBUF_FACTOR , "--mbuf-factor", SO_REQ_SEP }, - { OPT_NO_WATCHDOG , "--no-watchdog", SO_NONE }, + { OPT_NO_WATCHDOG , "--no-watchdog", SO_NONE }, + { OPT_ALLOW_COREDUMP , "--allow-coredump", SO_NONE }, SO_END_OF_OPTIONS @@ -718,6 +722,8 @@ static int usage(){ printf(" \n"); printf(" --no-watchdog : disable watchdog \n"); printf(" \n"); + printf(" --allow-coredump : allow a creation of core dump \n"); + printf(" \n"); printf(" --vm-sim : simulate vm with driver of one input queue and one output queue \n"); printf(" \n"); printf(" Examples: "); @@ -935,6 +941,10 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t po->preview.setWDDisable(true); break; + case OPT_ALLOW_COREDUMP : + po->preview.setCoreDumpEnable(true); + break; + case OPT_LATENCY_PREVIEW : sscanf(args.OptionArg(),"%d", &po->m_latency_prev); break; @@ -4703,6 +4713,15 @@ int main_test(int argc , char * argv[]){ exit(-1); } + /* enable core dump if requested */ + if (CGlobalInfo::m_options.preview.getCoreDumpEnable()) { + utl_set_coredump_size(-1); + } + else { + utl_set_coredump_size(0); + } + + update_global_info_from_platform_file(); /* It is not a mistake. Give the user higher priorty over the configuration file */ @@ -5779,3 +5798,4 @@ int TrexDpdkPlatformApi::get_active_pgids(flow_stat_active_t &result) const { CFlowStatParser *TrexDpdkPlatformApi::get_flow_stat_parser() const { return CTRexExtendedDriverDb::Ins()->get_drv()->get_flow_stat_parser(); } + |