Creating UL_ind RACH handle function in VNF
Also fixed a few bugs in nr-nFAPI: - Push16->push8 fix in packing of RACH - Allocating memory for pdu_list and preamble_list in unpack - Properly indexing through both lists during unpack - Created new nr_rach handling function
This commit is contained in:
+24
-24
@@ -145,32 +145,34 @@ void init_nrUE_standalone_thread(int ue_idx)
|
||||
pthread_setname_np(phy_thread, "oai:nrue-stand-phy");
|
||||
}
|
||||
|
||||
static void L1_nsa_prach_procedures(nfapi_nr_rach_indication_t *rach_ind, frame_t frame, int slot)
|
||||
static void L1_nsa_prach_procedures(frame_t frame, int slot)
|
||||
{
|
||||
rach_ind->sfn = frame;
|
||||
rach_ind->slot = slot;
|
||||
rach_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION;
|
||||
nfapi_nr_rach_indication_t rach_ind;
|
||||
memset(&rach_ind, 0, sizeof(rach_ind));
|
||||
rach_ind.sfn = frame;
|
||||
rach_ind.slot = slot;
|
||||
rach_ind.header.message_id = NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION;
|
||||
|
||||
uint8_t pdu_index = 0;
|
||||
rach_ind->pdu_list = CALLOC(1, sizeof(*rach_ind->pdu_list));
|
||||
rach_ind->number_of_pdus = 1;
|
||||
rach_ind->pdu_list[pdu_index].phy_cell_id = 0;
|
||||
rach_ind->pdu_list[pdu_index].symbol_index = 0;
|
||||
rach_ind->pdu_list[pdu_index].slot_index = slot;
|
||||
rach_ind->pdu_list[pdu_index].freq_index = 1;
|
||||
rach_ind->pdu_list[pdu_index].avg_rssi = 128;
|
||||
rach_ind->pdu_list[pdu_index].avg_snr = 0xff; // invalid for now
|
||||
rach_ind.pdu_list = CALLOC(1, sizeof(*rach_ind.pdu_list));
|
||||
rach_ind.number_of_pdus = 1;
|
||||
rach_ind.pdu_list[pdu_index].phy_cell_id = 0;
|
||||
rach_ind.pdu_list[pdu_index].symbol_index = 0;
|
||||
rach_ind.pdu_list[pdu_index].slot_index = slot;
|
||||
rach_ind.pdu_list[pdu_index].freq_index = 1;
|
||||
rach_ind.pdu_list[pdu_index].avg_rssi = 128;
|
||||
rach_ind.pdu_list[pdu_index].avg_snr = 0xff; // invalid for now
|
||||
|
||||
rach_ind->pdu_list[pdu_index].num_preamble = 1;
|
||||
const int num_p = rach_ind->pdu_list[pdu_index].num_preamble;
|
||||
rach_ind->pdu_list[pdu_index].preamble_list = calloc(num_p, sizeof(nfapi_nr_prach_indication_preamble_t));
|
||||
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_index = 63; //Melissa, need to get this out of rrc_reconfig_msg
|
||||
rach_ind->pdu_list[pdu_index].preamble_list[0].timing_advance = 0;
|
||||
rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_pwr = 0xffffffff;
|
||||
rach_ind.pdu_list[pdu_index].num_preamble = 1;
|
||||
const int num_p = rach_ind.pdu_list[pdu_index].num_preamble;
|
||||
rach_ind.pdu_list[pdu_index].preamble_list = calloc(num_p, sizeof(nfapi_nr_prach_indication_preamble_t));
|
||||
rach_ind.pdu_list[pdu_index].preamble_list[0].preamble_index = 63; //Melissa, need to get this out of rrc_reconfig_msg
|
||||
rach_ind.pdu_list[pdu_index].preamble_list[0].timing_advance = 0;
|
||||
rach_ind.pdu_list[pdu_index].preamble_list[0].preamble_pwr = 0xffffffff;
|
||||
|
||||
send_nsa_standalone_msg(rach_ind);
|
||||
free(rach_ind->pdu_list);
|
||||
//free(rach_ind->pdu_list[pdu_index].preamble_list); Melissa hack maybe
|
||||
send_nsa_standalone_msg(&rach_ind);
|
||||
free(rach_ind.pdu_list[pdu_index].preamble_list);
|
||||
free(rach_ind.pdu_list);
|
||||
}
|
||||
|
||||
static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
|
||||
@@ -224,9 +226,7 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg)
|
||||
|
||||
if (nr_prach == 1)
|
||||
{
|
||||
nfapi_nr_rach_indication_t *ind = CALLOC(1, sizeof(*ind));
|
||||
L1_nsa_prach_procedures(ind, ul_info.frame_tx, ul_info.slot_tx);
|
||||
free(ind);
|
||||
L1_nsa_prach_procedures(ul_info.frame_tx, ul_info.slot_tx);
|
||||
/* Fill rach indication here and send to proxy. Basically take pieces from
|
||||
L1_nr_prach_procedures() and send it to the proxy. prach from ue->gNb->gnb sends rach->ue receives rach
|
||||
The UE is basically filling the rach and proxy will receive and think that it came from the gNB. The
|
||||
|
||||
@@ -286,7 +286,7 @@ void *pnf_p7_thread_start(void *ptr) {
|
||||
}
|
||||
|
||||
void *pnf_nr_p7_thread_start(void *ptr) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "[PNF] P7 THREAD %s\n", __FUNCTION__);
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "[NR_PNF] NR P7 THREAD %s\n", __FUNCTION__);
|
||||
pnf_set_thread_priority(79);
|
||||
nfapi_pnf_p7_config_t *config = (nfapi_pnf_p7_config_t *)ptr;
|
||||
nfapi_nr_pnf_p7_start(config);
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
extern RAN_CONTEXT_t RC;
|
||||
extern UL_RCC_IND_t UL_RCC_INFO;
|
||||
extern NR_UL_IND_t UL_INFO;
|
||||
|
||||
typedef struct {
|
||||
uint8_t enabled;
|
||||
@@ -699,6 +700,32 @@ int phy_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_rach_indicatio
|
||||
return 1;
|
||||
}
|
||||
|
||||
int phy_nr_rach_indication(struct nfapi_vnf_p7_config *config, nfapi_nr_rach_indication_t *ind)
|
||||
{
|
||||
if(NFAPI_MODE == NFAPI_MODE_VNF)
|
||||
{
|
||||
for (int i = 0; i < ind->number_of_pdus; i++) {
|
||||
LOG_I(NR_MAC, "%s() NFAPI SFN:%d/SLOT:%d number_of_preambles:%u\n", __FUNCTION__, ind->sfn, ind->slot, ind->pdu_list[i].num_preamble);
|
||||
|
||||
UL_INFO.rach_ind = *ind;
|
||||
|
||||
const int num_p = ind->pdu_list[i].num_preamble;
|
||||
if (num_p > 0)
|
||||
{
|
||||
UL_INFO.rach_ind.pdu_list[i].preamble_list = calloc(num_p, sizeof(nfapi_nr_prach_indication_preamble_t));
|
||||
for (int j = 0; j < num_p; j++)
|
||||
{
|
||||
UL_INFO.rach_ind.pdu_list[i].preamble_list[j] = ind->pdu_list[i].preamble_list[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
LOG_E(NR_MAC, "NFAPI_MODE = %d not NFAPI_MODE_VNF(2)\n", nfapi_getmode());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int phy_harq_indication(struct nfapi_vnf_p7_config *config, nfapi_harq_indication_t *ind) {
|
||||
struct PHY_VARS_eNB_s *eNB = RC.eNB[0][0];
|
||||
LOG_D(MAC, "%s() NFAPI SFN/SF:%d number_of_harqs:%u\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind->sfn_sf), ind->harq_indication_body.number_of_harqs);
|
||||
@@ -1147,11 +1174,10 @@ void *vnf_nr_p7_thread_start(void *ptr) {
|
||||
p7_vnf->config->port = p7_vnf->local_port;
|
||||
p7_vnf->config->sync_indication = &phy_sync_indication;
|
||||
p7_vnf->config->slot_indication = &phy_slot_indication;
|
||||
|
||||
p7_vnf->config->harq_indication = &phy_harq_indication;
|
||||
p7_vnf->config->crc_indication = &phy_crc_indication;
|
||||
p7_vnf->config->rx_indication = &phy_rx_indication;
|
||||
p7_vnf->config->rach_indication = &phy_rach_indication;
|
||||
p7_vnf->config->nr_rach_indication = &phy_nr_rach_indication;
|
||||
p7_vnf->config->srs_indication = &phy_srs_indication;
|
||||
p7_vnf->config->sr_indication = &phy_sr_indication;
|
||||
p7_vnf->config->cqi_indication = &phy_cqi_indication;
|
||||
@@ -1532,6 +1558,7 @@ void configure_nr_nfapi_vnf(char *vnf_addr, int vnf_p5_port) {
|
||||
config->codec_config.allocate = &vnf_allocate;
|
||||
config->codec_config.deallocate = &vnf_deallocate;
|
||||
memset(&UL_RCC_INFO,0,sizeof(UL_RCC_IND_t));
|
||||
memset(&UL_INFO, 0, sizeof(NR_UL_IND_t));
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Creating VNF NFAPI start thread %s\n", __FUNCTION__);
|
||||
pthread_create(&vnf_start_pthread, NULL, (void *)&vnf_nr_start_thread, config);
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "[VNF] Created VNF NFAPI start thread %s\n", __FUNCTION__);
|
||||
|
||||
@@ -3522,7 +3522,7 @@ static uint8_t pack_nr_rach_indication(void *msg, uint8_t **ppWritePackedMsg, ui
|
||||
|
||||
if (!(push16(pNfapiMsg->sfn , ppWritePackedMsg, end) &&
|
||||
push16(pNfapiMsg->slot , ppWritePackedMsg, end) &&
|
||||
push16(pNfapiMsg->number_of_pdus, ppWritePackedMsg, end)
|
||||
push8(pNfapiMsg->number_of_pdus, ppWritePackedMsg, end)
|
||||
))
|
||||
return 0;
|
||||
|
||||
@@ -6502,9 +6502,11 @@ return 1;
|
||||
|
||||
//NR RACH
|
||||
|
||||
static uint8_t unpack_nr_rach_indication_body(void* tlv, uint8_t **ppReadPackedMsg, uint8_t *end)
|
||||
static uint8_t unpack_nr_rach_indication_body(nfapi_nr_prach_indication_pdu_t* value,
|
||||
uint8_t **ppReadPackedMsg,
|
||||
uint8_t *end,
|
||||
nfapi_p7_codec_config_t* config)
|
||||
{
|
||||
nfapi_nr_prach_indication_pdu_t* value = (nfapi_nr_prach_indication_pdu_t*)tlv;
|
||||
|
||||
if(!(pull16(ppReadPackedMsg, &value->phy_cell_id, end) &&
|
||||
pull8(ppReadPackedMsg, &value->symbol_index, end) &&
|
||||
@@ -6515,14 +6517,18 @@ static uint8_t unpack_nr_rach_indication_body(void* tlv, uint8_t **ppReadPackedM
|
||||
pull8(ppReadPackedMsg, &value->num_preamble, end)
|
||||
))
|
||||
return 0;
|
||||
for(int i = 0; i < value->num_preamble; i++)
|
||||
{
|
||||
if(!(pull8(ppReadPackedMsg, &value->preamble_list->preamble_index, end) &&
|
||||
pull16(ppReadPackedMsg, &value->preamble_list->timing_advance, end) &&
|
||||
pull32(ppReadPackedMsg, &value->preamble_list->preamble_pwr, end)
|
||||
))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (value->num_preamble > 0) {
|
||||
value->preamble_list = nfapi_p7_allocate(sizeof(*value->preamble_list) * value->num_preamble, config);
|
||||
for(int i = 0; i < value->num_preamble; i++)
|
||||
{
|
||||
if(!(pull8(ppReadPackedMsg, &value->preamble_list[i].preamble_index, end) &&
|
||||
pull16(ppReadPackedMsg, &value->preamble_list[i].timing_advance, end) &&
|
||||
pull32(ppReadPackedMsg, &value->preamble_list[i].preamble_pwr, end)
|
||||
))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -6533,15 +6539,17 @@ static uint8_t unpack_nr_rach_indication(uint8_t **ppReadPackedMsg, uint8_t *end
|
||||
pull16(ppReadPackedMsg, &pNfapiMsg->slot , end) &&
|
||||
pull8(ppReadPackedMsg, &pNfapiMsg->number_of_pdus, end)
|
||||
))
|
||||
return 0;
|
||||
|
||||
for(int i=0; i< pNfapiMsg->number_of_pdus;i++)
|
||||
{
|
||||
if(!unpack_nr_rach_indication_body(&pNfapiMsg->pdu_list,ppReadPackedMsg,end))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
if (pNfapiMsg->number_of_pdus > 0) {
|
||||
pNfapiMsg->pdu_list = nfapi_p7_allocate(sizeof(*pNfapiMsg->pdu_list) * pNfapiMsg->number_of_pdus, config);
|
||||
for(int i = 0; i < pNfapiMsg->number_of_pdus; i++)
|
||||
{
|
||||
if(!unpack_nr_rach_indication_body(&pNfapiMsg->pdu_list[i], ppReadPackedMsg, end, config))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//NR UCI
|
||||
|
||||
@@ -760,6 +760,20 @@ typedef struct nfapi_vnf_p7_config
|
||||
*/
|
||||
int (*rach_indication)(struct nfapi_vnf_p7_config* config, nfapi_rach_indication_t* ind);
|
||||
|
||||
/*! A callback for the RACH.indication
|
||||
* \param config A pointer to the vnf p7 configuration
|
||||
* \param ind A data structure for the decoded nrRACH.indication This will
|
||||
* have been allocated on the stack.
|
||||
* \return not currently used.
|
||||
*
|
||||
* The ind may contain pointers to dyanmically allocated sub structures
|
||||
* such as the pdu. The dyanmically allocated structure will
|
||||
* be deallocated on return. If the client wishes to 'keep' the structures
|
||||
* then the substructure pointers should be set to 0 and then the client should
|
||||
* use the codec_config.deallocate function to release it at a future point
|
||||
*/
|
||||
int (*nr_rach_indication)(struct nfapi_vnf_p7_config* config, nfapi_nr_rach_indication_t* ind);
|
||||
|
||||
/*! A callback for the SRS.indication
|
||||
* \param config A pointer to the vnf p7 configuration
|
||||
* \param ind A data structure for the decoded SRS.indication This will
|
||||
|
||||
@@ -1547,14 +1547,22 @@ void vnf_handle_nr_rach_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Melissa %s: HANDLING RACH IND\n", __FUNCTION__);
|
||||
nfapi_nr_rach_indication_t ind;
|
||||
|
||||
if(nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, &ind, sizeof(ind), &vnf_p7->_public.codec_config) < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s: Failed to unpack message\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s: Handling RACH Indication\n", __FUNCTION__);
|
||||
if(vnf_p7->_public.nr_rach_indication)
|
||||
{
|
||||
(vnf_p7->_public.nr_rach_indication)(&vnf_p7->_public, &ind);
|
||||
}
|
||||
}
|
||||
//vnf_p7_codec_free(vnf_p7, ind.nr_rach_indication_body.preamble_list); Melissa do we need to do this?
|
||||
//vnf_p7_codec_free(vnf_p7, ind.vendor_extension);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "PHY/types.h"
|
||||
#include "PHY/defs_eNB.h"
|
||||
#include "PHY/defs_gNB.h"
|
||||
#include "PHY/defs_UE.h"
|
||||
#include "common/ran_context.h"
|
||||
|
||||
@@ -45,6 +46,7 @@ int16_t *primary_synch2_time;
|
||||
PHY_VARS_UE ***PHY_vars_UE_g;
|
||||
RAN_CONTEXT_t RC;
|
||||
UL_RCC_IND_t UL_RCC_INFO;
|
||||
NR_UL_IND_t UL_INFO;
|
||||
|
||||
unsigned short rev[2048],rev_times4[8192],rev_half[1024];
|
||||
unsigned short rev256[256],rev512[512],rev1024[1024],rev4096[4096],rev2048[2048],rev8192[8192];
|
||||
|
||||
@@ -52,26 +52,28 @@ extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind);
|
||||
extern uint8_t nfapi_mode;
|
||||
extern uint16_t sf_ahead;
|
||||
extern uint16_t sl_ahead;
|
||||
extern NR_UL_IND_t UL_INFO;
|
||||
|
||||
void handle_nr_rach(NR_UL_IND_t *UL_info) {
|
||||
|
||||
if (UL_info->rach_ind.number_of_pdus>0) {
|
||||
LOG_I(MAC,"Melissa UL_info[Frame %d, Slot %d] Calling initiate_ra_proc RACH:SFN/SLOT:%d/%d\n",UL_info->frame,UL_info->slot, UL_info->rach_ind.sfn,UL_info->rach_ind.slot);
|
||||
int npdus = UL_info->rach_ind.number_of_pdus;
|
||||
if (UL_INFO.rach_ind.number_of_pdus>0) {
|
||||
LOG_I(MAC,"Melissa UL_INFO[Frame %d, Slot %d] Calling initiate_ra_proc RACH:SFN/SLOT:%d/%d\n",
|
||||
UL_INFO.frame,UL_INFO.slot, UL_INFO.rach_ind.sfn,UL_INFO.rach_ind.slot);
|
||||
int npdus = UL_INFO.rach_ind.number_of_pdus;
|
||||
for(int i = 0; i < npdus; i++) {
|
||||
UL_info->rach_ind.number_of_pdus--;
|
||||
if (UL_info->rach_ind.pdu_list[i].num_preamble>0)
|
||||
AssertFatal(UL_info->rach_ind.pdu_list[i].num_preamble==1,
|
||||
UL_INFO.rach_ind.number_of_pdus--;
|
||||
if (UL_INFO.rach_ind.pdu_list[i].num_preamble>0)
|
||||
AssertFatal(UL_INFO.rach_ind.pdu_list[i].num_preamble==1,
|
||||
"More than 1 preamble not supported\n");
|
||||
|
||||
nr_initiate_ra_proc(UL_info->module_id,
|
||||
UL_info->CC_id,
|
||||
UL_info->rach_ind.sfn,
|
||||
UL_info->rach_ind.slot,
|
||||
UL_info->rach_ind.pdu_list[i].preamble_list[0].preamble_index,
|
||||
UL_info->rach_ind.pdu_list[i].freq_index,
|
||||
UL_info->rach_ind.pdu_list[i].symbol_index,
|
||||
UL_info->rach_ind.pdu_list[i].preamble_list[0].timing_advance);
|
||||
nr_initiate_ra_proc(UL_INFO.module_id,
|
||||
UL_INFO.CC_id,
|
||||
UL_INFO.rach_ind.sfn,
|
||||
UL_INFO.rach_ind.slot,
|
||||
UL_INFO.rach_ind.pdu_list[i].preamble_list[0].preamble_index,
|
||||
UL_INFO.rach_ind.pdu_list[i].freq_index,
|
||||
UL_INFO.rach_ind.pdu_list[i].symbol_index,
|
||||
UL_INFO.rach_ind.pdu_list[i].preamble_list[0].timing_advance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,8 +131,14 @@ void send_nsa_standalone_msg(nfapi_nr_rach_indication_t *rach_ind)
|
||||
{
|
||||
char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE];
|
||||
int encoded_size = nfapi_nr_p7_message_pack(rach_ind, buffer, sizeof(buffer), NULL);
|
||||
LOG_I(NR_MAC, "NR_RACH_IND sent to Proxy, Size: %d Frame %d Subframe %d\n", encoded_size,
|
||||
rach_ind->sfn, rach_ind->slot);
|
||||
if (encoded_size <= 0)
|
||||
{
|
||||
LOG_E(NR_MAC, "nfapi_nr_p7_message_pack has failed. Encoded size = %d\n", encoded_size);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_I(NR_MAC, "NR_RACH_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size,
|
||||
rach_ind->sfn, rach_ind->slot, rach_ind->number_of_pdus);
|
||||
if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0)
|
||||
{
|
||||
LOG_E(NR_MAC, "Send Proxy NR_UE failed\n");
|
||||
|
||||
Reference in New Issue
Block a user