Skip to content

Commit

Permalink
v4.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HailoRT-Automation committed Jul 19, 2022
1 parent c5cf7e1 commit 6346a2d
Show file tree
Hide file tree
Showing 118 changed files with 5,044 additions and 2,596 deletions.
71 changes: 47 additions & 24 deletions common/include/context_switch_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ extern "C" {
(((cluster_index) << CONTEXT_SWITCH_DEFS__PACKED_LCU_ID_CLUSTER_INDEX_SHIFT) & CONTEXT_SWITCH_DEFS__PACKED_LCU_ID_CLUSTER_INDEX_MASK)


#define CONTEXT_SWITCH_DEFS__PACKED_VDMA_CHANNEL_ID__VDMA_CHANNEL_INDEX_MASK (0x1f)
#define CONTEXT_SWITCH_DEFS__PACKED_VDMA_CHANNEL_ID__ENGINE_INDEX_MASK (0x60)
#define CONTEXT_SWITCH_DEFS__PACKED_VDMA_CHANNEL_ID__ENGINE_INDEX_SHIFT (5)

#define CONTEXT_SWITCH_DEFS__PACKED_VDMA_CHANNEL_ID__SET(dst, engine_index, vdma_channel_index) do { \
(dst) = (vdma_channel_index) | ((engine_index) << CONTEXT_SWITCH_DEFS__PACKED_VDMA_CHANNEL_ID__ENGINE_INDEX_SHIFT);\
} while (0)

#define CONTEXT_SWITCH_DEFS__PACKED_VDMA_CHANNEL_ID__READ(src, engine_index, vdma_channel_index) do {\
(engine_index) = ((src) & CONTEXT_SWITCH_DEFS__PACKED_VDMA_CHANNEL_ID__ENGINE_INDEX_MASK) >> \
CONTEXT_SWITCH_DEFS__PACKED_VDMA_CHANNEL_ID__ENGINE_INDEX_SHIFT; \
(vdma_channel_index) = ((src) & CONTEXT_SWITCH_DEFS__PACKED_VDMA_CHANNEL_ID__VDMA_CHANNEL_INDEX_MASK); \
} while (0)

