Commit 8e84ce99 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

adding SmartBits testing program

parent 4df5984d
CC = gcc
NAME = wrs_smb
CFLAGS = -I ../../smartlib/include
LDFLAGS = -L ../../smartlib/lib
LIB = ../../smartlib/lib/libetsmb.so
OBJ = wrs_smb.o smartbits.o tests_body.o switch_config.o
all: $(OBJ)
$(CC) $(LDFLAGS) -o $(NAME) $^ $(LIB)
%.o : %.c
$(CC) -c $(CFLAGS) $^
clean:
rm -rf *.o wrs_smb
This diff is collapsed.
#ifndef __SMARTBITS_H__
#define __SMARTBITS_H__
#define HUB 0
#define SLOT 7
#define IPADR "137.138.194.38"
//#define IPADR "127.0.0.1"
#define FIBER 1
#define BANK 0
//FIBER 0 BANK 0 -> regular ETH switch
//FIBER 1 BANK 0 -> WR switch
//FIBER 0 BANK 1 -> PCBE13137
//FIBER 1 BANK 1 -> loopback
/****** SmartBits device ******/
#define SMB_PORTS 4
#define SMB_P0 0x01
#define SMB_P1 0x02
#define SMB_P2 0x04
#define SMB_P3 0x08
#define SMB_PALL (SMB_P0 | SMB_P1 | SMB_P2 | SMB_P3)
#define PORT_TO_PMASK(i) (1<<(i))
#define FRAME_SZ 60
#define LINKUP_TIMEOUT 10
#define TRAFFIC_START 1
#define TRAFFIC_STOP 0
// macro CHECKERROR:
// in case of error displays the function name and the status
#define CHECKERROR(givenfunction) \
{\
int _____ireturncode = (givenfunction); \
if( _____ireturncode < 0 ) \
fprintf(stderr, "\n%s = %d\n", #givenfunction, _____ireturncode); \
}
void linkToSmartBits();
void setTrigger(int h1, int s1, int p1);
void clearCounters(int h1, int s1, int p1);
int set_port_config(int p);
void show_card_info(int p);
void show_cntrs(HTCountStructure *cs, int p1);
void latency_meas(int p_tx, int p_rx);
int basic_traffic(int fsize, int p_tx, int p_rx);
int setup_stream(int port, char *dmac, char *smac, int fsize, int fnum, float ratio, int v_pri, int vid);
int temp_run_test(int p_tx, int p_rx);
int detect_stop(void);
long ratio_to_fps(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 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);
#endif
#include <stdio.h>
#include <stdlib.h>
#include "switch_config.h"
int wrs_config(char *ip, int testno)
{
char cmd[100];
int list[7] = {211, 212, 221, 222, 225, 226, 227};
sprintf(cmd, "ssh -p %d root@%s %s %d >/dev/null 2>&1", WRS_PORT, ip, WRS_CONF_SCRIPT, list[testno]);
return system(cmd);
}
#ifndef __SWITCH_CONFIG_H__
#define __SWITCH_CONFIG_H__
#define WRS_PORT 2223
#define WRS_CONF_SCRIPT "/root/wrs_vlan_config.sh"
int wrs_config(char *ip, int testno);
#endif
This diff is collapsed.
#ifndef __TESTS_BODY_H__
#define __TESTS_BODY_H__
#include "et1000.h"
#include "smartbits.h"
#define TEST_2_1_1 0
#define TEST_2_1_2 1
#define TEST_2_2_1 2
#define TEST_2_2_2 3
#define TEST_2_2_5 4
#define TEST_2_2_6 5
#define TEST_2_2_7 6
extern const char* TLIST[7];
#define DPORT_NONE 0xFE
#define TX_PALL 0x4
#define VID_NONE -1
#define RX_PALL 0xFF
#define VLAN_TAG(vid,prio) ((0x8100 << 16) | (prio<<13) | (vid))
#define NOVLAN_TAG 0x0800
#define TEST_PASSED 2
#define TEST_WARNING 1
#define TEST_FAILED 0
/* Tests parameters */
#define T_2XX_FNUM 1000
#define T_2XX_UNRECOG_THR 10
struct smb_port_tx {
int d_port; //SMB destination port index [0..3]; 0xff for broadcast
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 fload; //traffic load [1..100]%
int fnum; //amount of frames sent in a single burst
};
struct smb_port_rx {
int s_port; //Source SMB port for setting TRIG1
char trig2_len; //TRIG2 pattern length, if 0 TRIG2 not set
char trig2_pat[6]; //TRIG2 pattern - Ethtype + VLAN tag
};
struct smb_test {
struct smb_port_tx ptx[SMB_PORTS];
struct smb_port_rx prx[SMB_PORTS];
};
void init_wr_tests(int num);
int run_test( HTCountStructure *cntrs );
int anl_result( HTCountStructure *cntrs, int testno);
#endif
This diff is collapsed.
#ifndef __WRS_SMB_H__
#define __WRS_SMB_H__
#define LOG_FILE "wrs-test"
FILE* open_logfile();
#endif
#!/bin/sh
/wr/bin/rtu_gd -g $1
if [ "$1" == "211" ] || [ "$1" == "212" ]; then
#remove VLAN 1
/wr/bin/rtu_stat vlan 1 1 0x0 1
fi
if [ "$1" == "221" ] || [ "$1" == "225" ] || [ "$1" == "226" ]; then
#configure VLAN 1
/wr/bin/rtu_stat vlan 1 1 0x3
fi
if [ "$1" == "222" ]; then
/wr/bin/rtu_stat vlan 1 1 0x1
fi
if [ "$1" == "227" ]; then
/wr/bin/rtu_stat vlan 1 1 0x20001
/wr/bin/rtu_stat vlan 2 2 0x00006
/wr/bin/rtu_stat vlan 3 3 0x00018
/wr/bin/rtu_stat vlan 4 4 0x00060
/wr/bin/rtu_stat vlan 5 5 0x00180
/wr/bin/rtu_stat vlan 6 6 0x00600
/wr/bin/rtu_stat vlan 7 7 0x01800
/wr/bin/rtu_stat vlan 8 8 0x06000
/wr/bin/rtu_stat vlan 9 9 0x18000
fi
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