Skip to content

Commit

Permalink
[Epic-Id: ODUHIGH-576][Task-Id: ODUHIGH-600][SubTask-Id: ODUHIGH-601]…
Browse files Browse the repository at this point in the history
…|[NFAPI_Branch]| PHY PARAM.Request

Change-Id: I99bf857cec59c3bbcadbf5b59db23be51d641c9f
Signed-off-by: pborla <[email protected]>
  • Loading branch information
pborla committed May 22, 2024
1 parent 75cc4af commit f9428be
Show file tree
Hide file tree
Showing 7 changed files with 384 additions and 242 deletions.
24 changes: 24 additions & 0 deletions src/5gnrmac/lwr_mac_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
#include "lwr_mac_phy.h"
#include "lwr_mac_utils.h"
#include "mac_utils.h"
#ifdef NFAPI_ENABLED
#include "nfapi_interface.h"
#include "lwr_mac_sctp_inf.h"
#include "nfapi_common.h"
#endif

#define MIB_SFN_BITMASK 0xFC
#define PDCCH_PDU_TYPE 0
Expand Down Expand Up @@ -1329,6 +1333,25 @@ void setMibPdu(uint8_t *mibPdu, uint32_t *val, uint16_t sfn)

uint8_t lwr_mac_procParamReqEvt(void *msg)
{

#ifdef NFAPI_ENABLED

Buffer *mBuf = NULLP;
Pst pst;

DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : NFAPI P5 PARAM_REQ\n");
if (ODU_GET_MSG_BUF(MAC_MEM_REGION, MAC_POOL, &mBuf) != ROK)
{
DU_LOG("\nERROR --> NFAPI_VNF : Memory allocation failed in packPnfParamReq");
return RFAILED;
}
nfapiFillP5Hdr(mBuf);
nfapiFillMsgHdr(mBuf, NFAPI_P5_PHY_ID, FAPI_PARAM_REQUEST, 0);

FILL_PST_LWR_MAC_TO_DUAPP(pst, EVENT_PNF_DATA);
return ODU_POST_TASK(&pst, mBuf);

#else
#ifdef INTEL_FAPI
#ifdef CALL_FLOW_DEBUG_LOG
DU_LOG("\nCall Flow: ENTMAC -> ENTLWRMAC : PARAM_REQ\n");
Expand Down Expand Up @@ -1371,6 +1394,7 @@ uint8_t lwr_mac_procParamReqEvt(void *msg)
DU_LOG("\nERROR --> LWR_MAC: Failed to allocate memory for Param Request");
return RFAILED;
}
#endif
#endif
return ROK;
}
Expand Down
2 changes: 2 additions & 0 deletions src/5gnrmac/nfapi_vnf_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "lwr_mac_utils.h"
#include "lwr_mac_sctp_inf.h"
#include "mac_utils.h"
#include "lwr_mac_fsm.h"

/*******************************************************************
*
Expand Down Expand Up @@ -332,6 +333,7 @@ uint8_t nfapi_vnf_procPnfStartRespEvt(nFapi_p5_hdr *p5Hdr, nFapi_msg_header *msg
{
vnfDb.pnfToReconfigure = false;
}
sendEventToLowerMacFsm(PARAM_REQUEST, 0, NULL);
}
else
{
Expand Down
246 changes: 6 additions & 240 deletions src/pnf_stub/pnf_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
/* This functions contains main() for pnf simulator */
#include "common_def.h"
#include <unistd.h>
#include "nfapi_interface.h"
#include "pnf_stub_sctp.h"
#include "pnf_stub.h"
#include "nfapi_interface.h"
#include "pnf_stub_p5_msg_hdl.h"


PnfGlobalCb pnfCb;

Expand Down Expand Up @@ -259,243 +261,7 @@ void nFapiExtractMsgHdr(nFapi_msg_header *msgHdr, Buffer *mBuf)
return;
}

/*********************************************************************************
*
* @Function Name: buildAndSendPnfReadyInd
*
*
* @Functionality:
* Builds and Sends PNF_READY_IND(Ref: SCF 225, Sec 3.1.0)
*
*
* *******************************************************************************/
uint8_t buildAndSendPnfReadyInd()
{
uint8_t ret = ROK;
Buffer *mBuf = NULLP;

if (ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK)
{
DU_LOG("\nERROR --> NFAPI_PNF : Memory allocation failed in pnf_readyInd");
return RFAILED;
}
nfapiFillP5Hdr(mBuf);
nfapiFillMsgHdr(mBuf, 0, TAG_NFAPI_PNF_READY_IND, 0);
CMCHKPK(oduPackPostUInt32, 123, mBuf); //version
ret = pnfP5SctpSend(mBuf);
if(ret == RFAILED)
{
ODU_PUT_MSG_BUF(mBuf);
}
return ret;
}

