summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-04-10 17:23:07 +0300
committerHanoh Haim <hhaim@cisco.com>2016-04-10 17:23:07 +0300
commit392f47fb7956b108c36d45c37b52cb4b2c91091f (patch)
treefcd7cbd2e0601209438559591cd39d7dc90582bb
parent3c9c5ad0310f30b77565a7a5b8532fd83313ae57 (diff)
fix trex-197
-rwxr-xr-xsrc/bp_sim.cpp73
-rwxr-xr-xsrc/bp_sim.h23
-rwxr-xr-xsrc/global_io_mode.cpp10
-rwxr-xr-xsrc/global_io_mode.h7
-rw-r--r--src/main_dpdk.cpp39
-rwxr-xr-xsrc/platform_cfg.cpp7
-rwxr-xr-xsrc/platform_cfg.h6
7 files changed, 149 insertions, 16 deletions
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index cc9af837..0e87fbeb 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -65,7 +65,7 @@ void CGlobalMemory::Dump(FILE *fd){
uint32_t c_total=0;
int i=0;
- for (i=0; i<MBUF_SIZE; i++) {
+ for (i=0; i<MBUF_ELM_SIZE; i++) {
if ( (i>MBUF_9k) && (i<MBUF_DP_FLOWS)){
continue;
}
@@ -85,7 +85,7 @@ void CGlobalMemory::Dump(FILE *fd){
void CGlobalMemory::set(const CPlatformMemoryYamlInfo &info,float mul){
int i;
- for (i=0; i<MBUF_SIZE; i++) {
+ for (i=0; i<MBUF_ELM_SIZE; i++) {
m_mbuf[i]=(uint32_t)((float)info.m_mbuf[i]*mul);
}
/* no need to multiply */
@@ -97,6 +97,15 @@ void CGlobalMemory::set(const CPlatformMemoryYamlInfo &info,float mul){
m_mbuf[MBUF_2048] += info.m_mbuf[TRAFFIC_MBUF_2048];
m_mbuf[MBUF_4096] += info.m_mbuf[TRAFFIC_MBUF_4096];
m_mbuf[MBUF_9k] += info.m_mbuf[MBUF_9k];
+
+ for (i=0; i<MBUF_1024; i++) {
+ float per_queue_factor= (float)m_mbuf[i]/((float)m_pool_cache_size*(float)m_num_cores);
+ if (per_queue_factor<2.0) {
+ printf("WARNING not enough mbuf memory for this configuration trying to auto update\n");
+ printf(" %d : %f \n",(int)i,per_queue_factor);
+ m_mbuf[i]=(uint32_t)(m_mbuf[i]*2.0/per_queue_factor);
+ }
+ }
}
@@ -487,6 +496,42 @@ void CRteMemPool::dump_in_case_of_error(FILE *fd){
dump(fd);
}
+std::string CRteMemPool::add_to_json(
+ std::string name,
+ rte_mempool_t * pool,
+ bool last){
+ uint32_t p_free = rte_mempool_count(pool);
+ uint32_t p_size = pool->size;
+ char buff[200];
+ sprintf(buff,"\"%s\":[%llu,%llu]",name.c_str(),(unsigned long long)p_free,(unsigned long long)p_size);
+ std::string json = std::string(buff) + (last?std::string(""):std::string(","));
+ return (json);
+}
+
+
+std::string CRteMemPool::dump_as_json(uint8_t id,bool last){
+
+ char buff[200];
+ sprintf(buff,"\"socket-%d\":{", (int)id);
+
+ std::string json=std::string(buff);
+
+ json+=add_to_json("64b",m_small_mbuf_pool);
+ json+=add_to_json("128b",m_mbuf_pool_128);
+ json+=add_to_json("256b",m_mbuf_pool_256);
+ json+=add_to_json("512b",m_mbuf_pool_512);
+ json+=add_to_json("1024b",m_mbuf_pool_1024);
+ json+=add_to_json("2048b",m_mbuf_pool_2048);
+ json+=add_to_json("4096b",m_mbuf_pool_4096);
+ json+=add_to_json("9kb",m_mbuf_pool_9k,true);
+
+ json+="}" ;
+ if (last==false) {
+ json+="," ;
+ }
+ return (json);
+}
+
void CRteMemPool::dump(FILE *fd){
#define DUMP_MBUF(a,b) { float p=(100.0*(float)rte_mempool_count(b)/(float)b->size); fprintf(fd," %-30s : %.2f %% %s \n",a,p,(p<5.0?"<-":"OK") ); }
@@ -504,6 +549,29 @@ void CRteMemPool::dump(FILE *fd){
////////////////////////////////////////
+std::string CGlobalInfo::dump_pool_as_json(void){
+
+ std::string json="\"mbuf_stats\":{";
+ CPlatformSocketInfo * lpSocket =&m_socket;
+ int last_socket=-1;
+
+ /* calc the last socket */
+ int i;
+ for (i=0; i<(int)MAX_SOCKETS_SUPPORTED; i++) {
+ if (lpSocket->is_sockets_enable((socket_id_t)i)) {
+ last_socket=i;
+ }
+ }
+
+ for (i=0; i<(int)MAX_SOCKETS_SUPPORTED; i++) {
+ if (lpSocket->is_sockets_enable((socket_id_t)i)) {
+ json+=m_mem_pool[i].dump_as_json(i,last_socket==i?true:false);
+ }
+ }
+ json+="},";
+ return json;
+}
+
void CGlobalInfo::free_pools(){
CPlatformSocketInfo * lpSocket =&m_socket;
CRteMemPool * lpmem;
@@ -4514,6 +4582,7 @@ void CParserOption::dump(FILE *fd){
fprintf(fd," out file : %s \n",out_file.c_str());
fprintf(fd," duration : %.0f \n",m_duration);
fprintf(fd," factor : %.0f \n",m_factor);
+ fprintf(fd," mbuf_factor : %.0f \n",m_mbuf_factor);
fprintf(fd," latency : %d pkt/sec \n",m_latency_rate);
fprintf(fd," zmq_port : %d \n",m_zmq_port);
fprintf(fd," telnet_port : %d \n",m_telnet_port);
diff --git a/src/bp_sim.h b/src/bp_sim.h
index cd85e82b..371015d4 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -729,6 +729,7 @@ public:
public:
CParserOption(){
m_factor=1.0;
+ m_mbuf_factor=1.0;
m_duration=0.0;
m_latency_rate =0;
m_latency_mask =0xffffffff;
@@ -753,6 +754,7 @@ public:
CPreviewMode preview;
float m_factor;
+ float m_mbuf_factor;
float m_duration;
float m_platform_factor;
uint16_t m_vlan_port[2]; /* vlan value */
@@ -845,8 +847,8 @@ class CGlobalMemory {
public:
CGlobalMemory(){
CPlatformMemoryYamlInfo info;
- set(info,1.0);
m_num_cores=1;
+ m_pool_cache_size=32;
}
void set(const CPlatformMemoryYamlInfo &info,float mul);
@@ -861,11 +863,16 @@ public:
m_num_cores = cores;
}
+ void set_pool_cache_size(uint32_t pool_cache){
+ m_pool_cache_size=pool_cache;
+ }
+
void Dump(FILE *fd);
public:
- uint32_t m_mbuf[MBUF_SIZE]; // relative to traffic norm to 2x10G ports
+ uint32_t m_mbuf[MBUF_ELM_SIZE]; // relative to traffic norm to 2x10G ports
uint32_t m_num_cores;
+ uint32_t m_pool_cache_size;
};
@@ -1141,6 +1148,14 @@ public:
void dump_in_case_of_error(FILE *fd);
+ std::string dump_as_json(uint8_t id,bool last);
+
+private:
+ std::string add_to_json(std::string name,
+ rte_mempool_t * pool,
+ bool last=false);
+
+
public:
rte_mempool_t * m_small_mbuf_pool; /* pool for start packets */
@@ -1227,11 +1242,15 @@ public:
return (res);
}
+
static inline void free_node(CGenNode *p){
rte_mempool_put(m_mem_pool[0].m_mbuf_global_nodes, p);
}
+ static std::string dump_pool_as_json(void);
+
+
public:
static CRteMemPool m_mem_pool[MAX_SOCKETS_SUPPORTED];
diff --git a/src/global_io_mode.cpp b/src/global_io_mode.cpp
index 23b2c4a3..2457599e 100755
--- a/src/global_io_mode.cpp
+++ b/src/global_io_mode.cpp
@@ -96,7 +96,16 @@ bool CTrexGlobalIoMode::handle_io_modes(void){
m_rc_mode = rcDISABLE;
}
break;
+ case ccMem:
+ if ( m_g_mode==gNORMAL ){
+ m_g_mode=gMem;
+ }else{
+ m_g_mode=gNORMAL;
+ }
+ break;
}
+
+
}
return false;
}
@@ -121,6 +130,7 @@ void CTrexGlobalIoMode::DumpHelp(FILE *fd){
fprintf(fd," a : Global ports Toggle mode, disable -> enable \n");
fprintf(fd," l : Latency Toggle mode, disable -> enable -> enhanced \n");
fprintf(fd," r : Rx check Toggle mode, disable -> enable -> enhanced \n");
+ fprintf(fd," m : memory stats , disable -> enable \n");
fprintf(fd," Press h or 1 to go back to Normal mode \n");
}
diff --git a/src/global_io_mode.h b/src/global_io_mode.h
index bbdcb6ef..84b402b7 100755
--- a/src/global_io_mode.h
+++ b/src/global_io_mode.h
@@ -52,7 +52,8 @@ public:
ccGPP='p',
ccGAP='a',
ccGL='l',
- ccGRC='r'
+ ccGRC='r',
+ ccMem='m'
};
enum CliDumpMode {
@@ -65,7 +66,9 @@ public:
enum Global {
gDISABLE=0, // no print at all
gHELP=1, // help
- gNORMAL=2 // normal
+ gNORMAL=2, // normal
+ gMem=3
+
};
typedef uint8_t Global_t;
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 1f415958..78aee6ab 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -516,7 +516,7 @@ enum { OPT_HELP,
OPT_PUB_DISABLE,
OPT_LIMT_NUM_OF_PORTS,
OPT_PLAT_CFG_FILE,
-
+ OPT_MBUF_FACTOR,
OPT_LATENCY,
OPT_NO_CLEAN_FLOW_CLOSE,
@@ -601,6 +601,8 @@ static CSimpleOpt::SOption parser_options[] =
{ OPT_PREFIX, "--prefix", SO_REQ_SEP },
{ 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 },
+
SO_END_OF_OPTIONS
};
@@ -699,6 +701,7 @@ static int usage(){
printf(" --mac-spread : Spread the destination mac-order by this factor. e.g 2 will generate the traffic to 2 devices DEST-MAC ,DEST-MAC+1 \n");
printf(" maximum is up to 128 devices \n");
+ printf(" --mbuf-factor : factor for packet memory \n");
printf("\n simulation mode : \n");
printf(" Using this mode you can generate the traffic into a pcap file and learn how trex works \n");
@@ -892,6 +895,9 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t
node_dump=1;
po->preview.setFileWrite(false);
break;
+ case OPT_MBUF_FACTOR:
+ sscanf(args.OptionArg(),"%f", &po->m_mbuf_factor);
+ break;
case OPT_BW_FACTOR :
sscanf(args.OptionArg(),"%f", &po->m_factor);
break;
@@ -2343,7 +2349,7 @@ public:
public:
void Dump(FILE *fd,DumpFormat mode);
void DumpAllPorts(FILE *fd);
- void dump_json(std::string & json, bool baseline);
+ void dump_json(std::string & json, bool baseline,uint32_t stats_tick);
private:
std::string get_field(std::string name,float &f);
std::string get_field(std::string name,uint64_t &f);
@@ -2377,7 +2383,7 @@ std::string CGlobalStats::get_field_port(int port,std::string name,uint64_t &f){
}
-void CGlobalStats::dump_json(std::string & json, bool baseline){
+void CGlobalStats::dump_json(std::string & json, bool baseline,uint32_t stats_tick){
/* refactor this to JSON */
json="{\"name\":\"trex-global\",\"type\":0,";
@@ -2438,6 +2444,10 @@ void CGlobalStats::dump_json(std::string & json, bool baseline){
json+=GET_FIELD_PORT(i,m_total_rx_pps);
}
json+=m_template.dump_as_json("template");
+ if ( stats_tick %4==0){
+ json+=CGlobalInfo::dump_pool_as_json(); /* no need a feq update beacuse it trash the cores D cache, once in 2 sec */
+ }
+
json+="\"unknown\":0}}" ;
}
@@ -2724,6 +2734,7 @@ private:
CLatencyPktInfo m_latency_pkt;
TrexPublisher m_zmq_publisher;
CGlobalStats m_stats;
+ uint32_t m_stats_cnt;
std::mutex m_cp_lock;
public:
@@ -3094,6 +3105,7 @@ int CGlobalTRex::ixgbe_start(void){
bool CGlobalTRex::Create(){
CFlowsYamlInfo pre_yaml_info;
+ m_stats_cnt =0;
if (!get_is_stateless()) {
pre_yaml_info.load_from_yaml_file(CGlobalInfo::m_options.cfg_file);
}
@@ -3652,7 +3664,7 @@ CGlobalTRex::publish_async_data(bool sync_now, bool baseline) {
get_stats(m_stats);
}
- m_stats.dump_json(json, baseline);
+ m_stats.dump_json(json, baseline,m_stats_cnt);
m_zmq_publisher.publish_json(json);
/* generator json , all cores are the same just sample the first one */
@@ -3700,6 +3712,8 @@ int CGlobalTRex::run_in_master() {
std::unique_lock<std::mutex> cp_lock(m_cp_lock);
while ( true ) {
+ m_stats_cnt+=1;
+
if ( CGlobalInfo::m_options.preview.get_no_keyboard() ==false ){
if ( m_io_modes.handle_io_modes() ){
@@ -3744,6 +3758,13 @@ int CGlobalTRex::run_in_master() {
fprintf (stdout," test duration : %.1f sec \n",d);
}
+ if (m_io_modes.m_g_mode == CTrexGlobalIoMode::gMem) {
+
+ if ( m_stats_cnt%4==0){
+ fprintf (stdout," %s \n",CGlobalInfo::dump_pool_as_json().c_str());
+ }
+ }
+
if ( CGlobalInfo::m_options.is_rx_enabled() ){
m_mg.update();
@@ -3784,6 +3805,8 @@ int CGlobalTRex::run_in_master() {
}
}
+
+
/* publish data */
publish_async_data(false);
@@ -4256,9 +4279,15 @@ int update_global_info_from_platform_file(){
mul = mul*(float)cg->m_port_bandwidth_gb/10.0;
mul= mul * (float)cg->m_port_limit/2.0;
- CGlobalInfo::m_memory_cfg.set(cg->m_memory,mul);
+ mul= mul * CGlobalInfo::m_options.m_mbuf_factor;
+
+
+ CGlobalInfo::m_memory_cfg.set_pool_cache_size(RTE_MEMPOOL_CACHE_MAX_SIZE);
+
CGlobalInfo::m_memory_cfg.set_number_of_dp_cors(
CGlobalInfo::m_options.get_number_of_dp_cores_needed() );
+
+ CGlobalInfo::m_memory_cfg.set(cg->m_memory,mul);
return (0);
}
diff --git a/src/platform_cfg.cpp b/src/platform_cfg.cpp
index a76cea2b..e11b0fb5 100755
--- a/src/platform_cfg.cpp
+++ b/src/platform_cfg.cpp
@@ -28,10 +28,11 @@ limitations under the License.
void CPlatformMemoryYamlInfo::reset(){
int i;
i=0;
- for (i=0; i<MBUF_SIZE; i++) {
+ for (i=0; i<MBUF_ELM_SIZE; i++) {
m_mbuf[i] = CONST_NB_MBUF_2_10G;
}
m_mbuf[MBUF_64] = m_mbuf[MBUF_64]*2;
+
m_mbuf[MBUF_2048] = CONST_NB_MBUF_2_10G/2;
m_mbuf[MBUF_4096] = 128;
@@ -39,6 +40,8 @@ void CPlatformMemoryYamlInfo::reset(){
m_mbuf[TRAFFIC_MBUF_64] = m_mbuf[MBUF_64] * 4;
+ m_mbuf[TRAFFIC_MBUF_128] = m_mbuf[MBUF_128] * 4;
+
m_mbuf[TRAFFIC_MBUF_2048] = CONST_NB_MBUF_2_10G * 8;
m_mbuf[TRAFFIC_MBUF_4096] = 128;
@@ -140,7 +143,7 @@ void CPlatformMemoryYamlInfo::Dump(FILE *fd){
const std::string * names =get_mbuf_names();
int i=0;
- for (i=0; i<MBUF_SIZE; i++) {
+ for (i=0; i<MBUF_ELM_SIZE; i++) {
fprintf(fd," %-40s : %lu \n",names[i].c_str(), (ulong)m_mbuf[i]);
}
}
diff --git a/src/platform_cfg.h b/src/platform_cfg.h
index 682f33e8..1b56aad2 100755
--- a/src/platform_cfg.h
+++ b/src/platform_cfg.h
@@ -29,7 +29,7 @@ limitations under the License.
#include <string>
-#define CONST_NB_MBUF_2_10G (16380/4)
+#define CONST_NB_MBUF_2_10G (16380/2)
typedef enum { MBUF_64 , // per dual port, per NUMA
@@ -55,7 +55,7 @@ typedef enum { MBUF_64 , // per dual port, per NUMA
MBUF_DP_FLOWS ,
MBUF_GLOBAL_FLOWS ,
- MBUF_SIZE
+ MBUF_ELM_SIZE
} mbuf_sizes_t;
const std::string * get_mbuf_names(void);
@@ -157,7 +157,7 @@ public:
CPlatformMemoryYamlInfo(){
reset();
}
- uint32_t m_mbuf[MBUF_SIZE]; // relative to traffic norm to 2x10G ports
+ uint32_t m_mbuf[MBUF_ELM_SIZE]; // relative to traffic norm to 2x10G ports
public:
void Dump(FILE *fd);