[Epic-ID: ODUHIGH-461][Task-ID: ODUHIGH-468]Unused files and functions removed/disabled
[o-du/l2.git] / src / cm / crg.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
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 \f
19
20 /************************************************************************
21  
22      Name:     LTE-MAC layer
23   
24      Type:     C source file
25   
26      Desc:     C source code for pack/unpack of CRG interface primitives. 
27   
28      File:     crg.c 
29   
30 **********************************************************************/
31
32 /** @file crg.c
33 @brief This file contains the packing/unpacking code for the CRG interface 
34        primitives.
35 */
36 /* header include files (.h) */
37 #include "common_def.h"
38 #include "crg.h"           /* CRG Interface defines */
39
40 /* header/extern include files (.x) */
41 #include "crg.x"           /* CRG Interface includes */
42
43 #ifdef LCCRG
44 \f
45 /**
46 * @brief Request from RRC to MAC to bind the interface saps
47 *
48 * @details
49 *
50 *     Function : cmPkCrgBndReq
51 *
52 *  @param[in]   Pst*  pst
53 *  @param[in]   SuId  suId
54 *  @param[in]   SpId  spId
55 *  @return   S16
56 *      -# ROK
57 **/
58 S16 cmPkCrgBndReq
59 (
60 Pst* pst,
61 SuId suId,
62 SpId spId
63 )
64 {
65    Buffer *mBuf = NULLP;
66
67    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
68 #if (ERRCLASS & ERRCLS_ADD_RES)
69       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
70          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
71          (ErrVal)ECRG001, (ErrVal)0, "Packing failed");
72 #endif
73       return RFAILED;
74    }
75    if (SPkS16(spId, mBuf) != ROK) {
76 #if (ERRCLASS & ERRCLS_ADD_RES)
77       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
78          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
79          (ErrVal)ECRG002, (ErrVal)0, "Packing failed");
80 #endif
81       SPutMsg(mBuf);
82       return RFAILED;
83    }
84    if (SPkS16(suId, mBuf) != ROK) {
85 #if (ERRCLASS & ERRCLS_ADD_RES)
86       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
87          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
88          (ErrVal)ECRG003, (ErrVal)0, "Packing failed");
89 #endif
90       SPutMsg(mBuf);
91       return RFAILED;
92    }
93    pst->event = (Event) EVTCRGBNDREQ;
94    return (SPstTsk(pst,mBuf));
95 }
96
97 \f
98 /**
99 * @brief Request from RRC to MAC to bind the interface saps
100 *
101 * @details
102 *
103 *     Function : cmUnpkCrgBndReq
104 *
105 *  @param[in]   Pst*  pst
106 *  @param[in]   SuId  suId
107 *  @param[in]   SpId  spId
108 *  @return   S16
109 *      -# ROK
110 **/
111 S16 cmUnpkCrgBndReq
112 (
113 CrgBndReq func,
114 Pst *pst,
115 Buffer *mBuf
116 )
117 {
118    SuId suId;
119    SpId spId;
120    
121
122    if (SUnpkS16(&suId, mBuf) != ROK) {
123       SPutMsg(mBuf);
124 #if (ERRCLASS & ERRCLS_ADD_RES)
125       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
126          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
127          (ErrVal)ECRG004, (ErrVal)0, "Packing failed");
128 #endif
129       return RFAILED;
130    }
131    if (SUnpkS16(&spId, mBuf) != ROK) {
132       SPutMsg(mBuf);
133 #if (ERRCLASS & ERRCLS_ADD_RES)
134       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
135          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
136          (ErrVal)ECRG005, (ErrVal)0, "Packing failed");
137 #endif
138       return RFAILED;
139    }
140    SPutMsg(mBuf);
141    return ((*func)(pst, suId, spId));
142 }
143
144 \f
145 /**
146 * @brief Confirmation from MAC to RRC for the bind/Unbind 
147  * request for the interface saps
148 *
149 * @details
150 *
151 *     Function : cmPkCrgBndCfm
152 *
153 *  @param[in]   Pst*  pst
154 *  @param[in]   SuId  suId
155 *  @param[in]   uint8_t  status
156 *  @return   S16
157 *      -# ROK
158 **/
159 S16 cmPkCrgBndCfm
160 (
161 Pst* pst,
162 SuId suId,
163 uint8_t status
164 )
165 {
166    Buffer *mBuf = NULLP;
167
168    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
169 #if (ERRCLASS & ERRCLS_ADD_RES)
170       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
171          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
172          (ErrVal)ECRG006, (ErrVal)0, "Packing failed");
173 #endif
174       return RFAILED;
175    }
176    if (oduUnpackUInt8(status, mBuf) != ROK) {
177 #if (ERRCLASS & ERRCLS_ADD_RES)
178       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
179          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
180          (ErrVal)ECRG007, (ErrVal)0, "Packing failed");
181 #endif
182       SPutMsg(mBuf);
183       return RFAILED;
184    }
185    if (SPkS16(suId, mBuf) != ROK) {
186 #if (ERRCLASS & ERRCLS_ADD_RES)
187       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
188          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
189          (ErrVal)ECRG008, (ErrVal)0, "Packing failed");
190 #endif
191       SPutMsg(mBuf);
192       return RFAILED;
193    }
194    pst->event = (Event) EVTCRGBNDCFM;
195    return (SPstTsk(pst,mBuf));
196 }
197
198 \f
199 /**
200 * @brief Confirmation from MAC to RRC for the bind/Unbind 
201  * request for the interface saps
202 *
203 * @details
204 *
205 *     Function : cmUnpkCrgBndCfm
206 *
207 *  @param[in]   Pst*  pst
208 *  @param[in]   SuId  suId
209 *  @param[in]   uint8_t  status
210 *  @return   S16
211 *      -# ROK
212 **/
213 S16 cmUnpkCrgBndCfm
214 (
215 CrgBndCfm func,
216 Pst *pst,
217 Buffer *mBuf
218 )
219 {
220    SuId suId;
221    uint8_t status;
222    
223
224    if (SUnpkS16(&suId, mBuf) != ROK) {
225       SPutMsg(mBuf);
226 #if (ERRCLASS & ERRCLS_ADD_RES)
227       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
228          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
229          (ErrVal)ECRG009, (ErrVal)0, "Packing failed");
230 #endif
231       return RFAILED;
232    }
233    if (oduPackUInt8(&status, mBuf) != ROK) {
234       SPutMsg(mBuf);
235 #if (ERRCLASS & ERRCLS_ADD_RES)
236       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
237          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
238          (ErrVal)ECRG010, (ErrVal)0, "Packing failed");
239 #endif
240       return RFAILED;
241    }
242    SPutMsg(mBuf);
243    return ((*func)(pst, suId, status));
244 }
245
246 \f
247 /**
248 * @brief Request from RRC to MAC to Unbind the interface saps
249 *
250 * @details
251 *
252 *     Function : cmPkCrgUbndReq
253 *
254 *  @param[in]   Pst*  pst
255 *  @param[in]   SpId  spId
256 *  @param[in]   Reason  reason
257 *  @return   S16
258 *      -# ROK
259 **/
260 S16 cmPkCrgUbndReq
261 (
262 Pst* pst,
263 SpId spId,
264 Reason reason
265 )
266 {
267    Buffer *mBuf = NULLP;
268
269    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
270 #if (ERRCLASS & ERRCLS_ADD_RES)
271       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
272          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
273          (ErrVal)ECRG011, (ErrVal)0, "Packing failed");
274 #endif
275       return RFAILED;
276    }
277    if (SPkS16(reason, mBuf) != ROK) {
278 #if (ERRCLASS & ERRCLS_ADD_RES)
279       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
280          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
281          (ErrVal)ECRG012, (ErrVal)0, "Packing failed");
282 #endif
283       SPutMsg(mBuf);
284       return RFAILED;
285    }
286    if (SPkS16(spId, mBuf) != ROK) {
287 #if (ERRCLASS & ERRCLS_ADD_RES)
288       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
289          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
290          (ErrVal)ECRG013, (ErrVal)0, "Packing failed");
291 #endif
292       SPutMsg(mBuf);
293       return RFAILED;
294    }
295    pst->event = (Event) EVTCRGUBNDREQ;
296    return (SPstTsk(pst,mBuf));
297 }
298
299 \f
300 /**
301 * @brief Request from RRC to MAC to Unbind the interface saps
302 *
303 * @details
304 *
305 *     Function : cmUnpkCrgUbndReq
306 *
307 *  @param[in]   Pst*  pst
308 *  @param[in]   SpId  spId
309 *  @param[in]   Reason  reason
310 *  @return   S16
311 *      -# ROK
312 **/
313 S16 cmUnpkCrgUbndReq
314 (
315 CrgUbndReq func,
316 Pst *pst,
317 Buffer *mBuf
318 )
319 {
320    SpId spId;
321    Reason reason;
322    
323
324    if (SUnpkS16(&spId, mBuf) != ROK) {
325       SPutMsg(mBuf);
326 #if (ERRCLASS & ERRCLS_ADD_RES)
327       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
328          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
329          (ErrVal)ECRG014, (ErrVal)0, "Packing failed");
330 #endif
331       return RFAILED;
332    }
333    if (SUnpkS16(&reason, mBuf) != ROK) {
334       SPutMsg(mBuf);
335 #if (ERRCLASS & ERRCLS_ADD_RES)
336       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
337          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
338          (ErrVal)ECRG015, (ErrVal)0, "Packing failed");
339 #endif
340       return RFAILED;
341    }
342    SPutMsg(mBuf);
343    return ((*func)(pst, spId, reason));
344 }
345
346 \f
347 /**
348 * @brief Configuration Confirm from MAC to RRC
349 *
350 * @details
351 *
352 *     Function : cmPkCrgCfgCfm
353 *
354 *  @param[in]   Pst*  pst
355 *  @param[in]   SuId  suId
356 *  @param[in]   CrgCfgTransId  transId
357 *  @param[in]   uint8_t  status
358 *  @return   S16
359 *      -# ROK
360 **/
361 S16 cmPkCrgCfgCfm
362 (
363 Pst* pst,
364 SuId suId,
365 CrgCfgTransId transId,
366 uint8_t status
367 )
368 {
369    Buffer *mBuf = NULLP;
370
371    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
372 #if (ERRCLASS & ERRCLS_ADD_RES)
373       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
374          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
375          (ErrVal)ECRG025, (ErrVal)0, "Packing failed");
376 #endif
377       return RFAILED;
378    }
379 /* crg_c_001.main_5 - ADD - Added the packing for status. */
380    if (oduUnpackUInt8(status, mBuf) != ROK) {
381 #if (ERRCLASS & ERRCLS_ADD_RES)
382       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
383          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
384          (ErrVal)ECRG026, (ErrVal)0, "Packing failed");
385 #endif
386       SPutMsg(mBuf);
387       return RFAILED;
388    }
389    if (cmPkCrgCfgTransId(&transId, mBuf) != ROK) {
390 #if (ERRCLASS & ERRCLS_ADD_RES)
391       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
392          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
393          (ErrVal)ECRG027, (ErrVal)0, "Packing failed");
394 #endif
395       SPutMsg(mBuf);
396       return RFAILED;
397    }
398    if (SPkS16(suId, mBuf) != ROK) {
399 #if (ERRCLASS & ERRCLS_ADD_RES)
400       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
401          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
402          (ErrVal)ECRG028, (ErrVal)0, "Packing failed");
403 #endif
404       SPutMsg(mBuf);
405       return RFAILED;
406    }
407    pst->event = (Event) EVTCRGCFGCFM;
408    return (SPstTsk(pst,mBuf));
409 }
410
411 \f
412 /**
413 * @brief Configuration Confirm from MAC to RRC
414 *
415 * @details
416 *
417 *     Function : cmUnpkCrgCfgCfm
418 *
419 *  @param[in]   Pst*  pst
420 *  @param[in]   SuId  suId
421 *  @param[in]   CrgCfgTransId  transId
422 *  @param[in]   uint8_t  status
423 *  @return   S16
424 *      -# ROK
425 **/
426 S16 cmUnpkCrgCfgCfm
427 (
428 CrgCfgCfm func,
429 Pst *pst,
430 Buffer *mBuf
431 )
432 {
433    SuId suId;
434    CrgCfgTransId transId;
435    uint8_t status;
436    
437
438    if (SUnpkS16(&suId, mBuf) != ROK) {
439       SPutMsg(mBuf);
440 #if (ERRCLASS & ERRCLS_ADD_RES)
441       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
442          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
443          (ErrVal)ECRG029, (ErrVal)0, "Packing failed");
444 #endif
445       return RFAILED;
446    }
447    if (cmUnpkCrgCfgTransId(&transId, mBuf) != ROK) {
448       SPutMsg(mBuf);
449 #if (ERRCLASS & ERRCLS_ADD_RES)
450       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
451          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
452          (ErrVal)ECRG030, (ErrVal)0, "Packing failed");
453 #endif
454       return RFAILED;
455    }
456    if (oduPackUInt8(&status, mBuf) != ROK) {
457       SPutMsg(mBuf);
458 #if (ERRCLASS & ERRCLS_ADD_RES)
459       SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
460          __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES,
461          (ErrVal)ECRG031, (ErrVal)0, "Packing failed");
462 #endif
463       return RFAILED;
464    }
465    SPutMsg(mBuf);
466    return ((*func)(pst, suId, transId, status));
467 }
468
469 \f
470 /***********************************************************
471 *
472 *     Func : cmPkCrgCfgTransId
473 *
474 *
475 *     Desc : Transaction ID between MAC and RRC
476 *
477 *
478 *     Ret  : S16
479 *
480 *     Notes:
481 *
482 *     File  : 
483 *
484 **********************************************************/
485 S16 cmPkCrgCfgTransId
486 (
487 CrgCfgTransId *param,
488 Buffer *mBuf
489 )
490 {
491
492    S32 i;
493
494    for (i=CRG_CFG_TRANSID_SIZE-1; i >= 0; i--) {
495       CMCHKPK(oduUnpackUInt8, param->trans[i], mBuf);
496    }
497    return ROK;
498 }
499
500
501 \f
502 /***********************************************************
503 *
504 *     Func : cmUnpkCrgCfgTransId
505 *
506 *
507 *     Desc : Transaction ID between MAC and RRC
508 *
509 *
510 *     Ret  : S16
511 *
512 *     Notes:
513 *
514 *     File  : 
515 *
516 **********************************************************/
517 S16 cmUnpkCrgCfgTransId
518 (
519 CrgCfgTransId *param,
520 Buffer *mBuf
521 )
522 {
523
524    S32 i;
525
526    for (i=0; i<CRG_CFG_TRANSID_SIZE; i++) {
527       CMCHKUNPK(oduPackUInt8, &param->trans[i], mBuf);
528    }
529    return ROK;
530 }
531
532
533 \f
534 /***********************************************************
535 *
536 *     Func : cmPkCrgUeUlHqCfg
537 *
538 *
539 *     Desc : Uplink HARQ configuration per UE
540 *
541 *
542 *     Ret  : S16
543 *
544 *     Notes:
545 *
546 *     File  : 
547 *
548 **********************************************************/
549 S16 cmPkCrgUeUlHqCfg
550 (
551 CrgUeUlHqCfg *param,
552 Buffer *mBuf
553 )
554 {
555
556
557    CMCHKPK(oduUnpackUInt8, param->maxUlHqTx, mBuf);
558    return ROK;
559 }
560
561 #ifdef LTE_ADV
562 /***********************************************************
563 *
564 *     Func : cmPkCrgUeSCellCfg
565 *
566 *
567 *     Desc : Secondary Cell information of the UE
568 *
569 *
570 *     Ret  : S16
571 *
572 *     Notes:
573 *
574 *     File  : 
575 *
576 **********************************************************/
577 static S16 cmPkCrgUeSCellCfg
578 (
579 CrgUeSCellInfo *param,
580 Buffer *mBuf
581 )
582 {
583    CMCHKPK(SPkS16, param->rguDlSapId, mBuf);
584    CMCHKPK(SPkS16, param->rguUlSapId, mBuf);
585    CMCHKPK(oduUnpackUInt8, param->macInst, mBuf);
586    CMCHKPK(oduUnpackUInt16, param->sCellId, mBuf);
587
588    return ROK;
589 }
590 /***********************************************************
591 *
592 *     Func : cmUnpkCrgUeSCellCfg
593 *
594 *
595 *     Desc : Secondary Cell information of the UE
596 *
597 *
598 *     Ret  : S16
599 *
600 *     Notes:
601 *
602 *     File  : 
603 *
604 **********************************************************/
605 static S16 cmUnpkCrgUeSCellCfg
606 (
607 CrgUeSCellInfo *param,
608 Buffer *mBuf
609 )
610 {
611    CMCHKUNPK(oduPackUInt16, &param->sCellId, mBuf);
612    CMCHKUNPK(oduPackUInt8, &param->macInst, mBuf);
613    CMCHKUNPK(SUnpkS16, &param->rguUlSapId, mBuf);
614    CMCHKUNPK(SUnpkS16, &param->rguDlSapId, mBuf);
615    return ROK;
616 }
617 /***********************************************************
618 *
619 *     Func : cmPkCrgUeSecCellInfo
620 *
621 *
622 *     Desc : Secondary Cell information of the UE
623 *
624 *
625 *     Ret  : S16
626 *
627 *     Notes:
628 *
629 *     File  : 
630 *
631 **********************************************************/
632 S16 cmPkCrgUeSecCellInfo
633 (
634 CrgUeSecCellInfo *param,
635 Buffer *mBuf
636 )
637 {
638    S8 idx;
639    for(idx = param->numSCells - 1; idx >= 0; idx--)
640    {
641       CMCHKPK(cmPkCrgUeSCellCfg, &param->ueSCellCfg[(uint8_t)idx], mBuf);
642    }
643
644    CMCHKPK(oduUnpackUInt8, param->numSCells, mBuf);
645    CMCHKPK(oduUnpackUInt8, param->isSCellCfgPres, mBuf);
646
647    return ROK;
648 }
649
650 /***********************************************************
651 *
652 *     Func : cmUnpkCrgUeSecCellInfo
653 *
654 *
655 *     Desc : Secondary Cell information of the UE
656 *
657 *
658 *     Ret  : S16
659 *
660 *     Notes:
661 *
662 *     File  : 
663 *
664 **********************************************************/
665 S16 cmUnpkCrgUeSecCellInfo
666 (
667 CrgUeSecCellInfo *param,
668 Buffer *mBuf
669 )
670 {
671    uint8_t idx;
672
673    CMCHKUNPK(oduPackUInt8, &param->isSCellCfgPres, mBuf);
674    if(TRUE == param->isSCellCfgPres)
675    {
676       CMCHKUNPK(oduPackUInt8, &param->numSCells, mBuf);
677
678       for(idx = 0; idx < param->numSCells; idx++)
679       {
680          CMCHKUNPK(cmUnpkCrgUeSCellCfg, &param->ueSCellCfg[idx],mBuf);
681       }
682    }
683
684    return ROK;
685 }
686
687 #endif /* LTE_ADV */
688
689 #endif
690 /**********************************************************************
691          End of file
692 **********************************************************************/