1 /******************************************************************************
3 * Copyright (c) 2020 Intel.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 *******************************************************************************/
20 * @brief XRAN C-plane processing module header file
21 * @file xran_cp_proc.h
22 * @ingroup group_source_xran
23 * @author Intel Corporation
26 #ifndef _XRAN_CP_PROC_H_
27 #define _XRAN_CP_PROC_H_
36 #include <rte_common.h>
38 #include "xran_fh_o_du.h"
39 #include "xran_printf.h"
41 extern uint8_t xran_cp_seq_id_num[XRAN_PORTS_NUM][XRAN_MAX_CELLS_PER_PORT][XRAN_DIR_MAX][XRAN_MAX_ANTENNA_NR * 2 + XRAN_MAX_ANT_ARRAY_ELM_NR];
42 extern uint8_t xran_updl_seq_id_num[XRAN_PORTS_NUM][XRAN_MAX_CELLS_PER_PORT][XRAN_MAX_ANTENNA_NR];
43 extern uint8_t xran_upul_seq_id_num[XRAN_PORTS_NUM][XRAN_MAX_CELLS_PER_PORT][XRAN_MAX_ANTENNA_NR * 2 + XRAN_MAX_ANT_ARRAY_ELM_NR];
44 extern uint8_t xran_section_id_curslot[XRAN_PORTS_NUM][XRAN_DIR_MAX][XRAN_MAX_CELLS_PER_PORT][XRAN_MAX_ANTENNA_NR * 2+ XRAN_MAX_ANT_ARRAY_ELM_NR];
45 extern uint16_t xran_section_id[XRAN_PORTS_NUM][XRAN_DIR_MAX][XRAN_MAX_CELLS_PER_PORT][XRAN_MAX_ANTENNA_NR * 2+ XRAN_MAX_ANT_ARRAY_ELM_NR];
47 int32_t xran_init_sectionid(void *pHandle);
48 int32_t xran_init_seqid(void *pHandle);
50 int32_t process_cplane(struct rte_mbuf *pkt, void* handle);
51 int32_t xran_cp_create_and_send_section(void *pHandle, uint8_t ru_port_id, int dir, int tti, int cc_id, struct xran_prb_map *prbMap,
52 struct xran_prb_elm_proc_info_t *prbElmProcInfo,
53 enum xran_category category, uint8_t ctx_id);
55 int32_t xran_ruemul_init(void *pHandle);
56 int32_t xran_ruemul_release(void *pHandle);
58 #define ONE_EXT_LEN(prbMap) (prbMap->bf_weight.ext_section_sz / prbMap->bf_weight.numSetBFWs) - sizeof(struct xran_cp_radioapp_section1)
59 #define ONE_CPSEC_EXT_LEN(prbMap) (prbMap->bf_weight.ext_section_sz / prbMap->bf_weight.numSetBFWs)
61 static __rte_always_inline uint16_t
62 xran_alloc_sectionid(void *pHandle, uint8_t dir, uint8_t cc_id, uint8_t ant_id, uint8_t subframe_id, uint8_t slot_id)
65 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
66 print_err("Invalid pHandle - %p", pHandle);
70 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
71 print_err("Invalid CC ID - %d", cc_id);
74 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2 + XRAN_MAX_ANT_ARRAY_ELM_NR) { //for PRACH, ant_id starts from num_ant
75 print_err("Invalid antenna ID - %d", ant_id);
79 /* if new slot has been started,
80 * then initializes section id again for new start */
81 if(xran_section_id_curslot[xran_port][dir][cc_id][ant_id] != (subframe_id * 2 + slot_id)) {
82 xran_section_id[xran_port][dir][cc_id][ant_id] = 0;
83 xran_section_id_curslot[xran_port][dir][cc_id][ant_id] = (subframe_id * 2 + slot_id);
86 return(xran_section_id[xran_port][dir][cc_id][ant_id]++);
89 static __rte_always_inline uint8_t
90 xran_get_upul_seqid(void *pHandle, uint8_t cc_id, uint8_t ant_id)
93 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
94 print_err("Invalid pHandle - %p", pHandle);
98 if(xran_port >= XRAN_PORTS_NUM) {
99 print_err("Invalid port - %d", xran_port);
103 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
104 print_err("Invalid CC ID - %d", cc_id);
107 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2 + XRAN_MAX_ANT_ARRAY_ELM_NR) {
108 print_err("Invalid antenna ID - %d", ant_id);
112 return(xran_upul_seq_id_num[xran_port][cc_id][ant_id]++);
115 static __rte_always_inline uint8_t*
116 xran_get_upul_seqid_addr(void *pHandle, uint8_t cc_id, uint8_t ant_id)
118 int8_t xran_port = 0;
119 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
120 print_err("Invalid pHandle - %p", pHandle);
124 if(xran_port >= XRAN_PORTS_NUM) {
125 print_err("Invalid port - %d", xran_port);
129 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
130 print_err("Invalid CC ID - %d", cc_id);
133 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2) {
134 print_err("Invalid antenna ID - %d", ant_id);
138 return(&xran_upul_seq_id_num[xran_port][cc_id][ant_id]);
141 static __rte_always_inline int8_t
142 xran_check_cp_seqid(void *pHandle, uint8_t dir, uint8_t cc_id, uint8_t ant_id, uint8_t seq_id)
144 int8_t xran_port = 0;
145 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
146 print_err("Invalid pHandle - %p", pHandle);
150 if(xran_port >= XRAN_PORTS_NUM) {
151 print_err("Invalid port - %d", xran_port);
155 if(dir >= XRAN_DIR_MAX) {
156 print_err("Invalid direction - %d", dir);
159 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
160 print_err("Invalid CC ID - %d", cc_id);
163 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2) {
164 print_err("Invalid antenna ID - %d", ant_id);
168 xran_cp_seq_id_num[xran_port][cc_id][dir][ant_id]++;
169 if(xran_cp_seq_id_num[xran_port][cc_id][dir][ant_id] == seq_id) { /* expected sequence */
173 xran_cp_seq_id_num[xran_port][cc_id][dir][ant_id] = seq_id;
178 static __rte_always_inline int8_t
179 xran_check_updl_seqid(void *pHandle, uint8_t cc_id, uint8_t ant_id, uint8_t slot_id, uint8_t seq_id)
181 int8_t xran_port = 0;
182 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
183 print_err("Invalid pHandle - %p", pHandle);
187 if(xran_port >= XRAN_PORTS_NUM) {
188 print_err("Invalid port - %d", xran_port);
192 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
193 print_err("Invalid CC ID - %d", cc_id);
197 if(ant_id >= XRAN_MAX_ANTENNA_NR) {
198 print_err("Invalid antenna ID - %d", ant_id);
202 /* O-RU needs to check the sequence ID of U-Plane DL from O-DU */
203 xran_updl_seq_id_num[xran_port][cc_id][ant_id]++;
204 if(xran_updl_seq_id_num[xran_port][cc_id][ant_id] == seq_id) {
205 /* expected sequence */
206 /*print_dbg("ant %u cc_id %u : slot_id %u : seq_id %u : expected seq_id %u\n",
207 ant_id, cc_id, slot_id, seq_id, xran_updl_seq_id_num[cc_id][ant_id]);*/
210 /*print_err("[%d] ant %u cc_id %u : slot_id %u : seq_id %u : expected seq_id %u\n",
211 xran_port, ant_id, cc_id, slot_id, seq_id, xran_updl_seq_id_num[xran_port][cc_id][ant_id]);*/
213 xran_updl_seq_id_num[xran_port][cc_id][ant_id] = seq_id;
219 static __rte_always_inline int8_t
220 xran_check_upul_seqid(void *pHandle, uint8_t cc_id, uint8_t ant_id, uint8_t slot_id, uint8_t seq_id)
222 int8_t xran_port = 0;
223 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
224 print_err("Invalid pHandle - %p", pHandle);
228 if(xran_port >= XRAN_PORTS_NUM) {
229 print_err("Invalid port - %d", xran_port);
233 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
234 print_err("Invalid CC ID - %d", cc_id);
238 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2 + XRAN_MAX_ANT_ARRAY_ELM_NR) {
239 print_err("Invalid antenna ID - %d", ant_id);
243 /* O-DU needs to check the sequence ID of U-Plane UL from O-RU */
244 xran_upul_seq_id_num[xran_port][cc_id][ant_id]++;
245 if(xran_upul_seq_id_num[xran_port][cc_id][ant_id] == seq_id) { /* expected sequence */
246 return (XRAN_STATUS_SUCCESS);
248 print_dbg("[%d]expected seqid %u received %u, slot %u, ant %u cc %u", xran_port, xran_upul_seq_id_num[xran_port][cc_id][ant_id], seq_id, slot_id, ant_id, cc_id);
249 xran_upul_seq_id_num[xran_port][cc_id][ant_id] = seq_id; // for next
254 static __rte_always_inline uint8_t*
255 xran_get_updl_seqid_addr(void *pHandle, uint8_t cc_id, uint8_t ant_id)
257 int8_t xran_port = 0;
258 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
259 print_err("Invalid pHandle - %p", pHandle);
263 if(xran_port >= XRAN_PORTS_NUM) {
264 print_err("Invalid port - %d", xran_port);
268 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
269 print_err("Invalid CC ID - %d", cc_id);
272 if(ant_id >= XRAN_MAX_ANTENNA_NR) {
273 print_err("Invalid antenna ID - %d", ant_id);
277 /* Only U-Plane DL needs to get sequence ID in O-DU */
278 return(&xran_updl_seq_id_num[xran_port][cc_id][ant_id]);
281 static __rte_always_inline uint8_t
282 xran_get_cp_seqid(void *pHandle, uint8_t dir, uint8_t cc_id, uint8_t ant_id)
284 int8_t xran_port = 0;
285 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
286 print_err("Invalid pHandle - %p", pHandle);
290 if(xran_port >= XRAN_PORTS_NUM) {
291 print_err("Invalid port - %d", xran_port);
295 if(dir >= XRAN_DIR_MAX) {
296 print_err("Invalid direction - %d", dir);
299 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
300 print_err("Invalid CC ID - %d", cc_id);
303 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2 + XRAN_MAX_ANT_ARRAY_ELM_NR) {
304 print_err("Invalid antenna ID - %d", ant_id);
308 return(xran_cp_seq_id_num[xran_port][cc_id][dir][ant_id]++);
311 static __rte_always_inline uint8_t
312 xran_get_updl_seqid(void *pHandle, uint8_t cc_id, uint8_t ant_id)
314 int8_t xran_port = 0;
315 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
316 print_err("Invalid pHandle - %p", pHandle);
320 if(xran_port >= XRAN_PORTS_NUM) {
321 print_err("Invalid port - %d", xran_port);
324 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
325 print_err("Invalid CC ID - %d", cc_id);
328 if(ant_id >= XRAN_MAX_ANTENNA_NR) {
329 print_err("Invalid antenna ID - %d", ant_id);
333 /* Only U-Plane DL needs to get sequence ID in O-DU */
334 return(xran_updl_seq_id_num[xran_port][cc_id][ant_id]++);
341 #endif /* _XRAN_CP_PROC_H_ */