common_lib.h 20.1 KB
Newer Older
1 2 3 4 5
/*
 * 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
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * 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
 */
21

22 23
/*! \file common_lib.h
 * \brief common APIs for different RF frontend device
24 25 26 27 28 29 30 31
 * \author HongliangXU, Navid Nikaein
 * \date 2015
 * \version 0.2
 * \company Eurecom
 * \maintainer:  navid.nikaein@eurecom.fr
 * \note
 * \warning
 */
32

Raymond Knopp's avatar
 
Raymond Knopp committed
33 34 35
#ifndef COMMON_LIB_H
#define COMMON_LIB_H
#include <stdint.h>
36
#include <stdio.h>
37
#include <sys/types.h>
38
#include <openair1/PHY/TOOLS/tools_defs.h>
39
#include "record_player.h"
Raymond Knopp's avatar
 
Raymond Knopp committed
40

41
/* default name of shared library implementing the radio front end */
42
#define OAI_RF_LIBNAME        "oai_device"
43
/* name of shared library implementing the transport */
44
#define OAI_TP_LIBNAME        "oai_transpro"
45 46
/* name of shared library implementing a third-party transport */
#define OAI_THIRDPARTY_TP_LIBNAME        "thirdparty_transpro"
47
/* name of shared library implementing the rf simulator */
48
#define OAI_RFSIM_LIBNAME     "rfsimulator"
49
/* name of shared library implementing the basic simulator */
50
#define OAI_BASICSIM_LIBNAME  "tcp_bridge_oai"
51 52 53
/* name of shared library implementing the iq player */
#define OAI_IQPLAYER_LIBNAME  "oai_iqplayer"

54
/* flags for BBU to determine whether the attached radio head is local or remote */
55 56
#define RAU_LOCAL_RADIO_HEAD  0
#define RAU_REMOTE_RADIO_HEAD 1
57
#define RAU_REMOTE_THIRDPARTY_RADIO_HEAD 2
WANG Tsu-Han's avatar
WANG Tsu-Han committed
58 59
#define MAX_WRITE_THREAD_PACKAGE     10
#define MAX_WRITE_THREAD_BUFFER_SIZE 8
60
#ifndef MAX_CARDS
61
  #define MAX_CARDS 8
62
#endif
63

Raymond Knopp's avatar
 
Raymond Knopp committed
64
typedef int64_t openair0_timestamp;
65
typedef volatile int64_t openair0_vtimestamp;
66

67

68
/*!\brief structure holds the parameters to configure USRP devices*/
Raymond Knopp's avatar
 
Raymond Knopp committed
69
typedef struct openair0_device_t openair0_device;
70

71
//#define USRP_GAIN_OFFSET (56.0)  // 86 calibrated for USRP B210 @ 2.6 GHz to get equivalent RS EPRE in OAI to SMBV100 output
Raymond Knopp's avatar
 
Raymond Knopp committed
72

Raymond Knopp's avatar
 
Raymond Knopp committed
73 74 75 76
typedef enum {
  max_gain=0,med_gain,byp_gain
} rx_gain_t;

77 78 79 80
typedef enum {
  duplex_mode_TDD=1,duplex_mode_FDD=0
} duplex_mode_t;

81

82
/** @addtogroup _GENERIC_PHY_RF_INTERFACE_
83 84
 * @{
 */
85 86 87 88 89 90 91 92 93 94
/*!\brief RF device types
 */
typedef enum {
  MIN_RF_DEV_TYPE = 0,
  /*!\brief device is ExpressMIMO */
  EXMIMO_DEV,
  /*!\brief device is USRP B200/B210*/
  USRP_B200_DEV,
  /*!\brief device is USRP X300/X310*/
  USRP_X300_DEV,
95 96
  /*!\brief device is USRP N300/N310*/
  USRP_N300_DEV,
97 98
  /*!\brief device is BLADE RF*/
  BLADERF_DEV,
99 100
  /*!\brief device is LMSSDR (SoDeRa)*/
  LMSSDR_DEV,
101 102
  /*!\brief device is Iris */
  IRIS_DEV,
103 104
  /*!\brief device is NONE*/
  NONE_DEV,
105 106 107 108
  /*!\brief device is ADRV9371_ZC706 */
  ADRV9371_ZC706_DEV,
  /*!\brief device is UEDv2 */
  UEDv2_DEV,
Laurent Thomas's avatar
Laurent Thomas committed
109
  RFSIMULATOR,
110 111
  MAX_RF_DEV_TYPE
} dev_type_t;
Laurent Thomas's avatar
Laurent Thomas committed
112
#define DEVTYPE_NAMES {"","EXMIMO","USRP B200","USRP X300","USRP N300","BLADERF","LMSSDR","IRIS","No HW","ADRV9371_ZC706","UEDv2", "RFSIMULATOR"} 
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
/*!\brief transport protocol types
 */
