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