From f25cbc7f98abce7cdee556a4e79c6f0d4fd860b1 Mon Sep 17 00:00:00 2001 From: "lishuang.xie" Date: Wed, 1 Nov 2023 11:38:08 +0800 Subject: [PATCH] update feature#1250 Support hearbeat function 1. SPU and ARM both update 2. 8 APE and 3 RFM(no pet_rfm_spu0) support hearbeat 3. ARM support new function get_heartbeat_status() to get the cores status 4. test: 4.1 spu(case34)+arm(case5): Pass 4.2 spu(case44)+arm(case5): Pass --> spu(case44)should use previous version 4.3 spu(case21)+arm(case21):Pass 4.4 spu(case14)+arm(case3): Pass --- interface/arm_interface.h | 8 ++++++ osp/inc/ospHeartbeat.h | 2 ++ osp/src/ospHeartbeat.c | 60 ++++++++++++++++++++++++++++++--------- osp/src/ospShell.c | 18 +++++++----- 4 files changed, 67 insertions(+), 21 deletions(-) diff --git a/interface/arm_interface.h b/interface/arm_interface.h index b81437f..c3af052 100644 --- a/interface/arm_interface.h +++ b/interface/arm_interface.h @@ -78,6 +78,14 @@ brief: drv function init */ 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 */ diff --git a/osp/inc/ospHeartbeat.h b/osp/inc/ospHeartbeat.h index 7251e2a..a0c6c5c 100644 --- a/osp/inc/ospHeartbeat.h +++ b/osp/inc/ospHeartbeat.h @@ -10,5 +10,7 @@ typedef struct __OspHeartBeatInfo_t int8_t OspHeartbeatPro(void); +uint32_t get_heartbeat_status(void); + #endif /* __OSP_HEARTBEAT__ */ diff --git a/osp/src/ospHeartbeat.c b/osp/src/ospHeartbeat.c index 4e37dd6..5b59c6f 100644 --- a/osp/src/ospHeartbeat.c +++ b/osp/src/ospHeartbeat.c @@ -1,18 +1,18 @@ -#include -#include -#include +#include +#include +#include #include #include #include #include -#include "pet_sm_mgt.h" -#include "msg_transfer_mem.h" +#include "pet_sm_mgt.h" +#include "msg_transfer_mem.h" #include "ospHeartbeat.h" -#include "ospSem.h" -//#include "ospSoftQue.h" -//#include "ospMsg.h" -//#include "ospDbg.h" +#include "ospSem.h" +//#include "ospSoftQue.h" +//#include "ospMsg.h" +//#include "ospDbg.h" #include "ucp_printf.h" #include "ospDelay.h" #include "ospDump.h" @@ -45,11 +45,43 @@ uint8_t* gu8virRegAddr = NULL; uint8_t* gu8VirSubctrlAddr = 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) { - PetSmLocalMgt_t* pPetSmLocalMgt = get_pet_sm_local_mgt(); - UcpHandshake_t* pHandshake = pPetSmLocalMgt->pHandshake; + PetSmLocalMgt_t* pPetSmLocalMgt = get_pet_sm_local_mgt(); + UcpHandshake_t* pHandshake = pPetSmLocalMgt->pHandshake; 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" /* 二次加载 */ -int8_t Osp2Loader(uint8_t u8CoreId) +int8_t Osp2Loader(uint8_t u8CoreId) { char cmd[128] = {0}; if (u8CoreId <= 7) { if (0 == u8CoreId%2) { - sprintf(cmd, OSP_LOAD_APE0_OUT, u8CoreId); + sprintf(cmd, OSP_LOAD_APE0_OUT, u8CoreId); } else { - sprintf(cmd, OSP_LOAD_APE1_OUT, u8CoreId); + sprintf(cmd, OSP_LOAD_APE1_OUT, u8CoreId); } UCP_PRINT_DEBUG("Osp2Loader: cmd = %s \r\n", cmd); system(cmd); diff --git a/osp/src/ospShell.c b/osp/src/ospShell.c index 74a800d..9a18239 100644 --- a/osp/src/ospShell.c +++ b/osp/src/ospShell.c @@ -21,6 +21,7 @@ #include "ospSwQueue.h" #include "pet_sm_mgt.h" #include "msg_transfer_layer.h" +#include "ospHeartbeat.h" #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] = { {"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}, {"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}, //{"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}, - //{"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}, //{"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}, @@ -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}, {"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}, - {"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}, + {"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}, {"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}, //{"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}, {"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}, -// {"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}, + {"hb", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)get_heartbeat_status, "test heartbeat", 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);