typedef enum {
  MIN_TRANSP_TYPE = 0,
  /*!\brief transport protocol ETHERNET */
  ETHERNET_TP,
  /*!\brief no transport protocol*/
  NONE_TP,
  MAX_TRANSP_TYPE
} transport_type_t;


/*!\brief  openair0 device host type */
typedef enum {
  MIN_HOST_TYPE = 0,
128
  /*!\brief device functions within a RAU */
129
  RAU_HOST,
130
  /*!\brief device functions within a RRU */
131
  RRU_HOST,
132
  MAX_HOST_TYPE
133
} host_type_t;
134

Rohit Gupta's avatar
Rohit Gupta committed
135

136
/*! \brief RF Gain clibration */
137 138 139 140 141 142
typedef struct {
  //! Frequency for which RX chain was calibrated
  double freq;
  //! Offset to be applied to RX gain
  double offset;
} rx_gain_calib_table_t;
Raymond Knopp's avatar
 
Raymond Knopp committed
143

144 145
/*! \brief Clock source types */
typedef enum {
146 147
  //! this means the paramter has not been set
  unset=-1,
148 149 150
  //! This tells the underlying hardware to use the internal reference
  internal=0,
  //! This tells the underlying hardware to use the external reference
151 152 153
  external=1,
  //! This tells the underlying hardware to use the gpsdo reference
  gpsdo=2
154 155
} clock_source_t;

156

Rohit Gupta's avatar
Rohit Gupta committed
157
/*! \brief RF frontend parameters set by application */
Raymond Knopp's avatar
 
