YB_Platform/public/common/msg/inc/msg_transfer_queue.h
2023-07-13 11:27:03 +08:00

103 lines
2.8 KiB
C

// +FHDR------------------------------------------------------------
// Copyright (c) 2022 SmartLogic.
// ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename : msg_transfer_queue.h
// Author : xianfeng.du
// Created On : 2022-12-21
// Last Modified :
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------
#ifndef __MSG_TRANSFER_QUEUE_H__
#define __MSG_TRANSFER_QUEUE_H__
#include "typedef.h"
#include "ucp_utility.h"
#include "msg_transfer_layer.h"
#define MAX_M_BUFFER_NUM 128
typedef enum eMsgQueueType {
UCP4008_TRAFFIC_NR_eMBB_DATA,
UCP4008_TRAFFIC_NR_eMBB_CTRL,
UCP4008_TRAFFIC_OAM,
UCP4008_TRAFFIC_MAX_NUM
} MsgQueueType_e;
typedef struct tQueueCfg {
uint32_t block_size;
uint16_t block_num;
uint16_t rsv;
//msg_transfer_callback* tx_callback;
union {
uint64_t ele;//aligned 64bit for NPU
msg_transfer_callback rx_callback;
};
} QueueCfg_t;
typedef struct tMsgQueueCfg {
HandleId_t handler;
QueueCfg_t tx_queue;
QueueCfg_t rx_queue;
} MsgQueueCfg_t;
typedef struct tMsgQueueCommonInfo {
uint32_t alloc;
uint32_t in;
uint32_t out;
uint32_t free;
uint16_t ringSize;
uint16_t ringMask;
uint32_t bufBase;
uint32_t bufSize;
uint32_t bufIdxBase;
} MsgQueueCommonInfo_t;
typedef struct tMsgQueueLocalInfo {
uint32_t alloc;
uint32_t in;
uint32_t out;
uint32_t free;
uint16_t ringSize;
uint16_t ringMask;
uint32_t bufBase;
uint32_t bufSize;
uint32_t bufIdxBase;
uint32_t bufAddr;
uint32_t availableSize;
uint32_t offset;
uint16_t idx;
uint16_t msgCnt;
} MsgQueueLocalInfo_t;
typedef struct tSyncInfo {
uint8_t queueCfgFlag;
uint8_t rsv[15];
} SyncInfo_t;
typedef struct tMsgQueueLocalMgt {
SyncInfo_t localSyncInfo;
MsgQueueCfg_t localQueueCfg[MAX_INSTANCE_NUM][UCP4008_TRAFFIC_MAX_NUM];//local
MsgQueueLocalInfo_t localDlQueue[MAX_INSTANCE_NUM][UCP4008_TRAFFIC_MAX_NUM];//local
MsgQueueLocalInfo_t localUlQueue[MAX_INSTANCE_NUM][UCP4008_TRAFFIC_MAX_NUM];//local
} MsgQueueLocalMgt_t;
ALWAYS_INLINE void* get_mbuf_ptr(uint32_t base, uint32_t size, uint16_t idx);
ALWAYS_INLINE int32_t msg_queue_ul_block_init(uint8_t inst_id, uint8_t que_id);
//ALWAYS_INLINE uint8_t* msg_queue_ul_alloc_buf(uint8_t inst_id, uint8_t que_id);
ALWAYS_INLINE uint8_t* msg_queue_ul_alloc_buf(uint8_t inst_id, uint8_t que_id, uint16_t* buf_id);
ALWAYS_INLINE int32_t msg_queue_ul_put_buf(uint8_t inst_id, uint8_t que_id);
ALWAYS_INLINE uint8_t* msg_queue_dl_get_buf(uint8_t inst_id, uint8_t que_id);
void msg_transfer_queue_init(void);
void msg_transfer_queue_recfg(void);
#endif