Handle tx_data.request efficiently
Avoid delays in tx_data.request handling by avoiding big malloc()s and copy operations. Reimplement function to (1) peek the frame/slot numbers, (2) decide on buffer, and (3) unpack directly into pre-allocated memory. Co-authored-by: hsum <ming-hong.hsu@eurecom.fr> Co-authored-by: chenyi <Yi-Quan.Chen@eurecom.fr> Co-authored-by: Rúben Soares Silva <rsilva@allbesmart.pt>
This commit is contained in:
co-authored by
hsum
chenyi
Rúben Soares Silva
parent
8da4e92189
commit
10beee4fd6
@@ -577,7 +577,7 @@ typedef struct
|
||||
nfapi_nr_dl_tti_request_t* dl_tti_req;//nfapi_dl_config_request_t* dl_config_req;
|
||||
nfapi_nr_ul_tti_request_t* ul_tti_req;//nfapi_ul_config_request_t* ul_config_req;
|
||||
nfapi_nr_ul_dci_request_t* ul_dci_req;//nfapi_hi_dci0_request_t* hi_dci0_req;
|
||||
nfapi_nr_tx_data_request_t* tx_data_req;//nfapi_tx_request_t* tx_req;
|
||||
nfapi_nr_tx_data_request_t tx_data_req;
|
||||
|
||||
//TODO: check these two later
|
||||
//nfapi_lbt_dl_config_request_t* lbt_dl_config_req;
|
||||
|
||||
@@ -273,32 +273,11 @@ void deallocate_nfapi_hi_dci0_request(nfapi_hi_dci0_request_t* req, pnf_p7_t* pn
|
||||
pnf_p7_free(pnf_p7, req);
|
||||
}
|
||||
|
||||
nfapi_nr_tx_data_request_t* allocate_nfapi_tx_data_request(pnf_p7_t* pnf_p7)
|
||||
{
|
||||
return pnf_p7_malloc(pnf_p7, sizeof(nfapi_nr_tx_data_request_t));
|
||||
}
|
||||
|
||||
nfapi_tx_request_t* allocate_nfapi_tx_request(pnf_p7_t* pnf_p7)
|
||||
{
|
||||
return pnf_p7_malloc(pnf_p7, sizeof(nfapi_tx_request_t));
|
||||
}
|
||||
|
||||
//TODO: Check if deallocate_nfapi_tx_data_request defn is proper
|
||||
void deallocate_nfapi_tx_data_request(nfapi_nr_tx_data_request_t* req, pnf_p7_t* pnf_p7)
|
||||
{
|
||||
/*
|
||||
if(pnf_p7->_public.codec_config.deallocate)
|
||||
{
|
||||
(pnf_p7->_public.codec_config.deallocate)(req->pdu_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
free(req->pdu_list);
|
||||
}
|
||||
*/
|
||||
pnf_p7_free(pnf_p7, req);
|
||||
}
|
||||
|
||||
void deallocate_nfapi_tx_request(nfapi_tx_request_t* req, pnf_p7_t* pnf_p7)
|
||||
{
|
||||
int i = 0;
|
||||
@@ -931,13 +910,12 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl
|
||||
(pnf_p7->_public.ul_tti_req_fn)(NULL, &(pnf_p7->_public), tx_slot_buffer->ul_tti_req);
|
||||
}
|
||||
|
||||
if(tx_slot_buffer->tx_data_req != 0 && tx_slot_buffer->tx_data_req->SFN == sfn_tx && tx_slot_buffer->tx_data_req->Slot == slot_tx)
|
||||
if(tx_slot_buffer->tx_data_req.Number_of_PDUs > 0 && tx_slot_buffer->tx_data_req.SFN == sfn_tx && tx_slot_buffer->tx_data_req.Slot == slot_tx)
|
||||
{
|
||||
|
||||
DevAssert(pnf_p7->_public.tx_data_req_fn != NULL);
|
||||
LOG_D(PHY, "Process tx_data SFN/slot %d.%d buffer index: %d \n",sfn_tx,slot_tx,buffer_index_tx);
|
||||
// pnf_phy_tx_data_req()
|
||||
(pnf_p7->_public.tx_data_req_fn)(&(pnf_p7->_public), tx_slot_buffer->tx_data_req);
|
||||
(pnf_p7->_public.tx_data_req_fn)(&(pnf_p7->_public), &tx_slot_buffer->tx_data_req);
|
||||
tx_slot_buffer->tx_data_req.SFN = -1;
|
||||
tx_slot_buffer->tx_data_req.Slot = - 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -958,12 +936,6 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl
|
||||
LOG_D(PHY,"SFN/slot %d.%d Buffer index : %d freed \n",sfn_tx,slot_tx,buffer_index_tx);
|
||||
}
|
||||
|
||||
if(tx_slot_buffer->tx_data_req != 0)
|
||||
{
|
||||
//deallocate_nfapi_tx_data_request(tx_slot_buffer->tx_data_req, pnf_p7);
|
||||
tx_slot_buffer->tx_data_req = 0;
|
||||
}
|
||||
|
||||
if(tx_slot_buffer->ul_dci_req != 0)
|
||||
{
|
||||
deallocate_nfapi_ul_dci_request(tx_slot_buffer->ul_dci_req, pnf_p7);
|
||||
@@ -983,7 +955,6 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl
|
||||
//reset slot buffer
|
||||
|
||||
if ( rx_slot_buffer->dl_tti_req == 0 &&
|
||||
rx_slot_buffer->tx_data_req == 0 &&
|
||||
rx_slot_buffer->ul_tti_req == 0)
|
||||
{
|
||||
pnf_p7->slot_buffer[buffer_index_rx].sfn = -1;
|
||||
@@ -1856,87 +1827,54 @@ void pnf_handle_hi_dci0_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void pnf_handle_tx_data_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7)
|
||||
{
|
||||
//NFAPI_TRACE(NFAPI_TRACE_INFO, "TX.req Received\n");
|
||||
|
||||
nfapi_nr_tx_data_request_t* req = allocate_nfapi_tx_data_request(pnf_p7);
|
||||
uint16_t frame, slot;
|
||||
if (peek_nr_nfapi_p7_sfn_slot(pRecvMsg, recvMsgLen, &frame, &slot)) {
|
||||
if (pthread_mutex_lock(&(pnf_p7->mutex)) != 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n");
|
||||
return;
|
||||
}
|
||||
if (check_nr_nfapi_p7_slot_type(frame, slot, "TX_DATA.REQUEST", NR_DOWNLINK_SLOT)
|
||||
&& is_nr_p7_request_in_window(frame, slot, "tx_request", pnf_p7)) {
|
||||
uint32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(frame, slot);
|
||||
uint8_t buffer_index = sfn_slot_dec % 20;
|
||||
pnf_p7->slot_buffer[buffer_index].sfn = frame;
|
||||
pnf_p7->slot_buffer[buffer_index].slot = slot;
|
||||
nfapi_nr_tx_data_request_t *req = &pnf_p7->slot_buffer[buffer_index].tx_data_req;
|
||||
pnf_p7->stats.tx_data_ontime++;
|
||||
|
||||
if(req == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to allocate nfapi_tx_request structure\n");
|
||||
return;
|
||||
}
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG,
|
||||
"POPULATE TX_data.request current tx sfn/slot:%d.%d p7 msg sfn/slot: %d.%d buffer_index:%d\n",
|
||||
pnf_p7->sfn,
|
||||
pnf_p7->slot,
|
||||
frame,
|
||||
slot,
|
||||
buffer_index);
|
||||
|
||||
int unpack_result = nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(nfapi_nr_tx_data_request_t), &pnf_p7->_public.codec_config);
|
||||
if(unpack_result == 0)
|
||||
{
|
||||
if(pthread_mutex_lock(&(pnf_p7->mutex)) != 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to lock mutex\n");
|
||||
return;
|
||||
}
|
||||
if (nfapi_nr_p7_message_unpack(pRecvMsg, recvMsgLen, req, sizeof(*req), &pnf_p7->_public.codec_config) != 0)
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "failed to unpack TX_data.request\n");
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO,
|
||||
"%s() TX_DATA_REQUEST Request is outside of window REQ:SFN_SLOT:%d CURR:SFN_SLOT:%d\n",
|
||||
__FUNCTION__,
|
||||
NFAPI_SFNSLOT2DEC(frame, slot),
|
||||
NFAPI_SFNSLOT2DEC(pnf_p7->sfn, pnf_p7->slot));
|
||||
|
||||
if(is_nr_p7_request_in_window(req->SFN, req->Slot,"tx_request", pnf_p7))
|
||||
{
|
||||
uint32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(req->SFN,req->Slot);
|
||||
uint8_t buffer_index = sfn_slot_dec % 20;
|
||||
if (pnf_p7->_public.timing_info_mode_aperiodic) {
|
||||
pnf_p7->timing_info_aperiodic_send = 1;
|
||||
}
|
||||
|
||||
struct timespec t;
|
||||
clock_gettime(CLOCK_MONOTONIC, &t);
|
||||
pnf_p7->stats.tx_data_late++;
|
||||
}
|
||||
|
||||
//NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() %ld.%09ld POPULATE TX_DATA_REQ sfn_sf:%d buffer_index:%d\n", __FUNCTION__, t.tv_sec, t.tv_nsec, sfn_slot_dec, buffer_index);
|
||||
#if 0
|
||||
if (0 && NFAPI_SFNSF2DEC(req->sfn_sf)%100==0) NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX_REQ.req sfn_sf:%d pdus:%d - TX_REQ is within window\n",
|
||||
__FUNCTION__,
|
||||
NFAPI_SFNSF2DEC(req->sfn_sf),
|
||||
req->tx_request_body.number_of_pdus);
|
||||
#endif
|
||||
|
||||
if(pnf_p7->slot_buffer[buffer_index].tx_data_req != 0)
|
||||
{
|
||||
//NFAPI_TRACE(NFAPI_TRACE_NOTE, "[%d] Freeing tx_req at index %d (%d/%d)",
|
||||
// pMyPhyInfo->sfnSf, bufferIdx,
|
||||
// SFNSF2SFN(dreq->sfn_sf), SFNSF2SF(dreq->sfn_sf));
|
||||
|
||||
deallocate_nfapi_tx_data_request(pnf_p7->slot_buffer[buffer_index].tx_data_req, pnf_p7);
|
||||
}
|
||||
|
||||
pnf_p7->slot_buffer[buffer_index].sfn = req->SFN;
|
||||
pnf_p7->slot_buffer[buffer_index].slot = req->Slot;
|
||||
pnf_p7->slot_buffer[buffer_index].tx_data_req = req;
|
||||
|
||||
pnf_p7->stats.tx_data_ontime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO,"%s() TX_DATA_REQUEST Request is outside of window REQ:SFN_SLOT:%d CURR:SFN_SLOT:%d\n", __FUNCTION__, NFAPI_SFNSLOT2DEC(req->SFN,req->Slot), NFAPI_SFNSLOT2DEC(pnf_p7->sfn,pnf_p7->slot));
|
||||
|
||||
deallocate_nfapi_tx_data_request(req, pnf_p7);
|
||||
|
||||
if(pnf_p7->_public.timing_info_mode_aperiodic)
|
||||
{
|
||||
pnf_p7->timing_info_aperiodic_send = 1;
|
||||
}
|
||||
|
||||
pnf_p7->stats.tx_data_late++;
|
||||
}
|
||||
|
||||
if(pthread_mutex_unlock(&(pnf_p7->mutex)) != 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
deallocate_nfapi_tx_data_request(req, pnf_p7);
|
||||
}
|
||||
if (pthread_mutex_unlock(&(pnf_p7->mutex)) != 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "failed to unlock mutex\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void pnf_handle_tx_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7)
|
||||
{
|
||||
//NFAPI_TRACE(NFAPI_TRACE_INFO, "TX.req Received\n");
|
||||
|
||||
Reference in New Issue
Block a user