1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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. #
16 ################################################################################
17 *******************************************************************************/
20 /************************************************************************
26 Desc: C source code for pack/unpack of CRG interface primitives.
30 **********************************************************************/
33 @brief This file contains the packing/unpacking code for the CRG interface
36 /* header include files (.h) */
37 #include "common_def.h"
38 #include "crg.h" /* CRG Interface defines */
40 /* header/extern include files (.x) */
41 #include "crg.x" /* CRG Interface includes */
46 * @brief Request from RRC to MAC to bind the interface saps
50 * Function : cmPkCrgBndReq
53 * @param[in] SuId suId
54 * @param[in] SpId spId
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");
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");
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");
93 pst->event = (Event) EVTCRGBNDREQ;
94 return (SPstTsk(pst,mBuf));
99 * @brief Request from RRC to MAC to bind the interface saps
103 * Function : cmUnpkCrgBndReq
105 * @param[in] Pst* pst
106 * @param[in] SuId suId
107 * @param[in] SpId spId
122 if (SUnpkS16(&suId, mBuf) != ROK) {
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");
131 if (SUnpkS16(&spId, mBuf) != ROK) {
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");
141 return ((*func)(pst, suId, spId));
146 * @brief Confirmation from MAC to RRC for the bind/Unbind
147 * request for the interface saps
151 * Function : cmPkCrgBndCfm
153 * @param[in] Pst* pst
154 * @param[in] SuId suId
155 * @param[in] uint8_t status
166 Buffer *mBuf = NULLP;
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");
176 if (oduPackUInt8(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");
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");
194 pst->event = (Event) EVTCRGBNDCFM;
195 return (SPstTsk(pst,mBuf));
200 * @brief Confirmation from MAC to RRC for the bind/Unbind
201 * request for the interface saps
205 * Function : cmUnpkCrgBndCfm
207 * @param[in] Pst* pst
208 * @param[in] SuId suId
209 * @param[in] uint8_t status
224 if (SUnpkS16(&suId, mBuf) != ROK) {
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");
233 if (oduUnpackUInt8(&status, mBuf) != ROK) {
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");
243 return ((*func)(pst, suId, status));
248 * @brief Request from RRC to MAC to Unbind the interface saps
252 * Function : cmPkCrgUbndReq
254 * @param[in] Pst* pst
255 * @param[in] SpId spId
256 * @param[in] Reason reason
267 Buffer *mBuf = NULLP;
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");
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");
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");
295 pst->event = (Event) EVTCRGUBNDREQ;
296 return (SPstTsk(pst,mBuf));
301 * @brief Request from RRC to MAC to Unbind the interface saps
305 * Function : cmUnpkCrgUbndReq
307 * @param[in] Pst* pst
308 * @param[in] SpId spId
309 * @param[in] Reason reason
324 if (SUnpkS16(&spId, mBuf) != ROK) {
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");
333 if (SUnpkS16(&reason, mBuf) != ROK) {
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");
343 return ((*func)(pst, spId, reason));
348 * @brief Configuration Confirm from MAC to RRC
352 * Function : cmPkCrgCfgCfm
354 * @param[in] Pst* pst
355 * @param[in] SuId suId
356 * @param[in] CrgCfgTransId transId
357 * @param[in] uint8_t status
365 CrgCfgTransId transId,
369 Buffer *mBuf = NULLP;
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");
379 /* crg_c_001.main_5 - ADD - Added the packing for status. */
380 if (oduPackUInt8(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");
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");
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");
407 pst->event = (Event) EVTCRGCFGCFM;
408 return (SPstTsk(pst,mBuf));
413 * @brief Configuration Confirm from MAC to RRC
417 * Function : cmUnpkCrgCfgCfm
419 * @param[in] Pst* pst
420 * @param[in] SuId suId
421 * @param[in] CrgCfgTransId transId
422 * @param[in] uint8_t status
434 CrgCfgTransId transId;
438 if (SUnpkS16(&suId, mBuf) != ROK) {
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");
447 if (cmUnpkCrgCfgTransId(&transId, mBuf) != ROK) {
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");
456 if (oduUnpackUInt8(&status, mBuf) != ROK) {
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");
466 return ((*func)(pst, suId, transId, status));
470 /***********************************************************
472 * Func : cmPkCrgCfgTransId
475 * Desc : Transaction ID between MAC and RRC
484 **********************************************************/
485 S16 cmPkCrgCfgTransId
487 CrgCfgTransId *param,
494 for (i=CRG_CFG_TRANSID_SIZE-1; i >= 0; i--) {
495 CMCHKPK(oduPackUInt8, param->trans[i], mBuf);
502 /***********************************************************
504 * Func : cmUnpkCrgCfgTransId
507 * Desc : Transaction ID between MAC and RRC
516 **********************************************************/
517 S16 cmUnpkCrgCfgTransId
519 CrgCfgTransId *param,
526 for (i=0; i<CRG_CFG_TRANSID_SIZE; i++) {
527 CMCHKUNPK(oduUnpackUInt8, ¶m->trans[i], mBuf);
534 /***********************************************************
536 * Func : cmPkCrgUeUlHqCfg
539 * Desc : Uplink HARQ configuration per UE
548 **********************************************************/
557 CMCHKPK(oduPackUInt8, param->maxUlHqTx, mBuf);
562 /***********************************************************
564 * Func : cmPkCrgUeSCellCfg
567 * Desc : Secondary Cell information of the UE
576 **********************************************************/
577 static S16 cmPkCrgUeSCellCfg
579 CrgUeSCellInfo *param,
583 CMCHKPK(SPkS16, param->rguDlSapId, mBuf);
584 CMCHKPK(SPkS16, param->rguUlSapId, mBuf);
585 CMCHKPK(oduPackUInt8, param->macInst, mBuf);
586 CMCHKPK(oduPackUInt16, param->sCellId, mBuf);
590 /***********************************************************
592 * Func : cmUnpkCrgUeSCellCfg
595 * Desc : Secondary Cell information of the UE
604 **********************************************************/
605 static S16 cmUnpkCrgUeSCellCfg
607 CrgUeSCellInfo *param,
611 CMCHKUNPK(oduUnpackUInt16, ¶m->sCellId, mBuf);
612 CMCHKUNPK(oduUnpackUInt8, ¶m->macInst, mBuf);
613 CMCHKUNPK(SUnpkS16, ¶m->rguUlSapId, mBuf);
614 CMCHKUNPK(SUnpkS16, ¶m->rguDlSapId, mBuf);
617 /***********************************************************
619 * Func : cmPkCrgUeSecCellInfo
622 * Desc : Secondary Cell information of the UE
631 **********************************************************/
632 S16 cmPkCrgUeSecCellInfo
634 CrgUeSecCellInfo *param,
639 for(idx = param->numSCells - 1; idx >= 0; idx--)
641 CMCHKPK(cmPkCrgUeSCellCfg, ¶m->ueSCellCfg[(uint8_t)idx], mBuf);
644 CMCHKPK(oduPackUInt8, param->numSCells, mBuf);
645 CMCHKPK(oduPackUInt8, param->isSCellCfgPres, mBuf);
650 /***********************************************************
652 * Func : cmUnpkCrgUeSecCellInfo
655 * Desc : Secondary Cell information of the UE
664 **********************************************************/
665 S16 cmUnpkCrgUeSecCellInfo
667 CrgUeSecCellInfo *param,
673 CMCHKUNPK(oduUnpackUInt8, ¶m->isSCellCfgPres, mBuf);
674 if(TRUE == param->isSCellCfgPres)
676 CMCHKUNPK(oduUnpackUInt8, ¶m->numSCells, mBuf);
678 for(idx = 0; idx < param->numSCells; idx++)
680 CMCHKUNPK(cmUnpkCrgUeSCellCfg, ¶m->ueSCellCfg[idx],mBuf);
690 /**********************************************************************
692 **********************************************************************/