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 "common_def.h"
42 #include "rg_env.h" /* MAC Environment Defines */
43 #include "crg.h" /* CRG Interface defines */
44 #include "rgu.h" /* RGU Interface defines */
45 #include "tfu.h" /* RGU Interface defines */
46 #include "rg_sch_inf.h" /* RGR Interface defines */
47 #include "lrg.h" /* LRG Interface defines */
48 #include "rgr.h" /* LRG Interface defines */
49 #include "rg.h" /* MAC defines */
50 #include "rg_err.h" /* MAC error defines */
52 /* header/extern include files (.x) */
53 #include "crg.x" /* CRG Interface includes */
54 #include "rgu.x" /* RGU Interface includes */
55 #include "tfu.x" /* RGU Interface includes */
56 #include "rg_sch_inf.x" /* SCH Interface includes */
57 #include "rg_prg.x" /* PRG Interface includes */
58 #include "lrg.x" /* LRG Interface includes */
59 #include "rgr.x" /* LRG Interface includes */
60 #include "du_app_mac_inf.h"
61 #include "rg.x" /* MAC includes */
63 #include "ss_diag.h" /* Common log file */
67 #include "lwr_mac.h" /* MAC CL defines */
68 #include "mac_sch_interface.h"
69 #include "lwr_mac_upr_inf.h"
71 #include "lwr_mac_phy.h"
72 #include "lwr_mac_fsm.h"
76 #endif /* __cplusplus */
77 EXTERN Void rgGetSId ARGS((SystemId *s));
80 #endif /* __cplusplus */
82 /* Public variable declaration */
86 /* forward references */
87 PRIVATE U16 rgLMMGenCfg ARGS((
92 PRIVATE U16 rgLMMSapCfg ARGS((
98 PRIVATE Void rgLMMShutdown ARGS((
102 PRIVATE Void rgLMMFillCfmPst ARGS((
108 PRIVATE Void rgLMMGenCntrl ARGS((
114 PRIVATE Void rgLMMSapCntrl ARGS((
122 * @brief Task Initiation callback function.
126 * Function : rgActvInit
128 * This function is supplied as one of parameters during MAC's
129 * task registration. SSI will invoke this function once, after
130 * it creates and attaches this TAPA Task to a system task.
132 * @param[in] Ent entity, the entity ID of this task.
133 * @param[in] Inst inst, the instance ID of this task.
134 * @param[in] Region region, the region ID registered for memory
135 * usage of this task.
136 * @param[in] Reason reason.
141 PUBLIC S16 rgActvInit
143 Ent entity, /* entity */
144 Inst inst, /* instance */
145 Region region, /* region */
146 Reason reason /* reason */
149 PUBLIC S16 rgActvInit(entity, inst, region, reason)
150 Ent entity; /* entity */
151 Inst inst; /* instance */
152 Region region; /* region */
153 Reason reason; /* reason */
159 RG_IS_INST_VALID(inst);
161 macInst = inst - RG_INST_START;
162 /* Initialize the MAC TskInit structure to zero */
163 cmMemset ((U8 *)&rgCb[macInst], 0, sizeof(RgCb));
165 /* Initialize the MAC TskInit with received values */
166 rgCb[macInst].rgInit.ent = entity;
167 rgCb[macInst].rgInit.inst = inst;
168 rgCb[macInst].rgInit.region = region;
169 rgCb[macInst].rgInit.pool = 0;
170 rgCb[macInst].rgInit.reason = reason;
171 rgCb[macInst].rgInit.cfgDone = FALSE;
172 rgCb[macInst].rgInit.acnt = FALSE;
173 rgCb[macInst].rgInit.usta = FALSE;
174 rgCb[macInst].rgInit.trc = FALSE;
175 rgCb[macInst].trcLen = 0;
178 /* disabling debugs by default */
179 rgCb[macInst].rgInit.dbgMask = 0xffffffff;
183 rgCb[macInst].rgInit.logMask = 0x0;
185 rgCb[macInst].rgInit.procId = SFndProcId();
186 rgCb[macInst].tfuSap.numBndRetries = 0;
188 /* Initialize Sap state */
189 rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
190 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
191 rgCb[macInst].rguSap = NULLP;
192 rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
194 rgCb[macInst].inactiveCell = NULLP;
195 rgCb[macInst].cell = NULLP;
197 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
198 SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
201 /* Initializing CL control block */
202 memset(&lwrMacCb, 0, sizeof(LwrMacCb));
203 lwrMacCb.region = region;
205 lwrMacCb.clCfgDone = TRUE;
206 lwrMacCb.numCell = 0;
207 lwrMacCb.phyState = PHY_STATE_IDLE;
209 /* Initialize Scheduler as well */
210 schActvInit(ENTRG, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
212 /* Initialize lower mac */
220 * @brief Layer Manager Configuration request handler.
224 * Function : RgMiLrgCfgReq
226 * This function handles the configuration
227 * request received from the Layer Manager.
228 * -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
229 * functions rgHdlGenCfg() or rgHdlSapCfg().
230 * -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
232 * @param[in] Pst *pst, the post structure
233 * @param[in] RgMngmt *cfg, the configuration parameter's structure
238 PUBLIC S16 RgMiLrgCfgReq
240 Pst *pst, /* post structure */
241 RgMngmt *cfg /* config structure */
244 PUBLIC S16 RgMiLrgCfgReq(pst, cfg)
245 Pst *pst; /* post structure */
246 RgMngmt *cfg; /* config structure */
249 U16 ret = LCM_PRIM_OK;
250 U16 reason = LCM_REASON_NOT_APPL;
258 RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
259 "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
260 pst->srcEnt, pst->srcInst,0,0);
262 RG_IS_INST_VALID(pst->dstInst);
263 inst = pst->dstInst - RG_INST_START;
265 /* Fill the post structure for sending the confirmation */
266 rgLMMFillCfmPst(pst, &cfmPst, cfg);
268 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
271 cfm.hdr.transId = cfg->hdr.transId;
275 cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
276 switch(cfg->hdr.elmId.elmnt)
279 reason = rgLMMGenCfg(inst,&cfg->t.cfg);
284 reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
288 reason = LCM_REASON_INVALID_ELMNT;
289 RLOG1(L_ERROR, "Invalid Elmnt=%d",
290 cfg->hdr.elmId.elmnt);
294 if (reason != LCM_REASON_NOT_APPL)
299 cfm.cfm.status = ret;
300 cfm.cfm.reason = reason;
302 RgMiLrgCfgCfm(&cfmPst, &cfm);
305 }/*-- RgMiLrgCfgReq --*/
309 * @brief Layer Manager Statistics request handler.
313 * Function : RgMiLrgStsReq
315 * This function handles the statistics
316 * request received from the Layer Manager.
317 * -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
318 * statistics from the rgCb global control block.
319 * -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
320 * -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
322 * @param[in] Pst *pst, the post structure
323 * @param[in] RgMngmt *sts, the statistics parameter's structure
328 PUBLIC S16 RgMiLrgStsReq
330 Pst *pst, /* post structure */
331 RgMngmt *sts /* statistics structure */
334 PUBLIC S16 RgMiLrgStsReq(pst, sts)
335 Pst *pst; /* post structure */
336 RgMngmt *sts; /* statistics structure */
346 RG_IS_INST_VALID(pst->dstInst);
347 inst = pst->dstInst - RG_INST_START;
348 /* Fill the post structure for sending the confirmation */
349 rgLMMFillCfmPst(pst, &cfmPst, sts);
351 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
354 cfm.hdr.transId = sts->hdr.transId;
356 SGetDateTime(&cfm.t.sts.dt);
357 cfm.cfm.status = LCM_PRIM_OK;
358 cfm.cfm.reason = LCM_REASON_NOT_APPL;
359 cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
360 cfm.t.sts.action = sts->t.sts.action;
362 /* Check if General Config Done */
363 if(rgCb[inst].rgInit.cfgDone != TRUE)
365 cfm.cfm.status = LCM_PRIM_NOK;
366 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
367 RgMiLrgStsCfm(&cfmPst,&cfm);
368 RLOG0(L_ERROR, "Gen Cfg not done");
372 switch(sts->hdr.elmId.elmnt)
376 cmMemcpy((U8 *)&(cfm.t.sts.s.genSts), (U8 *)&rgCb[inst].genSts,
378 /* check if action is read and reset */
379 if(sts->t.sts.action == ARST)
381 rgCb[inst].genSts.numHarqFail = 0;
386 RgGenSts *genSts = &(cfm.t.sts.s.genSts);
388 for(cqi=0; cqi <= 14; cqi++)
390 /* Filling DL ACK/NACK stats */
391 genSts->nackAckStats.dlCqiStat[cqi].mcs = \
392 hqFailStats.dlCqiStat[cqi].mcs;
393 genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
394 hqFailStats.dlCqiStat[cqi].numOfNacks;
395 genSts->nackAckStats.dlCqiStat[cqi].numOfAcks =
396 hqFailStats.dlCqiStat[cqi].numOfAcks;
398 /* Filling UL ACK/NACK stats */
399 genSts->nackAckStats.ulCqiStat[cqi].mcs = \
400 hqFailStats.ulCqiStat[cqi].mcs;
401 genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
402 hqFailStats.ulCqiStat[cqi].numOfNacks;
403 genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
404 hqFailStats.ulCqiStat[cqi].numOfAcks;
406 /* Filling DL HQ Retx stats */
407 genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
408 hqRetxStats.dlCqiStat[cqi].mcs;
409 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
410 hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
411 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
412 hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
413 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
414 hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
415 genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
416 hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
417 genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
418 hqRetxStats.dlCqiStat[cqi].totalTx;
420 /* Filling UL HQ Retx stats */
421 genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
422 hqRetxStats.ulCqiStat[cqi].mcs;
423 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
424 hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
425 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
426 hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
427 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
428 hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
429 genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
430 hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
431 genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
432 hqRetxStats.ulCqiStat[cqi].totalTx;
434 /* Reset statistics */
435 if(sts->t.sts.action == ZEROSTS)
437 cmMemset((U8 *)&hqRetxStats, 0, \
438 sizeof(RgSchHqRetxStats));
439 cmMemset((U8 *)&hqFailStats, 0, \
440 sizeof(RgSchNackAckStats));
443 #endif /* MAC_SCH_STATS*/
447 cmMemcpy((U8 *)&(cfm.t.sts.s.rguSts), (U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
450 /* check if action is read and reset */
451 if(sts->t.sts.action == ARST)
452 cmMemset((U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
456 cmMemcpy((U8 *)&(cfm.t.sts.s.crgSts), (U8 *)&rgCb[inst].crgSap.sapSts,
459 /* check if action is read and reset */
460 if(sts->t.sts.action == ARST)
461 cmMemset((U8 *)&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
465 cmMemcpy((U8 *)&(cfm.t.sts.s.tfuSts), (U8 *)&rgCb[inst].tfuSap.sapSts,
468 /* check if action is read and reset */
469 if(sts->t.sts.action == ARST)
470 cmMemset((U8 *)&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
474 cfm.cfm.status = LCM_PRIM_NOK;
475 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
476 RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
479 RgMiLrgStsCfm(&cfmPst,&cfm);
481 }/*-- RgMiLrgStsReq --*/
485 * @brief Layer Manager Status request handler.
489 * Function : RgMiLrgStaReq
491 * This function handles the solicited status
492 * request received from the Layer Manager.
493 * -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
494 * particular SAP from the rgCb global control block.
495 * -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
497 * @param[in] Pst *pst, the post structure
498 * @param[in] RgMngmt *sta, the status parameter's structure
503 PUBLIC S16 RgMiLrgStaReq
505 Pst *pst, /* post structure */
506 RgMngmt *sta /* status structure */
509 PUBLIC S16 RgMiLrgStaReq(pst, sta)
510 Pst *pst; /* post structure */
511 RgMngmt *sta; /* status structure */
521 RG_IS_INST_VALID(pst->dstInst);
522 inst = pst->dstInst - RG_INST_START;
525 /* Fill the post structure for sending the confirmation */
526 rgLMMFillCfmPst(pst, &cfmPst, sta);
528 if (sta->t.ssta.s.sysId.ptNmb != NULLP)
530 SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
533 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
534 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
537 cfm.hdr.transId = sta->hdr.transId;
539 /* Check if General Config Done */
540 if(rgCb[inst].rgInit.cfgDone != TRUE)
542 SGetDateTime(&cfm.t.ssta.dt);
543 if (SGetSBuf(cfmPst.region, cfmPst.pool,
544 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
547 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
550 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
551 rgGetSId(&cfm.t.ssta.s.sysId);
552 cfm.cfm.status = LCM_PRIM_NOK;
553 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
554 cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
555 RgMiLrgStaCfm(&cfmPst, &cfm);
556 RLOG0(L_ERROR, "Gen Cfg not done");
560 switch(sta->hdr.elmId.elmnt)
563 SGetDateTime(&cfm.t.ssta.dt);
564 if (SGetSBuf(cfmPst.region, cfmPst.pool,
565 (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
568 RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
571 cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
572 rgGetSId(&cfm.t.ssta.s.sysId);
573 cfm.cfm.status = LCM_PRIM_OK;
574 cfm.cfm.reason = LCM_REASON_NOT_APPL;
575 RgMiLrgStaCfm(&cfmPst, &cfm);
578 cfm.cfm.status = LCM_PRIM_OK;
579 cfm.cfm.reason = LCM_REASON_NOT_APPL;
580 SGetDateTime(&cfm.t.ssta.dt);
581 cmMemcpy((U8 *)&(cfm.t.ssta.s.rguSapSta),
582 (U8 *)&rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
584 RgMiLrgStaCfm(&cfmPst, &cfm);
587 cfm.cfm.status = LCM_PRIM_OK;
588 cfm.cfm.reason = LCM_REASON_NOT_APPL;
589 SGetDateTime(&cfm.t.ssta.dt);
590 cmMemcpy((U8 *)&(cfm.t.ssta.s.crgSapSta), (U8 *)&rgCb[inst].crgSap.sapSta,
592 RgMiLrgStaCfm(&cfmPst, &cfm);
595 cfm.cfm.status = LCM_PRIM_OK;
596 cfm.cfm.reason = LCM_REASON_NOT_APPL;
597 SGetDateTime(&cfm.t.ssta.dt);
598 cmMemcpy((U8 *)&(cfm.t.ssta.s.tfuSapSta), (U8 *)&rgCb[inst].tfuSap.sapSta,
600 RgMiLrgStaCfm(&cfmPst, &cfm);
603 cfm.cfm.status = LCM_PRIM_NOK;
604 cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
605 RgMiLrgStaCfm(&cfmPst, &cfm);
606 RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
610 }/*-- RgMiLrgStaReq --*/
614 * @brief Layer Manager Control request handler.
618 * Function : RgMiLrgCntrlReq
620 * This function handles the control
621 * request received from the Layer Manager.
622 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
623 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
624 * of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
625 * and layer shutdown.
626 * -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
628 * @param[in] Pst *pst, the post structure
629 * @param[in] RgMngmt *cntrl, the control parameter's structure
634 PUBLIC S16 RgMiLrgCntrlReq
636 Pst *pst, /* post structure */
637 RgMngmt *cntrl /* control structure */
640 PUBLIC S16 RgMiLrgCntrlReq(pst, cntrl)
641 Pst *pst; /* post structure */
642 RgMngmt *cntrl; /* control structure */
645 S16 ret = ROK; /* return value */
650 TRC2(RgMiLrgCntrlReq)
652 /* Fill the post structure for sending the confirmation */
654 RG_IS_INST_VALID(pst->dstInst);
655 inst = pst->dstInst - RG_INST_START;
657 rgLMMFillCfmPst(pst, &cfmPst, cntrl);
659 cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
661 cfm.hdr.transId = cntrl->hdr.transId;
663 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
664 cfm.t.cntrl.action = cntrl->t.cntrl.action;
665 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
667 /* Check if General Config Done*/
668 if(rgCb[inst].rgInit.cfgDone != TRUE)
670 cfm.cfm.status = LCM_PRIM_NOK;
671 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
672 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
673 RgMiLrgCntrlCfm(&cfmPst, &cfm);
674 RLOG0(L_ERROR, "Gen Cfg not done");
678 /* General Config done, process the Control request */
679 switch(cntrl->hdr.elmId.elmnt)
682 rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
687 rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
690 cfm.cfm.status = LCM_PRIM_NOK;
691 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
692 RgMiLrgCntrlCfm(&cfmPst, &cfm);
693 RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
697 }/*-- RgMiLrgCntrlReq --*/
701 * @brief SAP Configuration Handler.
705 * Function : rgLMMSapCfg
707 * This function in called by RgMiLrgCfgReq(). It handles the
708 * interface SAP configuration of the LTE MAC layer. It
709 * initializes the sapState to LRG_UNBND. Returns
710 * reason for success/failure of this function.
712 * @param[in] Inst inst
713 * @param[in] RgCfg *cfg, the Configuaration information
715 * -# LCM_REASON_GENCFG_NOT_DONE
716 * -# LCM_REASON_INVALID_SAP
717 * -# LCM_REASON_NOT_APPL
720 PRIVATE U16 rgLMMSapCfg
723 RgCfg *cfg, /* Configuaration information */
724 Elmnt sapType /* Sap Type */
727 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
729 RgCfg *cfg; /* Configuaration information */
730 Elmnt sapType; /* Sap Type */
733 U16 ret = LCM_REASON_NOT_APPL;
734 RgLowSapCfgInfo *lowSapCfg = NULLP;
735 RgUpSapCfgInfo *upSapCfg = NULLP;
736 RgUpSapCb *upSapCb = NULLP;
740 /* Check if Gen Config has been done */
741 if(rgCb[inst].rgInit.cfgDone != TRUE)
742 return (LCM_REASON_GENCFG_NOT_DONE);
747 if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
748 (cfg->s.rguSap.selector != ODU_SELECTOR_TC) &&
749 (cfg->s.rguSap.selector != ODU_SELECTOR_LC))
751 ret = LCM_REASON_INVALID_PAR_VAL;
752 RLOG0(L_ERROR, "unsupported Selector value for RGU");
755 upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
756 if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
758 upSapCb->sapSta.sapState = LRG_UNBND;
760 upSapCfg = &(upSapCb->sapCfg);
761 upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
762 upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
763 upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
764 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
765 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
766 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
767 upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
768 upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
769 upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
770 upSapCfg->sapPst.route = cfg->s.rguSap.route;
771 upSapCfg->sapPst.intfVer = 0;
772 upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
773 upSapCfg->suId = cfg->s.rguSap.suId;
774 upSapCfg->spId = cfg->s.rguSap.spId;
775 /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
776 * there is cfg request with sap is 1*/
779 if ((cfg->s.crgSap.selector != ODU_SELECTOR_TC) &&
780 (cfg->s.crgSap.selector != ODU_SELECTOR_LC))
782 ret = LCM_REASON_INVALID_PAR_VAL;
783 RLOG0(L_ERROR, "unsupported Selector value for CRG");
786 if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
788 rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
790 upSapCfg = &rgCb[inst].crgSap.sapCfg;
792 upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
793 upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
794 upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
795 upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
796 upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
797 upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
798 upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
799 upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
800 upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
801 upSapCfg->sapPst.route = cfg->s.crgSap.route;
802 upSapCfg->sapPst.intfVer = 0;
803 upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
804 upSapCfg->suId = cfg->s.crgSap.suId;
805 upSapCfg->spId = cfg->s.crgSap.spId;
809 if ((cfg->s.tfuSap.selector != ODU_SELECTOR_TC) &&
810 (cfg->s.tfuSap.selector != ODU_SELECTOR_LC))
812 ret = LCM_REASON_INVALID_PAR_VAL;
813 RLOG0(L_ERROR, "unsupported Selector value for TFU");
817 if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG)
819 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
821 lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
823 lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
824 lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
825 lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
826 lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
827 lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
828 lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
829 lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
830 lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
831 lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
832 lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
833 lowSapCfg->sapPst.intfVer = 0;
834 lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
835 lowSapCfg->suId = cfg->s.tfuSap.suId;
836 lowSapCfg->spId = cfg->s.tfuSap.spId;
837 cmMemcpy((U8 *)&lowSapCfg->bndTmr, (U8 *)&cfg->s.tfuSap.bndTmr,
841 /* would never reach here */
849 * @brief General Configuration Handler.
853 * Function : rgLMMGenCfg
855 * This function in called by RgMiLrgCfgReq(). It handles the
856 * general configuration of the LTE MAC layer. It initializes
857 * the hash lists of RgCb. Returns
858 * reason for success/failure of this function.
860 * @param[in] Inst inst
861 * @param[in] RgCfg *cfg, the Configuaration information
863 * -# LCM_REASON_NOT_APPL
864 * -# LCM_REASON_INVALID_MSGTYPE
865 * -# LCM_REASON_MEM_NOAVAIL
868 PRIVATE U16 rgLMMGenCfg
871 RgCfg *cfg /* Configuaration information */
874 PRIVATE U16 rgLMMGenCfg(inst,cfg)
876 RgCfg *cfg; /* Configuaration information */
879 U16 ret = LCM_REASON_NOT_APPL;
883 /* Check if General Configuration is done already */
884 if (rgCb[inst].rgInit.cfgDone == TRUE)
886 return (LCM_REASON_INVALID_MSGTYPE);
888 if ((cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_TC) &&
889 (cfg->s.genCfg.lmPst.selector != ODU_SELECTOR_LC))
891 RLOG0(L_ERROR, "unsupported Selector value for RGU");
892 return (LCM_REASON_INVALID_PAR_VAL);
894 /* Update the Pst structure for LM interface */
895 cmMemcpy((U8 *)&rgCb[inst].rgInit.lmPst, (U8 *)&cfg->s.genCfg.lmPst,
898 rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
899 rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
900 rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
901 rgCb[inst].rgInit.lmPst.event = EVTNONE;
903 rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
904 rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
905 rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
907 macCb.macInst = rgCb[inst].rgInit.inst;
908 macCb.procId = rgCb[inst].rgInit.procId;
910 /* Initialize SAP States */
911 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
913 if(cfg->s.genCfg.numRguSaps == 0)
915 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
919 /* allocate RGR saps */
920 if (SGetSBuf(rgCb[inst].rgInit.region,
921 rgCb[inst].rgInit.pool,
922 (Data **)&rgCb[inst].rguSap,
923 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
925 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
928 rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
930 for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
932 rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
933 cmMemset((U8 *)&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
935 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
936 /* Initialize the timer blocks */
937 cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
938 /* Initialzie the timer queue */
939 cmMemset((U8 *)&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
940 /* Initialize the timer control point */
941 cmMemset((U8 *)&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
942 rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
944 /* Timer Registration request to SSI */
945 if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
946 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
949 RLOG0(L_ERROR, "Failed to register timer");
951 SPutSBuf(rgCb[inst].rgInit.region,
952 rgCb[inst].rgInit.pool,
953 (Data *)rgCb[inst].rguSap,
954 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
956 return (LCM_REASON_MEM_NOAVAIL);
959 /* Set Config done in TskInit */
960 rgCb[inst].rgInit.cfgDone = TRUE;
966 /***********************************************************
968 * Func : rgLMMShutdown
971 * Desc : Handles the MAC layer shutdown request. Calls
972 * rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
981 **********************************************************/
983 PRIVATE Void rgLMMShutdown
988 PRIVATE Void rgLMMShutdown(inst)
992 RgCellCb *cell = rgCb[inst].cell;
997 /* Unbind the TFU Sap */
998 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
1000 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1001 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1003 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1005 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1007 if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
1009 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1010 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1016 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1018 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1021 rgCFGFreeCellCb(cell);
1024 /* Deleting the RGU SAPs */
1025 SPutSBuf(rgCb[inst].rgInit.region,
1026 rgCb[inst].rgInit.pool,
1027 (Data *)rgCb[inst].rguSap,
1028 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1029 rgCb[inst].rguSap = NULLP;
1031 rgCb[inst].inactiveCell = NULLP;
1032 rgCb[inst].cell = NULLP;
1034 /* De-register the Timer Service */
1035 (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1036 (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr);
1038 /* call back the task initialization function to intialize
1039 * the global RgCb Struct */
1040 rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region,
1041 rgCb[inst].rgInit.reason);
1047 /***********************************************************
1049 * Func : rgLMMGenCntrl
1052 * Desc : Processes the LM control request for STGEN elmnt.
1061 **********************************************************/
1063 PRIVATE Void rgLMMGenCntrl
1070 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1076 Inst inst = (cfmPst->srcInst - RG_INST_START);
1079 cfm->cfm.status = LCM_PRIM_OK;
1080 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1083 switch(cntrl->t.cntrl.action)
1086 /* Action is Enable */
1087 switch(cntrl->t.cntrl.subAction)
1091 rgCb[inst].rgInit.trc = TRUE;
1092 rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1093 /*Store the response and TransId for sending the Traces */
1094 cmMemcpy((U8 *)&rgCb[inst].genCfg.trcResp.response,
1095 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1096 rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1100 /* Enable Unsolicited Status (alarms) */
1101 rgCb[inst].rgInit.usta = TRUE;
1102 /*Store the response and TransId for sending the Alarms */
1103 cmMemcpy((U8 *)&rgCb[inst].genCfg.ustaResp.response,
1104 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1105 rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1108 /* Enable Debug Printing */
1110 rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1115 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1120 cfm->cfm.status = LCM_PRIM_NOK;
1121 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1122 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1127 /* Action is Diable immidiately */
1128 switch(cntrl->t.cntrl.subAction)
1131 /* Disable Traces */
1132 rgCb[inst].rgInit.trc = FALSE;
1135 /* Disable Unsolicited Status (alarms) */
1136 rgCb[inst].rgInit.usta = FALSE;
1139 /* Disable Debug Printing */
1141 rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1146 rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1151 cfm->cfm.status = LCM_PRIM_NOK;
1152 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1153 RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1158 /* Free all the memory dynamically allocated by MAC */
1159 rgLMMShutdown(inst);
1162 cfm->cfm.status = LCM_PRIM_NOK;
1163 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1164 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1167 RgMiLrgCntrlCfm(cfmPst, cfm);
1172 /***********************************************************
1174 * Func : rgLMMSapCntrl
1177 * Desc : Processes the LM control request for STxxxSAP elmnt.
1186 **********************************************************/
1188 PRIVATE Void rgLMMSapCntrl
1195 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1201 Inst inst = cfmPst->srcInst - RG_INST_START;
1204 /* Only TFU Sap can be controlled by LM */
1205 switch(cntrl->hdr.elmId.elmnt)
1208 switch(cntrl->t.cntrl.action)
1211 /* Bind Enable Request */
1212 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1213 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1215 cfm->cfm.status = LCM_PRIM_NOK;
1216 cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1220 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1222 rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val,
1223 (PTR)&rgCb[inst].tfuSap);
1225 /* Change SAP state */
1226 rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1227 rgCb[inst].tfuSap.numBndRetries++;
1228 /* Store the response and TransId for sending
1229 * the Control confirm */
1230 cmMemcpy((U8 *)&rgCb[inst].genCfg.bndCfmResp.response,
1231 (U8 *)&cntrl->hdr.response, sizeof(Resp));
1232 rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1234 /* Sending Status Indication to Layer Manager */
1235 cfm->cfm.status = LCM_PRIM_OK_NDONE;
1236 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1237 RgMiLrgCntrlCfm(cfmPst, cfm);
1239 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1240 rgCb[inst].tfuSap.sapCfg.spId);
1245 /* Unbind request */
1247 /* Check if the SAP is configured */
1248 if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1249 (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1251 cfm->cfm.status = LCM_PRIM_NOK;
1252 cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
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);
1261 /* Change SAP state */
1262 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1263 cfm->cfm.status = LCM_PRIM_OK;
1264 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1268 /* Delete SAP, does initialization of SAP */
1269 if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1270 (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1272 rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1273 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1275 rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1278 cmMemset((U8 *)&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1279 rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1280 cfm->cfm.status = LCM_PRIM_OK;
1281 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1284 cfm->cfm.status = LCM_PRIM_NOK;
1285 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1286 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1287 cntrl->t.cntrl.action));
1292 switch(cntrl->t.cntrl.action)
1295 cmMemset((U8 *)&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1296 rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1297 cfm->cfm.status = LCM_PRIM_OK;
1298 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1301 cfm->cfm.status = LCM_PRIM_NOK;
1302 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1303 RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1304 cntrl->t.cntrl.action));
1309 switch(cntrl->t.cntrl.action)
1312 cmMemset((U8 *)&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1313 rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1314 cfm->cfm.status = LCM_PRIM_OK;
1315 cfm->cfm.reason = LCM_REASON_NOT_APPL;
1318 cfm->cfm.status = LCM_PRIM_NOK;
1319 cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1320 RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1326 /* Would never here. */
1329 RgMiLrgCntrlCfm(cfmPst, cfm);
1334 /***********************************************************
1336 * Func : rgLMMFillCfmPst
1339 * Desc : Fills the Confirmation Post Structure cfmPst using the reqPst
1340 * and the cfm->hdr.response.
1349 **********************************************************/
1351 PRIVATE Void rgLMMFillCfmPst
1358 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1365 TRC2(rgLMMFillCfmPst)
1366 inst = (reqPst->dstInst - RG_INST_START);
1368 cfmPst->srcEnt = rgCb[inst].rgInit.ent;
1369 cfmPst->srcInst = rgCb[inst].rgInit.inst;
1370 cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1371 cfmPst->dstEnt = reqPst->srcEnt;
1372 cfmPst->dstInst = reqPst->srcInst;
1373 cfmPst->dstProcId = reqPst->srcProcId;
1375 cfmPst->selector = cfm->hdr.response.selector;
1376 cfmPst->prior = cfm->hdr.response.prior;
1377 cfmPst->route = cfm->hdr.response.route;
1378 cfmPst->region = cfm->hdr.response.mem.region;
1379 cfmPst->pool = cfm->hdr.response.mem.pool;
1386 * @brief Timer start handler.
1390 * Function : rgLMMStartTmr
1392 * This function based on the input parameters starts the timer for
1393 * "tmrVal" duration. As of now MAC uses the timer functionality for
1394 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1396 * @param[in] Inst inst
1397 * @param[in] S16 tmrEvnt, the Timer Event
1398 * @param[in] U32 tmrVal, the Wait Time
1399 * @param[in] PTR cb, Entry for which Timer expired
1404 PUBLIC S16 rgLMMStartTmr
1407 S16 tmrEvnt, /* Timer Event */
1408 U32 tmrVal, /* Wait Time */
1409 PTR cb /* Entry for which Timer Expired */
1412 PUBLIC S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1414 S16 tmrEvnt; /* Timer Event */
1415 U32 tmrVal; /* Wait Time */
1416 PTR cb; /* Entry for which Timer Expired */
1425 /* Initialize the arg structure */
1426 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1428 arg.tqCp = &rgCb[inst].tmrTqCp;
1429 arg.tq = rgCb[inst].tmrTq;
1430 arg.timers = rgCb[inst].tmrBlk;
1433 arg.max = RG_MAX_TIMER;
1434 arg.evnt = RG_BNDREQ_TMR;
1443 * @brief Timer stop handler.
1447 * Function : rgLMMStopTmr
1449 * This function based on the input parameters stops the timer for
1450 * "tmrEvnt". As of now MAC uses the timer functionality for
1451 * BndReq only. Hence there is no conditional code based on "tmrEvnt".
1452 * Once the bind happens and this timer is stopped, the timer functionality
1453 * is deregistered with SSI. As there is no further use of timer processing.
1455 * @param[in] Inst inst
1456 * @param[in] S16 tmrEvnt, the Timer Event
1457 * @param[in] PTR cb, Entry for which Timer expired
1463 PUBLIC S16 rgLMMStopTmr
1465 Inst inst, /* Scheduler instance */
1466 S16 tmrEvnt, /* Timer Event */
1467 PTR cb /* Entry for which Timer Expired */
1470 PUBLIC S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1471 Inst inst; /* Scheduler instance */
1472 S16 tmrEvnt; /* Timer Event */
1473 PTR cb; /* Entry for which Timer Expired */
1484 for(i=0;i<RG_MAX_TIMER;i++)
1486 /* Search for the Timer Blocks */
1487 if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1489 /* Initialize the arg structure */
1490 cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1492 arg.tqCp = &rgCb[inst].tmrTqCp;
1493 arg.tq = rgCb[inst].tmrTq;
1494 arg.timers = rgCb[inst].tmrBlk;
1496 arg.max = RG_MAX_TIMER;
1514 * @brief Timer Expiry handler.
1518 * Function : rgLMMTmrExpiry
1520 * This is a callback function used as an input parameter to cmPrcTmr()
1521 * to check expiry of any timer. In this function, the only concern is
1522 * about tmrEvnt=Bind timer.
1524 * @param[in] PTR cb, Entry for which Timer expired
1525 * @param[in] S16 tmrEvnt, the Timer Event
1530 PUBLIC S16 rgLMMTmrExpiry
1532 PTR cb, /* Pointer to timer control block */
1533 S16 tmrEvnt /* Timer Event */
1536 PUBLIC S16 rgLMMTmrExpiry(cb,tmrEvnt)
1537 PTR cb; /* Pointer to timer control block */
1538 S16 tmrEvnt; /* Timer Event */
1542 RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1543 Inst inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1545 TRC2(rgLMMTmrExpiry)
1551 tfuSap->numBndRetries++;
1552 if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1554 rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1555 LCM_CAUSE_TMR_EXPIRED, NULLP);
1559 /* Restart the bind timer */
1560 if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1562 ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1566 /* Send bind request */
1567 rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1568 rgCb[inst].tfuSap.sapCfg.spId);
1572 RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1582 * @brief Layer Manager Unsolicited Status Indication generation.
1586 * Function : rgLMMStaInd
1588 * This API is used by the other modules of MAC to send a unsolicited
1589 * status indication to the Layer Manager.
1591 * @param[in] Inst inst
1592 * @param[in] U16 category, the Alarm category
1593 * @param[in] U16 event, the Alarm event
1594 * @param[in] U16 cause, the cause of the Alarm
1595 * @param[in] RgUstaDgn *dgn, Alarm Diagonostics
1600 PUBLIC S16 rgLMMStaInd
1609 PUBLIC S16 rgLMMStaInd(inst,category, event, cause, dgn)
1621 if(rgCb[inst].rgInit.usta == FALSE)
1626 cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1628 SGetDateTime(&usta.t.usta.cmAlarm.dt);
1629 usta.t.usta.cmAlarm.category = category;
1630 usta.t.usta.cmAlarm.event = event;
1631 usta.t.usta.cmAlarm.cause = cause;
1634 cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1637 rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1638 rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1639 rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1640 rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1641 rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1642 usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1644 return (RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1649 * @brief Layer Manager Trace Indication generation.
1653 * Function : rgLMMTrcInd
1655 * This API is used by the other modules of MAC to send a
1656 * Trace indication to the Layer Manager.
1658 * @param[in] Inst inst
1659 * @param[in] Buffer *srcMbuf, the Message Buffer .
1660 * @param[in] U8 event, the trace event.
1664 PUBLIC Void rgLMMTrcInd
1667 Buffer *srcMbuf, /* Message Buffer */
1668 U8 event /* event */
1671 PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
1673 Buffer *srcMbuf; /* Message Buffer */
1674 U8 event; /* event */
1677 Buffer *dstMbuf = NULLP;
1687 if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1689 RLOG0(L_ERROR, "Trace Disabled.");
1693 cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
1695 pst = rgCb[inst].rgInit.lmPst;
1696 pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1697 pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1698 pst.route = rgCb[inst].genCfg.trcResp.response.route;
1699 pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1700 pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1702 trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1704 SGetDateTime(&trc.t.trc.dt);
1706 /* Check if the whole buffer is to be sent in Trace indication */
1707 if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1709 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1712 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1715 trc.cfm.status = LCM_PRIM_OK;
1716 trc.cfm.reason = LCM_REASON_NOT_APPL;
1717 trc.t.trc.evnt = event;
1719 /* Send Trace Indication to Layer manager */
1720 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1722 /* check if only a specified number of bytes are to be sent */
1723 else if(rgCb[inst].trcLen > 0)
1725 /* Get the length of the recvd message buffer */
1726 if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1728 RLOG0(L_ERROR, "SFndLenMsg Failed.");
1731 /* Check if the recvd buffer size is less than request trace len */
1732 if(bufLen < rgCb[inst].trcLen)
1734 /* Copy the whole of the recvd buffer in trace indication */
1736 if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1739 RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1743 trc.cfm.status = LCM_PRIM_OK;
1744 trc.cfm.reason = LCM_REASON_NOT_APPL;
1745 trc.t.trc.evnt = event;
1747 /* Send Trace Indication to Layer manager */
1748 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1750 /* if the recvd buffer size is greater than request trace len */
1751 if(bufLen >= rgCb[inst].trcLen)
1753 /* Get a temporary buffer to store the msg */
1754 if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1756 RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1760 /* Copy trcLen nos of bytes from the recvd message */
1761 if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)
1763 RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1767 if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1769 RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1772 /* Copy the tempBuf data to dst mBuf */
1773 if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1775 RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1779 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1781 /* Free the memory allocated for tempBuf */
1782 rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1784 trc.cfm.status = LCM_PRIM_OK;
1785 trc.cfm.reason = LCM_REASON_NOT_APPL;
1786 trc.t.trc.evnt = event;
1788 /* Send Trace Indication to Layer manager */
1789 RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1797 * @brief Layer Manager Control Confirm generation handler
1798 * for Bind Confirm reception at TFU interface.
1799 * RgLiTfuBndCfm() forwards the confirmation to this
1800 * function. All SAP state related handling is restricted
1801 * to LMM modules, hence the cfm forwarding.
1805 * Function : rgLMMBndCfm
1807 * This API is used by the LIM module of MAC to forward
1808 * the Bind Confirm it receives over the TFU interface.
1810 * @param[in] Pst *pst, Post Structure
1811 * @param[in] SuId suId, Service user ID
1812 * @param[in] U8 status, Status
1817 PUBLIC S16 rgLMMBndCfm
1819 Pst *pst, /* Post Structure */
1820 SuId suId, /* Service user ID */
1821 U8 status /* Status */
1824 PUBLIC S16 rgLMMBndCfm(pst,suId,status)
1825 Pst *pst; /* Post Structure */
1826 SuId suId; /* Service user ID */
1827 U8 status; /* Status */
1830 Inst inst = pst->dstInst - RG_INST_START;
1839 /* Check if the suId is valid */
1840 if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1842 RLOG0(L_ERROR, "Invalid SuId");
1846 /* check the Sap State */
1847 switch(rgCb[inst].tfuSap.sapSta.sapState)
1849 case LRG_WAIT_BNDCFM:
1852 /* SAP is already bound */
1858 cfmPst = rgCb[inst].rgInit.lmPst;
1859 cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1860 cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1861 cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1862 cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1863 cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1865 cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1869 case CM_BND_OK: /* status is OK */
1870 /* Change SAP state to Bound */
1871 rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1872 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1874 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1876 /* Send Control Confirm with status as OK to Layer Manager */
1877 cntrlCfm.cfm.status = LCM_PRIM_OK;
1878 cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1882 /* Change SAP state to UnBound */
1883 rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1884 if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1886 ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1888 /* Send Control Confirm with status as NOK to Layer Manager */
1889 cntrlCfm.cfm.status = LCM_PRIM_NOK;
1890 cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1893 rgCb[inst].tfuSap.numBndRetries = 0;
1894 cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1895 cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1897 ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1904 * @brief LTE MAC timer call back function registered with SSI.
1908 * Function : rgActvTmr
1910 * This function is invoked by SSI for every timer activation
1917 PUBLIC S16 rgActvTmr
1923 PUBLIC S16 rgActvTmr(ent, inst)
1928 Inst macInst = (inst - RG_INST_START);
1931 /* Check if any MAC timer has expired */
1932 cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1936 } /* end of rgActvTmr */
1938 /**********************************************************************
1941 **********************************************************************/