Front Haul Interface Library update to third seed code contribution
[o-du/phy.git] / fhi_lib / lib / api / xran_fh_o_du.h
index f1ba5e7..8d264e2 100644 (file)
-/******************************************************************************\r
-*\r
-*   Copyright (c) 2019 Intel.\r
-*\r
-*   Licensed under the Apache License, Version 2.0 (the "License");\r
-*   you may not use this file except in compliance with the License.\r
-*   You may obtain a copy of the License at\r
-*\r
-*       http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-*   Unless required by applicable law or agreed to in writing, software\r
-*   distributed under the License is distributed on an "AS IS" BASIS,\r
-*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-*   See the License for the specific language governing permissions and\r
-*   limitations under the License.\r
-*\r
-*******************************************************************************/\r
-\r
-/**\r
- * @brief This file provides public interface to xRAN Front Haul layer implementation as defined in the\r
- *      ORAN-WG4.CUS.0-v01.00 spec. Implementation specific to\r
- *      Lower Layer Split Central Unit (O-DU): a logical node that includes the eNB/gNB functions as\r
- *      listed in section 2.1 split option 7-2x, excepting those functions allocated exclusively to the O-RU.\r
- *      The O-DU controls the operation of O-RUs for 5G NR Radio Access technology\r
- *\r
- * @file xran_fh_o_du.h\r
- * @ingroup group_lte_source_xran\r
- * @author Intel Corporation\r
- *\r
- **/\r
-\r
-#ifndef _XRAN_FH_O_DU_H_\r
-#define _XRAN_FH_O_DU_H_\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <stdint.h>\r
-#include <inttypes.h>\r
-#include <sys/types.h>\r
-#include <sys/queue.h>\r
-#include <netinet/in.h>\r
-#include <setjmp.h>\r
-#include <stdarg.h>\r
-#include <ctype.h>\r
-#include <errno.h>\r
-#include <getopt.h>\r
-#include <unistd.h>\r
-\r
-#define XRAN_STATUS_SUCCESS (0)\r
-/**<\r
- *  @ingroup xran\r
- *   Success status value. */\r
-#define XRAN_STATUS_FAIL (-1)\r
-/**<\r
- *  @ingroup xran\r
- *   Fail status value. */\r
-\r
-#define XRAN_STATUS_RETRY (-2)\r
-/**<\r
- *  @ingroup xran\r
- *  Retry status value. */\r
-\r
-#define XRAN_STATUS_RESOURCE (-3)\r
-/**<\r
- *  @ingroup xran\r
- *  The resource that has been requested is unavailable. Refer\r
- *  to relevant sections of the API for specifics on what the suggested\r
- *  course of action is. */\r
-\r
-#define XRAN_STATUS_INVALID_PARAM (-4)\r
-/**<\r
- *  @ingroup xran\r
- *  Invalid parameter has been passed in. */\r
-#define XRAN_STATUS_FATAL (-5)\r
-/**<\r
- *  @ingroup xran\r
- *  A serious error has occurred. Recommended course of action\r
- *  is to shutdown and restart the component. */\r
-\r
-#define XRAN_STATUS_UNSUPPORTED (-6)\r
-/**<\r
- *  @ingroup xran\r
- *  The function is not supported, at least not with the specific\r
- *  parameters supplied.  This may be because a particular\r
- *  capability is not supported by the current implementation. */\r
-\r
-#define XRAN_STATUS_INVALID_PACKET (-7)\r
-/**<\r
- *  @ingroup xran\r
- *  Recevied packet does not have correct format. */\r
-\r
-/** Macro to calculate TTI number from symbol index used by timing thread */\r
-#define XranGetTtiNum(symIdx, numSymPerTti) (((uint32_t)symIdx / (uint32_t)numSymPerTti))\r
-/** Macro to calculate Symbol number for given slot from symbol index  */\r
-#define XranGetSymNum(symIdx, numSymPerTti) (((uint32_t)symIdx % (uint32_t)numSymPerTti))\r
-/** Macro to calculate Frame number for given tti */\r
-#define XranGetFrameNum(tti,SFNatSecStart,numSubFramePerSystemFrame, numSlotPerSubFrame)  ((((uint32_t)tti / ((uint32_t)numSubFramePerSystemFrame * (uint32_t)numSlotPerSubFrame)) + SFNatSecStart) & 0x3FF)\r
-/** Macro to calculate Subframe number for given tti */\r
-#define XranGetSubFrameNum(tti, numSlotPerSubFrame, numSubFramePerSystemFrame) (((uint32_t)tti/(uint32_t)numSlotPerSubFrame) % (uint32_t)numSubFramePerSystemFrame)\r
-/** Macro to calculate Slot number */\r
-#define XranGetSlotNum(tti, numSlotPerSfn) ((uint32_t)tti % ((uint32_t)numSlotPerSfn))\r
-\r
-#define XRAN_PORTS_NUM               (1)    /**< number of XRAN ports (aka O-RU devices) supported */\r
-#define XRAN_N_FE_BUF_LEN            (40)   /**< Number of TTIs (slots) */\r
-#define XRAN_MAX_SECTOR_NR           (12)   /**< Max sectors per XRAN port */\r
-#define XRAN_MAX_ANTENNA_NR          (16)    /**< Max number of extended Antenna-Carriers:\r
-                                                a data flow for a single antenna (or spatial stream) for a single carrier in a single sector */\r
-\r
-/* see 10.2    Hierarchy of Radiation Structure in O-RU (assume TX and RX pannel are the same dimensions)*/\r
-#define XRAN_MAX_PANEL_NR            (1)   /**< Max number of Panels supported per O-RU */\r
-#define XRAN_MAX_TRX_ANTENNA_ARRAY   (1)   /**< Max number of TX and RX arrays per panel in O-RU */\r
-#define XRAN_MAX_ANT_ARRAY_ELM_NR    (64)  /**< Maximum number of Antenna Array Elemets in Antenna Array in the O-RU */\r
-\r
-\r
-\r
-#define XRAN_NUM_OF_SYMBOL_PER_SLOT  (14) /**< Number of symbols per slot */\r
-#define XRAN_MAX_NUM_OF_SRS_SYMBOL_PER_SLOT  XRAN_NUM_OF_SYMBOL_PER_SLOT /**< Max Number of SRS symbols per slot */\r
-#define XRAN_MAX_TDD_PERIODICITY     (80) /**< Max TDD pattern period */\r
-#define XRAN_MAX_CELLS_PER_PORT      (XRAN_MAX_SECTOR_NR) /**< Max cells mapped to XRAN port */\r
-#define XRAN_COMPONENT_CARRIERS_MAX  (XRAN_MAX_SECTOR_NR) /**< number of CCs */\r
-#define XRAN_NUM_OF_ANT_RADIO        (XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR) /**< Max Number of Antennas supported for all CC on single XRAN port */\r
-#define XRAN_MAX_PRBS                (275) /**< Max of PRBs per CC per antanna for 5G NR */\r
-\r
-#define XRAN_MAX_SECTIONS_PER_SYM    (16)  /**< Max number of different sections in single symbol (section is equal to RB allocation for UE) */\r
-\r
-#define XRAN_MAX_PKT_BURST (448+4) /**< 4x14x8 symbols per ms */\r
-#define XRAN_N_MAX_BUFFER_SEGMENT XRAN_MAX_PKT_BURST /**< Max number of segments per ms */\r
-\r
-#define XRAN_STRICT_PARM_CHECK               (1) /**< enable parameter check for C-plane */\r
-\r
-/* Slot type definition */\r
-#define XRAN_SLOT_TYPE_INVALID               (0) /**< invalid slot type */\r
-#define XRAN_SLOT_TYPE_DL                    (1) /**< DL slot */\r
-#define XRAN_SLOT_TYPE_UL                    (2) /**< UL slot */\r
-#define XRAN_SLOT_TYPE_SP                    (3) /**< Special slot */\r
-#define XRAN_SLOT_TYPE_FDD                   (4) /**< FDD slot */\r
-#define XRAN_SLOT_TYPE_LAST                  (5) /**< MAX slot */\r
-\r
-/* symbol type definition */\r
-#define XRAN_SYMBOL_TYPE_DL                  (0) /**< DL symbol  */\r
-#define XRAN_SYMBOL_TYPE_UL                  (1) /**< UL symbol  */\r
-#define XRAN_SYMBOL_TYPE_GUARD               (2) /**< GUARD symbol */\r
-#define XRAN_SYMBOL_TYPE_FDD                 (3) /**< FDD symbol */\r
-\r
-#define XRAN_NUM_OF_SLOT_IN_TDD_LOOP         (80)/**< MAX number of slot for TDD repetition */\r
-\r
-//#define _XRAN_DEBUG   /**< Enable debug log */\r
-//#define _XRAN_VERBOSE /**< Enable verbose log */\r
-\r
-#ifdef _XRAN_DEBUG\r
-    #define xran_log_dbg(fmt, ...)          \\r
-        fprintf(stderr,                     \\r
-            "DEBUG: %s(%d): " fmt "\n",     \\r
-            __FILE__,                       \\r
-            __LINE__, ##__VA_ARGS__)\r
-#else\r
-    #define xran_log_dbg(fmt, ...)\r
-#endif\r
-\r
-#if defined(_XRAN_DEBUG) || defined(_XRAN_VERBOSE)\r
-    #define xran_log_wrn(fmt, ...)          \\r
-        fprintf(                            \\r
-            stderr,                         \\r
-            "WARNING: %s(%d): " fmt "\n",   \\r
-            __FILE__,                       \\r
-            __LINE__, ##__VA_ARGS__)\r
-#else\r
-    #define xran_log_dbg(fmt, ...)\r
-    #define xran_log_wrn(fmt, ...)\r
-#endif\r
-\r
-#define xran_log_err(fmt, ...)          \\r
-    fprintf(stderr,                     \\r
-        "ERROR: %s(%d): " fmt "\n",     \\r
-        __FILE__,                       \\r
-        __LINE__, ##__VA_ARGS__)\r
-\r
-enum XranFrameDuplexType\r
-{\r
-    XRAN_FDD = 0, XRAN_TDD\r
-};\r
-\r
-enum xran_if_state\r
-{\r
-    XRAN_INIT = 0,\r
-    XRAN_RUNNING,\r
-    XRAN_STOPPED\r
-};\r
-\r
-/**\r
- ******************************************************************************\r
- * @ingroup xran\r
- *\r
- * @description\r
- *      Compression Method 6.3.3.13, Table 6-43\r
- *****************************************************************************/\r
-enum xran_compression_method {\r
-    XRAN_COMPMETHOD_NONE        = 0,\r
-    XRAN_COMPMETHOD_BLKFLOAT    = 1,\r
-    XRAN_COMPMETHOD_BLKSCALE    = 2,\r
-    XRAN_COMPMETHOD_ULAW        = 3,\r
-    XRAN_COMPMETHOD_MODULATION  = 4,\r
-    XRAN_COMPMETHOD_MAX\r
-};\r
-\r
-/**\r
- ******************************************************************************\r
- * @ingroup xran\r
- *\r
- * @description\r
- *      Callback function type for symbol packet enum\r
- *****************************************************************************/\r
-enum callback_to_phy_id\r
-{\r
-    XRAN_CB_TTI = 0, /**< callback on TTI boundary */\r
-    XRAN_CB_HALF_SLOT_RX =1, /**< callback on half slot (sym 7) packet arrival*/\r
-    XRAN_CB_FULL_SLOT_RX =2, /**< callback on full slot (sym 14) packet arrival */\r
-    XRAN_CB_MAX /**< max number of callbacks */\r
-};\r
-\r
-/**  Beamforming type, enumerated as "frequency", "time" or "hybrid"\r
-     section 10.4.2    Weight-based dynamic beamforming */\r
-enum xran_weight_based_beamforming_type {\r
-    XRAN_BF_T_FREQUENCY = 0,\r
-    XRAN_BF_T_TIME      = 1,\r
-    XRAN_BF_T_HYBRID    = 2,\r
-    XRAN_BF_T_MAX\r
-};\r
-\r
-typedef int32_t xran_status_t; /**< Xran status return value */\r
-\r
-/** callback function type for Symbol packet */\r
-typedef void (*xran_callback_sym_fn)(void*);\r
-\r
-/** Callback function type for TTI event */\r
-typedef int (*xran_fh_tti_callback_fn)(void*);\r
-\r
-/** Callback function type packet arrival from transport layer (ETH or IP) */\r
-typedef void (*xran_transport_callback_fn)(void*, xran_status_t);\r
-\r
-/** Callback functions to poll BBdev encoder */\r
-typedef int16_t (*phy_encoder_poll_fn)(void);\r
-\r
-/** Callback functions to poll BBdev secoder */\r
-typedef int16_t (*phy_decoder_poll_fn)(void);\r
-\r
-/** XRAN port enum */\r
-enum xran_vf_ports\r
-{\r
-    XRAN_UP_VF = 0, /**< port type for U-plane */\r
-    XRAN_CP_VF,     /**< port type for C-plane */\r
-    XRAN_VF_MAX\r
-};\r
-\r
-/** XRAN category enum */\r
-enum xran_category\r
-{\r
-    XRAN_CATEGORY_A = 0,\r
-    XRAN_CATEGORY_B = 1,\r
-    XRAN_CATEGORY_MAX\r
-};\r
-\r
-/** type of beamforming */\r
-enum xran_beamforming_type\r
-{\r
-    XRAN_BEAM_ID_BASED = 0, /**< beam index based */\r
-    XRAN_BEAM_WEIGHT,       /**< beam forming weights */\r
-    XRAN_BEAM_ATTRIBUTE,    /**< beam index based */\r
-};\r
-\r
-/** state of bbdev with xran */\r
-enum xran_bbdev_init\r
-{\r
-    XRAN_BBDEV_NOT_USED    = -1, /**< BBDEV is disabled */\r
-    XRAN_BBDEV_MODE_HW_OFF = 0,  /**< BBDEV is enabled for SW sim mode */\r
-    XRAN_BBDEV_MODE_HW_ON  = 1,  /**< BBDEV is enable for HW */\r
-    XRAN_BBDEV_MODE_MAX\r
-};\r
-\r
-/** callback return information */\r
-struct xran_cb_tag {\r
-    uint16_t cellId;\r
-    uint32_t symbol;\r
-    uint32_t slotiId;\r
-};\r
-\r
-/** DPDK IO configuration for XRAN layer */\r
-struct xran_io_cfg {\r
-    uint8_t id; /**< should be (0) for O-DU or (1) O-RU (debug) */\r
-    char *dpdk_dev[XRAN_VF_MAX]; /**< VFs devices  */\r
-    char *bbdev_dev[1];     /**< BBDev dev name */\r
-    int32_t bbdev_mode;     /**< DPDK for BBDev */\r
-    int32_t core;           /**< reservd */\r
-    int32_t system_core;    /**< reservd */\r
-    int32_t pkt_proc_core;  /**< reservd */\r
-    int32_t pkt_aux_core;   /**< reservd */\r
-    int32_t timing_core;    /**< core used by xRAN */\r
-    int32_t port[XRAN_VF_MAX];  /**< VFs ports */\r
-};\r
-\r
-/** XRAN spec section 3.1.3.1.6 ecpriRtcid / ecpriPcid define */\r
-struct xran_eaxcid_config {\r
-    uint16_t mask_cuPortId;     /**< Mask CU PortId */\r
-    uint16_t mask_bandSectorId; /**< Mask Band */\r
-    uint16_t mask_ccId;         /**< Mask CC */\r
-    uint16_t mask_ruPortId;     /**< Mask RU Port ID */\r
-\r
-    uint8_t bit_cuPortId;       /**< bandsectorId + ccId + ruportId */\r
-    uint8_t bit_bandSectorId;   /**< ccId + ruPortId */\r
-    uint8_t bit_ccId;           /**< ruportId */\r
-    uint8_t bit_ruPortId;       /**< 0 */\r
-};\r
-\r
-/**\r
-* XRAN Front haul interface initialization settings\r
-*/\r
-struct xran_fh_init {\r
-    struct xran_io_cfg io_cfg;/**< DPDK IO for XRAN */\r
-    struct xran_eaxcid_config eAxCId_conf; /**< config of ecpriRtcid/ecpriPcid */\r
-\r
-    uint32_t dpdkBasebandFecMode; /**< DPDK Baseband FEC device mode (0-SW, 1-HW) */\r
-    char *dpdkBasebandDevice;     /**< DPDK Baseband device address */\r
-    char *filePrefix;             /**< DPDK prefix */\r
-\r
-    uint32_t mtu; /**< maximum transmission unit (MTU) is the size of the largest protocol data unit (PDU) that can be communicated in a single\r
-                       xRAN network layer transaction. supported 1500 bytes and 9600 bytes (Jumbo Frame) */\r
-    int8_t *p_o_du_addr;  /**<  O-DU Ethernet Mac Address */\r
-    int8_t *p_o_ru_addr;  /**<  O-RU Ethernet Mac Address */\r
-\r
-    uint16_t totalBfWeights;/**< The total number of beamforming weights on RU for extensions */\r
-\r
-    uint16_t Tadv_cp_dl;    /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T2a_min_cp_dl; /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T2a_max_cp_dl; /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T2a_min_cp_ul; /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T2a_max_cp_ul; /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T2a_min_up;    /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T2a_max_up;    /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t Ta3_min;       /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t Ta3_max;       /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T1a_min_cp_dl; /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T1a_max_cp_dl; /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T1a_min_cp_ul; /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T1a_max_cp_ul; /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T1a_min_up;    /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t T1a_max_up;    /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t Ta4_min;       /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-    uint16_t Ta4_max;       /**< Table 2 7 : xRAN Delay Management Model Parameters */\r
-\r
-    uint8_t enableCP;       /**<  enable C-plane */\r
-    uint8_t prachEnable;    /**<  enable PRACH   */\r
-    uint8_t srsEnable;      /**<  enable SRS (Cat B specific) */\r
-    uint8_t cp_vlan_tag;    /**<  C-plane vlan tag */\r
-    uint8_t up_vlan_tag;    /**<  U-plane vlan tag */\r
-    int32_t debugStop;      /**<  enable auto stop */\r
-    int32_t debugStopCount;      /**<  enable auto stop after number of Tx packets */\r
-    int32_t DynamicSectionEna; /**<  enable dynamic C-Plane section allocation */\r
-    int32_t GPS_Alpha;  // refer to alpha as defined in section 9.7.2 of ORAN spec. this value should be alpha*(1/1.2288ns), range 0 - 1e7 (ns)\r
-    int32_t GPS_Beta;   //beta value as defined in section 9.7.2 of ORAN spec. range -32767 ~ +32767\r
-};\r
-\r
-/** Beamforming waights for single stream for each PRBs  given number of Antenna elements */\r
-struct xran_cp_bf_weight{\r
-    int16_t nAntElmTRx;        /**< num TRX for this allocation */\r
-    int8_t*  p_ext_section;    /**< pointer to form extType */\r
-    int16_t  ext_section_sz;   /**< extType section size */\r
-};\r
-struct xran_cp_bf_attribute{\r
-    int16_t weight[4];\r
-};\r
-struct xran_cp_bf_precoding{\r
-    int16_t weight[4];\r
-};\r
-\r
-/** section descriptor for given number of PRBs used on U-plane packet creation */\r
-struct xran_section_desc {\r
-    uint16_t section_id; /**< section id used for this element */\r
-\r
-    int16_t iq_buffer_offset;    /**< Offset in bytes for the content of IQs with in main symb buffer */\r
-    int16_t iq_buffer_len;       /**< Length in bytes for the content of IQs with in main symb buffer */\r
-\r
-    uint8_t *pData;      /**< optional pointer to data buffer */\r
-    void    *pCtrl;      /**< optional poitner to mbuf */\r
-};\r
-\r
-/** PRB element structure */\r
-struct xran_prb_elm {\r
-    int16_t nRBStart;    /**< start RB of RB allocation */\r
-    int16_t nRBSize;     /**< number of RBs used */\r
-    int16_t nStartSymb;  /**< start symbol ID */\r
-    int16_t numSymb;     /**< number of symbols */\r
-    int16_t nBeamIndex;  /**< beam index for given PRB */\r
-    int16_t bf_weight_update; /** need to update beam weights or not */\r
-    int16_t compMethod;  /**< compression index for given PRB */\r
-    int16_t iqWidth;     /**< compression bit width for given PRB */\r
-    int16_t BeamFormingType; /**< index based, weights based or attribute based beam forming*/\r
-\r
-    struct xran_section_desc * p_sec_desc[XRAN_NUM_OF_SYMBOL_PER_SLOT]; /**< section desctiptors to U-plane data given RBs */\r
-    struct xran_cp_bf_weight   bf_weight; /**< beam forming information relevant for given RBs */\r
-\r
-    union {\r
-        struct xran_cp_bf_attribute bf_attribute;\r
-        struct xran_cp_bf_precoding bf_precoding;\r
-    };\r
-};\r
-\r
-/** PRB map structure */\r
-struct xran_prb_map {\r
-    uint8_t   dir;        /**< DL or UL direction */\r
-    uint8_t   xran_port;  /**< xran id of given RU [0-(XRAN_PORTS_NUM-1)] */\r
-    uint16_t  band_id;    /**< xran band id */\r
-    uint16_t  cc_id;      /**< componnent carrier id [0 - (XRAN_MAX_SECTOR_NR-1)] */\r
-    uint16_t  ru_port_id; /**< RU device antenna port id [0 - (XRAN_MAX_ANTENNA_NR-1) */\r
-    uint16_t  tti_id;     /**< xRAN slot id [0 - (max tti-1)] */\r
-    uint8_t   start_sym_id;     /**< start symbol Id [0-13] */\r
-    uint32_t  nPrbElm;    /**< total number of PRB elements for given map [0- (XRAN_MAX_PRBS-1)] */\r
-    struct xran_prb_elm prbMap[XRAN_MAX_PRBS];\r
-\r
-\r
-};\r
-\r
-/* PRACH config required for XRAN based FH */\r
-struct xran_prach_config\r
-{\r
-    /* PRACH config*/\r
-    uint8_t      nPrachConfIdx;  /**< PRACH Configuration Index*/\r
-    uint8_t      nPrachSubcSpacing;\r
-    /**< PRACH Sub-carrier spacing\r
-    Value:0->1\r
-    For below 6GHz the values indicate 15kHz or 30kHz\r
-    For above 6GHz the values indicate 60kHz or 120kHz*/\r
-    uint8_t      nPrachZeroCorrConf; /**< PRACH zeroCorrelationZoneConfig */\r
-    uint8_t      nPrachRestrictSet;  /**< PRACH restrictedSetConfig */\r
-    uint16_t     nPrachRootSeqIdx; /**< PRACH Root Sequence Index */\r
-    uint16_t     nPrachFreqStart;  /**< PRACH prach-frequency-start  */\r
-    int32_t      nPrachFreqOffset; /**< PRACH prach-frequency-offset */\r
-    uint8_t      nPrachFilterIdx;  /**< PRACH Filter index */\r
-};\r
-\r
-/**< SRS configuration required for XRAN based FH */\r
-struct xran_srs_config {\r
-    uint16_t   symbMask;    /**< symbols used for SRS with in U/S slot [bits 0-13] */\r
-    uint8_t    eAxC_offset; /**< starting value of eAxC for SRS packets */\r
-};\r
-\r
-/** XRAN slot configuration */\r
-struct xran_slot_config {\r
-    uint8_t nSymbolType[XRAN_NUM_OF_SYMBOL_PER_SLOT]; /**< Defines the Symbol type for all 14 symbols in a slot. 0: DL, 1: UL, 2: Guard */\r
-    uint8_t reserved[2];\r
-};\r
-\r
-/** XRAN front haul frame config */\r
-struct xran_frame_config {\r
-    uint8_t      nFrameDuplexType; /**< Frame Duplex type:  0 -> FDD, 1 -> TDD */\r
-    uint8_t      nNumerology; /**< Numerology, determine sub carrier spacing, Value: 0->4\r
-                                   0: 15khz,  1: 30khz,  2: 60khz\r
-                                   3: 120khz, 4: 240khz */\r
-    uint8_t      nTddPeriod;  /**< TDD period */\r
-    struct xran_slot_config sSlotConfig[XRAN_MAX_TDD_PERIODICITY];\r
-    /**< TDD Slot configuration - If nFrameDuplexType = TDD(1), then this config defines the slot config type for each slot.*/\r
-    /* The number of slots need to be equal to nTddPeriod */\r
-};\r
-\r
-/** XRAN-PHY interface byte order */\r
-enum xran_input_byte_order {\r
-    XRAN_NE_BE_BYTE_ORDER = 0, /**< Network byte order (Big endian), xRAN lib doesn't do swap */\r
-    XRAN_CPU_LE_BYTE_ORDER     /**< CPU byte order (Little endian), xRAN lib does do swap */\r
-};\r
-\r
-/** XRAN-PHY interface I and Q order */\r
-enum xran_input_i_q_order {\r
-    XRAN_I_Q_ORDER = 0,  /**< I , Q */\r
-    XRAN_Q_I_ORDER       /**< Q , I */\r
-};\r
-\r
-/** XRAN front haul IQ compression settings */\r
-struct xran_ru_config {\r
-    enum xran_category xranCat;   /**< mode: Catergory A or Category B */\r
-\r
-    uint8_t iqWidth;        /**< IQ bit width */\r
-    uint8_t compMeth;       /**< Compression method */\r
-    uint8_t fftSize;        /**< FFT Size */\r
-    enum xran_input_byte_order byteOrder; /**< Order of bytes in int16_t in buffer. Big or little endian */\r
-    enum xran_input_i_q_order  iqOrder;   /**< order of IQs in the buffer */\r
-    uint16_t xran_max_frame; /**< max frame number supported */\r
-};\r
-\r
-/**\r
- * @ingroup xran\r
- * XRAN front haul general configuration */\r
-struct xran_fh_config {\r
-    uint32_t            dpdk_port; /**< DPDK port number used for FH */\r
-    uint32_t            sector_id; /**< Band sector ID for FH */\r
-    uint32_t            nCC;       /**< number of Component carriers supported on FH */\r
-    uint32_t            neAxc;     /**< number of eAxc supported on one CC*/\r
-    uint32_t            neAxcUl;     /**< number of eAxc supported on one CC for UL direction */\r
-    uint32_t            nAntElmTRx;  /**< Number of antenna elements for TX and RX */\r
-    uint16_t            nDLFftSize;  /**< DL FFT size */\r
-    uint16_t            nULFftSize;  /**< UL FFT size */\r
-    uint16_t            nDLRBs;      /**< DL PRB  */\r
-    uint16_t            nULRBs;      /**< UL PRB  */\r
-    uint32_t            nDLAbsFrePointA; /**< Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000 */\r
-    uint32_t            nULAbsFrePointA; /**< Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000 */\r
-    uint32_t            nDLCenterFreqARFCN;   /**< center frerquency for DL in MHz */\r
-    uint32_t            nULCenterFreqARFCN;   /**< center frerquency for UL in MHz */\r
-    xran_fh_tti_callback_fn     ttiCb;        /**< call back for TTI event */\r
-    void                *ttiCbParam;  /**< parameters of call back function */\r
-\r
-    struct xran_prach_config     prach_conf;   /**< PRACH specific configurations for FH */\r
-    struct xran_srs_config       srs_conf;     /**< SRS specific configurations for FH */\r
-    struct xran_frame_config     frame_conf;   /**< frame config */\r
-    struct xran_ru_config        ru_conf;      /**< config of RU as per XRAN spec */\r
-\r
-    phy_encoder_poll_fn bbdev_enc; /**< call back to poll BBDev encoder */\r
-    phy_decoder_poll_fn bbdev_dec; /**< call back to poll BBDev decoder */\r
-\r
-    uint32_t log_level; /**< configuration of log level */\r
-};\r
-\r
-/**\r
- * @ingroup xran\r
- * XRAN front haul statistic counters according to Table 7 1 : Common Counters for both DL and UL */\r
-struct xran_common_counters{\r
-    uint64_t Rx_on_time;      /**< Data was received on time (applies to user data reception window) */\r
-    uint64_t Rx_early;        /**< Data was received too early (applies to user data reception window) */\r
-    uint64_t Rx_late;         /**< Data was received too late (applies to user data reception window) */\r
-    uint64_t Rx_corrupt;      /**< Corrupt/Incorrect header packet */\r
-    uint64_t Rx_pkt_dupl;     /**< Duplicated packet */\r
-    uint64_t Total_msgs_rcvd; /**< Total messages received (on all links) */\r
-};\r
-\r
-/**\r
- * @ingroup xran\r
- * CC instance handle pointer type */\r
-typedef void * xran_cc_handle_t;\r
-\r
-/**\r
- *****************************************************************************\r
- * @ingroup xran\r
- *\r
- * @description\r
- *      A flat buffer structure. The data pointer, pData, is a virtual address.\r
- *      The API requires the memory to by physically contiguous. Each flat\r
- *      buffer segment may contain several equally sized elements.\r
- *\r
- *****************************************************************************/\r
-struct xran_flat_buffer\r
-{\r
-    uint32_t nElementLenInBytes;\r
-    /**< The Element length specified in bytes.\r
-     * This parameter specifies the size of a single element in the buffer.\r
-     * The total size of the buffer is described as\r
-     * bufferSize = nElementLenInBytes * nNumberOfElements */\r
-    uint32_t nNumberOfElements;\r
-    /**< The number of elements in the physical contiguous memory segment */\r
-    uint32_t nOffsetInBytes;\r
-    /**< Offset in bytes to the start of the data in the physical contiguous\r
-     * memory segment */\r
-    uint32_t nIsPhyAddr;\r
-    uint8_t *pData;\r
-    /**< The data pointer is a virtual address, however the actual data pointed\r
-     * to is required to be in contiguous physical memory unless the field\r
-     requiresPhysicallyContiguousMemory in CpaInstanceInfo is false. */\r
-    void *pCtrl;\r
-    /**< pointer to control section coresponding to data buffer */\r
-};\r
-\r
-/**\r
- *****************************************************************************\r
- * @ingroup xran\r
- *      Scatter/Gather buffer list containing an array of Simple buffers.\r
- *\r
- * @description\r
- *      A Scatter/Gather buffer list structure. It is expected that this buffer\r
- *      structure will be used where more than one flat buffer can be provided\r
- *      on a particular API.\r
- *\r
- *      IMPORTANT - The memory for the pPrivateMetaData member must be allocated\r
- *      by the client as contiguous memory.  When allocating memory for\r
- *      pPrivateMetaData a call to cpaCyBufferListGetMetaSize MUST be made to\r
- *      determine the size of the Meta Data Buffer.  The returned size\r
- *      (in bytes) may then be passed in a memory allocation routine to allocate\r
- *      the pPrivateMetaData memory.\r
- *\r
- *****************************************************************************/\r
-struct xran_buffer_list\r
-{\r
-    uint32_t nNumBuffers;\r
-    /**< Number of pointers */\r
-    struct xran_flat_buffer *pBuffers;\r
-    /**< Pointer to an unbounded array containing the number of CpaFlatBuffers\r
-     * defined by nNumBuffers */\r
-    void *pUserData;\r
-    /**< This is an opaque field that is not read or modified internally. */\r
-    void *pPrivateMetaData;\r
-    /**< Private Meta representation of this buffer List - the memory for this\r
-     * buffer needs to be allocated by the client as contiguous data.\r
-     * The amount of memory required is returned with a call to\r
-     * cpaCyBufferListGetMetaSize. If cpaCyBufferListGetMetaSize returns a size\r
-     * of zero no memory needs to be allocated, and this parameter can be NULL.\r
-     */\r
-};\r
-\r
-/**\r
- * @ingroup xran\r
- * Initialize the XRAN Layer via DPDK.\r
- *\r
- * @param argc\r
- *   A non-negative value.  If it is greater than 0, the array members\r
- *   for argv[0] through argv[argc] (non-inclusive) shall contain pointers\r
- *   to strings.\r
- * @param argv\r
- *   An array of strings.  The contents of the array, as well as the strings\r
- *   which are pointed to by the array, may be modified by this function.\r
- *\r
- * @return\r
- *   0 - on success\r
- *   Error codes returned via rte_errno\r
- */\r
-int32_t xran_init(int argc, char *argv[], struct xran_fh_init *p_xran_fh_init, char *appName, void ** pHandle);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function returns handles for number of sectors supported by XRAN layer. Currently function\r
- *   supports one handle XRAN layer where it supports only one CC\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle\r
- * @param nNumInstances\r
- *   total number of instances of CC\r
- * @param pSectorInstanceHandles\r
- *   Pointer to xran_cc_handle_t where to store Handle pointer\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-int32_t xran_sector_get_instances (void * pHandle, uint16_t nNumInstances,\r
-               xran_cc_handle_t * pSectorInstanceHandles);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function initialize Memory Management subsystem (mm) in order to handle memory buffers between XRAN layer\r
- *   and PHY.\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- * @param nMemorySize\r
- *   memory size of all segments\r
- * @param nMemorySegmentSize\r
- *   size of memory per segment\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-int32_t xran_mm_init (void * pHandle, uint64_t nMemorySize, uint32_t nMemorySegmentSize);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function allocates buffer memory (bm) used between XRAN layer and PHY. In general case it's DPDK mbuf.\r
- *   it uses Memory Management system to get memory chunk and define memory pool on top of it.\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- * @param nPoolIndex\r
- *   pointer to buffer pool identification to be returned\r
- * @param nNumberOfBuffers\r
- *   number of buffer to allocate in the pool\r
- * @param nBufferSize\r
- *   buffer size to allocate\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-int32_t xran_bm_init (void * pHandle, uint32_t * pPoolIndex, uint32_t nNumberOfBuffers, uint32_t nBufferSize);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function allocates buffer used between XRAN layer and PHY. In general case it's DPDK mbuf.\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- * @param nPoolIndex\r
- *   buffer pool identification\r
- * @param ppData\r
- *   Pointer to pointer where to store address of new buffer\r
- * @param ppCtrl\r
- *   Pointer to pointer where to store address of internal private control information\r
- *\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-int32_t xran_bm_allocate_buffer(void * pHandle, uint32_t nPoolIndex, void **ppData,  void **ppCtrl);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function frees buffer used between XRAN layer and PHY. In general case it's DPDK mbuf\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- * @param pData\r
- *   Pointer to buffer\r
- * @param pData\r
- *   Pointer to internal private control information\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-int32_t xran_bm_free_buffer(void * pHandle, void *pData, void *pCtrl);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function destroys Memory Management (MM) layer of XRAN library\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-int32_t xran_mm_destroy (void * pHandle);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function configures TX(DL) and RX(UL) output buffers and callback (UL only) for XRAN layer with\r
- *   given handle\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- * @param pSrcBuffer\r
- *   list of memory buffers to use to fetch IQs from PHY to XRAN layer (DL)\r
- * @param pSrcCpBuffer\r
- *   list of memory buffers to use to configure C-plane (DL)\r
- * @param pDstBuffer\r
- *   list of memory buffers to use to deliver IQs from XRAN layer to PHY (UL)\r
- * @param pDstCpBuffer\r
- *   list of memory buffers to use to configure C-plane (UL)\r
- * @param xran_transport_callback_fn pCallback\r
- *   Callback function to call with arrival of all packets for given CC for given symbol\r
- * @param pCallbackTag\r
- *   Parameters of Callback function\r
- *\r
- * @return\r
- *   0  - on success\r
- *   -1 - on error\r
- */\r
- int32_t xran_5g_fronthault_config (void * pHandle,\r
-                    struct xran_buffer_list *pSrcBuffer[XRAN_MAX_ANTENNA_NR][XRAN_N_FE_BUF_LEN],\r
-                    struct xran_buffer_list *pSrcCpBuffer[XRAN_MAX_ANTENNA_NR][XRAN_N_FE_BUF_LEN],\r
-                    struct xran_buffer_list *pDstBuffer[XRAN_MAX_ANTENNA_NR][XRAN_N_FE_BUF_LEN],\r
-                    struct xran_buffer_list *pDstCpBuffer[XRAN_MAX_ANTENNA_NR][XRAN_N_FE_BUF_LEN],\r
-                    xran_transport_callback_fn pCallback,\r
-                    void *pCallbackTag);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function configures PRACH output buffers and callback for XRAN layer with given handle\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- * @param pDstBuffer\r
- *   list of memory buffers to use to deliver PRACH IQs from xran layer to PHY\r
- * @param xran_transport_callback_fn pCallback\r
- *   Callback function to call with arrival of PRACH packets for given CC\r
- * @param pCallbackTag\r
- *   Parameters of Callback function\r
- *\r
- * @return\r
- *   0  - on success\r
- *   -1 - on error\r
- */\r
-int32_t xran_5g_prach_req (void *  pHandle,\r
-                struct xran_buffer_list *pDstBuffer[XRAN_MAX_ANTENNA_NR][XRAN_N_FE_BUF_LEN],\r
-                xran_transport_callback_fn pCallback,\r
-                void *pCallbackTag);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function configures SRS output buffers and callback for XRAN layer with given handle\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- * @param pDstBuffer\r
- *   list of memory buffers to use to deliver SRS IQs from xran layer to PHY\r
- * @param xran_transport_callback_fn pCallback\r
- *   Callback function to call with arrival of SRS packets for given CC\r
- * @param pCallbackTag\r
- *   Parameters of Callback function\r
- *\r
- * @return\r
- *   0  - on success\r
- *   -1 - on error\r
- */\r
-int32_t xran_5g_srs_req (void *  pHandle,\r
-                struct xran_buffer_list *pDstBuffer[XRAN_MAX_ANT_ARRAY_ELM_NR][XRAN_N_FE_BUF_LEN],\r
-                xran_transport_callback_fn pCallback,\r
-                void *pCallbackTag);\r
-\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function returns XRAN core utilization stats\r
- *\r
- * @param total_time (out)\r
- *   Pointer to variable to store Total time thread has been running\r
- * @param used_time (out)\r
- *   Pointer to variable to store Total time essential tasks have been running on the thread\r
- * @param core_used (out)\r
- *   Pointer to variable to store Core on which the XRAN thread is running\r
- * @param clear (in)\r
- *   If set to 1, then internal variables total_time and used_time are cleared\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-uint32_t xran_get_time_stats(uint64_t *total_time, uint64_t *used_time, uint32_t *core_used, uint32_t clear);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function opens XRAN layer with given handle\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- * @param pointer to struct xran_fh_config pConf\r
- *   Pointer to XRAN configuration structure with specific settings to use\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-int32_t xran_open(void *pHandle, struct xran_fh_config* pConf);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function starts XRAN layer with given handle\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-int32_t xran_start(void *pHandle);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function stops XRAN layer with given handle\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-int32_t xran_stop(void *pHandle);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function closes XRAN layer with given handle\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-int32_t xran_close(void *pHandle);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function registers callback to XRAN layer. Function support callbacks aligned on packet arrival.\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- * @param symCb\r
- *   pointer to callback function\r
- * @param symCb\r
- *   pointer to Callback Function parameters\r
- * @param symb\r
- *   symbol to be register for\r
- * @param ant\r
- *   Antenna number to trigger callback for packet arrival\r
- *\r
- * @return\r
- *    0 - in case of success\r
- *   -1 - in case of failure\r
- */\r
-int32_t xran_reg_sym_cb(void *pHandle, xran_callback_sym_fn symCb, void * symCbParam, uint8_t symb, uint8_t ant);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function registers callback to XRAN layer. Function support callbacks align to OTA time. TTI even, half of slot,\r
- *   full slot with respect to PTP time.\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- * @param Cb\r
- *   pointer to callback function\r
- * @param cbParam\r
- *   pointer to Callback Function parameters\r
- * @param skipTtiNum\r
- *   number of calls to be skipped before first call\r
- * @param callback_to_phy_id\r
- *   call back time identification (see enum callback_to_phy_id)\r
- *\r
- * @return\r
- *    0 - in case of success\r
- *   -1 - in case of failure\r
- */\r
-int32_t xran_reg_physide_cb(void *pHandle, xran_fh_tti_callback_fn Cb, void *cbParam, int skipTtiNum, enum callback_to_phy_id);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function returns current TTI, Frame, Subframe, Slot Number as seen "Over air" base on PTP time\r
- *\r
- * @param nFrameIdx\r
- *    Pointer to Frame number [0-99]\r
- *\r
- * @param nSubframeIdx\r
- *    Pointer to Subframe number [0-10]\r
- *\r
- * @param nSlotIdx\r
- *    Pointer to Slot number [0-7]\r
- *\r
- * @param nSecond\r
- *    Pointer to current UTC second\r
- *\r
- * @return\r
- *   current TTI number [0-7999]\r
- */\r
-int32_t xran_get_slot_idx (uint32_t *nFrameIdx, uint32_t *nSubframeIdx,  uint32_t *nSlotIdx, uint64_t *nSecond);\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function retrun XRAN layer common counters for given handle\r
- *\r
- * @param pHandle\r
- *   Pointer to XRAN layer handle for given CC\r
- *\r
- * @param pStats\r
- *   Pointer to pointer of common counter structure\r
- *\r
- * @return\r
- *   0 - on success\r
- */\r
-int32_t xran_get_common_counters(void *pXranLayerHandle, struct xran_common_counters *pStats);\r
-\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function returns status of operation of FH layer\r
- *\r
- * @return\r
- *  XRAN_INIT    - init state\r
- *  XRAN_RUNNING - running\r
- *  XRAN_STOPPED - stopped\r
- */\r
-enum xran_if_state xran_get_if_state(void);\r
-\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function allocates memory of given size from heap\r
- *\r
- * @param buf_len\r
- *   buffer size\r
- *\r
- * @return\r
- *   ptr - to memory buffer or NULL\r
- */\r
-void*    xran_malloc(size_t buf_len);\r
-\r
-\r
-/**\r
- * @ingroup xran\r
- *\r
- *   Function calculates offset for ptr according to ORAN headers requared\r
- *\r
- * @param dst\r
- *   pointer to be addjusted\r
- * @compMethod\r
- *   compression method according to enum xran_compression_method\r
- *\r
- * @return\r
- *   ptr - pointer to payload given header requared\r
- */\r
-uint8_t* xran_add_hdr_offset(uint8_t  *dst, int16_t compMethod);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif /* _XRAN_FH_O_DU_H_*/\r
+/******************************************************************************
+*
+*   Copyright (c) 2019 Intel.
+*
+*   Licensed under the Apache License, Version 2.0 (the "License");
+*   you may not use this file except in compliance with the License.
+*   You may obtain a copy of the License at
+*
+*       http://www.apache.org/licenses/LICENSE-2.0
+*
+*   Unless required by applicable law or agreed to in writing, software
+*   distributed under the License is distributed on an "AS IS" BASIS,
+*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*   See the License for the specific language governing permissions and
+*   limitations under the License.
+*
+*******************************************************************************/
+
+/**
+ * @brief This file provides public interface to xRAN Front Haul layer implementation as defined in the
+ *      ORAN-WG4.CUS.0-v01.00 spec. Implementation specific to
+ *      Lower Layer Split Central Unit (O-DU): a logical node that includes the eNB/gNB functions as
+ *      listed in section 2.1 split option 7-2x, excepting those functions allocated exclusively to the O-RU.
+ *      The O-DU controls the operation of O-RUs for 5G NR Radio Access technology
+ *
+ * @file xran_fh_o_du.h
+ * @ingroup group_lte_source_xran
+ * @author Intel Corporation
+ *
+ **/
+
+#ifndef _XRAN_FH_O_DU_H_
+#define _XRAN_FH_O_DU_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <netinet/in.h>
+#include <setjmp.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <errno.h>
+#include <getopt.h>
+#include <unistd.h>
+
+#define XRAN_STATUS_SUCCESS (0)
+/**<
+ *  @ingroup xran
+ *   Success status value. */
+#define XRAN_STATUS_FAIL (-1)
+/**<
+ *  @ingroup xran
+ *   Fail status value. */
+
+#define XRAN_STATUS_RETRY (-2)
+/**<
+ *  @ingroup xran
+ *  Retry status value. */
+
+#define XRAN_STATUS_RESOURCE (-3)
+/**<
+ *  @ingroup xran
+ *  The resource that has been requested is unavailable. Refer
+ *  to relevant sections of the API for specifics on what the suggested
+ *  course of action is. */
+
+#define XRAN_STATUS_INVALID_PARAM (-4)
+/**<
+ *  @ingroup xran
+ *  Invalid parameter has been passed in. */
+#define XRAN_STATUS_FATAL (-5)
+/**<
+ *  @ingroup xran
+ *  A serious error has occurred. Recommended course of action
+ *  is to shutdown and restart the component. */
+
+#define XRAN_STATUS_UNSUPPORTED (-6)
+/**<
+ *  @ingroup xran
+ *  The function is not supported, at least not with the specific
+ *  parameters supplied.  This may be because a particular
+ *  capability is not supported by the current implementation. */
+
+#define XRAN_STATUS_INVALID_PACKET (-7)
+/**<
+ *  @ingroup xran
+ *  Recevied packet does not have correct format. */
+
+/** Macro to calculate TTI number from symbol index used by timing thread */
+#define XranGetTtiNum(symIdx, numSymPerTti) (((uint32_t)symIdx / (uint32_t)numSymPerTti))
+/** Macro to calculate Symbol number for given slot from symbol index  */
+#define XranGetSymNum(symIdx, numSymPerTti) (((uint32_t)symIdx % (uint32_t)numSymPerTti))
+/** Macro to calculate Frame number for given tti */
+#define XranGetFrameNum(tti,SFNatSecStart,numSubFramePerSystemFrame, numSlotPerSubFrame)  ((((uint32_t)tti / ((uint32_t)numSubFramePerSystemFrame * (uint32_t)numSlotPerSubFrame)) + SFNatSecStart) & 0x3FF)
+/** Macro to calculate Subframe number for given tti */
+#define XranGetSubFrameNum(tti, numSlotPerSubFrame, numSubFramePerSystemFrame) (((uint32_t)tti/(uint32_t)numSlotPerSubFrame) % (uint32_t)numSubFramePerSystemFrame)
+/** Macro to calculate Slot number */
+#define XranGetSlotNum(tti, numSlotPerSfn) ((uint32_t)tti % ((uint32_t)numSlotPerSfn))
+
+#define XRAN_PORTS_NUM               (1)    /**< number of XRAN ports (aka O-RU devices) supported */
+#define XRAN_N_FE_BUF_LEN            (40)   /**< Number of TTIs (slots) */
+#define XRAN_MAX_SECTOR_NR           (12)   /**< Max sectors per XRAN port */
+#define XRAN_MAX_ANTENNA_NR          (16)    /**< Max number of extended Antenna-Carriers:
+                                                a data flow for a single antenna (or spatial stream) for a single carrier in a single sector */
+
+/* see 10.2    Hierarchy of Radiation Structure in O-RU (assume TX and RX pannel are the same dimensions)*/
+#define XRAN_MAX_PANEL_NR            (1)   /**< Max number of Panels supported per O-RU */
+#define XRAN_MAX_TRX_ANTENNA_ARRAY   (1)   /**< Max number of TX and RX arrays per panel in O-RU */
+#define XRAN_MAX_ANT_ARRAY_ELM_NR    (64)  /**< Maximum number of Antenna Array Elemets in Antenna Array in the O-RU */
+
+
+
+#define XRAN_NUM_OF_SYMBOL_PER_SLOT  (14) /**< Number of symbols per slot */
+#define XRAN_MAX_NUM_OF_SRS_SYMBOL_PER_SLOT  XRAN_NUM_OF_SYMBOL_PER_SLOT /**< Max Number of SRS symbols per slot */
+#define XRAN_MAX_TDD_PERIODICITY     (80) /**< Max TDD pattern period */
+#define XRAN_MAX_CELLS_PER_PORT      (XRAN_MAX_SECTOR_NR) /**< Max cells mapped to XRAN port */
+#define XRAN_COMPONENT_CARRIERS_MAX  (XRAN_MAX_SECTOR_NR) /**< number of CCs */
+#define XRAN_NUM_OF_ANT_RADIO        (XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR) /**< Max Number of Antennas supported for all CC on single XRAN port */
+#define XRAN_MAX_PRBS                (275) /**< Max of PRBs per CC per antanna for 5G NR */
+
+#define XRAN_MAX_SECTIONS_PER_SYM    (16)  /**< Max number of different sections in single symbol (section is equal to RB allocation for UE) */
+
+#define XRAN_MAX_PKT_BURST (448+4) /**< 4x14x8 symbols per ms */
+#define XRAN_N_MAX_BUFFER_SEGMENT XRAN_MAX_PKT_BURST /**< Max number of segments per ms */
+
+#define XRAN_STRICT_PARM_CHECK               (1) /**< enable parameter check for C-plane */
+
+/* Slot type definition */
+#define XRAN_SLOT_TYPE_INVALID               (0) /**< invalid slot type */
+#define XRAN_SLOT_TYPE_DL                    (1) /**< DL slot */
+#define XRAN_SLOT_TYPE_UL                    (2) /**< UL slot */
+#define XRAN_SLOT_TYPE_SP                    (3) /**< Special slot */
+#define XRAN_SLOT_TYPE_FDD                   (4) /**< FDD slot */
+#define XRAN_SLOT_TYPE_LAST                  (5) /**< MAX slot */
+
+/* symbol type definition */
+#define XRAN_SYMBOL_TYPE_DL                  (0) /**< DL symbol  */
+#define XRAN_SYMBOL_TYPE_UL                  (1) /**< UL symbol  */
+#define XRAN_SYMBOL_TYPE_GUARD               (2) /**< GUARD symbol */
+#define XRAN_SYMBOL_TYPE_FDD                 (3) /**< FDD symbol */
+
+#define XRAN_NUM_OF_SLOT_IN_TDD_LOOP         (80)/**< MAX number of slot for TDD repetition */
+
+//#define _XRAN_DEBUG   /**< Enable debug log */
+//#define _XRAN_VERBOSE /**< Enable verbose log */
+
+#ifdef _XRAN_DEBUG
+    #define xran_log_dbg(fmt, ...)          \
+        fprintf(stderr,                     \
+            "DEBUG: %s(%d): " fmt "\n",     \
+            __FILE__,                       \
+            __LINE__, ##__VA_ARGS__)
+#else
+    #define xran_log_dbg(fmt, ...)
+#endif
+
+#if defined(_XRAN_DEBUG) || defined(_XRAN_VERBOSE)
+    #define xran_log_wrn(fmt, ...)          \
+        fprintf(                            \
+            stderr,                         \
+            "WARNING: %s(%d): " fmt "\n",   \
+            __FILE__,                       \
+            __LINE__, ##__VA_ARGS__)
+#else
+    #define xran_log_dbg(fmt, ...)
+    #define xran_log_wrn(fmt, ...)
+#endif
+
+#define xran_log_err(fmt, ...)          \
+    fprintf(stderr,                     \
+        "ERROR: %s(%d): " fmt "\n",     \
+        __FILE__,                       \
+        __LINE__, ##__VA_ARGS__)
+
+enum XranFrameDuplexType
+{
+    XRAN_FDD = 0, XRAN_TDD
+};
+
+enum xran_if_state
+{
+    XRAN_INIT = 0,
+    XRAN_RUNNING,
+    XRAN_STOPPED
+};
+
+/**
+ ******************************************************************************
+ * @ingroup xran
+ *
+ * @description
+ *      Compression Method 6.3.3.13, Table 6-43
+ *****************************************************************************/
+enum xran_compression_method {
+    XRAN_COMPMETHOD_NONE        = 0,
+    XRAN_COMPMETHOD_BLKFLOAT    = 1,
+    XRAN_COMPMETHOD_BLKSCALE    = 2,
+    XRAN_COMPMETHOD_ULAW        = 3,
+    XRAN_COMPMETHOD_MODULATION  = 4,
+    XRAN_COMPMETHOD_MAX
+};
+
+/**
+ ******************************************************************************
+ * @ingroup xran
+ *
+ * @description
+ *      Callback function type for symbol packet enum
+ *****************************************************************************/
+enum callback_to_phy_id
+{
+    XRAN_CB_TTI = 0, /**< callback on TTI boundary */
+    XRAN_CB_HALF_SLOT_RX =1, /**< callback on half slot (sym 7) packet arrival*/
+    XRAN_CB_FULL_SLOT_RX =2, /**< callback on full slot (sym 14) packet arrival */
+    XRAN_CB_MAX /**< max number of callbacks */
+};
+
+/**  Beamforming type, enumerated as "frequency", "time" or "hybrid"
+     section 10.4.2    Weight-based dynamic beamforming */
+enum xran_weight_based_beamforming_type {
+    XRAN_BF_T_FREQUENCY = 0,
+    XRAN_BF_T_TIME      = 1,
+    XRAN_BF_T_HYBRID    = 2,
+    XRAN_BF_T_MAX
+};
+
+typedef int32_t xran_status_t; /**< Xran status return value */
+
+/** callback function type for Symbol packet */
+typedef void (*xran_callback_sym_fn)(void*);
+
+/** Callback function type for TTI event */
+typedef int (*xran_fh_tti_callback_fn)(void*);
+
+/** Callback function type packet arrival from transport layer (ETH or IP) */
+typedef void (*xran_transport_callback_fn)(void*, xran_status_t);
+
+/** Callback functions to poll BBdev encoder */
+typedef int16_t (*phy_encoder_poll_fn)(void);
+
+/** Callback functions to poll BBdev secoder */
+typedef int16_t (*phy_decoder_poll_fn)(void);
+
+/** XRAN port enum */
+enum xran_vf_ports
+{
+    XRAN_UP_VF = 0, /**< port type for U-plane */
+    XRAN_CP_VF,     /**< port type for C-plane */
+    XRAN_VF_MAX
+};
+
+/** XRAN category enum */
+enum xran_category
+{
+    XRAN_CATEGORY_A = 0,
+    XRAN_CATEGORY_B = 1,
+    XRAN_CATEGORY_MAX
+};
+
+/** type of beamforming */
+enum xran_beamforming_type
+{
+    XRAN_BEAM_ID_BASED = 0, /**< beam index based */
+    XRAN_BEAM_WEIGHT,       /**< beam forming weights */
+    XRAN_BEAM_ATTRIBUTE,    /**< beam index based */
+};
+
+/** state of bbdev with xran */
+enum xran_bbdev_init
+{
+    XRAN_BBDEV_NOT_USED    = -1, /**< BBDEV is disabled */
+    XRAN_BBDEV_MODE_HW_OFF = 0,  /**< BBDEV is enabled for SW sim mode */
+    XRAN_BBDEV_MODE_HW_ON  = 1,  /**< BBDEV is enable for HW */
+    XRAN_BBDEV_MODE_MAX
+};
+
+/** callback return information */
+struct xran_cb_tag {
+    uint16_t cellId;
+    uint32_t symbol;
+    uint32_t slotiId;
+};
+
+/** DPDK IO configuration for XRAN layer */
+struct xran_io_cfg {
+    uint8_t id; /**< should be (0) for O-DU or (1) O-RU (debug) */
+    char *dpdk_dev[XRAN_VF_MAX]; /**< VFs devices  */
+    char *bbdev_dev[1];     /**< BBDev dev name */
+    int32_t bbdev_mode;     /**< DPDK for BBDev */
+    int32_t core;           /**< reservd */
+    int32_t system_core;    /**< reservd */
+    int32_t pkt_proc_core;  /**< reservd */
+    int32_t pkt_aux_core;   /**< reservd */
+    int32_t timing_core;    /**< core used by xRAN */
+    int32_t port[XRAN_VF_MAX];  /**< VFs ports */
+};
+
+/** XRAN spec section 3.1.3.1.6 ecpriRtcid / ecpriPcid define */
+struct xran_eaxcid_config {
+    uint16_t mask_cuPortId;     /**< Mask CU PortId */
+    uint16_t mask_bandSectorId; /**< Mask Band */
+    uint16_t mask_ccId;         /**< Mask CC */
+    uint16_t mask_ruPortId;     /**< Mask RU Port ID */
+
+    uint8_t bit_cuPortId;       /**< bandsectorId + ccId + ruportId */
+    uint8_t bit_bandSectorId;   /**< ccId + ruPortId */
+    uint8_t bit_ccId;           /**< ruportId */
+    uint8_t bit_ruPortId;       /**< 0 */
+};
+
+/**
+* XRAN Front haul interface initialization settings
+*/
+struct xran_fh_init {
+    struct xran_io_cfg io_cfg;/**< DPDK IO for XRAN */
+    struct xran_eaxcid_config eAxCId_conf; /**< config of ecpriRtcid/ecpriPcid */
+
+    uint32_t dpdkBasebandFecMode; /**< DPDK Baseband FEC device mode (0-SW, 1-HW) */
+    char *dpdkBasebandDevice;     /**< DPDK Baseband device address */
+    char *filePrefix;             /**< DPDK prefix */
+
+    uint32_t mtu; /**< maximum transmission unit (MTU) is the size of the largest protocol data unit (PDU) that can be communicated in a single
+                       xRAN network layer transaction. supported 1500 bytes and 9600 bytes (Jumbo Frame) */
+    int8_t *p_o_du_addr;  /**<  O-DU Ethernet Mac Address */
+    int8_t *p_o_ru_addr;  /**<  O-RU Ethernet Mac Address */
+
+    uint16_t totalBfWeights;/**< The total number of beamforming weights on RU for extensions */
+
+    uint16_t Tadv_cp_dl;    /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T2a_min_cp_dl; /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T2a_max_cp_dl; /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T2a_min_cp_ul; /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T2a_max_cp_ul; /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T2a_min_up;    /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T2a_max_up;    /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t Ta3_min;       /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t Ta3_max;       /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T1a_min_cp_dl; /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T1a_max_cp_dl; /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T1a_min_cp_ul; /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T1a_max_cp_ul; /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T1a_min_up;    /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t T1a_max_up;    /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t Ta4_min;       /**< Table 2 7 : xRAN Delay Management Model Parameters */
+    uint16_t Ta4_max;       /**< Table 2 7 : xRAN Delay Management Model Parameters */
+
+    uint8_t enableCP;       /**<  enable C-plane */
+    uint8_t prachEnable;    /**<  enable PRACH   */
+    uint8_t srsEnable;      /**<  enable SRS (Cat B specific) */
+    uint8_t cp_vlan_tag;    /**<  C-plane vlan tag */
+    uint8_t up_vlan_tag;    /**<  U-plane vlan tag */
+    int32_t debugStop;      /**<  enable auto stop */
+    int32_t debugStopCount;      /**<  enable auto stop after number of Tx packets */
+    int32_t DynamicSectionEna; /**<  enable dynamic C-Plane section allocation */
+    int32_t GPS_Alpha;  // refer to alpha as defined in section 9.7.2 of ORAN spec. this value should be alpha*(1/1.2288ns), range 0 - 1e7 (ns)
+    int32_t GPS_Beta;   //beta value as defined in section 9.7.2 of ORAN spec. range -32767 ~ +32767
+};
+
+/** Beamforming waights for single stream for each PRBs  given number of Antenna elements */
+struct xran_cp_bf_weight{
+    int16_t nAntElmTRx;        /**< num TRX for this allocation */
+    int8_t*  p_ext_section;    /**< pointer to form extType */
+    int16_t  ext_section_sz;   /**< extType section size */
+};
+struct xran_cp_bf_attribute{
+    int16_t weight[4];
+};
+struct xran_cp_bf_precoding{
+    int16_t weight[4];
+};
+
+/** section descriptor for given number of PRBs used on U-plane packet creation */
+struct xran_section_desc {
+    uint16_t section_id; /**< section id used for this element */
+
+    int16_t iq_buffer_offset;    /**< Offset in bytes for the content of IQs with in main symb buffer */
+    int16_t iq_buffer_len;       /**< Length in bytes for the content of IQs with in main symb buffer */
+
+    uint8_t *pData;      /**< optional pointer to data buffer */
+    void    *pCtrl;      /**< optional poitner to mbuf */
+};
+
+/** PRB element structure */
+struct xran_prb_elm {
+    int16_t nRBStart;    /**< start RB of RB allocation */
+    int16_t nRBSize;     /**< number of RBs used */
+    int16_t nStartSymb;  /**< start symbol ID */
+    int16_t numSymb;     /**< number of symbols */
+    int16_t nBeamIndex;  /**< beam index for given PRB */
+    int16_t bf_weight_update; /** need to update beam weights or not */
+    int16_t compMethod;  /**< compression index for given PRB */
+    int16_t iqWidth;     /**< compression bit width for given PRB */
+    int16_t BeamFormingType; /**< index based, weights based or attribute based beam forming*/
+
+    struct xran_section_desc * p_sec_desc[XRAN_NUM_OF_SYMBOL_PER_SLOT]; /**< section desctiptors to U-plane data given RBs */
+    struct xran_cp_bf_weight   bf_weight; /**< beam forming information relevant for given RBs */
+
+    union {
+        struct xran_cp_bf_attribute bf_attribute;
+        struct xran_cp_bf_precoding bf_precoding;
+    };
+};
+
+/** PRB map structure */
+struct xran_prb_map {
+    uint8_t   dir;        /**< DL or UL direction */
+    uint8_t   xran_port;  /**< xran id of given RU [0-(XRAN_PORTS_NUM-1)] */
+    uint16_t  band_id;    /**< xran band id */
+    uint16_t  cc_id;      /**< componnent carrier id [0 - (XRAN_MAX_SECTOR_NR-1)] */
+    uint16_t  ru_port_id; /**< RU device antenna port id [0 - (XRAN_MAX_ANTENNA_NR-1) */
+    uint16_t  tti_id;     /**< xRAN slot id [0 - (max tti-1)] */
+    uint8_t   start_sym_id;     /**< start symbol Id [0-13] */
+    uint32_t  nPrbElm;    /**< total number of PRB elements for given map [0- (XRAN_MAX_PRBS-1)] */
+    struct xran_prb_elm prbMap[XRAN_MAX_PRBS];
+
+
+};
+
+/* PRACH config required for XRAN based FH */
+struct xran_prach_config
+{
+    /* PRACH config*/
+    uint8_t      nPrachConfIdx;  /**< PRACH Configuration Index*/
+    uint8_t      nPrachSubcSpacing;
+    /**< PRACH Sub-carrier spacing
+    Value:0->1
+    For below 6GHz the values indicate 15kHz or 30kHz
+    For above 6GHz the values indicate 60kHz or 120kHz*/
+    uint8_t      nPrachZeroCorrConf; /**< PRACH zeroCorrelationZoneConfig */
+    uint8_t      nPrachRestrictSet;  /**< PRACH restrictedSetConfig */
+    uint16_t     nPrachRootSeqIdx; /**< PRACH Root Sequence Index */
+    uint16_t     nPrachFreqStart;  /**< PRACH prach-frequency-start  */
+    int32_t      nPrachFreqOffset; /**< PRACH prach-frequency-offset */
+    uint8_t      nPrachFilterIdx;  /**< PRACH Filter index */
+};
+
+/**< SRS configuration required for XRAN based FH */
+struct xran_srs_config {
+    uint16_t   symbMask;    /**< symbols used for SRS with in U/S slot [bits 0-13] */
+    uint8_t    eAxC_offset; /**< starting value of eAxC for SRS packets */
+};
+
+/** XRAN slot configuration */
+struct xran_slot_config {
+    uint8_t nSymbolType[XRAN_NUM_OF_SYMBOL_PER_SLOT]; /**< Defines the Symbol type for all 14 symbols in a slot. 0: DL, 1: UL, 2: Guard */
+    uint8_t reserved[2];
+};
+
+/** XRAN front haul frame config */
+struct xran_frame_config {
+    uint8_t      nFrameDuplexType; /**< Frame Duplex type:  0 -> FDD, 1 -> TDD */
+    uint8_t      nNumerology; /**< Numerology, determine sub carrier spacing, Value: 0->4
+                                   0: 15khz,  1: 30khz,  2: 60khz
+                                   3: 120khz, 4: 240khz */
+    uint8_t      nTddPeriod;  /**< TDD period */
+    struct xran_slot_config sSlotConfig[XRAN_MAX_TDD_PERIODICITY];
+    /**< TDD Slot configuration - If nFrameDuplexType = TDD(1), then this config defines the slot config type for each slot.*/
+    /* The number of slots need to be equal to nTddPeriod */
+};
+
+/** XRAN-PHY interface byte order */
+enum xran_input_byte_order {
+    XRAN_NE_BE_BYTE_ORDER = 0, /**< Network byte order (Big endian), xRAN lib doesn't do swap */
+    XRAN_CPU_LE_BYTE_ORDER     /**< CPU byte order (Little endian), xRAN lib does do swap */
+};
+
+/** XRAN-PHY interface I and Q order */
+enum xran_input_i_q_order {
+    XRAN_I_Q_ORDER = 0,  /**< I , Q */
+    XRAN_Q_I_ORDER       /**< Q , I */
+};
+
+/** XRAN front haul IQ compression settings */
+struct xran_ru_config {
+    enum xran_category xranCat;   /**< mode: Catergory A or Category B */
+
+    uint8_t iqWidth;        /**< IQ bit width */
+    uint8_t compMeth;       /**< Compression method */
+    uint8_t fftSize;        /**< FFT Size */
+    enum xran_input_byte_order byteOrder; /**< Order of bytes in int16_t in buffer. Big or little endian */
+    enum xran_input_i_q_order  iqOrder;   /**< order of IQs in the buffer */
+    uint16_t xran_max_frame; /**< max frame number supported */
+};
+
+/**
+ * @ingroup xran
+ * XRAN front haul general configuration */
+struct xran_fh_config {
+    uint32_t            dpdk_port; /**< DPDK port number used for FH */
+    uint32_t            sector_id; /**< Band sector ID for FH */
+    uint32_t            nCC;       /**< number of Component carriers supported on FH */
+    uint32_t            neAxc;     /**< number of eAxc supported on one CC*/
+    uint32_t            neAxcUl;     /**< number of eAxc supported on one CC for UL direction */
+    uint32_t            nAntElmTRx;  /**< Number of antenna elements for TX and RX */
+    uint16_t            nDLFftSize;  /**< DL FFT size */
+    uint16_t            nULFftSize;  /**< UL FFT size */
+    uint16_t            nDLRBs;      /**< DL PRB  */
+    uint16_t            nULRBs;      /**< UL PRB  */
+    uint32_t            nDLAbsFrePointA; /**< Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000 */
+    uint32_t            nULAbsFrePointA; /**< Abs Freq Point A of the Carrier Center Frequency for in KHz Value: 450000->52600000 */
+    uint32_t            nDLCenterFreqARFCN;   /**< center frerquency for DL in MHz */
+    uint32_t            nULCenterFreqARFCN;   /**< center frerquency for UL in MHz */
+    xran_fh_tti_callback_fn     ttiCb;        /**< call back for TTI event */
+    void                *ttiCbParam;  /**< parameters of call back function */
+
+    struct xran_prach_config     prach_conf;   /**< PRACH specific configurations for FH */
+    struct xran_srs_config       srs_conf;     /**< SRS specific configurations for FH */
+    struct xran_frame_config     frame_conf;   /**< frame config */
+    struct xran_ru_config        ru_conf;      /**< config of RU as per XRAN spec */
+
+    phy_encoder_poll_fn bbdev_enc; /**< call back to poll BBDev encoder */
+    phy_decoder_poll_fn bbdev_dec; /**< call back to poll BBDev decoder */
+
+    uint32_t log_level; /**< configuration of log level */
+};
+
+/**
+ * @ingroup xran
+ * XRAN front haul statistic counters according to Table 7 1 : Common Counters for both DL and UL */
+struct xran_common_counters{
+    uint64_t Rx_on_time;      /**< Data was received on time (applies to user data reception window) */
+    uint64_t Rx_early;        /**< Data was received too early (applies to user data reception window) */
+    uint64_t Rx_late;         /**< Data was received too late (applies to user data reception window) */
+    uint64_t Rx_corrupt;      /**< Corrupt/Incorrect header packet */
+    uint64_t Rx_pkt_dupl;     /**< Duplicated packet */
+    uint64_t Total_msgs_rcvd; /**< Total messages received (on all links) */
+};
+
+/**
+ * @ingroup xran
+ * CC instance handle pointer type */
+typedef void * xran_cc_handle_t;
+
+/**
+ *****************************************************************************
+ * @ingroup xran
+ *
+ * @description
+ *      A flat buffer structure. The data pointer, pData, is a virtual address.
+ *      The API requires the memory to by physically contiguous. Each flat
+ *      buffer segment may contain several equally sized elements.
+ *
+ *****************************************************************************/
+struct xran_flat_buffer
+{
+    uint32_t nElementLenInBytes;
+    /**< The Element length specified in bytes.
+     * This parameter specifies the size of a single element in the buffer.
+     * The total size of the buffer is described as
+     * bufferSize = nElementLenInBytes * nNumberOfElements */
+    uint32_t nNumberOfElements;
+    /**< The number of elements in the physical contiguous memory segment */
+    uint32_t nOffsetInBytes;
+    /**< Offset in bytes to the start of the data in the physical contiguous
+     * memory segment */
+    uint32_t nIsPhyAddr;
+    uint8_t *pData;
+    /**< The data pointer is a virtual address, however the actual data pointed
+     * to is required to be in contiguous physical memory unless the field
+     requiresPhysicallyContiguousMemory in CpaInstanceInfo is false. */
+    void *pCtrl;
+    /**< pointer to control section coresponding to data buffer */
+};
+
+/**
+ *****************************************************************************
+ * @ingroup xran
+ *      Scatter/Gather buffer list containing an array of Simple buffers.
+ *
+ * @description
+ *      A Scatter/Gather buffer list structure. It is expected that this buffer
+ *      structure will be used where more than one flat buffer can be provided
+ *      on a particular API.
+ *
+ *      IMPORTANT - The memory for the pPrivateMetaData member must be allocated
+ *      by the client as contiguous memory.  When allocating memory for
+ *      pPrivateMetaData a call to cpaCyBufferListGetMetaSize MUST be made to
+ *      determine the size of the Meta Data Buffer.  The returned size
+ *      (in bytes) may then be passed in a memory allocation routine to allocate
+ *      the pPrivateMetaData memory.
+ *
+ *****************************************************************************/
+struct xran_buffer_list
+{
+    uint32_t nNumBuffers;
+    /**< Number of pointers */
+    struct xran_flat_buffer *pBuffers;
+    /**< Pointer to an unbounded array containing the number of CpaFlatBuffers
+     * defined by nNumBuffers */
+    void *pUserData;
+    /**< This is an opaque field that is not read or modified internally. */
+    void *pPrivateMetaData;
+    /**< Private Meta representation of this buffer List - the memory for this
+     * buffer needs to be allocated by the client as contiguous data.
+     * The amount of memory required is returned with a call to
+     * cpaCyBufferListGetMetaSize. If cpaCyBufferListGetMetaSize returns a size
+     * of zero no memory needs to be allocated, and this parameter can be NULL.
+     */
+};
+
+/**
+ * @ingroup xran
+ * Initialize the XRAN Layer via DPDK.
+ *
+ * @param argc
+ *   A non-negative value.  If it is greater than 0, the array members
+ *   for argv[0] through argv[argc] (non-inclusive) shall contain pointers
+ *   to strings.
+ * @param argv
+ *   An array of strings.  The contents of the array, as well as the strings
+ *   which are pointed to by the array, may be modified by this function.
+ *
+ * @return
+ *   0 - on success
+ *   Error codes returned via rte_errno
+ */
+int32_t xran_init(int argc, char *argv[], struct xran_fh_init *p_xran_fh_init, char *appName, void ** pHandle);
+
+/**
+ * @ingroup xran
+ *
+ *   Function returns handles for number of sectors supported by XRAN layer. Currently function
+ *   supports one handle XRAN layer where it supports only one CC
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle
+ * @param nNumInstances
+ *   total number of instances of CC
+ * @param pSectorInstanceHandles
+ *   Pointer to xran_cc_handle_t where to store Handle pointer
+ *
+ * @return
+ *   0 - on success
+ */
+int32_t xran_sector_get_instances (void * pHandle, uint16_t nNumInstances,
+               xran_cc_handle_t * pSectorInstanceHandles);
+
+/**
+ * @ingroup xran
+ *
+ *   Function initialize Memory Management subsystem (mm) in order to handle memory buffers between XRAN layer
+ *   and PHY.
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ * @param nMemorySize
+ *   memory size of all segments
+ * @param nMemorySegmentSize
+ *   size of memory per segment
+ *
+ * @return
+ *   0 - on success
+ */
+int32_t xran_mm_init (void * pHandle, uint64_t nMemorySize, uint32_t nMemorySegmentSize);
+
+/**
+ * @ingroup xran
+ *
+ *   Function allocates buffer memory (bm) used between XRAN layer and PHY. In general case it's DPDK mbuf.
+ *   it uses Memory Management system to get memory chunk and define memory pool on top of it.
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ * @param nPoolIndex
+ *   pointer to buffer pool identification to be returned
+ * @param nNumberOfBuffers
+ *   number of buffer to allocate in the pool
+ * @param nBufferSize
+ *   buffer size to allocate
+ *
+ * @return
+ *   0 - on success
+ */
+int32_t xran_bm_init (void * pHandle, uint32_t * pPoolIndex, uint32_t nNumberOfBuffers, uint32_t nBufferSize);
+
+/**
+ * @ingroup xran
+ *
+ *   Function allocates buffer used between XRAN layer and PHY. In general case it's DPDK mbuf.
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ * @param nPoolIndex
+ *   buffer pool identification
+ * @param ppData
+ *   Pointer to pointer where to store address of new buffer
+ * @param ppCtrl
+ *   Pointer to pointer where to store address of internal private control information
+ *
+ *
+ * @return
+ *   0 - on success
+ */
+int32_t xran_bm_allocate_buffer(void * pHandle, uint32_t nPoolIndex, void **ppData,  void **ppCtrl);
+
+/**
+ * @ingroup xran
+ *
+ *   Function frees buffer used between XRAN layer and PHY. In general case it's DPDK mbuf
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ * @param pData
+ *   Pointer to buffer
+ * @param pData
+ *   Pointer to internal private control information
+ *
+ * @return
+ *   0 - on success
+ */
+int32_t xran_bm_free_buffer(void * pHandle, void *pData, void *pCtrl);
+
+/**
+ * @ingroup xran
+ *
+ *   Function destroys Memory Management (MM) layer of XRAN library
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ *
+ * @return
+ *   0 - on success
+ */
+int32_t xran_mm_destroy (void * pHandle);
+
+/**
+ * @ingroup xran
+ *
+ *   Function configures TX(DL) and RX(UL) output buffers and callback (UL only) for XRAN layer with
+ *   given handle
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ * @param pSrcBuffer
+ *   list of memory buffers to use to fetch IQs from PHY to XRAN layer (DL)
+ * @param pSrcCpBuffer
+ *   list of memory buffers to use to configure C-plane (DL)
+ * @param pDstBuffer
+ *   list of memory buffers to use to deliver IQs from XRAN layer to PHY (UL)
+ * @param pDstCpBuffer
+ *   list of memory buffers to use to configure C-plane (UL)
+ * @param xran_transport_callback_fn pCallback
+ *   Callback function to call with arrival of all packets for given CC for given symbol
+ * @param pCallbackTag
+ *   Parameters of Callback function
+ *
+ * @return
+ *   0  - on success
+ *   -1 - on error
+ */
+ int32_t xran_5g_fronthault_config (void * pHandle,
+                    struct xran_buffer_list *pSrcBuffer[XRAN_MAX_ANTENNA_NR][XRAN_N_FE_BUF_LEN],
+                    struct xran_buffer_list *pSrcCpBuffer[XRAN_MAX_ANTENNA_NR][XRAN_N_FE_BUF_LEN],
+                    struct xran_buffer_list *pDstBuffer[XRAN_MAX_ANTENNA_NR][XRAN_N_FE_BUF_LEN],
+                    struct xran_buffer_list *pDstCpBuffer[XRAN_MAX_ANTENNA_NR][XRAN_N_FE_BUF_LEN],
+                    xran_transport_callback_fn pCallback,
+                    void *pCallbackTag);
+
+/**
+ * @ingroup xran
+ *
+ *   Function configures PRACH output buffers and callback for XRAN layer with given handle
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ * @param pDstBuffer
+ *   list of memory buffers to use to deliver PRACH IQs from xran layer to PHY
+ * @param xran_transport_callback_fn pCallback
+ *   Callback function to call with arrival of PRACH packets for given CC
+ * @param pCallbackTag
+ *   Parameters of Callback function
+ *
+ * @return
+ *   0  - on success
+ *   -1 - on error
+ */
+int32_t xran_5g_prach_req (void *  pHandle,
+                struct xran_buffer_list *pDstBuffer[XRAN_MAX_ANTENNA_NR][XRAN_N_FE_BUF_LEN],
+                xran_transport_callback_fn pCallback,
+                void *pCallbackTag);
+
+/**
+ * @ingroup xran
+ *
+ *   Function configures SRS output buffers and callback for XRAN layer with given handle
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ * @param pDstBuffer
+ *   list of memory buffers to use to deliver SRS IQs from xran layer to PHY
+ * @param xran_transport_callback_fn pCallback
+ *   Callback function to call with arrival of SRS packets for given CC
+ * @param pCallbackTag
+ *   Parameters of Callback function
+ *
+ * @return
+ *   0  - on success
+ *   -1 - on error
+ */
+int32_t xran_5g_srs_req (void *  pHandle,
+                struct xran_buffer_list *pDstBuffer[XRAN_MAX_ANT_ARRAY_ELM_NR][XRAN_N_FE_BUF_LEN],
+                xran_transport_callback_fn pCallback,
+                void *pCallbackTag);
+
+
+/**
+ * @ingroup xran
+ *
+ *   Function returns XRAN core utilization stats
+ *
+ * @param total_time (out)
+ *   Pointer to variable to store Total time thread has been running
+ * @param used_time (out)
+ *   Pointer to variable to store Total time essential tasks have been running on the thread
+ * @param core_used (out)
+ *   Pointer to variable to store Core on which the XRAN thread is running
+ * @param clear (in)
+ *   If set to 1, then internal variables total_time and used_time are cleared
+ *
+ * @return
+ *   0 - on success
+ */
+uint32_t xran_get_time_stats(uint64_t *total_time, uint64_t *used_time, uint32_t *core_used, uint32_t clear);
+
+/**
+ * @ingroup xran
+ *
+ *   Function opens XRAN layer with given handle
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ * @param pointer to struct xran_fh_config pConf
+ *   Pointer to XRAN configuration structure with specific settings to use
+ *
+ * @return
+ *   0 - on success
+ */
+int32_t xran_open(void *pHandle, struct xran_fh_config* pConf);
+
+/**
+ * @ingroup xran
+ *
+ *   Function starts XRAN layer with given handle
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ *
+ * @return
+ *   0 - on success
+ */
+int32_t xran_start(void *pHandle);
+
+/**
+ * @ingroup xran
+ *
+ *   Function stops XRAN layer with given handle
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ *
+ * @return
+ *   0 - on success
+ */
+int32_t xran_stop(void *pHandle);
+
+/**
+ * @ingroup xran
+ *
+ *   Function closes XRAN layer with given handle
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ *
+ * @return
+ *   0 - on success
+ */
+int32_t xran_close(void *pHandle);
+
+/**
+ * @ingroup xran
+ *
+ *   Function registers callback to XRAN layer. Function support callbacks aligned on packet arrival.
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ * @param symCb
+ *   pointer to callback function
+ * @param symCb
+ *   pointer to Callback Function parameters
+ * @param symb
+ *   symbol to be register for
+ * @param ant
+ *   Antenna number to trigger callback for packet arrival
+ *
+ * @return
+ *    0 - in case of success
+ *   -1 - in case of failure
+ */
+int32_t xran_reg_sym_cb(void *pHandle, xran_callback_sym_fn symCb, void * symCbParam, uint8_t symb, uint8_t ant);
+
+/**
+ * @ingroup xran
+ *
+ *   Function registers callback to XRAN layer. Function support callbacks align to OTA time. TTI even, half of slot,
+ *   full slot with respect to PTP time.
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ * @param Cb
+ *   pointer to callback function
+ * @param cbParam
+ *   pointer to Callback Function parameters
+ * @param skipTtiNum
+ *   number of calls to be skipped before first call
+ * @param callback_to_phy_id
+ *   call back time identification (see enum callback_to_phy_id)
+ *
+ * @return
+ *    0 - in case of success
+ *   -1 - in case of failure
+ */
+int32_t xran_reg_physide_cb(void *pHandle, xran_fh_tti_callback_fn Cb, void *cbParam, int skipTtiNum, enum callback_to_phy_id);
+
+/**
+ * @ingroup xran
+ *
+ *   Function returns current TTI, Frame, Subframe, Slot Number as seen "Over air" base on PTP time
+ *
+ * @param nFrameIdx
+ *    Pointer to Frame number [0-99]
+ *
+ * @param nSubframeIdx
+ *    Pointer to Subframe number [0-10]
+ *
+ * @param nSlotIdx
+ *    Pointer to Slot number [0-7]
+ *
+ * @param nSecond
+ *    Pointer to current UTC second
+ *
+ * @return
+ *   current TTI number [0-7999]
+ */
+int32_t xran_get_slot_idx (uint32_t *nFrameIdx, uint32_t *nSubframeIdx,  uint32_t *nSlotIdx, uint64_t *nSecond);
+
+/**
+ * @ingroup xran
+ *
+ *   Function retrun XRAN layer common counters for given handle
+ *
+ * @param pHandle
+ *   Pointer to XRAN layer handle for given CC
+ *
+ * @param pStats
+ *   Pointer to pointer of common counter structure
+ *
+ * @return
+ *   0 - on success
+ */
+int32_t xran_get_common_counters(void *pXranLayerHandle, struct xran_common_counters *pStats);
+
+
+/**
+ * @ingroup xran
+ *
+ *   Function returns status of operation of FH layer
+ *
+ * @return
+ *  XRAN_INIT    - init state
+ *  XRAN_RUNNING - running
+ *  XRAN_STOPPED - stopped
+ */
+enum xran_if_state xran_get_if_state(void);
+
+
+/**
+ * @ingroup xran
+ *
+ *   Function allocates memory of given size from heap
+ *
+ * @param buf_len
+ *   buffer size
+ *
+ * @return
+ *   ptr - to memory buffer or NULL
+ */
+void*    xran_malloc(size_t buf_len);
+
+
+/**
+ * @ingroup xran
+ *
+ *   Function calculates offset for ptr according to ORAN headers requared
+ *
+ * @param dst
+ *   pointer to be addjusted
+ * @compMethod
+ *   compression method according to enum xran_compression_method
+ *
+ * @return
+ *   ptr - pointer to payload given header requared
+ */
+uint8_t* xran_add_hdr_offset(uint8_t  *dst, int16_t compMethod);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _XRAN_FH_O_DU_H_*/