/*********************************************************************************
*
* @Function Name: buildAndSendPnfParamResp
*
* @Functionality:
* Build Pnf Param rsp as per 5G nFAPI Specification 3.1.2 PNF_PARAM.response
* And Send to VNF
*
* *******************************************************************************/

uint8_t buildAndSendPnfParamResp()
{
uint8_t ret = ROK,idx=0, array_size=0;
Buffer *mBuf = NULLP;
nFapi_pnf_param_general paramGeneral;

memset(&paramGeneral, 0, sizeof(nFapi_pnf_param_general));
array_size = sizeof(paramGeneral.loc_coordinates) / sizeof(paramGeneral.loc_coordinates[0]);
paramGeneral.max_num_phy=1;

if (ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK)
{
DU_LOG("\nERROR --> NFAPI_PNF : Memory allocation failed in pnf_readyInd");
return RFAILED;
}
nfapiFillP5Hdr(mBuf);
nfapiFillMsgHdr(mBuf, 0, TAG_NFAPI_PNF_PARAM_RESP, 0);
CMCHKPK(oduPackPostUInt8, 0, mBuf);
CMCHKPK(oduPackPostUInt8, 1, mBuf);
CMCHKPK(oduPackPostUInt16, TAG_NFAPI_PNF_PARAM_GENERAL, mBuf);
CMCHKPK(oduPackPostUInt16, sizeof(nFapi_pnf_param_general), mBuf);
CMCHKPK(oduPackPostUInt8, paramGeneral.nFapi_sync_mode, mBuf);
CMCHKPK(oduPackPostUInt8, paramGeneral.loc_mode, mBuf);
CMCHKPK(oduPackPostUInt16, paramGeneral.max_num_phy, mBuf);
for(idx =0; idx < 3; idx++)
{
CMCHKPK(oduPackPostUInt8, paramGeneral.oui[idx], mBuf);
}
CMCHKPK(oduPackPostUInt16, paramGeneral.numRfInstances, mBuf);
CMCHKPK(oduPackPostUInt16, paramGeneral.numDfeInstances, mBuf);

ret = pnfP5SctpSend(mBuf);
if(ret == RFAILED)
{
ODU_PUT_MSG_BUF(mBuf);
}
return ret;
}

/*********************************************************************************
*
* @Function Name: buildAndSendPnfConfigResp
*
*
* @Functionality:
* Builds and Sends PNF_CONFIG_RSP(Ref: SCF 225, Sec 3.1.4)
*
*
* *******************************************************************************/
uint8_t buildAndSendPnfConfigResp()
{
uint8_t ret = ROK;
Buffer *mBuf = NULLP;

DU_LOG("\nINFO --> NFAPI_PNF: Building PNF_CONFIG_RSP");
pnfCb.pnfCfgParams.pnfState=PNF_CONFIGURED;

if(ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK)
{
DU_LOG("\nERROR --> NFAPI_PNF : Memory allocation failed in pnf config rsp");
return RFAILED;
}
nfapiFillP5Hdr(mBuf);
nfapiFillMsgHdr(mBuf, 0, TAG_NFAPI_PNF_CONFIG_RESP, 0);
CMCHKPK(oduPackPostUInt32, 0, mBuf); //Error Code
ret = pnfP5SctpSend(mBuf);
if(ret == RFAILED)
{
ODU_PUT_MSG_BUF(mBuf);
}
return ret;
}

/*********************************************************************************
*
* @Function Name: buildAndSendPnfStartResp
*
*
* @Functionality:
* Builds and Sends PNF_START_RSP(Ref: SCF 225, Sec 3.1.6)
*
*
* *******************************************************************************/
uint8_t buildAndSendPnfStartResp()
{
uint8_t ret = ROK;
Buffer *mBuf = NULLP;

DU_LOG("\nINFO --> NFAPI_PNF: Building PNF_START_RSP");
pnfCb.pnfCfgParams.pnfState=PNF_RUNNING;

if(ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK)
{
DU_LOG("\nERROR --> NFAPI_PNF : Memory allocation failed in pnf start rsp");
return RFAILED;
}
nfapiFillP5Hdr(mBuf);
nfapiFillMsgHdr(mBuf, 0, TAG_NFAPI_PNF_START_RESP, 0);
CMCHKPK(oduPackPostUInt32, 0, mBuf); //Error Code
ret = pnfP5SctpSend(mBuf);
if(ret == RFAILED)
{
ODU_PUT_MSG_BUF(mBuf);
}
return ret;
}
/**********************************************************************
End of file
**********************************************************************/

