Front Haul Interface Library first seed code contribution
[o-du/phy.git] / fhi_lib / lib / api / xran_pkt_up.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2019 Intel.
4 *
5 *   Licensed under the Apache License, Version 2.0 (the "License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 *
17 *******************************************************************************/
18
19
20 /**
21  * @brief Definitions and support functions to process XRAN packet
22  * @file xran_pkt_up.h
23  * @ingroup group_source_xran
24  * @author Intel Corporation
25  **/
26
27 /**
28  *****************************************************************************
29  * @file xran_pkt_up.h
30  *
31  * @defgroup xran_up_pkt U-Plane XRAN Packet definitions and functions
32  * @ingroup xran
33  *
34  * @description
35  *      Structures relevant to U-plane packets only (data now only)
36  *****************************************************************************/
37 #ifndef _XRAN_PKT_UP_H_
38 #define _XRAN_PKT_UP_H_
39
40 #include "xran_pkt.h"
41
42 #define IQ_PAIR_NUM_IN_RB 12
43 #define MAX_DATA_SECTIONS_NUM 273
44 #define MAX_IQ_BIT_WIDTH 16
45
46 /* currently library supports I and Q sizes of 8 and 16 bits each */
47 #define IQ_BITS MAX_IQ_BIT_WIDTH
48
49 /*
50  * Structure holding data section header fields
51  * It is repeated for every section ID in xRAN packet
52  */
53
54 /**
55  ******************************************************************************
56  * @ingroup xran_up_pkt
57  *
58  * @description
59  *       Structure holding data section header fields
60  *       It is repeated for every section ID in xRAN packet
61  *       5.4.5  Coding of Information Elements - Application Layer, Sections
62  *       for U-plane as per 6.3.2       DL/UL Data
63  *****************************************************************************/
64 struct data_section_hdr {
65     union {
66         uint32_t all_bits;
67         struct {
68             uint32_t     num_prbu:8;    /**< 5.4.5.6 number of contiguous PRBs per control section */
69             uint32_t     start_prbu:10; /**< 5.4.5.4 starting PRB of control section */
70             uint32_t     sym_inc:1;     /**< 5.4.5.3 symbol number increment command XRAN_SYMBOLNUMBER_xxxx */
71             uint32_t     rb:1;          /**< 5.4.5.2 resource block indicator, XRAN_RBIND_xxx */
72             uint32_t     sect_id:12;    /**< 5.4.5.1 section identifier */
73         };
74     }fields;
75     } __attribute__((__packed__));
76
77
78 /*
79  ******************************************************************************
80  * @ingroup xran_up_pkt
81  *
82  * @description
83  *       Structure holds compression header structure and field reserved for future use.
84  *       reserved goes always with udCompHdr in u-plane pkt
85  *       U-plane as per 6.3.2   DL/UL Data
86  *****************************************************************************/
87 struct data_section_compression_hdr
88 {
89     struct compression_hdr ud_comp_hdr;
90     uint8_t rsrvd; /**< This parameter provides 1 byte for future definition,
91     should be set to all zeros by the sender and ignored by the receiver.
92     This field is only present when udCompHdr is present, and is absent when
93     the static IQ format and compression method is configured via the M-Plane */
94
95     /* TODO: support for Block Floating Point compression */
96     /* udCompMeth  0000b = no compression       absent*/
97 };
98
99 /*
100  ******************************************************************************
101  * @ingroup xran_up_pkt
102  *
103  * @description
104  *       Structure holds the compression parameters by the compression header.
105  *       may not be present by udCompMeth in 6.3.3.13
106  *****************************************************************************/
107 union compression_params {
108     struct block_fl_point {
109         uint8_t exponent:4;
110         uint8_t reserved:4;
111         } blockFlPoint;
112     struct block_scaling {
113         uint8_t sblockScaler;
114         } blockScaling;
115     struct u_law {
116         uint8_t compShift:4;
117         uint8_t compBitWidth:4;
118         } uLaw;
119     } __attribute__((__packed__));
120
121
122 /*
123  ******************************************************************************
124  * @ingroup xran_up_pkt
125  *
126  * @description
127  *       Structure holds an IQ sample pair
128  *       U-plane as per 6.3.2   DL/UL Data
129  *       Each bit field size is defined with IQ_BITS macro
130  *       Currently supported I and Q sizes are 8 and 16 bits
131  *****************************************************************************/
132 struct rb_map
133 {
134     int16_t i_sample:IQ_BITS; /**< This parameter is the In-phase sample value */
135     int16_t q_sample:IQ_BITS; /**< This parameter is the Quadrature sample value */
136 } __rte_packed;;
137
138 #endif