From 946789f001471ffa0b0c39b178f786368ca97345 Mon Sep 17 00:00:00 2001 From: "yonglin.gui" Date: Sun, 8 Oct 2023 09:43:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9pcie=20testcase=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E9=80=82=E9=85=8D=E6=96=B0=E4=BB=A3=E7=A0=81=E6=A1=86?= =?UTF-8?q?=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../case50/fronthaul/8ape_case(30K).txt | 0 .../case50/fronthaul/src/fh_test_case50.s.c | 61 +++ .../testcases/case50/osp/inc/pcie_testcase.h | 34 ++ .../testcases/case50/osp/src/pcie_testcase.c | 471 ++++++++++++++++++ 4 files changed, 566 insertions(+) create mode 100644 public/test/testcases/case50/fronthaul/8ape_case(30K).txt create mode 100644 public/test/testcases/case50/fronthaul/src/fh_test_case50.s.c create mode 100644 public/test/testcases/case50/osp/inc/pcie_testcase.h create mode 100644 public/test/testcases/case50/osp/src/pcie_testcase.c diff --git a/public/test/testcases/case50/fronthaul/8ape_case(30K).txt b/public/test/testcases/case50/fronthaul/8ape_case(30K).txt new file mode 100644 index 0000000..e69de29 diff --git a/public/test/testcases/case50/fronthaul/src/fh_test_case50.s.c b/public/test/testcases/case50/fronthaul/src/fh_test_case50.s.c new file mode 100644 index 0000000..2df6169 --- /dev/null +++ b/public/test/testcases/case50/fronthaul/src/fh_test_case50.s.c @@ -0,0 +1,61 @@ +// +FHDR------------------------------------------------------------ +// Copyright (c) 2022 SmartLogic. +// ALL RIGHTS RESERVED +// ----------------------------------------------------------------- +// Filename : ape_test_case1.s.c +// Author : +// Created On : 2022-10-26 +// Last Modified : +// ----------------------------------------------------------------- +// Description: +// +// +// -FHDR------------------------------------------------------------ + +#include "typedef.h" +#include "ucp_printf.h" +#include "phy_para.h" + + +/************************************************************************/ +extern void cpri_init(uint32_t option,uint32_t MappingMode); +extern void jesd_init(); +extern void ecpri_init(uint8_t nOption); + +int32_t fh_data_init(void) +{ + return 0; +} + +int32_t fh_drv_init() +{ +#ifdef DISTRIBUTED_BS + cpri_init(CPRI_OPTION_8, OTIC_MAP_FIGURE12); +#endif +#ifdef ECPRI_DISTRIBUTED_BS + ecpri_init(ECPRI_OPTION_10G); +#endif +#ifdef INTEGRATED_BS + jesd_init(); +#endif + + return 0; +} + +int32_t fh_csu_test_init(void) +{ + + return 0; +} + +void fh_test_case() +{ + return; +} + +void fh_data_check(uint32_t times) +{ + return; +} + + diff --git a/public/test/testcases/case50/osp/inc/pcie_testcase.h b/public/test/testcases/case50/osp/inc/pcie_testcase.h new file mode 100644 index 0000000..5700ec1 --- /dev/null +++ b/public/test/testcases/case50/osp/inc/pcie_testcase.h @@ -0,0 +1,34 @@ +// +FHDR------------------------------------------------------------ +// Copyright (c) 2022 SmartLogic. +// ALL RIGHTS RESERVED +// ----------------------------------------------------------------- +// Filename : ucp_pcie_traffic.h +// Author : xianfeng.du +// Created On : 2022-06-25 +// Last Modified : +// ----------------------------------------------------------------- +// Description: +// +// +// -FHDR------------------------------------------------------------ +#ifndef __PCIE_TESTCASE_H__ +#define __PCIE_TESTCASE_H__ + + +uint32_t pcie_rx_callback_data(const char* buf,uint32_t payloadSize); +uint32_t pcie_rx_callback_ctrl(const char* buf,uint32_t payloadSize); +uint32_t pcie_rx_callback_oam(const char* buf,uint32_t payloadSize); +void test_case_cfgpar_pcie(); +void test_case_sendmsg_pcie(); +void test_case_recv_msg_pcie(); +void test_speed_sendmsg_pcie(); +void test_speed_recv_msg_pcie(); +void ape0_test_task_reg(void); +void pcie_test_task_func(void); +void ape1_test_task_reg(void); +void ape2_test_task_reg(void); +void ape3_test_task_reg(void); + +#endif + + diff --git a/public/test/testcases/case50/osp/src/pcie_testcase.c b/public/test/testcases/case50/osp/src/pcie_testcase.c new file mode 100644 index 0000000..75d3a33 --- /dev/null +++ b/public/test/testcases/case50/osp/src/pcie_testcase.c @@ -0,0 +1,471 @@ +// +FHDR------------------------------------------------------------ +// Copyright (c) 2022 SmartLogic. +// ALL RIGHTS RESERVED +// ----------------------------------------------------------------- +// Filename : main.c +// Author : xianfeng.du +// Created On : 2022-06-25 +// Last Modified : +// ----------------------------------------------------------------- +// Description: +// +// +// -FHDR------------------------------------------------------------ +#include "typedef.h" +#include "osp_task.h" +#include "osp_timer.h" +#include "ucp_printf.h" +#include "spu_log.h" + +#include "ucp_drv_common.h" +//#include "pet_rfm_spu0_top.h" +//#include "msg_transfer_host.h" +#include "msg_transfer_layer.h" +//#include "ucp_pcie_traffic.h" +#include "ucp_printf.h" +#include "msg_transfer_mem.h" +#include "msg_transfer_mbuffer.h" + +uint32_t pcie_rx_callback_data(const char* buf,uint32_t payloadSize) +{ + char tmplogbuf[1024] = {0}; + if(payloadSize < 1024) + { + memcpy_ucp(tmplogbuf, buf, payloadSize); + } + else + { + memcpy_ucp(tmplogbuf, buf, 1024); + } + UCP_PRINT_LOG("received buf : %s\n", tmplogbuf); + + return payloadSize; +} + +uint32_t pcie_rx_callback_ctrl(const char* buf,uint32_t payloadSize) +{ + char tmplogbuf[1024] = {0}; + if(payloadSize < 1024) + { + memcpy_ucp(tmplogbuf, buf, payloadSize); + } + else + { + memcpy_ucp(tmplogbuf, buf, 1024); + } + UCP_PRINT_LOG("received buf : %s\n", tmplogbuf); + + return payloadSize; +} + +uint32_t pcie_rx_callback_oam(const char* buf,uint32_t payloadSize) +{ + char tmplogbuf[1024] = {0}; + if(payloadSize < 1024) + { + memcpy_ucp(tmplogbuf, buf, payloadSize); + } + else + { + memcpy_ucp(tmplogbuf, buf, 1024); + } + UCP_PRINT_LOG("received buf : %s\n", tmplogbuf); + + return payloadSize; +} + +void test_case_cfgpar_pcie() +{ + int i = 0; + + for(i = 0; i < MAX_INSTANCE_NUM; i++) + { + msg_transfer_callback_register(CU_SPLIT, i, C_PLANE, pcie_rx_callback_ctrl); + msg_transfer_callback_register(CU_SPLIT, i, U_PLANE, pcie_rx_callback_data); + msg_transfer_callback_register(OAM, i, C_PLANE, pcie_rx_callback_oam); + } +} + +int8_t get_id(uint16_t type_id, uint16_t cu_flag) +{ + int8_t que_id = -1; + + switch (type_id) { + case CU_SPLIT: + if (cu_flag == U_PLANE) { + que_id = UCP4008_TRAFFIC_NR_eMBB_DATA; + } else { + que_id = UCP4008_TRAFFIC_NR_eMBB_CTRL; + } + break; + case OAM: + que_id = UCP4008_TRAFFIC_OAM; + break; + default: + UCP_PRINT_LOG("get_queue_id doesn't support transfer_type[%d] .",type_id); + break; + } + + return que_id; +} + +//static uint32_t count = 0; + +void test_case_sendmsg_pcie() +{ + uint32_t size = 512-16; + char* buf = NULL; + uint32_t availableSize; + + uint16_t cu_flag = C_PLANE; + HandleId_t handler; + handler.port_id = 0; + handler.inst_id = 0; + handler.type_id = CU_SPLIT; + uint32_t slot_ind_flag = 1; + int ret = 0; + + uint32_t offset = 0; + uint32_t i = 0; + char templogbuf[256] = {0}; + + int8_t que_id = 0; + MsgQueueLocalMgt_t* pMsgQueueLocalMgt = get_msg_queue_local_mgt(); + MsgQueueLocalInfo_t* ch; + //uint32_t core_id = get_core_id(); + //uint32_t bufsize = ch->bufSize - MSG_MBUF_HEAD_SIZE; + /****************************test code************************************************/ + for(i = 0; i < MAX_INSTANCE_NUM; i++) + { + //debug_write(DBG_DDR_COMMON_IDX(core_id, 2), ++count); + handler.port_id = 0; + handler.inst_id = i; + handler.type_id = CU_SPLIT; + if(1 == slot_ind_flag) + { + // slot_ind_flag = 0; + ret = msg_transfer_send_start(handler.value); + /************C_PLANE***************/ + cu_flag = C_PLANE; + que_id = get_id(handler.type_id, cu_flag); + ch = (MsgQueueLocalInfo_t *)&pMsgQueueLocalMgt->localUlQueue[i][que_id]; + size = ch->bufSize-MSG_MBUF_HEAD_SIZE; + ret = msg_transfer_alloc_msg(handler.value, cu_flag, size, &buf, &availableSize, &offset); + com_debug_log("alloc ctrl msg ulque[%d][%d] ch=0x%llx ch->bufSize=0x%x\n", i, que_id, (uint64_t)ch, ch->bufSize); + if ( SUCCESS != ret) { + com_debug_log("alloc ctrl msg failed! ulque[%d][%d] ch=0x%llx ch->bufSize=0x%x\n", i, que_id, (uint64_t)ch, ch->bufSize); + continue; + } + //size = availableSize; + //buf = *bufAddr; + UCP_PRINT_LOG("msg transfer alloced ul msg C_PLANE buf = 0x%x!\n", buf); + memset(templogbuf, 0x00, sizeof(templogbuf)); + sprintf(templogbuf, "%s", "this is test for ul CU_SPLIT ctrl transfer!\n"); + memcpy_ucp(buf, templogbuf, strlen(templogbuf)+1); + /* + *(uint32_t*)(ptr + 0) = 0x12345678; + *(uint32_t*)(ptr + 4) = 0x5a5a5a5a; + *(uint32_t*)(ptr + 8) = 0x12345678; + *(uint32_t*)(ptr + 12) = 0xa5a5a5a5; + */ + //PCIE_DEBUG_LOG("start enter msg_transfer_send_msg\n"); + ret = msg_transfer_send_msg(handler.value, cu_flag, (uint8_t *)buf, offset, size); + if(ret != SUCCESS) + { + com_debug_log("ul msg_transfer_send_msg CU_SPLIT ctrl failed! ret = %d inst_id=%d\n", ret, handler.inst_id); + } + + /************U_PLANE***************/ + cu_flag = U_PLANE; + que_id = get_id(handler.type_id, cu_flag); + ch = (MsgQueueLocalInfo_t *)&pMsgQueueLocalMgt->localUlQueue[i][que_id]; + size = ch->bufSize-MSG_MBUF_HEAD_SIZE; + ret = msg_transfer_alloc_msg(handler.value, cu_flag, size, &buf, &availableSize, &offset); + com_debug_log("alloc data msg ulque[%d][%d] ch=0x%llx ch->bufSize=0x%x\n", i, que_id, (uint64_t)ch, ch->bufSize); + + if ( SUCCESS != ret) { + com_debug_log("alloc data msg failed! ulque[%d][%d] ch=0x%llx ch->bufSize=0x%x\n", i, que_id, ch, ch->bufSize); + continue; + } + //size = availableSize; + //buf = *bufAddr; + UCP_PRINT_LOG("msg transfer alloced ul U_PLANE msg buf = 0x%x!\n", buf); + memset(templogbuf, 0x00, sizeof(templogbuf)); + sprintf(templogbuf, "%s", "this is test for ul CU_SPLIT data transfer!\n"); + memcpy_ucp(buf, templogbuf, strlen(templogbuf)+1); + + /* + ptr = (uint8_t *)buf; + *(uint32_t*)(ptr + 0) = 0x12345678; + *(uint32_t*)(ptr + 4) = 0x5a5a5a5a; + *(uint32_t*)(ptr + 8) = 0x12345678; + *(uint32_t*)(ptr + 12) = 0xa5a5a5a5; + */ + ret = msg_transfer_send_msg(handler.value, cu_flag, (uint8_t *)buf, offset, size); + if(ret != SUCCESS) + { + com_debug_log("ul msg_transfer_send_msg CU_SPLIT data failed! ret = %d inst_id = %d\n", ret, handler.inst_id); + } + + ret = msg_transfer_send_end(handler.value); + if(ret != SUCCESS) + { + com_debug_log("ul msg_transfer_send_end CU_SPLIT data failed! ret = %d inst_id = %d\n", ret, handler.inst_id); + } + } + + handler.type_id = OAM; + if(1 == slot_ind_flag) + { + // slot_ind_flag = 0; + + ret = msg_transfer_send_start(handler.value); + + /************C_PLANE***************/ + cu_flag = C_PLANE; + que_id = get_id(handler.type_id, cu_flag); + ch = (MsgQueueLocalInfo_t *)&pMsgQueueLocalMgt->localUlQueue[i][que_id]; + size = ch->bufSize-MSG_MBUF_HEAD_SIZE; + ret = msg_transfer_alloc_msg(handler.value, cu_flag, size, &buf, &availableSize, &offset); + com_debug_log("alloc oam msg ulque[%d][%d] ch=0x%llx ch->bufSize=0x%x\n", i, que_id, (uint64_t)ch, ch->bufSize); + + if ( SUCCESS != ret) { + com_debug_log("oam alloc msg failed! ulque[%d][%d] ch=0x%llx ch->bufSize = 0x%x\n", i, que_id, ch, ch->bufSize); + continue; + } + //size = availableSize; + //buf = *bufAddr; + UCP_PRINT_LOG("msg transfer alloced msg OAM buf = 0x%x!\n", buf); + memset(templogbuf, 0x00, sizeof(templogbuf)); + sprintf(templogbuf, "%s", "this is test for ul OAM ctrl transfer!\n"); + memcpy_ucp(buf, templogbuf, strlen(templogbuf)+1); + + /* + *(uint32_t*)(ptr + 0) = 0x12345678; + *(uint32_t*)(ptr + 4) = 0x5a5a5a5a; + *(uint32_t*)(ptr + 8) = 0x12345678; + *(uint32_t*)(ptr + 12) = 0xa5a5a5a5; + */ + ret = msg_transfer_send_msg(handler.value, cu_flag, (uint8_t *)buf, offset, size); + if(ret != SUCCESS) + { + com_debug_log("ul msg_transfer_send_msg failed! CU_SPLIT oam ! ret = %d inst_id = %d\n", ret, handler.inst_id); + continue; + } + + UCP_PRINT_LOG("msg_transfer_send_msg end!\n"); + ret = msg_transfer_send_end(handler.value); + if(ret != SUCCESS) + { + com_debug_log("ul msg_transfer_send_end CU_SPLIT oam failed! ret = %d inst_id = %d\n", ret, handler.inst_id); + } + } + } + /*********************************************************************************/ + +} + +void test_case_recv_msg_pcie() +{ + uint16_t cu_flag = C_PLANE; + HandleId_t handler; + handler.port_id = 0; + handler.inst_id = 0; + handler.type_id = CU_SPLIT; + + uint8_t port_id = 0; + uint32_t offset = 0; + uint32_t len = 0; + uint8_t* msg_ptr; + uint32_t i = 0; + + /****************************test code************************************************/ + for ( i = 0; i < MAX_INSTANCE_NUM; i++) { + handler.port_id = port_id; + handler.inst_id = i; + handler.type_id = CU_SPLIT; + cu_flag = C_PLANE; + msg_transfer_receive(handler.value, cu_flag, offset, len, &msg_ptr); + + cu_flag = U_PLANE; + msg_transfer_receive(handler.value, cu_flag, offset, len, &msg_ptr); + + handler.type_id = OAM; + msg_transfer_receive(handler.value, cu_flag, offset, len, &msg_ptr); + } + /*********************************************************************************/ +} + +#if 0 + +void test_speed_sendmsg_pcie() +{ + uint32_t size = 0; + char* buf = NULL; + uint32_t availableSize; + + uint16_t cu_flag = C_PLANE; + HandleId_t handler; + handler.port_id = 0; + handler.inst_id = 0; + handler.type_id = CU_SPLIT; + uint32_t slot_ind_flag = 1; + int ret = 0; + + uint32_t offset = 0; + uint32_t i = 0; + char templogbuf[1024] = {0}; + + MsgQueueLocalMgt_t* pMsgQueueLocalMgt = get_msg_queue_local_mgt(); + MsgQueueLocalInfo_t* ch = (MsgQueueLocalInfo_t*)&pMsgQueueLocalMgt->localUlQueue[0][1]; + size = ch->bufSize - MSG_MBUF_HEAD_SIZE; + /****************************test code************************************************/ + for(i = 0; i < 2; i++) + { + handler.port_id = 0; + handler.inst_id = i; + handler.type_id = CU_SPLIT; + if(1 == slot_ind_flag) + { + // slot_ind_flag = 0; + ret = msg_transfer_send_start(handler.value); + + /************C_PLANE***************/ + cu_flag = C_PLANE; + ret = msg_transfer_alloc_msg(handler.value, cu_flag, size, &buf, &availableSize, &offset); + if ( SUCCESS != ret) { + UCP_PRINT_LOG("alloc msg failed!\n"); + continue; + } + //size = availableSize; + //buf = *bufAddr; + UCP_PRINT_LOG("msg transfer alloced ul msg C_PLANE buf = 0x%x!\n", buf); + memset(templogbuf, 0x00, sizeof(templogbuf)); + sprintf(templogbuf, "%s", "this is test for ul CU_SPLIT ctrl transfer!\n"); + memcpy_ucp(buf, templogbuf, strlen(templogbuf)+1); + /* + *(uint32_t*)(ptr + 0) = 0x12345678; + *(uint32_t*)(ptr + 4) = 0x5a5a5a5a; + *(uint32_t*)(ptr + 8) = 0x12345678; + *(uint32_t*)(ptr + 12) = 0xa5a5a5a5; + */ + //PCIE_DEBUG_LOG("start enter msg_transfer_send_msg\n"); + ret = msg_transfer_send_msg(handler.value, cu_flag, (uint8_t *)buf, offset, size); + if(ret != SUCCESS) + { + UCP_PRINT_LOG("ul msg_transfer_send_msg CU_SPLIT ctrl failed! ret = %d\n", ret); + } + + ret = msg_transfer_send_end(handler.value); + } + + } + /*********************************************************************************/ + +} +#endif + +void test_speed_recv_msg_pcie() +{ + uint16_t cu_flag = C_PLANE; + HandleId_t handler; + handler.port_id = 0; + handler.inst_id = 0; + handler.type_id = CU_SPLIT; + + uint8_t port_id = 0; + uint32_t offset = 0; + uint32_t len = 0; + uint8_t* msg_ptr; + uint32_t i = 0; + + /****************************test code************************************************/ + for ( i = 0; i < 2; i++) { + handler.port_id = port_id; + handler.inst_id = i; + handler.type_id = CU_SPLIT; + cu_flag = C_PLANE; + msg_transfer_receive(handler.value, cu_flag, offset, len, &msg_ptr); + + cu_flag = U_PLANE; + msg_transfer_receive(handler.value, cu_flag, offset, len, &msg_ptr); + + handler.type_id = OAM; + msg_transfer_receive(handler.value, cu_flag, offset, len, &msg_ptr); + } + /*********************************************************************************/ +} + + +void pcie_test_task_func(void) +{ + //uint32_t clockTick = 0; + // uint32_t clockOffset = 0; + test_case_sendmsg_pcie(); + //test_speed_recv_msg_pcie(); + //delay_us(50); + + return; +} + +void pcie_test_task_func4(void) +{ + //uint32_t clockTick = 0; + // uint32_t clockOffset = 0; + test_case_sendmsg_pcie(); + //test_speed_recv_msg_pcie(); + //delay_us(50); + + return; +} + + +void ape0_test_task_reg(void) +{ + + //uint32_t core_id = get_core_id(); + // test_case_cfgpar_pcie(); + osp_task_info_ex pcie_timer_task_stc = {50, (int8_t*)"pcie_test_taskc", 50, 4096, OSP_NORMAL_TYPE, 1, 0, 0, NULL, (OSP_TASKENTRY_FUNC)pcie_test_task_func}; + osp_task_create(&pcie_timer_task_stc); + osp_timer_sync(1); + + return; +} + +void ape1_test_task_reg(void) +{ + + return; +} + +void ape2_test_task_reg(void) +{ + return ; +} + +void ape3_test_task_reg(void) +{ + return ; +} + +void ape4_test_task_reg(void) +{ + return ; +} + +void ape5_test_task_reg(void) +{ + return ; +} + +void ape6_test_task_reg(void) +{ + return ; +} + +void ape7_test_task_reg(void) +{ + return ; +} + +