/*********************************************************************************
*
* @Function Name: buildAndSendPnfStopResp
*
*
* @Functionality:
* Builds and Sends PNF_STOP_RSP(Ref: SCF 225, Sec 3.1.8)
*
*
* *******************************************************************************/
uint8_t buildAndSendPnfStopResp()
{
uint8_t ret = ROK;
Buffer *mBuf = NULLP;

DU_LOG("\nINFO --> NFAPI_PNF: Building PNF_STOP_RSP");
pnfCb.pnfCfgParams.pnfState=PNF_CONFIGURED;

if(ODU_GET_MSG_BUF(PNF_APP_MEM_REG, PNF_POOL, &mBuf) != ROK)
{
DU_LOG("\nERROR --> NFAPI_PNF : Memory allocation failed in pnf stop rsp");
return RFAILED;
}
nfapiFillP5Hdr(mBuf);
nfapiFillMsgHdr(mBuf, 0, TAG_NFAPI_PNF_STOP_RESP, 0);
CMCHKPK(oduPackPostUInt32, 0, mBuf); //Error Code
ret = pnfP5SctpSend(mBuf);
if(ret == RFAILED)
{
ODU_PUT_MSG_BUF(mBuf);
}
return ret;
}

/*********************************************************************************
*
* @Function Name: p5MsgHandlerAtPnf
*
*
* @Functionality:
* Handles the P5 MEssages at PNF SIM
*
* @Params [IN]: Message Buffer received at SCTP NFAPI P5 Interface
*
* *******************************************************************************/
uint8_t p5MsgHandlerAtPnf(Buffer *mBuf)
{
nFapi_p5_hdr p5Hdr;
nFapi_msg_header msgHdr;
uint8_t ret = ROK;

nFapiExtractP5Hdr(&p5Hdr, mBuf);
nFapiExtractMsgHdr(&msgHdr, mBuf);

switch(msgHdr.msg_id)
{
case TAG_NFAPI_PNF_PARAM_REQ:
{
DU_LOG("\nINFO --> NFAPI_PNF: PNF_PARAM_REQ recevied.");
ret = buildAndSendPnfParamResp();
break;
}
case TAG_NFAPI_PNF_CONFIG_REQ:
{
DU_LOG("\nINFO --> NFAPI_PNF: PNF_CONFIG_REQ recevied.");
ret = buildAndSendPnfConfigResp();
break;
}
case TAG_NFAPI_PNF_START_REQ:
{
DU_LOG("\nINFO --> NFAPI_PNF: PNF_START_REQ recevied.");
ret = buildAndSendPnfStartResp();
break;
}
case TAG_NFAPI_PNF_STOP_REQ:
{
DU_LOG("\nINFO --> NFAPI_PNF: PNF_STOP_REQ recevied.");
ret = buildAndSendPnfStopResp();
break;
}
default:
{
DU_LOG("\nERROR --> NFAPI_PNF: Wrong MSGID of NFAPI P5 Message:%d",msgHdr.msg_id);
}
}

if(ret == RFAILED)
{
return RFAILED;
}
return ret;
}
6 changes: 4 additions & 2 deletions src/pnf_stub/pnf_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ typedef struct pnfGlobalCb
}PnfGlobalCb;

extern PnfGlobalCb pnfCb;
uint8_t buildAndSendPnfReadyInd();
uint8_t buildAndSendPnfConfigRsp();
uint8_t p5MsgHandlerAtPnf(Buffer *mBuf);
void nfapiFillP5Hdr(Buffer *mBuf);
void nfapiFillMsgHdr(Buffer *mBuf, uint8_t phyId, uint16_t msgId, uint32_t msgLen);
void nFapiExtractP5Hdr(nFapi_p5_hdr *p5Hdr, Buffer *mBuf);
void nFapiExtractMsgHdr(nFapi_msg_header *msgHdr, Buffer *mBuf);
#endif
Loading

0 comments on commit f9428be

Please sign in to comment.