Raymond Knopp committed
158
typedef struct {
159
  //! Module ID for this configuration
160
  int Mod_id;
Rohit Gupta's avatar
Rohit Gupta committed
161
  //! device log level
162
  int log_level;
163 164
  //! duplexing mode
  duplex_mode_t duplex_mode;
165 166
  //! number of downlink resource blocks
  int num_rb_dl;
167
  //! number of samples per frame
168
  unsigned int  samples_per_frame;
169
  //! the sample rate for both transmit and receive.
Raymond Knopp's avatar
 
Raymond Knopp committed
170
  double sample_rate;
171 172
  //! flag to indicate that the device is doing mmapped DMA transfers
  int mmapped_dma;
173 174
  //! offset in samples between TX and RX paths
  int tx_sample_advance;
175
  //! samples per packet on the fronthaul interface
176
  int samples_per_packet;
177
  //! number of RX channels (=RX antennas)
Raymond Knopp's avatar
 
Raymond Knopp committed
178
  int rx_num_channels;
179
  //! number of TX channels (=TX antennas)
Raymond Knopp's avatar
 
Raymond Knopp committed
180
  int tx_num_channels;
Raymond Knopp's avatar
Raymond Knopp committed
181
  //! \brief RX base addresses for mmapped_dma
182
  int32_t *rxbase[4];
Raymond Knopp's avatar
Raymond Knopp committed
183
  //! \brief TX base addresses for mmapped_dma
184
  int32_t *txbase[4];
185 186
  //! \brief Center frequency in Hz for RX.
  //! index: [0..rx_num_channels[
Raymond Knopp's avatar
 
Raymond Knopp committed
187
  double rx_freq[4];
188 189
  //! \brief Center frequency in Hz for TX.
  //! index: [0..rx_num_channels[ !!! see lte-ue.c:427 FIXME iterates over rx_num_channels
Raymond Knopp's avatar
 
Raymond Knopp committed
190
  double tx_freq[4];
191
  //! \brief memory
192 193
  //! \brief Pointer to Calibration table for RX gains
  rx_gain_calib_table_t *rx_gain_calib_table;
194
  //! mode for rxgain (ExpressMIMO2)
Raymond Knopp's avatar
 
Raymond Knopp committed
195
  rx_gain_t rxg_mode[4];
196
  //! \brief Gain for RX in dB.
197
  //! index: [0..rx_num_channels]
Raymond Knopp's avatar
 
Raymond Knopp committed
198
  double rx_gain[4];
199 200 201
  //! \brief Gain offset (for calibration) in dB
  //! index: [0..rx_num_channels]
  double rx_gain_offset[4];
202
  //! gain for TX in dB
Raymond Knopp's avatar
 
Raymond Knopp committed
203
  double tx_gain[4];
204
  //! RX bandwidth in Hz
Raymond Knopp's avatar
 
Raymond Knopp committed
205
  double rx_bw;
206
  //! TX bandwidth in Hz
Raymond Knopp's avatar
 
Raymond Knopp committed
207
  double tx_bw;
208
  //! clock source
209
  clock_source_t clock_source;
210
  //! timing_source
211
  clock_source_t time_source;
212
  //! Manual SDR IP address
213
  //#if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)
214
  char *sdr_addrs;
215 216
  //! Auto calibration flag
  int autocal[4];
217
  //! rf devices work with x bits iqs when oai have its own iq format
218
  //! the two following parameters are used to convert iqs
219 220
  int iq_txshift;
  int iq_rxrescale;
221 222
  //! Configuration file for LMS7002M
  char *configFilename;
223 224 225 226 227 228 229 230
  //! remote IP/MAC addr for Ethernet interface
  char *remote_addr;
  //! remote port number for Ethernet interface
  unsigned int remote_port;
  //! local IP/MAC addr for Ethernet interface (eNB/BBU, UE)
  char *my_addr;
  //! local port number for Ethernet interface (eNB/BBU, UE)
  unsigned int my_port;
231 232 233
  //! record player configuration, definition in record_player.h
  uint32_t       recplay_mode;
  recplay_conf_t *recplay_conf;
root's avatar
root committed
234 235 236 237 238 239
  //! number of samples per tti
  unsigned int  samples_per_tti;
  //! the sample rate for receive.
  double rx_sample_rate;
  //! the sample rate for transmit.
  double tx_sample_rate;
240 241
  //! check for threequarter sampling rate
  int8_t threequarter_fs;
Raymond Knopp's avatar
 
Raymond Knopp committed
242 243
} openair0_config_t;

244
/*! \brief RF mapping */
245
typedef struct {
Rohit Gupta's avatar
Rohit Gupta committed
246
  //! card id
247
  int card;
Rohit Gupta's avatar
Rohit Gupta committed
248
  //! rf chain id
249 250 251 252
  int chain;
} openair0_rf_map;


253 254
typedef struct {
  char *remote_addr;
255 256 257 258
  //! remote port number for Ethernet interface (control)
  uint16_t remote_portc;
  //! remote port number for Ethernet interface (user)
  uint16_t remote_portd;
259
  //! local IP/MAC addr for Ethernet interface (eNB/RAU, UE)
260
  char *my_addr;
261 262 263 264
  //! local port number (control) for Ethernet interface (eNB/RAU, UE)
  uint16_t  my_portc;
  //! local port number (user) for Ethernet interface (eNB/RAU, UE)
  uint16_t  my_portd;
265
  //! local Ethernet interface (eNB/RAU, UE)
266
  char *local_if_name;
267
  //! transport type preference  (RAW/UDP)
268
  uint8_t transp_preference;
269 270
  //! compression enable (0: No comp/ 1: A-LAW)
  uint8_t if_compress;
271
} eth_params_t;
272

273
typedef struct {
274 275
  //! Tx buffer for if device, keep one per subframe now to allow multithreading
  void *tx[10];
276 277
  //! Tx buffer (PRACH) for if device
  void *tx_prach;
278 279 280 281
  //! Rx buffer for if device
  void *rx;
} if_buffer_t;

