1use std::os::raw::{c_char, c_float, c_double, c_int, c_uchar, c_void};
7
8use crate::constants::{
9 HAILO_ETH_MAC_LENGTH, HAILO_MAX_BOARD_NAME_LENGTH, HAILO_MAX_DEVICE_ID_LENGTH,
10 HAILO_MAX_NETWORK_GROUP_NAME_SIZE, HAILO_MAX_NETWORK_NAME_SIZE,
11 HAILO_MAX_NETWORKS_IN_NETWORK_GROUP, HAILO_MAX_NETWORK_GROUPS, HAILO_MAX_PART_NUMBER_LENGTH,
12 HAILO_MAX_PRODUCT_NAME_LENGTH, HAILO_MAX_SERIAL_NUMBER_LENGTH, HAILO_MAX_STREAM_NAME_SIZE,
13 HAILO_MAX_STREAMS_COUNT, HAILO_MAX_TEMPERATURE_THROTTLING_LEVELS_NUMBER,
14 HAILO_SOC_ID_LENGTH, HAILO_SOC_PM_VALUES_BYTES_LENGTH,
15 HAILO_UNIT_LEVEL_TRACKING_BYTES_LENGTH, MAX_NUMBER_OF_PLANES,
16};
17use crate::enums::{
18 hailo_buffer_flags_t, hailo_device_architecture_t, hailo_device_boot_source_t,
19 hailo_endianness_t, hailo_format_flags_t, hailo_format_order_t, hailo_format_type_t,
20 hailo_latency_measurement_flags_t, hailo_nms_burst_type_t, hailo_notification_id_t,
21 hailo_overcurrent_protection_overcurrent_zone_t, hailo_pipeline_elem_stats_flags_t,
22 hailo_pix_buffer_memory_type_t, hailo_power_mode_t, hailo_scheduling_algorithm_t,
23 hailo_stream_direction_t, hailo_stream_flags_t, hailo_stream_interface_t,
24 hailo_stream_transform_mode_t, hailo_temperature_protection_temperature_zone_t,
25 hailo_vstream_stats_flags_t,
26};
27use crate::handles::hailo_device;
28use crate::status::hailo_status;
29
30pub type float32_t = c_float;
35pub type float64_t = c_double;
36pub type nms_bbox_counter_t = u16;
37
38#[repr(C)]
43#[derive(Debug, Copy, Clone)]
44pub struct hailo_version_t {
45 pub major: u32,
46 pub minor: u32,
47 pub revision: u32,
48}
49
50#[repr(C)]
51#[derive(Debug, Copy, Clone)]
52pub struct hailo_firmware_version_t {
53 pub major: u32,
54 pub minor: u32,
55 pub revision: u32,
56}
57
58#[repr(C)]
59#[derive(Debug, Copy, Clone)]
60pub struct hailo_pcie_device_info_t {
61 pub domain: u32,
62 pub bus: u32,
63 pub device: u32,
64 pub func: u32,
65}
66
67#[repr(C)]
68#[derive(Debug, Copy, Clone)]
69pub struct hailo_device_id_t {
70 pub id: [c_char; HAILO_MAX_DEVICE_ID_LENGTH],
71}
72
73#[repr(C)]
74#[derive(Debug, Copy, Clone)]
75pub struct hailo_device_identity_t {
76 pub protocol_version: u32,
77 pub fw_version: hailo_firmware_version_t,
78 pub logger_version: u32,
79 pub board_name_length: u8,
80 pub board_name: [c_char; HAILO_MAX_BOARD_NAME_LENGTH],
81 pub is_release: bool,
82 pub extended_context_switch_buffer: bool,
83 pub extended_fw_check: bool,
84 pub device_architecture: hailo_device_architecture_t,
85 pub serial_number_length: u8,
86 pub serial_number: [c_char; HAILO_MAX_SERIAL_NUMBER_LENGTH],
87 pub part_number_length: u8,
88 pub part_number: [c_char; HAILO_MAX_PART_NUMBER_LENGTH],
89 pub product_name_length: u8,
90 pub product_name: [c_char; HAILO_MAX_PRODUCT_NAME_LENGTH],
91}
92
93#[repr(C)]
94#[derive(Debug, Copy, Clone)]
95pub struct hailo_core_information_t {
96 pub is_release: bool,
97 pub extended_context_switch_buffer: bool,
98 pub extended_fw_check: bool,
99 pub fw_version: hailo_firmware_version_t,
100}
101
102#[repr(C)]
103#[derive(Debug, Copy, Clone)]
104pub struct hailo_device_supported_features_t {
105 pub ethernet: bool,
106 pub mipi: bool,
107 pub pcie: bool,
108 pub current_monitoring: bool,
109 pub mdio: bool,
110 pub power_measurement: bool,
111}
112
113#[repr(C)]
114#[derive(Debug, Copy, Clone)]
115pub struct hailo_extended_device_information_t {
116 pub neural_network_core_clock_rate: u32,
117 pub supported_features: hailo_device_supported_features_t,
118 pub boot_source: hailo_device_boot_source_t,
119 pub soc_id: [c_uchar; HAILO_SOC_ID_LENGTH],
120 pub lcs: c_uchar,
121 pub eth_mac_address: [c_uchar; HAILO_ETH_MAC_LENGTH],
122 pub unit_level_tracking_id: [c_uchar; HAILO_UNIT_LEVEL_TRACKING_BYTES_LENGTH],
123 pub soc_pm_values: [c_uchar; HAILO_SOC_PM_VALUES_BYTES_LENGTH],
124 pub gpio_mask: u16,
125}
126
127#[repr(C)]
128#[derive(Debug, Copy, Clone)]
129pub struct hailo_fw_user_config_information_t {
130 pub version: u32,
131 pub entry_count: u32,
132 pub total_size: u32,
133}
134
135#[repr(C)]
140#[derive(Debug, Copy, Clone)]
141pub struct hailo_vdevice_params_t {
142 pub device_count: u32,
143 pub device_ids: *mut hailo_device_id_t,
145 pub scheduling_algorithm: hailo_scheduling_algorithm_t,
146 pub group_id: *const c_char,
148 pub multi_process_service: bool,
149}
150
151#[repr(C)]
156#[derive(Debug, Copy, Clone)]
157pub struct hailo_format_t {
158 pub type_: hailo_format_type_t,
159 pub order: hailo_format_order_t,
160 pub flags: hailo_format_flags_t,
161}
162
163#[repr(C)]
164#[derive(Debug, Copy, Clone)]
165pub struct hailo_quant_info_t {
166 pub qp_zp: float32_t,
167 pub qp_scale: float32_t,
168 pub limvals_min: float32_t,
169 pub limvals_max: float32_t,
170}
171
172#[repr(C)]
177#[derive(Debug, Copy, Clone)]
178pub struct hailo_transform_params_t {
179 pub transform_mode: hailo_stream_transform_mode_t,
180 pub user_buffer_format: hailo_format_t,
181}
182
183#[repr(C)]
185#[derive(Debug, Copy, Clone)]
186pub struct hailo_demux_params_t {
187 pub _reserved: u8,
188}
189
190#[repr(C)]
192#[derive(Debug, Copy, Clone)]
193pub struct hailo_pcie_input_stream_params_t {
194 pub _reserved: u8,
195}
196
197#[repr(C)]
199#[derive(Debug, Copy, Clone)]
200pub struct hailo_pcie_output_stream_params_t {
201 pub _reserved: u8,
202}
203
204#[repr(C)]
206#[derive(Debug, Copy, Clone)]
207pub struct hailo_integrated_input_stream_params_t {
208 pub _reserved: u8,
209}
210
211#[repr(C)]
213#[derive(Debug, Copy, Clone)]
214pub struct hailo_integrated_output_stream_params_t {
215 pub _reserved: u8,
216}
217
218#[repr(C)]
220pub union hailo_stream_params_union_t {
221 pub pcie_input_params: hailo_pcie_input_stream_params_t,
222 pub integrated_input_params: hailo_integrated_input_stream_params_t,
223 pub pcie_output_params: hailo_pcie_output_stream_params_t,
224 pub integrated_output_params: hailo_integrated_output_stream_params_t,
225}
226
227#[repr(C)]
228pub struct hailo_stream_parameters_t {
229 pub stream_interface: hailo_stream_interface_t,
230 pub direction: hailo_stream_direction_t,
231 pub flags: hailo_stream_flags_t,
232 pub params: hailo_stream_params_union_t,
233}
234
235#[repr(C)]
236pub struct hailo_stream_parameters_by_name_t {
237 pub name: [c_char; HAILO_MAX_STREAM_NAME_SIZE],
238 pub stream_params: hailo_stream_parameters_t,
239}
240
241#[repr(C)]
246#[derive(Debug, Copy, Clone)]
247pub struct hailo_vstream_params_t {
248 pub user_buffer_format: hailo_format_t,
249 pub timeout_ms: u32,
250 pub queue_size: u32,
251 pub vstream_stats_flags: hailo_vstream_stats_flags_t,
252 pub pipeline_elements_stats_flags: hailo_pipeline_elem_stats_flags_t,
253}
254
255#[repr(C)]
256#[derive(Debug, Copy, Clone)]
257pub struct hailo_input_vstream_params_by_name_t {
258 pub name: [c_char; HAILO_MAX_STREAM_NAME_SIZE],
259 pub params: hailo_vstream_params_t,
260}
261
262#[repr(C)]
263#[derive(Debug, Copy, Clone)]
264pub struct hailo_output_vstream_params_by_name_t {
265 pub name: [c_char; HAILO_MAX_STREAM_NAME_SIZE],
266 pub params: hailo_vstream_params_t,
267}
268
269#[repr(C)]
270#[derive(Debug, Copy, Clone)]
271pub struct hailo_output_vstream_name_by_group_t {
272 pub name: [c_char; HAILO_MAX_STREAM_NAME_SIZE],
273 pub pipeline_group_index: u8,
274}
275
276#[repr(C)]
281#[derive(Debug, Copy, Clone)]
282pub struct hailo_3d_image_shape_t {
283 pub height: u32,
284 pub width: u32,
285 pub features: u32,
286}
287
288#[repr(C)]
290pub union hailo_pix_buffer_plane_ptr_t {
291 pub user_ptr: *mut c_void,
292 pub fd: c_int,
293}
294
295#[repr(C)]
296pub struct hailo_pix_buffer_plane_t {
297 pub bytes_used: u32,
298 pub plane_size: u32,
299 pub ptr: hailo_pix_buffer_plane_ptr_t,
300}
301
302#[repr(C)]
303pub struct hailo_pix_buffer_t {
304 pub index: u32,
305 pub planes: [hailo_pix_buffer_plane_t; MAX_NUMBER_OF_PLANES],
306 pub number_of_planes: u32,
307 pub memory_type: hailo_pix_buffer_memory_type_t,
308}
309
310#[repr(C)]
311#[derive(Debug, Copy, Clone)]
312pub struct hailo_dma_buffer_t {
313 pub fd: c_int,
314 pub size: usize,
315}
316
317#[repr(C)]
318#[derive(Debug, Copy, Clone)]
319pub struct hailo_buffer_parameters_t {
320 pub flags: hailo_buffer_flags_t,
321}
322
323#[repr(C)]
328#[derive(Debug, Copy, Clone)]
329pub struct hailo_nms_defuse_info_t {
330 pub class_group_index: u32,
331 pub original_name: [c_char; HAILO_MAX_STREAM_NAME_SIZE],
332}
333
334#[repr(C)]
335#[derive(Debug, Copy, Clone)]
336pub struct hailo_nms_info_t {
337 pub number_of_classes: u32,
338 pub max_bboxes_per_class: u32,
339 pub max_bboxes_total: u32,
340 pub bbox_size: u32,
341 pub chunks_per_frame: u32,
342 pub burst_size: u32,
343 pub is_defused: bool,
344 pub defuse_info: hailo_nms_defuse_info_t,
345 pub burst_type: hailo_nms_burst_type_t,
346}
347
348#[repr(C)]
349pub struct hailo_nms_fuse_input_t {
350 pub buffer: *mut c_void,
351 pub size: usize,
352 pub nms_info: hailo_nms_info_t,
353}
354
355#[repr(C)]
356#[derive(Debug, Copy, Clone)]
357pub struct hailo_nms_shape_t {
358 pub number_of_classes: u32,
359 pub max_bboxes_per_class: u32,
360 pub max_bboxes_total: u32,
361 pub max_accumulated_mask_size: u32,
362}
363
364#[repr(C)]
365#[derive(Debug, Copy, Clone)]
366pub struct hailo_bbox_t {
367 pub y_min: u16,
368 pub x_min: u16,
369 pub y_max: u16,
370 pub x_max: u16,
371 pub score: u16,
372}
373
374#[repr(C)]
375#[derive(Debug, Copy, Clone)]
376pub struct hailo_bbox_float32_t {
377 pub y_min: float32_t,
378 pub x_min: float32_t,
379 pub y_max: float32_t,
380 pub x_max: float32_t,
381 pub score: float32_t,
382}
383
384#[repr(C)]
385#[derive(Debug, Copy, Clone)]
386pub struct hailo_rectangle_t {
387 pub y_min: float32_t,
388 pub x_min: float32_t,
389 pub y_max: float32_t,
390 pub x_max: float32_t,
391}
392
393#[repr(C)]
394#[derive(Debug, Copy, Clone)]
395pub struct hailo_detection_t {
396 pub y_min: float32_t,
397 pub x_min: float32_t,
398 pub y_max: float32_t,
399 pub x_max: float32_t,
400 pub score: float32_t,
401 pub class_id: u16,
402}
403
404#[repr(C)]
409pub struct hailo_detections_t {
410 pub count: u16,
411 pub detections: [hailo_detection_t; 0],
412}
413
414#[repr(C)]
415pub struct hailo_detection_with_byte_mask_t {
416 pub box_: hailo_rectangle_t,
417 pub score: float32_t,
418 pub class_id: u16,
419 pub mask_size: usize,
420 pub mask: *mut c_uchar,
422 pub mask_offset: usize,
423}
424
425#[repr(C)]
431pub struct hailo_stream_write_async_completion_info_t {
432 pub status: hailo_status,
433 pub buffer_addr: *const c_void,
434 pub buffer_size: usize,
435 pub opaque: *mut c_void,
436}
437
438#[repr(C)]
440pub struct hailo_stream_read_async_completion_info_t {
441 pub status: hailo_status,
442 pub buffer_addr: *mut c_void,
443 pub buffer_size: usize,
444 pub opaque: *mut c_void,
445}
446
447pub type hailo_stream_write_async_callback_t =
448 unsafe extern "C" fn(info: *const hailo_stream_write_async_completion_info_t);
449
450pub type hailo_stream_read_async_callback_t =
451 unsafe extern "C" fn(info: *const hailo_stream_read_async_completion_info_t);
452
453pub type hailo_notification_callback = unsafe extern "C" fn(
454 device: hailo_device,
455 notification: *const hailo_notification_t,
456 opaque: *mut c_void,
457);
458
459#[repr(C)]
464#[derive(Copy, Clone)]
465pub struct hailo_rx_error_notification_message_t {
466 pub error: u32,
467 pub queue_number: u32,
468 pub rx_errors_count: u32,
469}
470
471#[repr(C)]
472#[derive(Copy, Clone)]
473pub struct hailo_debug_notification_message_t {
474 pub connection_status: u32,
475 pub connection_type: u32,
476 pub vdma_is_active: u32,
477 pub host_port: u32,
478 pub host_ip_addr: u32,
479}
480
481#[repr(C)]
482#[derive(Copy, Clone)]
483pub struct hailo_health_monitor_dataflow_shutdown_notification_message_t {
484 pub ts0_temperature: float32_t,
485 pub ts1_temperature: float32_t,
486}
487
488#[repr(C)]
489#[derive(Copy, Clone)]
490pub struct hailo_health_monitor_temperature_alarm_notification_message_t {
491 pub temperature_zone: hailo_temperature_protection_temperature_zone_t,
492 pub alarm_ts_id: u32,
493 pub ts0_temperature: float32_t,
494 pub ts1_temperature: float32_t,
495}
496
497#[repr(C)]
498#[derive(Copy, Clone)]
499pub struct hailo_health_monitor_overcurrent_alert_notification_message_t {
500 pub overcurrent_zone: hailo_overcurrent_protection_overcurrent_zone_t,
501 pub exceeded_alert_threshold: float32_t,
502 pub is_last_overcurrent_violation_reached: bool,
503}
504
505#[repr(C)]
506#[derive(Copy, Clone)]
507pub struct hailo_health_monitor_lcu_ecc_error_notification_message_t {
508 pub cluster_error: u16,
509}
510
511#[repr(C)]
512#[derive(Copy, Clone)]
513pub struct hailo_health_monitor_cpu_ecc_notification_message_t {
514 pub memory_bitmap: u32,
515}
516
517#[repr(C)]
518#[derive(Copy, Clone)]
519pub struct hailo_context_switch_breakpoint_reached_message_t {
520 pub network_group_index: u8,
521 pub batch_index: u32,
522 pub context_index: u16,
523 pub action_index: u16,
524}
525
526#[repr(C)]
527#[derive(Copy, Clone)]
528pub struct hailo_health_monitor_clock_changed_notification_message_t {
529 pub previous_clock: u32,
530 pub current_clock: u32,
531}
532
533#[repr(C)]
534#[derive(Copy, Clone)]
535pub struct hailo_hw_infer_manager_infer_done_notification_message_t {
536 pub infer_cycles: u32,
537}
538
539#[repr(C)]
540#[derive(Copy, Clone)]
541pub struct hailo_start_update_cache_offset_notification_message_t {
542 pub cache_id_bitmask: u64,
543}
544
545#[repr(C)]
546#[derive(Copy, Clone)]
547pub struct hailo_context_switch_run_time_error_message_t {
548 pub exit_status: u32,
549 pub network_group_index: u8,
550 pub batch_index: u16,
551 pub context_index: u16,
552 pub action_index: u16,
553}
554
555#[repr(C)]
556#[derive(Copy, Clone)]
557pub struct hailo_throttling_state_change_message_t {
558 pub new_state: u16,
559}
560
561#[repr(C)]
562pub union hailo_notification_message_parameters_t {
563 pub rx_error_notification: hailo_rx_error_notification_message_t,
564 pub debug_notification: hailo_debug_notification_message_t,
565 pub health_monitor_dataflow_shutdown_notification:
566 hailo_health_monitor_dataflow_shutdown_notification_message_t,
567 pub health_monitor_temperature_alarm_notification:
568 hailo_health_monitor_temperature_alarm_notification_message_t,
569 pub health_monitor_overcurrent_alert_notification:
570 hailo_health_monitor_overcurrent_alert_notification_message_t,
571 pub health_monitor_lcu_ecc_error_notification:
572 hailo_health_monitor_lcu_ecc_error_notification_message_t,
573 pub health_monitor_cpu_ecc_notification: hailo_health_monitor_cpu_ecc_notification_message_t,
574 pub context_switch_breakpoint_reached_notification:
575 hailo_context_switch_breakpoint_reached_message_t,
576 pub health_monitor_clock_changed_notification:
577 hailo_health_monitor_clock_changed_notification_message_t,
578 pub hw_infer_manager_infer_done_notification:
579 hailo_hw_infer_manager_infer_done_notification_message_t,
580 pub context_switch_run_time_error: hailo_context_switch_run_time_error_message_t,
581 pub start_update_cache_offset_notification:
582 hailo_start_update_cache_offset_notification_message_t,
583 pub throttling_state_change: hailo_throttling_state_change_message_t,
584}
585
586#[repr(C)]
587pub struct hailo_notification_t {
588 pub id: hailo_notification_id_t,
589 pub sequence: u32,
590 pub body: hailo_notification_message_parameters_t,
591}
592
593#[repr(C)]
599#[derive(Debug, Copy, Clone)]
600pub struct hailo_stream_info_shape_pair_t {
601 pub shape: hailo_3d_image_shape_t,
602 pub hw_shape: hailo_3d_image_shape_t,
603}
604
605#[repr(C)]
607pub union hailo_stream_info_shape_t {
608 pub shapes: hailo_stream_info_shape_pair_t,
609 pub nms_info: hailo_nms_info_t,
610}
611
612#[repr(C)]
613pub struct hailo_stream_info_t {
614 pub shape: hailo_stream_info_shape_t,
615 pub hw_data_bytes: u32,
616 pub hw_frame_size: u32,
617 pub format: hailo_format_t,
618 pub direction: hailo_stream_direction_t,
619 pub index: u8,
620 pub name: [c_char; HAILO_MAX_STREAM_NAME_SIZE],
621 pub quant_info: hailo_quant_info_t,
622 pub is_mux: bool,
623}
624
625#[repr(C)]
627pub union hailo_vstream_info_shape_t {
628 pub shape: hailo_3d_image_shape_t,
629 pub nms_shape: hailo_nms_shape_t,
630}
631
632#[repr(C)]
633pub struct hailo_vstream_info_t {
634 pub name: [c_char; HAILO_MAX_STREAM_NAME_SIZE],
635 pub network_name: [c_char; HAILO_MAX_NETWORK_NAME_SIZE],
636 pub direction: hailo_stream_direction_t,
637 pub format: hailo_format_t,
638 pub shape: hailo_vstream_info_shape_t,
639 pub quant_info: hailo_quant_info_t,
640}
641
642#[repr(C)]
647#[derive(Debug, Copy, Clone)]
648pub struct hailo_power_measurement_data_t {
649 pub average_value: float32_t,
650 pub average_time_value_milliseconds: float32_t,
651 pub min_value: float32_t,
652 pub max_value: float32_t,
653 pub total_number_of_samples: u32,
654}
655
656#[repr(C)]
657#[derive(Debug, Copy, Clone)]
658pub struct hailo_chip_temperature_info_t {
659 pub ts0_temperature: float32_t,
660 pub ts1_temperature: float32_t,
661 pub sample_count: u16,
662}
663
664#[repr(C)]
665#[derive(Debug, Copy, Clone)]
666pub struct hailo_throttling_level_t {
667 pub temperature_threshold: float32_t,
668 pub hysteresis_temperature_threshold: float32_t,
669 pub throttling_nn_clock_freq: u32,
670}
671
672#[repr(C)]
673#[derive(Debug, Copy, Clone)]
674pub struct hailo_health_info_t {
675 pub overcurrent_protection_active: bool,
676 pub current_overcurrent_zone: u8,
677 pub red_overcurrent_threshold: float32_t,
678 pub overcurrent_throttling_active: bool,
679 pub temperature_throttling_active: bool,
680 pub current_temperature_zone: u8,
681 pub current_temperature_throttling_level: i8,
682 pub temperature_throttling_levels:
683 [hailo_throttling_level_t; HAILO_MAX_TEMPERATURE_THROTTLING_LEVELS_NUMBER],
684 pub orange_temperature_threshold: i32,
685 pub orange_hysteresis_temperature_threshold: i32,
686 pub red_temperature_threshold: i32,
687 pub red_hysteresis_temperature_threshold: i32,
688 pub requested_overcurrent_clock_freq: u32,
689 pub requested_temperature_clock_freq: u32,
690}
691
692#[repr(C)]
693#[derive(Debug, Copy, Clone)]
694pub struct hailo_performance_stats_t {
695 pub cpu_utilization: float32_t,
696 pub ram_size_total: i64,
697 pub ram_size_used: i64,
698 pub nnc_utilization: float32_t,
699 pub ddr_noc_total_transactions: i32,
700 pub dsp_utilization: i32,
701}
702
703#[repr(C)]
704#[derive(Debug, Copy, Clone)]
705pub struct hailo_health_stats_t {
706 pub on_die_temperature: float32_t,
707 pub on_die_voltage: i32,
708 pub bist_failure_mask: i32,
709}
710
711#[repr(C)]
716#[derive(Debug, Copy, Clone)]
717pub struct hailo_network_parameters_t {
718 pub batch_size: u16,
719}
720
721#[repr(C)]
722#[derive(Debug, Copy, Clone)]
723pub struct hailo_network_parameters_by_name_t {
724 pub name: [c_char; HAILO_MAX_NETWORK_NAME_SIZE],
725 pub network_params: hailo_network_parameters_t,
726}
727
728#[repr(C)]
729pub struct hailo_configure_network_group_params_t {
730 pub name: [c_char; HAILO_MAX_NETWORK_GROUP_NAME_SIZE],
731 pub batch_size: u16,
732 pub power_mode: hailo_power_mode_t,
733 pub latency: hailo_latency_measurement_flags_t,
734 pub enable_kv_cache: bool,
735 pub stream_params_by_name_count: usize,
736 pub stream_params_by_name: [hailo_stream_parameters_by_name_t; HAILO_MAX_STREAMS_COUNT],
737 pub network_params_by_name_count: usize,
738 pub network_params_by_name:
739 [hailo_network_parameters_by_name_t; HAILO_MAX_NETWORKS_IN_NETWORK_GROUP],
740}
741
742#[repr(C)]
743pub struct hailo_configure_params_t {
744 pub network_group_params_count: usize,
745 pub network_group_params: [hailo_configure_network_group_params_t; HAILO_MAX_NETWORK_GROUPS],
746}
747
748#[repr(C)]
750#[derive(Debug, Copy, Clone)]
751pub struct hailo_activate_network_group_params_t {
752 pub _reserved: u8,
753}
754
755#[repr(C)]
756#[derive(Debug, Copy, Clone)]
757pub struct hailo_network_group_info_t {
758 pub name: [c_char; HAILO_MAX_NETWORK_GROUP_NAME_SIZE],
759 pub is_multi_context: bool,
760}
761
762#[repr(C)]
763#[derive(Debug, Copy, Clone)]
764pub struct hailo_layer_name_t {
765 pub name: [c_char; HAILO_MAX_STREAM_NAME_SIZE],
766}
767
768#[repr(C)]
769#[derive(Debug, Copy, Clone)]
770pub struct hailo_network_info_t {
771 pub name: [c_char; HAILO_MAX_NETWORK_NAME_SIZE],
772}
773
774#[repr(C)]
775pub struct hailo_stream_raw_buffer_t {
776 pub buffer: *mut c_void,
777 pub size: usize,
778}
779
780#[repr(C)]
781pub struct hailo_stream_raw_buffer_by_name_t {
782 pub name: [c_char; HAILO_MAX_STREAM_NAME_SIZE],
783 pub raw_buffer: hailo_stream_raw_buffer_t,
784}
785
786#[repr(C)]
787#[derive(Debug, Copy, Clone)]
788pub struct hailo_latency_measurement_result_t {
789 pub avg_hw_latency_ms: float64_t,
790}
791
792#[repr(C)]
793pub struct hailo_rate_limit_t {
794 pub stream_name: [c_char; HAILO_MAX_STREAM_NAME_SIZE],
795 pub rate: u32,
796}
797
798#[repr(C)]
803#[derive(Debug, Copy, Clone)]
804pub struct hailo_i2c_slave_config_t {
805 pub endianness: hailo_endianness_t,
806 pub slave_address: u16,
807 pub register_address_size: u8,
808 pub bus_index: u8,
809 pub should_hold_bus: bool,
810}
811
812#[cfg(test)]
821mod tests {
822 use super::*;
823 use std::mem::{align_of, offset_of, size_of};
824
825 #[test]
828 fn primitive_aliases_match_underlying_type() {
829 assert_eq!(size_of::<float32_t>(), size_of::<f32>());
830 assert_eq!(size_of::<float64_t>(), size_of::<f64>());
831 assert_eq!(size_of::<nms_bbox_counter_t>(), size_of::<u16>());
832 assert_eq!(align_of::<nms_bbox_counter_t>(), align_of::<u16>());
833 }
834
835 #[test]
838 fn hailo_version_t_layout() {
839 assert_eq!(size_of::<hailo_version_t>(), 12);
840 assert_eq!(align_of::<hailo_version_t>(), 4);
841 assert_eq!(offset_of!(hailo_version_t, major), 0);
842 assert_eq!(offset_of!(hailo_version_t, minor), 4);
843 assert_eq!(offset_of!(hailo_version_t, revision), 8);
844 }
845
846 #[test]
847 fn hailo_firmware_version_t_layout() {
848 assert_eq!(size_of::<hailo_firmware_version_t>(), 12);
849 assert_eq!(align_of::<hailo_firmware_version_t>(), 4);
850 assert_eq!(offset_of!(hailo_firmware_version_t, major), 0);
851 assert_eq!(offset_of!(hailo_firmware_version_t, minor), 4);
852 assert_eq!(offset_of!(hailo_firmware_version_t, revision), 8);
853 }
854
855 #[test]
856 fn hailo_pcie_device_info_t_layout() {
857 assert_eq!(size_of::<hailo_pcie_device_info_t>(), 16);
858 assert_eq!(align_of::<hailo_pcie_device_info_t>(), 4);
859 assert_eq!(offset_of!(hailo_pcie_device_info_t, domain), 0);
860 assert_eq!(offset_of!(hailo_pcie_device_info_t, bus), 4);
861 assert_eq!(offset_of!(hailo_pcie_device_info_t, device), 8);
862 assert_eq!(offset_of!(hailo_pcie_device_info_t, func), 12);
863 }
864
865 #[test]
866 fn hailo_device_id_t_layout() {
867 use crate::constants::HAILO_MAX_DEVICE_ID_LENGTH;
868 assert_eq!(size_of::<hailo_device_id_t>(), HAILO_MAX_DEVICE_ID_LENGTH);
869 assert_eq!(offset_of!(hailo_device_id_t, id), 0);
870 }
871
872 #[test]
873 fn hailo_device_identity_t_layout() {
874 assert_eq!(size_of::<hailo_device_identity_t>(), 140);
891 assert_eq!(align_of::<hailo_device_identity_t>(), 4);
892 assert_eq!(offset_of!(hailo_device_identity_t, protocol_version), 0);
893 assert_eq!(offset_of!(hailo_device_identity_t, fw_version), 4);
894 assert_eq!(offset_of!(hailo_device_identity_t, logger_version), 16);
895 assert_eq!(offset_of!(hailo_device_identity_t, board_name_length), 20);
896 assert_eq!(offset_of!(hailo_device_identity_t, board_name), 21);
897 assert_eq!(offset_of!(hailo_device_identity_t, is_release), 53);
898 assert_eq!(offset_of!(hailo_device_identity_t, device_architecture), 56);
899 assert_eq!(offset_of!(hailo_device_identity_t, serial_number_length), 60);
900 assert_eq!(offset_of!(hailo_device_identity_t, serial_number), 61);
901 assert_eq!(offset_of!(hailo_device_identity_t, part_number_length), 77);
902 assert_eq!(offset_of!(hailo_device_identity_t, part_number), 78);
903 assert_eq!(offset_of!(hailo_device_identity_t, product_name_length), 94);
904 assert_eq!(offset_of!(hailo_device_identity_t, product_name), 95);
905 }
906
907 #[test]
908 fn hailo_core_information_t_layout() {
909 assert_eq!(size_of::<hailo_core_information_t>(), 16);
911 assert_eq!(align_of::<hailo_core_information_t>(), 4);
912 assert_eq!(offset_of!(hailo_core_information_t, is_release), 0);
913 assert_eq!(offset_of!(hailo_core_information_t, fw_version), 4);
914 }
915
916 #[test]
917 fn hailo_device_supported_features_t_layout() {
918 assert_eq!(size_of::<hailo_device_supported_features_t>(), 6);
920 assert_eq!(align_of::<hailo_device_supported_features_t>(), 1);
921 assert_eq!(offset_of!(hailo_device_supported_features_t, ethernet), 0);
922 assert_eq!(offset_of!(hailo_device_supported_features_t, mipi), 1);
923 assert_eq!(offset_of!(hailo_device_supported_features_t, pcie), 2);
924 assert_eq!(
925 offset_of!(hailo_device_supported_features_t, current_monitoring),
926 3
927 );
928 assert_eq!(offset_of!(hailo_device_supported_features_t, mdio), 4);
929 assert_eq!(
930 offset_of!(hailo_device_supported_features_t, power_measurement),
931 5
932 );
933 }
934
935 #[test]
936 fn hailo_extended_device_information_t_layout() {
937 assert_eq!(size_of::<hailo_extended_device_information_t>(), 96);
941 assert_eq!(align_of::<hailo_extended_device_information_t>(), 4);
942 assert_eq!(
943 offset_of!(
944 hailo_extended_device_information_t,
945 neural_network_core_clock_rate
946 ),
947 0
948 );
949 assert_eq!(
950 offset_of!(hailo_extended_device_information_t, supported_features),
951 4
952 );
953 assert_eq!(
954 offset_of!(hailo_extended_device_information_t, boot_source),
955 12
956 );
957 assert_eq!(offset_of!(hailo_extended_device_information_t, soc_id), 16);
958 assert_eq!(offset_of!(hailo_extended_device_information_t, lcs), 48);
959 assert_eq!(
960 offset_of!(hailo_extended_device_information_t, eth_mac_address),
961 49
962 );
963 assert_eq!(
964 offset_of!(
965 hailo_extended_device_information_t,
966 unit_level_tracking_id
967 ),
968 55
969 );
970 assert_eq!(
971 offset_of!(hailo_extended_device_information_t, soc_pm_values),
972 67
973 );
974 assert_eq!(
975 offset_of!(hailo_extended_device_information_t, gpio_mask),
976 92
977 );
978 }
979
980 #[test]
981 fn hailo_fw_user_config_information_t_layout() {
982 assert_eq!(size_of::<hailo_fw_user_config_information_t>(), 12);
983 assert_eq!(align_of::<hailo_fw_user_config_information_t>(), 4);
984 assert_eq!(offset_of!(hailo_fw_user_config_information_t, version), 0);
985 assert_eq!(
986 offset_of!(hailo_fw_user_config_information_t, entry_count),
987 4
988 );
989 assert_eq!(
990 offset_of!(hailo_fw_user_config_information_t, total_size),
991 8
992 );
993 }
994
995 #[test]
998 #[cfg(target_pointer_width = "64")]
999 fn hailo_vdevice_params_t_layout() {
1000 assert_eq!(size_of::<hailo_vdevice_params_t>(), 40);
1004 assert_eq!(align_of::<hailo_vdevice_params_t>(), 8);
1005 assert_eq!(offset_of!(hailo_vdevice_params_t, device_count), 0);
1006 assert_eq!(offset_of!(hailo_vdevice_params_t, device_ids), 8);
1007 assert_eq!(
1008 offset_of!(hailo_vdevice_params_t, scheduling_algorithm),
1009 16
1010 );
1011 assert_eq!(offset_of!(hailo_vdevice_params_t, group_id), 24);
1012 assert_eq!(
1013 offset_of!(hailo_vdevice_params_t, multi_process_service),
1014 32
1015 );
1016 }
1017
1018 #[test]
1021 fn hailo_format_t_layout() {
1022 assert_eq!(size_of::<hailo_format_t>(), 12);
1023 assert_eq!(align_of::<hailo_format_t>(), 4);
1024 assert_eq!(offset_of!(hailo_format_t, type_), 0);
1025 assert_eq!(offset_of!(hailo_format_t, order), 4);
1026 assert_eq!(offset_of!(hailo_format_t, flags), 8);
1027 }
1028
1029 #[test]
1030 fn hailo_quant_info_t_layout() {
1031 assert_eq!(size_of::<hailo_quant_info_t>(), 16);
1032 assert_eq!(align_of::<hailo_quant_info_t>(), 4);
1033 assert_eq!(offset_of!(hailo_quant_info_t, qp_zp), 0);
1034 assert_eq!(offset_of!(hailo_quant_info_t, qp_scale), 4);
1035 assert_eq!(offset_of!(hailo_quant_info_t, limvals_min), 8);
1036 assert_eq!(offset_of!(hailo_quant_info_t, limvals_max), 12);
1037 }
1038
1039 #[test]
1042 fn hailo_transform_params_t_layout() {
1043 assert_eq!(size_of::<hailo_transform_params_t>(), 16);
1044 assert_eq!(align_of::<hailo_transform_params_t>(), 4);
1045 assert_eq!(offset_of!(hailo_transform_params_t, transform_mode), 0);
1046 assert_eq!(offset_of!(hailo_transform_params_t, user_buffer_format), 4);
1047 }
1048
1049 #[test]
1050 fn empty_stream_param_structs_are_one_byte() {
1051 assert_eq!(size_of::<hailo_demux_params_t>(), 1);
1052 assert_eq!(size_of::<hailo_pcie_input_stream_params_t>(), 1);
1053 assert_eq!(size_of::<hailo_pcie_output_stream_params_t>(), 1);
1054 assert_eq!(size_of::<hailo_integrated_input_stream_params_t>(), 1);
1055 assert_eq!(size_of::<hailo_integrated_output_stream_params_t>(), 1);
1056 }
1057
1058 #[test]
1059 fn hailo_stream_params_union_t_layout() {
1060 assert_eq!(size_of::<hailo_stream_params_union_t>(), 1);
1061 assert_eq!(align_of::<hailo_stream_params_union_t>(), 1);
1062 }
1063
1064 #[test]
1065 fn hailo_stream_parameters_t_layout() {
1066 assert_eq!(size_of::<hailo_stream_parameters_t>(), 16);
1068 assert_eq!(align_of::<hailo_stream_parameters_t>(), 4);
1069 assert_eq!(offset_of!(hailo_stream_parameters_t, stream_interface), 0);
1070 assert_eq!(offset_of!(hailo_stream_parameters_t, direction), 4);
1071 assert_eq!(offset_of!(hailo_stream_parameters_t, flags), 8);
1072 assert_eq!(offset_of!(hailo_stream_parameters_t, params), 12);
1073 }
1074
1075 #[test]
1076 fn hailo_stream_parameters_by_name_t_layout() {
1077 assert_eq!(size_of::<hailo_stream_parameters_by_name_t>(), 144);
1079 assert_eq!(align_of::<hailo_stream_parameters_by_name_t>(), 4);
1080 assert_eq!(offset_of!(hailo_stream_parameters_by_name_t, name), 0);
1081 assert_eq!(
1082 offset_of!(hailo_stream_parameters_by_name_t, stream_params),
1083 128
1084 );
1085 }
1086
1087 #[test]
1090 fn hailo_vstream_params_t_layout() {
1091 assert_eq!(size_of::<hailo_vstream_params_t>(), 28);
1093 assert_eq!(align_of::<hailo_vstream_params_t>(), 4);
1094 assert_eq!(offset_of!(hailo_vstream_params_t, user_buffer_format), 0);
1095 assert_eq!(offset_of!(hailo_vstream_params_t, timeout_ms), 12);
1096 assert_eq!(offset_of!(hailo_vstream_params_t, queue_size), 16);
1097 assert_eq!(offset_of!(hailo_vstream_params_t, vstream_stats_flags), 20);
1098 assert_eq!(
1099 offset_of!(hailo_vstream_params_t, pipeline_elements_stats_flags),
1100 24
1101 );
1102 }
1103
1104 #[test]
1105 fn hailo_input_vstream_params_by_name_t_layout() {
1106 assert_eq!(size_of::<hailo_input_vstream_params_by_name_t>(), 156);
1107 assert_eq!(align_of::<hailo_input_vstream_params_by_name_t>(), 4);
1108 assert_eq!(offset_of!(hailo_input_vstream_params_by_name_t, name), 0);
1109 assert_eq!(
1110 offset_of!(hailo_input_vstream_params_by_name_t, params),
1111 128
1112 );
1113 }
1114
1115 #[test]
1116 fn hailo_output_vstream_params_by_name_t_layout() {
1117 assert_eq!(size_of::<hailo_output_vstream_params_by_name_t>(), 156);
1118 assert_eq!(align_of::<hailo_output_vstream_params_by_name_t>(), 4);
1119 assert_eq!(offset_of!(hailo_output_vstream_params_by_name_t, name), 0);
1120 assert_eq!(
1121 offset_of!(hailo_output_vstream_params_by_name_t, params),
1122 128
1123 );
1124 }
1125
1126 #[test]
1127 fn hailo_output_vstream_name_by_group_t_layout() {
1128 assert_eq!(size_of::<hailo_output_vstream_name_by_group_t>(), 129);
1129 assert_eq!(align_of::<hailo_output_vstream_name_by_group_t>(), 1);
1130 assert_eq!(offset_of!(hailo_output_vstream_name_by_group_t, name), 0);
1131 assert_eq!(
1132 offset_of!(hailo_output_vstream_name_by_group_t, pipeline_group_index),
1133 128
1134 );
1135 }
1136
1137 #[test]
1140 fn hailo_3d_image_shape_t_layout() {
1141 assert_eq!(size_of::<hailo_3d_image_shape_t>(), 12);
1142 assert_eq!(align_of::<hailo_3d_image_shape_t>(), 4);
1143 assert_eq!(offset_of!(hailo_3d_image_shape_t, height), 0);
1144 assert_eq!(offset_of!(hailo_3d_image_shape_t, width), 4);
1145 assert_eq!(offset_of!(hailo_3d_image_shape_t, features), 8);
1146 }
1147
1148 #[test]
1149 #[cfg(target_pointer_width = "64")]
1150 fn hailo_pix_buffer_plane_ptr_t_layout() {
1151 assert_eq!(size_of::<hailo_pix_buffer_plane_ptr_t>(), 8);
1153 assert_eq!(align_of::<hailo_pix_buffer_plane_ptr_t>(), 8);
1154 }
1155
1156 #[test]
1157 #[cfg(target_pointer_width = "64")]
1158 fn hailo_pix_buffer_plane_t_layout() {
1159 assert_eq!(size_of::<hailo_pix_buffer_plane_t>(), 16);
1161 assert_eq!(align_of::<hailo_pix_buffer_plane_t>(), 8);
1162 assert_eq!(offset_of!(hailo_pix_buffer_plane_t, bytes_used), 0);
1163 assert_eq!(offset_of!(hailo_pix_buffer_plane_t, plane_size), 4);
1164 assert_eq!(offset_of!(hailo_pix_buffer_plane_t, ptr), 8);
1165 }
1166
1167 #[test]
1168 #[cfg(target_pointer_width = "64")]
1169 fn hailo_pix_buffer_t_layout() {
1170 assert_eq!(size_of::<hailo_pix_buffer_t>(), 80);
1172 assert_eq!(align_of::<hailo_pix_buffer_t>(), 8);
1173 assert_eq!(offset_of!(hailo_pix_buffer_t, index), 0);
1174 assert_eq!(offset_of!(hailo_pix_buffer_t, planes), 8);
1175 assert_eq!(offset_of!(hailo_pix_buffer_t, number_of_planes), 72);
1176 assert_eq!(offset_of!(hailo_pix_buffer_t, memory_type), 76);
1177 }
1178
1179 #[test]
1180 #[cfg(target_pointer_width = "64")]
1181 fn hailo_dma_buffer_t_layout() {
1182 assert_eq!(size_of::<hailo_dma_buffer_t>(), 16);
1184 assert_eq!(align_of::<hailo_dma_buffer_t>(), 8);
1185 assert_eq!(offset_of!(hailo_dma_buffer_t, fd), 0);
1186 assert_eq!(offset_of!(hailo_dma_buffer_t, size), 8);
1187 }
1188
1189 #[test]
1190 fn hailo_buffer_parameters_t_layout() {
1191 assert_eq!(size_of::<hailo_buffer_parameters_t>(), 4);
1192 assert_eq!(align_of::<hailo_buffer_parameters_t>(), 4);
1193 assert_eq!(offset_of!(hailo_buffer_parameters_t, flags), 0);
1194 }
1195
1196 #[test]
1199 fn hailo_nms_defuse_info_t_layout() {
1200 assert_eq!(size_of::<hailo_nms_defuse_info_t>(), 132);
1202 assert_eq!(align_of::<hailo_nms_defuse_info_t>(), 4);
1203 assert_eq!(offset_of!(hailo_nms_defuse_info_t, class_group_index), 0);
1204 assert_eq!(offset_of!(hailo_nms_defuse_info_t, original_name), 4);
1205 }
1206
1207 #[test]
1208 fn hailo_nms_info_t_layout() {
1209 assert_eq!(size_of::<hailo_nms_info_t>(), 164);
1211 assert_eq!(align_of::<hailo_nms_info_t>(), 4);
1212 assert_eq!(offset_of!(hailo_nms_info_t, number_of_classes), 0);
1213 assert_eq!(offset_of!(hailo_nms_info_t, max_bboxes_per_class), 4);
1214 assert_eq!(offset_of!(hailo_nms_info_t, max_bboxes_total), 8);
1215 assert_eq!(offset_of!(hailo_nms_info_t, bbox_size), 12);
1216 assert_eq!(offset_of!(hailo_nms_info_t, chunks_per_frame), 16);
1217 assert_eq!(offset_of!(hailo_nms_info_t, burst_size), 20);
1218 assert_eq!(offset_of!(hailo_nms_info_t, is_defused), 24);
1219 assert_eq!(offset_of!(hailo_nms_info_t, defuse_info), 28);
1220 assert_eq!(offset_of!(hailo_nms_info_t, burst_type), 160);
1221 }
1222
1223 #[test]
1224 #[cfg(target_pointer_width = "64")]
1225 fn hailo_nms_fuse_input_t_layout() {
1226 assert_eq!(size_of::<hailo_nms_fuse_input_t>(), 184);
1228 assert_eq!(align_of::<hailo_nms_fuse_input_t>(), 8);
1229 assert_eq!(offset_of!(hailo_nms_fuse_input_t, buffer), 0);
1230 assert_eq!(offset_of!(hailo_nms_fuse_input_t, size), 8);
1231 assert_eq!(offset_of!(hailo_nms_fuse_input_t, nms_info), 16);
1232 }
1233
1234 #[test]
1235 fn hailo_nms_shape_t_layout() {
1236 assert_eq!(size_of::<hailo_nms_shape_t>(), 16);
1237 assert_eq!(align_of::<hailo_nms_shape_t>(), 4);
1238 assert_eq!(offset_of!(hailo_nms_shape_t, number_of_classes), 0);
1239 assert_eq!(offset_of!(hailo_nms_shape_t, max_bboxes_per_class), 4);
1240 assert_eq!(offset_of!(hailo_nms_shape_t, max_bboxes_total), 8);
1241 assert_eq!(offset_of!(hailo_nms_shape_t, max_accumulated_mask_size), 12);
1242 }
1243
1244 #[test]
1245 fn hailo_bbox_t_layout() {
1246 assert_eq!(size_of::<hailo_bbox_t>(), 10);
1247 assert_eq!(align_of::<hailo_bbox_t>(), 2);
1248 assert_eq!(offset_of!(hailo_bbox_t, y_min), 0);
1249 assert_eq!(offset_of!(hailo_bbox_t, x_min), 2);
1250 assert_eq!(offset_of!(hailo_bbox_t, y_max), 4);
1251 assert_eq!(offset_of!(hailo_bbox_t, x_max), 6);
1252 assert_eq!(offset_of!(hailo_bbox_t, score), 8);
1253 }
1254
1255 #[test]
1256 fn hailo_bbox_float32_t_layout() {
1257 assert_eq!(size_of::<hailo_bbox_float32_t>(), 20);
1258 assert_eq!(align_of::<hailo_bbox_float32_t>(), 4);
1259 assert_eq!(offset_of!(hailo_bbox_float32_t, y_min), 0);
1260 assert_eq!(offset_of!(hailo_bbox_float32_t, x_min), 4);
1261 assert_eq!(offset_of!(hailo_bbox_float32_t, y_max), 8);
1262 assert_eq!(offset_of!(hailo_bbox_float32_t, x_max), 12);
1263 assert_eq!(offset_of!(hailo_bbox_float32_t, score), 16);
1264 }
1265
1266 #[test]
1267 fn hailo_rectangle_t_layout() {
1268 assert_eq!(size_of::<hailo_rectangle_t>(), 16);
1269 assert_eq!(align_of::<hailo_rectangle_t>(), 4);
1270 assert_eq!(offset_of!(hailo_rectangle_t, y_min), 0);
1271 assert_eq!(offset_of!(hailo_rectangle_t, x_min), 4);
1272 assert_eq!(offset_of!(hailo_rectangle_t, y_max), 8);
1273 assert_eq!(offset_of!(hailo_rectangle_t, x_max), 12);
1274 }
1275
1276 #[test]
1277 fn hailo_detection_t_layout() {
1278 assert_eq!(size_of::<hailo_detection_t>(), 24);
1280 assert_eq!(align_of::<hailo_detection_t>(), 4);
1281 assert_eq!(offset_of!(hailo_detection_t, y_min), 0);
1282 assert_eq!(offset_of!(hailo_detection_t, x_min), 4);
1283 assert_eq!(offset_of!(hailo_detection_t, y_max), 8);
1284 assert_eq!(offset_of!(hailo_detection_t, x_max), 12);
1285 assert_eq!(offset_of!(hailo_detection_t, score), 16);
1286 assert_eq!(offset_of!(hailo_detection_t, class_id), 20);
1287 }
1288
1289 #[test]
1290 fn hailo_detections_t_layout() {
1291 assert_eq!(size_of::<hailo_detections_t>(), 4);
1293 assert_eq!(align_of::<hailo_detections_t>(), 4);
1294 assert_eq!(offset_of!(hailo_detections_t, count), 0);
1295 }
1296
1297 #[test]
1298 #[cfg(target_pointer_width = "64")]
1299 fn hailo_detection_with_byte_mask_t_layout() {
1300 assert_eq!(size_of::<hailo_detection_with_byte_mask_t>(), 48);
1302 assert_eq!(align_of::<hailo_detection_with_byte_mask_t>(), 8);
1303 assert_eq!(offset_of!(hailo_detection_with_byte_mask_t, box_), 0);
1304 assert_eq!(offset_of!(hailo_detection_with_byte_mask_t, score), 16);
1305 assert_eq!(offset_of!(hailo_detection_with_byte_mask_t, class_id), 20);
1306 assert_eq!(offset_of!(hailo_detection_with_byte_mask_t, mask_size), 24);
1307 assert_eq!(offset_of!(hailo_detection_with_byte_mask_t, mask), 32);
1308 assert_eq!(offset_of!(hailo_detection_with_byte_mask_t, mask_offset), 40);
1309 }
1310
1311 #[test]
1314 #[cfg(target_pointer_width = "64")]
1315 fn hailo_stream_write_async_completion_info_t_layout() {
1316 assert_eq!(size_of::<hailo_stream_write_async_completion_info_t>(), 32);
1318 assert_eq!(
1319 align_of::<hailo_stream_write_async_completion_info_t>(),
1320 8
1321 );
1322 assert_eq!(
1323 offset_of!(hailo_stream_write_async_completion_info_t, status),
1324 0
1325 );
1326 assert_eq!(
1327 offset_of!(hailo_stream_write_async_completion_info_t, buffer_addr),
1328 8
1329 );
1330 assert_eq!(
1331 offset_of!(hailo_stream_write_async_completion_info_t, buffer_size),
1332 16
1333 );
1334 assert_eq!(
1335 offset_of!(hailo_stream_write_async_completion_info_t, opaque),
1336 24
1337 );
1338 }
1339
1340 #[test]
1341 #[cfg(target_pointer_width = "64")]
1342 fn hailo_stream_read_async_completion_info_t_layout() {
1343 assert_eq!(size_of::<hailo_stream_read_async_completion_info_t>(), 32);
1344 assert_eq!(align_of::<hailo_stream_read_async_completion_info_t>(), 8);
1345 assert_eq!(
1346 offset_of!(hailo_stream_read_async_completion_info_t, status),
1347 0
1348 );
1349 assert_eq!(
1350 offset_of!(hailo_stream_read_async_completion_info_t, buffer_addr),
1351 8
1352 );
1353 assert_eq!(
1354 offset_of!(hailo_stream_read_async_completion_info_t, buffer_size),
1355 16
1356 );
1357 assert_eq!(
1358 offset_of!(hailo_stream_read_async_completion_info_t, opaque),
1359 24
1360 );
1361 }
1362
1363 #[test]
1366 fn notification_message_struct_sizes() {
1367 assert_eq!(
1368 size_of::<hailo_rx_error_notification_message_t>(),
1369 12
1370 );
1371 assert_eq!(
1372 size_of::<hailo_debug_notification_message_t>(),
1373 20
1374 );
1375 assert_eq!(
1376 size_of::<hailo_health_monitor_dataflow_shutdown_notification_message_t>(),
1377 8
1378 );
1379 assert_eq!(
1380 size_of::<hailo_health_monitor_temperature_alarm_notification_message_t>(),
1381 16
1382 );
1383 assert_eq!(
1384 size_of::<hailo_health_monitor_overcurrent_alert_notification_message_t>(),
1385 12
1386 );
1387 assert_eq!(
1388 size_of::<hailo_health_monitor_lcu_ecc_error_notification_message_t>(),
1389 2
1390 );
1391 assert_eq!(
1392 size_of::<hailo_health_monitor_cpu_ecc_notification_message_t>(),
1393 4
1394 );
1395 assert_eq!(
1396 size_of::<hailo_context_switch_breakpoint_reached_message_t>(),
1397 12
1398 );
1399 assert_eq!(
1400 size_of::<hailo_health_monitor_clock_changed_notification_message_t>(),
1401 8
1402 );
1403 assert_eq!(
1404 size_of::<hailo_hw_infer_manager_infer_done_notification_message_t>(),
1405 4
1406 );
1407 assert_eq!(
1408 size_of::<hailo_start_update_cache_offset_notification_message_t>(),
1409 8
1410 );
1411 assert_eq!(
1412 size_of::<hailo_context_switch_run_time_error_message_t>(),
1413 12
1414 );
1415 assert_eq!(
1416 size_of::<hailo_throttling_state_change_message_t>(),
1417 2
1418 );
1419 }
1420
1421 #[test]
1422 fn hailo_notification_message_parameters_t_layout() {
1423 assert_eq!(size_of::<hailo_notification_message_parameters_t>(), 24);
1427 assert_eq!(align_of::<hailo_notification_message_parameters_t>(), 8);
1428 }
1429
1430 #[test]
1431 fn hailo_notification_t_layout() {
1432 assert_eq!(size_of::<hailo_notification_t>(), 32);
1434 assert_eq!(align_of::<hailo_notification_t>(), 8);
1435 assert_eq!(offset_of!(hailo_notification_t, id), 0);
1436 assert_eq!(offset_of!(hailo_notification_t, sequence), 4);
1437 assert_eq!(offset_of!(hailo_notification_t, body), 8);
1438 }
1439
1440 #[test]
1443 fn hailo_stream_info_shape_pair_t_layout() {
1444 assert_eq!(size_of::<hailo_stream_info_shape_pair_t>(), 24);
1445 assert_eq!(align_of::<hailo_stream_info_shape_pair_t>(), 4);
1446 assert_eq!(offset_of!(hailo_stream_info_shape_pair_t, shape), 0);
1447 assert_eq!(offset_of!(hailo_stream_info_shape_pair_t, hw_shape), 12);
1448 }
1449
1450 #[test]
1451 fn hailo_stream_info_shape_t_layout() {
1452 assert_eq!(size_of::<hailo_stream_info_shape_t>(), 164);
1454 assert_eq!(align_of::<hailo_stream_info_shape_t>(), 4);
1455 }
1456
1457 #[test]
1458 fn hailo_stream_info_t_layout() {
1459 assert_eq!(size_of::<hailo_stream_info_t>(), 340);
1463 assert_eq!(align_of::<hailo_stream_info_t>(), 4);
1464 assert_eq!(offset_of!(hailo_stream_info_t, shape), 0);
1465 assert_eq!(offset_of!(hailo_stream_info_t, hw_data_bytes), 164);
1466 assert_eq!(offset_of!(hailo_stream_info_t, hw_frame_size), 168);
1467 assert_eq!(offset_of!(hailo_stream_info_t, format), 172);
1468 assert_eq!(offset_of!(hailo_stream_info_t, direction), 184);
1469 assert_eq!(offset_of!(hailo_stream_info_t, index), 188);
1470 assert_eq!(offset_of!(hailo_stream_info_t, name), 189);
1471 assert_eq!(offset_of!(hailo_stream_info_t, quant_info), 320);
1472 assert_eq!(offset_of!(hailo_stream_info_t, is_mux), 336);
1473 }
1474
1475 #[test]
1476 fn hailo_vstream_info_shape_t_layout() {
1477 assert_eq!(size_of::<hailo_vstream_info_shape_t>(), 16);
1479 assert_eq!(align_of::<hailo_vstream_info_shape_t>(), 4);
1480 }
1481
1482 #[test]
1483 fn hailo_vstream_info_t_layout() {
1484 assert_eq!(size_of::<hailo_vstream_info_t>(), 436);
1487 assert_eq!(align_of::<hailo_vstream_info_t>(), 4);
1488 assert_eq!(offset_of!(hailo_vstream_info_t, name), 0);
1489 assert_eq!(offset_of!(hailo_vstream_info_t, network_name), 128);
1490 assert_eq!(offset_of!(hailo_vstream_info_t, direction), 388);
1491 assert_eq!(offset_of!(hailo_vstream_info_t, format), 392);
1492 assert_eq!(offset_of!(hailo_vstream_info_t, shape), 404);
1493 assert_eq!(offset_of!(hailo_vstream_info_t, quant_info), 420);
1494 }
1495
1496 #[test]
1499 fn hailo_power_measurement_data_t_layout() {
1500 assert_eq!(size_of::<hailo_power_measurement_data_t>(), 20);
1501 assert_eq!(align_of::<hailo_power_measurement_data_t>(), 4);
1502 assert_eq!(
1503 offset_of!(hailo_power_measurement_data_t, average_value),
1504 0
1505 );
1506 assert_eq!(
1507 offset_of!(
1508 hailo_power_measurement_data_t,
1509 average_time_value_milliseconds
1510 ),
1511 4
1512 );
1513 assert_eq!(offset_of!(hailo_power_measurement_data_t, min_value), 8);
1514 assert_eq!(offset_of!(hailo_power_measurement_data_t, max_value), 12);
1515 assert_eq!(
1516 offset_of!(hailo_power_measurement_data_t, total_number_of_samples),
1517 16
1518 );
1519 }
1520
1521 #[test]
1522 fn hailo_chip_temperature_info_t_layout() {
1523 assert_eq!(size_of::<hailo_chip_temperature_info_t>(), 12);
1525 assert_eq!(align_of::<hailo_chip_temperature_info_t>(), 4);
1526 assert_eq!(
1527 offset_of!(hailo_chip_temperature_info_t, ts0_temperature),
1528 0
1529 );
1530 assert_eq!(
1531 offset_of!(hailo_chip_temperature_info_t, ts1_temperature),
1532 4
1533 );
1534 assert_eq!(offset_of!(hailo_chip_temperature_info_t, sample_count), 8);
1535 }
1536
1537 #[test]
1538 fn hailo_throttling_level_t_layout() {
1539 assert_eq!(size_of::<hailo_throttling_level_t>(), 12);
1540 assert_eq!(align_of::<hailo_throttling_level_t>(), 4);
1541 assert_eq!(
1542 offset_of!(hailo_throttling_level_t, temperature_threshold),
1543 0
1544 );
1545 assert_eq!(
1546 offset_of!(
1547 hailo_throttling_level_t,
1548 hysteresis_temperature_threshold
1549 ),
1550 4
1551 );
1552 assert_eq!(
1553 offset_of!(hailo_throttling_level_t, throttling_nn_clock_freq),
1554 8
1555 );
1556 }
1557
1558 #[test]
1559 fn hailo_health_info_t_layout() {
1560 assert_eq!(size_of::<hailo_health_info_t>(), 84);
1567 assert_eq!(align_of::<hailo_health_info_t>(), 4);
1568 assert_eq!(
1569 offset_of!(hailo_health_info_t, overcurrent_protection_active),
1570 0
1571 );
1572 assert_eq!(
1573 offset_of!(hailo_health_info_t, current_overcurrent_zone),
1574 1
1575 );
1576 assert_eq!(
1577 offset_of!(hailo_health_info_t, red_overcurrent_threshold),
1578 4
1579 );
1580 assert_eq!(
1581 offset_of!(hailo_health_info_t, overcurrent_throttling_active),
1582 8
1583 );
1584 assert_eq!(
1585 offset_of!(hailo_health_info_t, temperature_throttling_active),
1586 9
1587 );
1588 assert_eq!(
1589 offset_of!(hailo_health_info_t, current_temperature_zone),
1590 10
1591 );
1592 assert_eq!(
1593 offset_of!(
1594 hailo_health_info_t,
1595 current_temperature_throttling_level
1596 ),
1597 11
1598 );
1599 assert_eq!(
1600 offset_of!(hailo_health_info_t, temperature_throttling_levels),
1601 12
1602 );
1603 assert_eq!(
1604 offset_of!(hailo_health_info_t, orange_temperature_threshold),
1605 60
1606 );
1607 assert_eq!(
1608 offset_of!(hailo_health_info_t, requested_overcurrent_clock_freq),
1609 76
1610 );
1611 assert_eq!(
1612 offset_of!(hailo_health_info_t, requested_temperature_clock_freq),
1613 80
1614 );
1615 }
1616
1617 #[test]
1618 #[cfg(target_pointer_width = "64")]
1619 fn hailo_performance_stats_t_layout() {
1620 assert_eq!(size_of::<hailo_performance_stats_t>(), 40);
1623 assert_eq!(align_of::<hailo_performance_stats_t>(), 8);
1624 assert_eq!(offset_of!(hailo_performance_stats_t, cpu_utilization), 0);
1625 assert_eq!(offset_of!(hailo_performance_stats_t, ram_size_total), 8);
1626 assert_eq!(offset_of!(hailo_performance_stats_t, ram_size_used), 16);
1627 assert_eq!(offset_of!(hailo_performance_stats_t, nnc_utilization), 24);
1628 assert_eq!(
1629 offset_of!(hailo_performance_stats_t, ddr_noc_total_transactions),
1630 28
1631 );
1632 assert_eq!(offset_of!(hailo_performance_stats_t, dsp_utilization), 32);
1633 }
1634
1635 #[test]
1636 fn hailo_health_stats_t_layout() {
1637 assert_eq!(size_of::<hailo_health_stats_t>(), 12);
1638 assert_eq!(align_of::<hailo_health_stats_t>(), 4);
1639 assert_eq!(offset_of!(hailo_health_stats_t, on_die_temperature), 0);
1640 assert_eq!(offset_of!(hailo_health_stats_t, on_die_voltage), 4);
1641 assert_eq!(offset_of!(hailo_health_stats_t, bist_failure_mask), 8);
1642 }
1643
1644 #[test]
1647 fn hailo_network_parameters_t_layout() {
1648 assert_eq!(size_of::<hailo_network_parameters_t>(), 2);
1649 assert_eq!(align_of::<hailo_network_parameters_t>(), 2);
1650 assert_eq!(offset_of!(hailo_network_parameters_t, batch_size), 0);
1651 }
1652
1653 #[test]
1654 fn hailo_network_parameters_by_name_t_layout() {
1655 assert_eq!(size_of::<hailo_network_parameters_by_name_t>(), 260);
1657 assert_eq!(align_of::<hailo_network_parameters_by_name_t>(), 2);
1658 assert_eq!(offset_of!(hailo_network_parameters_by_name_t, name), 0);
1659 assert_eq!(
1660 offset_of!(hailo_network_parameters_by_name_t, network_params),
1661 258
1662 );
1663 }
1664
1665 #[test]
1666 #[cfg(target_pointer_width = "64")]
1667 fn hailo_configure_network_group_params_t_layout() {
1668 assert_eq!(
1674 size_of::<hailo_configure_network_group_params_t>(),
1675 8000
1676 );
1677 assert_eq!(
1678 align_of::<hailo_configure_network_group_params_t>(),
1679 8
1680 );
1681 assert_eq!(
1682 offset_of!(hailo_configure_network_group_params_t, name),
1683 0
1684 );
1685 assert_eq!(
1686 offset_of!(hailo_configure_network_group_params_t, batch_size),
1687 128
1688 );
1689 assert_eq!(
1690 offset_of!(hailo_configure_network_group_params_t, power_mode),
1691 132
1692 );
1693 assert_eq!(
1694 offset_of!(hailo_configure_network_group_params_t, latency),
1695 136
1696 );
1697 assert_eq!(
1698 offset_of!(hailo_configure_network_group_params_t, enable_kv_cache),
1699 140
1700 );
1701 assert_eq!(
1702 offset_of!(
1703 hailo_configure_network_group_params_t,
1704 stream_params_by_name_count
1705 ),
1706 144
1707 );
1708 assert_eq!(
1709 offset_of!(
1710 hailo_configure_network_group_params_t,
1711 stream_params_by_name
1712 ),
1713 152
1714 );
1715 assert_eq!(
1716 offset_of!(
1717 hailo_configure_network_group_params_t,
1718 network_params_by_name_count
1719 ),
1720 5912
1721 );
1722 assert_eq!(
1723 offset_of!(
1724 hailo_configure_network_group_params_t,
1725 network_params_by_name
1726 ),
1727 5920
1728 );
1729 }
1730
1731 #[test]
1732 #[cfg(target_pointer_width = "64")]
1733 fn hailo_configure_params_t_layout() {
1734 assert_eq!(size_of::<hailo_configure_params_t>(), 64008);
1736 assert_eq!(align_of::<hailo_configure_params_t>(), 8);
1737 assert_eq!(
1738 offset_of!(hailo_configure_params_t, network_group_params_count),
1739 0
1740 );
1741 assert_eq!(
1742 offset_of!(hailo_configure_params_t, network_group_params),
1743 8
1744 );
1745 }
1746
1747 #[test]
1748 fn hailo_activate_network_group_params_t_layout() {
1749 assert_eq!(size_of::<hailo_activate_network_group_params_t>(), 1);
1750 }
1751
1752 #[test]
1753 fn hailo_network_group_info_t_layout() {
1754 assert_eq!(size_of::<hailo_network_group_info_t>(), 129);
1755 assert_eq!(align_of::<hailo_network_group_info_t>(), 1);
1756 assert_eq!(offset_of!(hailo_network_group_info_t, name), 0);
1757 assert_eq!(
1758 offset_of!(hailo_network_group_info_t, is_multi_context),
1759 128
1760 );
1761 }
1762
1763 #[test]
1764 fn hailo_layer_name_t_layout() {
1765 assert_eq!(size_of::<hailo_layer_name_t>(), 128);
1766 assert_eq!(offset_of!(hailo_layer_name_t, name), 0);
1767 }
1768
1769 #[test]
1770 fn hailo_network_info_t_layout() {
1771 assert_eq!(size_of::<hailo_network_info_t>(), 257);
1772 assert_eq!(offset_of!(hailo_network_info_t, name), 0);
1773 }
1774
1775 #[test]
1776 #[cfg(target_pointer_width = "64")]
1777 fn hailo_stream_raw_buffer_t_layout() {
1778 assert_eq!(size_of::<hailo_stream_raw_buffer_t>(), 16);
1780 assert_eq!(align_of::<hailo_stream_raw_buffer_t>(), 8);
1781 assert_eq!(offset_of!(hailo_stream_raw_buffer_t, buffer), 0);
1782 assert_eq!(offset_of!(hailo_stream_raw_buffer_t, size), 8);
1783 }
1784
1785 #[test]
1786 #[cfg(target_pointer_width = "64")]
1787 fn hailo_stream_raw_buffer_by_name_t_layout() {
1788 assert_eq!(size_of::<hailo_stream_raw_buffer_by_name_t>(), 144);
1790 assert_eq!(align_of::<hailo_stream_raw_buffer_by_name_t>(), 8);
1791 assert_eq!(offset_of!(hailo_stream_raw_buffer_by_name_t, name), 0);
1792 assert_eq!(
1793 offset_of!(hailo_stream_raw_buffer_by_name_t, raw_buffer),
1794 128
1795 );
1796 }
1797
1798 #[test]
1799 fn hailo_latency_measurement_result_t_layout() {
1800 assert_eq!(size_of::<hailo_latency_measurement_result_t>(), 8);
1801 assert_eq!(align_of::<hailo_latency_measurement_result_t>(), 8);
1802 assert_eq!(
1803 offset_of!(hailo_latency_measurement_result_t, avg_hw_latency_ms),
1804 0
1805 );
1806 }
1807
1808 #[test]
1809 fn hailo_rate_limit_t_layout() {
1810 assert_eq!(size_of::<hailo_rate_limit_t>(), 132);
1812 assert_eq!(align_of::<hailo_rate_limit_t>(), 4);
1813 assert_eq!(offset_of!(hailo_rate_limit_t, stream_name), 0);
1814 assert_eq!(offset_of!(hailo_rate_limit_t, rate), 128);
1815 }
1816
1817 #[test]
1818 fn hailo_i2c_slave_config_t_layout() {
1819 assert_eq!(size_of::<hailo_i2c_slave_config_t>(), 12);
1822 assert_eq!(align_of::<hailo_i2c_slave_config_t>(), 4);
1823 assert_eq!(offset_of!(hailo_i2c_slave_config_t, endianness), 0);
1824 assert_eq!(offset_of!(hailo_i2c_slave_config_t, slave_address), 4);
1825 assert_eq!(
1826 offset_of!(hailo_i2c_slave_config_t, register_address_size),
1827 6
1828 );
1829 assert_eq!(offset_of!(hailo_i2c_slave_config_t, bus_index), 7);
1830 assert_eq!(offset_of!(hailo_i2c_slave_config_t, should_hold_bus), 8);
1831 }
1832}