1#include <string.h>
2
3#include "thread_options.h"
4
5static void string_to_cpu(char **dst, const uint8_t *src)
6{
7	const char *__src = (const char *) src;
8
9	if (strlen(__src))
10		*dst = strdup(__src);
11}
12
13static void __string_to_net(uint8_t *dst, const char *src, size_t dst_size)
14{
15	if (src) {
16		dst[dst_size - 1] = '\0';
17		strncpy((char *) dst, src, dst_size - 1);
18	} else
19		dst[0] = '\0';
20}
21
22#define string_to_net(dst, src)	__string_to_net((dst), (src), sizeof(dst))
23
24static void free_thread_options_to_cpu(struct thread_options *o)
25{
26	free(o->description);
27	free(o->name);
28	free(o->directory);
29	free(o->filename);
30	free(o->filename_format);
31	free(o->opendir);
32	free(o->ioengine);
33	free(o->mmapfile);
34	free(o->read_iolog_file);
35	free(o->write_iolog_file);
36	free(o->bw_log_file);
37	free(o->lat_log_file);
38	free(o->iops_log_file);
39	free(o->replay_redirect);
40	free(o->exec_prerun);
41	free(o->exec_postrun);
42	free(o->ioscheduler);
43	free(o->profile);
44	free(o->cgroup);
45}
46
47void convert_thread_options_to_cpu(struct thread_options *o,
48				   struct thread_options_pack *top)
49{
50	int i, j;
51
52	for (i = 0; i < NR_OPTS_SZ; i++)
53		o->set_options[i] = le64_to_cpu(top->set_options[i]);
54
55	string_to_cpu(&o->description, top->description);
56	string_to_cpu(&o->name, top->name);
57	string_to_cpu(&o->directory, top->directory);
58	string_to_cpu(&o->filename, top->filename);
59	string_to_cpu(&o->filename_format, top->filename_format);
60	string_to_cpu(&o->opendir, top->opendir);
61	string_to_cpu(&o->ioengine, top->ioengine);
62	string_to_cpu(&o->mmapfile, top->mmapfile);
63	string_to_cpu(&o->read_iolog_file, top->read_iolog_file);
64	string_to_cpu(&o->write_iolog_file, top->write_iolog_file);
65	string_to_cpu(&o->bw_log_file, top->bw_log_file);
66	string_to_cpu(&o->lat_log_file, top->lat_log_file);
67	string_to_cpu(&o->iops_log_file, top->iops_log_file);
68	string_to_cpu(&o->replay_redirect, top->replay_redirect);
69	string_to_cpu(&o->exec_prerun, top->exec_prerun);
70	string_to_cpu(&o->exec_postrun, top->exec_postrun);
71	string_to_cpu(&o->ioscheduler, top->ioscheduler);
72	string_to_cpu(&o->profile, top->profile);
73	string_to_cpu(&o->cgroup, top->cgroup);
74
75	o->td_ddir = le32_to_cpu(top->td_ddir);
76	o->rw_seq = le32_to_cpu(top->rw_seq);
77	o->kb_base = le32_to_cpu(top->kb_base);
78	o->unit_base = le32_to_cpu(top->kb_base);
79	o->ddir_seq_nr = le32_to_cpu(top->ddir_seq_nr);
80	o->ddir_seq_add = le64_to_cpu(top->ddir_seq_add);
81	o->iodepth = le32_to_cpu(top->iodepth);
82	o->iodepth_low = le32_to_cpu(top->iodepth_low);
83	o->iodepth_batch = le32_to_cpu(top->iodepth_batch);
84	o->iodepth_batch_complete = le32_to_cpu(top->iodepth_batch_complete);
85	o->size = le64_to_cpu(top->size);
86	o->io_limit = le64_to_cpu(top->io_limit);
87	o->size_percent = le32_to_cpu(top->size_percent);
88	o->fill_device = le32_to_cpu(top->fill_device);
89	o->file_append = le32_to_cpu(top->file_append);
90	o->file_size_low = le64_to_cpu(top->file_size_low);
91	o->file_size_high = le64_to_cpu(top->file_size_high);
92	o->start_offset = le64_to_cpu(top->start_offset);
93
94	for (i = 0; i < DDIR_RWDIR_CNT; i++) {
95		o->bs[i] = le32_to_cpu(top->bs[i]);
96		o->ba[i] = le32_to_cpu(top->ba[i]);
97		o->min_bs[i] = le32_to_cpu(top->min_bs[i]);
98		o->max_bs[i] = le32_to_cpu(top->max_bs[i]);
99		o->bssplit_nr[i] = le32_to_cpu(top->bssplit_nr[i]);
100
101		if (o->bssplit_nr[i]) {
102			o->bssplit[i] = malloc(o->bssplit_nr[i] * sizeof(struct bssplit));
103			for (j = 0; j < o->bssplit_nr[i]; j++) {
104				o->bssplit[i][j].bs = le32_to_cpu(top->bssplit[i][j].bs);
105				o->bssplit[i][j].perc = le32_to_cpu(top->bssplit[i][j].perc);
106			}
107		}
108
109		o->rwmix[i] = le32_to_cpu(top->rwmix[i]);
110		o->rate[i] = le32_to_cpu(top->rate[i]);
111		o->ratemin[i] = le32_to_cpu(top->ratemin[i]);
112		o->rate_iops[i] = le32_to_cpu(top->rate_iops[i]);
113		o->rate_iops_min[i] = le32_to_cpu(top->rate_iops_min[i]);
114
115		o->perc_rand[i] = le32_to_cpu(top->perc_rand[i]);
116	}
117
118	o->ratecycle = le32_to_cpu(top->ratecycle);
119	o->nr_files = le32_to_cpu(top->nr_files);
120	o->open_files = le32_to_cpu(top->open_files);
121	o->file_lock_mode = le32_to_cpu(top->file_lock_mode);
122	o->odirect = le32_to_cpu(top->odirect);
123	o->oatomic = le32_to_cpu(top->oatomic);
124	o->invalidate_cache = le32_to_cpu(top->invalidate_cache);
125	o->create_serialize = le32_to_cpu(top->create_serialize);
126	o->create_fsync = le32_to_cpu(top->create_fsync);
127	o->create_on_open = le32_to_cpu(top->create_on_open);
128	o->create_only = le32_to_cpu(top->create_only);
129	o->end_fsync = le32_to_cpu(top->end_fsync);
130	o->pre_read = le32_to_cpu(top->pre_read);
131	o->sync_io = le32_to_cpu(top->sync_io);
132	o->verify = le32_to_cpu(top->verify);
133	o->do_verify = le32_to_cpu(top->do_verify);
134	o->verifysort = le32_to_cpu(top->verifysort);
135	o->verifysort_nr = le32_to_cpu(top->verifysort_nr);
136	o->experimental_verify = le32_to_cpu(top->experimental_verify);
137	o->verify_state = le32_to_cpu(top->verify_state);
138	o->verify_interval = le32_to_cpu(top->verify_interval);
139	o->verify_offset = le32_to_cpu(top->verify_offset);
140
141	memcpy(o->verify_pattern, top->verify_pattern, MAX_PATTERN_SIZE);
142	memcpy(o->buffer_pattern, top->buffer_pattern, MAX_PATTERN_SIZE);
143
144	o->verify_pattern_bytes = le32_to_cpu(top->verify_pattern_bytes);
145	o->verify_fatal = le32_to_cpu(top->verify_fatal);
146	o->verify_dump = le32_to_cpu(top->verify_dump);
147	o->verify_async = le32_to_cpu(top->verify_async);
148	o->verify_batch = le32_to_cpu(top->verify_batch);
149	o->use_thread = le32_to_cpu(top->use_thread);
150	o->unlink = le32_to_cpu(top->unlink);
151	o->do_disk_util = le32_to_cpu(top->do_disk_util);
152	o->override_sync = le32_to_cpu(top->override_sync);
153	o->rand_repeatable = le32_to_cpu(top->rand_repeatable);
154	o->allrand_repeatable = le32_to_cpu(top->allrand_repeatable);
155	o->rand_seed = le64_to_cpu(top->rand_seed);
156	o->log_avg_msec = le32_to_cpu(top->log_avg_msec);
157	o->log_offset = le32_to_cpu(top->log_offset);
158	o->log_gz = le32_to_cpu(top->log_gz);
159	o->log_gz_store = le32_to_cpu(top->log_gz_store);
160	o->norandommap = le32_to_cpu(top->norandommap);
161	o->softrandommap = le32_to_cpu(top->softrandommap);
162	o->bs_unaligned = le32_to_cpu(top->bs_unaligned);
163	o->fsync_on_close = le32_to_cpu(top->fsync_on_close);
164	o->bs_is_seq_rand = le32_to_cpu(top->bs_is_seq_rand);
165	o->random_distribution = le32_to_cpu(top->random_distribution);
166	o->zipf_theta.u.f = fio_uint64_to_double(le64_to_cpu(top->zipf_theta.u.i));
167	o->pareto_h.u.f = fio_uint64_to_double(le64_to_cpu(top->pareto_h.u.i));
168	o->random_generator = le32_to_cpu(top->random_generator);
169	o->hugepage_size = le32_to_cpu(top->hugepage_size);
170	o->rw_min_bs = le32_to_cpu(top->rw_min_bs);
171	o->thinktime = le32_to_cpu(top->thinktime);
172	o->thinktime_spin = le32_to_cpu(top->thinktime_spin);
173	o->thinktime_blocks = le32_to_cpu(top->thinktime_blocks);
174	o->fsync_blocks = le32_to_cpu(top->fsync_blocks);
175	o->fdatasync_blocks = le32_to_cpu(top->fdatasync_blocks);
176	o->barrier_blocks = le32_to_cpu(top->barrier_blocks);
177
178	o->verify_backlog = le64_to_cpu(top->verify_backlog);
179	o->start_delay = le64_to_cpu(top->start_delay);
180	o->start_delay_high = le64_to_cpu(top->start_delay_high);
181	o->timeout = le64_to_cpu(top->timeout);
182	o->ramp_time = le64_to_cpu(top->ramp_time);
183	o->zone_range = le64_to_cpu(top->zone_range);
184	o->zone_size = le64_to_cpu(top->zone_size);
185	o->zone_skip = le64_to_cpu(top->zone_skip);
186	o->lockmem = le64_to_cpu(top->lockmem);
187	o->offset_increment = le64_to_cpu(top->offset_increment);
188	o->number_ios = le64_to_cpu(top->number_ios);
189
190	o->overwrite = le32_to_cpu(top->overwrite);
191	o->bw_avg_time = le32_to_cpu(top->bw_avg_time);
192	o->iops_avg_time = le32_to_cpu(top->iops_avg_time);
193	o->loops = le32_to_cpu(top->loops);
194	o->mem_type = le32_to_cpu(top->mem_type);
195	o->mem_align = le32_to_cpu(top->mem_align);
196	o->max_latency = le32_to_cpu(top->max_latency);
197	o->stonewall = le32_to_cpu(top->stonewall);
198	o->new_group = le32_to_cpu(top->new_group);
199	o->numjobs = le32_to_cpu(top->numjobs);
200	o->cpus_allowed_policy = le32_to_cpu(top->cpus_allowed_policy);
201	o->iolog = le32_to_cpu(top->iolog);
202	o->rwmixcycle = le32_to_cpu(top->rwmixcycle);
203	o->nice = le32_to_cpu(top->nice);
204	o->ioprio = le32_to_cpu(top->ioprio);
205	o->ioprio_class = le32_to_cpu(top->ioprio_class);
206	o->file_service_type = le32_to_cpu(top->file_service_type);
207	o->group_reporting = le32_to_cpu(top->group_reporting);
208	o->fadvise_hint = le32_to_cpu(top->fadvise_hint);
209	o->fallocate_mode = le32_to_cpu(top->fallocate_mode);
210	o->zero_buffers = le32_to_cpu(top->zero_buffers);
211	o->refill_buffers = le32_to_cpu(top->refill_buffers);
212	o->scramble_buffers = le32_to_cpu(top->scramble_buffers);
213	o->buffer_pattern_bytes = le32_to_cpu(top->buffer_pattern_bytes);
214	o->time_based = le32_to_cpu(top->time_based);
215	o->disable_lat = le32_to_cpu(top->disable_lat);
216	o->disable_clat = le32_to_cpu(top->disable_clat);
217	o->disable_slat = le32_to_cpu(top->disable_slat);
218	o->disable_bw = le32_to_cpu(top->disable_bw);
219	o->unified_rw_rep = le32_to_cpu(top->unified_rw_rep);
220	o->gtod_reduce = le32_to_cpu(top->gtod_reduce);
221	o->gtod_cpu = le32_to_cpu(top->gtod_cpu);
222	o->clocksource = le32_to_cpu(top->clocksource);
223	o->no_stall = le32_to_cpu(top->no_stall);
224	o->trim_percentage = le32_to_cpu(top->trim_percentage);
225	o->trim_batch = le32_to_cpu(top->trim_batch);
226	o->trim_zero = le32_to_cpu(top->trim_zero);
227	o->clat_percentiles = le32_to_cpu(top->clat_percentiles);
228	o->percentile_precision = le32_to_cpu(top->percentile_precision);
229	o->continue_on_error = le32_to_cpu(top->continue_on_error);
230	o->cgroup_weight = le32_to_cpu(top->cgroup_weight);
231	o->cgroup_nodelete = le32_to_cpu(top->cgroup_nodelete);
232	o->uid = le32_to_cpu(top->uid);
233	o->gid = le32_to_cpu(top->gid);
234	o->flow_id = __le32_to_cpu(top->flow_id);
235	o->flow = __le32_to_cpu(top->flow);
236	o->flow_watermark = __le32_to_cpu(top->flow_watermark);
237	o->flow_sleep = le32_to_cpu(top->flow_sleep);
238	o->sync_file_range = le32_to_cpu(top->sync_file_range);
239	o->latency_target = le64_to_cpu(top->latency_target);
240	o->latency_window = le64_to_cpu(top->latency_window);
241	o->latency_percentile.u.f = fio_uint64_to_double(le64_to_cpu(top->latency_percentile.u.i));
242	o->compress_percentage = le32_to_cpu(top->compress_percentage);
243	o->compress_chunk = le32_to_cpu(top->compress_chunk);
244	o->dedupe_percentage = le32_to_cpu(top->dedupe_percentage);
245
246	o->trim_backlog = le64_to_cpu(top->trim_backlog);
247
248	for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
249		o->percentile_list[i].u.f = fio_uint64_to_double(le64_to_cpu(top->percentile_list[i].u.i));
250#if 0
251	uint8_t cpumask[FIO_TOP_STR_MAX];
252	uint8_t verify_cpumask[FIO_TOP_STR_MAX];
253#endif
254}
255
256void convert_thread_options_to_net(struct thread_options_pack *top,
257				   struct thread_options *o)
258{
259	int i, j;
260
261	for (i = 0; i < NR_OPTS_SZ; i++)
262		top->set_options[i] = cpu_to_le64(o->set_options[i]);
263
264	string_to_net(top->description, o->description);
265	string_to_net(top->name, o->name);
266	string_to_net(top->directory, o->directory);
267	string_to_net(top->filename, o->filename);
268	string_to_net(top->filename_format, o->filename_format);
269	string_to_net(top->opendir, o->opendir);
270	string_to_net(top->ioengine, o->ioengine);
271	string_to_net(top->mmapfile, o->mmapfile);
272	string_to_net(top->read_iolog_file, o->read_iolog_file);
273	string_to_net(top->write_iolog_file, o->write_iolog_file);
274	string_to_net(top->bw_log_file, o->bw_log_file);
275	string_to_net(top->lat_log_file, o->lat_log_file);
276	string_to_net(top->iops_log_file, o->iops_log_file);
277	string_to_net(top->replay_redirect, o->replay_redirect);
278	string_to_net(top->exec_prerun, o->exec_prerun);
279	string_to_net(top->exec_postrun, o->exec_postrun);
280	string_to_net(top->ioscheduler, o->ioscheduler);
281	string_to_net(top->profile, o->profile);
282	string_to_net(top->cgroup, o->cgroup);
283
284	top->td_ddir = cpu_to_le32(o->td_ddir);
285	top->rw_seq = cpu_to_le32(o->rw_seq);
286	top->kb_base = cpu_to_le32(o->kb_base);
287	top->unit_base = cpu_to_le32(o->kb_base);
288	top->ddir_seq_nr = cpu_to_le32(o->ddir_seq_nr);
289	top->iodepth = cpu_to_le32(o->iodepth);
290	top->iodepth_low = cpu_to_le32(o->iodepth_low);
291	top->iodepth_batch = cpu_to_le32(o->iodepth_batch);
292	top->iodepth_batch_complete = cpu_to_le32(o->iodepth_batch_complete);
293	top->size_percent = cpu_to_le32(o->size_percent);
294	top->fill_device = cpu_to_le32(o->fill_device);
295	top->file_append = cpu_to_le32(o->file_append);
296	top->ratecycle = cpu_to_le32(o->ratecycle);
297	top->nr_files = cpu_to_le32(o->nr_files);
298	top->open_files = cpu_to_le32(o->open_files);
299	top->file_lock_mode = cpu_to_le32(o->file_lock_mode);
300	top->odirect = cpu_to_le32(o->odirect);
301	top->oatomic = cpu_to_le32(o->oatomic);
302	top->invalidate_cache = cpu_to_le32(o->invalidate_cache);
303	top->create_serialize = cpu_to_le32(o->create_serialize);
304	top->create_fsync = cpu_to_le32(o->create_fsync);
305	top->create_on_open = cpu_to_le32(o->create_on_open);
306	top->create_only = cpu_to_le32(o->create_only);
307	top->end_fsync = cpu_to_le32(o->end_fsync);
308	top->pre_read = cpu_to_le32(o->pre_read);
309	top->sync_io = cpu_to_le32(o->sync_io);
310	top->verify = cpu_to_le32(o->verify);
311	top->do_verify = cpu_to_le32(o->do_verify);
312	top->verifysort = cpu_to_le32(o->verifysort);
313	top->verifysort_nr = cpu_to_le32(o->verifysort_nr);
314	top->experimental_verify = cpu_to_le32(o->experimental_verify);
315	top->verify_state = cpu_to_le32(o->verify_state);
316	top->verify_interval = cpu_to_le32(o->verify_interval);
317	top->verify_offset = cpu_to_le32(o->verify_offset);
318	top->verify_pattern_bytes = cpu_to_le32(o->verify_pattern_bytes);
319	top->verify_fatal = cpu_to_le32(o->verify_fatal);
320	top->verify_dump = cpu_to_le32(o->verify_dump);
321	top->verify_async = cpu_to_le32(o->verify_async);
322	top->verify_batch = cpu_to_le32(o->verify_batch);
323	top->use_thread = cpu_to_le32(o->use_thread);
324	top->unlink = cpu_to_le32(o->unlink);
325	top->do_disk_util = cpu_to_le32(o->do_disk_util);
326	top->override_sync = cpu_to_le32(o->override_sync);
327	top->rand_repeatable = cpu_to_le32(o->rand_repeatable);
328	top->allrand_repeatable = cpu_to_le32(o->allrand_repeatable);
329	top->rand_seed = __cpu_to_le64(o->rand_seed);
330	top->log_avg_msec = cpu_to_le32(o->log_avg_msec);
331	top->log_offset = cpu_to_le32(o->log_offset);
332	top->log_gz = cpu_to_le32(o->log_gz);
333	top->log_gz_store = cpu_to_le32(o->log_gz_store);
334	top->norandommap = cpu_to_le32(o->norandommap);
335	top->softrandommap = cpu_to_le32(o->softrandommap);
336	top->bs_unaligned = cpu_to_le32(o->bs_unaligned);
337	top->fsync_on_close = cpu_to_le32(o->fsync_on_close);
338	top->bs_is_seq_rand = cpu_to_le32(o->bs_is_seq_rand);
339	top->random_distribution = cpu_to_le32(o->random_distribution);
340	top->zipf_theta.u.i = __cpu_to_le64(fio_double_to_uint64(o->zipf_theta.u.f));
341	top->pareto_h.u.i = __cpu_to_le64(fio_double_to_uint64(o->pareto_h.u.f));
342	top->random_generator = cpu_to_le32(o->random_generator);
343	top->hugepage_size = cpu_to_le32(o->hugepage_size);
344	top->rw_min_bs = cpu_to_le32(o->rw_min_bs);
345	top->thinktime = cpu_to_le32(o->thinktime);
346	top->thinktime_spin = cpu_to_le32(o->thinktime_spin);
347	top->thinktime_blocks = cpu_to_le32(o->thinktime_blocks);
348	top->fsync_blocks = cpu_to_le32(o->fsync_blocks);
349	top->fdatasync_blocks = cpu_to_le32(o->fdatasync_blocks);
350	top->barrier_blocks = cpu_to_le32(o->barrier_blocks);
351	top->overwrite = cpu_to_le32(o->overwrite);
352	top->bw_avg_time = cpu_to_le32(o->bw_avg_time);
353	top->iops_avg_time = cpu_to_le32(o->iops_avg_time);
354	top->loops = cpu_to_le32(o->loops);
355	top->mem_type = cpu_to_le32(o->mem_type);
356	top->mem_align = cpu_to_le32(o->mem_align);
357	top->max_latency = cpu_to_le32(o->max_latency);
358	top->stonewall = cpu_to_le32(o->stonewall);
359	top->new_group = cpu_to_le32(o->new_group);
360	top->numjobs = cpu_to_le32(o->numjobs);
361	top->cpus_allowed_policy = cpu_to_le32(o->cpus_allowed_policy);
362	top->iolog = cpu_to_le32(o->iolog);
363	top->rwmixcycle = cpu_to_le32(o->rwmixcycle);
364	top->nice = cpu_to_le32(o->nice);
365	top->ioprio = cpu_to_le32(o->ioprio);
366	top->ioprio_class = cpu_to_le32(o->ioprio_class);
367	top->file_service_type = cpu_to_le32(o->file_service_type);
368	top->group_reporting = cpu_to_le32(o->group_reporting);
369	top->fadvise_hint = cpu_to_le32(o->fadvise_hint);
370	top->fallocate_mode = cpu_to_le32(o->fallocate_mode);
371	top->zero_buffers = cpu_to_le32(o->zero_buffers);
372	top->refill_buffers = cpu_to_le32(o->refill_buffers);
373	top->scramble_buffers = cpu_to_le32(o->scramble_buffers);
374	top->buffer_pattern_bytes = cpu_to_le32(o->buffer_pattern_bytes);
375	top->time_based = cpu_to_le32(o->time_based);
376	top->disable_lat = cpu_to_le32(o->disable_lat);
377	top->disable_clat = cpu_to_le32(o->disable_clat);
378	top->disable_slat = cpu_to_le32(o->disable_slat);
379	top->disable_bw = cpu_to_le32(o->disable_bw);
380	top->unified_rw_rep = cpu_to_le32(o->unified_rw_rep);
381	top->gtod_reduce = cpu_to_le32(o->gtod_reduce);
382	top->gtod_cpu = cpu_to_le32(o->gtod_cpu);
383	top->clocksource = cpu_to_le32(o->clocksource);
384	top->no_stall = cpu_to_le32(o->no_stall);
385	top->trim_percentage = cpu_to_le32(o->trim_percentage);
386	top->trim_batch = cpu_to_le32(o->trim_batch);
387	top->trim_zero = cpu_to_le32(o->trim_zero);
388	top->clat_percentiles = cpu_to_le32(o->clat_percentiles);
389	top->percentile_precision = cpu_to_le32(o->percentile_precision);
390	top->continue_on_error = cpu_to_le32(o->continue_on_error);
391	top->cgroup_weight = cpu_to_le32(o->cgroup_weight);
392	top->cgroup_nodelete = cpu_to_le32(o->cgroup_nodelete);
393	top->uid = cpu_to_le32(o->uid);
394	top->gid = cpu_to_le32(o->gid);
395	top->flow_id = __cpu_to_le32(o->flow_id);
396	top->flow = __cpu_to_le32(o->flow);
397	top->flow_watermark = __cpu_to_le32(o->flow_watermark);
398	top->flow_sleep = cpu_to_le32(o->flow_sleep);
399	top->sync_file_range = cpu_to_le32(o->sync_file_range);
400	top->latency_target = __cpu_to_le64(o->latency_target);
401	top->latency_window = __cpu_to_le64(o->latency_window);
402	top->latency_percentile.u.i = __cpu_to_le64(fio_double_to_uint64(o->latency_percentile.u.f));
403	top->compress_percentage = cpu_to_le32(o->compress_percentage);
404	top->compress_chunk = cpu_to_le32(o->compress_chunk);
405	top->dedupe_percentage = cpu_to_le32(o->dedupe_percentage);
406
407	for (i = 0; i < DDIR_RWDIR_CNT; i++) {
408		top->bs[i] = cpu_to_le32(o->bs[i]);
409		top->ba[i] = cpu_to_le32(o->ba[i]);
410		top->min_bs[i] = cpu_to_le32(o->min_bs[i]);
411		top->max_bs[i] = cpu_to_le32(o->max_bs[i]);
412		top->bssplit_nr[i] = cpu_to_le32(o->bssplit_nr[i]);
413
414		if (o->bssplit_nr[i]) {
415			unsigned int bssplit_nr = o->bssplit_nr[i];
416
417			if (bssplit_nr > BSSPLIT_MAX) {
418				log_err("fio: BSSPLIT_MAX is too small\n");
419				bssplit_nr = BSSPLIT_MAX;
420			}
421			for (j = 0; j < bssplit_nr; j++) {
422				top->bssplit[i][j].bs = cpu_to_le32(o->bssplit[i][j].bs);
423				top->bssplit[i][j].perc = cpu_to_le32(o->bssplit[i][j].perc);
424			}
425		}
426
427		top->rwmix[i] = cpu_to_le32(o->rwmix[i]);
428		top->rate[i] = cpu_to_le32(o->rate[i]);
429		top->ratemin[i] = cpu_to_le32(o->ratemin[i]);
430		top->rate_iops[i] = cpu_to_le32(o->rate_iops[i]);
431		top->rate_iops_min[i] = cpu_to_le32(o->rate_iops_min[i]);
432
433		top->perc_rand[i] = cpu_to_le32(o->perc_rand[i]);
434	}
435
436	memcpy(top->verify_pattern, o->verify_pattern, MAX_PATTERN_SIZE);
437	memcpy(top->buffer_pattern, o->buffer_pattern, MAX_PATTERN_SIZE);
438
439	top->size = __cpu_to_le64(o->size);
440	top->io_limit = __cpu_to_le64(o->io_limit);
441	top->verify_backlog = __cpu_to_le64(o->verify_backlog);
442	top->start_delay = __cpu_to_le64(o->start_delay);
443	top->start_delay_high = __cpu_to_le64(o->start_delay_high);
444	top->timeout = __cpu_to_le64(o->timeout);
445	top->ramp_time = __cpu_to_le64(o->ramp_time);
446	top->zone_range = __cpu_to_le64(o->zone_range);
447	top->zone_size = __cpu_to_le64(o->zone_size);
448	top->zone_skip = __cpu_to_le64(o->zone_skip);
449	top->lockmem = __cpu_to_le64(o->lockmem);
450	top->ddir_seq_add = __cpu_to_le64(o->ddir_seq_add);
451	top->file_size_low = __cpu_to_le64(o->file_size_low);
452	top->file_size_high = __cpu_to_le64(o->file_size_high);
453	top->start_offset = __cpu_to_le64(o->start_offset);
454	top->trim_backlog = __cpu_to_le64(o->trim_backlog);
455	top->offset_increment = __cpu_to_le64(o->offset_increment);
456	top->number_ios = __cpu_to_le64(o->number_ios);
457
458	for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
459		top->percentile_list[i].u.i = __cpu_to_le64(fio_double_to_uint64(o->percentile_list[i].u.f));
460#if 0
461	uint8_t cpumask[FIO_TOP_STR_MAX];
462	uint8_t verify_cpumask[FIO_TOP_STR_MAX];
463#endif
464
465}
466
467/*
468 * Basic conversion test. We'd really need to fill in more of the options
469 * to have a thorough test. Even better, we should auto-generate the
470 * converter functions...
471 */
472int fio_test_cconv(struct thread_options *__o)
473{
474	struct thread_options o;
475	struct thread_options_pack top1, top2;
476
477	memset(&top1, 0, sizeof(top1));
478	memset(&top2, 0, sizeof(top2));
479
480	convert_thread_options_to_net(&top1, __o);
481	memset(&o, 0, sizeof(o));
482	convert_thread_options_to_cpu(&o, &top1);
483	convert_thread_options_to_net(&top2, &o);
484
485	free_thread_options_to_cpu(&o);
486
487	return memcmp(&top1, &top2, sizeof(top1));
488}
489