WANG Tsu-Han's avatar
WANG Tsu-Han committed
282 283
typedef struct {
  openair0_timestamp timestamp;
WANG Tsu-Han's avatar
WANG Tsu-Han committed
284
  void *buff[MAX_WRITE_THREAD_BUFFER_SIZE];// buffer to be write;
WANG Tsu-Han's avatar
WANG Tsu-Han committed
285 286 287 288
  int nsamps;
  int cc;
  signed char first_packet;
  signed char last_packet;
WANG Tsu-Han's avatar
WANG Tsu-Han committed
289
  int flags_msb;
WANG Tsu-Han's avatar
WANG Tsu-Han committed
290 291 292
} openair0_write_package_t;

typedef struct {
WANG Tsu-Han's avatar
WANG Tsu-Han committed
293
  openair0_write_package_t write_package[MAX_WRITE_THREAD_PACKAGE];
WANG Tsu-Han's avatar
WANG Tsu-Han committed
294 295 296
  int start;
  int end;
  /// \internal This variable is protected by \ref mutex_write
WANG Tsu-Han's avatar
WANG Tsu-Han committed
297
  int count_write;
WANG Tsu-Han's avatar
WANG Tsu-Han committed
298 299 300 301 302 303 304 305 306 307
  /// pthread struct for trx write thread
  pthread_t pthread_write;
  /// pthread attributes for trx write thread
  pthread_attr_t attr_write;
  /// condition varible for trx write thread
  pthread_cond_t cond_write;
  /// mutex for trx write thread
  pthread_mutex_t mutex_write;
} openair0_thread_t;

308
/*!\brief structure holds the parameters to configure USRP devices */
Raymond Knopp's avatar
 
Raymond Knopp committed
309
struct openair0_device_t {
WANG Tsu-Han's avatar
WANG Tsu-Han committed
310 311 312
  /*!tx write thread*/
  openair0_thread_t write_thread;

313
  /*!brief Module ID of this device */
314
  int Mod_id;
315 316 317

  /*!brief Component Carrier ID of this device */
  int CC_id;
318

319
  /*!brief Type of this device */
320 321
  dev_type_t type;

322
  /*!brief Transport protocol type that the device supports (in case I/Q samples need to be transported) */
323 324
  transport_type_t transp_type;

325
  /*!brief Type of the device's host (RAU/RRU) */
326
  host_type_t host_type;
327

Aikaterini's avatar
Aikaterini committed
328
  /* !brief RF frontend parameters set by application */
329
  openair0_config_t *openair0_cfg;
330

331 332
  /* !brief ETH params set by application */
  eth_params_t *eth_params;
333 334
  //! record player data, definition in record_player.h
  recplay_state_t *recplay_state;
335 336 337 338
  /* !brief Indicates if device already initialized */
  int is_init;


339
  /*!brief Can be used by driver to hold internal structure*/
Raymond Knopp's avatar
 
Raymond Knopp committed
340 341 342 343
  void *priv;

  /* Functions API, which are called by the application*/

344 345 346
  /*! \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
  */
Raymond Knopp's avatar
 
Raymond Knopp committed
347 348
  int (*trx_start_func)(openair0_device *device);

349 350 351 352 353 354 355
 /*! \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);

356
  /*! \brief Called to send a request message between RAU-RRU on control port
357
      @param device pointer to the device structure specific to the RF hardware target
358
      @param msg pointer to the message structure passed between RAU-RRU
359 360
      @param msg_len length of the message
  */
361
  int (*trx_ctlsend_func)(openair0_device *device, void *msg, ssize_t msg_len);
362

363
  /*! \brief Called to receive a reply  message between RAU-RRU on control port
364
      @param device pointer to the device structure specific to the RF hardware target
365
      @param msg pointer to the message structure passed between RAU-RRU
366 367
      @param msg_len length of the message
  */
368
  int (*trx_ctlrecv_func)(openair0_device *device, void *msg, ssize_t msg_len);
369

370 371
  /*! \brief Called to send samples to the RF target
      @param device pointer to the device structure specific to the RF hardware target
372
      @param timestamp The timestamp at whicch the first sample MUST be sent
373
      @param buff Buffer which holds the samples (2 dimensional)
374
      @param nsamps number of samples to be sent
375
      @param number of antennas 
376
      @param flags flags must be set to TRUE if timestamp parameter needs to be applied
377
  */
378
  int (*trx_write_func)(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int antenna_id, int flags);
Raymond Knopp's avatar
 
Raymond Knopp committed
379

380 381 382 383 384 385 386 387 388 389
  /*! \brief Called to send samples to the RF target
      @param device pointer to the device structure specific to the RF hardware target
      @param timestamp The timestamp at whicch the first sample MUST be sent
      @param buff Buffer which holds the samples (1 dimensional)
      @param nsamps number of samples to be sent
      @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
  */
  int (*trx_write_func2)(openair0_device *device, openair0_timestamp timestamp, void *buff, int nsamps,int antenna_id, int flags);

390 391
  /*! \brief Receive samples from hardware.
   * Read \ref nsamps samples from each channel to buffers. buff[0] is the array for
Raymond Knopp's avatar
 
Raymond Knopp committed
392 393
   * the first channel. *ptimestamp is the time at which the first sample
   * was received.
394 395
   * \param device the hardware to use
   * \param[out] ptimestamp the time at which the first sample was received.
Rohit Gupta's avatar
Rohit Gupta committed
396
   * \param[out] buff An array of pointers to buffers for received samples. The buffers must be large enough to hold the number of samples \ref nsamps.
397
   * \param nsamps Number of samples. One sample is 2 byte I + 2 byte Q => 4 byte.
398
   * \param num_antennas number of antennas from which to receive samples
399 400
   * \returns the number of sample read
   */
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415

