Commit 068c239b authored by Sofia Pison's avatar Sofia Pison Committed by rajeshwari.p

Add first template for NR integration of O-RAN FHI Library.

parent 62c73ee3
......@@ -676,10 +676,11 @@ include_directories ("/usr/local/dpdk_19_11/include/dpdk")
include_directories("${ICC_LIB}")
set(ORAN_FHLIB_5G_SOURCE
${OPENAIR_TARGETS}/ARCH/ETHERNET/oran/5g/oran.cc
${OPENAIR_TARGETS}/ARCH/ETHERNET/oran/5g/oran.cpp
${OPENAIR_TARGETS}/ARCH/ETHERNET/oran/5g/shared_buffers.c
${OPENAIR_TARGETS}/ARCH/ETHERNET/oran/5g/low_oran.c
${OPENAIR_TARGETS}/ARCH/ETHERNET/oran/5g/low_dpdk_oran.c
${OPENAIR_TARGETS}/ARCH/ETHERNET/oran/5g/oran_isolate.c
)
add_library(oran_fhlib_5g MODULE ${ORAN_FHLIB_5G_SOURCE})
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
// #include "common_lib.h"
// #include "ethernet_lib.h"
#include "oran_isolate.h"
#include "shared_buffers.h"
#include "low_oran.h"
#include "xran_lib_wrap.hpp"
#include "common.hpp"
#include "xran_compression.h"
#include "xran_sync_api.h"
// Declare variable useful for the send buffer function
struct xran_device_ctx *p_xran_dev_ctx_2;
// Variable declaration useful for fill IQ samples from file
#define IQ_PLAYBACK_BUFFER_BYTES (XRAN_NUM_OF_SLOT_IN_TDD_LOOP*N_SYM_PER_SLOT*XRAN_MAX_PRBS*N_SC_PER_PRB*4L)
int16_t *p_tx_play_buffer[MAX_ANT_CARRIER_SUPPORTED];
int iq_playback_buffer_size_dl = IQ_PLAYBACK_BUFFER_BYTES;
int32_t tx_play_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
int32_t tx_play_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
// Declare the function useful to load IQs from file
int sys_load_file_to_buff(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num)
{
unsigned int file_size = 0;
int num= 0;
if (size)
{
if (filename && bufname)
{
FILE *file;
printf("Loading file %s to %s: ", filename, bufname);
file = fopen(filename, "rb");
if (file == NULL)
{
printf("can't open file %s!!!", filename);
exit(-1);
}
else
{
fseek(file, 0, SEEK_END);
file_size = ftell(file);
fseek(file, 0, SEEK_SET);
if ((file_size > size) || (file_size == 0))
file_size = size;
printf("Reading IQ samples from file: File Size: %d [Buffer Size: %d]\n", file_size, size);
num = fread(pBuffer, buffers_num, size, file);
fflush(file);
fclose(file);
printf("from addr (0x%lx) size (%d) bytes num (%d)", (uint64_t)pBuffer, file_size, num);
}
printf(" \n");
}
else
{
printf(" the file name, buffer name are not set!!!");
}
}
else
{
printf(" the %s is free: size = %d bytes!!!", bufname, size);
}
return num;
}
//------------------------------------------------------------------------
void xran_fh_rx_callback(void *pCallbackTag, xran_status_t status){
rte_pause();
}
void xran_fh_srs_callback(void *pCallbackTag, xran_status_t status){
rte_pause();
}
void xran_fh_rx_prach_callback(void *pCallbackTag, xran_status_t status){
rte_pause();
}
int physide_dl_tti_call_back(void * param)
{
rte_pause();
return 0;
}
int physide_ul_half_slot_call_back(void * param)
{
rte_pause();
return 0;
}
int physide_ul_full_slot_call_back(void * param)
{
rte_pause();
return 0;
}
//------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
void* define_oran_pointer(){
xranLibWraper *xranlib;
xranlib = new xranLibWraper;
//xranLibWraper *xranlib = (xranLibWraper*) calloc(1,sizeof(xranLibWraper));
return xranlib;
}
#ifdef __cplusplus
}
#endif
//------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
int setup_oran( void *xranlib_ ){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
if(xranlib->SetUp() < 0) {
return (-1);
}
return (0);
}
#ifdef __cplusplus
}
#endif
//------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
int open_oran_callback(void *xranlib_){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
xranlib->Open(nullptr,
nullptr,
(void *)xran_fh_rx_callback,
(void *)xran_fh_rx_prach_callback,
(void *)xran_fh_srs_callback);
return(0);
}
#ifdef __cplusplus
}
#endif
//------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
int open_oran(void *xranlib_){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
struct xran_fh_config *pCfg = (struct xran_fh_config*) malloc(sizeof(struct xran_fh_config));
assert(pCfg != NULL);
xranlib->get_cfg_fh(pCfg);
xran_open(xranlib->get_xranhandle(),pCfg);
return(0);
}
#ifdef __cplusplus
}
#endif
//------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
int initialize_oran(void *xranlib_){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
xranlib->Init();
return(0);
}
#ifdef __cplusplus
}
#endif
//------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
int start_oran(void *xranlib_){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
xranlib->Start();
return (0);
}
#ifdef __cplusplus
}
#endif
//------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
int register_physide_callbacks(void *xranlib_){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
xran_reg_physide_cb(xranlib->get_xranhandle(), physide_dl_tti_call_back, NULL, 10, XRAN_CB_TTI);
xran_reg_physide_cb(xranlib->get_xranhandle(), physide_ul_half_slot_call_back, NULL, 10, XRAN_CB_HALF_SLOT_RX);
xran_reg_physide_cb(xranlib->get_xranhandle(), physide_ul_full_slot_call_back, NULL, 10, XRAN_CB_FULL_SLOT_RX);
return (0);
}
#ifdef __cplusplus
}
#endif
//------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
int load_iq_from_file(void *xranlib_){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
int numCCPorts_ = xranlib->get_num_cc();
int num_eAxc_ = xranlib->get_num_eaxc();
printf("numCCPorts_ =%d, num_eAxc_=%d, MAX_ANT_CARRIER_SUPPORTED =%d\n",numCCPorts_,num_eAxc_,MAX_ANT_CARRIER_SUPPORTED);
int i;
char *IQ_filename[MAX_ANT_CARRIER_SUPPORTED];
for(i=0; i<MAX_ANT_CARRIER_SUPPORTED; i++){
if( (i==0) || (i==1) || (i==2) || (i==3) ){
IQ_filename[0] = "/home/oba/PISONS/phy/fhi_lib/app/usecase/mu0_5mhz/ant_0.bin";
IQ_filename[1] = "/home/oba/PISONS/phy/fhi_lib/app/usecase/mu0_5mhz/ant_1.bin";
IQ_filename[2] = "/home/oba/PISONS/phy/fhi_lib/app/usecase/mu0_5mhz/ant_2.bin";
IQ_filename[3] = "/home/oba/PISONS/phy/fhi_lib/app/usecase/mu0_5mhz/ant_3.bin";
}else{
IQ_filename[i] = "";
}
}
int32_t number_slots = 40; // According to wrapper.hpp uint32_t m_nSlots = 10; but for the file 5MHz is set to 40
uint32_t numerology = xranlib->get_numerology(); // According to the conf file is mu number
uint32_t bandwidth = 5; // According to the wrapper.hpp since we are reading the 5MHz files
uint32_t sub6 = xranlib->get_sub6();
iq_playback_buffer_size_dl = (number_slots * N_SYM_PER_SLOT * N_SC_PER_PRB * xranlib->get_num_rbs(numerology,bandwidth,sub6)*4L);
for(i = 0; i < MAX_ANT_CARRIER_SUPPORTED && i < (uint32_t)(numCCPorts_ * num_eAxc_); i++) {
if(((uint8_t *)IQ_filename[i])[0]!=0){
p_tx_play_buffer[i] = (int16_t*)malloc(iq_playback_buffer_size_dl);
assert (NULL != (p_tx_play_buffer[i]));
tx_play_buffer_size[i] = (int32_t)iq_playback_buffer_size_dl;
printf("Loading file [%d] %s \n",i,IQ_filename[i]);
tx_play_buffer_size[i] = sys_load_file_to_buff( IQ_filename[i],
"DL IFFT IN IQ Samples in binary format",
(uint8_t*) p_tx_play_buffer[i],
tx_play_buffer_size[i],
1);
tx_play_buffer_position[i] = 0;
} else {
p_tx_play_buffer[i]=(int16_t*)malloc(iq_playback_buffer_size_dl);
tx_play_buffer_size[i]=0;
tx_play_buffer_position[i] = 0;
}
}
return(0);
}
#ifdef __cplusplus
}
#endif
//------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
int xran_fh_tx_send_buffer(void *xranlib_){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
int32_t flowId;
void *ptr = NULL;
char *pos = NULL;
p_xran_dev_ctx_2 = xran_dev_get_ctx();
if (p_xran_dev_ctx_2 != NULL){
printf("p_xran_dev_ctx_2=%d\n",p_xran_dev_ctx_2);
}
int num_eaxc = xranlib->get_num_eaxc();
int num_eaxc_ul = xranlib->get_num_eaxc_ul();
uint32_t xran_max_antenna_nr = RTE_MAX(num_eaxc, num_eaxc_ul);
int ant_el_trx = xranlib->get_num_antelmtrx();
uint32_t xran_max_ant_array_elm_nr = RTE_MAX(ant_el_trx, xran_max_antenna_nr);
int32_t nSectorIndex[XRAN_MAX_SECTOR_NR];
int32_t nSectorNum;
for (nSectorNum = 0; nSectorNum < XRAN_MAX_SECTOR_NR; nSectorNum++)
{
nSectorIndex[nSectorNum] = nSectorNum;
}
nSectorNum = xranlib->get_num_cc();
int maxflowid = num_eaxc * (nSectorNum-1) + (xran_max_antenna_nr-1);
printf("the maximum flowID will be=%d\n",maxflowid);
for(uint16_t cc_id=0; cc_id<nSectorNum; cc_id++){
for(int32_t tti = 0; tti < XRAN_N_FE_BUF_LEN; tti++) {
for(uint8_t ant_id = 0; ant_id < xran_max_antenna_nr; ant_id++){
for(int32_t sym_idx = 0; sym_idx < XRAN_NUM_OF_SYMBOL_PER_SLOT; sym_idx++) {
flowId = num_eaxc * cc_id + ant_id;
uint8_t *pData = p_xran_dev_ctx_2->sFrontHaulTxBbuIoBufCtrl[tti % XRAN_N_FE_BUF_LEN][cc_id][ant_id].sBufferList.pBuffers[sym_idx%XRAN_NUM_OF_SYMBOL_PER_SLOT].pData;
uint8_t *pPrbMapData = p_xran_dev_ctx_2->sFrontHaulTxPrbMapBbuIoBufCtrl[tti % XRAN_N_FE_BUF_LEN][cc_id][ant_id].sBufferList.pBuffers->pData;
struct xran_prb_map *pPrbMap = (struct xran_prb_map *)pPrbMapData;
ptr = pData;
pos = ((char*)p_tx_play_buffer[flowId]) + tx_play_buffer_position[flowId];
uint8_t *u8dptr;
struct xran_prb_map *pRbMap = pPrbMap;
int32_t sym_id = sym_idx%XRAN_NUM_OF_SYMBOL_PER_SLOT;
if(ptr && pos){
int idxElm = 0;
u8dptr = (uint8_t*)ptr;
int16_t payload_len = 0;
uint8_t *dst = (uint8_t *)u8dptr;
uint8_t *src = (uint8_t *)pos;
struct xran_prb_elm* p_prbMapElm = &pRbMap->prbMap[idxElm];
dst = xran_add_hdr_offset(dst, p_prbMapElm->compMethod);
for (idxElm = 0; idxElm < pRbMap->nPrbElm; idxElm++) {
struct xran_section_desc *p_sec_desc = NULL;
p_prbMapElm = &pRbMap->prbMap[idxElm];
p_sec_desc = p_prbMapElm->p_sec_desc[sym_id];
if(p_sec_desc == NULL){
printf ("p_sec_desc == NULL\n");
exit(-1);
}
src = (uint8_t *)(pos + p_prbMapElm->nRBStart*N_SC_PER_PRB*4L);
if(p_prbMapElm->compMethod == XRAN_COMPMETHOD_NONE) {
payload_len = p_prbMapElm->nRBSize*N_SC_PER_PRB*4L;
rte_memcpy(dst, src, payload_len);
} else if (p_prbMapElm->compMethod == XRAN_COMPMETHOD_BLKFLOAT) {
printf("idxElm=%d, compMeth==BLKFLOAT\n",idxElm);
struct xranlib_compress_request bfp_com_req;
struct xranlib_compress_response bfp_com_rsp;
memset(&bfp_com_req, 0, sizeof(struct xranlib_compress_request));
memset(&bfp_com_rsp, 0, sizeof(struct xranlib_compress_response));
bfp_com_req.data_in = (int16_t*)src;
bfp_com_req.numRBs = p_prbMapElm->nRBSize;
bfp_com_req.len = p_prbMapElm->nRBSize*N_SC_PER_PRB*4L;
bfp_com_req.compMethod = p_prbMapElm->compMethod;
bfp_com_req.iqWidth = p_prbMapElm->iqWidth;
bfp_com_rsp.data_out = (int8_t*)dst;
bfp_com_rsp.len = 0;
xranlib_compress_avx512(&bfp_com_req, &bfp_com_rsp);
payload_len = bfp_com_rsp.len;
}else {
printf ("p_prbMapElm->compMethod == %d is not supported\n",
p_prbMapElm->compMethod);
exit(-1);
}
p_sec_desc->iq_buffer_offset = RTE_PTR_DIFF(dst, u8dptr);
p_sec_desc->iq_buffer_len = payload_len;
dst += payload_len;
dst = xran_add_hdr_offset(dst, p_prbMapElm->compMethod);
}
} else {
exit(-1);
printf("ptr ==NULL\n");
}
}
}
}
}
return(0);
}
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
int xran_fh_tx_send_slot(void *xranlib_, ru_info_t *ru, int frame, int slot, uint64_t timestamp){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
int tti = /*frame*SUBFRAMES_PER_SYSTEMFRAME*SLOTNUM_PER_SUBFRAME*/+slot; //commented out temporarily to check that compilation of oran 5g is working.
int32_t flowId;
void *ptr = NULL;
int32_t *pos = NULL;
p_xran_dev_ctx_2 = xran_dev_get_ctx();
if (p_xran_dev_ctx_2 != NULL){
printf("p_xran_dev_ctx_2=%d\n",p_xran_dev_ctx_2);
}
int num_eaxc = xranlib->get_num_eaxc();
int num_eaxc_ul = xranlib->get_num_eaxc_ul();
uint32_t xran_max_antenna_nr = RTE_MAX(num_eaxc, num_eaxc_ul);
int ant_el_trx = xranlib->get_num_antelmtrx();
uint32_t xran_max_ant_array_elm_nr = RTE_MAX(ant_el_trx, xran_max_antenna_nr);
int32_t nSectorIndex[XRAN_MAX_SECTOR_NR];
int32_t nSectorNum;
for (nSectorNum = 0; nSectorNum < XRAN_MAX_SECTOR_NR; nSectorNum++)
{
nSectorIndex[nSectorNum] = nSectorNum;
}
nSectorNum = xranlib->get_num_cc();
int maxflowid = num_eaxc * (nSectorNum-1) + (xran_max_antenna_nr-1);
printf("the maximum flowID will be=%d\n",maxflowid);
for(uint16_t cc_id=0; cc_id<1/*nSectorNum*/; cc_id++){ // OAI does not support multiple CC yet.
for(uint8_t ant_id = 0; ant_id < xran_max_antenna_nr && ant_id<ru->nb_tx; ant_id++){
// This loop would better be more inner to avoid confusion and maybe also errors.
for(int32_t sym_idx = 0; sym_idx < XRAN_NUM_OF_SYMBOL_PER_SLOT; sym_idx++) {
flowId = num_eaxc * cc_id + ant_id;
uint8_t *pData = p_xran_dev_ctx_2->sFrontHaulTxBbuIoBufCtrl[tti % XRAN_N_FE_BUF_LEN][cc_id][ant_id].sBufferList.pBuffers[sym_idx%XRAN_NUM_OF_SYMBOL_PER_SLOT].pData;
uint8_t *pPrbMapData = p_xran_dev_ctx_2->sFrontHaulTxPrbMapBbuIoBufCtrl[tti % XRAN_N_FE_BUF_LEN][cc_id][ant_id].sBufferList.pBuffers->pData;
struct xran_prb_map *pPrbMap = (struct xran_prb_map *)pPrbMapData;
ptr = pData;
pos = &ru->txdataF_BF[ant_id][sym_idx * 2048 /*fp->ofdm_symbol_size*/]; // We had to use a different ru structure than benetel so the access to the buffer is not the same.
uint8_t *u8dptr;
struct xran_prb_map *pRbMap = pPrbMap;
int32_t sym_id = sym_idx%XRAN_NUM_OF_SYMBOL_PER_SLOT;
if(ptr && pos){
int idxElm = 0;
u8dptr = (uint8_t*)ptr;
int16_t payload_len = 0;
uint8_t *dst = (uint8_t *)u8dptr;
uint8_t *src = (uint8_t *)pos;
struct xran_prb_elm* p_prbMapElm = &pRbMap->prbMap[idxElm];
dst = xran_add_hdr_offset(dst, p_prbMapElm->compMethod);
for (idxElm = 0; idxElm < pRbMap->nPrbElm; idxElm++) {
struct xran_section_desc *p_sec_desc = NULL;
p_prbMapElm = &pRbMap->prbMap[idxElm];
p_sec_desc = p_prbMapElm->p_sec_desc[sym_id];
if(p_sec_desc == NULL){
printf ("p_sec_desc == NULL\n");
exit(-1);
}
// Calculation of the pointer for the section in the buffer.
if (p_prbMapElm->nRBStart*N_SC_PER_PRB<600){
src = (uint8_t *)(pos + p_prbMapElm->nRBStart*N_SC_PER_PRB + 1);
}else{
src = (uint8_t *)(pos + p_prbMapElm->nRBStart*N_SC_PER_PRB + 2048 - 1200);
}
if(p_prbMapElm->compMethod == XRAN_COMPMETHOD_NONE) {
payload_len = p_prbMapElm->nRBSize*N_SC_PER_PRB*4L;
rte_memcpy(dst, src, payload_len);
} else if (p_prbMapElm->compMethod == XRAN_COMPMETHOD_BLKFLOAT) {
printf("idxElm=%d, compMeth==BLKFLOAT\n",idxElm);
struct xranlib_compress_request bfp_com_req;
struct xranlib_compress_response bfp_com_rsp;
memset(&bfp_com_req, 0, sizeof(struct xranlib_compress_request));
memset(&bfp_com_rsp, 0, sizeof(struct xranlib_compress_response));
bfp_com_req.data_in = (int16_t*)src;
bfp_com_req.numRBs = p_prbMapElm->nRBSize;
bfp_com_req.len = p_prbMapElm->nRBSize*N_SC_PER_PRB*4L;
bfp_com_req.compMethod = p_prbMapElm->compMethod;
bfp_com_req.iqWidth = p_prbMapElm->iqWidth;
bfp_com_rsp.data_out = (int8_t*)dst;
bfp_com_rsp.len = 0;
xranlib_compress_avx512(&bfp_com_req, &bfp_com_rsp);
payload_len = bfp_com_rsp.len;
}else {
printf ("p_prbMapElm->compMethod == %d is not supported\n",
p_prbMapElm->compMethod);
exit(-1);
}
p_sec_desc->iq_buffer_offset = RTE_PTR_DIFF(dst, u8dptr);
p_sec_desc->iq_buffer_len = payload_len;
dst += payload_len;
dst = xran_add_hdr_offset(dst, p_prbMapElm->compMethod);
}
// The tti should be updated as it increased.
pRbMap->tti_id = tti;
} else {
exit(-1);
printf("ptr ==NULL\n");
}
}
}
}
return(0);
}
#ifdef __cplusplus
}
#endif
//-----------------------------------------------------------------------
int64_t count_sec =0;
struct xran_common_counters x_counters;
uint64_t nTotalTime;
uint64_t nUsedTime;
uint32_t nCoreUsed;
float nUsedPercent;
long old_rx_counter = 0;
long old_tx_counter = 0;
#ifdef __cplusplus
extern "C"
{
#endif
int compute_xran_statistics(void *xranlib_){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
if(xran_get_common_counters(xranlib->get_xranhandle(), &x_counters) == XRAN_STATUS_SUCCESS) {
xran_get_time_stats(&nTotalTime, &nUsedTime, &nCoreUsed, 1);
nUsedPercent = ((float)nUsedTime * 100.0) / (float)nTotalTime;
printf("[rx %7ld pps %7ld kbps %7ld][tx %7ld pps %7ld kbps %7ld] [on_time %ld early %ld late %ld corrupt %ld pkt_dupl %ld Total %ld] IO Util: %5.2f %%\n",
x_counters.rx_counter,
x_counters.rx_counter-old_rx_counter,
x_counters.rx_bytes_per_sec*8/1000L,
x_counters.tx_counter,
x_counters.tx_counter-old_tx_counter,
x_counters.tx_bytes_per_sec*8/1000L,
x_counters.Rx_on_time,
x_counters.Rx_early,
x_counters.Rx_late,
x_counters.Rx_corrupt,
x_counters.Rx_pkt_dupl,
x_counters.Total_msgs_rcvd,
nUsedPercent);
if(x_counters.rx_counter > old_rx_counter)
old_rx_counter = x_counters.rx_counter;
if(x_counters.tx_counter > old_tx_counter)
old_tx_counter = x_counters.tx_counter;
} else {
printf("error xran_get_common_counters\n");
return(1);
}
return (0);
}
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void check_xran_ptp_sync(){
if (xran_is_synchronized() != 0)
printf("Machine is not synchronized using PTP!\n");
else
printf("Machine is synchronized using PTP!\n");
}
#ifdef __cplusplus
}
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <stdio.h>
#include "common_lib.h"
#include "ethernet_lib.h"
#include "shared_buffers.h"
#include "low_oran.h"
#include "oran_isolate.h"
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
typedef struct {
eth_state_t e;
shared_buffers buffers;
rru_config_msg_type_t last_msg;
int capabilities_sent;
void *oran_priv;
} oran_eth_state_t;
int trx_oran_start(openair0_device *device)
{
printf("ORAN: %s\n", __FUNCTION__);
return 0;
}
void trx_oran_end(openair0_device *device)
{
printf("ORAN: %s\n", __FUNCTION__);
}
int trx_oran_stop(openair0_device *device)
{
printf("ORAN: %s\n", __FUNCTION__);
return(0);
}
int trx_oran_set_freq(openair0_device* device,
openair0_config_t *openair0_cfg,
int exmimo_dump_config)
{
printf("ORAN: %s\n", __FUNCTION__);
return(0);
}
int trx_oran_set_gains(openair0_device* device,
openair0_config_t *openair0_cfg)
{
printf("ORAN: %s\n", __FUNCTION__);
return(0);
}
int trx_oran_get_stats(openair0_device* device)
{
printf("ORAN: %s\n", __FUNCTION__);
return(0);
}
int trx_oran_reset_stats(openair0_device* device)
{
printf("ORAN: %s\n", __FUNCTION__);
return(0);
}
int ethernet_tune(openair0_device *device,
unsigned int option,
int value)
{
printf("ORAN: %s\n", __FUNCTION__);
return 0;
}
int trx_oran_write_raw(openair0_device *device,
openair0_timestamp timestamp,
void **buff, int nsamps, int cc, int flags)
{
printf("ORAN: %s\n", __FUNCTION__);
return 0;
}
int trx_oran_read_raw(openair0_device *device,
openair0_timestamp *timestamp,
void **buff, int nsamps, int cc)
{
printf("ORAN: %s\n", __FUNCTION__);
return 0;
}
char *msg_type(int t)
{
static char *s[12] = {
"RAU_tick",
"RRU_capabilities",
"RRU_config",
"RRU_config_ok",
"RRU_start",
"RRU_stop",
"RRU_sync_ok",
"RRU_frame_resynch",
"RRU_MSG_max_num",
"RRU_check_sync",
"RRU_config_update",
"RRU_config_update_ok",
};
if (t < 0 || t > 11) return "UNKNOWN";
return s[t];
}
int trx_oran_ctlsend(openair0_device *device, void *msg, ssize_t msg_len)
{
RRU_CONFIG_msg_t *rru_config_msg = msg;
oran_eth_state_t *s = device->priv;
printf("ORAN: %s\n", __FUNCTION__);
printf(" rru_config_msg->type %d [%s]\n", rru_config_msg->type,
msg_type(rru_config_msg->type));
s->last_msg = rru_config_msg->type;
return msg_len;
}
int trx_oran_ctlrecv(openair0_device *device, void *msg, ssize_t msg_len)
{
RRU_CONFIG_msg_t *rru_config_msg = msg;
oran_eth_state_t *s = device->priv;
printf("ORAN: %s\n", __FUNCTION__);
if (s->last_msg == RAU_tick && s->capabilities_sent == 0) {
printf("Oran RAU_tick and capabilities sent\n");
RRU_capabilities_t *cap;
rru_config_msg->type = RRU_capabilities;
rru_config_msg->len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_capabilities_t);
cap = (RRU_capabilities_t*)&rru_config_msg->msg[0];
cap->FH_fmt = OAI_IF4p5_only;
cap->num_bands = 1;
cap->band_list[0] = 7;
cap->nb_rx[0] = device->openair0_cfg->rx_num_channels;
cap->nb_tx[0] = device->openair0_cfg->tx_num_channels;
cap->max_pdschReferenceSignalPower[0] = -27;
cap->max_rxgain[0] = 90;
s->capabilities_sent = 1;
return rru_config_msg->len;
}
if (s->last_msg == RRU_config) {
printf("Oran RRU_config\n");
rru_config_msg->type = RRU_config_ok;
return 0;
}
if (s->last_msg == RRU_start) {
// Folllow the same steps as in the wrapper
printf("Oran RRU_start\n");
// Check if the machine is PTP sync
check_xran_ptp_sync();
// SetUp
if ( setup_oran(s->oran_priv) !=0 ){
printf("%s:%d:%s: SetUp ORAN failed ... Exit\n",
__FILE__, __LINE__, __FUNCTION__);
exit(1);
}else{
printf("SetUp ORAN. Done\n");
}
// Load the IQ samples from file
load_iq_from_file(s->oran_priv);
printf("Load IQ from file. Done\n");
// Register physide callbacks
register_physide_callbacks(s->oran_priv);
printf("Register physide callbacks. Done\n");
// Open callbacks
open_oran_callback(s->oran_priv);
printf("Open Oran callbacks. Done\n");
// Init ORAN
initialize_oran(s->oran_priv);
printf("Init Oran. Done\n");
// Copy the loaded IQ to the xran buffer fro the tx
xran_fh_tx_send_buffer(s->oran_priv);
printf("ORAN FH send tx buffer filled in with loaded IQs. Done\n");
// Open ORAN
open_oran(s->oran_priv);
printf("xran_open. Done\n");
// Start ORAN
if ( start_oran(s->oran_priv) !=0 ){
printf("%s:%d:%s: Start ORAN failed ... Exit\n",
__FILE__, __LINE__, __FUNCTION__);
exit(1);
}else{
printf("Start ORAN. Done\n");
}
// Once xran library and thread started compute the statistics
while(1){
sleep(1);
compute_xran_statistics(s->oran_priv);
}
}
return(0);
}
/*This function reads the IQ samples from OAI, symbol by symbol.
It also handles the shared buffers. */
void oran_fh_if4p5_south_in(RU_t *ru,
int *frame,
int *slot)
{
#if 0
printf("ORAN: %s for UL. frame=%d, slot=%d, \n", __FUNCTION__,frame,slot);
oran_eth_state_t *s = ru->ifdevice.priv;
PHY_VARS_eNB **eNB_list = ru->eNB_list, *eNB;
LTE_DL_FRAME_PARMS *fp;
int symbol;
int32_t *rxdata;
int antenna;
lock_ul_buffer(&s->buffers, *slot);
next:
while (!((s->buffers.ul_busy[0][*slot] == 0x3fff &&
s->buffers.ul_busy[1][*slot] == 0x3fff) ||
s->buffers.prach_busy[*slot] == 1))
wait_ul_buffer(&s->buffers, *slot);
if (s->buffers.prach_busy[*slot] == 1) {
int i;
int antenna = 0;
uint16_t *in;
uint16_t *out;
in = (uint16_t *)s->buffers.prach[*slot];
out = (uint16_t *)ru->prach_rxsigF[0][antenna];
for (i = 0; i < 840*2; i++)
out[i] = ntohs(in[i]);
s->buffers.prach_busy[*slot] = 0;
ru->wakeup_prach_eNB(ru->eNB_list[0], ru, *frame, *slot);
goto next;
}
eNB = eNB_list[0];
fp = &eNB->frame_parms;
for (antenna = 0; antenna < ru->nb_rx; antenna++) {
for (symbol = 0; symbol < 14; symbol++) {
int i;
uint16_t *p = (uint16_t *)(&s->buffers.ul[antenna][*slot][symbol*1200*4]);
for (i = 0; i < 1200*2; i++) {
p[i] = htons(p[i]);
}
rxdata = &ru->common.rxdataF[antenna][symbol * fp->ofdm_symbol_size];
#if 1
memcpy(rxdata + 2048 - 600,
&s->buffers.ul[antenna][*slot][symbol*1200*4],
600 * 4);
memcpy(rxdata,
&s->buffers.ul[antenna][*slot][symbol*1200*4] + 600*4,
600 * 4);
#endif
}
}
s->buffers.ul_busy[0][*slot] = 0;
s->buffers.ul_busy[1][*slot] = 0;
signal_ul_buffer(&s->buffers, *slot);
unlock_ul_buffer(&s->buffers, *slot);
RU_proc_t *proc = &ru->proc;
extern uint16_t sl_ahead;
int f = *frame;
int sl = *slot;
proc->tti_rx = sl;
proc->frame_rx = f;
proc->timestamp_rx = ((proc->frame_rx * 10) + proc->tti_rx ) * fp->samples_per_tti ;
if (get_nprocs()<=4) {
proc->tti_tx = (sl+sl_ahead)%10;
proc->frame_tx = (sl>(9-sl_ahead)) ? (f+1)&1023 : f;
}
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_IN_RU+ru->idx,f);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_IN_RU+ru->idx,sl);
proc->symbol_mask[sl] = 0;
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff);
#endif
}
void oran_fh_if4p5_south_out(RU_t *ru,
int frame,
int slot,
uint64_t timestamp)
{
#if 0
/*
* Romain:
* Questions:
* -Do we need a lock on the buffer? If yes, how should we implement it?
* -Why is the byte order changed in Benetel? Do we need to do the same?
*/
printf("ORAN: %s for DL. frame=%d, slot=%d, \n", __FUNCTION__,frame,slot);
oran_eth_state_t *s = ru->ifdevice.priv;
PHY_VARS_eNB **eNB_list = ru->eNB_list, *eNB;
LTE_DL_FRAME_PARMS *fp;
int symbol;
int32_t *txdata;
int aa;
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff );
// Romain: Lock on the DL buffer on given slot for avoiding concurrent write
lock_dl_buffer(&s->buffers, slot);
if (s->buffers.dl_busy[0][slot] ||
s->buffers.dl_busy[1][slot]) {
printf("%s: fatal: DL buffer busy for slot %d\n", __FUNCTION__, slot);
unlock_dl_buffer(&s->buffers, slot);
return;
}
// Romain: Configuration check
eNB = eNB_list[0];
fp = &eNB->frame_parms;
if (ru->num_eNB != 1 || fp->ofdm_symbol_size != 2048 ||
fp->Ncp != NORMAL || fp->symbols_per_tti != 14) {
printf("%s:%d:%s: unsupported configuration\n",
__FILE__, __LINE__, __FUNCTION__);
exit(1);
}
// Romain: Loop over antenas and symbols
for (aa = 0; aa < ru->nb_tx; aa++) {
for (symbol = 0; symbol < 14; symbol++) {
// Romain: txdata will hold the data from OAI to send on downlink. How are they presented?
txdata = &ru->common.txdataF_BF[aa][symbol * fp->ofdm_symbol_size];
#if 1
// Romain: For Benetel, '&s->buffers.dl' is the downlink buffer. Should we moove the data as it is done here?
memcpy(&s->buffers.dl[aa][slot][symbol*1200*4],
txdata + 2048 - 600,
600 * 4);
memcpy(&s->buffers.dl[aa][slot][symbol*1200*4] + 600*4,
txdata + 1,
600 * 4);
#endif
// Romain: Change byte order. Why?
int i;
uint16_t *p = (uint16_t *)(&s->buffers.dl[aa][slot][symbol*1200*4]);
for (i = 0; i < 1200*2; i++) {
p[i] = htons(p[i]);
}
}
}
// Romain: Lock on the DL buffer on given slot for avoiding concurrent write
s->buffers.dl_busy[0][slot] = 0x3fff;
s->buffers.dl_busy[1][slot] = 0x3fff;
unlock_dl_buffer(&s->buffers, slot);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_OUT_RU+ru->idx, ru->proc.frame_tx);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_OUT_RU+ru->idx, ru->proc.tti_tx);
#endif
}
void *get_internal_parameter(char *name)
{
printf("ORAN: %s\n", __FUNCTION__);
if (!strcmp(name, "fh_if4p5_south_in"))
return (void *) oran_fh_if4p5_south_in;
if (!strcmp(name, "fh_if4p5_south_out"))
return (void *) oran_fh_if4p5_south_out;
return NULL;
}
__attribute__((__visibility__("default")))
int transport_init(openair0_device *device,
openair0_config_t *openair0_cfg,
eth_params_t * eth_params )
{
oran_eth_state_t *eth;
printf("ORAN: %s\n", __FUNCTION__);
device->Mod_id = 0;
device->transp_type = ETHERNET_TP;
device->trx_start_func = trx_oran_start;
device->trx_get_stats_func = trx_oran_get_stats;
device->trx_reset_stats_func = trx_oran_reset_stats;
device->trx_end_func = trx_oran_end;
device->trx_stop_func = trx_oran_stop;
device->trx_set_freq_func = trx_oran_set_freq;
device->trx_set_gains_func = trx_oran_set_gains;
device->trx_write_func = trx_oran_write_raw;
device->trx_read_func = trx_oran_read_raw;
device->trx_ctlsend_func = trx_oran_ctlsend;
device->trx_ctlrecv_func = trx_oran_ctlrecv;
device->get_internal_parameter = get_internal_parameter;
eth = (oran_eth_state_t *)calloc(1, sizeof(oran_eth_state_t));
if (eth == NULL) {
AssertFatal(0==1, "out of memory\n");
}
eth->e.flags = ETH_RAW_IF4p5_MODE;
eth->e.compression = NO_COMPRESS;
eth->e.if_name = eth_params->local_if_name;
eth->oran_priv = define_oran_pointer();
device->priv = eth;
device->openair0_cfg=&openair0_cfg[0];
eth->last_msg = (rru_config_msg_type_t)-1;
init_buffers(&eth->buffers);
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _ORAN_ISOLATE_H_
#define _ORAN_ISOLATE_H_
#include <stdio.h>
#include "shared_buffers.h"
#include "low_oran.h"
/*
* Structure added to bear the information needed from OAI RU
*/
typedef struct ru_info_s{
// Needed for DL
int nb_tx;
int32_t **txdataF_BF;
// Needed for UL
// TODO
} ru_info_t;
#ifdef __cplusplus
extern "C"
{
#endif
void* define_oran_pointer();
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
int setup_oran( void *xranlib_ );
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
int open_oran_callback( void *xranlib_ );
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
int open_oran( void *xranlib_ );
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
int initialize_oran( void *xranlib_ );
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
int start_oran( void *xranlib_ );
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
int register_physide_callbacks(void *xranlib_);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
int load_iq_from_file(void *xranlib_);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
int xran_fh_tx_send_buffer(void *xranlib_);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
int xran_fh_tx_send_slot(void *xranlib_, ru_info_t *ru, int frame, int slot, uint64_t timestamp);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
int compute_xran_statistics(void *xranlib_);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void check_xran_ptp_sync();
#ifdef __cplusplus
}
#endif
#endif /* _ORAN_ISOLATE_H_ */
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