d72f27aa37d6e9bb2b35afd3e5bfeea3e7c60489
[o-du/phy.git] / fhi_lib / lib / src / xran_common.c
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 XRAN layer common functionality for both lls-CU and RU as well as C-plane and
21  *    U-plane
22  * @file xran_common.c
23  * @ingroup group_source_xran
24  * @author Intel Corporation
25  **/
26
27 #include <assert.h>
28 #include <err.h>
29 #include <arpa/inet.h>
30 #include <sys/time.h>
31 #include <time.h>
32
33 #include "xran_common.h"
34 #include "ethdi.h"
35 #include "xran_pkt.h"
36 #include "xran_pkt_up.h"
37 #include "xran_up_api.h"
38 #include "xran_lib_mlog_tasks_id.h"
39
40 #include "../src/xran_printf.h"
41 #include <rte_mbuf.h>
42 #include "xran_mlog_lnx.h"
43
44 #define MBUFS_CNT 16
45
46 extern long interval_us;
47
48 extern int xran_process_rx_sym(void *arg,
49                         struct rte_mbuf *mbuf,
50                         void *iq_data_start,
51                         uint16_t size,
52                         uint8_t CC_ID,
53                         uint8_t Ant_ID,
54                         uint8_t frame_id,
55                         uint8_t subframe_id,
56                         uint8_t slot_id,
57                         uint8_t symb_id,
58                         uint16_t num_prbu,
59                         uint16_t start_prbu,
60                         uint16_t sym_inc,
61                         uint16_t rb,
62                         uint16_t sect_id,
63                         uint32_t *mb_free);
64
65
66 extern int xran_process_prach_sym(void *arg,
67                         struct rte_mbuf *mbuf,
68                         void *iq_data_start,
69                         uint16_t size,
70                         uint8_t CC_ID,
71                         uint8_t Ant_ID,
72                         uint8_t frame_id,
73                         uint8_t subframe_id,
74                         uint8_t slot_id,
75                         uint8_t symb_id,
76                         uint16_t num_prbu,
77                         uint16_t start_prbu,
78                         uint16_t sym_inc,
79                         uint16_t rb,
80                         uint16_t sect_id);
81
82 extern int32_t xran_pkt_validate(void *arg,
83                         struct rte_mbuf *mbuf,
84                         void *iq_data_start,
85                         uint16_t size,
86                         uint8_t CC_ID,
87                         uint8_t Ant_ID,
88                         uint8_t frame_id,
89                         uint8_t subframe_id,
90                         uint8_t slot_id,
91                         uint8_t symb_id,
92                         struct ecpri_seq_id *seq_id,
93                         uint16_t num_prbu,
94                         uint16_t start_prbu,
95                         uint16_t sym_inc,
96                         uint16_t rb,
97                         uint16_t sect_id);
98
99 long rx_counter = 0;
100 long tx_counter = 0;
101
102 int process_mbuf(struct rte_mbuf *pkt)
103 {
104     void *iq_samp_buf;
105     struct ecpri_seq_id seq;
106     static int symbol_total_bytes = 0;
107     int num_bytes = 0;
108     struct xran_device_ctx * p_x_ctx = xran_dev_get_ctx();
109
110     uint8_t CC_ID = 0;
111     uint8_t Ant_ID = 0;
112     uint8_t frame_id = 0;
113     uint8_t subframe_id = 0;
114     uint8_t slot_id = 0;
115     uint8_t symb_id = 0;
116
117     uint16_t num_prbu;
118     uint16_t start_prbu;
119     uint16_t sym_inc;
120     uint16_t rb;
121     uint16_t sect_id;
122     void *pHandle = NULL;
123     uint8_t num_eAxc = xran_get_num_eAxc(pHandle);
124     int ret = MBUF_FREE;
125     uint32_t mb_free = 0;
126     int32_t valid_res = 0;
127
128
129     if(p_x_ctx->xran2phy_mem_ready == 0)
130         return MBUF_FREE;
131
132     num_bytes = xran_extract_iq_samples(pkt,
133                                         &iq_samp_buf,
134                                         &CC_ID,
135                                         &Ant_ID,
136                                         &frame_id,
137                                         &subframe_id,
138                                         &slot_id,
139                                         &symb_id,
140                                         &seq,
141                                         &num_prbu,
142                                         &start_prbu,
143                                         &sym_inc,
144                                         &rb,
145                                         &sect_id);
146
147     if (num_bytes <= 0){
148         print_err("num_bytes is wrong [%d]\n", num_bytes);
149         return MBUF_FREE;
150     }
151
152     valid_res = xran_pkt_validate(NULL,
153                                 pkt,
154                                 iq_samp_buf,
155                                 num_bytes,
156                                 CC_ID,
157                                 Ant_ID,
158                                 frame_id,
159                                 subframe_id,
160                                 slot_id,
161                                 symb_id,
162                                 &seq,
163                                 num_prbu,
164                                 start_prbu,
165                                 sym_inc,
166                                 rb,
167                                 sect_id);
168
169     if(valid_res != 0) {
170         print_err("valid_res is wrong [%d] ant %u (%u : %u : %u : %u) seq %u num_bytes %d\n", valid_res, Ant_ID, frame_id, subframe_id, slot_id, symb_id, seq.seq_id, num_bytes);
171         return MBUF_FREE;
172     }
173
174     if (Ant_ID >= num_eAxc && p_x_ctx->fh_init.prachEnable) // PRACH packet has ruportid = num_eAxc + ant_id
175     {
176         Ant_ID -= num_eAxc;
177         if (seq.e_bit == 1) {
178
179             print_dbg("Completed receiving PRACH symbol %d, size=%d bytes\n",
180                 symb_id, num_bytes);
181
182                 xran_process_prach_sym(NULL,
183                                 pkt,
184                                 iq_samp_buf,
185                                 num_bytes,
186                                 CC_ID,
187                                 Ant_ID,
188                                 frame_id,
189                                 subframe_id,
190                                 slot_id,
191                                 symb_id,
192                                 num_prbu,
193                                 start_prbu,
194                                 sym_inc,
195                                 rb,
196                                 sect_id);
197         }
198         else {
199             print_dbg("Transport layer fragmentation (eCPRI) is not supported\n");
200         }
201     } else {
202         symbol_total_bytes += num_bytes;
203
204         if (seq.e_bit == 1) {
205             print_dbg("Completed receiving symbol %d, size=%d bytes\n",
206                 symb_id, symbol_total_bytes);
207
208             if (symbol_total_bytes){
209                 int res = xran_process_rx_sym(NULL,
210                                 pkt,
211                                 iq_samp_buf,
212                                 symbol_total_bytes,
213                                 CC_ID,
214                                 Ant_ID,
215                                 frame_id,
216                                 subframe_id,
217                                 slot_id,
218                                 symb_id,
219                                 num_prbu,
220                                 start_prbu,
221                                 sym_inc,
222                                 rb,
223                                 sect_id,
224                                 &mb_free);
225                 if(res == symbol_total_bytes)
226                     ret  = mb_free;
227                 else
228                     print_err("res != symbol_total_bytes\n");
229             }
230             symbol_total_bytes = 0;
231         }
232         else {
233             print_dbg("Transport layer fragmentation (eCPRI) is not supported\n");
234         }
235     }
236
237     return ret;
238 }
239
240 static int set_iq_bit_width(uint8_t iq_bit_width, struct data_section_compression_hdr *compr_hdr)
241 {
242     if (iq_bit_width == MAX_IQ_BIT_WIDTH)
243         compr_hdr->ud_comp_hdr.ud_iq_width = (uint8_t) 0;
244     else
245         compr_hdr->ud_comp_hdr.ud_iq_width = iq_bit_width;
246
247     return  0;
248
249 }
250
251 /* Send a single 5G symbol over multiple packets */
252 int32_t prepare_symbol_ex(enum xran_pkt_dir direction,
253                 uint16_t section_id,
254                 struct rte_mbuf *mb,
255                 struct rb_map *data,
256                 const enum xran_input_byte_order iq_buf_byte_order,
257                 uint8_t frame_id,
258                 uint8_t subframe_id,
259                 uint8_t slot_id,
260                 uint8_t symbol_no,
261                 int prb_start,
262                 int prb_num,
263                 uint8_t CC_ID,
264                 uint8_t RU_Port_ID,
265                 uint8_t seq_id,
266                 uint32_t do_copy)
267 {
268     int32_t n_bytes = ((prb_num == 0) ? MAX_N_FULLBAND_SC : prb_num) * N_SC_PER_PRB * sizeof(struct rb_map);
269
270     int32_t prep_bytes;
271
272     int16_t nPktSize = sizeof(struct ether_hdr) + sizeof(struct xran_ecpri_hdr) +
273             sizeof(struct radio_app_common_hdr)+ sizeof(struct data_section_hdr) + n_bytes;
274     uint32_t off;
275     struct xran_up_pkt_gen_no_compression_params xp = { 0 };
276
277     n_bytes = RTE_MIN(n_bytes, XRAN_MAX_MBUF_LEN);
278
279     /* radio app header */
280     xp.app_params.data_direction = direction;
281     xp.app_params.payl_ver       = 1;
282     xp.app_params.filter_id      = 0;
283     xp.app_params.frame_id       = frame_id;
284     xp.app_params.sf_slot_sym.subframe_id    = subframe_id;
285     xp.app_params.sf_slot_sym.slot_id        = slot_id;
286     xp.app_params.sf_slot_sym.symb_id        = symbol_no;
287
288     /* convert to network byte order */
289     xp.app_params.sf_slot_sym.value = rte_cpu_to_be_16(xp.app_params.sf_slot_sym.value);
290
291     xp.sec_hdr.fields.sect_id    = section_id;
292     xp.sec_hdr.fields.num_prbu   = (uint8_t)prb_num;
293     xp.sec_hdr.fields.start_prbu = (uint8_t)prb_start;
294     xp.sec_hdr.fields.sym_inc    = 0;
295     xp.sec_hdr.fields.rb         = 0;
296
297     /* network byte order */
298     xp.sec_hdr.fields.all_bits  = rte_cpu_to_be_32(xp.sec_hdr.fields.all_bits);
299
300     if (mb == NULL){
301         MLogPrint(NULL);
302         errx(1, "out of mbufs after %d packets", 1);
303     }
304
305     prep_bytes = xran_prepare_iq_symbol_portion_no_comp(mb,
306                                                   data,
307                                                   iq_buf_byte_order,
308                                                   n_bytes,
309                                                   &xp,
310                                                   CC_ID,
311                                                   RU_Port_ID,
312                                                   seq_id,
313                                                   do_copy);
314     if (prep_bytes <= 0)
315         errx(1, "failed preparing symbol");
316
317     rte_pktmbuf_pkt_len(mb)  = nPktSize;
318     rte_pktmbuf_data_len(mb) = nPktSize;
319
320 #ifdef DEBUG
321     printf("Symbol %2d prep_bytes (%d packets, %d bytes)\n", symbol_no, i, n_bytes);
322 #endif
323
324     return prep_bytes;
325 }
326
327 /* Send a single 5G symbol over multiple packets */
328 int send_symbol_ex(enum xran_pkt_dir direction,
329                 uint16_t section_id,
330                 struct rte_mbuf *mb,
331                 struct rb_map *data,
332                 const enum xran_input_byte_order iq_buf_byte_order,
333                 uint8_t frame_id,
334                 uint8_t subframe_id,
335                 uint8_t slot_id,
336                 uint8_t symbol_no,
337                 int prb_start,
338                 int prb_num,
339                 uint8_t CC_ID,
340                 uint8_t RU_Port_ID,
341                 uint8_t seq_id)
342 {
343     uint32_t do_copy = 0;
344     int32_t n_bytes = ((prb_num == 0) ? MAX_N_FULLBAND_SC : prb_num) * N_SC_PER_PRB * sizeof(struct rb_map);
345
346     if (mb == NULL){
347         char * pChar = NULL;
348         mb = xran_ethdi_mbuf_alloc(); /* will be freede by ETH */
349         if(mb ==  NULL){
350             MLogPrint(NULL);
351             errx(1, "out of mbufs after %d packets", 1);
352         }
353         pChar = rte_pktmbuf_append(mb, sizeof(struct xran_ecpri_hdr)+ sizeof(struct radio_app_common_hdr)+ sizeof(struct data_section_hdr) + n_bytes);
354         if(pChar == NULL){
355                 MLogPrint(NULL);
356                 errx(1, "incorrect mbuf size %d packets", 1);
357         }
358         pChar = rte_pktmbuf_prepend(mb, sizeof(struct ether_hdr));
359         if(pChar == NULL){
360                 MLogPrint(NULL);
361                 errx(1, "incorrect mbuf size %d packets", 1);
362         }
363         do_copy = 1; /* new mbuf hence copy of IQs  */
364     }else {
365         rte_pktmbuf_refcnt_update(mb, 1); /* make sure eth won't free our mbuf */
366     }
367
368     int32_t sent = prepare_symbol_ex(direction,
369                          section_id,
370                          mb,
371                          data,
372                          iq_buf_byte_order,
373                          frame_id,
374                          subframe_id,
375                          slot_id,
376                          symbol_no,
377                          prb_start,
378                          prb_num,
379                          CC_ID,
380                          RU_Port_ID,
381                          seq_id,
382                          do_copy);
383
384     if(sent){
385         tx_counter++;
386         xran_ethdi_mbuf_send(mb, ETHER_TYPE_ECPRI);
387     } else {
388
389     }
390
391
392
393 #ifdef DEBUG
394     printf("Symbol %2d sent (%d packets, %d bytes)\n", symbol_no, i, n_bytes);
395 #endif
396
397     return sent;
398 }
399
400 int send_cpmsg(void *pHandle, struct rte_mbuf *mbuf,struct xran_cp_gen_params *params,
401                 struct xran_section_gen_info *sect_geninfo, uint8_t cc_id, uint8_t ru_port_id, uint8_t seq_id)
402 {
403     int ret = 0, nsection, i;
404     uint8_t frame_id = params->hdr.frameId;
405     uint8_t subframe_id = params->hdr.subframeId;
406     uint8_t slot_id = params->hdr.slotId;
407     uint8_t dir = params->dir;
408
409     nsection = params->numSections;
410
411     /* add in the ethernet header */
412     struct ether_hdr *const h = (void *)rte_pktmbuf_prepend(mbuf, sizeof(*h));
413     xran_ethdi_mbuf_send_cp(mbuf, ETHER_TYPE_ECPRI);
414     tx_counter++;
415     for(i=0; i<nsection; i++)
416         xran_cp_add_section_info(pHandle, dir, cc_id, ru_port_id,
417                 (slot_id + subframe_id*SLOTNUM_PER_SUBFRAME)%XRAN_MAX_SECTIONDB_CTX,
418                 &sect_geninfo[i].info);
419
420     return (ret);
421 }
422
423 int generate_cpmsg_dlul(void *pHandle, struct xran_cp_gen_params *params, struct xran_section_gen_info *sect_geninfo, struct rte_mbuf *mbuf,
424     enum xran_pkt_dir dir, uint8_t frame_id, uint8_t subframe_id, uint8_t slot_id,
425     uint8_t startsym, uint8_t numsym, uint16_t prb_start, uint16_t prb_num,
426     uint16_t beam_id, uint8_t cc_id, uint8_t ru_port_id, uint8_t comp_method, uint8_t seq_id, uint8_t symInc)
427 {
428     int ret = 0, nsection, i;
429
430
431     params->dir                  = dir;
432     params->sectionType          = XRAN_CP_SECTIONTYPE_1;        // Most DL/UL Radio Channels
433     params->hdr.filterIdx        = XRAN_FILTERINDEX_STANDARD;
434     params->hdr.frameId          = frame_id;
435     params->hdr.subframeId       = subframe_id;
436     params->hdr.slotId           = slot_id;
437     params->hdr.startSymId       = startsym;                     // start Symbol ID
438     params->hdr.iqWidth          = xran_get_conf_iqwidth(pHandle);
439     params->hdr.compMeth         = comp_method;
440
441     nsection = 0;
442     sect_geninfo[nsection].info.type        = params->sectionType;       // for database
443     sect_geninfo[nsection].info.startSymId  = params->hdr.startSymId;    // for database
444     sect_geninfo[nsection].info.iqWidth     = params->hdr.iqWidth;       // for database
445     sect_geninfo[nsection].info.compMeth    = params->hdr.compMeth;      // for database
446     sect_geninfo[nsection].info.id          = xran_alloc_sectionid(pHandle, dir, cc_id, ru_port_id, slot_id);
447     sect_geninfo[nsection].info.rb          = XRAN_RBIND_EVERY;
448     sect_geninfo[nsection].info.symInc      = symInc;
449     sect_geninfo[nsection].info.startPrbc   = prb_start;
450     sect_geninfo[nsection].info.numPrbc     = prb_num;
451     sect_geninfo[nsection].info.numSymbol   = numsym;
452     sect_geninfo[nsection].info.reMask      = 0xfff;
453     sect_geninfo[nsection].info.beamId      = beam_id;
454
455     sect_geninfo[nsection].info.ef          = 0;
456     sect_geninfo[nsection].exDataSize       = 0;
457 //    sect_geninfo[nsection].exData           = NULL;
458     nsection++;
459
460     params->numSections          = nsection;
461     params->sections             = sect_geninfo;
462
463     if(unlikely(mbuf == NULL)) {
464         print_err("Alloc fail!\n");
465         return (-1);
466     }
467
468     ret = xran_prepare_ctrl_pkt(mbuf, params, cc_id, ru_port_id, seq_id);
469     if(ret < 0){
470         print_err("Fail to build control plane packet - [%d:%d:%d] dir=%d\n",
471                     frame_id, subframe_id, slot_id, dir);
472         rte_pktmbuf_free(mbuf);
473     }
474
475     return (ret);
476 }
477
478 int generate_cpmsg_prach(void *pHandle, struct xran_cp_gen_params *params, struct xran_section_gen_info *sect_geninfo, struct rte_mbuf *mbuf, struct xran_device_ctx *pxran_lib_ctx,
479                 uint8_t frame_id, uint8_t subframe_id, uint8_t slot_id,
480                 uint16_t beam_id, uint8_t cc_id, uint8_t prach_port_id, uint8_t seq_id)
481 {
482     int i, nsection, ret;
483     xRANPrachCPConfigStruct *pPrachCPConfig = &(pxran_lib_ctx->PrachCPConfig);
484     uint16_t timeOffset;
485     uint16_t nNumerology = pxran_lib_ctx->fh_cfg.frame_conf.nNumerology;
486
487     if(unlikely(mbuf == NULL)) {
488         print_err("Alloc fail!\n");
489         return (-1);
490     }
491 #if 0
492     printf("%d:%d:%d:%d - filter=%d, startSym=%d[%d:%d], numSym=%d, occasions=%d, freqOff=%d\n",
493                 frame_id, subframe_id, slot_id, prach_port_id,
494                 pPrachCPConfig->filterIdx,
495                 pPrachCPConfig->startSymId,
496                 pPrachCPConfig->startPrbc,
497                 pPrachCPConfig->numPrbc,
498                 pPrachCPConfig->numSymbol,
499                 pPrachCPConfig->occassionsInPrachSlot,
500                 pPrachCPConfig->freqOffset);
501 #endif
502     timeOffset = pPrachCPConfig->timeOffset; //this is the CP value per 38.211 tab 6.3.3.1-1&2
503     timeOffset = timeOffset >> nNumerology; //original number is Tc, convert to Ts based on mu
504     if (pPrachCPConfig->startSymId > 0)
505     {
506         timeOffset += (pPrachCPConfig->startSymId * 2048) >> nNumerology;
507         if ((slot_id == 0) || (slot_id == (SLOTNUM_PER_SUBFRAME >> 1)))
508             timeOffset += 16;
509     }
510     params->dir                  = XRAN_DIR_UL;
511     params->sectionType          = XRAN_CP_SECTIONTYPE_3;
512     params->hdr.filterIdx        = pPrachCPConfig->filterIdx;
513     params->hdr.frameId          = frame_id;
514     params->hdr.subframeId       = subframe_id;
515     params->hdr.slotId           = slot_id;
516     params->hdr.startSymId       = pPrachCPConfig->startSymId;
517     params->hdr.iqWidth          = xran_get_conf_iqwidth(pHandle);
518     params->hdr.compMeth         = xran_get_conf_compmethod(pHandle);
519         /* use timeOffset field for the CP length value for prach sequence */
520     params->hdr.timeOffset       = timeOffset;
521     params->hdr.fftSize          = xran_get_conf_fftsize(pHandle);
522     params->hdr.scs              = xran_get_conf_prach_scs(pHandle);
523     params->hdr.cpLength         = 0;
524
525     nsection = 0;
526     sect_geninfo[nsection].info.type        = params->sectionType;       // for database
527     sect_geninfo[nsection].info.startSymId  = params->hdr.startSymId;    // for database
528     sect_geninfo[nsection].info.iqWidth     = params->hdr.iqWidth;       // for database
529     sect_geninfo[nsection].info.compMeth    = params->hdr.compMeth;      // for database
530     sect_geninfo[nsection].info.id          = xran_alloc_sectionid(pHandle, XRAN_DIR_UL, cc_id, prach_port_id, slot_id);
531     sect_geninfo[nsection].info.rb          = XRAN_RBIND_EVERY;
532     sect_geninfo[nsection].info.symInc      = XRAN_SYMBOLNUMBER_NOTINC;
533     sect_geninfo[nsection].info.startPrbc   = pPrachCPConfig->startPrbc;
534     sect_geninfo[nsection].info.numPrbc     = pPrachCPConfig->numPrbc,
535     sect_geninfo[nsection].info.numSymbol   = pPrachCPConfig->numSymbol*pPrachCPConfig->occassionsInPrachSlot;
536     sect_geninfo[nsection].info.reMask      = 0xfff;
537     sect_geninfo[nsection].info.beamId      = beam_id;
538     sect_geninfo[nsection].info.freqOffset  = pPrachCPConfig->freqOffset;
539
540     pxran_lib_ctx->prach_last_symbol[cc_id] = sect_geninfo[nsection].info.startSymId + sect_geninfo[nsection].info.numSymbol - 1;
541
542     sect_geninfo[nsection].info.ef          = 0;
543     sect_geninfo[nsection].exDataSize       = 0;
544 //    sect_geninfo[nsection].exData           = NULL;
545     nsection++;
546
547     params->numSections          = nsection;
548     params->sections             = sect_geninfo;
549
550     ret = xran_prepare_ctrl_pkt(mbuf, params, cc_id, prach_port_id, seq_id);
551     if(ret < 0){
552         print_err("Fail to build prach control packet - [%d:%d:%d]\n", frame_id, subframe_id, slot_id);
553         rte_pktmbuf_free(mbuf);
554     }
555     return ret;
556 }
557
558
559 int process_ring(struct rte_ring *r)
560 {
561     assert(r);
562
563     struct rte_mbuf *mbufs[MBUFS_CNT];
564     int i;
565     uint32_t remaining;
566     uint64_t t1;
567     const uint16_t dequeued = rte_ring_dequeue_burst(r, (void **)mbufs,
568         RTE_DIM(mbufs), &remaining);
569
570     if (!dequeued)
571         return 0;
572
573     t1 = MLogTick();
574     for (i = 0; i < dequeued; ++i) {
575         if (xran_ethdi_filter_packet(mbufs[i], 0) == MBUF_FREE)
576             rte_pktmbuf_free(mbufs[i]);
577     }
578     MLogTask(PID_PROCESS_UP_PKT, t1, MLogTick());
579
580     return remaining;
581 }
582
583 int32_t ring_processing_func(void)
584 {
585     struct xran_ethdi_ctx *const ctx = xran_ethdi_get_ctx();
586     struct xran_device_ctx *const pxran_lib_ctx = xran_dev_get_ctx();
587
588     rte_timer_manage();
589
590     /* UP first */
591     if (process_ring(ctx->rx_ring[ETHDI_UP_VF]))
592         return 0;
593     /* CP next */
594     if (process_ring(ctx->rx_ring[ETHDI_CP_VF]))
595         return 0;
596
597     if (pxran_lib_ctx->bbdev_dec)
598         pxran_lib_ctx->bbdev_dec();
599
600     if (pxran_lib_ctx->bbdev_enc)
601         pxran_lib_ctx->bbdev_enc();
602
603     if (XRAN_STOPPED == xran_if_current_state)
604         return -1;
605
606     return 0;
607 }
608
609 int ring_processing_thread(void *args)
610 {
611     struct sched_param sched_param;
612     int res = 0;
613
614     printf("%s [CPU %2d] [PID: %6d]\n", __FUNCTION__,  rte_lcore_id(), getpid());
615     sched_param.sched_priority = XRAN_THREAD_DEFAULT_PRIO;
616     if ((res = pthread_setschedparam(pthread_self(), SCHED_FIFO, &sched_param))){
617         printf("priority is not changed: coreId = %d, result1 = %d\n",rte_lcore_id(), res);
618     }
619
620     for (;;)
621         if(ring_processing_func() != 0)
622             break;
623
624     puts("Pkt processing thread finished.");
625     return 0;
626 }
627