Commit 383daaf7 authored by Aniq's avatar Aniq

Added slot_indication on VNF side

parent 02141b8b
...@@ -116,6 +116,7 @@ pthread_cond_t nfapi_sync_cond; ...@@ -116,6 +116,7 @@ pthread_cond_t nfapi_sync_cond;
pthread_mutex_t nfapi_sync_mutex; pthread_mutex_t nfapi_sync_mutex;
int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex
uint16_t sf_ahead=6; //??? value ??? uint16_t sf_ahead=6; //??? value ???
uint16_t slot_ahead = 6;
pthread_cond_t sync_cond; pthread_cond_t sync_cond;
pthread_mutex_t sync_mutex; pthread_mutex_t sync_mutex;
int sync_var=-1; //!< protected by mutex \ref sync_mutex. int sync_var=-1; //!< protected by mutex \ref sync_mutex.
......
...@@ -58,6 +58,7 @@ extern RAN_CONTEXT_t RC; ...@@ -58,6 +58,7 @@ extern RAN_CONTEXT_t RC;
#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h" #include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h"
#include "openair1/SCHED_NR/fapi_nr_l1.h" #include "openair1/SCHED_NR/fapi_nr_l1.h"
#include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h" #include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h"
#include "openair1/PHY/defs_gNB.h"
#define NUM_P5_PHY 2 #define NUM_P5_PHY 2
...@@ -901,7 +902,7 @@ void pnf_phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t *header) { ...@@ -901,7 +902,7 @@ void pnf_phy_deallocate_p7_vendor_ext(nfapi_p7_message_header_t *header) {
} }
int pnf_phy_ul_dci_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_ul_dci_request_t *req) { int pnf_phy_ul_dci_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_ul_dci_request_t *req) {
// if (req-> hi_dci0_request_body.number_of_dci == 0 && req->hi_dci0_request_body.number_of_hi == 0) // if (req-> hi_dci0_request_body.number_of_dci == 0 && req->hi_dci0_request_body.number_of_hi == 0)
// LOG_D(PHY,"[PNF] HI_DCI0_REQUEST SFN/SF:%05d dci:%d hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi); // LOG_D(PHY,"[PNF] HI_DCI0_REQUEST SFN/SF:%05d dci:%d hi:%d\n", NFAPI_SFNSF2DEC(req->sfn_sf), req->hi_dci0_request_body.number_of_dci, req->hi_dci0_request_body.number_of_hi);
...@@ -966,7 +967,7 @@ int pnf_phy_hi_dci0_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfa ...@@ -966,7 +967,7 @@ int pnf_phy_hi_dci0_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfa
} }
int pnf_phy_dl_tti_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_dl_tti_request_t *req) { int pnf_phy_dl_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_dl_tti_request_t *req) {
if (RC.ru == 0) { if (RC.ru == 0) {
return -1; return -1;
} }
...@@ -1004,7 +1005,7 @@ int pnf_phy_dl_tti_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfap ...@@ -1004,7 +1005,7 @@ int pnf_phy_dl_tti_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfap
if (req->dl_tti_request_body.nPDUs) if (req->dl_tti_request_body.nPDUs)
NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d; sfn:%d, slot:%d, nGroup:%u, nPDUs: %u, nUE: %u, PduIdx: %u,\n", NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() TX:%d/%d RX:%d/%d; sfn:%d, slot:%d, nGroup:%u, nPDUs: %u, nUE: %u, PduIdx: %u,\n",
__FUNCTION__, proc->frame_tx, proc->subframe_tx, proc->frame_rx, proc->subframe_rx, // TODO: change subframes to slot __FUNCTION__, proc->frame_tx, proc->slot_tx, proc->frame_rx, proc->slot_rx, // TODO: change subframes to slot
req->SFN, req->SFN,
req->Slot, req->Slot,
req->dl_tti_request_body.nGroup, req->dl_tti_request_body.nGroup,
...@@ -1168,6 +1169,35 @@ int pnf_phy_dl_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, n ...@@ -1168,6 +1169,35 @@ int pnf_phy_dl_config_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, n
return 0; return 0;
} }
int pnf_phy_tx_data_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_tx_data_request_t *req) {
uint16_t sfn = req->SFN;
uint16_t slot = req->Slot;
if (req->Number_of_PDUs == 0)
LOG_D(PHY,"%s() SFN/SLOT:%d%d PDUs:%d\n", __FUNCTION__, sfn, slot, req->Number_of_PDUs);
if (req->pdu_list[0].TLVs->tag == NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST) {
for (int i=0; i<req->Number_of_PDUs; i++) {
// LOG_D(PHY,"%s() SFN/SF:%d%d number_of_pdus:%d [PDU:%d] pdu_length:%d pdu_index:%d num_segments:%d\n",
// __FUNCTION__,
// sfn, sf,
// req->tx_request_body.number_of_pdus,
// i,
// req->tx_request_body.tx_pdu_list[i].pdu_length,
// req->tx_request_body.tx_pdu_list[i].pdu_index,
// req->tx_request_body.tx_pdu_list[i].num_segments
// );
// tx_request_pdu[sfn][sf][i] = &req->tx_request_body.tx_pdu_list[i];
tx_data_request[sfn][slot][i] = &req->pdu_list[i];
}
}
return 0;
}
int pnf_phy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) { int pnf_phy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) {
uint16_t sfn = NFAPI_SFNSF2SFN(req->sfn_sf); uint16_t sfn = NFAPI_SFNSF2SFN(req->sfn_sf);
uint16_t sf = NFAPI_SFNSF2SF(req->sfn_sf); uint16_t sf = NFAPI_SFNSF2SF(req->sfn_sf);
...@@ -1195,7 +1225,7 @@ int pnf_phy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) { ...@@ -1195,7 +1225,7 @@ int pnf_phy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) {
int pnf_phy_ul_tti_req(L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_ul_tti_request_t *req) { int pnf_phy_ul_tti_req(gNB_L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t *pnf_p7, nfapi_nr_ul_tti_request_t *req) {
// if (0)LOG_D(PHY,"[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d rach_prach_frequency_resources:%d srs_present:%u\n", // if (0)LOG_D(PHY,"[PNF] UL_CONFIG_REQ %s() sfn_sf:%d pdu:%d rach_prach_frequency_resources:%d srs_present:%u\n",
// __FUNCTION__, // __FUNCTION__,
// NFAPI_SFNSF2DEC(req->sfn_sf), // NFAPI_SFNSF2DEC(req->sfn_sf),
...@@ -1446,9 +1476,10 @@ int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap ...@@ -1446,9 +1476,10 @@ int start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nfap
} }
// NR // NR
p7_config->dl_tti_req_fn = &pnf_phy_dl_tti_req; p7_config->dl_tti_req_fn = &pnf_phy_dl_tti_req;
p7_config->ul_tti_req_fn = &pnf_phy_ul_tti_req; p7_config->ul_tti_req_fn = &pnf_phy_ul_tti_req;
// p7_config->ul_dci_req_fn = &pnf_phy_ul_dci_req; p7_config->ul_dci_req_fn = &pnf_phy_ul_dci_req;
p7_config->tx_data_req_fn = &pnf_phy_tx_data_req;
// LTE // LTE
p7_config->dl_config_req = &pnf_phy_dl_config_req; p7_config->dl_config_req = &pnf_phy_dl_config_req;
......
...@@ -198,6 +198,7 @@ void install_schedule_handlers(IF_Module_t *if_inst); ...@@ -198,6 +198,7 @@ void install_schedule_handlers(IF_Module_t *if_inst);
extern int single_thread_flag; extern int single_thread_flag;
extern void init_eNB_afterRU(void); extern void init_eNB_afterRU(void);
extern uint16_t sf_ahead; extern uint16_t sf_ahead;
extern uint16_t slot_ahead;
void oai_create_enb(void) { void oai_create_enb(void) {
int bodge_counter=0; int bodge_counter=0;
...@@ -362,6 +363,66 @@ int pnf_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_config_ ...@@ -362,6 +363,66 @@ int pnf_config_resp_cb(nfapi_vnf_config_t *config, int p5_idx, nfapi_pnf_config_
return 0; return 0;
} }
int wake_gNB_rxtx(PHY_VARS_gNB *gNB, uint16_t sfn, uint16_t slot) {
gNB_L1_proc_t *proc=&gNB->proc;
gNB_L1_rxtx_proc_t *L1_proc= (slot&1)? &proc->L1_proc : &proc->L1_proc_tx;
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
//printf("%s(eNB:%p, sfn:%d, sf:%d)\n", __FUNCTION__, eNB, sfn, sf);
//int i;
struct timespec wait;
wait.tv_sec=0;
wait.tv_nsec=5000000L;
// wake up TX for subframe n+sf_ahead
// lock the TX mutex and make sure the thread is ready
if (pthread_mutex_timedlock(&L1_proc->mutex,&wait) != 0) {
LOG_E( PHY, "[gNB] ERROR pthread_mutex_lock for gNB RXTX thread %d (IC %d)\n", L1_proc->slot_rx&1,L1_proc->instance_cnt );
exit_fun( "error locking mutex_rxtx" );
return(-1);
}
{
static uint16_t old_slot = 0;
static uint16_t old_sfn = 0;
proc->slot_rx = old_slot;
proc->frame_rx = old_sfn;
// Try to be 1 frame back
old_slot = slot;
old_sfn = sfn;
if (old_slot == 0 && old_sfn % 100 == 0) LOG_W( PHY,"[gNB] sfn/slot:%d%d old_sfn/slot:%d%d proc[rx:%d%d]\n", sfn, slot, old_sfn, old_slot, proc->frame_rx, proc->slot_rx);
}
++L1_proc->instance_cnt;
//LOG_D( PHY,"[VNF-subframe_ind] sfn/sf:%d:%d proc[frame_rx:%d subframe_rx:%d] L1_proc->instance_cnt_rxtx:%d \n", sfn, sf, proc->frame_rx, proc->subframe_rx, L1_proc->instance_cnt_rxtx);
// We have just received and processed the common part of a subframe, say n.
// TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired
// transmitted timestamp of the next TX slot (first).
// The last (TS_rx mod samples_per_frame) was n*samples_per_tti,
// we want to generate subframe (n+N), so TS_tx = TX_rx+N*samples_per_tti,
// and proc->subframe_tx = proc->subframe_rx+sf_ahead
L1_proc->timestamp_tx = proc->timestamp_rx + (slot_ahead *fp->samples_per_tti);
L1_proc->frame_rx = proc->frame_rx;
L1_proc->slot_rx = proc->slot_rx;
L1_proc->frame_tx = (L1_proc->slot_rx > (9-slot_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx;
L1_proc->slot_tx = (L1_proc->slot_rx + slot_ahead)%20;
//LOG_D(PHY, "sfn/sf:%d%d proc[rx:%d%d] L1_proc[instance_cnt_rxtx:%d rx:%d%d] About to wake rxtx thread\n\n", sfn, sf, proc->frame_rx, proc->subframe_rx, L1_proc->instance_cnt_rxtx, L1_proc->frame_rx, L1_proc->subframe_rx);
// the thread can now be woken up
if (pthread_cond_signal(&L1_proc->cond) != 0) {
LOG_E( PHY, "[gNB] ERROR pthread_cond_signal for gNB RXn-TXnp4 thread\n");
exit_fun( "ERROR pthread_cond_signal" );
return(-1);
}
//LOG_D(PHY,"%s() About to attempt pthread_mutex_unlock\n", __FUNCTION__);
pthread_mutex_unlock( &L1_proc->mutex );
//LOG_D(PHY,"%s() UNLOCKED pthread_mutex_unlock\n", __FUNCTION__);
return(0);
}
int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) { int wake_eNB_rxtx(PHY_VARS_eNB *eNB, uint16_t sfn, uint16_t sf) {
L1_proc_t *proc=&eNB->proc; L1_proc_t *proc=&eNB->proc;
L1_rxtx_proc_t *L1_proc= (sf&1)? &proc->L1_proc : &proc->L1_proc_tx; L1_rxtx_proc_t *L1_proc= (sf&1)? &proc->L1_proc : &proc->L1_proc_tx;
...@@ -439,6 +500,29 @@ int phy_sync_indication(struct nfapi_vnf_p7_config *config, uint8_t sync) { ...@@ -439,6 +500,29 @@ int phy_sync_indication(struct nfapi_vnf_p7_config *config, uint8_t sync) {
return(0); return(0);
} }
int phy_slot_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uint16_t sfn, uint16_t slot) {
static uint8_t first_time = 1;
if (first_time) {
printf("[VNF] slot indication %d\n", NFAPI_SFNSLOT2DEC(sfn, slot));
first_time = 0;
}
if (RC.gNB && RC.gNB[0]->configured) {
// uint16_t sfn = NFAPI_SFNSF2SFN(sfn_sf);
// uint16_t sf = NFAPI_SFNSF2SF(sfn_sf);
//LOG_D(PHY,"[VNF] subframe indication sfn_sf:%d sfn:%d sf:%d\n", sfn_sf, sfn, sf);
wake_gNB_rxtx(RC.gNB[0], sfn, slot); // DONE: find NR equivalent
} else {
printf("[VNF] %s() RC.gNB:%p\n", __FUNCTION__, RC.gNB);
if (RC.gNB) printf("RC.gNB[0]->configured:%d\n", RC.gNB[0]->configured);
}
return 0;
}
int phy_subframe_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uint16_t sfn_sf) { int phy_subframe_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uint16_t sfn_sf) {
static uint8_t first_time = 1; static uint8_t first_time = 1;
...@@ -960,6 +1044,8 @@ void *vnf_p7_thread_start(void *ptr) { ...@@ -960,6 +1044,8 @@ void *vnf_p7_thread_start(void *ptr) {
p7_vnf->config->port = p7_vnf->local_port; p7_vnf->config->port = p7_vnf->local_port;
p7_vnf->config->sync_indication = &phy_sync_indication; p7_vnf->config->sync_indication = &phy_sync_indication;
p7_vnf->config->subframe_indication = &phy_subframe_indication; p7_vnf->config->subframe_indication = &phy_subframe_indication;
p7_vnf->config->slot_indication = &phy_slot_indication;
p7_vnf->config->harq_indication = &phy_harq_indication; p7_vnf->config->harq_indication = &phy_harq_indication;
p7_vnf->config->crc_indication = &phy_crc_indication; p7_vnf->config->crc_indication = &phy_crc_indication;
p7_vnf->config->rx_indication = &phy_rx_indication; p7_vnf->config->rx_indication = &phy_rx_indication;
......
...@@ -64,7 +64,7 @@ typedef enum { ...@@ -64,7 +64,7 @@ typedef enum {
NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST= 0X81, NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST= 0X81,
NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION=0X82, NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION=0X82,
NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST= 0X83, NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST= 0X83,
NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST=0X54, NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST=0X84, // CHANGED TO 0X84
NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION=0X85, NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION=0X85,
NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION= 0X86, NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION= 0X86,
NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION= 0X87, NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION= 0X87,
......
...@@ -29,6 +29,9 @@ extern "C" { ...@@ -29,6 +29,9 @@ extern "C" {
#include "nfapi_nr_interface_scf.h" #include "nfapi_nr_interface_scf.h"
#include <sys/types.h> #include <sys/types.h>
#include "openair1/PHY/defs_gNB.h"
/*! This enum is used to describe the states of the pnf /*! This enum is used to describe the states of the pnf
...@@ -642,7 +645,7 @@ typedef struct nfapi_pnf_p7_config ...@@ -642,7 +645,7 @@ typedef struct nfapi_pnf_p7_config
* \param req A pointer to the dl config request message structure * \param req A pointer to the dl config request message structure
* \return not currently used * \return not currently used
*/ */
int (*dl_tti_req_fn)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_nr_dl_tti_request_t* req); int (*dl_tti_req_fn)(gNB_L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_nr_dl_tti_request_t* req);
int (*dl_config_req)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_dl_config_request_t* req); int (*dl_config_req)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_dl_config_request_t* req);
/*! A callback for the UL_CONFIG.request /*! A callback for the UL_CONFIG.request
...@@ -650,7 +653,7 @@ typedef struct nfapi_pnf_p7_config ...@@ -650,7 +653,7 @@ typedef struct nfapi_pnf_p7_config
* \param req A pointer to the ul config request message structure * \param req A pointer to the ul config request message structure
* \return not currently used * \return not currently used
*/ */
int (*ul_tti_req_fn)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_nr_ul_tti_request_t* req); int (*ul_tti_req_fn)(gNB_L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_nr_ul_tti_request_t* req);
int (*ul_config_req)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_ul_config_request_t* req); int (*ul_config_req)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_ul_config_request_t* req);
/*! A callback for the HI_DCI0.request /*! A callback for the HI_DCI0.request
...@@ -658,7 +661,7 @@ typedef struct nfapi_pnf_p7_config ...@@ -658,7 +661,7 @@ typedef struct nfapi_pnf_p7_config
* \param req A pointer to the hi dci0 request message structure * \param req A pointer to the hi dci0 request message structure
* \return not currently used * \return not currently used
*/ */
int (*ul_dci_req_fn)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_nr_ul_dci_request_t* req); int (*ul_dci_req_fn)(gNB_L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_nr_ul_dci_request_t* req);
int (*hi_dci0_req)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_hi_dci0_request_t* req); int (*hi_dci0_req)(L1_rxtx_proc_t *proc,nfapi_pnf_p7_config_t* config, nfapi_hi_dci0_request_t* req);
/*! A callback for the TX_REQ.request /*! A callback for the TX_REQ.request
......
...@@ -694,6 +694,7 @@ typedef struct nfapi_vnf_p7_config ...@@ -694,6 +694,7 @@ typedef struct nfapi_vnf_p7_config
*/ */
int (*subframe_indication)(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn_sf); int (*subframe_indication)(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn_sf);
int (*slot_indication)(struct nfapi_vnf_p7_config* config, uint16_t phy_id, uint16_t sfn, uint16_t slot);
/*! A callback for the HARQ.indication /*! A callback for the HARQ.indication
* \param config A pointer to the vnf p7 configuration * \param config A pointer to the vnf p7 configuration
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment