588d3e1d7fb0434b501e22112b43e72939def5d8
[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 } __rte_packed;
79
80
81 /*
82  ******************************************************************************
83  * @ingroup xran_up_pkt
84  *
85  * @description
86  *       Structure holds compression header structure and field reserved for future use.
87  *       reserved goes always with udCompHdr in u-plane pkt
88  *       U-plane as per 6.3.2   DL/UL Data
89  *****************************************************************************/
90 struct data_section_compression_hdr
91 {
92     struct compression_hdr ud_comp_hdr;
93     uint8_t rsrvd; /**< This parameter provides 1 byte for future definition,
94     should be set to all zeros by the sender and ignored by the receiver.
95     This field is only present when udCompHdr is present, and is absent when
96     the static IQ format and compression method is configured via the M-Plane */
97
98     /* TODO: support for Block Floating Point compression */
99     /* udCompMeth  0000b = no compression       absent*/
100 };
101
102 /*
103  ******************************************************************************
104  * @ingroup xran_up_pkt
105  *
106  * @description
107  *       Structure holds the compression parameters by the compression header.
108  *       may not be present by udCompMeth in 6.3.3.13
109  *****************************************************************************/
110 union compression_params {
111     struct block_fl_point {
112         uint8_t exponent:4;
113         uint8_t reserved:4;
114         } blockFlPoint;
115     struct block_scaling {
116         uint8_t sblockScaler;
117         } blockScaling;
118     struct u_law {
119         uint8_t compShift:4;
120         uint8_t compBitWidth:4;
121         } uLaw;
122 } __rte_packed;
123
124
125 /*
126  ******************************************************************************
127  * @ingroup xran_up_pkt
128  *
129  * @description
130  *       Structure holds an IQ sample pair
131  *       U-plane as per 6.3.2   DL/UL Data
132  *       Each bit field size is defined with IQ_BITS macro
133  *       Currently supported I and Q sizes are 8 and 16 bits
134  *****************************************************************************/
135 struct rb_map
136 {
137     int16_t i_sample:IQ_BITS; /**< This parameter is the In-phase sample value */
138     int16_t q_sample:IQ_BITS; /**< This parameter is the Quadrature sample value */
139 } __rte_packed;
140
141 /**
142  ******************************************************************************
143  * @ingroup xran_common_pkt
144  *
145  * @description
146  *       Structure holds complete xran u-plane packet header
147  *       3.1.1  Ethernet Encapsulation
148  *****************************************************************************/
149 struct xran_up_pkt_hdr
150 {
151     struct xran_ecpri_hdr ecpri_hdr; /**< eCPRI Transport Header */
152     struct radio_app_common_hdr app_hdr; /**< eCPRI Transport Header */
153     struct data_section_hdr data_sec_hdr;
154 } __rte_packed;
155
156
157 /**
158  ******************************************************************************
159  * @ingroup xran_common_pkt
160  *
161  * @description
162  *       Structure holds complete ethernet and xran u-plane packet header
163  *       3.1.1  Ethernet Encapsulation
164  *****************************************************************************/
165 struct eth_xran_up_pkt_hdr
166 {
167     struct ether_hdr eth_hdr;
168     struct xran_up_pkt_hdr xran_hdr;
169 }__rte_packed;
170
171 #ifdef __cplusplus
172 }
173 #endif
174
175 #endif