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 *******************************************************************************/
19 /************************************************************************
25 Desc: C source code for Layer Manager Interface Module
29 **********************************************************************/
32 @brief This file contains the Layer Management interface module implementation.
33 The functions for the configuration, control, status and statistics
34 request primitives are defined here.
36 static const char* RLOG_MODULE_NAME="MAC";
37 static int RLOG_FILE_ID=220;
38 static int RLOG_MODULE_ID=4096;
40 /* header include files (.h) */
41 #include "envopt.h" /* environment options */
42 #include "envdep.h" /* environment dependent */
43 #include "envind.h" /* environment independent */
44 #include "gen.h" /* general */
45 #include "ssi.h" /* system services */
46 #include "cm_tkns.h" /* Common Token Defines */
47 #include "cm_llist.h" /* Common Link List Defines */
48 #include "cm_hash.h" /* Common Hash List Defines */
49 #include "cm_mblk.h" /* common memory link list library */
50 #include "cm_lte.h" /* Common LTE Defines */
51 #include "rg_env.h" /* MAC Environment Defines */
52 #include "crg.h" /* CRG Interface defines */
53 #include "rgu.h" /* RGU Interface defines */
54 #include "tfu.h" /* RGU Interface defines */
55 #include "rg_sch_inf.h" /* RGR Interface defines */
56 #include "lrg.h" /* LRG Interface defines */
57 #include "rg.h" /* MAC defines */
58 #include "rg_err.h" /* MAC error defines */
60 /* header/extern include files (.x) */
61 #include "gen.x" /* general */
62 #include "ssi.x" /* system services */
63 #include "cm5.x" /* system services */
64 #include "cm_tkns.x" /* Common Token Definitions */
65 #include "cm_llist.x" /* Common Link List Definitions */
66 #include "cm_lib.x" /* Common Library Definitions */
67 #include "cm_hash.x" /* Common Hash List Definitions */
68 #include "cm_mblk.x" /* common memory link list library */
69 #include "cm_lte.x" /* Common LTE Defines */
70 #include "crg.x" /* CRG Interface includes */
71 #include "rgu.x" /* RGU Interface includes */
72 #include "tfu.x" /* RGU Interface includes */
73 #include "rg_sch_inf.x" /* SCH Interface includes */
74 #include "rg_prg.x" /* PRG Interface includes */
75 #include "lrg.x" /* LRG Interface includes */
76 #include "rg.x" /* MAC includes */
78 #include "ss_diag.h" /* Common log file */
84 #endif /* __cplusplus */
85 EXTERN Void rgGetSId ARGS((SystemId *s));
88 #endif /* __cplusplus */
91 /* forward references */
92 PRIVATE U16 rgLMMGenCfg ARGS((
97 PRIVATE U16 rgLMMSapCfg ARGS((
103 PRIVATE Void rgLMMShutdown ARGS((
107 PRIVATE Void rgLMMFillCfmPst ARGS((
113 PRIVATE Void rgLMMGenCntrl ARGS((
119 PRIVATE Void rgLMMSapCntrl ARGS((
127 * @brief Task Initiation callback function.
131 * Function : rgActvInit
133 * This function is supplied as one of parameters during MAC's
134 * task registration. SSI will invoke this function once, after
135 * it creates and attaches this TAPA Task to a system task.
137 * @param[in] Ent entity, the entity ID of this task.
138 * @param[in] Inst inst, the instance ID of this task.
139 * @param[in] Region region, the region ID registered for memory
140 * usage of this task.
141 * @param[in] Reason reason.
146 PUBLIC S16 rgActvInit
148 Ent entity, /* entity */
149 Inst inst, /* instance */
150 Region region, /* region */
151 Reason reason /* reason */
154 PUBLIC S16 rgActvInit(entity, inst, region, reason)
155 Ent entity; /* entity */
156 Inst inst; /* instance */
157 Region region; /* region */
158 Reason reason; /* reason */
164 RG_IS_INST_VALID(inst);
166 macInst = inst - RG_INST_START;
167 /* Initialize the MAC TskInit structure to zero */
168 cmMemset ((U8 *)&rgCb[macInst], 0, sizeof(RgCb));
170 /* Initialize the MAC TskInit with received values */
171 rgCb[macInst].rgInit.ent = entity;
172 rgCb[macInst].rgInit.inst = inst;
173 rgCb[macInst].rgInit.region = region;
174 rgCb[macInst].rgInit.pool = 0;
175 rgCb[macInst].rgInit.reason = reason;
176 rgCb[macInst].rgInit.cfgDone = FALSE;
177 rgCb[macInst].rgInit.acnt = FALSE;
178 rgCb[macInst].rgInit.usta = FALSE;
179 rgCb[macInst].rgInit.trc = FALSE;
180 rgCb[macInst].trcLen = 0;
183 /* disabling debugs by default */
184 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
188 rgCb[macInst].rgInit.logMask = 0x0;
190 rgCb[macInst].rgInit.procId = SFndProcId();
191 rgCb[macInst].tfuSap.numBndRetries = 0;
193 /* Initialize Sap state */
194 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
195 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
196 rgCb[macInst].rguSap = NULLP;
197 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
199 rgCb[macInst].inactiveCell = NULLP;
200 rgCb[macInst].cell = NULLP;
202 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
203 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
210 * @brief Layer Manager Configuration request handler.
214 * Function : RgMiLrgCfgReq
216 * This function handles the configuration
217 * request received from the Layer Manager.
218 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
219 * functions rgHdlGenCfg() or rgHdlSapCfg().
220 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
222 * @param[in] Pst *pst, the post structure
223 * @param[in] RgMngmt *cfg, the configuration parameter's structure
228 PUBLIC S16 RgMiLrgCfgReq
230 Pst *pst, /* post structure */
231 RgMngmt *cfg /* config structure */
234 PUBLIC S16 RgMiLrgCfgReq(pst, cfg)
235 Pst *pst; /* post structure */
236 RgMngmt *cfg; /* config structure */
239 U16 ret = LCM_PRIM_OK;
240 U16 reason = LCM_REASON_NOT_APPL;
248 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
249 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
250 pst->srcEnt, pst->srcInst,0,0);
252 RG_IS_INST_VALID(pst->dstInst);
253 inst = pst->dstInst - RG_INST_START;
255 /* Fill the post structure for sending the confirmation */
256 rgLMMFillCfmPst(pst, &cfmPst, cfg);
258 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
261 cfm.hdr.transId = cfg->hdr.transId;
265 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
266 switch(cfg->hdr.elmId.elmnt)
269 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
274 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
278 reason = LCM_REASON_INVALID_ELMNT;
279 RLOG1(L_ERROR, "Invalid Elmnt=%d",
280 cfg->hdr.elmId.elmnt);
284 if (reason != LCM_REASON_NOT_APPL)
289 cfm.cfm.status = ret;
290 cfm.cfm.reason = reason;
292 RgMiLrgCfgCfm(&cfmPst, &cfm);
295 }/*-- RgMiLrgCfgReq --*/
299 * @brief Layer Manager Statistics request handler.
303 * Function : RgMiLrgStsReq
305 * This function handles the statistics
306 * request received from the Layer Manager.
307 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
308 * statistics from the rgCb global control block.
309 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
310 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
312 * @param[in] Pst *pst, the post structure
313 * @param[in] RgMngmt *sts, the statistics parameter's structure
318 PUBLIC S16 RgMiLrgStsReq
320 Pst *pst, /* post structure */
321 RgMngmt *sts /* statistics structure */
324 PUBLIC S16 RgMiLrgStsReq(pst, sts)
325 Pst *pst; /* post structure */
326 RgMngmt *sts; /* statistics structure */
336 RG_IS_INST_VALID(pst->dstInst);
337 inst = pst->dstInst - RG_INST_START;
338 /* Fill the post structure for sending the confirmation */
339 rgLMMFillCfmPst(pst, &cfmPst, sts);
341 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
344 cfm.hdr.transId = sts->hdr.transId;
346 SGetDateTime(&cfm.t.sts.dt);
347 cfm.cfm.status = LCM_PRIM_OK;
348 cfm.cfm.reason = LCM_REASON_NOT_APPL;
349 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
350 cfm.t.sts.action = sts->t.sts.action;
352 /* Check if General Config Done */
353 if(rgCb[inst].rgInit.cfgDone != TRUE)
355 cfm.cfm.status = LCM_PRIM_NOK;
356 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
357 RgMiLrgStsCfm(&cfmPst,&cfm);
358 RLOG0(L_ERROR, "Gen Cfg not done");
362 switch(sts->hdr.elmId.elmnt)
366 cmMemcpy((U8 *)&(cfm.t.sts.s.genSts), (U8 *)&rgCb[inst].genSts,
368 /* check if action is read and reset */
369 if(sts->t.sts.action == ARST)
371 rgCb[inst].genSts.numHarqFail = 0;
376 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
378 for(cqi=0; cqi <= 14; cqi++)
380 /* Filling DL ACK/NACK stats */
381 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
382 hqFailStats.dlCqiStat[cqi].mcs;
383 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
384 hqFailStats.dlCqiStat[cqi].numOfNacks;
385 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
386 hqFailStats.dlCqiStat[cqi].numOfAcks;
388 /* Filling UL ACK/NACK stats */
389 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
390 hqFailStats.ulCqiStat[cqi].mcs;
391 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
392 hqFailStats.ulCqiStat[cqi].numOfNacks;
393 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
394 hqFailStats.ulCqiStat[cqi].numOfAcks;
396 /* Filling DL HQ Retx stats */
397 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
398 hqRetxStats.dlCqiStat[cqi].mcs;
399 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
400 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
401 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
402 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
403 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
404 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
405 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
406 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
407 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
408 hqRetxStats.dlCqiStat[cqi].totalTx;
410 /* Filling UL HQ Retx stats */
411 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
412 hqRetxStats.ulCqiStat[cqi].mcs;
413 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
414 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
415 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
416 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
417 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
418 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
419 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
420 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
421 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
422 hqRetxStats.ulCqiStat[cqi].totalTx;
424 /* Reset statistics */
425 if(sts->t.sts.action == ZEROSTS)
427 cmMemset((U8 *)&hqRetxStats, 0, \
428 sizeof(RgSchHqRetxStats));
429 cmMemset((U8 *)&hqFailStats, 0, \
430 sizeof(RgSchNackAckStats));
433 #endif /* MAC_SCH_STATS*/
437 cmMemcpy((U8 *)&(cfm.t.sts.s.rguSts), (U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
440 /* check if action is read and reset */
441 if(sts->t.sts.action == ARST)
442 cmMemset((U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
446 cmMemcpy((U8 *)&(cfm.t.sts.s.crgSts), (U8 *)&rgCb[inst].crgSap.sapSts,
449 /* check if action is read and reset */
450 if(sts->t.sts.action == ARST)
451 cmMemset((U8 *)&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
455 cmMemcpy((U8 *)&(cfm.t.sts.s.tfuSts), (U8 *)&rgCb[inst].tfuSap.sapSts,
458 /* check if action is read and reset */
459 if(sts->t.sts.action == ARST)
460 cmMemset((U8 *)&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
464 cfm.cfm.status = LCM_PRIM_NOK;
465 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
466 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
469 RgMiLrgStsCfm(&cfmPst,&cfm);
471 }/*-- RgMiLrgStsReq --*/
475 * @brief Layer Manager Status request handler.
479 * Function : RgMiLrgStaReq
481 * This function handles the solicited status
482 * request received from the Layer Manager.
483 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
484 * particular SAP from the rgCb global control block.
485 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
487 * @param[in] Pst *pst, the post structure
488 * @param[in] RgMngmt *sta, the status parameter's structure
493 PUBLIC S16 RgMiLrgStaReq
495 Pst *pst, /* post structure */
496 RgMngmt *sta /* status structure */
499 PUBLIC S16 RgMiLrgStaReq(pst, sta)
500 Pst *pst; /* post structure */
501 RgMngmt *sta; /* status structure */
511 RG_IS_INST_VALID(pst->dstInst);
512 inst = pst->dstInst - RG_INST_START;
515 /* Fill the post structure for sending the confirmation */
516 rgLMMFillCfmPst(pst, &cfmPst, sta);
518 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
520 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
523 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
524 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
527 cfm.hdr.transId = sta->hdr.transId;
529 /* Check if General Config Done */
530 if(rgCb[inst].rgInit.cfgDone != TRUE)
532 SGetDateTime(&cfm.t.ssta.dt);
533 if (SGetSBuf(cfmPst.region, cfmPst.pool,
534 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
537 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
540 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
541 rgGetSId(&cfm.t.ssta.s.sysId);
542 cfm.cfm.status = LCM_PRIM_NOK;
543 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
544 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
545 RgMiLrgStaCfm(&cfmPst, &cfm);
546 RLOG0(L_ERROR, "Gen Cfg not done");
550 switch(sta->hdr.elmId.elmnt)
553 SGetDateTime(&cfm.t.ssta.dt);
554 if (SGetSBuf(cfmPst.region, cfmPst.pool,
555 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
558 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
561 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
562 rgGetSId(&cfm.t.ssta.s.sysId);
563 cfm.cfm.status = LCM_PRIM_OK;
564 cfm.cfm.reason = LCM_REASON_NOT_APPL;
565 RgMiLrgStaCfm(&cfmPst, &cfm);
568 cfm.cfm.status = LCM_PRIM_OK;
569 cfm.cfm.reason = LCM_REASON_NOT_APPL;
570 SGetDateTime(&cfm.t.ssta.dt);
571 cmMemcpy((U8 *)&(cfm.t.ssta.s.rguSapSta),
572 (U8 *)&rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
574 RgMiLrgStaCfm(&cfmPst, &cfm);
577 cfm.cfm.status = LCM_PRIM_OK;
578 cfm.cfm.reason = LCM_REASON_NOT_APPL;
579 SGetDateTime(&cfm.t.ssta.dt);
580 cmMemcpy((U8 *)&(cfm.t.ssta.s.crgSapSta), (U8 *)&rgCb[inst].crgSap.sapSta,
582 RgMiLrgStaCfm(&cfmPst, &cfm);
585 cfm.cfm.status = LCM_PRIM_OK;
586 cfm.cfm.reason = LCM_REASON_NOT_APPL;
587 SGetDateTime(&cfm.t.ssta.dt);
588 cmMemcpy((U8 *)&(cfm.t.ssta.s.tfuSapSta), (U8 *)&rgCb[inst].tfuSap.sapSta,
590 RgMiLrgStaCfm(&cfmPst, &cfm);
593 cfm.cfm.status = LCM_PRIM_NOK;
594 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
595 RgMiLrgStaCfm(&cfmPst, &cfm);
596 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
600 }/*-- RgMiLrgStaReq --*/
604 * @brief Layer Manager Control request handler.
608 * Function : RgMiLrgCntrlReq
610 * This function handles the control
611 * request received from the Layer Manager.
612 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
613 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
614 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
615 * and layer shutdown.
616 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
618 * @param[in] Pst *pst, the post structure
619 * @param[in] RgMngmt *cntrl, the control parameter's structure
624 PUBLIC S16 RgMiLrgCntrlReq
626 Pst *pst, /* post structure */
627 RgMngmt *cntrl /* control structure */
630 PUBLIC S16 RgMiLrgCntrlReq(pst, cntrl)
631 Pst *pst; /* post structure */
632 RgMngmt *cntrl; /* control structure */
635 S16 ret = ROK; /* return value */
640 TRC2(RgMiLrgCntrlReq)
642 /* Fill the post structure for sending the confirmation */
644 RG_IS_INST_VALID(pst->dstInst);
645 inst = pst->dstInst - RG_INST_START;
647 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
649 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
651 cfm.hdr.transId = cntrl->hdr.transId;
653 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
654 cfm.t.cntrl.action = cntrl->t.cntrl.action;
655 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
657 /* Check if General Config Done*/
658 if(rgCb[inst].rgInit.cfgDone != TRUE)
660 cfm.cfm.status = LCM_PRIM_NOK;
661 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
662 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
663 RgMiLrgCntrlCfm(&cfmPst, &cfm);
664 RLOG0(L_ERROR, "Gen Cfg not done");
668 /* General Config done, process the Control request */
669 switch(cntrl->hdr.elmId.elmnt)
672 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
677 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
680 cfm.cfm.status = LCM_PRIM_NOK;
681 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
682 RgMiLrgCntrlCfm(&cfmPst, &cfm);
683 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
687 }/*-- RgMiLrgCntrlReq --*/
691 * @brief SAP Configuration Handler.
695 * Function : rgLMMSapCfg
697 * This function in called by RgMiLrgCfgReq(). It handles the
698 * interface SAP configuration of the LTE MAC layer. It
699 * initializes the sapState to LRG_UNBND. Returns
700 * reason for success/failure of this function.
702 * @param[in] Inst inst
703 * @param[in] RgCfg *cfg, the Configuaration information
705 * -# LCM_REASON_GENCFG_NOT_DONE
706 * -# LCM_REASON_INVALID_SAP
707 * -# LCM_REASON_NOT_APPL
710 PRIVATE U16 rgLMMSapCfg
713 RgCfg *cfg, /* Configuaration information */
714 Elmnt sapType /* Sap Type */
717 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
719 RgCfg *cfg; /* Configuaration information */
720 Elmnt sapType; /* Sap Type */
723 U16 ret = LCM_REASON_NOT_APPL;
724 RgLowSapCfgInfo *lowSapCfg = NULLP;
725 RgUpSapCfgInfo *upSapCfg = NULLP;
726 RgUpSapCb *upSapCb = NULLP;
730 /* Check if Gen Config has been done */
731 if(rgCb[inst].rgInit.cfgDone != TRUE)
732 RETVALUE(LCM_REASON_GENCFG_NOT_DONE);
737 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
738 (cfg->s.rguSap.selector != RGU_SEL_TC) &&
739 (cfg->s.rguSap.selector != RGU_SEL_LC))
741 ret = LCM_REASON_INVALID_PAR_VAL;
742 RLOG0(L_ERROR, "unsupported Selector value for RGU");
745 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
746 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
748 upSapCb->sapSta.sapState = LRG_UNBND;
750 upSapCfg = &(upSapCb->sapCfg);
751 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
752 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
753 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
754 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
755 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
756 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
757 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
758 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
759 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
760 upSapCfg->sapPst.route = cfg->s.rguSap.route;
761 upSapCfg->sapPst.intfVer = 0;
762 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
763 upSapCfg->suId = cfg->s.rguSap.suId;
764 upSapCfg->spId = cfg->s.rguSap.spId;
765 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
766 * there is cfg request with sap is 1*/
769 if ((cfg->s.crgSap.selector != CRG_SEL_TC) &&
770 (cfg->s.crgSap.selector != CRG_SEL_LC))
772 ret = LCM_REASON_INVALID_PAR_VAL;
773 RLOG0(L_ERROR, "unsupported Selector value for CRG");
776 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
778 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
780 upSapCfg = &rgCb[inst].crgSap.sapCfg;
782 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
783 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
784 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
785 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
786 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
787 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
788 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
789 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
790 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
791 upSapCfg->sapPst.route = cfg->s.crgSap.route;
792 upSapCfg->sapPst.intfVer = 0;
793 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
794 upSapCfg->suId = cfg->s.crgSap.suId;
795 upSapCfg->spId = cfg->s.crgSap.spId;
799 if ((cfg->s.tfuSap.selector != TFU_SEL_TC) &&
800 (cfg->s.tfuSap.selector != TFU_SEL_LC))
802 ret = LCM_REASON_INVALID_PAR_VAL;
803 RLOG0(L_ERROR, "unsupported Selector value for TFU");
807 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
809 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
811 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
813 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
814 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
815 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
816 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
817 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
818 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
819 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
820 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
821 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
822 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
823 lowSapCfg->sapPst.intfVer = 0;
824 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
825 lowSapCfg->suId = cfg->s.tfuSap.suId;
826 lowSapCfg->spId = cfg->s.tfuSap.spId;
827 cmMemcpy((U8 *)&lowSapCfg->bndTmr, (U8 *)&cfg->s.tfuSap.bndTmr,
831 /* would never reach here */
839 * @brief General Configuration Handler.
843 * Function : rgLMMGenCfg
845 * This function in called by RgMiLrgCfgReq(). It handles the
846 * general configuration of the LTE MAC layer. It initializes
847 * the hash lists of RgCb. Returns
848 * reason for success/failure of this function.
850 * @param[in] Inst inst
851 * @param[in] RgCfg *cfg, the Configuaration information
853 * -# LCM_REASON_NOT_APPL
854 * -# LCM_REASON_INVALID_MSGTYPE
855 * -# LCM_REASON_MEM_NOAVAIL
858 PRIVATE U16 rgLMMGenCfg
861 RgCfg *cfg /* Configuaration information */
864 PRIVATE U16 rgLMMGenCfg(inst,cfg)
866 RgCfg *cfg; /* Configuaration information */
869 U16 ret = LCM_REASON_NOT_APPL;
873 /* Check if General Configuration is done already */
874 if (rgCb[inst].rgInit.cfgDone == TRUE)
876 RETVALUE(LCM_REASON_INVALID_MSGTYPE);
878 if ((cfg->s.genCfg.lmPst.selector != LRG_SEL_TC) &&
879 (cfg->s.genCfg.lmPst.selector != LRG_SEL_LC))
881 RLOG0(L_ERROR, "unsupported Selector value for RGU");
882 RETVALUE(LCM_REASON_INVALID_PAR_VAL);
884 /* Update the Pst structure for LM interface */
885 cmMemcpy((U8 *)&rgCb[inst].rgInit.lmPst, (U8 *)&cfg->s.genCfg.lmPst,
888 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
889 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
890 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
891 rgCb[inst].rgInit.lmPst.event = EVTNONE;
893 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
894 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
895 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
896 /* Initialize SAP States */
897 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
899 if(cfg->s.genCfg.numRguSaps == 0)
901 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
905 /* allocate RGR saps */
906 if (SGetSBuf(rgCb[inst].rgInit.region,
907 rgCb[inst].rgInit.pool,
908 (Data **)&rgCb[inst].rguSap,
909 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
911 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
914 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
916 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
918 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
919 cmMemset((U8 *)&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
921 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
922 /* Initialize the timer blocks */
923 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
924 /* Initialzie the timer queue */
925 cmMemset((U8 *)&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
926 /* Initialize the timer control point */
927 cmMemset((U8 *)&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
928 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
929 /* Timer Registration request to SSI */
930 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
931 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
934 RLOG0(L_ERROR, "Failed to register timer");
936 SPutSBuf(rgCb[inst].rgInit.region,
937 rgCb[inst].rgInit.pool,
938 (Data *)rgCb[inst].rguSap,
939 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
941 RETVALUE(LCM_REASON_MEM_NOAVAIL);
943 /* Set Config done in TskInit */
944 rgCb[inst].rgInit.cfgDone = TRUE;
950 /***********************************************************
952 * Func : rgLMMShutdown
955 * Desc : Handles the MAC layer shutdown request. Calls
956 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
965 **********************************************************/
967 PRIVATE Void rgLMMShutdown
972 PRIVATE Void rgLMMShutdown(inst)
976 RgCellCb *cell = rgCb[inst].cell;
981 /* Unbind the TFU Sap */
982 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
984 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
985 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
987 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
989 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
991 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
993 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
994 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1000 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1002 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1005 rgCFGFreeCellCb(cell);
1008 /* Deleting the RGU SAPs */
1009 SPutSBuf(rgCb[inst].rgInit.region,
1010 rgCb[inst].rgInit.pool,
1011 (Data *)rgCb[inst].rguSap,
1012 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1013 rgCb[inst].rguSap = NULLP;
1015 rgCb[inst].inactiveCell = NULLP;
1016 rgCb[inst].cell = NULLP;
1018 /* De-register the Timer Service */
1019 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1020 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1022 /* call back the task initialization function to intialize
1023 * the global RgCb Struct */
1024 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1025 rgCb[inst].rgInit.reason);
1031 /***********************************************************
1033 * Func : rgLMMGenCntrl
1036 * Desc : Processes the LM control request for STGEN elmnt.
1045 **********************************************************/
1047 PRIVATE Void rgLMMGenCntrl
1054 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1060 Inst inst = (cfmPst->srcInst - RG_INST_START);
1063 cfm->cfm.status = LCM_PRIM_OK;
1064 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1067 switch(cntrl->t.cntrl.action)
1070 /* Action is Enable */
1071 switch(cntrl->t.cntrl.subAction)
1075 rgCb[inst].rgInit.trc = TRUE;
1076 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1077 /*Store the response and TransId for sending the Traces */
1078 cmMemcpy((U8 *)&rgCb[inst].genCfg.trcResp.response,
1079 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1080 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1084 /* Enable Unsolicited Status (alarms) */
1085 rgCb[inst].rgInit.usta = TRUE;
1086 /*Store the response and TransId for sending the Alarms */
1087 cmMemcpy((U8 *)&rgCb[inst].genCfg.ustaResp.response,
1088 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1089 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1092 /* Enable Debug Printing */
1094 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1099 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1104 cfm->cfm.status = LCM_PRIM_NOK;
1105 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1106 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1111 /* Action is Diable immidiately */
1112 switch(cntrl->t.cntrl.subAction)
1115 /* Disable Traces */
1116 rgCb[inst].rgInit.trc = FALSE;
1119 /* Disable Unsolicited Status (alarms) */
1120 rgCb[inst].rgInit.usta = FALSE;
1123 /* Disable Debug Printing */
1125 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1130 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1135 cfm->cfm.status = LCM_PRIM_NOK;
1136 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1137 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1142 /* Free all the memory dynamically allocated by MAC */
1143 rgLMMShutdown(inst);
1146 cfm->cfm.status = LCM_PRIM_NOK;
1147 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1148 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1151 RgMiLrgCntrlCfm(cfmPst, cfm);
1156 /***********************************************************
1158 * Func : rgLMMSapCntrl
1161 * Desc : Processes the LM control request for STxxxSAP elmnt.
1170 **********************************************************/
1172 PRIVATE Void rgLMMSapCntrl
1179 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1185 Inst inst = cfmPst->srcInst - RG_INST_START;
1188 /* Only TFU Sap can be controlled by LM */
1189 switch(cntrl->hdr.elmId.elmnt)
1192 switch(cntrl->t.cntrl.action)
1195 /* Bind Enable Request */
1196 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1197 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1199 cfm->cfm.status = LCM_PRIM_NOK;
1200 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1204 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1206 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1207 (PTR)&rgCb[inst].tfuSap);
1209 /* Change SAP state */
1210 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1211 rgCb[inst].tfuSap.numBndRetries++;
1212 /* Store the response and TransId for sending
1213 * the Control confirm */
1214 cmMemcpy((U8 *)&rgCb[inst].genCfg.bndCfmResp.response,
1215 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1216 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1218 /* Sending Status Indication to Layer Manager */
1219 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1220 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1221 RgMiLrgCntrlCfm(cfmPst, cfm);
1223 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1224 rgCb[inst].tfuSap.sapCfg.spId);
1229 /* Unbind request */
1231 /* Check if the SAP is configured */
1232 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1233 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1235 cfm->cfm.status = LCM_PRIM_NOK;
1236 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1240 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1241 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1243 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1245 /* Change SAP state */
1246 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1247 cfm->cfm.status = LCM_PRIM_OK;
1248 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1252 /* Delete SAP, does initialization of SAP */
1253 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1254 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1256 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1257 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1259 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1262 cmMemset((U8 *)&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1263 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1264 cfm->cfm.status = LCM_PRIM_OK;
1265 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1268 cfm->cfm.status = LCM_PRIM_NOK;
1269 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1270 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1271 cntrl->t.cntrl.action));
1276 switch(cntrl->t.cntrl.action)
1279 cmMemset((U8 *)&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1280 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1281 cfm->cfm.status = LCM_PRIM_OK;
1282 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1285 cfm->cfm.status = LCM_PRIM_NOK;
1286 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1287 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1288 cntrl->t.cntrl.action));
1293 switch(cntrl->t.cntrl.action)
1296 cmMemset((U8 *)&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1297 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1298 cfm->cfm.status = LCM_PRIM_OK;
1299 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1302 cfm->cfm.status = LCM_PRIM_NOK;
1303 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1304 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1310 /* Would never here. */
1313 RgMiLrgCntrlCfm(cfmPst, cfm);
1318 /***********************************************************
1320 * Func : rgLMMFillCfmPst
1323 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1324 * and the cfm->hdr.response.
1333 **********************************************************/
1335 PRIVATE Void rgLMMFillCfmPst
1342 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1349 TRC2(rgLMMFillCfmPst)
1350 inst = (reqPst->dstInst - RG_INST_START);
1352 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1353 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1354 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1355 cfmPst->dstEnt = reqPst->srcEnt;
1356 cfmPst->dstInst = reqPst->srcInst;
1357 cfmPst->dstProcId = reqPst->srcProcId;
1359 cfmPst->selector = cfm->hdr.response.selector;
1360 cfmPst->prior = cfm->hdr.response.prior;
1361 cfmPst->route = cfm->hdr.response.route;
1362 cfmPst->region = cfm->hdr.response.mem.region;
1363 cfmPst->pool = cfm->hdr.response.mem.pool;
1370 * @brief Timer start handler.
1374 * Function : rgLMMStartTmr
1376 * This function based on the input parameters starts the timer for
1377 * "tmrVal" duration. As of now MAC uses the timer functionality for
1378 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1380 * @param[in] Inst inst
1381 * @param[in] S16 tmrEvnt, the Timer Event
1382 * @param[in] U32 tmrVal, the Wait Time
1383 * @param[in] PTR cb, Entry for which Timer expired
1388 PUBLIC S16 rgLMMStartTmr
1391 S16 tmrEvnt, /* Timer Event */
1392 U32 tmrVal, /* Wait Time */
1393 PTR cb /* Entry for which Timer Expired */
1396 PUBLIC S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1398 S16 tmrEvnt; /* Timer Event */
1399 U32 tmrVal; /* Wait Time */
1400 PTR cb; /* Entry for which Timer Expired */
1409 /* Initialize the arg structure */
1410 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1412 arg.tqCp = &rgCb[inst].tmrTqCp;
1413 arg.tq = rgCb[inst].tmrTq;
1414 arg.timers = rgCb[inst].tmrBlk;
1417 arg.max = RG_MAX_TIMER;
1418 arg.evnt = RG_BNDREQ_TMR;
1427 * @brief Timer stop handler.
1431 * Function : rgLMMStopTmr
1433 * This function based on the input parameters stops the timer for
1434 * "tmrEvnt". As of now MAC uses the timer functionality for
1435 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1436 * Once the bind happens and this timer is stopped, the timer functionality
1437 * is deregistered with SSI. As there is no further use of timer processing.
1439 * @param[in] Inst inst
1440 * @param[in] S16 tmrEvnt, the Timer Event
1441 * @param[in] PTR cb, Entry for which Timer expired
1447 PUBLIC S16 rgLMMStopTmr
1449 Inst inst, /* Scheduler instance */
1450 S16 tmrEvnt, /* Timer Event */
1451 PTR cb /* Entry for which Timer Expired */
1454 PUBLIC S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1455 Inst inst; /* Scheduler instance */
1456 S16 tmrEvnt; /* Timer Event */
1457 PTR cb; /* Entry for which Timer Expired */
1468 for(i=0;i<RG_MAX_TIMER;i++)
1470 /* Search for the Timer Blocks */
1471 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1473 /* Initialize the arg structure */
1474 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1476 arg.tqCp = &rgCb[inst].tmrTqCp;
1477 arg.tq = rgCb[inst].tmrTq;
1478 arg.timers = rgCb[inst].tmrBlk;
1480 arg.max = RG_MAX_TIMER;
1498 * @brief Timer Expiry handler.
1502 * Function : rgLMMTmrExpiry
1504 * This is a callback function used as an input parameter to cmPrcTmr()
1505 * to check expiry of any timer. In this function, the only concern is
1506 * about tmrEvnt=Bind timer.
1508 * @param[in] PTR cb, Entry for which Timer expired
1509 * @param[in] S16 tmrEvnt, the Timer Event
1514 PUBLIC S16 rgLMMTmrExpiry
1516 PTR cb, /* Pointer to timer control block */
1517 S16 tmrEvnt /* Timer Event */
1520 PUBLIC S16 rgLMMTmrExpiry(cb,tmrEvnt)
1521 PTR cb; /* Pointer to timer control block */
1522 S16 tmrEvnt; /* Timer Event */
1526 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1527 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1529 TRC2(rgLMMTmrExpiry)
1535 tfuSap->numBndRetries++;
1536 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1538 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1539 LCM_CAUSE_TMR_EXPIRED, NULLP);
1543 /* Restart the bind timer */
1544 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1546 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1550 /* Send bind request */
1551 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1552 rgCb[inst].tfuSap.sapCfg.spId);
1556 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1566 * @brief Layer Manager Unsolicited Status Indication generation.
1570 * Function : rgLMMStaInd
1572 * This API is used by the other modules of MAC to send a unsolicited
1573 * status indication to the Layer Manager.
1575 * @param[in] Inst inst
1576 * @param[in] U16 category, the Alarm category
1577 * @param[in] U16 event, the Alarm event
1578 * @param[in] U16 cause, the cause of the Alarm
1579 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1584 PUBLIC S16 rgLMMStaInd
1593 PUBLIC S16 rgLMMStaInd(inst,category, event, cause, dgn)
1605 if(rgCb[inst].rgInit.usta == FALSE)
1610 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1612 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1613 usta.t.usta.cmAlarm.category = category;
1614 usta.t.usta.cmAlarm.event = event;
1615 usta.t.usta.cmAlarm.cause = cause;
1618 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1621 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1622 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1623 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1624 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1625 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1626 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1628 RETVALUE(RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1633 * @brief Layer Manager Trace Indication generation.
1637 * Function : rgLMMTrcInd
1639 * This API is used by the other modules of MAC to send a
1640 * Trace indication to the Layer Manager.
1642 * @param[in] Inst inst
1643 * @param[in] Buffer *srcMbuf, the Message Buffer .
1644 * @param[in] U8 event, the trace event.
1648 PUBLIC Void rgLMMTrcInd
1651 Buffer *srcMbuf, /* Message Buffer */
1652 U8 event /* event */
1655 PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
1657 Buffer *srcMbuf; /* Message Buffer */
1658 U8 event; /* event */
1661 Buffer *dstMbuf = NULLP;
1671 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1673 RLOG0(L_ERROR, "Trace Disabled.");
1677 cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
1679 pst = rgCb[inst].rgInit.lmPst;
1680 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1681 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1682 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1683 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1684 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1686 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1688 SGetDateTime(&trc.t.trc.dt);
1690 /* Check if the whole buffer is to be sent in Trace indication */
1691 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1693 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1696 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1699 trc.cfm.status = LCM_PRIM_OK;
1700 trc.cfm.reason = LCM_REASON_NOT_APPL;
1701 trc.t.trc.evnt = event;
1703 /* Send Trace Indication to Layer manager */
1704 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1706 /* check if only a specified number of bytes are to be sent */
1707 else if(rgCb[inst].trcLen > 0)
1709 /* Get the length of the recvd message buffer */
1710 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1712 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1715 /* Check if the recvd buffer size is less than request trace len */
1716 if(bufLen < rgCb[inst].trcLen)
1718 /* Copy the whole of the recvd buffer in trace indication */
1720 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1723 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1727 trc.cfm.status = LCM_PRIM_OK;
1728 trc.cfm.reason = LCM_REASON_NOT_APPL;
1729 trc.t.trc.evnt = event;
1731 /* Send Trace Indication to Layer manager */
1732 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1734 /* if the recvd buffer size is greater than request trace len */
1735 if(bufLen >= rgCb[inst].trcLen)
1737 /* Get a temporary buffer to store the msg */
1738 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1740 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1744 /* Copy trcLen nos of bytes from the recvd message */
1745 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1747 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1751 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1753 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1756 /* Copy the tempBuf data to dst mBuf */
1757 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1759 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1763 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1765 /* Free the memory allocated for tempBuf */
1766 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1768 trc.cfm.status = LCM_PRIM_OK;
1769 trc.cfm.reason = LCM_REASON_NOT_APPL;
1770 trc.t.trc.evnt = event;
1772 /* Send Trace Indication to Layer manager */
1773 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1781 * @brief Layer Manager Control Confirm generation handler
1782 * for Bind Confirm reception at TFU interface.
1783 * RgLiTfuBndCfm() forwards the confirmation to this
1784 * function. All SAP state related handling is restricted
1785 * to LMM modules, hence the cfm forwarding.
1789 * Function : rgLMMBndCfm
1791 * This API is used by the LIM module of MAC to forward
1792 * the Bind Confirm it receives over the TFU interface.
1794 * @param[in] Pst *pst, Post Structure
1795 * @param[in] SuId suId, Service user ID
1796 * @param[in] U8 status, Status
1801 PUBLIC S16 rgLMMBndCfm
1803 Pst *pst, /* Post Structure */
1804 SuId suId, /* Service user ID */
1805 U8 status /* Status */
1808 PUBLIC S16 rgLMMBndCfm(pst,suId,status)
1809 Pst *pst; /* Post Structure */
1810 SuId suId; /* Service user ID */
1811 U8 status; /* Status */
1814 Inst inst = pst->dstInst - RG_INST_START;
1823 /* Check if the suId is valid */
1824 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1826 RLOG0(L_ERROR, "Invalid SuId");
1830 /* check the Sap State */
1831 switch(rgCb[inst].tfuSap.sapSta.sapState)
1833 case LRG_WAIT_BNDCFM:
1836 /* SAP is already bound */
1842 cfmPst = rgCb[inst].rgInit.lmPst;
1843 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1844 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1845 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1846 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1847 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1849 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1853 case CM_BND_OK: /* status is OK */
1854 /* Change SAP state to Bound */
1855 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1856 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1858 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1860 /* Send Control Confirm with status as OK to Layer Manager */
1861 cntrlCfm.cfm.status = LCM_PRIM_OK;
1862 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1866 /* Change SAP state to UnBound */
1867 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1868 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1870 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1872 /* Send Control Confirm with status as NOK to Layer Manager */
1873 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1874 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1877 rgCb[inst].tfuSap.numBndRetries = 0;
1878 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1879 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1881 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1888 * @brief LTE MAC timer call back function registered with SSI.
1892 * Function : rgActvTmr
1894 * This function is invoked by SSI for every timer activation
1901 PUBLIC S16 rgActvTmr
1907 PUBLIC S16 rgActvTmr(ent, inst)
1912 Inst macInst = (inst - RG_INST_START);
1915 /* Check if any MAC timer has expired */
1916 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1920 } /* end of rgActvTmr */
1923 /**********************************************************************
1926 **********************************************************************/