OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [common/] [current/] [tests/] [nc_test_framework.h] - Blame information for rev 857

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      tests/nc_test_framework.h
4
//
5
//      Network characterization tests framework
6
//
7
//==========================================================================
8
// ####BSDALTCOPYRIGHTBEGIN####                                             
9
// -------------------------------------------                              
10
// Portions of this software may have been derived from FreeBSD, OpenBSD,   
11
// or other sources, and if so are covered by the appropriate copyright     
12
// and license included herein.                                             
13
// -------------------------------------------                              
14
// ####BSDALTCOPYRIGHTEND####                                               
15
//==========================================================================
16
//#####DESCRIPTIONBEGIN####
17
//
18
// Author(s):    gthomas
19
// Contributors: gthomas
20
// Date:         2000-01-10
21
// Purpose:      
22
// Description:  
23
//              
24
//
25
//####DESCRIPTIONEND####
26
//
27
//==========================================================================
28
 
29
#ifndef _TESTS_NC_TEST_FRAMEWORK_H_
30
#define _TESTS_NC_TEST_FRAMEWORK_H_
31
 
32
#ifdef __ECOS
33
#include <network.h>
34
#else
35
#undef _KERNEL
36
#include <sys/param.h>
37
#include <sys/socket.h>
38
#include <sys/ioctl.h>
39
#include <sys/errno.h>
40
#include <sys/time.h>
41
 
42
#include <net/if.h>
43
#include <netinet/in_systm.h>
44
#include <netinet/in.h>
45
#include <netinet/ip.h>
46
#include <netinet/ip_icmp.h>
47
#include <string.h>
48
 
49
#include <netdb.h>
50
#ifndef EAI_NONE
51
#define EAI_NONE 0
52
#endif
53
#endif
54
 
55
#ifdef __ECOS
56
#define test_printf diag_printf
57
typedef cyg_addrword_t test_param_t;
58
#else
59
#include <stdio.h>
60
#define test_printf printf
61
typedef void *test_param_t;
62
#endif
63
 
64
#ifndef true
65
#define false 0
66
#define true  1
67
#endif
68
 
69
#define NC_SLAVE_PORT  7777
70
#define NC_MASTER_PORT 7776
71
 
72
#define NC_TESTING_SLAVE_PORT  8770
73
#define NC_TESTING_MASTER_PORT 8771
74
 
75
#define __string(s) #s
76
#define _string(s) __string(s)
77
 
78
//
79
// The basic idea behind this test structure is that one end will run
80
// in "slave" mode and the other in "master" mode.  Typically, the slave
81
// will run on a target platform with the master running on a host.
82
//
83
// The slave starts up by listening for a connection on the "SLAVE_PORT".
84
// In order for the testing to require the minimum stack support, this
85
// connection (and the protocol) will use UDP.
86
//
87
// The master will connect to the slave and send it a request over this
88
// connection.  Once the slave accepts the request, then master and slave
89
// will execute the operation, typically a test.  The control connection
90
// will remain active until the master sends a 'disconnect' request.  The
91
// control connection will be broken after the reply to this request has
92
// been sent.
93
//
94
 
95
#define MAX_ERRORS          5   // Give up after this many errors
96
 
97
#define NC_REPLY_TIMEOUT    10  // The slave may be slow
98
#define NC_TEST_TIMEOUT     3   // More generous for tests
99
#define NC_RESULTS_TIMEOUT  (MAX_ERRORS+2)*NC_TEST_TIMEOUT
100
 
101
struct nc_request {
102
    int type;          // Description of request
103
    int seq;           // Sequence number, used to build response
104
    int nbufs;         // Number of "buffers" to send
105
    int buflen;        // Length of each buffer
106
    int slave_port;    // Network ports to use
107
    int master_port;
108
    int timeout;       // Max time to wait for any packet
109
};
110
 
111
#define NC_REQUEST_DISCONNECT 0x0001
112
#define NC_REQUEST_UDP_SEND   0x0010  // Slave to send UDP data
113
#define NC_REQUEST_UDP_RECV   0x0011  // Slave to receive UDP data
114
#define NC_REQUEST_UDP_ECHO   0x0012  // Master->slave->master
115
#define NC_REQUEST_TCP_SEND   0x0020  // Slave to send TCP data
116
#define NC_REQUEST_TCP_RECV   0x0021  // Slave to receive TCP data
117
#define NC_REQUEST_TCP_ECHO   0x0022  // Master->slave->master
118
#define NC_REQUEST_START_IDLE 0x0100  // Start some idle processing
119
#define NC_REQUEST_STOP_IDLE  0x0101  // Stop idle processing
120
#define NC_REQUEST_SET_LOAD   0x0200  // Set the background load level
121
 
122
struct nc_reply {
123
    int  response; // ACK or NAK
124
    int  seq;      // Must match request
125
    int  reason;   // If NAK, why request turned down
126
    union {        // Miscellaneous data, depending on request
127
        struct {
128
            long      elapsed_time;  // In 10ms "ticks"
129
            long      count[2];      // Result 
130
        } idle_results;
131
    } misc;
132
};
133
 
134
#define NC_REPLY_ACK  0x0001    // Request accepted
135
#define NC_REPLY_NAK  0x0000    // Request denied
136
 
137
#define NC_REPLY_NAK_UNKNOWN_REQUEST 0x0001
138
#define NC_REPLY_NAK_BAD_REQUEST     0x0002  // Slave can't handle
139
#define NC_REPLY_NAK_NO_BACKGROUND   0x0003  // Slave can't do background/idle
140
 
141
//
142
// Test data 'packets' look like this
143
 
144
struct nc_test_data {
145
    long  key1;
146
    int   seq;
147
    int   len;
148
    long  key2;
149
    char  data[0];  // Actual data
150
};
151
 
152
#define NC_TEST_DATA_KEY1 0xC0DEADC0
153
#define NC_TEST_DATA_KEY2 0xC0DEADC1
154
 
155
struct nc_test_results {
156
    long key1;         // Identify uniquely as a response record
157
    int  seq;          // Matches request
158
    int  nsent;
159
    int  nrecvd;
160
    long key2;         // Additional verification
161
};
162
 
163
#define NC_TEST_RESULT_KEY1 0xDEADC0DE
164
#define NC_TEST_RESULT_KEY2 0xDEADC1DE
165
 
166
#endif // _TESTS_NC_TEST_FRAMEWORK_H_
167
 
168
 
169
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.