  int (*trx_read_func)(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps,int num_antennas);

  /*! \brief Receive samples from hardware, this version provides a single antenna at a time and returns.
   * Read \ref nsamps samples from each channel to buffers. buff[0] is the array for
   * the first channel. *ptimestamp is the time at which the first sample
   * was received.
   * \param device the hardware to use
   * \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 nsamps Number of samples. One sample is 2 byte I + 2 byte Q => 4 byte.
   * \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, void *buff, int nsamps,int *antenna_id);
416

417
  /*! \brief print the device statistics
418 419 420 421 422
   * \param device the hardware to use
   * \returns  0 on success
   */
  int (*trx_get_stats_func)(openair0_device *device);

423
  /*! \brief Reset device statistics
424
   * \param device the hardware to use
425
   * \returns 0 in success
426 427
   */
  int (*trx_reset_stats_func)(openair0_device *device);
Raymond Knopp's avatar
 
Raymond Knopp committed
428

429
  /*! \brief Terminate operation of the transceiver -- free all associated resources
Rohit Gupta's avatar
Rohit Gupta committed
430 431
   * \param device the hardware to use
   */
Raymond Knopp's avatar
 
Raymond Knopp committed
432
  void (*trx_end_func)(openair0_device *device);
433

434
  /*! \brief Stop operation of the transceiver
Rohit Gupta's avatar
Rohit Gupta committed
435
   */
436
  int (*trx_stop_func)(openair0_device *device);
437 438 439

  /* Functions API related to UE*/

440
  /*! \brief Set RX feaquencies
Rohit Gupta's avatar
Rohit Gupta committed
441 442
   * \param device the hardware to use
   * \param openair0_cfg RF frontend parameters set by application
443 444
   * \param exmimo_dump_config  dump EXMIMO configuration
   * \returns 0 in success
445
   */
446 447
  int (*trx_set_freq_func)(openair0_device *device, openair0_config_t *openair0_cfg,int exmimo_dump_config);

448
  /*! \brief Set gains
Rohit Gupta's avatar
Rohit Gupta committed
449 450
   * \param device the hardware to use
   * \param openair0_cfg RF frontend parameters set by application
451
   * \returns 0 in success
452
   */
453
  int (*trx_set_gains_func)(openair0_device *device, openair0_config_t *openair0_cfg);
454

455 456 457 458
  /*! \brief RRU Configuration callback
   * \param idx RU index
   * \param arg pointer to capabilities or configuration
   */
459
  void (*configure_rru)(int idx, void *arg);
460 461 462 463 464 465

/*! \brief Pointer to generic RRU private information
   */

  void *thirdparty_priv;

466 467 468 469
  /*! \brief Callback for Third-party RRU Initialization routine
     \param device the hardware configuration to use
   */
  int (*thirdparty_init)(openair0_device *device);
470 471 472 473
  /*! \brief Callback for Third-party RRU Cleanup routine
     \param device the hardware configuration to use
   */
  int (*thirdparty_cleanup)(openair0_device *device);
474 475 476 477 478 479

