-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.h
119 lines (99 loc) · 2.5 KB
/
test.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#ifndef _TEST_HEAD_H
#define _TEST_HEAD_H
enum req_status {
reqs_initial,
reqs_setup,
reqs_sent,
reqs_wip,
reqs_done,
};
extern char * req_status_string[];
struct req_statstic {
unsigned long long t_reqs;
unsigned long long t_aborted;
unsigned long long t_missed;
};
#define APPS_NUM 4
#define PKTG_NUM 4
#define PKTG_CONFIG_NUM 1
/*
* This represent one burst of packet sent out from the TG
* Although we can simply specify the duration in total (i.e. one prameter
* only, but it's more like a TG with size of packet number and duration as
* packet size
*/
struct request_entry
{
int size;
int duration;
};
struct request_config
{
int entnum;
struct request_entry *entries;
};
struct test_config
{
int num_apps;
int num_pktgens;
struct request_config *configs;
};
/*
* This is a producer program to emulate the work of a packet generator.
* It tries to feed packet requirement to the DPDKapp thread.
*/
struct request {
int id;
/* The update to this function is through atomic function and hope
* that's memory barrier safe
*/
volatile int status;
int eabort;
/* request information */
struct request_entry req;
/* How many has been done */
volatile int done;
/* the time the request is sent out */
unsigned long long rtime;
/* the time the request is expected to finish
* if the handling finished after this point, the
* DPDKapp should exit handling and then some packet lost
*/
unsigned long long deadline;
/* The time the DPDKApp begin the handling */
unsigned long long stime;
/* The time the DPDKApp finish the handling */
unsigned long long etime;
struct req_statstic stats;
};
extern int req_number;
extern struct request *request_array;
extern struct request *getRequest(int number);
extern int initRequests(int number);
extern void freeRequests(void);
void dumpGenResults(void);
void dumpAppResults(void);
void wait_dpdk_done(void);
void wait_pktgen_done(void);
int init_dpdk_apps(int num_apps);
void free_dpdk_apps(void);
int init_pktgens(int num_pktgens, struct request_config *config);
void free_pktgens(void);
extern volatile int gen_loop;
extern volatile int app_loop;
extern int tprintf(const char *format, ...);
typedef unsigned long long ttime_t;
static inline unsigned long long rdtscl(void)
{
unsigned long low, high;
asm volatile("rdtsc" : "=a" (low), "=d" (high));
return ((low) | (high) << 32);
}
static inline ttime_t getNow(void)
{
return (ttime_t)rdtscl();
}
#define MAX_APPS 0x4
#define KVM_HYPERCALL \
(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9")
#endif