Front Haul Interface Library first seed code contribution
[o-du/phy.git] / fhi_lib / lib / api / xran_up_api.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 This file provides the definitions for User Plane Messages APIs.
22  *
23  * @file xran_up_api.h
24  * @ingroup group_lte_source_xran
25  * @author Intel Corporation
26  *
27  **/
28
29 #ifndef _XRAN_UP_API_H_
30 #define _XRAN_UP_API_H_
31
32 #include <rte_common.h>
33 #include <rte_mbuf.h>
34
35 #include "xran_pkt.h"
36 #include "xran_pkt_up.h"
37
38 #define XRAN_BYTE_ORDER_SWAP
39
40 /*
41  * structure used for storing packet parameters needed for generating
42  * a data packet
43  */
44 struct xran_up_pkt_gen_params
45 {
46     struct radio_app_common_hdr app_params;
47     struct data_section_hdr sec_hdr;
48     struct data_section_compression_hdr compr_hdr_param;
49     union compression_params compr_param;
50 };
51
52 /*
53  * structure used for storing packet parameters needed for generating
54  * a data packet without compression
55  *   Next fields are omitted:
56  *        udCompHdr (not always present)
57  *        reserved (not always present)
58  *        udCompParam (not always present)
59  */
60 struct xran_up_pkt_gen_no_compression_params
61 {
62     struct radio_app_common_hdr app_params;
63     struct data_section_hdr sec_hdr;
64 };
65
66
67 /**
68  * @brief Function that is preparing an mbuf with portion of IQ samples related
69  *        to the single symbol.
70  *
71  * @param mbuf Initialized rte_mbuf packet
72  * @param iq_data_start Address of the first element in IQ data array.
73  * @param iq_data_num_elements Size of the IQ data array.
74  * @param iq_data_offset IQ data array's elements already sent.
75  * @param alignment Align data to this many bytes.
76  * @param params Structure containing Radio App Header and Data Section Header
77  *               structures.
78  * @return int Bytes of IQ samples that have been appended to the packet.
79  */
80 int xran_prepare_iq_symbol_portion(
81     struct rte_mbuf *mbuf,
82     const void *iq_data_start,
83     const uint32_t iq_data_num_bytes,
84     uint32_t *iq_data_offset,
85     const uint8_t alignment,
86     struct xran_up_pkt_gen_params *params,
87     int sub_seq_id);
88
89 /**
90  * @brief Function extracts IQ samples from received mbuf packet.
91  *
92  * @param mbuf Packet with received data.
93  * @param iq_data_start Address of the first IQ sample in mbuf will be returned
94  *                      here
95  * @return int Bytes of IQ samples that have been extracted from mbuf.
96  */
97 int xran_extract_iq_samples(struct rte_mbuf *mbuf,
98     void **iq_data_start,
99     uint8_t *CC_ID,
100     uint8_t *Ant_ID,
101     uint8_t *frame_id,
102     uint8_t *subframe_id,
103     uint8_t *slot_id,
104     uint8_t *symb_id,
105     struct ecpri_seq_id *seq_id);
106
107 int xran_prepare_iq_symbol_portion_no_comp(
108                         struct rte_mbuf *mbuf,
109                         const void *iq_data_start,
110                         const uint32_t iq_data_num_bytes,
111                         struct xran_up_pkt_gen_no_compression_params *params,
112                         uint8_t CC_ID,
113                         uint8_t Ant_ID,
114                         uint8_t seq_id);
115
116 #endif /* _XRAN_UP_API_H_ */