  /*! \brief Callback for Third-party start streaming routine
     \param device the hardware configuration to use
   */
  int (*thirdparty_startstreaming)(openair0_device *device);

WANG Tsu-Han's avatar
WANG Tsu-Han committed
480 481 482 483 484
  /*! \brief RRU Configuration callback
   * \param idx RU index
   * \param arg pointer to capabilities or configuration
   */
  int (*trx_write_init)(openair0_device *device);
485 486 487 488 489
  /* \brief Get internal parameter
   * \param id parameter to get
   * \return a pointer to the parameter
   */
  void *(*get_internal_parameter)(char *id);
Raymond Knopp's avatar
 
Raymond Knopp committed
490 491
};

492
/* type of device init function, implemented in shared lib */
493 494
typedef int(*oai_device_initfunc_t)(openair0_device *device, openair0_config_t *openair0_cfg);
/* type of transport init function, implemented in shared lib */
495
typedef int(*oai_transport_initfunc_t)(openair0_device *device, openair0_config_t *openair0_cfg, eth_params_t *eth_params);
Laurent Thomas's avatar
Laurent Thomas committed
496 497
#define UE_MAGICDL 0xA5A5A5A5A5A5A5A5  // UE DL FDD record
#define UE_MAGICUL 0x5A5A5A5A5A5A5A5A  // UE UL FDD record
498

Laurent Thomas's avatar
Laurent Thomas committed
499 500
#define ENB_MAGICDL 0xB5B5B5B5B5B5B5B5  // eNB DL FDD record
#define ENB_MAGICUL 0x5B5B5B5B5B5B5B5B  // eNB UL FDD record
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515

#define OPTION_LZ4  0x00000001          // LZ4 compression (option_value is set to compressed size)


typedef struct {
  uint64_t magic;          // Magic value (see defines above)
  uint32_t size;           // Number of samples per antenna to follow this header
  uint32_t nbAnt;          // Total number of antennas following this header
  // Samples per antenna follow this header,
  // i.e. nbAnt = 2 => this header+samples_antenna_0+samples_antenna_1
  // data following this header in bytes is nbAnt*size*sizeof(sample_t)
  uint64_t timestamp;      // Timestamp value of first sample
  uint32_t option_value;   // Option value
  uint32_t option_flag;    // Option flag
} samplesBlockHeader_t;
Raymond Knopp's avatar
 
Raymond Knopp committed
516 517 518 519

#ifdef __cplusplus
extern "C"
{
520 521
#endif

522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538

#define  DEVICE_SECTION   "device"
#define  CONFIG_HLP_DEVICE  "Identifies the oai device (the interface to RF) to use, the shared lib \"lib_<name>.so\" will be loaded"

#define  CONFIG_DEVICEOPT_NAME "name"

/* inclusion for device configuration */
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/*                                            config parameters for oai device                                                                                               */
/*   optname                     helpstr                paramflags                      XXXptr                  defXXXval                            type           numelt   */
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
#define DEVICE_PARAMS_DESC {\
    { CONFIG_DEVICEOPT_NAME,      CONFIG_HLP_DEVICE,          0,                strptr:&devname,                 defstrval:NULL,         TYPE_STRING,     0}\
}



539 540
/*! \brief get device name from device type */
char *get_devname(int devtype);
541 542 543 544
/*! \brief Initialize openair RF target. It returns 0 if OK */
int openair0_device_load(openair0_device *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);
545

546

547 548 549 550 551 552 553 554 555 556 557
/*! \brief Get current timestamp of USRP
 * \param device the hardware to use
 */
openair0_timestamp get_usrp_time(openair0_device *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);
558 559 560 561 562
/*! \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);

Rohit Gupta's avatar
Rohit Gupta committed
563

564 565
#include <unistd.h>
#ifndef gettid
laurent's avatar
laurent committed
566
#define gettid() syscall(__NR_gettid)
567
#endif
568
/*@}*/
569

570

571

572
#ifdef __cplusplus
Raymond Knopp's avatar
 
Raymond Knopp committed
573 574 575
}
#endif

Raymond Knopp's avatar
 
Raymond Knopp committed
576
#endif // COMMON_LIB_H
577