Merge branch 'dev_ck_v2.1_feature#1250#' into 'dev_ck_v2.1'

update feature#1250 Support hearbeat function

See merge request ucp/driver/ucp4008_platform_arm!31
This commit is contained in:
Xianfeng Du 2023-11-02 00:19:37 +00:00
commit fa4a1d0174
4 changed files with 67 additions and 21 deletions

View File

@ -78,6 +78,14 @@ brief: drv function init
*/ */
int32_t drv_init(void); int32_t drv_init(void);
/*
name: get_heartbeat_status
para: null
brief: get the status of spu cores
return value: 0:success other:bitmap for all cores(1:missing heartbeat)
*/
uint32_t get_heartbeat_status(void);
/**********************************************************************************************/ /**********************************************************************************************/
/* testmac interface */ /* testmac interface */

View File

@ -10,5 +10,7 @@ typedef struct __OspHeartBeatInfo_t
int8_t OspHeartbeatPro(void); int8_t OspHeartbeatPro(void);
uint32_t get_heartbeat_status(void);
#endif /* __OSP_HEARTBEAT__ */ #endif /* __OSP_HEARTBEAT__ */

View File

@ -1,18 +1,18 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <fcntl.h> #include <fcntl.h>
#include "pet_sm_mgt.h" #include "pet_sm_mgt.h"
#include "msg_transfer_mem.h" #include "msg_transfer_mem.h"
#include "ospHeartbeat.h" #include "ospHeartbeat.h"
#include "ospSem.h" #include "ospSem.h"
//#include "ospSoftQue.h" //#include "ospSoftQue.h"
//#include "ospMsg.h" //#include "ospMsg.h"
//#include "ospDbg.h" //#include "ospDbg.h"
#include "ucp_printf.h" #include "ucp_printf.h"
#include "ospDelay.h" #include "ospDelay.h"
#include "ospDump.h" #include "ospDump.h"
@ -45,11 +45,43 @@ uint8_t* gu8virRegAddr = NULL;
uint8_t* gu8VirSubctrlAddr = NULL; uint8_t* gu8VirSubctrlAddr = NULL;
uint8_t* gu8VirRstCfgAddr = NULL; uint8_t* gu8VirRstCfgAddr = NULL;
uint32_t g32heartbeatCounter[MAX_NUM_SPU] = {0};
uint32_t get_heartbeat_status(void)
{
volatile uint32_t vu32counter = 0;
uint32_t u32coreHeartbeatBitmap = SUCCESS;
uint32_t u32coreHeartbeatMask = 0xEFF;
uint8_t u8loop = 0;
PetSmLocalMgt_t* pPetSmLocalMgt = get_pet_sm_local_mgt();
UcpHandshake_t* pHandshake = pPetSmLocalMgt->pHandshake;
for (u8loop = 0; u8loop < MAX_NUM_SPU; u8loop++)
{
vu32counter = pHandshake->heartbeat[u8loop];
if (vu32counter == g32heartbeatCounter[u8loop])
{
u32coreHeartbeatBitmap |= (1 << u8loop);
}
/* update */
g32heartbeatCounter[u8loop] = vu32counter;
}
u32coreHeartbeatBitmap &= u32coreHeartbeatMask;
UCP_PRINT_WARN("[get_heartbeat_status]: HeartbeatBitMap = 0x%x\r\n", u32coreHeartbeatBitmap);
return u32coreHeartbeatBitmap;
}
/* 获取对应核的心跳计数 */ /* 获取对应核的心跳计数 */
uint32_t OspGetHeartbeat(uint8_t u8CoreId) uint32_t OspGetHeartbeat(uint8_t u8CoreId)
{ {
PetSmLocalMgt_t* pPetSmLocalMgt = get_pet_sm_local_mgt(); PetSmLocalMgt_t* pPetSmLocalMgt = get_pet_sm_local_mgt();
UcpHandshake_t* pHandshake = pPetSmLocalMgt->pHandshake; UcpHandshake_t* pHandshake = pPetSmLocalMgt->pHandshake;
return pHandshake->heartbeat[u8CoreId]; return pHandshake->heartbeat[u8CoreId];
} }
@ -157,18 +189,18 @@ int8_t OspDumpDm2Ddr(uint8_t u8CoreId)
#define OSP_LOAD_APE1_OUT "./loadelf_8g -ape dump_im.ape1.out %d 1" #define OSP_LOAD_APE1_OUT "./loadelf_8g -ape dump_im.ape1.out %d 1"
/* 二次加载 */ /* 二次加载 */
int8_t Osp2Loader(uint8_t u8CoreId) int8_t Osp2Loader(uint8_t u8CoreId)
{ {
char cmd[128] = {0}; char cmd[128] = {0};
if (u8CoreId <= 7) if (u8CoreId <= 7)
{ {
if (0 == u8CoreId%2) if (0 == u8CoreId%2)
{ {
sprintf(cmd, OSP_LOAD_APE0_OUT, u8CoreId); sprintf(cmd, OSP_LOAD_APE0_OUT, u8CoreId);
} }
else else
{ {
sprintf(cmd, OSP_LOAD_APE1_OUT, u8CoreId); sprintf(cmd, OSP_LOAD_APE1_OUT, u8CoreId);
} }
UCP_PRINT_DEBUG("Osp2Loader: cmd = %s \r\n", cmd); UCP_PRINT_DEBUG("Osp2Loader: cmd = %s \r\n", cmd);
system(cmd); system(cmd);

View File

@ -21,6 +21,7 @@
#include "ospSwQueue.h" #include "ospSwQueue.h"
#include "pet_sm_mgt.h" #include "pet_sm_mgt.h"
#include "msg_transfer_layer.h" #include "msg_transfer_layer.h"
#include "ospHeartbeat.h"
#define MAX_CMD_LEN (150) /*the max length of a shell command */ #define MAX_CMD_LEN (150) /*the max length of a shell command */
@ -62,13 +63,14 @@ void help(void);
OSP_CMD_RTN ospCmdRtnTbl[MAX_CMD_NUM] = OSP_CMD_RTN ospCmdRtnTbl[MAX_CMD_NUM] =
{ {
{"help", (OSP_FUNCPTR)help, NULL, }, {"help", (OSP_FUNCPTR)help, NULL, },
{"?", (OSP_FUNCPTR)help, NULL, }, {"?", (OSP_FUNCPTR)help, NULL, },
{"i", (OSP_FUNCPTR)osp_show_task_info, NULL,"show alltask info", 0}, {"i", (OSP_FUNCPTR)osp_show_task_info, NULL,"show alltask info", 0},
{"oam", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_set_oam, "set arm oam level", 1}, {"oam", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_set_oam, "set arm oam level", 1},
//{"x", (OSP_FUNCPTR)osp_shell_mem_wrapper, (OSP_FUNCPTR)osp_shell_dis_mem, "x num addr: show addr memory(length is num)", 2}, //{"x", (OSP_FUNCPTR)osp_shell_mem_wrapper, (OSP_FUNCPTR)osp_shell_dis_mem, "x num addr: show addr memory(length is num)", 2},
//{"s", (OSP_FUNCPTR)osp_shell_mem_wrapper, (OSP_FUNCPTR)osp_shell_set_mem, "s addr val: set addr memory(length is 4)", 2}, //{"s", (OSP_FUNCPTR)osp_shell_mem_wrapper, (OSP_FUNCPTR)osp_shell_set_mem, "s addr val: set addr memory(length is 4)", 2},
//{"phym", (OSP_FUNCPTR)osp_shell_mem_wrapper, (OSP_FUNCPTR)osp_display_phy_mem, "show phy mempry info", 2}, //{"phym", (OSP_FUNCPTR)osp_shell_mem_wrapper, (OSP_FUNCPTR)osp_display_phy_mem, "show phy mempry info", 2},
//{"c", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_show_tsk_diag_cnt, "show Task Diag Cnt", 1}, //{"c", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_show_tsk_diag_cnt, "show Task Diag Cnt", 1},
//{"sw", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_show_swqueue_info, "show arm print level", 0},
{"net", (OSP_FUNCPTR)osp_show_udp, NULL, "show net info", 0}, {"net", (OSP_FUNCPTR)osp_show_udp, NULL, "show net info", 0},
//{"sw", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_show_swqueue_info, "show arm print level", 0}, //{"sw", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_show_swqueue_info, "show arm print level", 0},
{"level", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_set_print_level, "set arm print level", 1}, {"level", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_set_print_level, "set arm print level", 1},
@ -83,8 +85,8 @@ OSP_CMD_RTN ospCmdRtnTbl[MAX_CMD_NUM] =
{"armlog", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_set_arm_log_mode, "0: arm log write file 1: arm log out to net 2:arm log to shell", 1}, {"armlog", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_set_arm_log_mode, "0: arm log write file 1: arm log out to net 2:arm log to shell", 1},
{"plog", (OSP_FUNCPTR)osp_shell_wrapper,(OSP_FUNCPTR)osp_set_platform_log_mode, "0: platform log write file 1: platform log out to net 2:platform log to shell", 1}, {"plog", (OSP_FUNCPTR)osp_shell_wrapper,(OSP_FUNCPTR)osp_set_platform_log_mode, "0: platform log write file 1: platform log out to net 2:platform log to shell", 1},
{"server", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_server_cfg, "server ip port", 2}, {"server", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_server_cfg, "server ip port", 2},
{"ss", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_server_cfg_show, "show server cfg", 0}, {"ss", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_server_cfg_show, "show server cfg", 0},
{"logpath", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_log_path_cfg, "cfg log path", 1}, {"logpath", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_log_path_cfg, "cfg log path", 1},
{"relog", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_log_mode_get,"reload log cfg", 0}, {"relog", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_log_mode_get,"reload log cfg", 0},
//{"tfu", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_get_tfu_location_info, "get tfu location", 0}, //{"tfu", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_get_tfu_location_info, "get tfu location", 0},
//{"clock_info", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_get_clock_tracking_state, "get clock tracking state", 0}, //{"clock_info", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_get_clock_tracking_state, "get clock tracking state", 0},
@ -92,9 +94,11 @@ OSP_CMD_RTN ospCmdRtnTbl[MAX_CMD_NUM] =
//{"set_clock", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_set_clk_mode, "set clock module", 1}, //{"set_clock", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_set_clk_mode, "set clock module", 1},
{"recmd_ape", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_reget_ape_cmd, "get ape cmd again", 0}, {"recmd_ape", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_reget_ape_cmd, "get ape cmd again", 0},
{"intr_ape", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_ape_csu_int_cnt, "show intr info", 0}, {"intr_ape", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_ape_csu_int_cnt, "show intr info", 0},
// {"level_ape", (OSP_FUNCPTR)osp_shell_wrapper,(OSP_FUNCPTR)osp_ape_set_log_level, "set ape log level", 1}, {"hb", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)get_heartbeat_status, "test heartbeat", 0},
// {"csu_stop_ape", (OSP_FUNCPTR)osp_shell_wrapper,(OSP_FUNCPTR)osp_ape_csu_stop_cfg, "set csu start or stop", 2},
// {"i_ape", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_show_ape_taskinfo, "show ape task info", 0}, //{"level_ape", (OSP_FUNCPTR)osp_shell_wrapper,(OSP_FUNCPTR)osp_ape_set_log_level, "set ape log level", 1},
//{"csu_stop_ape", (OSP_FUNCPTR)osp_shell_wrapper,(OSP_FUNCPTR)osp_ape_csu_stop_cfg, "set csu start or stop", 2},
//{"i_ape", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_show_ape_taskinfo, "show ape task info", 0},
}; };
int32_t SHELL_CMD_NUM = OSP_NELEMENTS(ospCmdRtnTbl); int32_t SHELL_CMD_NUM = OSP_NELEMENTS(ospCmdRtnTbl);