#pragma pack(push, 1)
typedef struct {
uint16_t core_bytes_per_buffer;
Expand Down Expand Up @@ -86,6 +100,7 @@ typedef enum __attribute__((packed)) {
CONTEXT_SWITCH_DEFS__ACTION_TYPE_FETCH_CCW_BURSTS,
CONTEXT_SWITCH_DEFS__ACTION_TYPE_VALIDATE_VDMA_CHANNEL,
CONTEXT_SWITCH_DEFS__ACTION_TYPE_BURST_CREDITS_TASK_START,
CONTEXT_SWITCH_DEFS__ACTION_TYPE_DDR_BUFFERING_RESET,

/* Must be last */
CONTEXT_SWITCH_DEFS__ACTION_TYPE_COUNT
Expand Down Expand Up @@ -141,12 +156,12 @@ typedef struct {

typedef struct {
uint16_t descriptors_count;
uint8_t cfg_channel_number;
uint8_t packed_vdma_channel_id;
} CONTEXT_SWITCH_DEFS__fetch_cfg_channel_descriptors_action_data_t;

typedef struct {
uint16_t ccw_bursts;
uint8_t cfg_channel_number;
uint8_t config_stream_index;
} CONTEXT_SWITCH_DEFS__fetch_ccw_bursts_action_data_t;

typedef struct {
Expand All @@ -172,15 +187,15 @@ typedef struct {
} CONTEXT_SWITCH_DEFS__disable_lcu_action_data_t;

typedef struct {
uint8_t vdma_channel_index;
uint8_t packed_vdma_channel_id;
uint8_t edge_layer_direction;
bool is_inter_context;
uint8_t host_buffer_type; // CONTROL_PROTOCOL__HOST_BUFFER_TYPE_t
uint32_t initial_credit_size;
} CONTEXT_SWITCH_DEFS__deactivate_vdma_channel_action_data_t;

typedef struct {
uint8_t vdma_channel_index;
uint8_t packed_vdma_channel_id;
uint8_t edge_layer_direction;
bool is_inter_context;
bool is_single_context_network_group;
Expand All @@ -189,7 +204,7 @@ typedef struct {
} CONTEXT_SWITCH_DEFS__validate_vdma_channel_action_data_t;

typedef struct {
uint8_t vdma_channel_index;
uint8_t packed_vdma_channel_id;
uint8_t stream_index;
uint8_t network_index;
uint32_t frame_periph_size;
Expand All @@ -199,7 +214,7 @@ typedef struct {
} CONTEXT_SWITCH_DEFS__fetch_data_action_data_t;

typedef struct {
uint8_t vdma_channel_index;
uint8_t packed_vdma_channel_id;
uint8_t stream_index;
bool is_dummy_stream;
} CONTEXT_SWITCH_DEFS__change_vdma_to_stream_mapping_data_t;
Expand All @@ -218,7 +233,7 @@ typedef struct {
} CONTEXT_SWITCH_DEFS__lcu_interrupt_data_t;

typedef struct {
uint8_t vdma_channel_index;
uint8_t packed_vdma_channel_id;
} CONTEXT_SWITCH_DEFS__vdma_dataflow_interrupt_data_t;

typedef struct {
Expand All @@ -235,7 +250,7 @@ typedef struct {
} CONTEXT_SWITCH_DEFS__wait_nms_idle_data_t;

typedef struct {
uint8_t vdma_channel_index;
uint8_t packed_vdma_channel_id;
uint8_t stream_index;
bool is_inter_context;
} CONTEXT_SWITCH_DEFS__wait_dma_idle_data_t;
Expand All @@ -250,65 +265,73 @@ typedef struct {

/* edge layers structs */
typedef struct {
uint8_t packed_vdma_channel_id;
uint8_t stream_index;
uint8_t vdma_channel_index;
CONTEXT_SWITCH_DEFS__stream_reg_info_t stream_reg_info;
CONTROL_PROTOCOL__host_buffer_info_t host_buffer_info;
uint32_t initial_credit_size;
bool is_single_context_app;
} CONTEXT_SWITCH_DEFS__activate_boundary_input_data_t;

typedef struct {
uint8_t packed_vdma_channel_id;
uint8_t stream_index;
uint8_t vdma_channel_index;
uint8_t network_index;
CONTEXT_SWITCH_DEFS__stream_reg_info_t stream_reg_info;
CONTROL_PROTOCOL__host_buffer_info_t host_buffer_info;
uint32_t initial_credit_size;
} CONTEXT_SWITCH_DEFS__activate_inter_context_input_data_t;

typedef struct {
uint8_t packed_vdma_channel_id;
uint8_t stream_index;
uint8_t vdma_channel_index;
CONTEXT_SWITCH_DEFS__stream_reg_info_t stream_reg_info;
uint64_t host_descriptors_base_address;
uint8_t desc_list_depth;
CONTROL_PROTOCOL__host_buffer_info_t host_buffer_info;
uint32_t initial_credit_size;
uint8_t connected_d2h_channel_index;
} CONTEXT_SWITCH_DEFS__activate_ddr_buffer_input_data_t;

typedef struct {
uint8_t packed_vdma_channel_id;
uint8_t stream_index;
uint8_t vdma_channel_index;
CONTEXT_SWITCH_DEFS__stream_reg_info_t stream_reg_info;
uint32_t frame_credits_in_bytes;
uint16_t desc_page_size;
CONTROL_PROTOCOL__host_buffer_info_t host_buffer_info;
} CONTEXT_SWITCH_DEFS__activate_boundary_output_data_t;

typedef struct {
uint8_t packed_vdma_channel_id;
uint8_t stream_index;
uint8_t vdma_channel_index;
uint8_t network_index;
CONTEXT_SWITCH_DEFS__stream_reg_info_t stream_reg_info;
CONTROL_PROTOCOL__host_buffer_info_t host_buffer_info;
} CONTEXT_SWITCH_DEFS__activate_inter_context_output_data_t;

typedef struct {
uint8_t packed_vdma_channel_id;
uint8_t stream_index;
uint8_t vdma_channel_index;
CONTEXT_SWITCH_DEFS__stream_reg_info_t stream_reg_info;
uint32_t frame_credits_in_bytes;
uint64_t host_descriptors_base_address;
uint16_t desc_page_size;
uint8_t desc_list_depth;
CONTROL_PROTOCOL__host_buffer_info_t host_buffer_info;
uint32_t buffered_rows_count;
} CONTEXT_SWITCH_DEFS__activate_ddr_buffer_output_data_t;

typedef union {
CONTEXT_SWITCH_DEFS__activate_boundary_input_data_t activate_boundary_input_data;
CONTEXT_SWITCH_DEFS__activate_inter_context_input_data_t activate_inter_context_input_data;
CONTEXT_SWITCH_DEFS__activate_ddr_buffer_input_data_t activate_ddr_buffer_input_data;
CONTEXT_SWITCH_DEFS__activate_boundary_output_data_t activate_boundary_output_data;
CONTEXT_SWITCH_DEFS__activate_inter_context_output_data_t activate_inter_context_output_data;
CONTEXT_SWITCH_DEFS__activate_ddr_buffer_output_data_t activate_ddr_buffer_output_data;
} CONTEXT_SWITCH_COMMON__activate_edge_layer_action_t;

typedef struct {
uint8_t channel_index;
uint8_t packed_vdma_channel_id;
uint8_t config_stream_index;
CONTROL_PROTOCOL__host_buffer_info_t host_buffer_info;
} CONTEXT_SWITCH_DEFS__activate_cfg_channel_t;

typedef struct {
uint8_t channel_index;
uint8_t packed_vdma_channel_id;
uint8_t config_stream_index;
} CONTEXT_SWITCH_DEFS__deactivate_cfg_channel_t;

#pragma pack(pop)
Expand Down
44 changes: 25 additions & 19 deletions common/include/control_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern "C" {
#define CONTROL_PROTOCOL__MAX_CONTEXT_SWITCH_APPLICATIONS (8)
#define CONTROL_PROTOCOL__MAX_NUMBER_OF_CLUSTERS (8)
#define CONTROL_PROTOCOL__MAX_CONTROL_LENGTH (1500)
#define CONTROL_PROTOCOL__MAX_TOTAL_CONTEXTS (32)
#define CONTROL_PROTOCOL__MAX_TOTAL_CONTEXTS (64)
#define CONTROL_PROTOCOL__SOC_ID_LENGTH (32)
#define CONTROL_PROTOCOL__MAX_CFG_CHANNELS (4)
#define CONTROL_PROTOCOL__MAX_NETWORKS_PER_NETWORK_GROUP (8)
Expand Down Expand Up @@ -878,7 +878,6 @@ typedef struct {
typedef struct {
uint8_t dynamic_contexts_count;
uint32_t host_boundary_channels_bitmap;
uint8_t cfg_channel_numbers[CONTROL_PROTOCOL__MAX_CFG_CHANNELS];
uint8_t power_mode; // CONTROL_PROTOCOL__power_mode_t
CONTROL_PROTOCOL__INFER_FEATURE_LIST_t infer_features;
uint8_t networks_count;
Expand Down Expand Up @@ -969,6 +968,7 @@ typedef enum {
CONTROL_PROTOCOL__CONTEXT_SWITCH_ACTION_ADD_REPEATED,
CONTROL_PROTOCOL__CONTEXT_SWITCH_ACTION_FETCH_CCW_BURSTS,
CONTROL_PROTOCOL__CONTEXT_SWITCH_ACTION_BURST_CREDITS_TASK_START,
CONTROL_PROTOCOL__CONTEXT_SWITCH_ACTION_EDGE_LAYER_ACTIVATION_ACTIONS_POSITION,

/* must be last*/
CONTROL_PROTOCOL__CONTEXT_SWITCH_ACTION_COUNT,
Expand Down Expand Up @@ -1054,6 +1054,7 @@ typedef struct {
uint32_t bytes_in_pattern;
} CONTROL_PROTOCOL__host_buffer_info_t;

/* TODO: merge CONTROL_PROTOCOL__edge_layer_common_info_t into the header (HRT-7113) */
typedef struct {
uint8_t communication_type;
uint8_t edge_connection_type;
Expand All @@ -1066,15 +1067,9 @@ typedef struct {
CONTROL_PROTOCOL__nn_stream_config_t nn_stream_config;
} CONTROL_PROTOCOL__edge_layer_common_info_t;

typedef struct {
uint64_t host_descriptors_base_address;
uint8_t desc_list_depth;
} CONTROL_PROTOCOL__host_desc_address_info_t;

typedef struct {
CONTROL_PROTOCOL__edge_layer_common_info_t common_info;
uint32_t frame_credits_in_bytes;
uint16_t desc_page_size;
CONTROL_PROTOCOL__host_buffer_info_t host_buffer_info;
} CONTROL_PROTOCOL__network_boundary_output_t;

typedef struct {
Expand All @@ -1084,9 +1079,7 @@ typedef struct {

typedef struct {
CONTROL_PROTOCOL__edge_layer_common_info_t common_info;
uint32_t frame_credits_in_bytes;
CONTROL_PROTOCOL__host_desc_address_info_t host_desc_address_info;
uint16_t desc_page_size;
CONTROL_PROTOCOL__host_buffer_info_t host_buffer_info;
uint32_t buffered_rows_count;
} CONTROL_PROTOCOL__ddr_buffer_output_t;

Expand All @@ -1097,7 +1090,7 @@ typedef struct {

typedef struct {
CONTROL_PROTOCOL__edge_layer_common_info_t common_info;
uint16_t desc_page_size;
CONTROL_PROTOCOL__host_buffer_info_t host_buffer_info;
uint32_t initial_credit_size;
} CONTROL_PROTOCOL__network_boundary_input_t;

Expand All @@ -1109,8 +1102,9 @@ typedef struct {

typedef struct {
CONTROL_PROTOCOL__edge_layer_common_info_t common_info;
CONTROL_PROTOCOL__host_desc_address_info_t host_desc_address_info;
CONTROL_PROTOCOL__host_buffer_info_t host_buffer_info;
uint32_t initial_credit_size;
uint8_t connected_d2h_channel_index;
} CONTROL_PROTOCOL__ddr_buffer_input_t;

typedef struct {
Expand All @@ -1121,6 +1115,11 @@ typedef struct {
uint8_t should_use_stream_remap;
} CONTROL_PROTOCOL__stream_remap_data_t;

typedef struct {
CONTROL_PROTOCOL__host_buffer_info_t config_buffer_info;
uint8_t vdma_channel_index;
} CONTROL_PROTOCOL__config_channel_info_t;

#if defined(_MSC_VER)
// TODO: warning C4200
#pragma warning(push)
Expand All @@ -1133,8 +1132,8 @@ typedef struct {
uint8_t is_last_control_per_context;
uint32_t cfg_channels_count_length;
uint8_t cfg_channels_count;
uint32_t config_buffer_infos_length;
CONTROL_PROTOCOL__host_buffer_info_t config_buffer_infos[CONTROL_PROTOCOL__MAX_CFG_CHANNELS];
uint32_t config_channel_infos_length;
CONTROL_PROTOCOL__config_channel_info_t config_channel_infos[CONTROL_PROTOCOL__MAX_CFG_CHANNELS];
uint32_t context_stream_remap_data_length;
CONTROL_PROTOCOL__stream_remap_data_t context_stream_remap_data;
uint32_t number_of_edge_layers_length;
Expand Down Expand Up @@ -1209,14 +1208,14 @@ typedef struct {
/* Must be first */
CONTROL_PROTOCOL__ACTION_HEADER_t header;
uint16_t descriptors_count;
uint8_t cfg_channel_handle;
uint8_t config_stream_index;
} CONTROL_PROTOCOL__READ_VDMA_ACTION_t;

typedef struct {
/* Must be first */
CONTROL_PROTOCOL__ACTION_HEADER_t header;
uint16_t ccw_bursts;
uint8_t cfg_channel_handle;
uint8_t config_stream_index;
} CONTROL_PROTOCOL__FETCH_CCW_BURSTS_ACTION_t;

typedef struct {
Expand Down Expand Up @@ -1299,6 +1298,11 @@ typedef struct {
CONTROL_PROTOCOL__ACTION_HEADER_t header;
} CONTROL_PROTOCOL__BURST_CREDITS_TASK_START_ACTION_T;

typedef struct {
/* Must be first */
CONTROL_PROTOCOL__ACTION_HEADER_t header;
} CONTROL_PROTOCOL__EDGE_LAYER_ACTIVATION_ACTIONS_POSITION_MARKER_T;

typedef struct {
CONTROL_PROTOCOL__TRIGGER_t trigger;
uint16_t triggers_action_count;
Expand Down Expand Up @@ -1360,6 +1364,8 @@ typedef struct {
uint8_t application_index;
uint32_t dynamic_batch_size_length;
uint16_t dynamic_batch_size;
uint32_t keep_nn_config_during_reset_length;
uint8_t keep_nn_config_during_reset;
} CONTROL_PROTOCOL__change_context_switch_status_request_t;

typedef struct {
Expand Down Expand Up @@ -1713,7 +1719,7 @@ typedef struct {
bool is_first_control_per_context;
bool is_last_control_per_context;
uint8_t cfg_channels_count;
CONTROL_PROTOCOL__host_buffer_info_t config_buffer_infos[CONTROL_PROTOCOL__MAX_CFG_CHANNELS];
CONTROL_PROTOCOL__config_channel_info_t config_channel_infos[CONTROL_PROTOCOL__MAX_CFG_CHANNELS];
CONTROL_PROTOCOL__stream_remap_data_t context_stream_remap_data;
uint8_t number_of_edge_layers;
uint8_t number_of_trigger_groups;
Expand Down
Loading

0 comments on commit 6346a2d

Please sign in to comment.