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 enum xran_category category, uint8_t ctx_id);
53 int32_t xran_ruemul_init(void *pHandle);
54 int32_t xran_ruemul_release(void *pHandle);
56 static __rte_always_inline uint16_t
57 xran_alloc_sectionid(void *pHandle, uint8_t dir, uint8_t cc_id, uint8_t ant_id, uint8_t slot_id)
60 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
61 print_err("Invalid pHandle - %p", pHandle);
65 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
66 print_err("Invalid CC ID - %d", cc_id);
69 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2 + XRAN_MAX_ANT_ARRAY_ELM_NR) { //for PRACH, ant_id starts from num_ant
70 print_err("Invalid antenna ID - %d", ant_id);
74 /* if new slot has been started,
75 * then initializes section id again for new start */
76 if(xran_section_id_curslot[xran_port][dir][cc_id][ant_id] != slot_id) {
77 xran_section_id[xran_port][dir][cc_id][ant_id] = 0;
78 xran_section_id_curslot[xran_port][dir][cc_id][ant_id] = slot_id;
81 return(xran_section_id[xran_port][dir][cc_id][ant_id]++);
84 static __rte_always_inline uint8_t
85 xran_get_upul_seqid(void *pHandle, uint8_t cc_id, uint8_t ant_id)
88 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
89 print_err("Invalid pHandle - %p", pHandle);
93 if(xran_port >= XRAN_PORTS_NUM) {
94 print_err("Invalid port - %d", xran_port);
98 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
99 print_err("Invalid CC ID - %d", cc_id);
102 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2 + XRAN_MAX_ANT_ARRAY_ELM_NR) {
103 print_err("Invalid antenna ID - %d", ant_id);
107 return(xran_upul_seq_id_num[xran_port][cc_id][ant_id]++);
110 static __rte_always_inline uint8_t*
111 xran_get_upul_seqid_addr(void *pHandle, uint8_t cc_id, uint8_t ant_id)
113 int8_t xran_port = 0;
114 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
115 print_err("Invalid pHandle - %p", pHandle);
119 if(xran_port >= XRAN_PORTS_NUM) {
120 print_err("Invalid port - %d", xran_port);
124 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
125 print_err("Invalid CC ID - %d", cc_id);
128 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2) {
129 print_err("Invalid antenna ID - %d", ant_id);
133 return(&xran_upul_seq_id_num[xran_port][cc_id][ant_id]);
136 static __rte_always_inline int8_t
137 xran_check_cp_seqid(void *pHandle, uint8_t dir, uint8_t cc_id, uint8_t ant_id, uint8_t seq_id)
139 int8_t xran_port = 0;
140 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
141 print_err("Invalid pHandle - %p", pHandle);
145 if(xran_port >= XRAN_PORTS_NUM) {
146 print_err("Invalid port - %d", xran_port);
150 if(dir >= XRAN_DIR_MAX) {
151 print_err("Invalid direction - %d", dir);
154 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
155 print_err("Invalid CC ID - %d", cc_id);
158 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2) {
159 print_err("Invalid antenna ID - %d", ant_id);
163 xran_cp_seq_id_num[xran_port][cc_id][dir][ant_id]++;
164 if(xran_cp_seq_id_num[xran_port][cc_id][dir][ant_id] == seq_id) { /* expected sequence */
168 xran_cp_seq_id_num[xran_port][cc_id][dir][ant_id] = seq_id;
173 static __rte_always_inline int8_t
174 xran_check_updl_seqid(void *pHandle, uint8_t cc_id, uint8_t ant_id, uint8_t slot_id, uint8_t seq_id)
176 int8_t xran_port = 0;
177 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
178 print_err("Invalid pHandle - %p", pHandle);
182 if(xran_port >= XRAN_PORTS_NUM) {
183 print_err("Invalid port - %d", xran_port);
187 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
188 print_err("Invalid CC ID - %d", cc_id);
192 if(ant_id >= XRAN_MAX_ANTENNA_NR) {
193 print_err("Invalid antenna ID - %d", ant_id);
197 /* O-RU needs to check the sequence ID of U-Plane DL from O-DU */
198 xran_updl_seq_id_num[xran_port][cc_id][ant_id]++;
199 if(xran_updl_seq_id_num[xran_port][cc_id][ant_id] == seq_id) {
200 /* expected sequence */
201 /*print_dbg("ant %u cc_id %u : slot_id %u : seq_id %u : expected seq_id %u\n",
202 ant_id, cc_id, slot_id, seq_id, xran_updl_seq_id_num[cc_id][ant_id]);*/
205 /*print_err("[%d] ant %u cc_id %u : slot_id %u : seq_id %u : expected seq_id %u\n",
206 xran_port, ant_id, cc_id, slot_id, seq_id, xran_updl_seq_id_num[xran_port][cc_id][ant_id]);*/
208 xran_updl_seq_id_num[xran_port][cc_id][ant_id] = seq_id;
214 static __rte_always_inline int8_t
215 xran_check_upul_seqid(void *pHandle, uint8_t cc_id, uint8_t ant_id, uint8_t slot_id, uint8_t seq_id)
217 int8_t xran_port = 0;
218 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
219 print_err("Invalid pHandle - %p", pHandle);
223 if(xran_port >= XRAN_PORTS_NUM) {
224 print_err("Invalid port - %d", xran_port);
228 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
229 print_err("Invalid CC ID - %d", cc_id);
233 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2 + XRAN_MAX_ANT_ARRAY_ELM_NR) {
234 print_err("Invalid antenna ID - %d", ant_id);
238 /* O-DU needs to check the sequence ID of U-Plane UL from O-RU */
239 xran_upul_seq_id_num[xran_port][cc_id][ant_id]++;
240 if(xran_upul_seq_id_num[xran_port][cc_id][ant_id] == seq_id) { /* expected sequence */
241 return (XRAN_STATUS_SUCCESS);
243 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);
244 xran_upul_seq_id_num[xran_port][cc_id][ant_id] = seq_id; // for next
249 static __rte_always_inline uint8_t*
250 xran_get_updl_seqid_addr(void *pHandle, uint8_t cc_id, uint8_t ant_id)
252 int8_t xran_port = 0;
253 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
254 print_err("Invalid pHandle - %p", pHandle);
258 if(xran_port >= XRAN_PORTS_NUM) {
259 print_err("Invalid port - %d", xran_port);
263 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
264 print_err("Invalid CC ID - %d", cc_id);
267 if(ant_id >= XRAN_MAX_ANTENNA_NR) {
268 print_err("Invalid antenna ID - %d", ant_id);
272 /* Only U-Plane DL needs to get sequence ID in O-DU */
273 return(&xran_updl_seq_id_num[xran_port][cc_id][ant_id]);
276 static __rte_always_inline uint8_t
277 xran_get_cp_seqid(void *pHandle, uint8_t dir, uint8_t cc_id, uint8_t ant_id)
279 int8_t xran_port = 0;
280 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
281 print_err("Invalid pHandle - %p", pHandle);
285 if(xran_port >= XRAN_PORTS_NUM) {
286 print_err("Invalid port - %d", xran_port);
290 if(dir >= XRAN_DIR_MAX) {
291 print_err("Invalid direction - %d", dir);
294 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
295 print_err("Invalid CC ID - %d", cc_id);
298 if(ant_id >= XRAN_MAX_ANTENNA_NR * 2 + XRAN_MAX_ANT_ARRAY_ELM_NR) {
299 print_err("Invalid antenna ID - %d", ant_id);
303 return(xran_cp_seq_id_num[xran_port][cc_id][dir][ant_id]++);
306 static __rte_always_inline uint8_t
307 xran_get_updl_seqid(void *pHandle, uint8_t cc_id, uint8_t ant_id)
309 int8_t xran_port = 0;
310 if((xran_port = xran_dev_ctx_get_port_id(pHandle)) < 0 ){
311 print_err("Invalid pHandle - %p", pHandle);
315 if(xran_port >= XRAN_PORTS_NUM) {
316 print_err("Invalid port - %d", xran_port);
319 if(cc_id >= XRAN_MAX_CELLS_PER_PORT) {
320 print_err("Invalid CC ID - %d", cc_id);
323 if(ant_id >= XRAN_MAX_ANTENNA_NR) {
324 print_err("Invalid antenna ID - %d", ant_id);
328 /* Only U-Plane DL needs to get sequence ID in O-DU */
329 return(xran_updl_seq_id_num[xran_port][cc_id][ant_id]++);
336 #endif /* _XRAN_CP_PROC_H_ */