Commit | Line | Data |
---|---|---|
9e066e23 CM |
1 | /* |
2 | * Copyright (C) 2012 Fusion-io | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public | |
6 | * License v2 as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program; if not, write to the Free Software | |
15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
16 | * | |
17 | */ | |
18 | #ifndef __IOWATCH_PLOT__ | |
19 | #define __IOWATCH_PLOT__ | |
20 | #define MAX_TICKS 10 | |
21 | ||
ba758825 CM |
22 | #include "list.h" |
23 | ||
9e066e23 CM |
24 | typedef __u64 u64; |
25 | typedef __u32 u32; | |
26 | typedef __u16 u16; | |
27 | ||
ba758825 | 28 | |
cc3d54d5 CM |
29 | /* values for the plot direction field */ |
30 | #define PLOT_DOWN 0 | |
31 | #define PLOT_ACROSS 1 | |
32 | ||
9e066e23 CM |
33 | struct plot { |
34 | int fd; | |
35 | ||
36 | /* svg style y = 0 is the top of the graph */ | |
37 | int start_y_offset; | |
38 | ||
39 | /* abs coords of the start of X start of the plot */ | |
40 | int start_x_offset; | |
41 | ||
42 | int add_xlabel; | |
8ed9516f | 43 | int no_legend; |
9e066e23 CM |
44 | |
45 | /* | |
46 | * these two are for anyone that wants | |
47 | * to add a plot after this one, it tells | |
48 | * them how much space we took up | |
49 | */ | |
50 | int total_height; | |
51 | int total_width; | |
52 | char **legend_lines; | |
53 | int legend_index; | |
54 | int num_legend_lines; | |
cc3d54d5 CM |
55 | int direction; |
56 | ||
57 | /* | |
58 | * timeline is a vertical line through line graphs that | |
59 | * is used by the movie mode to show where in the graph | |
60 | * our current frame lives | |
61 | */ | |
62 | int timeline; | |
9e066e23 CM |
63 | }; |
64 | ||
65 | struct graph_line_pair { | |
66 | u64 count; | |
67 | u64 sum; | |
68 | }; | |
69 | ||
70 | struct graph_line_data { | |
230f0601 JK |
71 | /* beginning of an interval displayed by this graph */ |
72 | int min_seconds; | |
73 | ||
74 | /* end of an interval displayed by this graph */ | |
f752a6eb | 75 | int max_seconds; |
9e066e23 CM |
76 | |
77 | int stop_seconds; | |
78 | ||
79 | /* Y max */ | |
80 | u64 max; | |
81 | ||
82 | /* label for this graph */ | |
83 | char *label; | |
84 | struct graph_line_pair data[]; | |
85 | }; | |
86 | ||
87 | struct graph_dot_data { | |
9b9fa04b | 88 | u64 min_offset; |
9e066e23 | 89 | u64 max_offset; |
bfb0e441 CM |
90 | u64 max_bank; |
91 | u64 max_bank_offset; | |
9e066e23 | 92 | u64 total_ios; |
bfb0e441 CM |
93 | u64 total_bank_ios; |
94 | ||
95 | int add_bank_ios; | |
9e066e23 CM |
96 | |
97 | /* in pixels, number of rows in our bitmap */ | |
98 | int rows; | |
99 | /* in pixels, number of cols in our bitmap */ | |
100 | int cols; | |
101 | ||
230f0601 JK |
102 | /* beginning of an interval displayed by this graph */ |
103 | int min_seconds; | |
104 | ||
105 | /* end of an interval displayed by this graph */ | |
f752a6eb | 106 | int max_seconds; |
9e066e23 CM |
107 | int stop_seconds; |
108 | ||
109 | /* label for the legend */ | |
110 | char *label; | |
111 | ||
112 | /* bitmap, one bit for each cell to light up */ | |
113 | unsigned char data[]; | |
114 | }; | |
115 | ||
ba758825 CM |
116 | struct plot_history { |
117 | struct list_head list; | |
abf08f96 | 118 | double history_max; |
ba758825 CM |
119 | int history_len; |
120 | int num_used; | |
121 | int col; | |
122 | char *color; | |
123 | double *history; | |
124 | }; | |
125 | ||
9e066e23 | 126 | int svg_io_graph(struct plot *plot, struct graph_dot_data *gdd, char *color); |
bfb0e441 | 127 | int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color, int thresh1, int thresh2); |
230f0601 | 128 | struct graph_line_data *alloc_line_data(int min_seconds, int max_seconds, int stop_seconds); |
9e066e23 | 129 | void free_line_data(struct graph_line_data *gld); |
230f0601 | 130 | struct graph_dot_data *alloc_dot_data(int min_seconds, int max_seconds, u64 min_offset, u64 max_offset, int stop_seconds); |
9e066e23 | 131 | void free_dot_data(struct graph_dot_data *gdd); |
ba758825 | 132 | void set_gdd_bit(struct graph_dot_data *gdd, u64 offset, double bytes, double time); |
9e066e23 CM |
133 | void print_gdd(struct graph_dot_data *gdd); |
134 | void write_svg_header(int fd); | |
ba758825 | 135 | struct plot *alloc_plot(void); |
9e066e23 | 136 | int close_plot(struct plot *plot); |
8ed9516f | 137 | int close_plot_no_height(struct plot *plot); |
9e066e23 CM |
138 | void setup_axis(struct plot *plot); |
139 | void set_xticks(struct plot *plot, int num_ticks, int first, int last); | |
140 | void set_yticks(struct plot *plot, int num_ticks, int first, int last, char *units); | |
141 | void set_plot_title(struct plot *plot, char *title); | |
142 | void set_plot_label(struct plot *plot, char *label); | |
143 | void set_xlabel(struct plot *plot, char *label); | |
144 | void set_ylabel(struct plot *plot, char *label); | |
145 | void scale_line_graph_bytes(u64 *max, char **units, u64 factor); | |
146 | void scale_line_graph_time(u64 *max, char **units); | |
147 | void write_drop_shadow(struct plot *plot); | |
148 | void write_drop_shadow_line(struct plot *plot); | |
149 | void svg_write_legend(struct plot *plot); | |
150 | void svg_add_legend(struct plot *plot, char *text, char *extra, char *color); | |
151 | void svg_alloc_legend(struct plot *plot, int num_lines); | |
152 | void set_legend_width(int longest_str); | |
153 | void set_rolling_avg(int rolling); | |
e199d546 | 154 | void svg_free_legend(struct plot *plot); |
ba758825 CM |
155 | void set_io_graph_scale(int scale); |
156 | void set_plot_output(struct plot *plot, char *filename); | |
157 | void set_graph_size(int width, int height); | |
158 | void get_graph_size(int *width, int *height); | |
159 | int svg_io_graph_movie(struct graph_dot_data *gdd, struct plot_history *ph, int col); | |
abf08f96 | 160 | int svg_io_graph_movie_array(struct plot *plot, struct plot_history *ph); |
ba758825 CM |
161 | void svg_write_time_line(struct plot *plot, int col); |
162 | void set_graph_height(int h); | |
163 | void set_graph_width(int w); | |
abf08f96 CM |
164 | int close_plot_file(struct plot *plot); |
165 | int svg_io_graph_movie_array_spindle(struct plot *plot, struct plot_history *ph); | |
166 | void rewind_spindle_steps(int num); | |
167 | void setup_axis_spindle(struct plot *plot); | |
8ed9516f | 168 | int close_plot_col(struct plot *plot); |
9e066e23 | 169 | #endif |