Commit 54f5383e authored by 111's avatar 111

modify to oxgrf

parent deb31add
trx trx
.vscode/
\ No newline at end of file
...@@ -38,21 +38,22 @@ ...@@ -38,21 +38,22 @@
#include "common_lib.h" #include "common_lib.h"
#include "assertions.h" #include "assertions.h"
#include "load_module_shlib.h" #include "common/utils/load_module_shlib.h"
#include "common/utils/LOG/log.h"
//#include "targets/RT/USER/lte-softmodem.h"
#include "executables/softmodem-common.h"
const char* devtype_names[MAX_RF_DEV_TYPE] = { const char* devtype_names[MAX_RF_DEV_TYPE] = {
"", "",
"EXMIMO",
"USRP B200", "USRP B200",
"USRP X300", "USRP X300",
"USRP N300", "USRP N300",
"USRP X400", "USRP X400",
"BLADERF", "BLADERF",
"YunSDR", "OXGRF_DEV",
"LMSSDR", "LMSSDR",
"IRIS", "IRIS",
"No HW", "No HW",
"ADRV9371_ZC706",
"UEDv2", "UEDv2",
"RFSIMULATOR" "RFSIMULATOR"
}; };
......
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
//#include <openair1/PHY/TOOLS/tools_defs.h>
//#include "record_player.h"
/* default name of shared library implementing the radio front end */ /* default name of shared library implementing the radio front end */
#define OAI_RF_LIBNAME "oai_device" #define OAI_RF_LIBNAME "oai_device"
...@@ -47,6 +45,7 @@ ...@@ -47,6 +45,7 @@
/* name of shared library implementing the rf simulator */ /* name of shared library implementing the rf simulator */
#define OAI_RFSIM_LIBNAME "rfsimulator" #define OAI_RFSIM_LIBNAME "rfsimulator"
/* name of shared library implementing the iq player */ /* name of shared library implementing the iq player */
#define OAI_IQPLAYER_LIBNAME "oai_iqplayer"
/* flags for BBU to determine whether the attached radio head is local or remote */ /* flags for BBU to determine whether the attached radio head is local or remote */
#define RAU_LOCAL_RADIO_HEAD 0 #define RAU_LOCAL_RADIO_HEAD 0
...@@ -81,8 +80,6 @@ typedef enum { ...@@ -81,8 +80,6 @@ typedef enum {
*/ */
typedef enum { typedef enum {
MIN_RF_DEV_TYPE = 0, MIN_RF_DEV_TYPE = 0,
/*!\brief device is ExpressMIMO */
EXMIMO_DEV,
/*!\brief device is USRP B200/B210*/ /*!\brief device is USRP B200/B210*/
USRP_B200_DEV, USRP_B200_DEV,
/*!\brief device is USRP X300/X310*/ /*!\brief device is USRP X300/X310*/
...@@ -93,16 +90,14 @@ typedef enum { ...@@ -93,16 +90,14 @@ typedef enum {
USRP_X400_DEV, USRP_X400_DEV,
/*!\brief device is BLADE RF*/ /*!\brief device is BLADE RF*/
BLADERF_DEV, BLADERF_DEV,
/*!\brief device is YUNSDR pcie*/ /*!\brief device is OXGRF pcie*/
YUNSDR_DEV, OXGRF_DEV,
/*!\brief device is LMSSDR (SoDeRa)*/ /*!\brief device is LMSSDR (SoDeRa)*/
LMSSDR_DEV, LMSSDR_DEV,
/*!\brief device is Iris */ /*!\brief device is Iris */
IRIS_DEV, IRIS_DEV,
/*!\brief device is NONE*/ /*!\brief device is NONE*/
NONE_DEV, NONE_DEV,
/*!\brief device is ADRV9371_ZC706 */
ADRV9371_ZC706_DEV,
/*!\brief device is UEDv2 */ /*!\brief device is UEDv2 */
UEDv2_DEV, UEDv2_DEV,
RFSIMULATOR, RFSIMULATOR,
...@@ -154,6 +149,13 @@ typedef enum { ...@@ -154,6 +149,13 @@ typedef enum {
gpsdo=2 gpsdo=2
} clock_source_t; } clock_source_t;
/*! \brief Radio Tx burst flags */
typedef enum {
Invalid = 0,
MiddleOfBurst,
StartOfBurst,
EndOfBurst
} radio_tx_flag_t;
/*! \brief RF frontend parameters set by application */ /*! \brief RF frontend parameters set by application */
typedef struct { typedef struct {
...@@ -179,9 +181,15 @@ typedef struct { ...@@ -179,9 +181,15 @@ typedef struct {
int rx_num_channels; int rx_num_channels;
//! number of TX channels (=TX antennas) //! number of TX channels (=TX antennas)
int tx_num_channels; int tx_num_channels;
//! rx daughter card
char* rx_subdev;
//! tx daughter card
char* tx_subdev;
//! \brief RX base addresses for mmapped_dma //! \brief RX base addresses for mmapped_dma
int32_t *rxbase[4]; int32_t *rxbase[4];
//! \brief TX base addresses for mmapped_dma //! \brief RX buffer size for direct access
int rxsize;
//! \brief TX base addresses for mmapped_dma or direct access
int32_t *txbase[4]; int32_t *txbase[4];
//! \brief Center frequency in Hz for RX. //! \brief Center frequency in Hz for RX.
//! index: [0..rx_num_channels[ //! index: [0..rx_num_channels[
...@@ -212,7 +220,6 @@ typedef struct { ...@@ -212,7 +220,6 @@ typedef struct {
//! timing_source //! timing_source
clock_source_t time_source; clock_source_t time_source;
//! Manual SDR IP address //! Manual SDR IP address
//#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) || defined(OAI_YUNSDR)
char *sdr_addrs; char *sdr_addrs;
//! Auto calibration flag //! Auto calibration flag
int autocal[4]; int autocal[4];
...@@ -247,6 +254,10 @@ typedef struct { ...@@ -247,6 +254,10 @@ typedef struct {
int nr_band; int nr_band;
//! NR scs for raster //! NR scs for raster
int nr_scs_for_raster; int nr_scs_for_raster;
//! Core IDs for RX FH
int rxfh_cores[4];
//! Core IDs for TX FH
int txfh_cores[4];
} openair0_config_t; } openair0_config_t;
/*! \brief RF mapping */ /*! \brief RF mapping */
...@@ -311,8 +322,23 @@ typedef struct { ...@@ -311,8 +322,23 @@ typedef struct {
pthread_cond_t cond_write; pthread_cond_t cond_write;
/// mutex for trx write thread /// mutex for trx write thread
pthread_mutex_t mutex_write; pthread_mutex_t mutex_write;
/// to inform the thread to exit
int write_thread_exit;
} openair0_thread_t; } 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;
int first_read;
uint32_t *buff[8];
uint32_t buff_size;
int r[8];
int active;
} fhstate_t;
/*!\brief structure holds the parameters to configure USRP devices */ /*!\brief structure holds the parameters to configure USRP devices */
struct openair0_device_t { struct openair0_device_t {
/*!tx write thread*/ /*!tx write thread*/
...@@ -338,7 +364,6 @@ struct openair0_device_t { ...@@ -338,7 +364,6 @@ struct openair0_device_t {
/* !brief ETH params set by application */ /* !brief ETH params set by application */
eth_params_t *eth_params; eth_params_t *eth_params;
/* !brief Indicates if device already initialized */ /* !brief Indicates if device already initialized */
int is_init; int is_init;
...@@ -346,6 +371,18 @@ struct openair0_device_t { ...@@ -346,6 +371,18 @@ struct openair0_device_t {
/*!brief Can be used by driver to hold internal structure*/ /*!brief Can be used by driver to hold internal structure*/
void *priv; void *priv;
/*!brief pointer to FH state, used in ECPRI split 8*/
fhstate_t fhstate;
/*!brief Used in ECPRI split 8 to indicate numerator of sampling rate ratio*/
int sampling_rate_ratio_n;
/*!brief Used in ECPRI split 8 to indicate denominator of sampling rate ratio*/
int sampling_rate_ratio_d;
/*!brief Used in ECPRI split 8 to indicate the TX/RX timing offset*/
int txrx_offset;
/* Functions API, which are called by the application*/ /* Functions API, which are called by the application*/
/*! \brief Called to start the transceiver. Return 0 if OK, < 0 if error /*! \brief Called to start the transceiver. Return 0 if OK, < 0 if error
...@@ -380,7 +417,7 @@ struct openair0_device_t { ...@@ -380,7 +417,7 @@ struct openair0_device_t {
@param buff Buffer which holds the samples (2 dimensional) @param buff Buffer which holds the samples (2 dimensional)
@param nsamps number of samples to be sent @param nsamps number of samples to be sent
@param number of antennas @param number of antennas
@param flags flags must be set to TRUE if timestamp parameter needs to be applied @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 antenna_id, int flags); int (*trx_write_func)(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int antenna_id, int flags);
...@@ -390,9 +427,9 @@ struct openair0_device_t { ...@@ -390,9 +427,9 @@ struct openair0_device_t {
@param buff Buffer which holds the samples (1 dimensional) @param buff Buffer which holds the samples (1 dimensional)
@param nsamps number of samples to be sent @param nsamps number of samples to be sent
@param antenna_id index of the antenna if the device has multiple anteannas @param antenna_id index of the antenna if the device has multiple anteannas
@param flags flags must be set to TRUE if timestamp parameter needs to be applied @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 nsamps,int antenna_id, int flags); int (*trx_write_func2)(openair0_device *device, openair0_timestamp timestamp, void **buff, int fd_ind,int nsamps, int flags,int nant);
/*! \brief Receive samples from hardware. /*! \brief Receive samples from hardware.
* Read \ref nsamps samples from each channel to buffers. buff[0] is the array for * Read \ref nsamps samples from each channel to buffers. buff[0] is the array for
...@@ -414,12 +451,13 @@ struct openair0_device_t { ...@@ -414,12 +451,13 @@ struct openair0_device_t {
* was received. * was received.
* \param device the hardware to use * \param device the hardware to use
* \param[out] ptimestamp the time at which the first sample was received. * \param[out] ptimestamp the time at which the first sample was received.
* \param[out] buff A pointers to a buffer for received samples. The buffer must be large enough to hold the number of samples \ref nsamps. * \param[out] buff A pointer to a buffer[ant_id][] for received samples. The buffer[ant_id] must be large enough to hold the number of samples \ref nsamps * the number of packets.
* \param nsamps Number of samples. One sample is 2 byte I + 2 byte Q => 4 byte. * \param nsamps Number of samples. One sample is 2 byte I + 2 byte Q => 4 byte.
* \param packet_idx offset into
* \param antenna_id Index of antenna from which samples were received * \param antenna_id Index of antenna from which samples were received
* \returns the number of sample read * \returns the number of sample read
*/ */
int (*trx_read_func2)(openair0_device *device, openair0_timestamp *ptimestamp, void *buff, int nsamps,int *antenna_id); int (*trx_read_func2)(openair0_device *device, openair0_timestamp *ptimestamp, uint32_t **buff, int nsamps);
/*! \brief print the device statistics /*! \brief print the device statistics
* \param device the hardware to use * \param device the hardware to use
...@@ -447,10 +485,9 @@ struct openair0_device_t { ...@@ -447,10 +485,9 @@ struct openair0_device_t {
/*! \brief Set RX feaquencies /*! \brief Set RX feaquencies
* \param device the hardware to use * \param device the hardware to use
* \param openair0_cfg RF frontend parameters set by application * \param openair0_cfg RF frontend parameters set by application
* \param exmimo_dump_config dump EXMIMO configuration
* \returns 0 in success * \returns 0 in success
*/ */
int (*trx_set_freq_func)(openair0_device *device, openair0_config_t *openair0_cfg,int exmimo_dump_config); int (*trx_set_freq_func)(openair0_device *device, openair0_config_t *openair0_cfg);
/*! \brief Set gains /*! \brief Set gains
* \param device the hardware to use * \param device the hardware to use
...@@ -468,6 +505,7 @@ struct openair0_device_t { ...@@ -468,6 +505,7 @@ struct openair0_device_t {
/*! \brief Pointer to generic RRU private information /*! \brief Pointer to generic RRU private information
*/ */
void *thirdparty_priv; void *thirdparty_priv;
/*! \brief Callback for Third-party RRU Initialization routine /*! \brief Callback for Third-party RRU Initialization routine
...@@ -494,6 +532,8 @@ struct openair0_device_t { ...@@ -494,6 +532,8 @@ struct openair0_device_t {
* \return a pointer to the parameter * \return a pointer to the parameter
*/ */
void *(*get_internal_parameter)(char *id); void *(*get_internal_parameter)(char *id);
/* \brief timing statistics for TX fronthaul (ethernet)
*/
}; };
/* type of device init function, implemented in shared lib */ /* type of device init function, implemented in shared lib */
...@@ -563,9 +603,6 @@ openair0_timestamp get_usrp_time(openair0_device *device); ...@@ -563,9 +603,6 @@ openair0_timestamp get_usrp_time(openair0_device *device);
*/ */
int openair0_set_rx_frequencies(openair0_device *device, openair0_config_t *openair0_cfg); int openair0_set_rx_frequencies(openair0_device *device, openair0_config_t *openair0_cfg);
/*! \brief store recorded iqs from memory to file. */
extern void iqrecorder_end(openair0_device *device);
#include <unistd.h> #include <unistd.h>
#ifndef gettid #ifndef gettid
......
This diff is collapsed.
/* /** oxgrf_lib.h
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
* *
* Author: openxg
*/ */
#ifndef YUNSDR_RF_HELPER_H_
#define YUNSDR_RF_HELPER_H_
// A bunch of helper functions to process device arguments #include "oxgrf_api_ss.h"
#include "common_lib.h"
/** @addtogroup _OXGRF_PHY_RF_INTERFACE_
* @{
*/
typedef struct
{
OXGRF_DESCRIPTOR *dev;
int16_t *rx_buffer;
int16_t *tx_buffer;
//! Sample rate
int a;
} test_t;
#include <stdio.h> /*! \brief OXGRF specific data structure */
#include <stdlib.h> typedef struct {
#include <string.h>
//! opaque OXGRF device struct. An empty ("") or NULL device identifier will result in the first encountered device being opened (using the first discovered backend)
OXGRF_DESCRIPTOR *dev;
int16_t *rx_buffer;
int16_t *tx_buffer;
//! Sample rate
unsigned int sample_rate;
int rx_num_channels;
int tx_num_channels;
// --------------------------------
// Debug and output control
// --------------------------------
//! Number of underflows
int num_underflows;
//! Number of overflows
int num_overflows;
//! number of RX errors
int num_rx_errors;
//! Number of TX errors
int num_tx_errors;
//! timestamp of current TX
uint64_t tx_current_ts;
//! timestamp of current RX
uint64_t rx_current_ts;
//! number of TX samples
uint64_t tx_nsamps;
//! number of RX samples
uint64_t rx_nsamps;
//! number of TX count
uint64_t tx_count;
//! number of RX count
uint64_t rx_count;
//! timestamp of RX packet
openair0_timestamp rx_timestamp;
} oxgrf_state_t;
/*! \brief get current timestamp
*\param device the hardware to use
*/
openair0_timestamp trx_get_timestamp(openair0_device *device);
#define REMOVE_SUBSTRING_WITHCOMAS(S, TOREMOVE) \ #define REMOVE_SUBSTRING_WITHCOMAS(S, TOREMOVE) \
remove_substring(S, TOREMOVE ","); \ remove_substring(S, TOREMOVE ","); \
...@@ -53,4 +93,11 @@ static inline void copy_subdev_string(char* dst, char* src) ...@@ -53,4 +93,11 @@ static inline void copy_subdev_string(char* dst, char* src)
dst[n] = '\0'; dst[n] = '\0';
} }
#endif /* YUNSDR_RF_HELPER_H_ */ /*! \brief Initialize Openair oxgrf target. It returns 0 if OK
* \param device the hardware to use
* \param openair0_cfg RF frontend parameters set by application
* \returns 0 on success
*/
int device_init(openair0_device *device, openair0_config_t *openair0_cfg);
/*@}*/
BUILD: BUILD:
x86 x86
sudo gcc -o trx trx_test.c yunsdr_lib.c -march=knl -lyunsdr_ss -g sudo gcc -o trx trx_test.c oxgrf_lib.c -march=native -loxgrf_ss -g
arm arm
sudo gcc -o trx trx_test.c yunsdr_lib.c -lyunsdr_ss -g sudo gcc -o trx trx_test.c yunsdr_lib.c -lyunsdr_ss -g
......
File deleted
...@@ -39,6 +39,15 @@ struct timespec nr_get_timespec_diff( ...@@ -39,6 +39,15 @@ struct timespec nr_get_timespec_diff(
} }
int main( int argc, char **argv ) { int main( int argc, char **argv ) {
// test_t *t1=malloc(sizeof(test_t));
test_t t2[4];
// t2[0].b = 30720 * 1e3;
// t1->a = t2[0].b;
// printf("test\n");
// return 0;
struct sched_param rr_param; struct sched_param rr_param;
rr_param.sched_priority = 90; rr_param.sched_priority = 90;
sched_setscheduler(getpid(), SCHED_RR, &rr_param); sched_setscheduler(getpid(), SCHED_RR, &rr_param);
...@@ -128,9 +137,9 @@ int main( int argc, char **argv ) { ...@@ -128,9 +137,9 @@ int main( int argc, char **argv ) {
readBlockSize = samples_per_subframe/2; readBlockSize = samples_per_subframe/2;
writeBlockSize = readBlockSize; writeBlockSize = readBlockSize;
device_init(&(rfdevice), &openair0_cfg[0]); device_init(&(rfdevice), &openair0_cfg[0]);
rfdevice.trx_start_func(&rfdevice); rfdevice.trx_start_func(&rfdevice);
//first time is very long, don't know why. //first time is very long, don't know why.
...@@ -183,6 +192,5 @@ int main( int argc, char **argv ) { ...@@ -183,6 +192,5 @@ int main( int argc, char **argv ) {
} // while !oai_exit } // while !oai_exit
return 0; return 0;
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <string.h> #include <string.h>
//#include "T.h" //#include "T.h"
#include "common_lib.h" #include "common_lib.h"
#include "yunsdr_lib.h" #include "oxgrf_lib.h"
#include "utils.h" #include "utils.h"
typedef long int openair0_timestamp; typedef long int openair0_timestamp;
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/** yunsdr_lib.h
*
* Author: eric
* base on bladerf_lib.h
*/
#include "yunsdr_api_ss.h"
#include "common_lib.h"
/** @addtogroup _YUNSDR_PHY_RF_INTERFACE_
* @{
*/
/*! \brief YunSDR specific data structure */
typedef struct {
//! opaque YunSDR device struct. An empty ("") or NULL device identifier will result in the first encountered device being opened (using the first discovered backend)
YUNSDR_DESCRIPTOR *dev;
int16_t *rx_buffer;
int16_t *tx_buffer;
//! Sample rate
unsigned int sample_rate;
int rx_num_channels;
int tx_num_channels;
uint64_t tx_lo_freq;
uint64_t rx_lo_freq;
// --------------------------------
// Debug and output control
// --------------------------------
//! Number of underflows
int num_underflows;
//! Number of overflows
int num_overflows;
//! number of RX errors
int num_rx_errors;
//! Number of TX errors
int num_tx_errors;
//! timestamp of current TX
uint64_t tx_current_ts;
//! timestamp of current RX
uint64_t rx_current_ts;
//! number of TX samples
uint64_t tx_nsamps;
//! number of RX samples
uint64_t rx_nsamps;
//! number of TX count
uint64_t tx_count;
//! number of RX count
uint64_t rx_count;
//! timestamp of RX packet
openair0_timestamp rx_timestamp;
} yunsdr_state_t;
/*! \brief get current timestamp
*\param device the hardware to use
*/
openair0_timestamp trx_get_timestamp(openair0_device *device);
int device_init(openair0_device *device, openair0_config_t *openair0_cfg);
/*@}*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment