Update to odulow per maintenance bronze
[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  * @brief Definitions and support functions to process XRAN packet
21  * @file xran_pkt_up.h
22  * @ingroup group_source_xran
23  * @author Intel Corporation
24  **/
25
26 /**
27  *****************************************************************************
28  * @file xran_pkt_up.h
29  *
30  * @defgroup xran_up_pkt U-Plane XRAN Packet definitions and functions
31  * @ingroup xran
32  *
33  * @description
34  *      Structures relevant to U-plane packets only (data now only)
35  *****************************************************************************/
36 #ifndef _XRAN_PKT_UP_H_
37 #define _XRAN_PKT_UP_H_
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 #include "xran_pkt.h"
44
45 #define IQ_PAIR_NUM_IN_RB 12
46 #define MAX_DATA_SECTIONS_NUM 273
47 #define MAX_IQ_BIT_WIDTH 16
48
49 /* currently library supports I and Q sizes of 8 and 16 bits each */
50 #define IQ_BITS MAX_IQ_BIT_WIDTH
51
52 /*
53  * Structure holding data section header fields
54  * It is repeated for every section ID in xRAN packet
55  */
56
57 /**
58  ******************************************************************************
59  * @ingroup xran_up_pkt
60  *
61  * @description
62  *       Structure holding data section header fields
63  *       It is repeated for every section ID in xRAN packet
64  *       5.4.5  Coding of Information Elements - Application Layer, Sections
65  *       for U-plane as per 6.3.2       DL/UL Data
66  *****************************************************************************/
67 struct data_section_hdr {
68     union {
69         uint32_t all_bits;
70         struct {
71             uint32_t     num_prbu:8;    /**< 5.4.5.6 number of contiguous PRBs per control section */
72             uint32_t     start_prbu:10; /**< 5.4.5.4 starting PRB of control section */
73             uint32_t     sym_inc:1;     /**< 5.4.5.3 symbol number increment command XRAN_SYMBOLNUMBER_xxxx */
74             uint32_t     rb:1;          /**< 5.4.5.2 resource block indicator, XRAN_RBIND_xxx */
75             uint32_t     sect_id:12;    /**< 5.4.5.1 section identifier */
76         };
77     }fields;
78 #ifdef FCN_ADAPT
79         uint8_t udCompHdr;
80         uint8_t reserved;
81 #endif
82 } __rte_packed;
83
84
85 /*
86  ******************************************************************************
87  * @ingroup xran_up_pkt
88  *
89  * @description
90  *       Structure holds compression header structure and field reserved for future use.
91  *       reserved goes always with udCompHdr in u-plane pkt
92  *       U-plane as per 6.3.2   DL/UL Data
93  *****************************************************************************/
94 struct data_section_compression_hdr
95 {
96     struct compression_hdr ud_comp_hdr;
97     uint8_t rsrvd; /**< This parameter provides 1 byte for future definition,
98     should be set to all zeros by the sender and ignored by the receiver.
99     This field is only present when udCompHdr is present, and is absent when
100     the static IQ format and compression method is configured via the M-Plane */
101
102     /* TODO: support for Block Floating Point compression */
103     /* udCompMeth  0000b = no compression       absent*/
104 };
105
106 /*
107  ******************************************************************************
108  * @ingroup xran_up_pkt
109  *
110  * @description
111  *       Structure holds the compression parameters by the compression header.
112  *       may not be present by udCompMeth in 6.3.3.13
113  *****************************************************************************/
114 union compression_params {
115     struct block_fl_point {
116         uint8_t exponent:4;
117         uint8_t reserved:4;
118         } blockFlPoint;
119     struct block_scaling {
120         uint8_t sblockScaler;
121         } blockScaling;
122     struct u_law {
123         uint8_t compShift:4;
124         uint8_t compBitWidth:4;
125         } uLaw;
126 } __rte_packed;
127
128
129 /*
130  ******************************************************************************
131  * @ingroup xran_up_pkt
132  *
133  * @description
134  *       Structure holds an IQ sample pair
135  *       U-plane as per 6.3.2   DL/UL Data
136  *       Each bit field size is defined with IQ_BITS macro
137  *       Currently supported I and Q sizes are 8 and 16 bits
138  *****************************************************************************/
139 struct rb_map
140 {
141     int16_t i_sample:IQ_BITS; /**< This parameter is the In-phase sample value */
142     int16_t q_sample:IQ_BITS; /**< This parameter is the Quadrature sample value */
143 } __rte_packed;
144
145 /**
146  ******************************************************************************
147  * @ingroup xran_common_pkt
148  *
149  * @description
150  *       Structure holds complete xran u-plane packet header
151  *       3.1.1  Ethernet Encapsulation
152  *****************************************************************************/
153 struct xran_up_pkt_hdr
154 {
155     struct xran_ecpri_hdr ecpri_hdr; /**< eCPRI Transport Header */
156     struct radio_app_common_hdr app_hdr; /**< eCPRI Transport Header */
157     struct data_section_hdr data_sec_hdr;
158 } __rte_packed;
159
160
161 /**
162  ******************************************************************************
163  * @ingroup xran_common_pkt
164  *
165  * @description
166  *       Structure holds complete ethernet and xran u-plane packet header
167  *       3.1.1  Ethernet Encapsulation
168  *****************************************************************************/
169 struct eth_xran_up_pkt_hdr
170 {
171     struct rte_ether_hdr eth_hdr;
172     struct xran_up_pkt_hdr xran_hdr;
173 }__rte_packed;
174
175 #ifdef __cplusplus
176 }
177 #endif
178
179 #endif