dpdk: Add support for Mellanox ConnectX-4 devices
[vpp.git] / g2 / g2.h
1 /* 
2  *------------------------------------------------------------------
3  * Copyright (c) 2005-2016 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /*
18  * typedefs and so forth
19  */
20 #include <sys/types.h>
21 #include <gtk-2.0/gtk/gtk.h>
22 #include <stdio.h>
23 #include "props.h"
24
25 typedef char boolean;
26 typedef unsigned long long ulonglong;
27
28 /*
29  * main.c
30  */
31
32 GtkWidget *g_mainwindow;
33 GtkWidget *g_mainvbox;
34 GtkWidget *g_mainhbox;
35
36 /*
37  * pointsel.c
38  */
39 void point_selector_init(void);
40 boolean read_event_definitions (char *filename);
41 char *sxerox(char *);
42 void pointsel_about(char *);
43 void pointsel_next_snapshot(void);
44 void initialize_events(void);
45 void finalize_events(void);
46
47 #define NEVENTS 100000
48
49 typedef struct event_def_ {
50     ulong event;
51     char *name;
52     char *format;
53     boolean selected;
54     boolean is_clib;
55     char pad[2];
56 } event_def_t;
57
58 event_def_t *find_event_definition (ulong code);
59
60 event_def_t g_eventdefs[NEVENTS];
61
62 /*
63  * config params
64  */
65 int c_maxpointsel;        /* max # points shown in selector dlg */
66 gint c_view1_draw_width;
67 gint c_view1_draw_height;
68
69 /*
70  * menu1.c
71  */
72
73 void menu1_init(void);
74 void modal_dialog (char *label_text, char *retry_text, char *default_value, 
75                    boolean (*cb)(char *));
76 void infobox(char *label_text, char *text);
77 /*
78  * view1.c
79  */
80 GdkFont *g_font;
81 GdkColor fg_black, bg_white;
82 void view1_init(void);
83 void view1_display(void);
84 void view1_read_events_callback(void);
85 void view1_display_when_idle(void);
86 void view1_print_callback(GtkToggleButton *item, gpointer data);
87 void view1_about(char *);
88 void set_pid_ax_width(int width);
89 void set_window_title(const char *filename);
90
91 enum view1_tbox_fn {
92     TBOX_DRAW_BOXED = 1,        /* note: order counts */
93         TBOX_DRAW_EVENT,
94     TBOX_DRAW_PLAIN,
95     TBOX_PRINT_BOXED,
96         TBOX_PRINT_EVENT,
97     TBOX_PRINT_PLAIN,           /* end restriction */
98     TBOX_GETRECT_BOXED,
99         TBOX_GETRECT_EVENT,
100     TBOX_GETRECT_PLAIN,
101 };
102
103 enum view1_line_fn {
104     LINE_DRAW_BLACK = 1,
105     LINE_DRAW_WHITE,
106     LINE_PRINT,
107 };
108
109 GdkRectangle *tbox (char *s, int x, int y, enum view1_tbox_fn function);
110 void line (int x1, int y1, int x2, int y2, enum view1_line_fn function);
111 gint view1_handle_key_press_event (GtkWidget *widget, GdkEventKey *event);
112
113 /*
114  * events.c
115  */
116
117 void events_about (char *);
118
119 typedef struct raw_event {
120     unsigned long time[2];
121     unsigned long pid;
122     unsigned long code;
123     unsigned long datum;
124 } raw_event_t;
125
126 void event_init(void);
127 char *mapfile (char *file, ulong *sizep);
128 boolean unmapfile (char *addr, ulong size);
129 void read_events (char *);
130 int find_event_index (ulonglong t);
131 int read_cpel_file(char *file);
132 int read_clib_file(char *file);
133 void cpel_event_init(ulong);
134 void add_event_from_cpel_file(ulong, char * , char *);
135 void add_event_from_clib_file(unsigned int event, char *name, 
136                               unsigned int vec_index);
137 void add_cpel_event(ulonglong delta, ulong, ulong, ulong);
138 void add_clib_event(double delta, unsigned short track, 
139                     unsigned short event, unsigned int index);
140 void cpel_event_finalize(void);
141 void *get_clib_event (unsigned int datum);
142
143 typedef struct pid_data {
144     struct pid_data *next;
145     ulong pid_value;            /* The actual pid value */
146     ulong pid_index;            /* Index in pid sort order */
147 } pid_data_t;
148     
149 #define EVENT_FLAG_SELECT       0x00000001 /* This event is selected */
150 #define EVENT_FLAG_SEARCHRSLT   0x00000002 /* This event is the search rslt */
151 #define EVENT_FLAG_CLIB         0x00000004 /* clib event */
152
153 typedef struct pid_sort {
154     struct pid_data *pid;
155     ulong pid_value;
156     /*
157      * This is a bit of a hack, since this is used only by the view:
158      */
159     unsigned color_index;
160 } pid_sort_t;
161
162 typedef struct event {
163     ulonglong time;
164     ulong code;
165     pid_data_t *pid;
166     ulong datum;
167     ulong flags;
168 } event_t;
169
170
171 boolean g_little_endian;
172 event_t *g_events;
173 ulong g_nevents;
174 pid_sort_t *g_pids;
175 pid_sort_t *g_original_pids;
176 int g_npids;
177 pid_data_t *g_pid_data_list;
178
179 #define PIDHASH_NBUCKETS        20021 /* Should be prime */
180
181 boolean ticks_per_ns_set;
182 double ticks_per_ns;
183
184 /*
185  * version.c
186  */
187 const char *version_string;
188 const char *minor_v_string;
189
190 /*
191  * cpel.c
192  */
193 char *get_track_label(unsigned long);
194 int widest_track_format;
195 char *strtab_ref(unsigned long);