Commit 62390602 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

smartbits-tester: added part of performance tests

parent 04dd60d2
......@@ -4,6 +4,7 @@
#include <string.h>
#include "et1000.h"
#include "smartbits.h"
#include "tests_body.h"
/**********************************************************************/
......@@ -159,6 +160,24 @@ int clear_allcntrs(int mask)
}
/**********************************************************************/
int show_floss(FILE *f, HTCountStructure *cntrs, unsigned long *total)
{
int i, loss[SMB_PORTS];
fprintf(f, "===========================\n");
fprintf(f, "| Port \t| Loss rate \t|\n");
fprintf(f, "===========================\n");
for(i=0; i<SMB_PORTS; ++i) {
if(total[i]!=0)
loss[i] = (total[i]-cntrs[i].RcvTrig)*100/total[i];
else
loss[i] = 0;
fprintf(f, "| %d \t| %d \t|\n", i, loss[i]);
}
}
/**********************************************************************/
int set_port_config(int p)
{
NSPhyConfig phycfg;
......@@ -244,8 +263,8 @@ int detect_stop(void)
FD_ZERO(&fds);
FD_SET(0, &fds);
tv.tv_sec = 1;
tv.tv_usec = 0;
tv.tv_sec = 0;
tv.tv_usec = 500000;
return select(1, &fds, NULL, NULL, &tv);
}
......@@ -254,10 +273,18 @@ int detect_stop(void)
long ratio_to_fps(int frame_size, float ratio)
{
long max_fps = 1000000000L / (frame_size+24) / 8;
//printf("max fps: %lu\n", max_fps);
return max_fps*ratio;
}
long ratio_to_gap(int frame_size, float ratio)
{
long fps = ratio_to_fps(frame_size, ratio);
return (1000000000L - (frame_size+12)*8*fps)/fps;
}
int reset_ports(int mask)
{
......@@ -409,3 +436,45 @@ int wait_test_done(int mask, int sec)
}
return 0;
}
/***************************************************/
int exp_rx_frames(struct smb_test *wrst, HTCountStructure *cntrs, unsigned long *exp)
{
int i_port, idp, j;
struct smb_port_tx *p_tx;
/* clear exp[] */
for(i_port=0; i_port<SMB_PORTS; ++i_port)
exp[i_port] = 0;
for(i_port=0; i_port<SMB_PORTS; ++i_port) {
/* take TX port */
p_tx = &(wrst->ptx[i_port]);
/* iterate through DST portx of TX port */
for(idp=0; idp < p_tx->d_ports_n; ++idp) {
if(p_tx->d_ports[idp] < SMB_PORTS && wrst->ftime == 0) {
/* first check if DST port is not broadcast */
/* increment appropriate port */
exp[ p_tx->d_ports[idp] ] += p_tx->fnum;
}
else if(p_tx->d_ports[idp] < SMB_PORTS && wrst->ftime > 0) {
/* still unicast, but now TX time was given instead of fnum */
/* all streams from one port have the same load */
exp[ p_tx->d_ports[idp] ] += cntrs[i_port].TmtPkt/p_tx->d_ports_n;
/* now check if at the end of the stream run, one more frame wasn't sent
* to analyzed port */
if( cntrs[i_port].TmtPkt % p_tx->d_ports_n > p_tx->d_ports[idp] )
exp[ p_tx->d_ports[idp] ]++;
}
else if(p_tx->d_ports[idp] == TX_PALL){
/* broadcast - increment all but TX port port */
for(j=0; j<SMB_PORTS; ++j)
if(j != i_port)
exp[j] + cntrs[i_port].TmtPkt;
}
}
}
return 0;
}
......@@ -39,6 +39,8 @@
fprintf(stderr, "\n%s = %d\n", #givenfunction, _____ireturncode); \
}
struct smb_test;
void linkToSmartBits();
void setTrigger(int h1, int s1, int p1);
void clearCounters(int h1, int s1, int p1);
......@@ -52,15 +54,18 @@ int temp_run_test(int p_tx, int p_rx);
int detect_stop(void);
long ratio_to_fps(int frame_size, float ratio);
long ratio_to_gap(int frame_size, float ratio);
int get_allcntrs(int mask, HTCountStructure *cntrs);
int show_allcntrs(FILE *f, int mask, HTCountStructure *cntrs);
int clear_allcntrs(int mask);
int show_floss(FILE *f, HTCountStructure *cntrs, unsigned long *total);
int reset_ports(int mask);
int run_traffic(int mask, int start);
int smb_learning(int mask, char [][6], int fnum);
int wait_linkup(int mask);
int smb_set_trigger(char *pat, int port, int offset, int range, int trigno);
int wait_test_done(int mask, int sec);
int exp_rx_frames(struct smb_test *wrst, HTCountStructure *cntrs, unsigned long *exp);
#endif
This diff is collapsed.
......@@ -16,8 +16,16 @@
#define VAR1 0
#define VAR2 1
#define TEST_3_1_1 7
#define TEST_3_1_2 8
#define TEST_3_1_3 9
#define TEST_3_1_4 10
#define TEST_3_1_5 11
#define TEST_3_2_1 12
#define TEST_3_2_2 13
#define TEST_3_3_1 14
#define TEST_3_3_2 15
extern const char* TLIST[7];
extern const char* TLIST[16];
//#define DPORT_NONE 0xFE
#define TX_PALL 0x4
......@@ -32,6 +40,9 @@ extern const char* TLIST[7];
#define TEST_WARNING 1
#define TEST_FAILED 0
#define TEST_FUNCTIONAL 0
#define TEST_PERFORMANCE 1
/* Tests parameters */
#define T_2XX_FNUM 1000
#define T_2XX_UNRECOG_THR 10
......@@ -45,6 +56,7 @@ struct smb_port_tx {
int q_vid; //VLAN ID, if 802.1d, make it -1
int q_pri; //priority, if 802.1d, make it -1
int fsize; //size of transmitted frames
int fsize_start;
int fsize_step;
int fsize_stop;
int fsize_tab[FSIZE_MAXTAB];
......@@ -52,7 +64,6 @@ struct smb_port_tx {
int fload[FLOAD_MAXTAB]; //traffic load [1..100]%
int fload_n;
int fnum; //amount of frames sent in a single burst
int ftime; //length of burst in seconds
};
struct smb_port_rx {
......@@ -64,10 +75,15 @@ struct smb_port_rx {
struct smb_test {
struct smb_port_tx ptx[SMB_PORTS];
struct smb_port_rx prx[SMB_PORTS];
int learning;
int variants;
int ftime; //length of burst in seconds
int test_type;
};
void init_wr_tests(int num);
int run_test( HTCountStructure *cntrs );
void init_wr_tests(int num, int variant);
int run_test( HTCountStructure *cntrs, int fload_idx, char mac[][6] );
int anl_result( HTCountStructure *cntrs, int testno);
int run_and_analyze(int test_no, FILE *logfile);
#endif
......@@ -13,9 +13,8 @@
int main()
{
HTCountStructure cntrs[SMB_PORTS];
FILE *logfile;
int test_no;
int test_no, result;
int t_pass = 0, t_warn = 0, t_fail = 0;
// Set Hub Slot Port location of the two cards in test
//int iHub = 0;
......@@ -57,35 +56,20 @@ int main()
}
for(test_no=0; test_no<6; ++test_no) {
//for(test_no=TEST_2_2_1; test_no<TEST_2_2_1+1; ++test_no) {
//for(test_no=TEST_3_1_1; test_no<TEST_3_1_1+1; ++test_no) {
//test_no = TEST_2_2_2;
printf("\n\n------ TEST %s ------\n", TLIST[test_no]);
fprintf(logfile, "\n\n------ TEST %s ------\n", TLIST[test_no]);
init_wr_test(test_no);
printf("Configuring WR Switch...\n");
wrs_config("127.0.0.1", test_no);
printf("Running test...");
fflush(stdout);
run_test(cntrs);
if (anl_result(cntrs, test_no) == TEST_PASSED) {
printf("Passed\n");
fprintf(logfile, "Passed\n");
++t_pass;
show_allcntrs(logfile, SMB_PALL, cntrs);
result = run_and_analyze(test_no, logfile);
switch (result) {
case TEST_PASSED:
++t_pass;
break;
case TEST_WARNING:
++t_warn;
break;
case TEST_FAILED:
++t_fail;
break;
}
else if (anl_result(cntrs, test_no) == TEST_WARNING) {
printf("Passed but with WARNING\n");
fprintf(logfile, "Passed but with WARNING\n");
++t_warn;
show_allcntrs(logfile, SMB_PALL, cntrs);
}
else {
printf("Failed\n");
fprintf(logfile, "Failed\n");
++t_fail;
show_allcntrs(logfile, SMB_PALL, cntrs);
}
show_allcntrs(stdout, SMB_PALL, cntrs);
NSDelay(5);
}
......@@ -391,23 +375,35 @@ int setup_stream(int port, char *dmac, char *smac, int fsize, int fnum, float ra
//printf("Calculated %lu frames/sec for %f ratio\n", ratio_to_fps(fsize, ratio), ratio);
if (idx >= 0) {
bzero(&l3_ext[idx], sizeof(L3StreamExtension));
l3_ext[idx].ulFrameRate = ratio_to_fps(fsize, ratio);
l3_ext[idx].ulBurstCount = fnum;
l3_ext[idx].uiInitialSeqNumber = 0;
l3_ext[idx].ucIPHeaderChecksumError = 0;
if (fnum > 0)
l3_ext[idx].ulTxMode = L3_SINGLE_BURST_MODE;
else
l3_ext[idx].ulTxMode = L3_CONTINUOUS_MODE;
//l3_ext[idx].ulFrameRate = ratio_to_fps(fsize, ratio);
//l3_ext[idx].ulBurstCount = fnum;
//l3_ext[idx].uiInitialSeqNumber = 0;
//l3_ext[idx].ucIPHeaderChecksumError = 0;
//if (fnum > 0)
// l3_ext[idx].ulTxMode = L3_SINGLE_BURST_MODE;
//else
// l3_ext[idx].ulTxMode = L3_CONTINUOUS_MODE;
}
else {
//printf("define L3 EXT for %d streams\n", n_streams);
CHECKERROR( HTSetStructure(L3_DEFINE_STREAM_EXTENSION, 0, 0, 0,
l3_ext, n_streams*sizeof(L3StreamExtension), HUB, SLOT, port) );
//printf("L3 EXT rate %lu count %lu\n", l3_ext[0].ulFrameRate, l3_ext[0].ulBurstCount);
//CHECKERROR( HTSetStructure(L3_DEFINE_STREAM_EXTENSION, 0, 0, 0,
// l3_ext, n_streams*sizeof(L3StreamExtension), HUB, SLOT, port) );
///*verify frame rate*/
//NSDelay(1);
//bzero(l3_ext, MAX_STREAMS*sizeof(L3StreamExtension));
//CHECKERROR( HTGetStructure(L3_READ_STREAM_EXTENSION, 1, 0, 0, l3_ext,
// sizeof(L3StreamExtension), HUB, SLOT, port) );
//printf("L3 EXT read rate %lu %s %lu\n", l3_ext[0].ulFrameRate,
// l3_ext[0].ulTxMode==L3_CONTINUOUS_MODE?"cont":"sburst", l3_ext[0].ulBurstCount);
bzero(&tx_mode, sizeof(NSPortTransmit));
tx_mode.ulBurstCount = n_streams*fnum;
tx_mode.ucScheduleMode = SCHEDULE_MODE_FRAME_RATE;
tx_mode.ucScheduleMode = SCHEDULE_MODE_GAP; //SCHEDULE_MODE_FRAME_RATE;
//printf("calculated gap %ld\n", ratio_to_gap(fsize, ratio));
tx_mode.ulInterFrameGap = ratio_to_gap(fsize, ratio);
tx_mode.uiGapScale = NANO_SCALE;
tx_mode.ucRandomGapEnable = 0;
if (fnum > 0)
tx_mode.ucTransmitMode = SINGLE_BURST_MODE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment