Commit f5b74a1b authored by Raymond Knopp's avatar Raymond Knopp

added modified sample_app files to FHI driver

parent 1be22b4c
#include <stdio.h>
#include <string.h>
void make_args(char **argv, int *argc, char *string)
{
char tmp[1024]={0x0};
FILE *cmd=NULL;
int i=0;
char *p=NULL;
sprintf(tmp, "set - %s && for i in %c$@%c;\n do\n echo $i\ndone",string, '"', '"');
cmd=popen(tmp, "r");
while (fgets(tmp, sizeof(tmp), cmd)!=NULL)
{
p=strchr(tmp, '\n');
if (p!=NULL) *p=0x0;
argv[i] = malloc(strlen(tmp));
strcpy(argv[i++], tmp);
}
*argc=i;
}
/******************************************************************************
*
* Copyright (c) 2020 Intel.
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* 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.
*
*******************************************************************************/
#include <assert.h>
#include <err.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <time.h>
#include "common.h"
#include "xran_fh_o_du.h"
#include "xran_pkt.h"
#include "xran_pkt_up.h"
#include "xran_cp_api.h"
#include "xran_up_api.h"
#include "xran_mlog_lnx.h"
extern enum app_state state;
int iq_playback_buffer_size_dl = IQ_PLAYBACK_BUFFER_BYTES;
int iq_playback_buffer_size_ul = IQ_PLAYBACK_BUFFER_BYTES;
int iq_bfw_buffer_size_dl = IQ_PLAYBACK_BUFFER_BYTES;
int iq_bfw_buffer_size_ul = IQ_PLAYBACK_BUFFER_BYTES;
int iq_srs_buffer_size_ul = IQ_PLAYBACK_BUFFER_BYTES;
uint8_t numCCPorts = 1;
/* Number of antennas supported by front-end */
uint8_t num_eAxc = 4;
/* Number of CPRI ports supported by front-end */
int16_t *p_tx_play_buffer[MAX_ANT_CARRIER_SUPPORTED];
int32_t tx_play_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
int32_t tx_play_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
int16_t *p_tx_prach_play_buffer[MAX_ANT_CARRIER_SUPPORTED];
int32_t tx_prach_play_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
int32_t tx_prach_play_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
int16_t *p_tx_srs_play_buffer[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
int32_t tx_srs_play_buffer_size[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
int32_t tx_srs_play_buffer_position[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
int16_t *p_rx_log_buffer[MAX_ANT_CARRIER_SUPPORTED];
int32_t rx_log_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
int32_t rx_log_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
int16_t *p_prach_log_buffer[MAX_ANT_CARRIER_SUPPORTED];
int32_t prach_log_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
int32_t prach_log_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
int16_t *p_srs_log_buffer[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
int32_t srs_log_buffer_size[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
int32_t srs_log_buffer_position[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
int16_t *p_tx_buffer[MAX_ANT_CARRIER_SUPPORTED];
int32_t tx_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
int16_t *p_rx_buffer[MAX_ANT_CARRIER_SUPPORTED];
int32_t rx_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
/* beamforming weights for UL (O-DU) */
int16_t *p_tx_dl_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
int32_t tx_dl_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
int32_t tx_dl_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
/* beamforming weights for UL (O-DU) */
int16_t *p_tx_ul_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
int32_t tx_ul_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
int32_t tx_ul_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
/* beamforming weights for UL (O-RU) */
int16_t *p_rx_dl_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
int32_t rx_dl_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
int32_t rx_dl_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
/* beamforming weights for UL (O-RU) */
int16_t *p_rx_ul_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
int32_t rx_ul_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
int32_t rx_ul_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
// F1 Tables 38.101-1 Table 5.3.2-1. Maximum transmission bandwidth configuration NRB
uint16_t nLteNumRbsPerSymF1[1][4] =
{
// 5MHz 10MHz 15MHz 20 MHz
{25, 50, 75, 100}, // Numerology 0 (15KHz)
};
// F1 Tables 38.101-1 Table 5.3.2-1. Maximum transmission bandwidth configuration NRB
uint16_t nNumRbsPerSymF1[3][13] =
{
// 5MHz 10MHz 15MHz 20 MHz 25 MHz 30 MHz 40 MHz 50MHz 60 MHz 70 MHz 80 MHz 90 MHz 100 MHz
{25, 52, 79, 106, 133, 160, 216, 270, 0, 0, 0, 0, 0}, // Numerology 0 (15KHz)
{11, 24, 38, 51, 65, 78, 106, 133, 162, 0, 217, 245, 273}, // Numerology 1 (30KHz)
{0, 11, 18, 24, 31, 38, 51, 65, 79, 0, 107, 121, 135} // Numerology 2 (60KHz)
};
// F2 Tables 38.101-2 Table 5.3.2-1. Maximum transmission bandwidth configuration NRB
uint16_t nNumRbsPerSymF2[2][4] =
{
// 50Mhz 100MHz 200MHz 400MHz
{66, 132, 264, 0}, // Numerology 2 (60KHz)
{32, 66, 132, 264} // Numerology 3 (120KHz)
};
// 38.211 - Table 4.2.1
uint16_t nSubCarrierSpacing[5] =
{
15, // mu = 0
30, // mu = 1
60, // mu = 2
120, // mu = 3
240 // mu = 4
};
// TTI interval in us (slot duration)
uint16_t nTtiInterval[4] =
{
1000, // mu = 0
500, // mu = 1
250, // mu = 2
125, // mu = 3
};
// F1 Tables 38.101-1 Table F.5.3. Window length for normal CP
uint16_t nCpSizeF1[3][13][2] =
{
// 5MHz 10MHz 15MHz 20 MHz 25 MHz 30 MHz 40 MHz 50MHz 60 MHz 70 MHz 80 MHz 90 MHz 100 MHz
{{40, 36}, {80, 72}, {120, 108}, {160, 144}, {160, 144}, {240, 216}, {320, 288}, {320, 288}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, // Numerology 0 (15KHz)
{{22, 18}, {44, 36}, {66, 54}, {88, 72}, {88, 72}, {132, 108}, {176, 144}, {176, 144}, {264, 216}, {264, 216}, {352, 288}, {352, 288}, {352, 288}}, // Numerology 1 (30KHz)
{ {0, 0}, {26, 18}, {39, 27}, {52, 36}, {52, 36}, {78, 54}, {104, 72}, {104, 72}, {156, 108}, {156, 108}, {208, 144}, {208, 144}, {208, 144}}, // Numerology 2 (60KHz)
};
// F2 Tables 38.101-2 Table F.5.3. Window length for normal CP
int16_t nCpSizeF2[2][4][2] =
{
// 50Mhz 100MHz 200MHz 400MHz
{ {0, 0}, {104, 72}, {208, 144}, {416, 288}}, // Numerology 2 (60KHz)
{{68, 36}, {136, 72}, {272, 144}, {544, 288}}, // Numerology 3 (120KHz)
};
uint32_t gMaxSlotNum;
uint32_t gNumDLCtx;
uint32_t gNumULCtx;
uint32_t gDLResetAdvance;
uint32_t gDLProcAdvance;
uint32_t gULProcAdvance;
static uint16_t g_NumSlotTDDLoop[XRAN_MAX_SECTOR_NR] = { XRAN_NUM_OF_SLOT_IN_TDD_LOOP };
static uint16_t g_NumDLSymSp[XRAN_MAX_SECTOR_NR][XRAN_NUM_OF_SLOT_IN_TDD_LOOP] = {0};
static uint16_t g_NumULSymSp[XRAN_MAX_SECTOR_NR][XRAN_NUM_OF_SLOT_IN_TDD_LOOP] = {0};
static uint8_t g_SlotType[XRAN_MAX_SECTOR_NR][XRAN_NUM_OF_SLOT_IN_TDD_LOOP] = {{XRAN_SLOT_TYPE_INVALID}};
float g_UlRate[XRAN_MAX_SECTOR_NR] = {0.0};
float g_DlRate[XRAN_MAX_SECTOR_NR] = {0.0};
uint32_t app_xran_get_tti_interval(uint8_t nMu)
{
if (nMu < 4)
{
return nTtiInterval[nMu];
}
else
{
printf("ERROR: %s Mu[%d] is not valid\n",__FUNCTION__, nMu);
}
return 0;
}
uint32_t app_xran_get_scs(uint8_t nMu)
{
if (nMu <= 3)
{
return nSubCarrierSpacing[nMu];
}
else
{
printf("ERROR: %s Mu[%d] is not valid\n",__FUNCTION__, nMu);
}
return 0;
}
//-------------------------------------------------------------------------------------------
/** @ingroup group_nr5g_source_phy_common
*
* @param[in] nNumerology - Numerology determine sub carrier spacing, Value: 0->4 0: 15khz, 1: 30khz, 2: 60khz 3: 120khz, 4: 240khz
* @param[in] nBandwidth - Carrier bandwidth for in MHz. Value: 5->400
* @param[in] nAbsFrePointA - Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000
*
* @return Number of RBs in cell
*
* @description
* Returns number of RBs based on 38.101-1 and 38.101-2 for the cell
*
**/
//-------------------------------------------------------------------------------------------
uint16_t app_xran_get_num_rbs(uint8_t ranTech, uint32_t nNumerology, uint32_t nBandwidth, uint32_t nAbsFrePointA)
{
uint32_t error = 1;
uint16_t numRBs = 0;
if (ranTech == XRAN_RAN_LTE) {
switch(nBandwidth)
{
case PHY_BW_5_0_MHZ:
numRBs = nLteNumRbsPerSymF1[nNumerology][0];
error = 0;
break;
case PHY_BW_10_0_MHZ:
numRBs = nLteNumRbsPerSymF1[nNumerology][1];
error = 0;
break;
case PHY_BW_15_0_MHZ:
numRBs = nLteNumRbsPerSymF1[nNumerology][2];
error = 0;
break;
case PHY_BW_20_0_MHZ:
numRBs = nLteNumRbsPerSymF1[nNumerology][3];
error = 0;
break;
default:
error = 1;
break;
}
} else if (nAbsFrePointA <= 6000000) {
// F1 Tables 38.101-1 Table 5.3.2-1. Maximum transmission bandwidth configuration NRB
if (nNumerology < 3)
{
switch(nBandwidth)
{
case PHY_BW_5_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][0];
error = 0;
break;
case PHY_BW_10_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][1];
error = 0;
break;
case PHY_BW_15_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][2];
error = 0;
break;
case PHY_BW_20_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][3];
error = 0;
break;
case PHY_BW_25_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][4];
error = 0;
break;
case PHY_BW_30_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][5];
error = 0;
break;
case PHY_BW_40_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][6];
error = 0;
break;
case PHY_BW_50_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][7];
error = 0;
break;
case PHY_BW_60_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][8];
error = 0;
break;
case PHY_BW_70_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][9];
error = 0;
break;
case PHY_BW_80_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][10];
error = 0;
break;
case PHY_BW_90_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][11];
error = 0;
break;
case PHY_BW_100_0_MHZ:
numRBs = nNumRbsPerSymF1[nNumerology][12];
error = 0;
break;
default:
error = 1;
break;
}
}
}
else
{
if ((nNumerology >= 2) && (nNumerology <= 3))
{
// F2 Tables 38.101-2 Table 5.3.2-1. Maximum transmission bandwidth configuration NRB
switch(nBandwidth)
{
case PHY_BW_50_0_MHZ:
numRBs = nNumRbsPerSymF2[nNumerology-2][0];
error = 0;
break;
case PHY_BW_100_0_MHZ:
numRBs = nNumRbsPerSymF2[nNumerology-2][1];
error = 0;
break;
case PHY_BW_200_0_MHZ:
numRBs = nNumRbsPerSymF2[nNumerology-2][2];
error = 0;
break;
case PHY_BW_400_0_MHZ:
numRBs = nNumRbsPerSymF2[nNumerology-2][3];
error = 0;
break;
default:
error = 1;
break;
}
}
}
if (error)
{
printf("ERROR: %s: RAN[%s] nNumerology[%d] nBandwidth[%d] nAbsFrePointA[%d]\n",__FUNCTION__, (ranTech ? "LTE" : "5G NR"), nNumerology, nBandwidth, nAbsFrePointA);
}
else
{
printf("%s: RAN [%s] nNumerology[%d] nBandwidth[%d] nAbsFrePointA[%d] numRBs[%d]\n",__FUNCTION__, (ranTech ? "LTE" : "5G NR"), nNumerology, nBandwidth, nAbsFrePointA, numRBs);
}
return numRBs;
}
//-------------------------------------------------------------------------------------------
/** @ingroup phy_cal_nrarfcn
*
* @param[in] center frequency
*
* @return NR-ARFCN
*
* @description
* This calculates NR-ARFCN value according to center frequency
*
**/
//-------------------------------------------------------------------------------------------
uint32_t app_xran_cal_nrarfcn(uint32_t nCenterFreq)
{
uint32_t nDeltaFglobal,nFoffs,nNoffs;
uint32_t nNRARFCN = 0;
if(nCenterFreq > 0 && nCenterFreq < 3000*1000)
{
nDeltaFglobal = 5;
nFoffs = 0;
nNoffs = 0;
}
else if(nCenterFreq >= 3000*1000 && nCenterFreq < 24250*1000)
{
nDeltaFglobal = 15;
nFoffs = 3000*1000;
nNoffs = 600000;
}
else if(nCenterFreq >= 24250*1000 && nCenterFreq <= 100000*1000)
{
nDeltaFglobal = 60;
nFoffs = 24250080;
nNoffs = 2016667;
}
else
{
printf("@@@@ incorrect center frerquency %d\n",nCenterFreq);
return (0);
}
nNRARFCN = ((nCenterFreq - nFoffs)/nDeltaFglobal) + nNoffs;
printf("%s: nCenterFreq[%d] nDeltaFglobal[%d] nFoffs[%d] nNoffs[%d] nNRARFCN[%d]\n", __FUNCTION__, nCenterFreq, nDeltaFglobal, nFoffs, nNoffs, nNRARFCN);
return (nNRARFCN);
}
int32_t app_xran_slot_limit(int32_t nSfIdx)
{
while (nSfIdx < 0) {
nSfIdx += gMaxSlotNum;
}
while (nSfIdx >= gMaxSlotNum) {
nSfIdx -= gMaxSlotNum;
}
return nSfIdx;
}
void app_xran_clear_slot_type(uint32_t nPhyInstanceId)
{
g_UlRate[nPhyInstanceId] = 0.0;
g_DlRate[nPhyInstanceId] = 0.0;
g_NumSlotTDDLoop[nPhyInstanceId] = 1;
}
int32_t app_xran_set_slot_type(uint32_t nPhyInstanceId, uint32_t nFrameDuplexType, uint32_t nTddPeriod, struct xran_slot_config *psSlotConfig)
{
uint32_t nSlotNum, nSymNum, nVal, i;
uint32_t numDlSym, numUlSym, numGuardSym;
uint32_t numDlSlots = 0, numUlSlots = 0, numSpDlSlots = 0, numSpUlSlots = 0, numSpSlots = 0;
char sSlotPattern[XRAN_SLOT_TYPE_LAST][10] = {"IN\0", "DL\0", "UL\0", "SP\0", "FD\0"};
// nPhyInstanceId Carrier ID
// nFrameDuplexType 0 = FDD 1 = TDD
// nTddPeriod Tdd Periodicity
// psSlotConfig[80] Slot Config Structure for nTddPeriod Slots
g_UlRate[nPhyInstanceId] = 0.0;
g_DlRate[nPhyInstanceId] = 0.0;
g_NumSlotTDDLoop[nPhyInstanceId] = nTddPeriod;
for (i = 0; i < XRAN_NUM_OF_SLOT_IN_TDD_LOOP; i++)
{
g_SlotType[nPhyInstanceId][i] = XRAN_SLOT_TYPE_INVALID;
g_NumDLSymSp[nPhyInstanceId][i] = 0;
g_NumULSymSp[nPhyInstanceId][i] = 0;
}
if (nFrameDuplexType == XRAN_FDD)
{
for (i = 0; i < XRAN_NUM_OF_SLOT_IN_TDD_LOOP; i++)
{
g_SlotType[nPhyInstanceId][i] = XRAN_SLOT_TYPE_FDD;
}
g_NumSlotTDDLoop[nPhyInstanceId] = 1;
g_DlRate[nPhyInstanceId] = 1.0;
g_UlRate[nPhyInstanceId] = 1.0;
}
else
{
for (nSlotNum = 0; nSlotNum < nTddPeriod; nSlotNum++)
{
numDlSym = 0;
numUlSym = 0;
numGuardSym = 0;
for (nSymNum = 0; nSymNum < XRAN_NUM_OF_SYMBOL_PER_SLOT; nSymNum++)
{
switch(psSlotConfig[nSlotNum].nSymbolType[nSymNum])
{
case XRAN_SYMBOL_TYPE_DL:
numDlSym++;
break;
case XRAN_SYMBOL_TYPE_GUARD:
numGuardSym++;
break;
default:
numUlSym++;
break;
}
}
// printf("nSlotNum[%d] : numDlSym[%d] numGuardSym[%d] numUlSym[%d]\n", nSlotNum, numDlSym, numGuardSym, numUlSym);
if ((numUlSym == 0) && (numGuardSym == 0))
{
g_SlotType[nPhyInstanceId][nSlotNum] = XRAN_SLOT_TYPE_DL;
numDlSlots++;
}
else if ((numDlSym == 0) && (numGuardSym == 0))
{
g_SlotType[nPhyInstanceId][nSlotNum] = XRAN_SLOT_TYPE_UL;
numUlSlots++;
}
else
{
g_SlotType[nPhyInstanceId][nSlotNum] = XRAN_SLOT_TYPE_SP;
numSpSlots++;
if (numDlSym)
{
numSpDlSlots++;
g_NumDLSymSp[nPhyInstanceId][nSlotNum] = numDlSym;
}
if (numUlSym)
{
numSpUlSlots++;
g_NumULSymSp[nPhyInstanceId][nSlotNum] = numUlSym;
}
}
// printf(" numDlSlots[%d] numUlSlots[%d] numSpSlots[%d] numSpDlSlots[%d] numSpUlSlots[%d]\n", numDlSlots, numUlSlots, numSpSlots, numSpDlSlots, numSpUlSlots);
}
g_DlRate[nPhyInstanceId] = (float)(numDlSlots + numSpDlSlots) / (float)nTddPeriod;
g_UlRate[nPhyInstanceId] = (float)(numUlSlots + numSpUlSlots) / (float)nTddPeriod;
}
printf("set_slot_type: nPhyInstanceId[%d] nFrameDuplexType[%d], nTddPeriod[%d]\n",
nPhyInstanceId, nFrameDuplexType, nTddPeriod);
printf("DLRate[%f] ULRate[%f]\n", g_DlRate[nPhyInstanceId], g_UlRate[nPhyInstanceId]);
nVal = (g_NumSlotTDDLoop[nPhyInstanceId] < 10) ? g_NumSlotTDDLoop[nPhyInstanceId] : 10;
printf("SlotPattern:\n");
printf("Slot: ");
for (nSlotNum = 0; nSlotNum < nVal; nSlotNum++)
{
printf("%d ", nSlotNum);
}
printf("\n");
printf(" %3d ", 0);
for (nSlotNum = 0, i = 0; nSlotNum < g_NumSlotTDDLoop[nPhyInstanceId]; nSlotNum++)
{
printf("%s ", sSlotPattern[g_SlotType[nPhyInstanceId][nSlotNum]]);
i++;
if ((i == 10) && ((nSlotNum+1) < g_NumSlotTDDLoop[nPhyInstanceId]))
{
printf("\n");
printf(" %3d ", nSlotNum);
i = 0;
}
}
printf("\n\n");
return 0;
}
int32_t app_xran_get_slot_type(int32_t nCellIdx, int32_t nSlotdx, int32_t nType)
{
int32_t nSfIdxMod, nSfType, ret = 0;
nSfIdxMod = app_xran_slot_limit(nSlotdx) % ((g_NumSlotTDDLoop[nCellIdx] > 0) ? g_NumSlotTDDLoop[nCellIdx]: 1);
nSfType = g_SlotType[nCellIdx][nSfIdxMod];
if (nSfType == nType)
{
ret = 1;
}
else if (nSfType == XRAN_SLOT_TYPE_SP)
{
if ((nType == XRAN_SLOT_TYPE_DL) && g_NumDLSymSp[nCellIdx][nSfIdxMod])
{
ret = 1;
}
if ((nType == XRAN_SLOT_TYPE_UL) && g_NumULSymSp[nCellIdx][nSfIdxMod])
{
ret = 1;
}
}
else if (nSfType == XRAN_SLOT_TYPE_FDD)
{
ret = 1;
}
return ret;
}
void sys_save_buf_to_file(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num)
{
if (size)
{
if (filename && bufname)
{
FILE *file;
printf("Storing %s to file %s: ", bufname, filename);
file = fopen(filename, "wb");
if (file == NULL)
{
printf("can't open file %s!!!", filename);
}
else
{
uint32_t num;
num = fwrite(pBuffer, buffers_num, size, file);
fflush(file);
fclose(file);
printf("from addr (0x%lx) size (%d) bytes num (%d)", (uint64_t)pBuffer, 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);
}
}
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 sys_save_buf_to_file_txt(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num)
{
unsigned int i;
int ret = 0;
if (pBuffer == NULL)
return;
if (size)
{
if (filename && bufname)
{
FILE *file;
printf("Storing %s to file %s: ", bufname, filename);
file = fopen(filename, "w");
if (file == NULL)
{
printf("can't open file %s!!!", filename);
exit(-1);
}
else
{
uint32_t num = 0;
signed short *ptr = (signed short*)pBuffer;
for (i = 0; i < (size/((unsigned int)sizeof(signed short) /** 2 * 2 * 2*/)); i = i + 2)
{
#ifndef CSCOPE_DEBUG
ret = fprintf(file,"%d %d\n", ptr[i], ptr[i + 1]);
#else
ret = fprintf(file,"%d %d ", ptr[i], ptr[i + 1]);
/* I data => Ramp data, from 1 to 792.
Q data => Contains time information of the current symbol:
Bits [15:14] = Antenna-ID
Bits [13:12] = 00
Bits [11:8] = Subframe-ID
Bits [7:4] = Slot-ID
Bits [3:0] = Symbol-ID */
fprintf(file, "0x%04x: ant %d Subframe-ID %d Slot-ID %d Symbol-ID %d\n",
ptr[i + 1], (ptr[i + 1]>>14) & 0x3, (ptr[i + 1]>>8) & 0xF, (ptr[i + 1]>>4) & 0xF, (ptr[i + 1]>>0) & 0xF);
#endif
if (ret < 0)
{
printf("fprintf %d\n", ret);
fclose(file);
break;
}
num++;
}
fflush(file);
fclose(file);
printf("from addr (0x%lx) size (%d) IQ num (%d)", (uint64_t)pBuffer, 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);
}
}
/******************************************************************************
*
* Copyright (c) 2020 Intel.
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* 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.
*
*******************************************************************************/
#ifndef _XRAN_APP_COMMON_H_
#define _XRAN_APP_COMMON_H_
#include <stdio.h>
#include <unistd.h>
#include "xran_fh_o_du.h"
#include "xran_pkt_up.h"
#include <rte_common.h>
#include <rte_mbuf.h>
#define VERSIONX "oran_bronze_release_v1.1"
#define APP_O_DU 0
#define APP_O_RU 1
enum app_state
{
APP_RUNNING,
APP_STOPPED
};
enum nRChBwOptions
{
PHY_BW_5_0_MHZ = 5, PHY_BW_10_0_MHZ = 10, PHY_BW_15_0_MHZ = 15, PHY_BW_20_0_MHZ = 20, PHY_BW_25_0_MHZ = 25,
PHY_BW_30_0_MHZ = 30, PHY_BW_40_0_MHZ = 40, PHY_BW_50_0_MHZ = 50, PHY_BW_60_0_MHZ = 60, PHY_BW_70_0_MHZ = 70,
PHY_BW_80_0_MHZ = 80, PHY_BW_90_0_MHZ = 90, PHY_BW_100_0_MHZ = 100, PHY_BW_200_0_MHZ = 200, PHY_BW_400_0_MHZ = 400
};
#define N_SC_PER_PRB 12
#define N_SYM_PER_SLOT 14
#define MAX_ANT_CARRIER_SUPPORTED (XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR)
#define MAX_ANT_CARRIER_SUPPORTED_CAT_B (XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR)
#define SUBFRAME_DURATION_US 1000
//#define SLOTNUM_PER_SUBFRAME 8
#define SUBFRAMES_PER_SYSTEMFRAME 10
#define IQ_PLAYBACK_BUFFER_BYTES (XRAN_NUM_OF_SLOT_IN_TDD_LOOP*N_SYM_PER_SLOT*XRAN_MAX_PRBS*N_SC_PER_PRB*4L)
/* PRACH data samples are 32 bits wide, 16bits for I and 16bits for Q. Each packet contains 839 samples for long sequence or 144*14 (max) for short sequence. The payload length is 3356 octets.*/
#define PRACH_PLAYBACK_BUFFER_BYTES (144*14*4L)
#ifdef _DEBUG
#define iAssert(p) if(!(p)){fprintf(stderr,\
"Assertion failed: %s, file %s, line %d, val %d\n",\
#p, __FILE__, __LINE__, p);exit(-1);}
#else /* _DEBUG */
#define iAssert(p)
#endif /* _DEBUG */
extern int iq_playback_buffer_size_dl;
extern int iq_playback_buffer_size_ul;
extern int iq_bfw_buffer_size_dl;
extern int iq_bfw_buffer_size_ul;
extern int iq_srs_buffer_size_ul;
extern uint8_t numCCPorts;
/* Number of antennas supported by front-end */
extern uint8_t num_eAxc;
/* Number of antennas supported by front-end */
extern int16_t *p_tx_play_buffer[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t tx_play_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t tx_play_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
extern int16_t *p_tx_prach_play_buffer[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t tx_prach_play_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t tx_prach_play_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
extern int16_t *p_tx_srs_play_buffer[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
extern int32_t tx_srs_play_buffer_size[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
extern int32_t tx_srs_play_buffer_position[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
/* Number of antennas supported by front-end */
extern int16_t *p_rx_log_buffer[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t rx_log_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t rx_log_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
extern int16_t *p_prach_log_buffer[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t prach_log_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t prach_log_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
extern int16_t *p_srs_log_buffer[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
extern int32_t srs_log_buffer_size[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
extern int32_t srs_log_buffer_position[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR];
extern int16_t *p_tx_buffer[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t tx_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
extern int16_t *p_rx_buffer[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t rx_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
/* beamforming weights for UL (O-DU) */
extern int16_t *p_tx_dl_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t tx_dl_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t tx_dl_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
/* beamforming weights for UL (O-DU) */
extern int16_t *p_tx_ul_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t tx_ul_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t tx_ul_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
/* beamforming weights for UL (O-RU) */
extern int16_t *p_rx_dl_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t rx_dl_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t rx_dl_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
/* beamforming weights for UL (O-RU) */
extern int16_t *p_rx_ul_bfw_buffer[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t rx_ul_bfw_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
extern int32_t rx_ul_bfw_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
void sys_save_buf_to_file_txt(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num);
void sys_save_buf_to_file(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num);
int sys_load_file_to_buff(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num);
uint32_t app_xran_get_scs(uint8_t nMu);
uint16_t app_xran_get_num_rbs(uint8_t ranTech, uint32_t nNumerology, uint32_t nBandwidth, uint32_t nAbsFrePointA);
uint32_t app_xran_cal_nrarfcn(uint32_t nCenterFreq);
int32_t app_xran_set_slot_type(uint32_t nPhyInstanceId, uint32_t nFrameDuplexType,
uint32_t nTddPeriod, struct xran_slot_config *psSlotConfig);
uint32_t app_xran_get_tti_interval(uint8_t nMu);
#endif /*_XRAN_APP_COMMON_H_*/
/******************************************************************************
*
* Copyright (c) 2020 Intel.
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* 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.
*
*******************************************************************************/
/**
* @brief
* @file
* @ingroup
* @author Intel Corporation
**/
#include "rte_common.h"
#include "config.h"
#include "common.h"
#include "debug.h"
#include <rte_ethdev.h>
#define MAX_LINE_SIZE 512
/* Configuration file maximum supported line length */
#define KEY_APP_MODE "appMode"
#define KEY_XRAN_MODE "xranMode"
#define KEY_XRAN_TECH "xranRanTech"
#define KEY_MU_NUMBER "mu"
#define KEY_NDLABSFREPOINTA "nDLAbsFrePointA"
#define KEY_NULABSFREPOINTA "nULAbsFrePointA"
#define KEY_NDLBANDWIDTH "nDLBandwidth"
#define KEY_NULBANDWIDTH "nULBandwidth"
#define KEY_NDLFFTSIZE "nDLFftSize"
#define KEY_NULFFTSIZE "nULFftSize"
#define KEY_DU_PORT_ID_BITWIDTH "DU_Port_ID_bitwidth"
#define KEY_BANDSECTOR_ID_BITWIDTH "BandSector_ID_bitwidth"
#define KEY_CC_ID_BITWIDTH "CC_ID_bitwidth"
#define KEY_RU_PORT_ID_BITWIDTH "RU_Port_ID_bitwidth"
#define KEY_NFRAMEDUPLEXTYPE "nFrameDuplexType"
#define KEY_NTDDPERIOD "nTddPeriod"
#define KEY_SSLOTCONFIG "sSlotConfig"
#define KEY_CC_PER_PORT_NUM "ccNum"
#define KEY_ANT_NUM "antNum"
#define KEY_UL_ANT_NUM "antNumUL"
#define KEY_ANT_ELM_TRX_NUM "antElmTRx"
#define KEY_MU_MIMO_UES_NUM "muMimoUEs"
#define KEY_DLLAYERS_PER_UE "DlLayersPerUe"
#define KEY_ULLAYERS_PER_UE "UlLayersPerUe"
#define KEY_FILE_DLBFWUE "DlBfwUe"
#define KEY_FILE_ULBFWUE "UlBfwUe"
#define KEY_FILE_ULSRS "antSrsC"
#define KEY_TTI_PERIOD "ttiPeriod"
#define KEY_MTU_SIZE "MTUSize"
#define KEY_IO_CORE "ioCore"
#define KEY_IO_WORKER "ioWorker"
#define KEY_IO_SLEEP "ioSleep"
#define KEY_SYSTEM_CORE "systemCore"
#define KEY_IOVA_MODE "iovaMode"
#define KEY_INSTANCE_ID "instanceId"
#define KEY_DU_MAC "duMac"
#define KEY_RU_MAC "ruMac"
#define KEY_FILE_NUMSLOTS "numSlots"
#define KEY_FILE_AxC "antC"
#define KEY_FILE_PRACH_AxC "antPrachC"
#define KEY_PRACH_ENABLE "rachEanble"
#define KEY_SRS_ENABLE "srsEanble"
#define KEY_PRACH_CFGIDX "prachConfigIndex"
#define KEY_SRS_SYM_IDX "srsSym"
#define KEY_MAX_FRAME_ID "maxFrameId"
#define KEY_IQ_SWAP "iqswap"
#define KEY_HTONS_SWAP "nebyteorderswap"
#define KEY_COMPRESSION "compression"
#define KEY_COMP_TYPE "compType"
#define KEY_BFW_NUM "totalBFWeights"
#define KEY_TADV_CP_DL "Tadv_cp_dl"
#define KEY_T2A_MIN_CP_DL "T2a_min_cp_dl"
#define KEY_T2A_MAX_CP_DL "T2a_max_cp_dl"
#define KEY_T2A_MIN_CP_UL "T2a_min_cp_ul"
#define KEY_T2A_MAX_CP_UL "T2a_max_cp_ul"
#define KEY_T2A_MIN_UP "T2a_min_up"
#define KEY_T2A_MAX_UP "T2a_max_up"
#define KEY_TA3_MIN "Ta3_min"
#define KEY_TA3_MAX "Ta3_max"
#define KEY_T1A_MIN_CP_DL "T1a_min_cp_dl"
#define KEY_T1A_MAX_CP_DL "T1a_max_cp_dl"
#define KEY_T1A_MIN_CP_UL "T1a_min_cp_ul"
#define KEY_T1A_MAX_CP_UL "T1a_max_cp_ul"
#define KEY_T1A_MIN_UP "T1a_min_up"
#define KEY_T1A_MAX_UP "T1a_max_up"
#define KEY_TA4_MIN "Ta4_min"
#define KEY_TA4_MAX "Ta4_max"
#define KEY_CP_ENABLE "CPenable"
#define KEY_CP_VTAG "c_plane_vlan_tag"
#define KEY_UP_VTAG "u_plane_vlan_tag"
#define KEY_DEBUG_STOP "debugStop"
#define KEY_DEBUG_STOP_CNT "debugStopCount"
#define KEY_BBDEV_MODE "bbdevMode"
#define KEY_DYNA_SEC_ENA "DynamicSectionEna"
#define KEY_ALPHA "Gps_Alpha"
#define KEY_BETA "Gps_Beta"
#define KEY_NPRBELEM_DL "nPrbElemDl"
#define KEY_PRBELEM_DL "PrbElemDl"
#define KEY_NPRBELEM_UL "nPrbElemUl"
#define KEY_PRBELEM_UL "PrbElemUl"
/**
* Set runtime configuration parameters to their defaults.
*
* @todo Initialize missing parameters.
*/
static void init_config(RuntimeConfig* config)
{
memset(config , 0, sizeof(RuntimeConfig));
}
/** - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - **/
static void trim(char* input)
{
uint32_t i;
for (i = 0; i<strlen(input); i++)
if (input[i] == ' ' || input[i] == '\n' || input[i] == '\t')
input[i] = '\0';
}
static int fillConfigStruct(RuntimeConfig *config, const char *key, const char *value)
{
int32_t parse_res = 0;
static unsigned int section_idx_dl = 0, section_idx_ul;
if (strcmp(key, KEY_APP_MODE) == 0){
config->appMode = atoi(value);
} else if (strcmp(key, KEY_XRAN_TECH) == 0) {
config->xranTech = atoi(value);
} else if (strcmp(key, KEY_XRAN_MODE) == 0) {
config->xranCat = atoi(value);
} else if (strcmp(key, KEY_CC_PER_PORT_NUM) == 0) {
config->numCC= atoi(value);
} else if (strcmp(key, KEY_MU_NUMBER) == 0) {
config->mu_number= atoi(value);
printf("mu_number: %d\n",config->mu_number);
} else if (strcmp(key, KEY_NDLABSFREPOINTA) == 0) {
config->nDLAbsFrePointA = atoi(value);
printf("nDLAbsFrePointA: %d\n",config->nDLAbsFrePointA);
} else if (strcmp(key, KEY_NULABSFREPOINTA) == 0) {
config->nULAbsFrePointA = atoi(value);
printf("nULAbsFrePointA: %d\n",config->nULAbsFrePointA);
} else if (strcmp(key, KEY_NDLBANDWIDTH) == 0) {
config->nDLBandwidth = atoi(value);
printf("nDLBandwidth: %d\n",config->nDLBandwidth);
} else if (strcmp(key, KEY_NULBANDWIDTH) == 0) {
config->nULBandwidth = atoi(value);
printf("nULBandwidth: %d\n",config->nULBandwidth);
} else if (strcmp(key, KEY_NDLFFTSIZE) == 0) {
config->nDLFftSize = atoi(value);
printf("nDLFftSize: %d\n",config->nDLFftSize);
} else if (strcmp(key, KEY_NULFFTSIZE) == 0) {
config->nULFftSize = atoi(value);
printf("nULFftSize: %d\n",config->nULFftSize);
} else if (strcmp(key, KEY_NFRAMEDUPLEXTYPE) == 0) {
config->nFrameDuplexType = atoi(value);
printf("nFrameDuplexType: %d\n",config->nFrameDuplexType);
} else if (strcmp(key, KEY_DU_PORT_ID_BITWIDTH) == 0) {
config->DU_Port_ID_bitwidth = atoi(value);
printf("DU_Port_ID_bitwidth: %d\n",config->DU_Port_ID_bitwidth);
} else if (strcmp(key, KEY_BANDSECTOR_ID_BITWIDTH) == 0) {
config->BandSector_ID_bitwidth = atoi(value);
printf("BandSector_ID_bitwidth: %d\n",config->BandSector_ID_bitwidth);
} else if (strcmp(key, KEY_CC_ID_BITWIDTH) == 0) {
config->CC_ID_bitwidth = atoi(value);
printf("CC_ID_bitwidth: %d\n",config->CC_ID_bitwidth);
} else if (strcmp(key, KEY_RU_PORT_ID_BITWIDTH) == 0) {
config->RU_Port_ID_bitwidth = atoi(value);
printf("RU_Port_ID_bitwidth: %d\n",config->RU_Port_ID_bitwidth);
} else if (strcmp(key, KEY_NTDDPERIOD) == 0) {
config->nTddPeriod = atoi(value);
printf("nTddPeriod: %d\n",config->nTddPeriod);
if (config->nTddPeriod > XRAN_MAX_TDD_PERIODICITY)
{
printf("nTddPeriod is larger than max allowed, invalid!\n");
config->nTddPeriod = XRAN_MAX_TDD_PERIODICITY;
}
} else if (strncmp(key, KEY_SSLOTCONFIG, strlen(KEY_SSLOTCONFIG)) == 0) {
unsigned int slot_num = 0;
int i = 0;
sscanf(key,"sSlotConfig%u",&slot_num);
if (slot_num >= config->nTddPeriod){
printf("slot_num %d exceeds TddPeriod\n",slot_num);
}
else{
sscanf(value, "%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx,%02hhx",
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[0],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[1],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[2],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[3],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[4],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[5],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[6],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[7],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[8],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[9],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[10],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[11],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[12],
(uint8_t *)&config->sSlotConfig[slot_num].nSymbolType[13]);
printf("sSlotConfig%d: ",slot_num);
for (i = 0; i< 14; i++){
printf("%d ",config->sSlotConfig[slot_num].nSymbolType[i]);
}
printf("\n");
}
} else if (strcmp(key, KEY_ANT_NUM) == 0) {
config->numAxc = atoi(value);
} else if (strcmp(key, KEY_UL_ANT_NUM) == 0) {
config->numUlAxc = atoi(value);
}else if (strcmp(key, KEY_ANT_ELM_TRX_NUM) == 0) {
config->antElmTRx = atoi(value);
printf("antElmTRx %d\n", config->antElmTRx);
} else if (strcmp(key, KEY_MU_MIMO_UES_NUM) == 0) {
config->muMimoUEs = atoi(value);
} else if (strcmp(key, KEY_DLLAYERS_PER_UE) == 0) {
config->DlLayersPerUe = atoi(value);
} else if (strcmp(key, KEY_ULLAYERS_PER_UE) == 0) {
config->UlLayersPerUe = atoi(value);
} else if (strcmp(key, KEY_TTI_PERIOD) == 0) {
config->ttiPeriod = atoi(value);
} else if (strcmp(key, KEY_IQ_SWAP) == 0) {
config->iqswap = atoi(value);
} else if (strcmp(key, KEY_HTONS_SWAP) == 0) {
config->nebyteorderswap = atoi(value);
} else if (strcmp(key, KEY_COMPRESSION) == 0) {
config->compression = atoi(value);
} else if (strcmp(key, KEY_COMP_TYPE) == 0) {
config->CompHdrType = atoi(value);
} else if (strcmp(key, KEY_MTU_SIZE) == 0) {
config->mtu = atoi(value);
printf("mtu %d\n", config->mtu);
} else if (strcmp(key, KEY_IO_SLEEP) == 0) {
config->io_sleep = atoi(value);
printf("io_sleep %d \n", config->io_sleep);
} else if (strcmp(key, KEY_IO_CORE) == 0) {
config->io_core = atoi(value);
printf("io_core %d [core id]\n", config->io_core);
} else if (strcmp(key, KEY_IO_WORKER) == 0) {
config->io_worker = strtoll(value, NULL, 0);
printf("io_worker 0x%lx [mask]\n", config->io_worker);
} else if (strcmp(key, KEY_SYSTEM_CORE) == 0) {
config->system_core = atoi(value);
printf("system core %d [core id]\n", config->system_core);
} else if (strcmp(key, KEY_IOVA_MODE) == 0) {
config->iova_mode = atoi(value);
printf("iova_mode %d\n", config->iova_mode);
} else if (strcmp(key, KEY_INSTANCE_ID) == 0) {
config->instance_id = atoi(value);
printf("instance_id %d\n", config->instance_id);
} else if (strncmp(key, KEY_DU_MAC, strlen(KEY_DU_MAC)) == 0) {
unsigned int vf_num = 0;
sscanf(key,"duMac%02u",&vf_num);
if (vf_num >= XRAN_VF_MAX) {
printf("duMac%d exceeds max antenna supported\n",vf_num);
} else {
printf("duMac%d: %s\n",vf_num, value);
sscanf(value, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", (uint8_t*)&config->o_du_addr[vf_num].addr_bytes[0],
(uint8_t*)&config->o_du_addr[vf_num].addr_bytes[1],
(uint8_t*)&config->o_du_addr[vf_num].addr_bytes[2],
(uint8_t*)&config->o_du_addr[vf_num].addr_bytes[3],
(uint8_t*)&config->o_du_addr[vf_num].addr_bytes[4],
(uint8_t*)&config->o_du_addr[vf_num].addr_bytes[5]);
printf("[vf %d]O-DU MAC address: %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
vf_num,
config->o_du_addr[vf_num].addr_bytes[0],
config->o_du_addr[vf_num].addr_bytes[1],
config->o_du_addr[vf_num].addr_bytes[2],
config->o_du_addr[vf_num].addr_bytes[3],
config->o_du_addr[vf_num].addr_bytes[4],
config->o_du_addr[vf_num].addr_bytes[5]);
}
} else if (strncmp(key, KEY_RU_MAC, strlen(KEY_RU_MAC)) == 0) {
unsigned int vf_num = 0;
sscanf(key,"ruMac%02u",&vf_num);
if (vf_num >= XRAN_VF_MAX) {
printf("ruMac%d exceeds max antenna supported\n",vf_num);
} else {
printf("ruMac%d: %s\n",vf_num, value);
sscanf(value, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", (uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[0],
(uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[1],
(uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[2],
(uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[3],
(uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[4],
(uint8_t*)&config->o_ru_addr[vf_num].addr_bytes[5]);
printf("[vf %d]RU MAC address: %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
vf_num,
config->o_ru_addr[vf_num].addr_bytes[0],
config->o_ru_addr[vf_num].addr_bytes[1],
config->o_ru_addr[vf_num].addr_bytes[2],
config->o_ru_addr[vf_num].addr_bytes[3],
config->o_ru_addr[vf_num].addr_bytes[4],
config->o_ru_addr[vf_num].addr_bytes[5]);
}
} else if (strcmp(key, KEY_FILE_NUMSLOTS) == 0) {
config->numSlots = atoi(value);
printf("numSlots: %d\n",config->numSlots);
}else if (strncmp(key, KEY_FILE_AxC, strlen(KEY_FILE_AxC)) == 0) {
unsigned int ant_num = 0;
sscanf(key,"antC%02u",&ant_num);
if (ant_num >= MAX_ANT_CARRIER_SUPPORTED) {
printf("antC%d exceeds max antenna supported\n",ant_num);
} else {
strncpy(&config->ant_file[ant_num][0], value, strlen(value));
printf("antC%d: %s\n",ant_num, config->ant_file[ant_num]);
}
} else if (strncmp(key, KEY_FILE_DLBFWUE, strlen(KEY_FILE_DLBFWUE)) == 0) {
unsigned int ue_num = 0;
sscanf(key,"DlBfwUe%02u",&ue_num);
if (ue_num >= MAX_ANT_CARRIER_SUPPORTED) {
printf("DlBfwUe%d exceeds max streams supported\n",ue_num);
} else {
strncpy(&config->dl_bfw_file[ue_num][0], value, strlen(value));
printf("DlBfwUe%d: %s\n",ue_num, config->dl_bfw_file[ue_num]);
}
}else if (strncmp(key, KEY_FILE_ULBFWUE, strlen(KEY_FILE_ULBFWUE)) == 0) {
unsigned int ue_num = 0;
sscanf(key,"UlBfwUe%02u",&ue_num);
if (ue_num >= MAX_ANT_CARRIER_SUPPORTED) {
printf("UlBfwUe%d exceeds max streams supported\n",ue_num);
} else {
strncpy(&config->ul_bfw_file[ue_num][0], value, strlen(value));
printf("UlBfwUe%d: %s\n",ue_num, config->ul_bfw_file[ue_num]);
}
}else if (strncmp(key, KEY_FILE_ULSRS, strlen(KEY_FILE_ULSRS)) == 0) {
unsigned int srs_ant = 0;
sscanf(key,"antSrsC%02u",&srs_ant);
if (srs_ant >= MAX_ANT_CARRIER_SUPPORTED_CAT_B) {
printf("antSrsC%d exceeds max ant elemnets supported [%d]\n", srs_ant, MAX_ANT_CARRIER_SUPPORTED_CAT_B);
} else {
strncpy(&config->ul_srs_file[srs_ant][0], value, strlen(value));
printf("antSrsC%d: %s\n",srs_ant, config->ul_srs_file[srs_ant]);
}
} else if (strcmp(key, KEY_PRACH_ENABLE) == 0) {
config->enablePrach = atoi(value);
printf("Prach enable: %d\n",config->enablePrach);
}else if (strcmp(key, KEY_MAX_FRAME_ID) == 0) {
config->maxFrameId = atoi(value);
printf("maxFrameId: %d\n",config->maxFrameId);
} else if (strcmp(key, KEY_SRS_ENABLE) == 0) {
config->enableSrs = atoi(value);
printf("Srs enable: %d\n",config->enablePrach);
} else if (strcmp(key, KEY_PRACH_CFGIDX) == 0) {
config->prachConfigIndex = atoi(value);
printf("Prach config index: %d\n",config->prachConfigIndex);
} else if (strcmp(key, KEY_SRS_SYM_IDX) == 0) {
config->srsSymMask = atoi(value);
printf("Srs symbol [0-13]: %d\n",config->srsSymMask);
} else if (strncmp(key, KEY_FILE_PRACH_AxC, strlen(KEY_FILE_PRACH_AxC)) == 0) {
unsigned int ant_num = 0;
sscanf(key,"antPrachC%02u",&ant_num);
if (ant_num >= MAX_ANT_CARRIER_SUPPORTED)
{
printf("antC%d exceeds max antenna supported\n",ant_num);
}
else{
strncpy(&config->prach_file[ant_num][0], value, strlen(value));
printf("antPrachC%d: %s\n",ant_num, config->prach_file[ant_num]);
}
} else if (strcmp(key, KEY_BFW_NUM) == 0) {
config->totalBfWeights = atoi(value);
printf("%s : %d\n",KEY_BFW_NUM, config->totalBfWeights);
/* timing */
} else if (strcmp(key, KEY_TADV_CP_DL ) == 0) {
config->Tadv_cp_dl = atoi(value);
printf("Tadv_cp_dl: %d\n",config->Tadv_cp_dl);
} else if (strcmp(key, KEY_T2A_MIN_CP_DL ) == 0) {
config->T2a_min_cp_dl = atoi(value);
printf("T2a_min_cp_dl: %d\n",config->T2a_min_cp_dl);
} else if (strcmp(key, KEY_T2A_MAX_CP_DL ) == 0) {
config->T2a_max_cp_dl = atoi(value);
printf("T2a_max_cp_dl: %d\n",config->T2a_max_cp_dl);
} else if (strcmp(key, KEY_T2A_MIN_CP_UL ) == 0) {
config->T2a_min_cp_ul = atoi(value);
printf("T2a_min_cp_ul: %d\n",config->T2a_min_cp_ul);
} else if (strcmp(key, KEY_T2A_MAX_CP_UL ) == 0) {
config->T2a_max_cp_ul = atoi(value);
printf("T2a_max_cp_ul: %d\n",config->T2a_max_cp_ul);
} else if (strcmp(key, KEY_T2A_MIN_UP ) == 0) {
config->T2a_min_up = atoi(value);
printf("T2a_min_up: %d\n",config->T2a_min_up);
} else if (strcmp(key, KEY_T2A_MAX_UP ) == 0) {
config->T2a_max_up = atoi(value);
printf("T2a_max_up: %d\n",config->T2a_max_up);
} else if (strcmp(key, KEY_TA3_MIN ) == 0) {
config->Ta3_min = atoi(value);
printf("Ta3_min: %d\n",config->Ta3_min);
} else if (strcmp(key, KEY_TA3_MAX ) == 0) {
config->Ta3_max = atoi(value);
printf("Ta3_max: %d\n",config->Ta3_max);
} else if (strcmp(key, KEY_T1A_MIN_CP_DL ) == 0) {
config->T1a_min_cp_dl = atoi(value);
printf("T1a_min_cp_dl: %d\n",config->T1a_min_cp_dl);
} else if (strcmp(key, KEY_T1A_MAX_CP_DL ) == 0) {
config->T1a_max_cp_dl = atoi(value);
printf("T1a_max_cp_dl: %d\n",config->T1a_max_cp_dl);
} else if (strcmp(key, KEY_T1A_MIN_CP_UL ) == 0) {
config->T1a_min_cp_ul = atoi(value);
printf("T1a_min_cp_ul: %d\n",config->T1a_min_cp_ul);
} else if (strcmp(key, KEY_T1A_MAX_CP_UL ) == 0) {
config->T1a_max_cp_ul = atoi(value);
printf("T1a_max_cp_ul: %d\n",config->T1a_max_cp_ul);
} else if (strcmp(key, KEY_T1A_MIN_UP ) == 0) {
config->T1a_min_up = atoi(value);
printf("T1a_min_up: %d\n",config->T1a_min_up);
} else if (strcmp(key, KEY_T1A_MAX_UP ) == 0) {
config->T1a_max_up = atoi(value);
printf("T1a_max_up: %d\n",config->T1a_max_up);
} else if (strcmp(key, KEY_TA4_MIN ) == 0) {
config->Ta4_min = atoi(value);
printf("Ta4_min: %d\n",config->Ta4_min);
} else if (strcmp(key, KEY_TA4_MAX ) == 0) {
config->Ta4_max = atoi(value);
printf("Ta4_max: %d\n",config->Ta4_max);
/* end of timing */
} else if (strcmp(key, KEY_CP_ENABLE ) == 0) {
config->enableCP = atoi(value);
printf("CPenable: %d\n",config->enableCP);
} else if (strcmp(key, KEY_DEBUG_STOP ) == 0) {
config->debugStop = atoi(value);
printf("debugStop: %d\n",config->debugStop);
} else if (strcmp(key, KEY_DEBUG_STOP_CNT) == 0) {
config->debugStopCount = atoi(value);
printf("debugStopCount: %d\n",config->debugStopCount);
} else if (strcmp(key, KEY_BBDEV_MODE) == 0) {
config->bbdevMode = atoi(value);
printf("bbdevMode: %d\n",config->debugStopCount);
} else if (strcmp(key, KEY_DYNA_SEC_ENA) == 0) {
config->DynamicSectionEna = atoi(value);
printf("DynamicSectionEna: %d\n",config->DynamicSectionEna);
} else if (strcmp(key, KEY_ALPHA) == 0) {
config->GPS_Alpha = atoi(value);
printf("GPS_Alpha: %d\n",config->GPS_Alpha);
} else if (strcmp(key, KEY_BETA) == 0) {
config->GPS_Beta = atoi(value);
printf("GPS_Beta: %d\n",config->GPS_Beta);
} else if (strcmp(key, KEY_CP_VTAG ) == 0) {
config->cp_vlan_tag = atoi(value);
printf("cp_vlan_tag: %d\n",config->cp_vlan_tag);
} else if (strcmp(key, KEY_UP_VTAG ) == 0) {
config->up_vlan_tag = atoi(value);
printf("up_vlan_tag: %d\n",config->up_vlan_tag);
} else if (strcmp(key, KEY_NPRBELEM_UL ) == 0) {
config->PrbMapUl.nPrbElm = atoi(value);
if (config->PrbMapUl.nPrbElm > XRAN_MAX_PRBS)
{
printf("nTddPeriod is larger than max allowed, invalid!\n");
config->PrbMapUl.nPrbElm = XRAN_MAX_PRBS;
}
printf("nPrbElemUl: %d\n",config->PrbMapUl.nPrbElm);
} else if (strncmp(key, KEY_PRBELEM_UL, strlen(KEY_PRBELEM_UL)) == 0) {
sscanf(key,"PrbElemUl%u",&section_idx_ul);
if (section_idx_ul >= config->PrbMapUl.nPrbElm){
printf("section_idx %d exceeds nPrbElemUl\n",section_idx_ul);
}
else{
struct xran_prb_elm *pPrbElem = &config->PrbMapUl.prbMap[section_idx_ul];
sscanf(value, "%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd",
(int16_t*)&pPrbElem->nRBStart,
(int16_t*)&pPrbElem->nRBSize,
(int16_t*)&pPrbElem->nStartSymb,
(int16_t*)&pPrbElem->numSymb,
(int16_t*)&pPrbElem->nBeamIndex,
(int16_t*)&pPrbElem->bf_weight_update,
(int16_t*)&pPrbElem->compMethod,
(int16_t*)&pPrbElem->iqWidth,
(int16_t*)&pPrbElem->BeamFormingType);
printf("nPrbElemUl%d: ",section_idx_ul);
printf("nRBStart %d,nRBSize %d,nStartSymb %d,numSymb %d,nBeamIndex %d, bf_weight_update %d compMethod %d, iqWidth %d BeamFormingType %d\n",
pPrbElem->nRBStart,pPrbElem->nRBSize,pPrbElem->nStartSymb,pPrbElem->numSymb,pPrbElem->nBeamIndex, pPrbElem->bf_weight_update, pPrbElem->compMethod, pPrbElem->iqWidth, pPrbElem->BeamFormingType);
}
}else if (strcmp(key, KEY_NPRBELEM_DL ) == 0) {
config->PrbMapDl.nPrbElm = atoi(value);
if (config->PrbMapDl.nPrbElm > XRAN_MAX_PRBS)
{
printf("nTddPeriod is larger than max allowed, invalid!\n");
config->PrbMapDl.nPrbElm = XRAN_MAX_PRBS;
}
printf("nPrbElemDl: %d\n",config->PrbMapDl.nPrbElm);
} else if (strncmp(key, KEY_PRBELEM_DL, strlen(KEY_PRBELEM_DL)) == 0) {
sscanf(key,"PrbElemDl%u",&section_idx_dl);
if (section_idx_dl >= config->PrbMapDl.nPrbElm){
printf("section_idx %d exceeds nPrbElemDl\n",section_idx_dl);
}
else{
struct xran_prb_elm *pPrbElem = &config->PrbMapDl.prbMap[section_idx_dl];
sscanf(value, "%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd,%hd",
(int16_t*)&pPrbElem->nRBStart,
(int16_t*)&pPrbElem->nRBSize,
(int16_t*)&pPrbElem->nStartSymb,
(int16_t*)&pPrbElem->numSymb,
(int16_t*)&pPrbElem->nBeamIndex,
(int16_t*)&pPrbElem->bf_weight_update,
(int16_t*)&pPrbElem->compMethod,
(int16_t*)&pPrbElem->iqWidth,
(int16_t*)&pPrbElem->BeamFormingType);
printf("nPrbElemDl%d: ",section_idx_dl);
printf("nRBStart %d,nRBSize %d,nStartSymb %d,numSymb %d,nBeamIndex %d, bf_weight_update %d compMethod %d, iqWidth %d BeamFormingType %d\n",
pPrbElem->nRBStart,pPrbElem->nRBSize,pPrbElem->nStartSymb,pPrbElem->numSymb,pPrbElem->nBeamIndex, pPrbElem->bf_weight_update, pPrbElem->compMethod, pPrbElem->iqWidth, pPrbElem->BeamFormingType);
}
} else {
printf("Unsupported configuration key [%s]\n", key);
return -1;
}
return 0;
}
int parseConfigFile(char *filename, RuntimeConfig *config)
{
char inputLine[MAX_LINE_SIZE] = {0};
int inputLen = 0;
int i;
int lineNum = 0;
char key[MAX_LINE_SIZE] = {0};
char value[MAX_LINE_SIZE] = {0};
FILE *file = fopen(filename, "r");
if (NULL == file) {
log_err("Error while opening config file from: %s", filename);
return -1;
}
// init_config(config);
for (;;) {
if (fgets(inputLine, MAX_LINE_SIZE, file) == NULL) {
if (lineNum > 0) {
printf("%d lines of config file has been read.\n", lineNum);
break;
} else {
printf("Configuration file reading error has occurred.\n");
fclose(file);
return -1;
}
}
if (inputLine[strlen(inputLine)-1] == '\n')
inputLine[strlen(inputLine)-1] == '\0';
lineNum++;
inputLen = strlen(inputLine);
for (i=0; i<inputLen; i++)
if (inputLine[i] == '#') {
inputLine[i] = '\0';
inputLen = i + 1;
break;
}
for (i=0; i<inputLen; i++)
if (inputLine[i] == '=') {
strncpy(key, inputLine, i);
key[i] = '\0';
trim(key);
if ((i + 1 > inputLen - 1) || (i - 2 > inputLen)) {
log_err("Parsing config file error at line %d", lineNum);
fclose(file);
return -1;
}
strncpy(value, &inputLine[i+1], (sizeof(value) - 1));
value[inputLen-i-2] = '\0';
trim(value);
if (strlen(key) == 0 || strlen(value) == 0) {
printf("Parsing config file error at line %d", lineNum);
fclose(file);
return -1;
}
if (fillConfigStruct(config, key, value) != 0) {
fclose(file);
return -1;
}
break;
}
memset(&inputLine[0], 0, sizeof(MAX_LINE_SIZE));
memset(&key[0], 0, sizeof(MAX_LINE_SIZE));
memset(&value[0], 0, sizeof(MAX_LINE_SIZE));
}
fclose(file);
return 0;
}
/******************************************************************************
*
* Copyright (c) 2020 Intel.
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* 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.
*
*******************************************************************************/
/**
* @brief
* @file
* @ingroup
* @author Intel Corporation
**/
#ifndef _SAMPLEAPP__CONFIG_H_
#define _SAMPLEAPP__CONFIG_H_
#include <stdint.h>
#include <rte_ether.h>
#include "xran_fh_o_du.h"
/** Run time configuration of application */
typedef struct _RuntimeConfig
{
uint8_t appMode; /**< Application mode: lls-CU or RU */
uint8_t xranTech; /**< Radio Access Technology (NR or LTE) */
uint8_t xranCat; /**< xran mode: NR Categoty A, NR Category B, LTE Cat A, LTE Cat B */
uint8_t numCC; /**< Number of CC per ports supported by RU */
uint8_t numAxc; /**< Number of Antenna Carriers per CC */
uint8_t numUlAxc; /**< Number of Antenna Carriers per CC for UL (Cat B) */
uint32_t antElmTRx; /**< Number of antenna elements for TX and RX */
uint32_t muMimoUEs; /**< Number of UEs (with 1 RX ant)/beams */
uint32_t DlLayersPerUe; /**< Number of DL layer per UE */
uint32_t UlLayersPerUe; /**< Number of UL layer per UE */
uint32_t ttiPeriod; /**< TTI period */
uint32_t testVect; /**< Test Signal to send */
struct rte_ether_addr o_du_addr[XRAN_VF_MAX]; /**< O-DU Ethernet Mac Address */
struct rte_ether_addr o_ru_addr[XRAN_VF_MAX]; /**< O-RU Ethernet Mac Address */
struct rte_ether_addr tmp_addr; /**< Temp Ethernet Mac Address */
uint32_t instance_id; /**< Instance ID of application */
uint32_t io_core; /**< Core used for IO */
uint64_t io_worker; /**< Mask for worker cores */
int32_t io_sleep; /**< enable sleep on PMD cores */
uint32_t system_core; /* house keeping core */
int iova_mode; /**< DPDK IOVA Mode */
uint32_t mtu; /**< maximum transmission unit (MTU) is the size of the largest protocol data unit (PDU) that can be communicated in a single
xRAN network layer transaction. supported 1500 bytes and 9600 bytes (Jumbo Frame) */
int numSlots; /**< number of slots in IQ vector */
char ant_file[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR][512]; /**< file to use for test vector */
char prach_file[XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR][512]; /**< file to use for test vector */
char dl_bfw_file [XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR][512]; /**< file with beamforming weights for DL streams */
char ul_bfw_file [XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR][512]; /**< file with beamforming weights for UL streams */
char ul_srs_file [XRAN_MAX_SECTOR_NR*XRAN_MAX_ANT_ARRAY_ELM_NR][512]; /**< file with SRS content for UL antenna elements */
/* prach config */
uint8_t enablePrach; /**< enable PRACH */
uint8_t prachOffset; /**< Sets the PRACH position in frequency / subcarrier position, n_PRBoffset^RA and is expressed as a physical resource block number.
Set by SIB2, prach-FreqOffset in E-UTRA. */
uint8_t prachConfigIndex;/**< TS36.211 - Table 5.7.1-2 : PRACH Configuration Index */
uint8_t iqswap; /**< do swap of IQ before send to ETH */
uint8_t nebyteorderswap; /**< do swap of byte order from host byte order to network byte order. ETH */
uint8_t compression; /**< enable use case with compression */
uint8_t CompHdrType; /**< dynamic or static compression header */
uint16_t totalBfWeights; /**< The total number of beamforming weights on RU */
uint8_t enableSrs; /**< enable SRS (valid for Cat B only) */
uint16_t srsSymMask; /**< SRS symbol mask [014] within S/U slot [0-13] def is 13 */
uint16_t maxFrameId; /**< max value of frame id */
uint16_t Tadv_cp_dl;
uint16_t T2a_min_cp_dl;
uint16_t T2a_max_cp_dl;
uint16_t T2a_min_cp_ul;
uint16_t T2a_max_cp_ul;
uint16_t T2a_min_up;
uint16_t T2a_max_up;
uint16_t Ta3_min;
uint16_t Ta3_max;
uint16_t T1a_min_cp_dl;
uint16_t T1a_max_cp_dl;
uint16_t T1a_min_cp_ul;
uint16_t T1a_max_cp_ul;
uint16_t T1a_min_up;
uint16_t T1a_max_up;
uint16_t Ta4_min;
uint16_t Ta4_max;
uint8_t enableCP; /**< enable C-plane */
uint8_t cp_vlan_tag; /**< C-plane vlan tag */
uint8_t up_vlan_tag; /**< U-plane vlan tag */
int32_t debugStop;
int32_t debugStopCount;
int32_t bbdevMode;
int32_t DynamicSectionEna;
int32_t GPS_Alpha;
int32_t GPS_Beta;
uint8_t mu_number; /**< Mu numner as per 3GPP */
uint32_t nDLAbsFrePointA; /**< Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000 */
uint32_t nULAbsFrePointA; /**< Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000 */
uint32_t nDLBandwidth; /**< Carrier bandwidth for in MHz. Value: 5->400 */
uint32_t nULBandwidth; /**< Carrier bandwidth for in MHz. Value: 5->400 */
uint32_t nDLFftSize; /**< DL FFT size */
uint32_t nULFftSize; /**< UL FFT size */
uint8_t nFrameDuplexType;
uint8_t nTddPeriod;
struct xran_slot_config sSlotConfig[XRAN_MAX_TDD_PERIODICITY];
struct xran_prb_map PrbMapDl;
struct xran_prb_map PrbMapUl;
int32_t DU_Port_ID_bitwidth;
int32_t BandSector_ID_bitwidth;
int32_t CC_ID_bitwidth;
int32_t RU_Port_ID_bitwidth;
} RuntimeConfig;
/**
* Parse application configuration file.
*
* @param filename The name of the configuration file to be parsed.
* @param config The configuration structure to be filled with parsed data. */
int parseConfigFile(char *filename, RuntimeConfig *config);
#endif /* _SAMPLEAPP__CONFIG_H_ */
/******************************************************************************
*
* Copyright (c) 2020 Intel.
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* 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.
*
*******************************************************************************/
/**
* @brief
* @file
* @ingroup
* @author Intel Corporation
**/
#ifndef _SAMPLEAPP__DEBUG_H_
#define _SAMPLEAPP__DEBUG_H_
#include <stdio.h>
#include "config.h"
#define MAX_FILE_NAME_LEN (512)
#define MAX_PATH_NAME_LEN (1024)
#ifdef _DEBUG
#define log_dbg(fmt, ...) \
fprintf(stderr, \
"DEBUG: %s(%d): " fmt "\n", \
__FILE__, \
__LINE__, ##__VA_ARGS__)
#else
#define log_dbg(fmt, ...)
#endif
#if defined(_DEBUG) || defined(_VERBOSE)
#define log_wrn(fmt, ...) \
fprintf( \
stderr, \
"WARNING: %s(%d): " fmt "\n", \
__FILE__, \
__LINE__, ##__VA_ARGS__)
#else
#define log_dbg(fmt, ...)
#define log_wrn(fmt, ...)
#endif
#define log_err(fmt, ...) \
fprintf(stderr, \
"ERROR: %s(%d): " fmt "\n", \
__FILE__, \
__LINE__, ##__VA_ARGS__)
inline void ShowData(void* ptr, unsigned int size)
{
uint8_t *d = (uint8_t *)ptr;
unsigned int i;
for(i = 0; i < size; i++)
{
if ( !(i & 0xf) )
printf("\n");
printf("%02x ", d[i]);
}
printf("\n");
}
#endif /* _SAMPLEAPP__DEBUG_H_ */
/*
* 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 <string.h>
#include <stdlib.h>
#include "common.h"
#include "config.h"
#include "xran_fh_o_du.h"
#include "xran_compression.h"
#include "xran_cp_api.h"
#include "xran_sync_api.h"
#include "oran_isolate.h"
#include "xran_common.h"
// Declare variable useful for the send buffer function
volatile uint8_t first_call_set = 0;
volatile uint8_t first_rx_set = 0;
// 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)
int rx_tti;
int rx_sym;
volatile uint32_t rx_cb_tti = 0;
volatile uint32_t rx_cb_frame = 0;
volatile uint32_t rx_cb_subframe = 0;
volatile uint32_t rx_cb_slot = 0;
#define GetFrameNum(tti,SFNatSecStart,numSubFramePerSystemFrame, numSlotPerSubFrame) ((((uint32_t)tti / ((uint32_t)numSubFramePerSystemFrame * (uint32_t)numSlotPerSubFrame)) + SFNatSecStart) & 0x3FF)
#define GetSlotNum(tti, numSlotPerSfn) ((uint32_t)tti % ((uint32_t)numSlotPerSfn))
int xran_is_prach_slot(uint32_t subframe_id, uint32_t slot_id);
extern struct xran_fh_config xranConf;
void oai_xran_fh_rx_callback(void *pCallbackTag, xran_status_t status){
struct xran_cb_tag *callback_tag = (struct xran_cb_tag *)pCallbackTag;
uint64_t second;
uint32_t tti;
uint32_t frame;
uint32_t subframe;
uint32_t slot;
tti = xran_get_slot_idx(&frame,&subframe,&slot,&second);
rx_tti = callback_tag->slotiId;
rx_sym = callback_tag->symbol;
if (rx_sym == 7) {
if (first_call_set) {
if (!first_rx_set) {
printf("first_rx is set\n");
}
first_rx_set = 1;
}
rx_cb_tti = tti;
rx_cb_frame = frame;
rx_cb_subframe = subframe;
rx_cb_slot = slot;
}
}
void oai_xran_fh_srs_callback(void *pCallbackTag, xran_status_t status){
rte_pause();
}
void oai_xran_fh_rx_prach_callback(void *pCallbackTag, xran_status_t status){
rte_pause();
}
int oai_physide_dl_tti_call_back(void * param)
{
if (!first_call_set)
printf("first_call set from phy cb first_call_set=%p\n",&first_call_set);
first_call_set = 1;
return 0;
}
int oai_physide_ul_half_slot_call_back(void * param)
{
rte_pause();
return 0;
}
int oai_physide_ul_full_slot_call_back(void * param)
{
rte_pause();
return 0;
}
int read_prach_data(ru_info_t *ru, int frame, int slot)
{
struct rte_mbuf *mb;
/* calculate tti and subframe_id from frame, slot num */
int tti = 20 * (frame) + (slot);
uint32_t subframe = XranGetSubFrameNum(tti, 2, 10);
uint32_t is_prach_slot = xran_is_prach_slot(subframe, (slot % 2));
int sym_idx = 0;
struct xran_device_ctx *xran_ctx = xran_dev_get_ctx();
struct xran_prach_cp_config *pPrachCPConfig = &(xran_ctx->PrachCPConfig);
/* If it is PRACH slot, copy prach IQ from XRAN PRACH buffer to OAI PRACH buffer */
if(is_prach_slot) {
for(sym_idx = 0; sym_idx < pPrachCPConfig->numSymbol; sym_idx++) {
for (int aa=0;aa<ru->nb_rx;aa++) {
mb = (struct rte_mbuf *) xran_ctx->sFHPrachRxBbuIoBufCtrl[tti % 40][0][aa].sBufferList.pBuffers[sym_idx].pCtrl;
if(mb) {
uint16_t *dst, *src;
int idx = 0;
dst = (uint16_t * )((uint8_t *)ru->prach_buf[aa]);// + (sym_idx*576));
src = (uint16_t *) ((uint8_t *) xran_ctx->sFHPrachRxBbuIoBufCtrl[tti % 40][0][aa].sBufferList.pBuffers[sym_idx].pData);
/* convert Network order to host order */
if (sym_idx==0) {
for (idx = 0; idx < 576/2; idx++)
{
((int16_t*)dst)[idx] = ((int16_t)ntohs(src[idx]))>>4;
}
}
else {
for (idx = 0; idx < 576/2; idx++)
{
((int16_t*)dst)[idx] += ((int16_t)ntohs(src[idx]))>>4;
}
}
} else {
/* TODO: Unlikely this code never gets executed */
printf("%s():%d, There is no prach ctrl data for symb %d ant %d\n", __func__, __LINE__, sym_idx,aa);
}
}
}
}
return(0);
}
int xran_fh_rx_read_slot(ru_info_t *ru, int *frame, int *slot, int oframe, int oslot, uint8_t sync){
void *ptr = NULL;
int32_t *pos = NULL;
int idx = 0;
static int print_tmp = 1;
static int print_tmp_1 = 1;
while (first_call_set != 1){
if (print_tmp) {
print_tmp = 0;
printf("wait in ru_thread() till first_call_set is set in xran\n");
}
}
while (first_rx_set != 1){
if (print_tmp_1) {
print_tmp_1 = 0;
printf("wait in ru_thread for first_rx_set to set in xran\n");
}
}
volatile uint32_t prev_rx_cb_tti;
int tti;
prev_rx_cb_tti = rx_cb_tti;
*frame = rx_cb_frame;
*slot = (rx_cb_subframe*2)+rx_cb_slot;
tti = (*frame*20) + *slot;
while (rx_cb_tti == prev_rx_cb_tti) {
}
read_prach_data(ru, *frame, *slot);
struct xran_device_ctx *xran_ctx = xran_dev_get_ctx();
int num_eaxc = xranConf.neAxc;
int num_eaxc_ul = xranConf.neAxcUl;
uint32_t xran_max_antenna_nr = RTE_MAX(num_eaxc, num_eaxc_ul);
int slot_offset_rxdata = 3&(*slot);
uint32_t slot_size = 4*14*4096;
uint8_t *rx_data = (uint8_t *)ru->rxdataF[0];
uint8_t *start_ptr = NULL;
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_rx; ant_id++){
rx_data = (uint8_t *)ru->rxdataF[ant_id];
start_ptr = rx_data + (slot_size*slot_offset_rxdata);
// 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++) {
uint8_t *pData = xran_ctx->sFrontHaulRxBbuIoBufCtrl[tti % XRAN_N_FE_BUF_LEN][cc_id][ant_id].sBufferList.pBuffers[sym_idx%XRAN_NUM_OF_SYMBOL_PER_SLOT].pData;
uint8_t *pPrbMapData = xran_ctx->sFrontHaulRxPrbMapBbuIoBufCtrl[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 = (int32_t *)(start_ptr + (4*sym_idx*4096));
uint8_t *u8dptr;
struct xran_prb_map *pRbMap = pPrbMap;
int32_t sym_id = sym_idx%XRAN_NUM_OF_SYMBOL_PER_SLOT;
if(ptr && pos){
uint32_t idxElm = 0;
u8dptr = (uint8_t*)ptr;
int16_t payload_len = 0;
uint8_t *src = (uint8_t *)u8dptr;
// first half
uint8_t *src1 = (uint8_t *)u8dptr;
uint8_t *dst1 = (uint8_t *)pos;
// second half
uint8_t *src2 = (uint8_t *)u8dptr;
uint8_t *dst2 = (uint8_t *)pos;
struct xran_prb_elm* p_prbMapElm = &pRbMap->prbMap[idxElm];
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(pRbMap->nPrbElm==1 && idxElm==0){
src = pData;
}
else if(p_sec_desc->pData==NULL){
return -1;
}else{
src = p_sec_desc->pData;
}
src2 = src;
if(p_sec_desc == NULL){
printf ("p_sec_desc == NULL\n");
exit(-1);
}
// Calculation of the pointer for the section in the buffer.
// first half
dst1 = (uint8_t *)(pos + p_prbMapElm->nRBStart*N_SC_PER_PRB);
// second half
dst2 = (uint8_t *)(pos + (p_prbMapElm->nRBStart*N_SC_PER_PRB + 3276/2) + 4096 - 3276);
if(p_prbMapElm->compMethod == XRAN_COMPMETHOD_NONE) {
payload_len = p_prbMapElm->nRBSize*N_SC_PER_PRB*4L;
src1 = src2 + payload_len/2;
for (idx = 0; idx < payload_len/(2*sizeof(int16_t)); idx++) {
((int16_t *)dst1)[idx] = ((int16_t)ntohs(((uint16_t *)src1)[idx]))>>2;
((int16_t *)dst2)[idx] = ((int16_t)ntohs(((uint16_t *)src2)[idx]))>>2;
}
} else if (p_prbMapElm->compMethod == XRAN_COMPMETHOD_BLKFLOAT) {
struct xranlib_decompress_request bfp_decom_req_2;
struct xranlib_decompress_response bfp_decom_rsp_2;
struct xranlib_decompress_request bfp_decom_req_1;
struct xranlib_decompress_response bfp_decom_rsp_1;
payload_len = (3* p_prbMapElm->iqWidth + 1)*p_prbMapElm->nRBSize;
memset(&bfp_decom_req_2, 0, sizeof(struct xranlib_decompress_request));
memset(&bfp_decom_rsp_2, 0, sizeof(struct xranlib_decompress_response));
memset(&bfp_decom_req_1, 0, sizeof(struct xranlib_decompress_request));
memset(&bfp_decom_rsp_1, 0, sizeof(struct xranlib_decompress_response));
bfp_decom_req_2.data_in = (int8_t*)src2;
bfp_decom_req_2.numRBs = p_prbMapElm->nRBSize/2;
bfp_decom_req_2.len = payload_len/2;
bfp_decom_req_2.compMethod = p_prbMapElm->compMethod;
bfp_decom_req_2.iqWidth = p_prbMapElm->iqWidth;
bfp_decom_rsp_2.data_out = (int16_t*)dst2;
bfp_decom_rsp_2.len = 0;
xranlib_decompress_avx512(&bfp_decom_req_2, &bfp_decom_rsp_2);
int16_t first_half_len = bfp_decom_rsp_2.len;
src1 = src2+(payload_len/2);
bfp_decom_req_1.data_in = (int8_t*)src1;
bfp_decom_req_1.numRBs = p_prbMapElm->nRBSize/2;
bfp_decom_req_1.len = payload_len/2;
bfp_decom_req_1.compMethod = p_prbMapElm->compMethod;
bfp_decom_req_1.iqWidth = p_prbMapElm->iqWidth;
bfp_decom_rsp_1.data_out = (int16_t*)dst1;
bfp_decom_rsp_1.len = 0;
xranlib_decompress_avx512(&bfp_decom_req_1, &bfp_decom_rsp_1);
payload_len = bfp_decom_rsp_1.len+first_half_len;
}else {
printf ("p_prbMapElm->compMethod == %d is not supported\n",
p_prbMapElm->compMethod);
exit(-1);
}
}
} else {
exit(-1);
printf("ptr ==NULL\n");
}
}
}
}
return(0);
}
int xran_fh_tx_send_slot(ru_info_t *ru, int frame, int slot, uint64_t timestamp){
int tti = /*frame*SUBFRAMES_PER_SYSTEMFRAME*SLOTNUM_PER_SUBFRAME+*/20*frame+slot; //commented out temporarily to check that compilation of oran 5g is working.
void *ptr = NULL;
int32_t *pos = NULL;
int idx = 0;
struct xran_device_ctx *xran_ctx = xran_dev_get_ctx();
int num_eaxc = xranConf.neAxc;
int num_eaxc_ul = xranConf.neAxcUl;
uint32_t xran_max_antenna_nr = RTE_MAX(num_eaxc, num_eaxc_ul);
/*
for (nSectorNum = 0; nSectorNum < XRAN_MAX_SECTOR_NR; nSectorNum++)
{
nSectorIndex[nSectorNum] = nSectorNum;
}
*/
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++) {
uint8_t *pData = xran_ctx->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 = xran_ctx->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 * 4096 /*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){
uint32_t idxElm = 0;
u8dptr = (uint8_t*)ptr;
int16_t payload_len = 0;
uint8_t *dst = (uint8_t *)u8dptr;
// first half
uint8_t *dst1 = (uint8_t *)u8dptr;
uint8_t *src1 = (uint8_t *)pos;
// second half
uint8_t *dst2 = (uint8_t *)u8dptr;
uint8_t *src2 = (uint8_t *)pos;
struct xran_prb_elm* p_prbMapElm = &pRbMap->prbMap[idxElm];
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];
payload_len = p_prbMapElm->nRBSize*N_SC_PER_PRB*4L;
dst = xran_add_hdr_offset(dst, p_prbMapElm->compMethod);
dst2 = dst;
dst1 = dst2 + payload_len/2;
if(p_sec_desc == NULL){
printf ("p_sec_desc == NULL\n");
exit(-1);
}
// Calculation of the pointer for the section in the buffer.
// first half
src1 = (uint8_t *)(pos + p_prbMapElm->nRBStart*N_SC_PER_PRB);
// second half
src2 = (uint8_t *)(pos + (p_prbMapElm->nRBStart*N_SC_PER_PRB + 3276/2) + 4096 - 3276);
if(p_prbMapElm->compMethod == XRAN_COMPMETHOD_NONE) {
/* convert to Network order */
for (idx = 0; idx < payload_len/(2*sizeof(uint16_t)); idx++)
{
((uint16_t *)dst1)[idx] = htons(((uint16_t *)src1)[idx]);
((uint16_t *)dst2)[idx] = htons(((uint16_t *)src2)[idx]);
}
} 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*)src2;
bfp_com_req.numRBs = p_prbMapElm->nRBSize/2;
bfp_com_req.len = payload_len/2;
bfp_com_req.compMethod = p_prbMapElm->compMethod;
bfp_com_req.iqWidth = p_prbMapElm->iqWidth;
bfp_com_rsp.data_out = (int8_t*)dst2;
bfp_com_rsp.len = 0;
xranlib_compress_avx512(&bfp_com_req, &bfp_com_rsp);
int16_t first_half_len = bfp_com_rsp.len;
dst1 = dst2 + first_half_len;
bfp_com_req.data_in = (int16_t*)src1;
bfp_com_req.numRBs = p_prbMapElm->nRBSize/2;
bfp_com_req.len = payload_len/2;
bfp_com_req.compMethod = p_prbMapElm->compMethod;
bfp_com_req.iqWidth = p_prbMapElm->iqWidth;
bfp_com_rsp.data_out = (int8_t*)dst1;
bfp_com_rsp.len = 0;
xranlib_compress_avx512(&bfp_com_req, &bfp_com_rsp);
payload_len = bfp_com_rsp.len+first_half_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);
}
#if 0
int64_t count_sec =0;
struct xran_common_counters x_counters;
uint64_t nTotalTime;
uint64_t nUsedTime;
uint32_t nCoreUsed;
float nUsedPercent;
uint64_t old_rx_counter = 0;
uint64_t old_tx_counter = 0;
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);
}
#endif
void check_xran_ptp_sync(){
int res;
if ((res=xran_is_synchronized()) != 0)
printf("Machine is not synchronized using PTP (%x)!\n",res);
else
printf("Machine is synchronized using PTP!\n");
}
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