diff --git a/executables/lte-ru.c b/executables/lte-ru.c index 9c47c92a0d..0fa397cc04 100644 --- a/executables/lte-ru.c +++ b/executables/lte-ru.c @@ -390,7 +390,7 @@ void fh_if5_north_asynch_in(RU_t *ru, LTE_DL_FRAME_PARMS *fp = ru->frame_parms; RU_proc_t *proc = &ru->proc; int tti_tx,frame_tx; - openair0_timestamp timestamp_tx=0; + openair0_timestamp_t timestamp_tx = 0; //recv_IF5(ru, ×tamp_tx, *subframe, IF5_RRH_GW_DL); // LOG_I(PHY,"Received subframe %d (TS %llu) from RCC\n",tti_tx,timestamp_tx); tti_tx = (timestamp_tx/fp->samples_per_tti)%10; @@ -540,7 +540,7 @@ void rx_rf(RU_t *ru, unsigned int rxs; int i; int resynch=0; - openair0_timestamp ts=0,old_ts=0; + openair0_timestamp_t ts = 0, old_ts = 0; for (i=0; inb_rx; i++) rxp[i] = (void *)&ru->common.rxdata[i][*subframe*fp->samples_per_tti]; diff --git a/executables/lte-ue.c b/executables/lte-ue.c index 2d7338c410..70da050d5d 100644 --- a/executables/lte-ue.c +++ b/executables/lte-ue.c @@ -1686,7 +1686,8 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) * \param arg unused * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -void write_dummy(PHY_VARS_UE *UE, openair0_timestamp timestamp) { +void write_dummy(PHY_VARS_UE *UE, openair0_timestamp_t timestamp) +{ // we have to write to tell explicitly to the eNB, else it will wait for us forever // we write the next subframe (always write in future of what we received) // @@ -1709,7 +1710,7 @@ void *UE_thread(void *arg) { PHY_VARS_UE *UE = (PHY_VARS_UE *) arg; // int tx_enabled = 0; int dummy_rx[UE->frame_parms.nb_antennas_rx][UE->frame_parms.samples_per_tti] __attribute__((aligned(32))); - openair0_timestamp timestamp,timestamp1; + openair0_timestamp_t timestamp, timestamp1; void *rxp[NB_ANTENNAS_RX], *txp[NB_ANTENNAS_TX]; int start_rx_stream = 0; int i; diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 7d96eb6772..9a1e99d31a 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -570,10 +570,10 @@ static void rx_rf(RU_t *ru, int *frame, int *slot) rxp[i] = (void *)&ru->common.rxdata[i][get_samples_slot_timestamp(fp, *slot)]; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1); - openair0_timestamp old_ts = proc->timestamp_rx; + openair0_timestamp_t old_ts = proc->timestamp_rx; LOG_D(PHY,"Reading %d samples for slot %d (%p)\n", samples_per_slot, *slot, rxp[0]); - openair0_timestamp ts; + openair0_timestamp_t ts; unsigned int rxs; rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, &ts, rxp, samples_per_slot, nb); diff --git a/executables/nr-ue.c b/executables/nr-ue.c index c920a57b88..29a59fbc0d 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -379,7 +379,7 @@ static void RU_write(nr_rxtx_thread_data_t *rxtxD, bool sl_tx_action, c16_t **tx } } - openair0_timestamp writeTimestamp = proc->timestamp_tx; + openair0_timestamp_t writeTimestamp = proc->timestamp_tx; int writeBlockSize = rxtxD->writeBlockSize; // if writeBlockSize gets longer that slot size, fill with dummy const int maxWriteBlockSize = get_samples_per_slot(proc->nr_slot_tx, fp); @@ -647,7 +647,8 @@ void UE_dl_processing(void *arg) { TracyCZoneEnd(ctx); } -void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockSize) { +void dummyWrite(PHY_VARS_NR_UE *UE, openair0_timestamp_t timestamp, int writeBlockSize) +{ NR_DL_FRAME_PARMS *fp = &UE->frame_parms; if (UE->sl_mode == 2) fp = &UE->SL_UE_PHY_PARAMS.sl_frame_params; @@ -663,7 +664,7 @@ void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockS AssertFatal(writeBlockSize == tmp, ""); } -void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, int duration_rx_to_tx, bool toTrash) +void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp_t *timestamp, int duration_rx_to_tx, bool toTrash) { NR_DL_FRAME_PARMS *fp = &UE->frame_parms; // two frames for initial sync @@ -693,7 +694,7 @@ void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, int duration_r if (IS_SOFTMODEM_RFSIM) { int ta = UE->timing_advance + UE->timing_advance_ntn; - const openair0_timestamp writeTimestamp = + const openair0_timestamp_t writeTimestamp = *timestamp + get_samples_slot_duration(fp, slot, duration_rx_to_tx) - UE->N_TA_offset - ta; dummyWrite(UE, writeTimestamp, get_samples_per_slot(slot, fp)); } @@ -705,7 +706,7 @@ void readFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, int duration_r free(rxp[i]); } -static void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, int duration_rx_to_tx, openair0_timestamp rx_offset) +static void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp_t *timestamp, int duration_rx_to_tx, openair0_timestamp_t rx_offset) { NR_DL_FRAME_PARMS *fp = &UE->frame_parms; if (UE->sl_mode == 2) @@ -721,7 +722,7 @@ static void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp, int d DevAssert(unitTransfer == res); if (IS_SOFTMODEM_RFSIM) { int ta = UE->timing_advance + UE->timing_advance_ntn; - const openair0_timestamp writeTimestamp = + const openair0_timestamp_t writeTimestamp = *timestamp + get_samples_slot_duration(fp, slot, duration_rx_to_tx) - UE->N_TA_offset - ta; dummyWrite(UE, writeTimestamp, unitTransfer); } @@ -798,7 +799,7 @@ void *UE_thread(void *arg) } int shiftForNextFrame = 0; int intialSyncOffset = 0; - openair0_timestamp sync_timestamp; + openair0_timestamp_t sync_timestamp; bool stats_printed = false; if (get_softmodem_params()->sync_ref && UE->sl_mode == 2) { @@ -995,7 +996,7 @@ void *UE_thread(void *arg) } const int readBlockSize = get_readBlockSize(slot_nr, fp) - iq_shift_to_apply; - openair0_timestamp rx_timestamp; + openair0_timestamp_t rx_timestamp; int tmp = UE->rfdevice.trx_read_func(&UE->rfdevice, &rx_timestamp, rxp, readBlockSize, fp->nb_antennas_rx); metadata meta = {.slot = curMsg.proc.nr_slot_rx, .frame = curMsg.proc.frame_rx}; UEscopeCopyWithMetadata(UE, ueTimeDomainSamples, rxp[0] - firstSymSamp * sizeof(c16_t), sizeof(c16_t), 1, readBlockSize, 0, &meta); @@ -1010,7 +1011,7 @@ void *UE_thread(void *arg) int first_symbols = fp->ofdm_symbol_size + fp->nb_prefix_samples0; // first symbol of every frames if (first_symbols > 0) { - openair0_timestamp ignore_timestamp; + openair0_timestamp_t ignore_timestamp; int tmp = UE->rfdevice.trx_read_func(&UE->rfdevice, &ignore_timestamp, (void **)UE->common_vars.rxdata, @@ -1023,7 +1024,7 @@ void *UE_thread(void *arg) } // use previous timing_advance value to compute writeTimestamp - const openair0_timestamp writeTimestamp = + const openair0_timestamp_t writeTimestamp = rx_timestamp + get_samples_slot_duration(fp, slot_nr, duration_rx_to_tx) - firstSymSamp - UE->N_TA_offset - timing_advance; // Calculate TX deadline, approximately 1 symbol before the first sample should be written diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 6fbfcb3cac..d7ce4a64a4 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -320,7 +320,7 @@ uint32_t get_samples_symbol_timestamp(const NR_DL_FRAME_PARMS *fp, int slot, int return get_samples_symbol_duration(fp, slot, 0, symbol); } -uint32_t get_slot_from_timestamp(openair0_timestamp timestamp_rx, const NR_DL_FRAME_PARMS *fp) +uint32_t get_slot_from_timestamp(openair0_timestamp_t timestamp_rx, const NR_DL_FRAME_PARMS *fp) { timestamp_rx = timestamp_rx % fp->samples_per_frame; if (timestamp_rx < fp->samples_per_slot0) diff --git a/openair1/PHY/INIT/tests/test_nr_frame_params.cpp b/openair1/PHY/INIT/tests/test_nr_frame_params.cpp index e3e541f8ab..acf43ec0b8 100644 --- a/openair1/PHY/INIT/tests/test_nr_frame_params.cpp +++ b/openair1/PHY/INIT/tests/test_nr_frame_params.cpp @@ -41,7 +41,7 @@ uint32_t ref_get_samples_slot_timestamp(NR_DL_FRAME_PARMS *fp, unsigned int slot return samp_count; } -uint32_t ref_get_slot_from_timestamp(openair0_timestamp ts, NR_DL_FRAME_PARMS *fp) +uint32_t ref_get_slot_from_timestamp(openair0_timestamp_t ts, NR_DL_FRAME_PARMS *fp) { uint32_t slot_idx = 0; int samples_till_the_slot = get_samples_per_slot(slot_idx, fp) - 1; @@ -75,7 +75,7 @@ void test_coherence_slot_api(NR_DL_FRAME_PARMS *fp) EXPECT_EQ(get_samples_slot_timestamp(fp, slot), ref_get_samples_slot_timestamp(fp, slot)); } - openair0_timestamp ts = get_samples_per_slot(0, fp); + openair0_timestamp_t ts = get_samples_per_slot(0, fp); // When timestamp is the last sample of the slot EXPECT_EQ(get_slot_from_timestamp(ts - 1, fp), 0); for (unsigned int slot = 0; slot < fp->slots_per_frame; slot++) { @@ -174,4 +174,4 @@ int main(int argc, char **argv) logInit(); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); -} \ No newline at end of file +} diff --git a/openair1/PHY/TOOLS/calibration_scope.c b/openair1/PHY/TOOLS/calibration_scope.c index c7a305ab27..eb80dec38e 100644 --- a/openair1/PHY/TOOLS/calibration_scope.c +++ b/openair1/PHY/TOOLS/calibration_scope.c @@ -18,7 +18,7 @@ typedef struct { #define SquaredNorm(VaR) ((VaR).r*(VaR).r+(VaR).i*(VaR).i) typedef struct { void ** samplesRx; - openair0_device *rfdevice; + openair0_device_t *rfdevice; } calibData_t; typedef struct OAIgraph { @@ -384,7 +384,8 @@ static void *scopeThread(void *arg) { return NULL; } -void CalibrationInitScope(void ** samplesRx,openair0_device *rfdevice) { +void CalibrationInitScope(void **samplesRx, openair0_device_t *rfdevice) +{ pthread_t forms_thread; calibData_t *tmp = (calibData_t *)malloc_or_fail(sizeof(*tmp)); tmp->samplesRx=samplesRx; diff --git a/openair1/PHY/TOOLS/calibration_scope.h b/openair1/PHY/TOOLS/calibration_scope.h index 052a1a6b6e..f2646d79ab 100644 --- a/openair1/PHY/TOOLS/calibration_scope.h +++ b/openair1/PHY/TOOLS/calibration_scope.h @@ -1,5 +1,5 @@ #ifndef CALIB_SCOPE_H #define CALIB_SCOPE_H -void CalibrationInitScope(void ** samplesRx,openair0_device *rfdevice); +void CalibrationInitScope(void **samplesRx, openair0_device_t *rfdevice); #endif diff --git a/openair1/PHY/TOOLS/calibration_test.c b/openair1/PHY/TOOLS/calibration_test.c index 8007040499..223c46e9a0 100644 --- a/openair1/PHY/TOOLS/calibration_test.c +++ b/openair1/PHY/TOOLS/calibration_test.c @@ -125,7 +125,7 @@ int main(int argc, char **argv) { .samples_per_tti=0, }; //----------------------- - openair0_device rfdevice= { + openair0_device_t rfdevice= { /*!tx write thread*/ //.write_thread={0}, /*!brief Module ID of this device */ @@ -306,7 +306,7 @@ int main(int argc, char **argv) { } CalibrationInitScope(samplesRx, &rfdevice); - openair0_timestamp timestamp=0; + openair0_timestamp_t timestamp=0; rfdevice.trx_start_func(&rfdevice); while(!oai_exit) { diff --git a/openair1/PHY/defs_L1_NB_IoT.h b/openair1/PHY/defs_L1_NB_IoT.h index 97f243fae8..41ab07a6b1 100644 --- a/openair1/PHY/defs_L1_NB_IoT.h +++ b/openair1/PHY/defs_L1_NB_IoT.h @@ -222,7 +222,7 @@ typedef struct { /// Context data structure for RX/TX portion of subframe processing typedef struct { /// timestamp transmitted to HW - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; /// subframe to act upon for transmission int subframe_tx; /// subframe to act upon for reception @@ -273,9 +273,9 @@ typedef struct eNB_proc_NB_IoT_t_s { /// thread index int thread_index; /// timestamp received from HW - openair0_timestamp timestamp_rx; + openair0_timestamp_t timestamp_rx; /// timestamp to send to "slave rru" - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; /// subframe to act upon for reception int subframe_rx; /// symbol mask for IF4p5 reception per subframe @@ -414,7 +414,7 @@ typedef struct { /// index of the current UE RX/TX proc int proc_id; /// timestamp transmitted to HW - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; /// subframe to act upon for transmission int subframe_tx; /// subframe to act upon for reception @@ -445,7 +445,7 @@ typedef struct { /// Context data structure for eNB subframe processing typedef struct { /// Last RX timestamp - openair0_timestamp timestamp_rx; + openair0_timestamp_t timestamp_rx; /// pthread attributes for main UE thread pthread_attr_t attr_ue; /// scheduling parameters for main UE thread @@ -484,9 +484,9 @@ typedef struct PHY_VARS_eNB_NB_IoT_s { eth_params_t eth_params_n; /// Ethernet parameters for fronthaul interface (upper L1 to Radio head) eth_params_t eth_params; - openair0_rf_map rf_map; + openair0_rf_map_t rf_map; int abstraction_flag; - openair0_timestamp ts_offset; + openair0_timestamp_t ts_offset; // indicator for synchronization state of eNB int in_synch; // indicator for master/slave (RRU) @@ -672,8 +672,8 @@ typedef struct PHY_VARS_eNB_NB_IoT_s { int32_t pusch_stats_BO[NUMBER_OF_UE_MAX][10240]; /// RF and Interface devices per CC - openair0_device rfdevice; - openair0_device ifdevice; + openair0_device_t rfdevice; + openair0_device_t ifdevice; /// Pointer for ifdevice buffer struct if_buffer_t ifbuffer; @@ -731,7 +731,7 @@ typedef struct { /// \brief Module ID indicator for this instance uint8_t Mod_id; /// \brief Mapping of CC_id antennas to cards - openair0_rf_map rf_map; + openair0_rf_map_t rf_map; //uint8_t local_flag; /// \brief Indicator of current run mode of UE (normal_txrx, rx_calib_ue, no_L2_connect, debug_prach) runmode_NB_IoT_t mode; @@ -956,7 +956,7 @@ typedef struct { time_stats_t tx_prach; /// RF and Interface devices per CC - openair0_device rfdevice; + openair0_device_t rfdevice; time_stats_t dlsch_encoding_SIC_stats; time_stats_t dlsch_scrambling_SIC_stats; time_stats_t dlsch_modulation_SIC_stats; diff --git a/openair1/PHY/defs_RU.h b/openair1/PHY/defs_RU.h index 9e69bda093..851d417804 100644 --- a/openair1/PHY/defs_RU.h +++ b/openair1/PHY/defs_RU.h @@ -196,9 +196,9 @@ typedef struct RU_proc_t_s { /// Pointer to associated RU descriptor struct RU_t_s *ru; /// timestamp received from HW - openair0_timestamp timestamp_rx; + openair0_timestamp_t timestamp_rx; /// timestamp to send to "slave rru" - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; /// subframe (LTE) / slot (NR) to act upon for reception int tti_rx; /// subframe (LTE) / slot (NR) to act upon for transmission @@ -354,7 +354,7 @@ typedef struct RU_proc_t_s { /// subframe to act upon for transmission int subframe_phy_tx; /// timestamp to send to "slave rru" - openair0_timestamp timestamp_phy_tx; + openair0_timestamp_t timestamp_phy_tx; /// pthread structure for RF TX thread pthread_t pthread_rf_tx; pthread_mutex_t mutex_rf_tx; @@ -500,7 +500,7 @@ typedef struct RU_t_s { /// "end of burst delay" used in TDD (unit: number of samples at 30.72MHz) (this is an expert option) int end_of_burst_delay; /// RF device descriptor - openair0_device rfdevice; + openair0_device_t rfdevice; /// HW configuration openair0_config_t openair0_cfg; /// Number of NBs using this RU @@ -510,9 +510,9 @@ typedef struct RU_t_s { struct PHY_VARS_eNB_s *eNB_list[NUMBER_OF_eNB_MAX]; struct PHY_VARS_gNB_s *gNB_list[NUMBER_OF_gNB_MAX]; /// Mapping of antenna ports to RF chain index - openair0_rf_map rf_map; + openair0_rf_map_t rf_map; /// IF device descriptor - openair0_device ifdevice; + openair0_device_t ifdevice; /// Pointer for ifdevice buffer struct if_buffer_t ifbuffer; /// if prach processing is to be performed in RU @@ -599,7 +599,7 @@ typedef struct RU_t_s { /// sequence number for IF5 uint8_t seqno; /// initial timestamp used as an offset make first real timestamp 0 - openair0_timestamp ts_offset; + openair0_timestamp_t ts_offset; /// Current state of the RU rru_state_t state; /// Command to do @@ -758,7 +758,7 @@ typedef struct processingData_RU { int frame_tx; int slot_tx; int next_slot; - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; RU_t *ru; } processingData_RU_t; #endif //__PHY_DEFS_RU__H__ diff --git a/openair1/PHY/defs_UE.h b/openair1/PHY/defs_UE.h index 20d5a9ab8d..84477cad8a 100644 --- a/openair1/PHY/defs_UE.h +++ b/openair1/PHY/defs_UE.h @@ -91,7 +91,7 @@ typedef struct { /// Component Carrier index uint8_t CC_id; /// timestamp transmitted to HW - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; /// subframe to act upon for transmission int subframe_tx; /// subframe to act upon for reception @@ -148,7 +148,7 @@ typedef struct { /// Component Carrier index uint8_t CC_id; /// Last RX timestamp - openair0_timestamp timestamp_rx; + openair0_timestamp_t timestamp_rx; /// pthread attributes for main UE thread pthread_attr_t attr_ue; /// scheduling parameters for main UE thread @@ -550,7 +550,7 @@ typedef struct { /// \brief Component carrier ID for this PHY instance uint8_t CC_id; /// \brief Mapping of CC_id antennas to cards - openair0_rf_map rf_map; + openair0_rf_map_t rf_map; //uint8_t local_flag; /// \brief Indicator of current run mode of UE (normal_txrx, rx_calib_ue, no_L2_connect, debug_prach) runmode_t mode; @@ -817,7 +817,7 @@ typedef struct { int instance_cnt_timer; /// RF and Interface devices per CC - openair0_device rfdevice; + openair0_device_t rfdevice; void *scopeData; } PHY_VARS_UE; diff --git a/openair1/PHY/defs_eNB.h b/openair1/PHY/defs_eNB.h index 6ae50482cc..441c7b8f96 100644 --- a/openair1/PHY/defs_eNB.h +++ b/openair1/PHY/defs_eNB.h @@ -218,8 +218,8 @@ typedef struct { /// Component Carrier index uint8_t CC_id; /// timestamp transmitted to HW - openair0_timestamp timestamp_tx; - openair0_timestamp timestamp_rx; + openair0_timestamp_t timestamp_tx; + openair0_timestamp_t timestamp_rx; /// subframe to act upon for transmission int subframe_tx; /// subframe to act upon for reception @@ -285,9 +285,9 @@ typedef struct L1_proc_t_s { /// thread index int thread_index; /// timestamp received from HW - openair0_timestamp timestamp_rx; + openair0_timestamp_t timestamp_rx; /// timestamp to send to "slave rru" - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; /// subframe to act upon for reception int subframe_rx; /// subframe to act upon for PRACH diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index f3350d707e..46ba246dbe 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -288,7 +288,7 @@ typedef struct { /// Component Carrier index uint8_t CC_id; /// timestamp transmitted to HW - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; /// slot to act upon for transmission int slot_tx; /// slot to act upon for reception @@ -312,9 +312,9 @@ typedef struct gNB_L1_proc_t_s { /// Component Carrier index uint8_t CC_id; /// timestamp received from HW - openair0_timestamp timestamp_rx; + openair0_timestamp_t timestamp_rx; /// timestamp to send to "slave rru" - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; /// slot to act upon for reception int slot_rx; /// frame to act upon for reception @@ -566,7 +566,7 @@ union ldpcReqUnion { typedef struct processingData_L1 { int frame_rx; int slot_rx; - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; PHY_VARS_gNB *gNB; notifiedFIFO_elt_t *elt; } processingData_L1_t; @@ -576,7 +576,7 @@ typedef struct processingData_L1tx { int slot; int frame_rx; int slot_rx; - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; PHY_VARS_gNB *gNB; } processingData_L1tx_t; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index e96927fe21..e04a49c8e4 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -113,7 +113,7 @@ typedef struct { /// Component Carrier index uint8_t CC_id; /// Last RX timestamp - openair0_timestamp timestamp_rx; + openair0_timestamp_t timestamp_rx; } UE_nr_proc_t; typedef enum { @@ -350,7 +350,7 @@ typedef struct PHY_VARS_NR_UE_s { /// \brief Component carrier ID for this PHY instance uint8_t CC_id; /// \brief Mapping of CC_id antennas to cards - openair0_rf_map rf_map; + openair0_rf_map_t rf_map; /// \brief Indicator that UE should perform band scanning int UE_scan; /// \brief Indicator that UE should perform coarse scanning around carrier @@ -508,7 +508,7 @@ typedef struct PHY_VARS_NR_UE_s { nr_ue_phy_cpu_stat_t phy_cpu_stats; /// RF and Interface devices per CC - openair0_device rfdevice; + openair0_device_t rfdevice; /// Phase precompensation flag bool no_phase_pre_comp; @@ -540,7 +540,7 @@ typedef struct PHY_VARS_NR_UE_s { } PHY_VARS_NR_UE; typedef struct { - openair0_timestamp timestamp_tx; + openair0_timestamp_t timestamp_tx; int gNB_id; /// NR slot index within frame_tx [0 .. slots_per_frame - 1] to act upon for transmission int nr_slot_tx; diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index b9948eaf92..96c03cd754 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -334,7 +334,7 @@ uint32_t get_samples_slot_duration(const NR_DL_FRAME_PARMS *fp, unsigned int sta // Get timestamp of slot from start of frame uint32_t get_samples_slot_timestamp(const NR_DL_FRAME_PARMS *fp, unsigned int slot); // Get slot from timestamp -uint32_t get_slot_from_timestamp(openair0_timestamp timestamp_rx, const NR_DL_FRAME_PARMS *fp); +uint32_t get_slot_from_timestamp(openair0_timestamp_t timestamp_rx, const NR_DL_FRAME_PARMS *fp); // Get number of samples in the slot uint32_t get_samples_per_slot(int slot, const NR_DL_FRAME_PARMS *fp); diff --git a/openair1/SIMULATION/LTE_PHY/unitary_defs.h b/openair1/SIMULATION/LTE_PHY/unitary_defs.h index f0c3f32b1b..8a411902c8 100644 --- a/openair1/SIMULATION/LTE_PHY/unitary_defs.h +++ b/openair1/SIMULATION/LTE_PHY/unitary_defs.h @@ -19,7 +19,7 @@ * contact@openairinterface.org */ -openair0_device openair0; +openair0_device_t openair0; int oai_exit=0; void exit_function(const char* file, const char* function, const int line,const char* s, const int assert) { diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h index 6e60ce76de..d31109a836 100644 --- a/openair1/SIMULATION/TOOLS/sim.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -328,8 +328,8 @@ typedef struct { int RU_output_mask[NUMBER_OF_UE_MAX]; pthread_mutex_t RU_output_mutex[NUMBER_OF_UE_MAX]; pthread_mutex_t UE_output_mutex[NUMBER_OF_RU_MAX]; - openair0_timestamp current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; - openair0_timestamp current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; + openair0_timestamp_t current_ru_rx_timestamp[NUMBER_OF_RU_MAX][MAX_NUM_CCs]; + openair0_timestamp_t current_UE_rx_timestamp[MAX_MOBILES_PER_ENB][MAX_NUM_CCs]; double ru_amp[NUMBER_OF_RU_MAX]; } sim_t; diff --git a/radio/AW2SORI/oaiori.c b/radio/AW2SORI/oaiori.c index 8665abc86a..b17c7e5dfd 100644 --- a/radio/AW2SORI/oaiori.c +++ b/radio/AW2SORI/oaiori.c @@ -212,8 +212,8 @@ void cb(void * userData, ORI_IndicationType_e type, ORI_IndicationValue_u value) printf("<============\n"); } -int aw2s_oricleanup(openair0_device *device) { - +int aw2s_oricleanup(openair0_device_t *device) +{ ORI_s * ori = (ORI_s*)device->thirdparty_priv; ORI_Disconnect(ori); @@ -222,8 +222,8 @@ int aw2s_oricleanup(openair0_device *device) { return(0); } -int aw2s_startstreaming(openair0_device *device) { - +int aw2s_startstreaming(openair0_device_t *device) +{ ORI_s * ori = (ORI_s*)device->thirdparty_priv; ORI_Result_e result; ORI_Result_e RE_result; @@ -413,9 +413,8 @@ int aw2s_startstreaming(openair0_device *device) { printf("ORI_ObjectStateModify: %s\n", ORI_Result_Print(RE_result)); } - device->fhstate.active=1; - return(0); - + device->fhstate.active = 1; + return (0); } uint32_t to_nrarfcn(int nr_bandP, @@ -423,9 +422,8 @@ uint32_t to_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t bw); -int aw2s_oriinit(openair0_device *device) { - - +int aw2s_oriinit(openair0_device_t *device) +{ ORI_s * ori; ORI_Result_e result; ORI_Result_e RE_result; @@ -892,9 +890,8 @@ int aw2s_oriinit(openair0_device *device) { return 0; } - -int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t * eth_params ) { - +int transport_init(openair0_device_t *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params) +{ printf("Initializing AW2S (%p,%p,%p)\n",aw2s_oriinit,aw2s_oricleanup,aw2s_startstreaming); device->thirdparty_init = aw2s_oriinit; device->thirdparty_cleanup = aw2s_oricleanup; diff --git a/radio/BLADERF/bladerf_lib.c b/radio/BLADERF/bladerf_lib.c index bff12bee8e..2298287b5a 100644 --- a/radio/BLADERF/bladerf_lib.c +++ b/radio/BLADERF/bladerf_lib.c @@ -46,7 +46,7 @@ int num_devices=0; * \param device RF frontend parameters set by application * \returns 0 on success */ -int trx_brf_init(openair0_device *device) +int trx_brf_init(openair0_device_t *device) { return 0; } @@ -57,8 +57,7 @@ int trx_brf_init(openair0_device *device) *\param module the bladeRf module *\returns timestamp of BladeRF */ -openair0_timestamp trx_get_timestamp(openair0_device *device, - bladerf_module module) +openair0_timestamp_t trx_get_timestamp(openair0_device_t *device, bladerf_module module) { int status; struct bladerf_metadata meta; @@ -78,7 +77,7 @@ openair0_timestamp trx_get_timestamp(openair0_device *device, * \param device the hardware to use * \returns 0 on success */ -int trx_brf_start(openair0_device *device) +int trx_brf_start(openair0_device_t *device) { brf_state_t *brf = (brf_state_t*)device->priv; int status; @@ -127,12 +126,7 @@ int trx_brf_start(openair0_device *device) \param flags Ignored for the moment \returns 0 on success */ -static int trx_brf_write(openair0_device *device, - openair0_timestamp ptimestamp, - void **buff, - int nsamps, - int cc, - int flags) +static int trx_brf_write(openair0_device_t *device, openair0_timestamp_t ptimestamp, void **buff, int nsamps, int cc, int flags) { int status; brf_state_t *brf = (brf_state_t*)device->priv; @@ -185,11 +179,7 @@ static int trx_brf_write(openair0_device *device, * \param cc Index of component carrier * \returns number of samples read */ -static int trx_brf_read(openair0_device *device, - openair0_timestamp *ptimestamp, - void **buff, - int nsamps, - int cc) +static int trx_brf_read(openair0_device_t *device, openair0_timestamp_t *ptimestamp, void **buff, int nsamps, int cc) { int status=0; brf_state_t *brf = (brf_state_t*)device->priv; @@ -235,7 +225,7 @@ static int trx_brf_read(openair0_device *device, /*! \brief Terminate operation of the BladeRF transceiver -- free all associated resources * \param device the hardware to use */ -void trx_brf_end(openair0_device *device) +void trx_brf_end(openair0_device_t *device) { int status; brf_state_t *brf = (brf_state_t*)device->priv; @@ -255,7 +245,7 @@ void trx_brf_end(openair0_device *device) * \param device the hardware to use * \returns 0 on success */ -int trx_brf_get_stats(openair0_device* device) +int trx_brf_get_stats(openair0_device_t *device) { return(0); } @@ -265,7 +255,7 @@ int trx_brf_get_stats(openair0_device* device) * \param device the hardware to use * \returns 0 on success */ -int trx_brf_reset_stats(openair0_device* device) +int trx_brf_reset_stats(openair0_device_t *device) { return(0); } @@ -275,7 +265,7 @@ int trx_brf_reset_stats(openair0_device* device) * \param card the hardware to use * \returns 0 in success */ -int trx_brf_stop(openair0_device* device) +int trx_brf_stop(openair0_device_t *device) { return(0); } @@ -286,7 +276,7 @@ int trx_brf_stop(openair0_device* device) * \param openair0_cfg1 openair0 Config structure (ignored. It is there to comply with RF common API) * \returns 0 in success */ -int trx_brf_set_freq(openair0_device* device, openair0_config_t *openair0_cfg1) +int trx_brf_set_freq(openair0_device_t *device, openair0_config_t *openair0_cfg1) { int status; brf_state_t *brf = (brf_state_t *)device->priv; @@ -315,12 +305,11 @@ int trx_brf_set_freq(openair0_device* device, openair0_config_t *openair0_cfg1) * \param openair0_cfg openair0 Config structure * \returns 0 in success */ -int trx_brf_set_gains(openair0_device* device, - openair0_config_t *openair0_cfg) +int trx_brf_set_gains(openair0_device_t *device, openair0_config_t *openair0_cfg) { return(0); } -int trx_brf_write_init(openair0_device *device) +int trx_brf_write_init(openair0_device_t *device) { return 0; } @@ -368,13 +357,13 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, /*! \brief Calibrate LMSSDR RF * \param device the hardware to use */ -void calibrate_rf(openair0_device *device) +void calibrate_rf(openair0_device_t *device) { /* TODO: this function does not seem to work. Disabled until fixed. */ return; brf_state_t *brf = (brf_state_t *)device->priv; - openair0_timestamp ptimestamp; + openair0_timestamp_t ptimestamp; int16_t *calib_buffp,*calib_tx_buffp; int16_t calib_buff[2*RXDCLENGTH]; int16_t calib_tx_buff[2*RXDCLENGTH]; @@ -948,8 +937,7 @@ void calibrate_rf(openair0_device *device) * \param openair0_cfg RF frontend parameters set by application * \returns 0 on success */ -int device_init(openair0_device *device, - openair0_config_t *openair0_cfg) +int device_init(openair0_device_t *device, openair0_config_t *openair0_cfg) { int status; brf_state_t *brf = (brf_state_t*)malloc(sizeof(brf_state_t)); @@ -1138,7 +1126,7 @@ int device_init(openair0_device *device, */ bladerf_log_set_verbosity(BLADERF_LOG_LEVEL_INFO); - printf("BLADERF: Initializing openair0_device\n"); + printf("BLADERF: Initializing openair0_device_t\n"); device->Mod_id = num_devices++; device->type = BLADERF_DEV; device->trx_start_func = trx_brf_start; diff --git a/radio/BLADERF/bladerf_lib.h b/radio/BLADERF/bladerf_lib.h index 7c736eb098..a3ba44ee6c 100644 --- a/radio/BLADERF/bladerf_lib.h +++ b/radio/BLADERF/bladerf_lib.h @@ -94,7 +94,7 @@ typedef struct { //! number of RX count uint64_t rx_count; //! timestamp of RX packet - openair0_timestamp rx_timestamp; + openair0_timestamp_t rx_timestamp; } brf_state_t; /* @@ -103,13 +103,13 @@ typedef struct { /*! \brief BladeRF Init function (not used at the moment) * \param device RF frontend parameters set by application */ -int trx_brf_init(openair0_device *device); +int trx_brf_init(openair0_device_t *device); /*! \brief get current timestamp *\param device the hardware to use *\param module the bladeRf module */ -openair0_timestamp trx_get_timestamp(openair0_device *device, bladerf_module module); +openair0_timestamp_t trx_get_timestamp(openair0_device_t *device, bladerf_module module); /*! \brief bladeRF error report * \param status diff --git a/radio/COMMON/common_lib.c b/radio/COMMON/common_lib.c index 670a9cc852..104546b795 100644 --- a/radio/COMMON/common_lib.c +++ b/radio/COMMON/common_lib.c @@ -53,7 +53,7 @@ const char *get_devname(int devtype) { return "none"; } -int set_device(openair0_device *device) +int set_device(openair0_device_t *device) { const char *devname = get_devname(device->type); if (strcmp(devname,"none") != 0) { @@ -65,7 +65,7 @@ int set_device(openair0_device *device) return 0; } -int set_transport(openair0_device *device) +int set_transport(openair0_device_t *device) { switch (device->transp_type) { case ETHERNET_TP: @@ -85,14 +85,10 @@ int set_transport(openair0_device *device) } } -typedef int(*devfunc_t)(openair0_device *, openair0_config_t *, eth_params_t *); - +typedef int (*devfunc_t)(openair0_device_t *, openair0_config_t *, eth_params_t *); /* look for the interface library and load it */ -int load_lib(openair0_device *device, - openair0_config_t *openair0_cfg, - eth_params_t *cfg, - uint8_t flag) +int load_lib(openair0_device_t *device, openair0_config_t *openair0_cfg, eth_params_t *cfg, uint8_t flag) { loader_shlibfunc_t shlib_fdesc[1]; int ret=0; @@ -139,9 +135,7 @@ int load_lib(openair0_device *device, return ((devfunc_t)shlib_fdesc[0].fptr)(device,openair0_cfg,cfg); } - -int openair0_device_load(openair0_device *device, - openair0_config_t *openair0_cfg) +int openair0_device_load(openair0_device_t *device, openair0_config_t *openair0_cfg) { int rc=0; rc=load_lib(device, openair0_cfg, NULL,RAU_LOCAL_RADIO_HEAD ); @@ -157,10 +151,7 @@ int openair0_device_load(openair0_device *device, return rc; } - -int openair0_transport_load(openair0_device *device, - openair0_config_t *openair0_cfg, - eth_params_t *eth_params) +int openair0_transport_load(openair0_device_t *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params) { int rc; rc=load_lib(device, openair0_cfg, eth_params, RAU_REMOTE_RADIO_HEAD); @@ -175,7 +166,7 @@ int openair0_transport_load(openair0_device *device, return rc; } -static void writerEnqueue(re_order_t *ctx, openair0_timestamp timestamp, void **txp, int nsamps, int nbAnt, int flags) +static void writerEnqueue(re_order_t *ctx, openair0_timestamp_t timestamp, void **txp, int nsamps, int nbAnt, int flags) { pthread_mutex_lock(&ctx->mutex_store); LOG_D(HW, "Enqueue write for TS: %lu\n", timestamp); @@ -196,7 +187,7 @@ static void writerEnqueue(re_order_t *ctx, openair0_timestamp timestamp, void ** pthread_mutex_unlock(&ctx->mutex_store); } -static void writerProcessWaitingQueue(openair0_device *device) +static void writerProcessWaitingQueue(openair0_device_t *device) { bool found = false; re_order_t *ctx = &device->reOrder; @@ -205,7 +196,7 @@ static void writerProcessWaitingQueue(openair0_device *device) pthread_mutex_lock(&ctx->mutex_store); for (int i = 0; i < WRITE_QUEUE_SZ; i++) { if (ctx->queue[i].active && llabs(ctx->queue[i].timestamp - ctx->nextTS) < MAX_GAP) { - openair0_timestamp timestamp = ctx->queue[i].timestamp; + openair0_timestamp_t timestamp = ctx->queue[i].timestamp; LOG_D(HW, "Dequeue write for TS: %lu\n", timestamp); int nsamps = ctx->queue[i].nsamps; int nbAnt = ctx->queue[i].nbAnt; @@ -235,7 +226,7 @@ static void writerProcessWaitingQueue(openair0_device *device) // but to make zerocopy and agnostic design, we need to make a proper ring buffer with mutex protection // mutex (or atomic flags) will be mandatory because this out order system root cause is there are several writer threads -int openair0_write_reorder(openair0_device *device, openair0_timestamp timestamp, void **txp, int nsamps, int nbAnt, int flags) +int openair0_write_reorder(openair0_device_t *device, openair0_timestamp_t timestamp, void **txp, int nsamps, int nbAnt, int flags) { int wroteSamples = 0; re_order_t *ctx = &device->reOrder; @@ -270,7 +261,7 @@ int openair0_write_reorder(openair0_device *device, openair0_timestamp timestamp return nsamps; } -void openair0_write_reorder_clear_context(openair0_device *device) +void openair0_write_reorder_clear_context(openair0_device_t *device) { LOG_I(HW, "received write reorder clear context\n"); re_order_t *ctx = &device->reOrder; diff --git a/radio/COMMON/common_lib.h b/radio/COMMON/common_lib.h index 5877506ea2..e5f55fe309 100644 --- a/radio/COMMON/common_lib.h +++ b/radio/COMMON/common_lib.h @@ -58,12 +58,11 @@ #define MAX_WRITE_THREAD_BUFFER_SIZE 8 #define MAX_CARDS 8 -typedef int64_t openair0_timestamp; -typedef volatile int64_t openair0_vtimestamp; - +typedef int64_t openair0_timestamp_t; +typedef volatile int64_t openair0_vtimestamp_t; /*!\brief structure holds the parameters to configure USRP devices*/ -typedef struct openair0_device_t openair0_device; +typedef struct openair0_device openair0_device_t; //#define USRP_GAIN_OFFSET (56.0) // 86 calibrated for USRP B210 @ 2.6 GHz to get equivalent RS EPRE in OAI to SMBV100 output @@ -167,7 +166,7 @@ typedef enum { /*! \brief Structure used for initializing UDP read threads */ typedef struct { - openair0_device *device; + openair0_device_t *device; int thread_id; pthread_t pthread; notifiedFIFO_t *resp; @@ -317,8 +316,7 @@ typedef struct { int card; //! rf chain id int chain; -} openair0_rf_map; - +} openair0_rf_map_t; typedef struct { char *remote_addr; @@ -350,7 +348,7 @@ typedef struct { } if_buffer_t; typedef struct { - openair0_timestamp timestamp; + openair0_timestamp_t timestamp; void *buff[MAX_WRITE_THREAD_BUFFER_SIZE];// buffer to be write; int nsamps; int cc; @@ -378,11 +376,11 @@ typedef struct { } openair0_thread_t; typedef struct fhstate_s { - openair0_timestamp TS[8]; - openair0_timestamp TS0; - openair0_timestamp olddeltaTS[8]; - openair0_timestamp oldTS[8]; - openair0_timestamp TS_read; + openair0_timestamp_t TS[8]; + openair0_timestamp_t TS0; + openair0_timestamp_t olddeltaTS[8]; + openair0_timestamp_t oldTS[8]; + openair0_timestamp_t TS_read; int first_read; uint32_t *buff[8]; uint32_t buff_size; @@ -395,10 +393,10 @@ typedef struct { bool initDone; pthread_mutex_t mutex_write; pthread_mutex_t mutex_store; - openair0_timestamp nextTS; + openair0_timestamp_t nextTS; struct { bool active; - openair0_timestamp timestamp; + openair0_timestamp_t timestamp; void *txp[NB_ANTENNAS_TX]; int nsamps; int nbAnt; @@ -407,7 +405,7 @@ typedef struct { } re_order_t; /*!\brief structure holds the parameters to configure USRP devices */ -struct openair0_device_t { +struct openair0_device { /*!tx write thread*/ openair0_thread_t write_thread; @@ -463,28 +461,27 @@ struct openair0_device_t { /*! \brief Called to start the transceiver. Return 0 if OK, < 0 if error @param device pointer to the device structure specific to the RF hardware target */ - int (*trx_start_func)(openair0_device *device); + int (*trx_start_func)(openair0_device_t *device); - /*! \brief Called to configure the device - @param device pointer to the device structure specific to the RF hardware target - */ + /*! \brief Called to configure the device + @param device pointer to the device structure specific to the RF hardware target + */ - - int (*trx_config_func)(openair0_device* device, openair0_config_t *openair0_cfg); + int (*trx_config_func)(openair0_device_t *device, openair0_config_t *openair0_cfg); /*! \brief Called to send a request message between RAU-RRU on control port @param device pointer to the device structure specific to the RF hardware target @param msg pointer to the message structure passed between RAU-RRU @param msg_len length of the message */ - int (*trx_ctlsend_func)(openair0_device *device, void *msg, ssize_t msg_len); + int (*trx_ctlsend_func)(openair0_device_t *device, void *msg, ssize_t msg_len); /*! \brief Called to receive a reply message between RAU-RRU on control port @param device pointer to the device structure specific to the RF hardware target @param msg pointer to the message structure passed between RAU-RRU @param msg_len length of the message */ - int (*trx_ctlrecv_func)(openair0_device *device, void *msg, ssize_t msg_len); + int (*trx_ctlrecv_func)(openair0_device_t *device, void *msg, ssize_t msg_len); /*! \brief Called to send samples to the RF target @param device pointer to the device structure specific to the RF hardware target @@ -495,8 +492,8 @@ struct openair0_device_t { @param num_beams number of beams @param flags flags must be set to true if timestamp parameter needs to be applied */ - int (*trx_write_beams_func)(openair0_device *device, - openair0_timestamp timestamp, + int (*trx_write_beams_func)(openair0_device_t *device, + openair0_timestamp_t timestamp, void ***buff, int nsamps, int nb_antennas_tx, @@ -511,7 +508,12 @@ struct openair0_device_t { @param nb_antennas_tx number of antennas @param flags flags must be set to true if timestamp parameter needs to be applied */ - int (*trx_write_func)(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int nb_antennas_tx, int flags); + int (*trx_write_func)(openair0_device_t *device, + openair0_timestamp_t timestamp, + void **buff, + int nsamps, + int nb_antennas_tx, + int flags); /*! \brief Called to send samples to the RF target @param device pointer to the device structure specific to the RF hardware target @@ -520,7 +522,13 @@ struct openair0_device_t { @param nsamps number of samples to be sent @param flags flags must be set to true if timestamp parameter needs to be applied */ - int (*trx_write_func2)(openair0_device *device, openair0_timestamp timestamp, void **buff, int fd_ind,int nsamps, int flags,int nant); + int (*trx_write_func2)(openair0_device_t *device, + openair0_timestamp_t timestamp, + void **buff, + int fd_ind, + int nsamps, + int flags, + int nant); /*! \brief Receive samples from hardware. * Read nsamps samples from each channel to buffers. buff[0] is the array for @@ -533,7 +541,7 @@ struct openair0_device_t { * antennas from which to receive samples \returns the number of sample read */ - int (*trx_read_func)(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int num_antennas); + int (*trx_read_func)(openair0_device_t *device, openair0_timestamp_t *ptimestamp, void **buff, int nsamps, int num_antennas); /*! \brief Receive samples from hardware. * Read nsamps samples from each channel to buffers. buff[0] is the array for @@ -548,8 +556,8 @@ struct openair0_device_t { * \param num_beams number of beams from which to receive samples * \returns the number of sample read */ - int (*trx_read_beams_func)(openair0_device *device, - openair0_timestamp *ptimestamp, + int (*trx_read_beams_func)(openair0_device_t *device, + openair0_timestamp_t *ptimestamp, void ***buff, int nsamps, int num_antennas, @@ -567,28 +575,28 @@ struct openair0_device_t { * \param antenna_id Index of antenna from which samples were received * \returns the number of sample read */ - int (*trx_read_func2)(openair0_device *device, openair0_timestamp *ptimestamp, uint32_t **buff, int nsamps); + int (*trx_read_func2)(openair0_device_t *device, openair0_timestamp_t *ptimestamp, uint32_t **buff, int nsamps); /*! \brief print the device statistics * \param device the hardware to use * \returns 0 on success */ - int (*trx_get_stats_func)(openair0_device *device); + int (*trx_get_stats_func)(openair0_device_t *device); /*! \brief Reset device statistics * \param device the hardware to use * \returns 0 in success */ - int (*trx_reset_stats_func)(openair0_device *device); + int (*trx_reset_stats_func)(openair0_device_t *device); /*! \brief Terminate operation of the transceiver -- free all associated resources * \param device the hardware to use */ - void (*trx_end_func)(openair0_device *device); + void (*trx_end_func)(openair0_device_t *device); /*! \brief Stop operation of the transceiver */ - int (*trx_stop_func)(openair0_device *device); + int (*trx_stop_func)(openair0_device_t *device); /* Functions API related to UE*/ @@ -597,14 +605,14 @@ struct openair0_device_t { * \param openair0_cfg RF frontend parameters set by application * \returns 0 in success */ - int (*trx_set_freq_func)(openair0_device *device, openair0_config_t *openair0_cfg); + int (*trx_set_freq_func)(openair0_device_t *device, openair0_config_t *openair0_cfg); /*! \brief Set gains * \param device the hardware to use * \param openair0_cfg RF frontend parameters set by application * \returns 0 in success */ - int (*trx_set_gains_func)(openair0_device *device, openair0_config_t *openair0_cfg); + int (*trx_set_gains_func)(openair0_device_t *device, openair0_config_t *openair0_cfg); /*! \brief Set tx/rx beams * @@ -619,9 +627,9 @@ struct openair0_device_t { * \param beam_map the beams to receive * \return 0 on success */ - int (*trx_set_beams)(openair0_device *device, uint64_t beam_map, openair0_timestamp timestamp); + int (*trx_set_beams)(openair0_device_t *device, uint64_t beam_map, openair0_timestamp_t timestamp); - /*! \brief Set tx/rx beams + /*! \brief Set tx/rx beams * * Set the tx/rx beams. This has to be done in advance of the reception in order to * allow the underlying device to change receiver configuration. The exact time depends @@ -635,7 +643,7 @@ struct openair0_device_t { * \param num_beams number of beams * \return 0 on success */ - int (*trx_set_beams2)(openair0_device *device, int* beams, int num_beams, openair0_timestamp timestamp); + int (*trx_set_beams2)(openair0_device_t *device, int *beams, int num_beams, openair0_timestamp_t timestamp); /*! \brief RRU Configuration callback * \param idx RU index @@ -651,22 +659,22 @@ struct openair0_device_t { /*! \brief Callback for Third-party RRU Initialization routine \param device the hardware configuration to use */ - int (*thirdparty_init)(openair0_device *device); + int (*thirdparty_init)(openair0_device_t *device); /*! \brief Callback for Third-party RRU Cleanup routine \param device the hardware configuration to use */ - int (*thirdparty_cleanup)(openair0_device *device); + int (*thirdparty_cleanup)(openair0_device_t *device); /*! \brief Callback for Third-party start streaming routine \param device the hardware configuration to use */ - int (*thirdparty_startstreaming)(openair0_device *device); + int (*thirdparty_startstreaming)(openair0_device_t *device); /*! \brief RRU Configuration callback * \param idx RU index * \param arg pointer to capabilities or configuration */ - int (*trx_write_init)(openair0_device *device); + int (*trx_write_init)(openair0_device_t *device); /* \brief Get internal parameter * \param id parameter to get * \return a pointer to the parameter @@ -679,9 +687,9 @@ struct openair0_device_t { }; /* type of device init function, implemented in shared lib */ -typedef int(*oai_device_initfunc_t)(openair0_device *device, openair0_config_t *openair0_cfg); +typedef int (*oai_device_initfunc_t)(openair0_device_t *device, openair0_config_t *openair0_cfg); /* type of transport init function, implemented in shared lib */ -typedef int(*oai_transport_initfunc_t)(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params); +typedef int (*oai_transport_initfunc_t)(openair0_device_t *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params); #define OPTION_LZ4 0x00000001 // LZ4 compression (option_value is set to compressed size) @@ -723,30 +731,29 @@ extern "C" /*! \brief get device name from device type */ const char *get_devname(int devtype); /*! \brief Initialize openair RF target. It returns 0 if OK */ -int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cfg); +int openair0_device_load(openair0_device_t *device, openair0_config_t *openair0_cfg); /*! \brief Initialize transport protocol . It returns 0 if OK */ -int openair0_transport_load(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params); - +int openair0_transport_load(openair0_device_t *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params); /*! \brief Get current timestamp of USRP * \param device the hardware to use */ -openair0_timestamp get_usrp_time(openair0_device *device); +openair0_timestamp_t get_usrp_time(openair0_device_t *device); /*! \brief Set RX frequencies * \param device the hardware to use * \param openair0_cfg RF frontend parameters set by application * \returns 0 in success */ -int openair0_set_rx_frequencies(openair0_device *device, openair0_config_t *openair0_cfg); +int openair0_set_rx_frequencies(openair0_device_t *device, openair0_config_t *openair0_cfg); /*! \brief read the iq record-player configuration */ extern int read_recplayconfig(recplay_conf_t **recplay_conf, recplay_state_t **recplay_state); /*! \brief store recorded iqs from memory to file. */ -extern void iqrecorder_end(openair0_device *device); +extern void iqrecorder_end(openair0_device_t *device); -int openair0_write_reorder(openair0_device *device, openair0_timestamp timestamp, void **txp, int nsamps, int nbAnt, int flags); -void openair0_write_reorder_clear_context(openair0_device *device); +int openair0_write_reorder(openair0_device_t *device, openair0_timestamp_t timestamp, void **txp, int nsamps, int nbAnt, int flags); +void openair0_write_reorder_clear_context(openair0_device_t *device); #include #ifndef gettid #define gettid() syscall(__NR_gettid) diff --git a/radio/COMMON/record_player.c b/radio/COMMON/record_player.c index 9e561f1d32..9286bb9ffd 100644 --- a/radio/COMMON/record_player.c +++ b/radio/COMMON/record_player.c @@ -78,7 +78,8 @@ int read_recplayconfig(recplay_conf_t **recplay_conf, recplay_state_t **recplay_ * used in record mode * \param device the hardware used */ -void iqrecorder_end(openair0_device *device) { +void iqrecorder_end(openair0_device_t *device) +{ if (device->recplay_state != NULL) { // subframes store iqfile_header_t fh = {device->type,device->openair0_cfg->tx_sample_advance, device->openair0_cfg->rx_bw,0,OAIIQFILE_ID}; recplay_state_t *rs = device->recplay_state; diff --git a/radio/ETHERNET/eth_raw.c b/radio/ETHERNET/eth_raw.c index 1b48a762f4..44f17ae5da 100644 --- a/radio/ETHERNET/eth_raw.c +++ b/radio/ETHERNET/eth_raw.c @@ -52,8 +52,8 @@ //int addr_len[MAX_INST]; //struct ifreq if_index[MAX_INST]; -int eth_socket_init_raw(openair0_device *device) { - +int eth_socket_init_raw(openair0_device_t *device) +{ eth_state_t *eth = (eth_state_t*)device->priv; const char *local_mac, *remote_mac; int sock_dom=0; @@ -125,8 +125,8 @@ int eth_socket_init_raw(openair0_device *device) { } /* 09/03/2019: fix obvious inconsistencies, but this code hasn't be tested for sure */ -int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags) { - +int trx_eth_write_raw(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int cc, int flags) +{ int bytes_sent=0; eth_state_t *eth = (eth_state_t*)device->priv; int sendto_flag =0; @@ -148,12 +148,12 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi /* we don't want to ovewrite with the header info the previous tx buffer data so we store it*/ struct ether_header temp = *(struct ether_header *)buff2; int32_t temp0 = *(int32_t *)(buff2 + MAC_HEADER_SIZE_BYTES); - openair0_timestamp temp1 = *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)); - + openair0_timestamp_t temp1 = *(openair0_timestamp_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)); + bytes_sent = 0; memcpy(buff2,(void*)ð->ehd,MAC_HEADER_SIZE_BYTES); *(int16_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int16_t))=1+(i<<1); - *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)) = timestamp; + *(openair0_timestamp_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)) = timestamp; /*printf("[RRU]write mod_%d %d , len %d, buff %p \n", Mod_id,eth->sockfd[Mod_id],RAW_PACKET_SIZE_BYTES(nsamps), buff2);*/ @@ -180,15 +180,13 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi /* tx buffer values restored */ *(struct ether_header *)buff2 = temp; *(int32_t *)(buff2 + MAC_HEADER_SIZE_BYTES) = temp0; - *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)) = temp1; + *(openair0_timestamp_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)) = temp1; } return (bytes_sent-APP_HEADER_SIZE_BYTES-MAC_HEADER_SIZE_BYTES)>>2; } - - -int trx_eth_write_raw_IF4p5(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { - +int trx_eth_write_raw_IF4p5(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int cc, int flags) +{ int nblocks = nsamps; int bytes_sent = 0; @@ -225,13 +223,11 @@ int trx_eth_write_raw_IF4p5(openair0_device *device, openair0_timestamp timestam eth->tx_count++; } - return (bytes_sent-MAC_HEADER_SIZE_BYTES); + return (bytes_sent-MAC_HEADER_SIZE_BYTES); } - - -int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { - +int trx_eth_read_raw(openair0_device_t *device, openair0_timestamp_t *timestamp, void **buff, int nsamps, int cc) +{ int ret; int bytes_received=0; int i=0; @@ -251,7 +247,7 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi /* we don't want to ovewrite with the header info the previous rx buffer data so we store it*/ struct ether_header temp = *(struct ether_header *)buff2; int32_t temp0 = *(int32_t *)(buff2 + MAC_HEADER_SIZE_BYTES); - openair0_timestamp temp1 = *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)); + openair0_timestamp_t temp1 = *(openair0_timestamp_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)); bytes_received=0; int receive_bytes; @@ -299,18 +295,18 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi } else { bytes_received+=ret; /* store the timestamp value from packet's header */ - *timestamp = *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)); + *timestamp = *(openair0_timestamp_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)); eth->rx_actual_nsamps=bytes_received>>2; eth->rx_count++; } } -#if DEBUG +#if DEBUG printf("------- RX------: nu=%x an_id=%d ts%d bytes_recv=%d \n", - *(uint8_t *)(buff2+ETH_ALEN), - *(int16_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int16_t)), - *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)), - bytes_received); + *(uint8_t *)(buff2 + ETH_ALEN), + *(int16_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int16_t)), + *(openair0_timestamp_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)), + bytes_received); dump_packet((device->host_type == RAU_HOST)? "RAU":"RRU", buff2, RAW_PACKET_SIZE_BYTES(nsamps),RX_FLAG); @@ -319,15 +315,13 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi /* tx buffer values restored */ *(struct ether_header *)buff2 = temp; *(int32_t *)(buff2 + MAC_HEADER_SIZE_BYTES) = temp0; - *(openair0_timestamp *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)) = temp1; + *(openair0_timestamp_t *)(buff2 + MAC_HEADER_SIZE_BYTES + sizeof(int32_t)) = temp1; } return (bytes_received-APP_HEADER_SIZE_BYTES-MAC_HEADER_SIZE_BYTES)>>2; } - - -int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { - +int trx_eth_read_raw_IF4p5(openair0_device_t *device, openair0_timestamp_t *timestamp, void **buff, int nsamps, int cc) +{ int ret; // Read nblocks info from packet itself int nblocks = nsamps; @@ -413,9 +407,8 @@ int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestam return(bytes_received); } - -int eth_set_dev_conf_raw(openair0_device *device) { - +int eth_set_dev_conf_raw(openair0_device_t *device) +{ eth_state_t *eth = (eth_state_t*)device->priv; void *msg; ssize_t msg_len; @@ -443,9 +436,8 @@ int eth_set_dev_conf_raw(openair0_device *device) { return 0; } - - -int eth_set_dev_conf_raw_IF4p5(openair0_device *device) { +int eth_set_dev_conf_raw_IF4p5(openair0_device_t *device) +{ // use for cc_id info eth_state_t *eth = (eth_state_t*)device->priv; @@ -475,9 +467,8 @@ int eth_set_dev_conf_raw_IF4p5(openair0_device *device) { return 0; } - -int eth_get_dev_conf_raw(openair0_device *device) { - +int eth_get_dev_conf_raw(openair0_device_t *device) +{ eth_state_t *eth = (eth_state_t*)device->priv; void *msg; ssize_t msg_len; @@ -503,8 +494,8 @@ int eth_get_dev_conf_raw(openair0_device *device) { return 0; } - -int eth_get_dev_conf_raw_IF4p5(openair0_device *device) { +int eth_get_dev_conf_raw_IF4p5(openair0_device_t *device) +{ // use for cc_id info eth_state_t *eth = (eth_state_t*)device->priv; diff --git a/radio/ETHERNET/eth_udp.c b/radio/ETHERNET/eth_udp.c index ea290f21cb..657e190ae1 100644 --- a/radio/ETHERNET/eth_udp.c +++ b/radio/ETHERNET/eth_udp.c @@ -58,8 +58,8 @@ uint16_t pck_seq_num = 1; uint16_t pck_seq_num_cur=0; uint16_t pck_seq_num_prev=0; -int eth_socket_init_udp(openair0_device *device) { - +int eth_socket_init_udp(openair0_device_t *device) +{ eth_state_t *eth = (eth_state_t*)device->priv; eth_params_t *eth_params = device->eth_params; @@ -192,8 +192,8 @@ int eth_socket_init_udp(openair0_device *device) { return 0; } -int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) { - +int trx_eth_read_udp_IF4p5(openair0_device_t *device, openair0_timestamp_t *timestamp, void **buff, int nsamps, int cc) +{ // Read nblocks info from packet itself int nblocks = nsamps; int bytes_received=-1; @@ -244,8 +244,8 @@ int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestam return(bytes_received); } -int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { - +int trx_eth_write_udp_IF4p5(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int cc, int flags) +{ int nblocks = nsamps; int bytes_sent = 0; @@ -294,10 +294,10 @@ int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestam -void *trx_eth_write_udp_cmd(udpTXelem_t *udpTXelem) { - - openair0_device *device=udpTXelem->device; - openair0_timestamp timestamp = udpTXelem->timestamp; +void *trx_eth_write_udp_cmd(udpTXelem_t *udpTXelem) +{ + openair0_device_t *device=udpTXelem->device; + openair0_timestamp_t timestamp = udpTXelem->timestamp; void **buff = udpTXelem->buff; int nsamps = udpTXelem->nsamps; int nant = udpTXelem->nant; @@ -331,7 +331,7 @@ void *trx_eth_write_udp_cmd(udpTXelem_t *udpTXelem) { // ECPRI Message type (1 byte) *(uint8_t *)(buff2 + 1) = 64; - openair0_timestamp TS = timestamp + fhstate->TS0; + openair0_timestamp_t TS = timestamp + fhstate->TS0; TS = (6*device->sampling_rate_ratio_d*TS)/device->sampling_rate_ratio_n; TS -= device->txrx_offset; int TSinc = (6*256*device->sampling_rate_ratio_d)/device->sampling_rate_ratio_n; @@ -386,8 +386,8 @@ void *trx_eth_write_udp_cmd(udpTXelem_t *udpTXelem) { return(NULL); } -int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, void **buff, int fd_ind, int nsamps, int flags, int nant) { - +int trx_eth_write_udp(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int fd_ind, int nsamps, int flags, int nant) +{ union udpTXReqUnion id = {.s={(uint64_t)timestamp,nsamps,0}}; notifiedFIFO_elt_t *req=newNotifiedFIFO_elt(sizeof(udpTXelem_t), id.p, device->utx[fd_ind]->resp,NULL); udpTXelem_t * udptxelem=(udpTXelem_t *) NotifiedFifoData(req); @@ -425,12 +425,13 @@ void *udp_write_thread(void *arg) { return(NULL); } -void *udp_read_thread(void *arg) { - openair0_timestamp TS; +void *udp_read_thread(void *arg) +{ + openair0_timestamp_t TS; int aid; udp_ctx_t *u = (udp_ctx_t *)arg; - openair0_device *device=u->device; + openair0_device_t *device=u->device; fhstate_t *fhstate = &device->fhstate; char buffer[UDP_PACKET_SIZE_BYTES(256)]; int first_read=0; @@ -457,7 +458,7 @@ void *udp_read_thread(void *arg) { if (oai_exit) break; aid = *(uint16_t*)(&buffer[ECPRICOMMON_BYTES]); - TS = *(openair0_timestamp *)(&buffer[ECPRICOMMON_BYTES+ECPRIPCID_BYTES]); + TS = *(openair0_timestamp_t *)(&buffer[ECPRICOMMON_BYTES+ECPRIPCID_BYTES]); // convert TS to samples, /6 for AW2S @ 30.72 Ms/s, this is converted for other sample rates in OAI application TS = (device->sampling_rate_ratio_n*TS)/(device->sampling_rate_ratio_d*6); AssertFatal(aid < 8,"Cannot handle more than 8 antennas, got aid %d\n",aid); @@ -487,24 +488,24 @@ void *udp_read_thread(void *arg) { return(0); } -int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, uint32_t **buff, int nsamps) { - +int trx_eth_read_udp(openair0_device_t *device, openair0_timestamp_t *timestamp, uint32_t **buff, int nsamps) +{ fhstate_t *fhstate = &device->fhstate; - openair0_timestamp prev_read_TS= fhstate->TS_read; - volatile openair0_timestamp min_TS; + openair0_timestamp_t prev_read_TS= fhstate->TS_read; + volatile openair0_timestamp_t min_TS; // block until FH is ready while (fhstate->r[0] == 0 || fhstate->r[1] == 0 || fhstate->r[2] == 0 || fhstate->r[3] == 0 || fhstate->r[4] == 0 || fhstate->r[5] == 0 || fhstate->r[6] == 0 || fhstate->r[7] == 0) usleep(100); // get minimum TS over all antennas - min_TS = (volatile openair0_timestamp)fhstate->TS[0]; + min_TS = (volatile openair0_timestamp_t)fhstate->TS[0]; for (int i=1;iopenair0_cfg->rx_num_channels;i++) min_TS = min(min_TS,fhstate->TS[i]); // poll/sleep until we accumulated enough samples on each antenna port int count=0; while (fhstate->first_read == 1 && min_TS < (fhstate->TS0+prev_read_TS + nsamps)) { usleep(10); - min_TS = (volatile openair0_timestamp)fhstate->TS[0]; - for (int i=1;iopenair0_cfg->rx_num_channels;i++) min_TS = min(min_TS,(volatile openair0_timestamp)fhstate->TS[i]); + min_TS = (volatile openair0_timestamp_t)fhstate->TS[0]; + for (int i=1;iopenair0_cfg->rx_num_channels;i++) min_TS = min(min_TS,(volatile openair0_timestamp_t)fhstate->TS[i]); count++; } if (fhstate->first_read == 0) { @@ -524,8 +525,8 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, uin -int trx_eth_ctlsend_udp(openair0_device *device, void *msg, ssize_t msg_len) { - +int trx_eth_ctlsend_udp(openair0_device_t *device, void *msg, ssize_t msg_len) +{ return(sendto(((eth_state_t*)device->priv)->sockfdc, msg, msg_len, @@ -535,8 +536,8 @@ int trx_eth_ctlsend_udp(openair0_device *device, void *msg, ssize_t msg_len) { } -int trx_eth_ctlrecv_udp(openair0_device *device, void *msg, ssize_t msg_len) { - +int trx_eth_ctlrecv_udp(openair0_device_t *device, void *msg, ssize_t msg_len) +{ return (recvfrom(((eth_state_t*)device->priv)->sockfdc, msg, msg_len, diff --git a/radio/ETHERNET/ethernet_lib.c b/radio/ETHERNET/ethernet_lib.c index 038246c998..d54d66ce72 100644 --- a/radio/ETHERNET/ethernet_lib.c +++ b/radio/ETHERNET/ethernet_lib.c @@ -51,12 +51,9 @@ int num_devices_eth = 0; struct sockaddr_in dest_addr[MAX_INST]; int dest_addr_len[MAX_INST]; -int load_lib(openair0_device *device, - openair0_config_t *openair0_cfg, - eth_params_t *cfg, - uint8_t flag); +int load_lib(openair0_device_t *device, openair0_config_t *openair0_cfg, eth_params_t *cfg, uint8_t flag); -int trx_eth_start(openair0_device *device) +int trx_eth_start(openair0_device_t *device) { eth_state_t *eth = (eth_state_t*)device->priv; @@ -225,8 +222,7 @@ int trx_eth_start(openair0_device *device) return 0; } - -void trx_eth_end(openair0_device *device) +void trx_eth_end(openair0_device_t *device) { eth_state_t *eth = (eth_state_t*)device->priv; /* destroys socket only for the processes that call the eth_end fuction-- shutdown() for beaking the pipe */ @@ -239,9 +235,8 @@ void trx_eth_end(openair0_device *device) } } - - -int trx_eth_stop(openair0_device *device) { +int trx_eth_stop(openair0_device_t *device) +{ eth_state_t *eth = (eth_state_t*)device->priv; if (eth->flags == ETH_UDP_IF5_ECPRI_MODE) { @@ -251,38 +246,32 @@ int trx_eth_stop(openair0_device *device) { return(0); } - -int trx_eth_set_freq(openair0_device* device, openair0_config_t *openair0_cfg) +int trx_eth_set_freq(openair0_device_t *device, openair0_config_t *openair0_cfg) { return(0); } - -int trx_eth_set_gains(openair0_device* device, openair0_config_t *openair0_cfg) +int trx_eth_set_gains(openair0_device_t *device, openair0_config_t *openair0_cfg) { return(0); } - -int trx_eth_get_stats(openair0_device* device) +int trx_eth_get_stats(openair0_device_t *device) { return(0); } - -int trx_eth_reset_stats(openair0_device* device) +int trx_eth_reset_stats(openair0_device_t *device) { return(0); } -int trx_eth_write_init(openair0_device *device) +int trx_eth_write_init(openair0_device_t *device) { return 0; } -int ethernet_tune(openair0_device *device, - unsigned int option, - int value) +int ethernet_tune(openair0_device_t *device, unsigned int option, int value) { eth_state_t *eth = (eth_state_t*)device->priv; struct timeval timeout; @@ -471,10 +460,7 @@ int ethernet_tune(openair0_device *device, return 0; } - -int transport_init(openair0_device *device, - openair0_config_t *openair0_cfg, - eth_params_t * eth_params ) +int transport_init(openair0_device_t *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params) { eth_state_t *eth = (eth_state_t*)malloc(sizeof(eth_state_t)); memset(eth, 0, sizeof(eth_state_t)); @@ -496,7 +482,7 @@ int transport_init(openair0_device *device, eth->num_fd = 1; - printf("[ETHERNET]: Initializing openair0_device for %s ...\n", ((device->host_type == RAU_HOST) ? "RAU": "RRU")); + printf("[ETHERNET]: Initializing openair0_device_t for %s ...\n", ((device->host_type == RAU_HOST) ? "RAU" : "RRU")); printf("[ETHERNET]: num_fd %d\n",eth->num_fd); device->Mod_id = 0;//num_devices_eth++; device->transp_type = ETHERNET_TP; @@ -577,8 +563,7 @@ unsigned short calc_csum (unsigned short *buf, return ~sum; } - -void dump_dev(openair0_device *device) +void dump_dev(openair0_device_t *device) { eth_state_t *eth = (eth_state_t*)device->priv; @@ -594,27 +579,21 @@ void dump_dev(openair0_device *device) } - -void inline dump_txcounters(openair0_device *device) +void inline dump_txcounters(openair0_device_t *device) { eth_state_t *eth = (eth_state_t*)device->priv; printf(" Ethernet device interface %i, tx counters:\n" ,device->openair0_cfg->Mod_id); printf(" Sent packets: %llu send errors: %i\n", (long long unsigned int)eth->tx_count, eth->num_tx_errors); } - -void inline dump_rxcounters(openair0_device *device) +void inline dump_rxcounters(openair0_device_t *device) { eth_state_t *eth = (eth_state_t*)device->priv; printf(" Ethernet device interface %i rx counters:\n" ,device->openair0_cfg->Mod_id); printf(" Received packets: %llu missed packets errors: %i\n", (long long unsigned int)eth->rx_count, eth->num_underflows); } - -void inline dump_buff(openair0_device *device, - char *buff, - unsigned int tx_rx_flag, - int nsamps) +void inline dump_buff(openair0_device_t *device, char *buff, unsigned int tx_rx_flag, int nsamps) { char *strptr; eth_state_t *eth = (eth_state_t*)device->priv; diff --git a/radio/ETHERNET/ethernet_lib.h b/radio/ETHERNET/ethernet_lib.h index 2a5f2db4ca..a5eacec29d 100644 --- a/radio/ETHERNET/ethernet_lib.h +++ b/radio/ETHERNET/ethernet_lib.h @@ -51,7 +51,7 @@ #include "if_defs.h" #define ECPRICOMMON_BYTES 4 #define ECPRIPCID_BYTES 2 -#define APP_HEADER_SIZE_BYTES (ECPRICOMMON_BYTES + ECPRIPCID_BYTES + sizeof(openair0_timestamp)) +#define APP_HEADER_SIZE_BYTES (ECPRICOMMON_BYTES + ECPRIPCID_BYTES + sizeof(openair0_timestamp_t)) #define ECPRIREV 1 // ECPRI Version 1, C=0 - single ECPRI message per OAI TX packet /*!\brief opaque ethernet data structure */ @@ -111,11 +111,11 @@ typedef struct { int num_rx_errors; /*!\brief number of errors in interface's transmitter */ int num_tx_errors; - - /*!\brief current TX timestamp */ - openair0_timestamp tx_current_ts; - /*!\brief socket file desc */ - openair0_timestamp rx_current_ts; + + /*!\brief current TX timestamp */ + openair0_timestamp_t tx_current_ts; + /*!\brief socket file desc */ + openair0_timestamp_t rx_current_ts; /*!\brief actual number of samples transmitted */ uint64_t tx_actual_nsamps; /*!\brief actual number of samples received */ @@ -150,8 +150,8 @@ typedef struct { uint16_t seq_num ; /*!\brief antenna port used to resynchronize */ uint16_t antenna_id; - /*!\brief packet's timestamp */ - openair0_timestamp timestamp; + /*!\brief packet's timestamp */ + openair0_timestamp_t timestamp; } header_t; /*!\brief different options for ethernet tuning in socket and driver level */ @@ -204,8 +204,8 @@ typedef struct { } iqoai_t ; typedef struct udpTXelem_s { - openair0_device *device; - openair0_timestamp timestamp; + openair0_device_t *device; + openair0_timestamp_t timestamp; void **buff; int fd_ind; int nant; @@ -227,17 +227,17 @@ union udpTXReqUnion { void dump_packet(char *title, unsigned char* pkt, int bytes, unsigned int tx_rx_flag); unsigned short calc_csum (unsigned short *buf, int nwords); -void dump_dev(openair0_device *device); -/*void inline dump_buff(openair0_device *device, char *buff,unsigned int tx_rx_flag,int nsamps); -void inline dump_rxcounters(openair0_device *device); -void inline dump_txcounters(openair0_device *device); +void dump_dev(openair0_device_t *device); +/*void inline dump_buff(openair0_device_t *device, char *buff,unsigned int tx_rx_flag,int nsamps); +void inline dump_rxcounters(openair0_device_t *device); +void inline dump_txcounters(openair0_device_t *device); */ void dump_iqs(char * buff, int iq_cnt); void *udp_read_thread(void *arg); void *udp_write_thread(void *arg); -/*! \fn int ethernet_tune (openair0_device *device, unsigned int option, int value); +/*! \fn int ethernet_tune (openair0_device_t *device, unsigned int option, int value); * \brief this function allows you to configure certain ethernet parameters in socket or device level * \param[in] device device which bears the socket * \param[in] option of parameter to configure @@ -246,34 +246,39 @@ void *udp_write_thread(void *arg); * \note * @ingroup _oai */ -int ethernet_tune(openair0_device *device, unsigned int option, int value); +int ethernet_tune(openair0_device_t *device, unsigned int option, int value); -/*! \fn int eth_socket_init_udp(openair0_device *device) +/*! \fn int eth_socket_init_udp(openair0_device_t *device) * \brief initialization of UDP Socket to communicate with one destination * \param[in] device openair device for which the socket will be created * \return 0 on success, otherwise -1 * \note * @ingroup _oai */ -int eth_socket_init_udp(openair0_device *device); -int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, void **buf, int fd_ind, int nsamps, int flags,int nant); -int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, uint32_t **buff, int nsamps); +int eth_socket_init_udp(openair0_device_t *device); +int trx_eth_write_udp(openair0_device_t *device, + openair0_timestamp_t timestamp, + void **buf, + int fd_ind, + int nsamps, + int flags, + int nant); +int trx_eth_read_udp(openair0_device_t *device, openair0_timestamp_t *timestamp, uint32_t **buff, int nsamps); +int eth_socket_init_raw(openair0_device_t *device); +int trx_eth_write_raw(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int cc, int flags); +int trx_eth_read_raw(openair0_device_t *device, openair0_timestamp_t *timestamp, void **buff, int nsamps, int cc); +int trx_eth_write_raw_IF4p5(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int cc, int flags); +int trx_eth_read_raw_IF4p5(openair0_device_t *device, openair0_timestamp_t *timestamp, void **buff, int nsamps, int cc); +int trx_eth_read_raw_IF5_mobipass(openair0_device_t *device, openair0_timestamp_t *timestamp, void **buff, int nsamps, int cc); +int trx_eth_write_udp_IF4p5(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int cc, int flags); +int trx_eth_read_udp_IF4p5(openair0_device_t *device, openair0_timestamp_t *timestamp, void **buff, int nsamps, int cc); +int trx_eth_ctlsend_udp(openair0_device_t *device, void *msg, ssize_t msg_len); +int trx_eth_ctlrecv_udp(openair0_device_t *device, void *msg, ssize_t msg_len); -int eth_socket_init_raw(openair0_device *device); -int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags); -int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc); -int trx_eth_write_raw_IF4p5(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags); -int trx_eth_read_raw_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc); -int trx_eth_read_raw_IF5_mobipass(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc); -int trx_eth_write_udp_IF4p5(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags); -int trx_eth_read_udp_IF4p5(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc); -int trx_eth_ctlsend_udp(openair0_device *device, void *msg, ssize_t msg_len); -int trx_eth_ctlrecv_udp(openair0_device *device, void *msg, ssize_t msg_len); - -int eth_get_dev_conf_raw(openair0_device *device); -int eth_set_dev_conf_raw(openair0_device *device); -int eth_get_dev_conf_raw_IF4p5(openair0_device *device); -int eth_set_dev_conf_raw_IF4p5(openair0_device *device); +int eth_get_dev_conf_raw(openair0_device_t *device); +int eth_set_dev_conf_raw(openair0_device_t *device); +int eth_get_dev_conf_raw_IF4p5(openair0_device_t *device); +int eth_set_dev_conf_raw_IF4p5(openair0_device_t *device); #endif diff --git a/radio/IRIS/iris_lib.cpp b/radio/IRIS/iris_lib.cpp index 927c63d72d..0251f8054c 100644 --- a/radio/IRIS/iris_lib.cpp +++ b/radio/IRIS/iris_lib.cpp @@ -71,14 +71,15 @@ extern "C" { //! rx count int64_t rx_count; //! timestamp of RX packet - openair0_timestamp rx_timestamp; + openair0_timestamp_t rx_timestamp; } iris_state_t; } /*! \brief Called to start the Iris lime transceiver. Return 0 if OK, < 0 if error @param device pointer to the device structure specific to the RF hardware target */ -static int trx_iris_start(openair0_device *device) { +static int trx_iris_start(openair0_device_t *device) +{ iris_state_t *s = (iris_state_t *) device->priv; long long timeNs = s->iris[0]->getHardwareTime("") + 500000; @@ -97,7 +98,8 @@ static int trx_iris_start(openair0_device *device) { /*! \brief Stop Iris * \param card refers to the hardware index to use */ -int trx_iris_stop(openair0_device *device) { +int trx_iris_stop(openair0_device_t *device) +{ iris_state_t *s = (iris_state_t *) device->priv; int r; for (r = 0; r < s->device_num; r++) { @@ -110,7 +112,8 @@ int trx_iris_stop(openair0_device *device) { /*! \brief Terminate operation of the Iris lime transceiver -- free all associated resources * \param device the hardware to use */ -static void trx_iris_end(openair0_device *device) { +static void trx_iris_end(openair0_device_t *device) +{ LOG_I(HW, "Closing Iris device.\n"); trx_iris_stop(device); iris_state_t *s = (iris_state_t *) device->priv; @@ -133,7 +136,7 @@ static void trx_iris_end(openair0_device *device) { static int -trx_iris_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) +trx_iris_write(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int cc, int flags) { using namespace std::chrono; @@ -209,7 +212,8 @@ trx_iris_write(openair0_device *device, openair0_timestamp timestamp, void **buf * \param antenna_id Index of antenna for which to receive samples * \returns the number of sample read */ -static int trx_iris_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { +static int trx_iris_read(openair0_device_t *device, openair0_timestamp_t *ptimestamp, void **buff, int nsamps, int cc) +{ int ret = 0; static long long nextTime; static bool nextTimeValid = false; @@ -304,7 +308,8 @@ static int trx_iris_read(openair0_device *device, openair0_timestamp *ptimestamp /*! \brief Get current timestamp of Iris * \param device the hardware to use */ -openair0_timestamp get_iris_time(openair0_device *device) { +openair0_timestamp_t get_iris_time(openair0_device_t *device) +{ iris_state_t *s = (iris_state_t *) device->priv; return SoapySDR::timeNsToTicks(s->iris[0]->getHardwareTime(""), s->sample_rate); } @@ -317,9 +322,9 @@ static bool is_equal(double a, double b) { return std::fabs(a - b) < std::numeric_limits::epsilon(); } -void *set_freq_thread(void *arg) { - - openair0_device *device = (openair0_device *) arg; +void *set_freq_thread(void *arg) +{ + openair0_device_t *device = (openair0_device_t *) arg; iris_state_t *s = (iris_state_t *) device->priv; int r, i; printf("Setting Iris TX Freq %f, RX Freq %f\n", device->openair0_cfg[0].tx_freq[0], @@ -344,7 +349,7 @@ void *set_freq_thread(void *arg) { * \param dummy dummy variable not used * \returns 0 in success */ -int trx_iris_set_freq(openair0_device *device, openair0_config_t *openair0_cfg) +int trx_iris_set_freq(openair0_device_t *device, openair0_config_t *openair0_cfg) { iris_state_t *s = (iris_state_t *)device->priv; int r, i; @@ -369,7 +374,7 @@ int trx_iris_set_freq(openair0_device *device, openair0_config_t *openair0_cfg) * \param openair0_cfg RF frontend parameters set by application * \returns 0 in success */ -int trx_iris_set_gains(openair0_device *device, +int trx_iris_set_gains(openair0_device_t *device, openair0_config_t *openair0_cfg) { iris_state_t *s = (iris_state_t *) device->priv; int r; @@ -448,23 +453,21 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index, int bw * \param device the hardware to use * \returns 0 on success */ -int trx_iris_get_stats(openair0_device *device) { - +int trx_iris_get_stats(openair0_device_t *device) +{ return (0); - } /*! \brief Reset the Iris statistics * \param device the hardware to use * \returns 0 on success */ -int trx_iris_reset_stats(openair0_device *device) { - +int trx_iris_reset_stats(openair0_device_t *device) +{ return (0); - } -int trx_iris_write_init(openair0_device *device) +int trx_iris_write_init(openair0_device_t *device) { return 0; } @@ -475,8 +478,8 @@ extern "C" { * \param device the hardware to use * \param openair0_cfg RF frontend parameters set by application */ -int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { - +int device_init(openair0_device_t *device, openair0_config_t *openair0_cfg) +{ int bw_gain_adjust = 0; openair0_cfg[0].rx_gain_calib_table = calib_table_iris; iris_state_t *s = (iris_state_t *) calloc(1, sizeof(*s)); diff --git a/radio/LMSSDR/lms_lib.cpp b/radio/LMSSDR/lms_lib.cpp index 3d0dd78118..bca1f8efaf 100644 --- a/radio/LMSSDR/lms_lib.cpp +++ b/radio/LMSSDR/lms_lib.cpp @@ -72,7 +72,8 @@ int write_output(const char *fname,const char *vname,void *data,int length,int d \param flags Ignored for the moment \returns 0 on success */ -int trx_lms_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int antenna_id, int flags) { +int trx_lms_write(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int antenna_id, int flags) +{ timestamp -= device->openair0_cfg->command_line_sample_advance - device->openair0_cfg->tx_sample_advance; lms_stream_meta_t meta; meta.waitForTimestamp = true; @@ -93,8 +94,8 @@ int trx_lms_write(openair0_device *device, openair0_timestamp timestamp, void ** * \param antenna_id Index of antenna port * \returns number of samples read */ -int trx_lms_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int antenna_id) { - +int trx_lms_read(openair0_device_t *device, openair0_timestamp_t *ptimestamp, void **buff, int nsamps, int antenna_id) +{ lms_stream_meta_t meta; meta.waitForTimestamp = false; meta.flushPartialPacket = false; @@ -140,7 +141,8 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index) { * \param openair0_cfg openair0 Config structure * \returns 0 in success, -1 on error */ -int trx_lms_set_gains(openair0_device* device, openair0_config_t *openair0_cfg) { +int trx_lms_set_gains(openair0_device_t* device, openair0_config_t *openair0_cfg) +{ int ret = 0; if (openair0_cfg->rx_gain[0] > 70+openair0_cfg->rx_gain_offset[0]) { @@ -158,8 +160,8 @@ int trx_lms_set_gains(openair0_device* device, openair0_config_t *openair0_cfg) * \param device the hardware to use * \returns 0 on success */ -int trx_lms_start(openair0_device *device){ - +int trx_lms_start(openair0_device_t *device) +{ lms_info_str_t list[16]={0}; int n= LMS_GetDeviceList(list); @@ -269,7 +271,8 @@ int trx_lms_start(openair0_device *device){ * \param card Index of the RF card to use * \returns 0 on success */ -int trx_lms_stop(openair0_device *device) { +int trx_lms_stop(openair0_device_t *device) +{ LMS_StopStream(&rx_stream); LMS_StopStream(&tx_stream); LMS_DestroyStream(lms_device,&rx_stream); @@ -283,7 +286,8 @@ int trx_lms_stop(openair0_device *device) { * \param openair0_cfg openair0 Config structure (ignored. It is there to comply with RF common API) * \returns 0 in success */ -int trx_lms_set_freq(openair0_device* device, openair0_config_t *openair0_cfg) { +int trx_lms_set_freq(openair0_device_t* device, openair0_config_t *openair0_cfg) +{ //Control port must be connected LMS_SetLOFrequency(lms_device,LMS_CH_TX,0,openair0_cfg->tx_freq[0]); LMS_SetLOFrequency(lms_device,LMS_CH_RX,0,openair0_cfg->rx_freq[0]); @@ -322,45 +326,43 @@ rx_gain_calib_table_t calib_table_lmssdr[] = { * \returns 0 in success */ -int trx_lms_get_stats(openair0_device* device) { - +int trx_lms_get_stats(openair0_device_t* device) +{ return(0); - } /*! \brief Reset LMSSDR Statistics * \param device the hardware to use * \returns 0 in success */ -int trx_lms_reset_stats(openair0_device* device) { - +int trx_lms_reset_stats(openair0_device_t* device) +{ return(0); - } /*! \brief Terminate operation of the LMSSDR transceiver -- free all associated resources * \param device the hardware to use */ -void trx_lms_end(openair0_device *device) { - - +void trx_lms_end(openair0_device_t *device) +{ } -int trx_lms_write_init(openair0_device *device) +int trx_lms_write_init(openair0_device_t *device) { return 0; } + extern "C" { /*! \brief Initialize Openair LMSSDR target. It returns 0 if OK * \param device the hardware to use * \param openair0_cfg RF frontend parameters set by application */ -int device_init(openair0_device *device, openair0_config_t *openair0_cfg){ - +int device_init(openair0_device_t *device, openair0_config_t *openair0_cfg) +{ device->type=LMSSDR_DEV; - printf("LMSSDR: Initializing openair0_device for %s ...\n", ((device->host_type == RAU_HOST) ? "RAU": "RRU")); + printf("LMSSDR: Initializing openair0_device_t for %s ...\n", ((device->host_type == RAU_HOST) ? "RAU": "RRU")); switch ((int)openair0_cfg[0].sample_rate) { case 30720000: diff --git a/radio/LMSSDR/sodera_lib.cpp b/radio/LMSSDR/sodera_lib.cpp index 7c3690a9d6..39b2811005 100644 --- a/radio/LMSSDR/sodera_lib.cpp +++ b/radio/LMSSDR/sodera_lib.cpp @@ -87,7 +87,7 @@ typedef struct int64_t tx_count; int64_t rx_count; - openair0_timestamp rx_timestamp; + openair0_timestamp_t rx_timestamp; } sodera_t; @@ -131,7 +131,7 @@ uint16_t SPI_read(LMScomms* dataPort, uint16_t address) return 0; } -static int trx_sodera_start(openair0_device *device) +static int trx_sodera_start(openair0_device_t *device) { sodera_t *s = (sodera_t*)device->priv; @@ -182,7 +182,7 @@ static int trx_sodera_start(openair0_device *device) return 0; } -static void trx_sodera_end(openair0_device *device) +static void trx_sodera_end(openair0_device_t *device) { sodera_t *s = (sodera_t*)device->priv; @@ -193,7 +193,7 @@ static void trx_sodera_end(openair0_device *device) } -static int trx_sodera_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) +static int trx_sodera_write(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int cc, int flags) { sodera_t *s = (sodera_t*)device->priv; @@ -203,7 +203,7 @@ static int trx_sodera_write(openair0_device *device, openair0_timestamp timestam #define DEBUG_READ 1 -static int trx_sodera_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) +static int trx_sodera_read(openair0_device_t *device, openair0_timestamp_t *ptimestamp, void **buff, int nsamps, int cc) { sodera_t *s = (sodera_t*)device->priv; int samples_received=0,i,j; @@ -350,19 +350,18 @@ static bool is_equal(double a, double b) return fabs(a-b) < 1e-6; } -int trx_sodera_set_freq(openair0_device* device, openair0_config_t *openair0_cfg, int dummy) { - +int trx_sodera_set_freq(openair0_device_t *device, openair0_config_t *openair0_cfg, int dummy) +{ sodera_t *s = (sodera_t*)device->priv; // s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[0]); // s->usrp->set_rx_freq(openair0_cfg[0].rx_freq[0]); - return(0); - + return (0); } -int openair0_set_rx_frequencies(openair0_device* device, openair0_config_t *openair0_cfg) { - +int openair0_set_rx_frequencies(openair0_device_t *device, openair0_config_t *openair0_cfg) +{ sodera_t *s = (sodera_t*)device->priv; static int first_call=1; static double rf_freq,diff; @@ -374,13 +373,11 @@ int openair0_set_rx_frequencies(openair0_device* device, openair0_config_t *open // rf_freq=openair0_cfg[0].rx_freq[0]; // s->usrp->set_rx_freq(rx_tune_req); - return(0); - + return (0); } -int trx_sodera_set_gains(openair0_device* device, - openair0_config_t *openair0_cfg) { - +int trx_sodera_set_gains(openair0_device_t *device, openair0_config_t *openair0_cfg) +{ sodera_t *s = (sodera_t*)device->priv; // s->usrp->set_tx_gain(openair0_cfg[0].tx_gain[0]); @@ -456,20 +453,17 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index,int bw_ } - -int trx_sodera_get_stats(openair0_device* device) { - - return(0); - -} -int trx_sodera_reset_stats(openair0_device* device) { - - return(0); - +int trx_sodera_get_stats(openair0_device_t *device) +{ + return (0); } +int trx_sodera_reset_stats(openair0_device_t *device) +{ + return (0); +} -int openair0_dev_init_sodera(openair0_device* device, openair0_config_t *openair0_cfg) +int openair0_dev_init_sodera(openair0_device_t *device, openair0_config_t *openair0_cfg) { sodera_t *s=&sodera_state; diff --git a/radio/USRP/usrp_lib.cpp b/radio/USRP/usrp_lib.cpp index dabc6f8947..f224b75354 100644 --- a/radio/USRP/usrp_lib.cpp +++ b/radio/USRP/usrp_lib.cpp @@ -104,7 +104,7 @@ typedef struct { //int first_tx; //int first_rx; //! timestamp of RX packet - openair0_timestamp rx_timestamp; + openair0_timestamp_t rx_timestamp; } usrp_state_t; //void print_notes(void) @@ -145,7 +145,8 @@ int check_ref_locked(usrp_state_t *s,size_t mboard) { return ref_locked; } -static int sync_to_gps(openair0_device *device) { +static int sync_to_gps(openair0_device_t *device) +{ //uhd::set_thread_priority_safe(); //std::string args; //Set up program options @@ -266,7 +267,7 @@ static int sync_to_gps(openair0_device *device) { #define ATR_XX 0x20 //data[5] #define MAN_MASK ATR_MASK ^ 0xFFF // manually controlled pins -static void trx_usrp_start_interdigital_gpio(openair0_device *device, usrp_state_t *s) +static void trx_usrp_start_interdigital_gpio(openair0_device_t *device, usrp_state_t *s) { AssertFatal(device->type == USRP_X400_DEV, "interdigital frontend device for beam management can only be used together with an X400\n"); @@ -280,7 +281,7 @@ static void trx_usrp_start_interdigital_gpio(openair0_device *device, usrp_state s->usrp->set_gpio_attr(s->gpio_bank, "OUT", (1 << 4), 0x1c); } -static void trx_usrp_start_generic_gpio(openair0_device *device, usrp_state_t *s) +static void trx_usrp_start_generic_gpio(openair0_device_t *device, usrp_state_t *s) { // setup GPIO for TDD, GPIO(4) = ATR_RX // set data direction register (DDR) to output @@ -299,7 +300,8 @@ static void trx_usrp_start_generic_gpio(openair0_device *device, usrp_state_t *s /*! \brief Called to start the USRP transceiver. Return 0 if OK, < 0 if error @param device pointer to the device structure specific to the RF hardware target */ -static int trx_usrp_start(openair0_device *device) { +static int trx_usrp_start(openair0_device_t *device) +{ usrp_state_t *s = (usrp_state_t *)device->priv; s->gpio_bank = (char *) "FP0"; //good for B210, X310 and N310 @@ -383,7 +385,8 @@ static void trx_usrp_write_reset(openair0_thread_t *wt); /*! \brief Terminate operation of the USRP transceiver -- free all associated resources * \param device the hardware to use */ -static void trx_usrp_end(openair0_device *device) { +static void trx_usrp_end(openair0_device_t *device) +{ if (device == NULL) return; @@ -423,12 +426,13 @@ static void trx_usrp_end(openair0_device *device) { @param antenna_id index of the antenna if the device has multiple antennas @param flags flags must be set to true if timestamp parameter needs to be applied */ -static int trx_usrp_write(openair0_device *device, - openair0_timestamp timestamp, +static int trx_usrp_write(openair0_device_t *device, + openair0_timestamp_t timestamp, void **buff, int nsamps, int cc, - int flags) { + int flags) +{ int ret=0; usrp_state_t *s = (usrp_state_t *)device->priv; timestamp -= device->openair0_cfg->command_line_sample_advance + device->openair0_cfg->tx_sample_advance; @@ -562,22 +566,23 @@ static int trx_usrp_write(openair0_device *device, @param antenna_id index of the antenna if the device has multiple antennas @param flags flags must be set to true if timestamp parameter needs to be applied */ -void *trx_usrp_write_thread(void * arg){ +void *trx_usrp_write_thread(void * arg) +{ int ret=0; - openair0_device *device=(openair0_device *)arg; + openair0_device_t *device=(openair0_device_t *)arg; openair0_thread_t *write_thread = &device->write_thread; openair0_write_package_t *write_package = write_thread->write_package; usrp_state_t *s; int nsamps2; // aligned to upper 32 or 16 byte boundary int start; - openair0_timestamp timestamp; - void **buff; - int nsamps; - int cc; - signed char first_packet; - signed char last_packet; - int flags_gpio; + openair0_timestamp_t timestamp; + void **buff; + int nsamps; + int cc; + signed char first_packet; + signed char last_packet; + int flags_gpio; printf("trx_usrp_write_thread started on cpu %d\n",sched_getcpu()); while(1){ @@ -659,8 +664,8 @@ void *trx_usrp_write_thread(void * arg){ return NULL; } -int trx_usrp_write_init(openair0_device *device){ - +int trx_usrp_write_init(openair0_device_t *device) +{ //uhd::set_thread_priority_safe(1.0); openair0_thread_t *write_thread = &device->write_thread; printf("initializing tx write thread\n"); @@ -705,7 +710,8 @@ static void trx_usrp_write_reset(openair0_thread_t *wt) { * \param antenna_id Index of antenna for which to receive samples * \returns the number of sample read */ -static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { +static int trx_usrp_read(openair0_device_t *device, openair0_timestamp_t *ptimestamp, void **buff, int nsamps, int cc) +{ usrp_state_t *s = (usrp_state_t *)device->priv; int samples_received=0; int nsamps2; // aligned to upper 32 or 16 byte boundary @@ -817,7 +823,7 @@ static bool is_equal(double a, double b) { } void *freq_thread(void *arg) { - openair0_device *device=(openair0_device *)arg; + openair0_device_t *device=(openair0_device_t *)arg; usrp_state_t *s = (usrp_state_t *)device->priv; uhd::tune_request_t tx_tune_req(device->openair0_cfg[0].tx_freq[0], device->openair0_cfg[0].tune_offset); @@ -833,7 +839,7 @@ void *freq_thread(void *arg) { * \param dummy dummy variable not used * \returns 0 in success */ -int trx_usrp_set_freq(openair0_device *device, openair0_config_t *openair0_cfg) +int trx_usrp_set_freq(openair0_device_t *device, openair0_config_t *openair0_cfg) { usrp_state_t *s = (usrp_state_t *)device->priv; printf("Setting USRP TX Freq %f, RX Freq %f, tune_offset: %f\n", openair0_cfg[0].tx_freq[0], openair0_cfg[0].rx_freq[0], openair0_cfg[0].tune_offset); @@ -851,7 +857,8 @@ int trx_usrp_set_freq(openair0_device *device, openair0_config_t *openair0_cfg) * \param openair0_cfg RF frontend parameters set by application * \returns 0 in success */ -int openair0_set_rx_frequencies(openair0_device *device, openair0_config_t *openair0_cfg) { +int openair0_set_rx_frequencies(openair0_device_t *device, openair0_config_t *openair0_cfg) +{ usrp_state_t *s = (usrp_state_t *)device->priv; uhd::tune_request_t rx_tune_req(openair0_cfg[0].rx_freq[0], openair0_cfg[0].tune_offset); printf("In openair0_set_rx_frequencies, freq: %f, tune offset: %f\n", @@ -867,8 +874,9 @@ int openair0_set_rx_frequencies(openair0_device *device, openair0_config_t *open * \param openair0_cfg RF frontend parameters set by application * \returns 0 in success */ -int trx_usrp_set_gains(openair0_device *device, - openair0_config_t *openair0_cfg) { +int trx_usrp_set_gains(openair0_device_t *device, + openair0_config_t *openair0_cfg) +{ usrp_state_t *s = (usrp_state_t *)device->priv; ::uhd::gain_range_t gain_range_tx = s->usrp->get_tx_gain_range(0); s->usrp->set_tx_gain(gain_range_tx.stop()-openair0_cfg[0].tx_gain[0]); @@ -892,7 +900,8 @@ int trx_usrp_set_gains(openair0_device *device, /*! \brief Stop USRP * \param card refers to the hardware index to use */ -int trx_usrp_stop(openair0_device *device) { +int trx_usrp_stop(openair0_device_t *device) +{ return(0); } @@ -1012,7 +1021,8 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index,int bw_ * \param device the hardware to use * \returns 0 on success */ -int trx_usrp_get_stats(openair0_device *device) { +int trx_usrp_get_stats(openair0_device_t *device) +{ return(0); } @@ -1020,7 +1030,8 @@ int trx_usrp_get_stats(openair0_device *device) { * \param device the hardware to use * \returns 0 on success */ -int trx_usrp_reset_stats(openair0_device *device) { +int trx_usrp_reset_stats(openair0_device_t *device) +{ return(0); } @@ -1047,7 +1058,8 @@ static void usrp_sync_pps(usrp_state_t *s) } extern "C" { - int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { + int device_init(openair0_device_t *device, openair0_config_t *openair0_cfg) + { LOG_I(HW, "openair0_cfg[0].sdr_addrs == '%s'\n", openair0_cfg[0].sdr_addrs); LOG_I(HW, "openair0_cfg[0].clock_source == '%d' (internal = %d, external = %d)\n", openair0_cfg[0].clock_source,internal,external); usrp_state_t *s ; diff --git a/radio/emulator/rf_emulator.c b/radio/emulator/rf_emulator.c index e73e9bf3d6..7fb2e2979a 100644 --- a/radio/emulator/rf_emulator.c +++ b/radio/emulator/rf_emulator.c @@ -115,7 +115,7 @@ static void *emulator_timing_job(void *arg) /*! \brief Called to start the RF transceiver. Return 0 if OK, < 0 if error * \param device pointer to the device structure specific to the RF hardware target */ -static int emulator_start(openair0_device *device) +static int emulator_start(openair0_device_t *device) { // Start the timing thread and the noise device emulator_state_t *emulator_state = (emulator_state_t *)device->priv; @@ -163,7 +163,7 @@ static int emulator_start(openair0_device *device) * \param device pointer to the device structure specific to the RF hardware target * \returns 0 on success */ -int emulator_get_stats(openair0_device *device) +int emulator_get_stats(openair0_device_t *device) { return (0); } @@ -172,7 +172,7 @@ int emulator_get_stats(openair0_device *device) * \param device pointer to the device structure specific to the RF hardware target * \returns 0 on success */ -int emulator_reset_stats(openair0_device *device) +int emulator_reset_stats(openair0_device_t *device) { return (0); } @@ -180,7 +180,7 @@ int emulator_reset_stats(openair0_device *device) /*! \brief Terminate operation of the RF transceiver -- free all associated resources (if any) * \param pointer to the device structure specific to the RF hardware target */ -static void emulator_end(openair0_device *device) +static void emulator_end(openair0_device_t *device) { // Stop the timing thread and the noise device emulator_state_t *emulator_state = (emulator_state_t *)device->priv; @@ -197,7 +197,7 @@ static void emulator_end(openair0_device *device) /*! \brief Stop RF * \param device pointer to the device structure specific to the RF hardware target */ -int emulator_stop(openair0_device *device) +int emulator_stop(openair0_device_t *device) { return (0); } @@ -207,7 +207,7 @@ int emulator_stop(openair0_device *device) * \param openair0_cfg RF frontend parameters set by application * \returns 0 in success */ -int emulator_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) +int emulator_set_gains(openair0_device_t *device, openair0_config_t *openair0_cfg) { return (0); } @@ -217,12 +217,12 @@ int emulator_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) * \param openair0_cfg RF frontend parameters set by application * \returns 0 in success */ -int emulator_set_freq(openair0_device *device, openair0_config_t *openair0_cfg) +int emulator_set_freq(openair0_device_t *device, openair0_config_t *openair0_cfg) { return (0); } -int emulator_write_init(openair0_device *device) +int emulator_write_init(openair0_device_t *device) { return (0); } @@ -235,7 +235,7 @@ int emulator_write_init(openair0_device *device) * \param nbAnt number of antennas * \param flags flags must be set to true if timestamp parameter needs to be applied */ -static int emulator_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int nbAnt, int flags) +static int emulator_write(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int nbAnt, int flags) { emulator_state_t *emulator_state = (emulator_state_t *)device->priv; @@ -297,7 +297,7 @@ static void read_noise(void *buff, int nsamps) * \param nbAnt number of antennas * \returns the number of samples read */ -static int emulator_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int nbAnt) +static int emulator_read(openair0_device_t *device, openair0_timestamp_t *ptimestamp, void **buff, int nsamps, int nbAnt) { emulator_state_t *emulator_state = (emulator_state_t *)device->priv; @@ -339,7 +339,7 @@ static void emulator_readconfig(emulator_state_t *emulator_state) AssertFatal(ret >= 0, "configuration couldn't be performed\n"); } -int device_init(openair0_device *device, openair0_config_t *openair0_cfg) +int device_init(openair0_device_t *device, openair0_config_t *openair0_cfg) { LOG_I(HW, "This is emulator RF that does nothing\n"); diff --git a/radio/fhi_72/oran.h b/radio/fhi_72/oran.h index c79bc88fa3..059d33d79e 100644 --- a/radio/fhi_72/oran.h +++ b/radio/fhi_72/oran.h @@ -28,7 +28,7 @@ void oran_fh_if4p5_south_out(RU_t *ru, int frame, int slot, uint64_t timestamp); void oran_fh_if4p5_south_in(RU_t *ru, int *frame, int *slot); -int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params); +int transport_init(openair0_device_t *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params); typedef struct { eth_state_t e; diff --git a/radio/fhi_72/oran_isolate.c b/radio/fhi_72/oran_isolate.c index 9b97b58390..603c12f1da 100644 --- a/radio/fhi_72/oran_isolate.c +++ b/radio/fhi_72/oran_isolate.c @@ -55,7 +55,7 @@ typedef struct { notifiedFIFO_t oran_sync_fifo; -int trx_oran_start(openair0_device *device) +int trx_oran_start(openair0_device_t *device) { printf("ORAN: %s\n", __FUNCTION__); @@ -71,14 +71,14 @@ int trx_oran_start(openair0_device *device) return 0; } -void trx_oran_end(openair0_device *device) +void trx_oran_end(openair0_device_t *device) { printf("ORAN: %s\n", __FUNCTION__); oran_eth_state_t *s = device->priv; xran_close(s->oran_priv); } -int trx_oran_stop(openair0_device *device) +int trx_oran_stop(openair0_device_t *device) { printf("ORAN: %s\n", __FUNCTION__); oran_eth_state_t *s = device->priv; @@ -91,19 +91,19 @@ int trx_oran_stop(openair0_device *device) return (0); } -int trx_oran_set_freq(openair0_device *device, openair0_config_t *openair0_cfg) +int trx_oran_set_freq(openair0_device_t *device, openair0_config_t *openair0_cfg) { printf("ORAN: %s\n", __FUNCTION__); return (0); } -int trx_oran_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) +int trx_oran_set_gains(openair0_device_t *device, openair0_config_t *openair0_cfg) { printf("ORAN: %s\n", __FUNCTION__); return (0); } -int trx_oran_get_stats(openair0_device *device) +int trx_oran_get_stats(openair0_device_t *device) { uint64_t total_time, used_time; uint32_t num_core_used, core_used[64]; @@ -114,25 +114,25 @@ int trx_oran_get_stats(openair0_device *device) return (0); } -int trx_oran_reset_stats(openair0_device *device) +int trx_oran_reset_stats(openair0_device_t *device) { printf("ORAN: %s\n", __FUNCTION__); return (0); } -int ethernet_tune(openair0_device *device, unsigned int option, int value) +int ethernet_tune(openair0_device_t *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) +int trx_oran_write_raw(openair0_device_t *device, openair0_timestamp_t 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) +int trx_oran_read_raw(openair0_device_t *device, openair0_timestamp_t *timestamp, void **buff, int nsamps, int cc) { printf("ORAN: %s\n", __FUNCTION__); return 0; @@ -160,7 +160,7 @@ char *msg_type(int t) return s[t]; } -int trx_oran_ctlsend(openair0_device *device, void *msg, ssize_t msg_len) +int trx_oran_ctlsend(openair0_device_t *device, void *msg, ssize_t msg_len) { RRU_CONFIG_msg_t *rru_config_msg = msg; oran_eth_state_t *s = device->priv; @@ -174,7 +174,7 @@ int trx_oran_ctlsend(openair0_device *device, void *msg, ssize_t msg_len) return msg_len; } -int trx_oran_ctlrecv(openair0_device *device, void *msg, ssize_t msg_len) +int trx_oran_ctlrecv(openair0_device_t *device, void *msg, ssize_t msg_len) { RRU_CONFIG_msg_t *rru_config_msg = msg; oran_eth_state_t *s = device->priv; @@ -312,7 +312,7 @@ void *get_internal_parameter(char *name) return NULL; } -__attribute__((__visibility__("default"))) int transport_init(openair0_device *device, +__attribute__((__visibility__("default"))) int transport_init(openair0_device_t *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params) { diff --git a/radio/iqplayer/iqplayer_lib.c b/radio/iqplayer/iqplayer_lib.c index 2df57c9202..d247ce0eb0 100644 --- a/radio/iqplayer/iqplayer_lib.c +++ b/radio/iqplayer/iqplayer_lib.c @@ -57,7 +57,8 @@ static void busy_wait(uint32_t usecs) { //LOG_I(HW, "Expected: %d Elapsed: %d us\n", usecs, elapsed_usecs); } -static void parse_iqfile_header(openair0_device *device, iqfile_header_t *iq_fh) { +static void parse_iqfile_header(openair0_device_t *device, iqfile_header_t *iq_fh) +{ char tmp[4]=OAIIQFILE_ID; AssertFatal((memcmp(iq_fh->oaiid,tmp,sizeof(iq_fh->oaiid)) == 0), "iqfile doesn't seem to be compatible with oai (invalid id %.4s in header)\n", @@ -69,11 +70,11 @@ static void parse_iqfile_header(openair0_device *device, iqfile_header_t *iq_fh) LOG_UI(HW,"Replay iqs from %s device, bandwidth %e\n",get_devname(iq_fh->devtype),iq_fh->bw); } - /*! \brief Called to start the iqplayer device. Return 0 if OK, < 0 if error @param device pointer to the device structure specific to the RF hardware target */ -static int iqplayer_loadfile(openair0_device *device, openair0_config_t *openair0_cfg) { +static int iqplayer_loadfile(openair0_device_t *device, openair0_config_t *openair0_cfg) +{ recplay_state_t *s = device->recplay_state; recplay_conf_t *c = openair0_cfg->recplay_conf; @@ -142,7 +143,7 @@ static int iqplayer_loadfile(openair0_device *device, openair0_config_t *openair * \param device the hardware to use * \returns 0 on success */ -static int trx_iqplayer_get_stats(openair0_device *device) +static int trx_iqplayer_get_stats(openair0_device_t *device) { LOG_I(HW, "trx_iqplayer_get_stats() called, not implemented\n"); return 0; @@ -152,7 +153,7 @@ static int trx_iqplayer_get_stats(openair0_device *device) * \param device the hardware to use * \returns 0 in success */ -static int trx_iqplayer_reset_stats(openair0_device *device) +static int trx_iqplayer_reset_stats(openair0_device_t *device) { LOG_I(HW, "trx_iqplayer_reset_stats() called, not implemented\n"); return 0; @@ -160,7 +161,7 @@ static int trx_iqplayer_reset_stats(openair0_device *device) /*! \brief Stop operation of the transceiver */ -static int trx_iqplayer_stop(openair0_device *device) +static int trx_iqplayer_stop(openair0_device_t *device) { LOG_I(HW, "trx_iqplayer_stop() called, not implemented\n"); return 0; @@ -171,7 +172,7 @@ static int trx_iqplayer_stop(openair0_device *device) * \param openair0_cfg RF frontend parameters set by application * \returns 0 in success */ -static int trx_iqplayer_set_freq(openair0_device *device, openair0_config_t *openair0_cfg) +static int trx_iqplayer_set_freq(openair0_device_t *device, openair0_config_t *openair0_cfg) { LOG_I(HW, "trx_iqplayer_set_freq() called, not implemented\n"); return 0; @@ -182,7 +183,7 @@ static int trx_iqplayer_set_freq(openair0_device *device, openair0_config_t *ope * \param openair0_cfg RF frontend parameters set by application * \returns 0 in success */ -static int trx_iqplayer_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) +static int trx_iqplayer_set_gains(openair0_device_t *device, openair0_config_t *openair0_cfg) { LOG_I(HW, "trx_iqplayer_set_gains() called, not implemented\n"); return 0; @@ -191,14 +192,16 @@ static int trx_iqplayer_set_gains(openair0_device *device, openair0_config_t *op /*! \brief start the oai iq player * \param device, the hardware used */ -static int trx_iqplayer_start(openair0_device *device) { +static int trx_iqplayer_start(openair0_device_t *device) +{ return 0; } /*! \brief Terminate operation of the oai iq player * \param device, the hardware used */ -static void trx_iqplayer_end(openair0_device *device) { +static void trx_iqplayer_end(openair0_device_t *device) +{ if (device == NULL) return; if (device->recplay_state == NULL) @@ -218,7 +221,6 @@ static void trx_iqplayer_end(openair0_device *device) { close(device->recplay_state->fd); device->recplay_state->fd = -1; } - } /*! \brief Write iqs function when in replay mode, just introduce a delay, as configured at init time, @param device pointer to the device structure specific to the RF hardware target @@ -228,7 +230,8 @@ static void trx_iqplayer_end(openair0_device *device) { @param antenna_id index of the antenna if the device has multiple antennas @param flags flags must be set to true if timestamp parameter needs to be applied */ -static int trx_iqplayer_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { +static int trx_iqplayer_write(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int cc, int flags) +{ struct timespec req; req.tv_sec = 0; req.tv_nsec = device->openair0_cfg->recplay_conf->u_sf_write_delay * 1000; @@ -247,7 +250,8 @@ static int trx_iqplayer_write(openair0_device *device, openair0_timestamp timest * \param antenna_id Index of antenna for which to receive samples * \returns the number of sample read */ -static int trx_iqplayer_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) { +static int trx_iqplayer_read(openair0_device_t *device, openair0_timestamp_t *ptimestamp, void **buff, int nsamps, int cc) +{ recplay_state_t *s = device->recplay_state; static struct timeval tprev; static int read_count = 0; @@ -324,7 +328,8 @@ static int trx_iqplayer_read(openair0_device *device, openair0_timestamp *ptimes return nsamps; } -int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { +int device_init(openair0_device_t *device, openair0_config_t *openair0_cfg) +{ device->openair0_cfg = openair0_cfg; device->trx_start_func = trx_iqplayer_start; device->trx_get_stats_func = trx_iqplayer_get_stats; diff --git a/radio/rfsimulator/simulator.cpp b/radio/rfsimulator/simulator.cpp index ef6be135e6..f89aef02cd 100644 --- a/radio/rfsimulator/simulator.cpp +++ b/radio/rfsimulator/simulator.cpp @@ -141,7 +141,7 @@ typedef c16_t sample_t; // 2*16 bits complex number typedef struct beam_switch_command_t { std::vector beams; - openair0_timestamp timestamp; + openair0_timestamp_t timestamp; } beam_switch_command_t; typedef struct { @@ -157,7 +157,7 @@ typedef struct { typedef struct buffer_s { int conn_sock; - openair0_timestamp lastReceivedTS; + openair0_timestamp_t lastReceivedTS; bool headerMode; bool trashingPacket; samplesBlockHeader_t th; @@ -183,8 +183,8 @@ typedef struct { int listen_sock, epollfd; pthread_mutex_t Sockmutex; unsigned int nb_cnx; - openair0_timestamp nextRxTstamp; - openair0_timestamp lastWroteTS; + openair0_timestamp_t nextRxTstamp; + openair0_timestamp_t lastWroteTS; simuRole role; char *ip; uint16_t port; @@ -218,7 +218,7 @@ typedef struct { * @param nsamps_out output pointer to receive the number of samples until the next beam switch. * @return The beam map (uint64_t) valid for the given timestamp. */ -static std::vector get_beams(beam_state_t *beam_state, openair0_timestamp timestamp, uint32_t nsamps, uint32_t *nsamps_out) +static std::vector get_beams(beam_state_t *beam_state, openair0_timestamp_t timestamp, uint32_t nsamps, uint32_t *nsamps_out) { std::lock_guard lock(beam_state->mutex); std::vector current_beams = beam_state->beams; @@ -284,7 +284,7 @@ static uint64_t beams_to_beam_map(const std::vector &beam_ids) * @param beam_state Pointer to the beam_state_t structure containing the command queue and current beam map. * @param timestamp The timestamp up to which commands should be processed and removed. */ -static void clear_beam_queue(beam_state_t *beam_state, openair0_timestamp timestamp) +static void clear_beam_queue(beam_state_t *beam_state, openair0_timestamp_t timestamp) { std::lock_guard lock(beam_state->mutex); while (!beam_state->cmd_queue.empty()) { @@ -472,7 +472,7 @@ static float get_rx_gain_db(rfsimulator_state_t *rfsimulator, uint rx_beam, uint return rfsimulator->beam_ctrl->beam_gains[rx_beam][tx_beam]; } -static int rfsimulator_set_beams(openair0_device *device, uint64_t beam_map, openair0_timestamp timestamp) +static int rfsimulator_set_beams(openair0_device_t *device, uint64_t beam_map, openair0_timestamp_t timestamp) { rfsimulator_state_t *s = static_cast(device->priv); rfsim_beam_ctrl_t *beam_ctrl = s->beam_ctrl; @@ -484,7 +484,7 @@ static int rfsimulator_set_beams(openair0_device *device, uint64_t beam_map, ope return 0; } -static int rfsimulator_set_beams_vector(openair0_device *device, int* beams, int num_beams, openair0_timestamp timestamp) +static int rfsimulator_set_beams_vector(openair0_device_t *device, int *beams, int num_beams, openair0_timestamp_t timestamp) { rfsimulator_state_t *s = static_cast(device->priv); rfsim_beam_ctrl_t *beam_ctrl = s->beam_ctrl; @@ -769,13 +769,13 @@ static int rfsimu_getdistance_cmd(char *buff, int debug, telnet_printfunc_t prnt static int rfsimu_vtime_cmd(char *buff, int debug, telnet_printfunc_t prnt, void *arg) { rfsimulator_state_t *t = (rfsimulator_state_t *)arg; - const openair0_timestamp ts = t->nextRxTstamp; + const openair0_timestamp_t ts = t->nextRxTstamp; const double sample_rate = t->sample_rate; prnt("%s: vtime measurement: TS %llu sample_rate %.3f\n", __func__, ts, sample_rate); return CMDSTATUS_FOUND; } -static int startServer(openair0_device *device) +static int startServer(openair0_device_t *device) { int sock = -1; struct addrinfo *results = NULL; @@ -885,7 +885,7 @@ static int client_try_connect(const char *host, uint16_t port) return sock; } -static int startClient(openair0_device *device) +static int startClient(openair0_device_t *device) { rfsimulator_state_t *t = static_cast(device->priv); t->role = SIMU_ROLE_CLIENT; @@ -928,7 +928,7 @@ static int startClient(openair0_device *device) } static int rfsimulator_write_internal(rfsimulator_state_t *t, - openair0_timestamp timestamp, + openair0_timestamp_t timestamp, void ***samplesVoid, int nsamps, int nbAnt, @@ -986,8 +986,8 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, return nsamps; } -static int rfsimulator_write_beams(openair0_device *device, - openair0_timestamp timestamp, +static int rfsimulator_write_beams(openair0_device_t *device, + openair0_timestamp_t timestamp, void ***samplesVoid, int nsamps, int nbAnt, @@ -1022,7 +1022,7 @@ static int rfsimulator_write_beams(openair0_device *device, return nsamps_initial; } -static int rfsimulator_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) +static int rfsimulator_write(openair0_device_t *device, openair0_timestamp_t timestamp, void **buff, int nsamps, int cc, int flags) { void **tmp = buff; return rfsimulator_write_beams(device, timestamp, &tmp, nsamps, cc, 1, flags); @@ -1253,7 +1253,7 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, bool first_time) static void rfsimulator_read_internal(rfsimulator_state_t *t, c16_t **samples, - openair0_timestamp timestamp, + openair0_timestamp_t timestamp, int nsamps, int nbAnt, int rx_beam_id, @@ -1355,8 +1355,8 @@ static void rfsimulator_read_internal(rfsimulator_state_t *t, } } -static int rfsimulator_read_beams(openair0_device *device, - openair0_timestamp *ptimestamp, +static int rfsimulator_read_beams(openair0_device_t *device, + openair0_timestamp_t *ptimestamp, void ***samplesVoid, int nsamps, int nbAnt, @@ -1438,7 +1438,7 @@ static int rfsimulator_read_beams(openair0_device *device, for (int a = 0; a < nbAnt; a++) memset(samplesVoid[beam][a], 0, sampleToByte(nsamps, 1)); - openair0_timestamp timestamp = t->nextRxTstamp; + openair0_timestamp_t timestamp = t->nextRxTstamp; int nsamps_to_process = nsamps; while (nsamps_to_process > 0) { uint32_t nsamps_beam_map; @@ -1488,7 +1488,7 @@ static int rfsimulator_read_beams(openair0_device *device, buffer_t *ptr = &t->buf[sock]; if (ptr->conn_sock != -1 && !ptr->received_packets.empty()) { - openair0_timestamp timestamp_to_free = t->nextRxTstamp - 1; + openair0_timestamp_t timestamp_to_free = t->nextRxTstamp - 1; if (ptr->channel_model) { timestamp_to_free -= (ptr->channel_model->channel_length - 1) + std::max(ptr->channel_model->channel_offset, t->chan_offset); @@ -1502,20 +1502,20 @@ static int rfsimulator_read_beams(openair0_device *device, return nsamps; } -static int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, void **samplesVoid, int nsamps, int nbAnt) +static int rfsimulator_read(openair0_device_t *device, openair0_timestamp_t *ptimestamp, void **samplesVoid, int nsamps, int nbAnt) { return rfsimulator_read_beams(device, ptimestamp, &samplesVoid, nsamps, nbAnt, 1); } -static int rfsimulator_get_stats(openair0_device *device) +static int rfsimulator_get_stats(openair0_device_t *device) { return 0; } -static int rfsimulator_reset_stats(openair0_device *device) +static int rfsimulator_reset_stats(openair0_device_t *device) { return 0; } -static void rfsimulator_end(openair0_device *device) +static void rfsimulator_end(openair0_device_t *device) { rfsimulator_state_t *s = static_cast(device->priv); for (int i = 0; i < MAX_FD_RFSIMU; i++) { @@ -1529,7 +1529,8 @@ static void rfsimulator_end(openair0_device *device) close(s->epollfd); free(s); } -static void stopServer(openair0_device *device) + +static void stopServer(openair0_device_t *device) { rfsimulator_state_t *t = (rfsimulator_state_t *)device->priv; DevAssert(t != NULL); @@ -1537,26 +1538,26 @@ static void stopServer(openair0_device *device) rfsimulator_end(device); } -static int rfsimulator_stop(openair0_device *device) +static int rfsimulator_stop(openair0_device_t *device) { return 0; } -static int rfsimulator_set_freq(openair0_device *device, openair0_config_t *openair0_cfg) +static int rfsimulator_set_freq(openair0_device_t *device, openair0_config_t *openair0_cfg) { rfsimulator_state_t *s = static_cast(device->priv); s->rx_freq = openair0_cfg->rx_freq[0]; return 0; } -static int rfsimulator_set_gains(openair0_device *device, openair0_config_t *openair0_cfg) +static int rfsimulator_set_gains(openair0_device_t *device, openair0_config_t *openair0_cfg) { return 0; } -static int rfsimulator_write_init(openair0_device *device) +static int rfsimulator_write_init(openair0_device_t *device) { return 0; } -extern "C" __attribute__((__visibility__("default"))) int device_init(openair0_device *device, openair0_config_t *openair0_cfg) +extern "C" __attribute__((__visibility__("default"))) int device_init(openair0_device_t *device, openair0_config_t *openair0_cfg) { // to change the log level, use this on command line // --log_config.hw_log_level debug diff --git a/radio/vrtsim/vrtsim.c b/radio/vrtsim/vrtsim.c index 1b2b075bd0..55be9788de 100644 --- a/radio/vrtsim/vrtsim.c +++ b/radio/vrtsim/vrtsim.c @@ -275,7 +275,7 @@ static client_info_t client_read_info(char *descriptor_file) return client_info; } -static int vrtsim_connect(openair0_device *device) +static int vrtsim_connect(openair0_device_t *device) { vrtsim_state_t *vrtsim_state = (vrtsim_state_t *)device->priv; @@ -337,7 +337,7 @@ static int vrtsim_connect(openair0_device *device) } static int vrtsim_write_internal(vrtsim_state_t *vrtsim_state, - openair0_timestamp timestamp, + openair0_timestamp_t timestamp, c16_t *samples, int nsamps, int aarx, @@ -366,7 +366,7 @@ static int vrtsim_write_internal(vrtsim_state_t *vrtsim_state, typedef struct { vrtsim_state_t *vrtsim_state; - openair0_timestamp timestamp; + openair0_timestamp_t timestamp; c16_t *samples[MAX_NUM_ANTENNAS_TX]; int nsamps; int nbAnt; @@ -469,7 +469,7 @@ static void perform_channel_modelling(void *arg) } static int vrtsim_write_with_chanmod(vrtsim_state_t *vrtsim_state, - openair0_timestamp timestamp, + openair0_timestamp_t timestamp, void **samplesVoid, int nsamps, int nbAnt, @@ -478,7 +478,7 @@ static int vrtsim_write_with_chanmod(vrtsim_state_t *vrtsim_state, // Sample history for channel impulse response static c16_t saved_samples[MAX_NUM_ANTENNAS_TX][SAVED_SAMPLES_LEN] __attribute__((aligned(32))) = {0}; // Indicates what samples are saves in saved_samples - static openair0_timestamp last_timestamp = 0; + static openair0_timestamp_t last_timestamp = 0; const int batch_size = 4096; AssertFatal(nbAnt <= MAX_NUM_ANTENNAS_TX, "Number of antennas %d exceeds maximum %d\n", nbAnt, MAX_NUM_ANTENNAS_TX); @@ -533,7 +533,12 @@ static int vrtsim_write_with_chanmod(vrtsim_state_t *vrtsim_state, return nsamps; } -static int vrtsim_write(openair0_device *device, openair0_timestamp timestamp, void **samplesVoid, int nsamps, int nbAnt, int flags) +static int vrtsim_write(openair0_device_t *device, + openair0_timestamp_t timestamp, + void **samplesVoid, + int nsamps, + int nbAnt, + int flags) { AssertFatal(nsamps > 0, "Number of samples must be greater than 0\n"); AssertFatal(nbAnt > 0 && nbAnt <= MAX_NUM_ANTENNAS_TX, @@ -548,8 +553,8 @@ static int vrtsim_write(openair0_device *device, openair0_timestamp timestamp, v : vrtsim_write_internal(vrtsim_state, timestamp, (c16_t *)samplesVoid[0], nsamps, 0, flags, 0); } -static int vrtsim_write_beams(openair0_device *device, - openair0_timestamp timestamp, +static int vrtsim_write_beams(openair0_device_t *device, + openair0_timestamp_t timestamp, void ***buff, int nsamps, int nb_antennas_tx, @@ -560,7 +565,7 @@ static int vrtsim_write_beams(openair0_device *device, return nsamps; } -static int vrtsim_read(openair0_device *device, openair0_timestamp *ptimestamp, void **samplesVoid, int nsamps, int nbAnt) +static int vrtsim_read(openair0_device_t *device, openair0_timestamp_t *ptimestamp, void **samplesVoid, int nsamps, int nbAnt) { vrtsim_state_t *vrtsim_state = (vrtsim_state_t *)device->priv; if (shm_td_iq_channel_is_aborted(vrtsim_state->channel)) { @@ -599,7 +604,7 @@ static int vrtsim_read(openair0_device *device, openair0_timestamp *ptimestamp, return nsamps; } -static void vrtsim_end(openair0_device *device) +static void vrtsim_end(openair0_device_t *device) { vrtsim_state_t *vrtsim_state = (vrtsim_state_t *)device->priv; if (vrtsim_state->role == ROLE_SERVER && vrtsim_state->run_timing_thread) { @@ -653,33 +658,34 @@ static void vrtsim_end(openair0_device *device) } } -static int vrtsim_stub(openair0_device *device) -{ - return 0; -} -static int vrtsim_stub2(openair0_device *device, openair0_config_t *openair0_cfg) +static int vrtsim_stub(openair0_device_t *device) { return 0; } -static int vrtsim_set_freq(openair0_device *device, openair0_config_t *openair0_cfg) +static int vrtsim_stub2(openair0_device_t *device, openair0_config_t *openair0_cfg) +{ + return 0; +} + +static int vrtsim_set_freq(openair0_device_t *device, openair0_config_t *openair0_cfg) { vrtsim_state_t *s = device->priv; s->rx_freq = openair0_cfg->rx_freq[0]; return 0; } -static int vrtsim_set_beams(openair0_device *device, uint64_t beam_map, openair0_timestamp timestamp) +static int vrtsim_set_beams(openair0_device_t *device, uint64_t beam_map, openair0_timestamp_t timestamp) { return 0; } -static int vrtsim_set_beams2(openair0_device *device, int *beam_ids, int num_beams, openair0_timestamp timestamp) +static int vrtsim_set_beams2(openair0_device_t *device, int *beam_ids, int num_beams, openair0_timestamp_t timestamp) { return 0; } -__attribute__((__visibility__("default"))) int device_init(openair0_device *device, openair0_config_t *openair0_cfg) +__attribute__((__visibility__("default"))) int device_init(openair0_device_t *device, openair0_config_t *openair0_cfg) { randominit(); vrtsim_state_t *vrtsim_state = calloc_or_fail(1, sizeof(vrtsim_state_t));