YB_Platform/inc/msg_transfer_layer.h

88 lines
2.7 KiB
C
Raw Normal View History

// +FHDR------------------------------------------------------------
// Copyright (c) 2022 SmartLogic.
// ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename : msg_transfer_layer.h
// Author : xianfeng.du
// Created On : 2022-06-29
// Last Modified :
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------
#ifndef __MSG_TRANSFER_LAYER_H__
#define __MSG_TRANSFER_LAYER_H__
#define MAX_INSTANCE_NUM (2)
#define MAX_PORT_NUM (4)
#define SUCCESS (0)
#define FAILURE (-1)
#define UNINITIALIZED_QUEUE (1)
#define FULLEDED_QUEUE (2)
#define EMPTY_QUEUE (2)
#define OUT_OF_BLOCK_MEMORY (2)
typedef enum e_transfer_type {
NON_CU_SPLIT,
CU_SPLIT,
OAM,
TRANSFER_TYPE_NUM
} transfer_type_e;
#define MAX_TRANS_NUM (TRANSFER_TYPE_NUM-1)
typedef enum e_cu_flag {
C_PLANE,
U_PLANE
} cu_flag_e;
typedef union tHandleId {
uint32_t value;
struct {
uint8_t rsv;
uint8_t type_id;
uint8_t inst_id;
uint8_t port_id;
};
} HandleId_t;
typedef uint32_t (*msg_transfer_callback)(const char* buf,uint32_t payloadSize);
typedef struct t_queue_info {
uint32_t tx_desc_num;
uint32_t rx_desc_num;
uint32_t tx_block_size;
uint32_t rx_block_size;
uint16_t tx_block_num;
uint16_t rx_block_num;
uint16_t directions;
uint16_t rsv;
union {
uint64_t ele0;//aligned 64bit for NPU
msg_transfer_callback tx_callback;
};
union {
uint64_t ele1;//aligned 64bit for NPU
msg_transfer_callback rx_callback;
};
} queue_info_s;
typedef struct t_transfer_type_info {
queue_info_s queue_cplane_info;
queue_info_s queue_uplane_info;
} transfer_type_info_s;
//int32_t msg_transfer_init(uint16_t port_index, uint16_t transfer_type, uint16_t inst_id, const transfer_type_info_s* transfer_type_info);
int32_t msg_transfer_callback_register(uint16_t transfer_type, uint16_t inst_id, uint16_t cu_flag, msg_transfer_callback rx_callback);
int32_t msg_transfer_send_start(int32_t handle_id);
int32_t msg_transfer_alloc_msg(int32_t handle_id, uint16_t cu_flag, uint32_t bufSize, char** buf, uint32_t* availableSize, uint32_t* offset);
int32_t msg_transfer_send_msg(int32_t handle_id, uint16_t cu_flag, uint8_t* msg_ptr, uint32_t offset, uint32_t msg_len);
int32_t msg_transfer_send_end(int32_t handle_id);
int32_t msg_transfer_receive(int32_t handle_id, uint16_t cu_flag, uint32_t offset, uint32_t len, uint8_t** msg_ptr);
int32_t msg_transfer_close(int32_t handle_id);
#endif