O-RAN E Maintenance Release contribution for ODULOW
[o-du/phy.git] / fhi_lib / lib / api / xran_cp_api.h
index 17e2f61..c45b5b6 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
 *
-*   Copyright (c) 2019 Intel.
+*   Copyright (c) 2020 Intel.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
@@ -32,7 +32,6 @@
 extern "C" {
 #endif
 
-
 #include "xran_fh_o_du.h"
 #include "xran_pkt_cp.h"
 #include "xran_transport.h"
@@ -68,6 +67,7 @@ enum xran_cp_filterindex {
     XRAN_FILTERINDEX_PRACH_3    = 2,    /**< UL filter for PRACH preamble format 3 */
     XRAN_FILTERINDEX_PRACH_ABC  = 3,    /**< UL filter for PRACH preamble format A1~3, B1~4, C0, C2 */
     XRAN_FILTERINDEX_NPRACH     = 4,    /**< UL filter for NPRACH */
+    XRAN_FILTERINDEX_LTE4       = 5,    /**< UL filter for PRACH preamble format LTE-4 */
     XRAN_FILTERINDEX_MAX
     };
 
@@ -138,11 +138,10 @@ enum xran_cp_symbolnuminc {
 #define XRAN_LBTMODE_PARTIAL34              2
 #define XRAN_LBTMODE_FULLSTOP               3
 
+
 #define XRAN_EF_F_LAST                      0
 #define XRAN_EF_F_ANOTHER_ONE               1
 
-
-
 /** Control Plane section extension commands, defined in 5.4.6 Table 5.13 */
 enum xran_cp_sectionextcmd {
     XRAN_CP_SECTIONEXTCMD_0 = 0,    /**< Reserved, for future use */
@@ -151,7 +150,13 @@ enum xran_cp_sectionextcmd {
     XRAN_CP_SECTIONEXTCMD_3 = 3,    /**< DL Precoding configuration parameters and indications, not supported */
     XRAN_CP_SECTIONEXTCMD_4 = 4,    /**< Modulation compression parameter */
     XRAN_CP_SECTIONEXTCMD_5 = 5,    /**< Modulation compression additional scaling parameters */
-    XRAN_CP_SECTIONEXTCMD_MAX       /* 6~127 reserved for future use */
+    XRAN_CP_SECTIONEXTCMD_6 = 6,    /**< Non-contiguous PRB allocation */
+    XRAN_CP_SECTIONEXTCMD_7 = 7,    /**< Multiple-eAxC designation */
+    XRAN_CP_SECTIONEXTCMD_8 = 8,    /**< MMSE parameters */
+    XRAN_CP_SECTIONEXTCMD_9 = 9,    /**< Dynamic Spectrum Sharing parameters */
+    XRAN_CP_SECTIONEXTCMD_10 = 10,  /**< Multiple ports grouping */
+    XRAN_CP_SECTIONEXTCMD_11 = 11,  /**< Flexible BF weights */
+    XRAN_CP_SECTIONEXTCMD_MAX       /* 12~127 reserved for future use */
     };
 
 /** Macro to convert bfwIqWidth defined in 5.4.7.1.1, Table 5-15 */
@@ -179,6 +184,40 @@ enum xran_cp_bfa_bitwidth {
     XRAN_BFABITWIDTH_8BIT           = 7,    /**< the filed is 8-bit bitwidth */
     };
 
+/** Layer ID for DL transmission in TM1-TM4 5.4.7.3.2 */
+#define XRAN_LAYERID_0              0       /**< Layer 0 */
+#define XRAN_LAYERID_1              1       /**< Layer 1 */
+#define XRAN_LAYERID_2              2       /**< Layer 2 */
+#define XRAN_LAYERID_3              3       /**< Layer 3 */
+#define XRAN_LAYERID_TXD            0xf     /**< TxD */
+
+/** LTE Transmission Scheme for section extension type 3 5.4.7.3.3 */
+#define XRAN_TXS_SMUXCDD            0       /**< Spatial Multiplexing (CDD) */
+#define XRAN_TXS_SMUXNOCDD          1       /**< Spatial Multiplexing (no CDD) */
+#define XRAN_TXS_TXDIV              2       /**< Transmit diversity */
+
+/** Resource Block Group Size 5.4.7.6.1 */
+enum xran_cp_rbgsize {
+    XRAN_RBGSIZE_1RB                = 1,    /**< 1 RB */
+    XRAN_RBGSIZE_2RB                = 2,    /**< 2 RBs */
+    XRAN_RBGSIZE_3RB                = 3,    /**< 3 RBs */
+    XRAN_RBGSIZE_4RB                = 4,    /**< 4 RBs */
+    XRAN_RBGSIZE_6RB                = 5,    /**< 6 RBs */
+    XRAN_RBGSIZE_8RB                = 6,    /**< 8 RBs */
+    XRAN_RBGSIZE_16RB               = 7,    /**< 16 RBs */
+};
+
+/** Technology for Dynamic Spectrum Sharing operation 5,4,7.9.1 */
+#define XRAN_DSSTECH_LTE            0       /**< LTE support */
+#define XRAN_DSSTECH_NR             1       /**< NR support */
+
+/** The type of beam grouping 5.4.7.10.1 */
+#define XRAN_BEAMGT_COMMON          0       /** common beam */
+#define XRAN_BEAMGT_MATRIXIND       1       /** beam matrix indication */
+#define XRAN_BEAMGT_VECTORLIST      2       /** beam vector listing */
+
+#define XRAN_MAX_NUMPORTC_EXT10     64      /* defined in 5.4.7.10.2 */
+
 /**
  * This structure contains the information to generate the section body of C-Plane message */
 struct xran_section_info {
@@ -209,7 +248,7 @@ struct xran_section_info {
 struct xran_sectionext1_info {
     uint16_t    rbNumber;                   /**< number RBs to ext1 chain */
     uint16_t    bfwNumber;                  /**< number of bf weights in this section */
-    uint8_t     bfwiqWidth;
+    uint8_t     bfwIqWidth;
     uint8_t     bfwCompMeth;
     int16_t     *p_bfwIQ;                   /**< pointer to formed section extention */
     int16_t     bfwIQ_sz;                   /**< size of buffer with section extention information */
@@ -235,7 +274,7 @@ struct xran_sectionext2_info {
     uint8_t     bfZeSI;
     };
 
-struct xran_sectionext3_info {  /* NOT SUPPORTED */
+struct xran_sectionext3_info {
     uint8_t     codebookIdx;
     uint8_t     layerId;
     uint8_t     numLayers;
@@ -243,6 +282,7 @@ struct xran_sectionext3_info {  /* NOT SUPPORTED */
     uint16_t    crsReMask;
     uint8_t     crsShift;
     uint8_t     crsSymNum;
+    uint16_t    numAntPort;     /* number of antenna port - 2 or 4 */
     uint16_t    beamIdAP1;
     uint16_t    beamIdAP2;
     uint16_t    beamIdAP3;
@@ -263,13 +303,84 @@ struct xran_sectionext5_info {
         } mc[XRAN_MAX_MODCOMP_ADDPARMS];
     };
 
+struct xran_sectionext6_info {
+    uint8_t     rbgSize;
+    uint8_t     pad;
+    uint16_t    symbolMask;
+    uint32_t    rbgMask;
+};
+
+struct xran_sectionext7_info {
+    uint16_t    eAxCmask;
+};
+
+struct xran_sectionext8_info {
+    uint16_t    regularizationFactor;
+};
+
+struct xran_sectionext9_info {
+    uint8_t     technology;
+};
+
+struct xran_sectionext10_info {
+    uint8_t     numPortc;
+    uint8_t     beamGrpType;
+    uint16_t    beamID[XRAN_MAX_NUMPORTC_EXT10];
+};
+
+struct xran_sectionext11_info {
+    uint8_t     RAD;
+    uint8_t     disableBFWs;
+
+    uint8_t     numBundPrb;
+    uint8_t     numSetBFWs;     /* Total number of beam forming weights set (L) */
+
+    uint8_t     bfwCompMeth;
+    uint8_t     bfwIqWidth;
+
+    int32_t         totalBfwIQLen;
+    int32_t         maxExtBufSize;  /* Maximum space of external buffer */
+    uint8_t     *pExtBuf;       /* pointer to start of external buffer */
+    void        *pExtBufShinfo; /* Pointer to rte_mbuf_ext_shared_info */
+};
+
+union xran_ext_bfwcompparam_info {
+    uint8_t     exponent;
+//    uint8_t     blockScaler;                /*  Not supported */
+//    uint8_t     compBitWidthShift;          /*  Not supported */
+//    uint8_t     *pActBeamspaceCoeffMask;    /*  Not supported */
+    };
+struct xran_ext11_prbbundle_info {
+    union xran_ext_bfwcompparam_info bfwCompParam;
+    uint16_t    beamId;     /*  15bits, needs to strip MSB */
+    uint16_t    BFWSize;    /*  actual size of bfws in bytes */
+    uint8_t     *pBFWs;     /*  external buffer pointer */
+};
+struct xran_sectionext11_recv_info {
+    uint8_t     RAD;
+    uint8_t     disableBFWs;
+
+    uint8_t     numBundPrb;
+    uint8_t     numSetBFWs;     /* Total number of beam forming weights set (L) */
+
+    uint8_t     bfwCompMeth;
+    uint8_t     bfwIqWidth;
+
+    int32_t         totalBfwIQLen;
+    int32_t         maxExtBufSize;  /* Maximum space of external buffer */
+    uint8_t     *pExtBuf;       /* pointer to start of external buffer */
+    void        *pExtBufShinfo; /* Pointer to rte_mbuf_ext_shared_info */
+
+    /* For parsing */
+    struct xran_ext11_prbbundle_info bundInfo[XRAN_MAX_SET_BFWS];
+};
+
 struct xran_sectionext_info {
     uint16_t    type;
     uint16_t    len;
     void        *data;
     };
 
-
 /**
  * This structure contains the information to generate the section header of C-Plane message */
 struct xran_cp_header_params {
@@ -290,6 +401,13 @@ struct xran_cp_header_params {
     uint16_t    cpLength;   /*  X   X         16bits */
     };
 
+/** The structure for the generation of section extension */
+struct xran_section_ext_gen_info {
+    uint16_t    type;           /**< the type of section extension */
+    uint16_t    len;            /**< length of extension data */
+    void        *data;          /**< pointer to extension data */
+    };
+
 /**
  * This structure to hold the information to generate the sections of C-Plane message */
 struct xran_section_gen_info {
@@ -297,19 +415,9 @@ struct xran_section_gen_info {
 
     uint32_t    exDataSize;         /**< The number of Extensions or type 6/7 data */
     /** the array to store section extension */
-    struct {
-        uint16_t    type;           /**< the type of section extension */
-        uint16_t    len;            /**< length of extension data */
-        void        *data;          /**< pointer to extension data */
-        } exData[XRAN_MAX_NUM_EXTENSIONS];
-    struct xran_sectionext1_info m_ext1[XRAN_MAX_NUM_EXTENSIONS];
-    struct xran_sectionext2_info m_ext2[XRAN_MAX_NUM_EXTENSIONS];
-    struct xran_sectionext3_info m_ext3[XRAN_MAX_NUM_EXTENSIONS];
-    struct xran_sectionext4_info m_ext4[XRAN_MAX_NUM_EXTENSIONS];
-    struct xran_sectionext5_info m_ext5[XRAN_MAX_NUM_EXTENSIONS];
+    struct xran_section_ext_gen_info exData[XRAN_MAX_NUM_EXTENSIONS];
 };
 
-
 /**
  * This structure to hold the information to generate a C-Plane message */
 struct xran_cp_gen_params {
@@ -323,6 +431,45 @@ struct xran_cp_gen_params {
     /**< Array of the section information */
     };
 
+/** The structure to store received section extension */
+struct xran_section_ext_recv_info {
+    uint16_t    type;           /**< the type of section extension */
+    uint16_t    size;
+    union {
+        struct xran_sectionext1_info    ext1;
+        struct xran_sectionext2_info    ext2;
+        struct xran_sectionext3_info    ext3;
+        struct xran_sectionext4_info    ext4;
+        struct xran_sectionext5_info    ext5;
+        struct xran_sectionext6_info    ext6;
+        struct xran_sectionext10_info   ext10;
+        struct xran_sectionext11_recv_info  ext11;
+    } u;
+};
+
+/**
+ * This structure to hold the information of received sections of C-Plane message */
+struct xran_section_recv_info {
+    struct xran_section_info info;  /**< The information for received section */
+
+    int32_t numExts;
+    /** the array to store section extension */
+    struct xran_section_ext_recv_info exts[XRAN_MAX_NUM_EXTENSIONS];
+};
+
+/**
+ * This structure to store received C-Plane message */
+struct xran_cp_recv_params {
+    uint8_t     dir;            /**< UL or DL */
+    uint8_t     sectionType;    /**< each section must have same type with this */
+    uint16_t    numSections;    /**< the number of sections received */
+
+    struct xran_cp_header_params hdr;
+    /**< The information for C-Plane message header */
+    struct xran_section_recv_info *sections;
+    /**< Array of the section information */
+};
+
 /**
  * This structure to hold the information of RB allocation from PHY
  * to send data for allocated RBs only. */
@@ -344,25 +491,28 @@ struct xran_cp_rbmap_list {
     uint8_t     pad0;
     };
 
+typedef struct tagSECTION_DB_TYPE {
+    struct xran_sectioninfo_db* p_sectiondb_elm[XRAN_MAX_SECTIONDB_CTX][XRAN_DIR_MAX][XRAN_COMPONENT_CARRIERS_MAX][XRAN_MAX_ANTENNA_NR * 2 + XRAN_MAX_ANT_ARRAY_ELM_NR];
+} SECTION_DB_TYPE, * PSECTION_DB_TYPE;
 
-uint16_t xran_get_cplength(int cpLength);
-int32_t xran_get_freqoffset(int freqOffset, int scs);
+uint16_t xran_get_cplength(int32_t cpLength);
+int32_t xran_get_freqoffset(int32_t freqOffset, int32_t scs);
 
-int xran_prepare_ctrl_pkt(struct rte_mbuf *mbuf,
+int32_t xran_prepare_ctrl_pkt(struct rte_mbuf *mbuf,
                         struct xran_cp_gen_params *params,
                         uint8_t CC_ID, uint8_t Ant_ID,
                         uint8_t seq_id);
 
-int xran_parse_cp_pkt(struct rte_mbuf *mbuf,
-                    struct xran_cp_gen_params *result,
+int32_t xran_parse_cp_pkt(struct rte_mbuf *mbuf,
+                    struct xran_cp_recv_params *result,
                     struct xran_recv_packet_info *pkt_info);
 
-int xran_cp_init_sectiondb(void *pHandle);
-int xran_cp_free_sectiondb(void *pHandle);
-int xran_cp_add_section_info(void *pHandle,
+int32_t xran_cp_init_sectiondb(void *pHandle);
+int32_t xran_cp_free_sectiondb(void *pHandle);
+int32_t xran_cp_add_section_info(void *pHandle,
         uint8_t dir, uint8_t cc_id, uint8_t ruport_id,
         uint8_t ctx_id, struct xran_section_info *info);
-int xran_cp_add_multisection_info(void *pHandle,
+int32_t xran_cp_add_multisection_info(void *pHandle,
         uint8_t cc_id, uint8_t ruport_id, uint8_t ctx_id,
         struct xran_cp_gen_params *gen_info);
 struct xran_section_info *xran_cp_find_section_info(void *pHandle,
@@ -371,8 +521,9 @@ struct xran_section_info *xran_cp_find_section_info(void *pHandle,
 struct xran_section_info *xran_cp_iterate_section_info(void *pHandle,
         uint8_t dir, uint8_t cc_id, uint8_t ruport_id,
         uint8_t ctx_id, uint32_t *next);
-int xran_cp_getsize_section_info(void *pHandle, uint8_t dir, uint8_t cc_id, uint8_t ruport_id, uint8_t ctx_id);
-int xran_cp_reset_section_info(void *pHandle, uint8_t dir, uint8_t cc_id, uint8_t ruport_id, uint8_t ctx_id);
+
+int32_t xran_cp_getsize_section_info(void *pHandle, uint8_t dir, uint8_t cc_id, uint8_t ruport_id, uint8_t ctx_id);
+int32_t xran_cp_reset_section_info(void *pHandle, uint8_t dir, uint8_t cc_id, uint8_t ruport_id, uint8_t ctx_id);
 int32_t xran_cp_populate_section_ext_1(int8_t  *p_ext1_dst,    /**< destination buffer */
                                        uint16_t  ext1_dst_len, /**< dest buffer size */
                                        int16_t  *p_bfw_iq_src, /**< source buffer of IQs */
@@ -380,6 +531,17 @@ int32_t xran_cp_populate_section_ext_1(int8_t  *p_ext1_dst,    /**< destination
                                        uint16_t  bfwNumber,    /**< number of bf weights in this set of sections */
                                        uint8_t   bfwiqWidth,   /**< bit size of IQs */
                                        uint8_t   bfwCompMeth); /**< compression method */
+struct rte_mbuf *xran_attach_cp_ext_buf(uint16_t vf_id, int8_t* p_ext_buff_start, int8_t* p_ext_buff, uint16_t ext_buff_len,
+                struct rte_mbuf_ext_shared_info * p_share_data);
+int32_t xran_cp_attach_ext_buf(struct rte_mbuf *mbuf, uint8_t *extbuf_start, uint16_t extbuf_len,
+                struct rte_mbuf_ext_shared_info *shinfo);
+int32_t xran_cp_prepare_ext11_bfws(uint8_t numSetBFW, uint8_t numBFW,
+                        uint8_t iqWidth, uint8_t compMeth,
+                        uint8_t *dst, int16_t dst_maxlen,
+                        struct xran_ext11_bfw_info bfwInfo[]);
+int32_t xran_cp_estimate_max_set_bfws(uint8_t numBFWs, uint8_t iqWidth,
+                        uint8_t compMeth, uint16_t mtu);
+
 #ifdef __cplusplus
 }
 #endif