PUCCH CHANGES AT SCH AND LOWER MAC
[o-du/l2.git] / src / 5gnrmac / rg_lmm.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /************************************************************************
20  
21      Name:     LTE-MAC layer
22   
23      Type:     C source file
24   
25      Desc:     C source code for Layer Manager Interface Module 
26   
27      File:     rg_lmm.c 
28   
29 **********************************************************************/
30
31 /** @file rg_lmm.c
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.
35 */
36 static const char* RLOG_MODULE_NAME="MAC";
37 static int RLOG_FILE_ID=220;
38 static int RLOG_MODULE_ID=4096;
39
40 /* header include files (.h) */
41 #include "stdbool.h"
42 #include "envopt.h"        /* environment options */
43 #include "envdep.h"        /* environment dependent */
44 #include "envind.h"        /* environment independent */
45 #include "gen.h"           /* general */
46 #include "ssi.h"           /* system services */
47 #include "cm_tkns.h"       /* Common Token Defines */
48 #include "cm_llist.h"      /* Common Link List Defines */
49 #include "cm_hash.h"       /* Common Hash List Defines */
50 #include "cm_mblk.h"       /* common memory link list library */
51 #include "cm_lte.h"        /* Common LTE Defines */
52 #include "rg_env.h"        /* MAC Environment Defines */
53 #include "crg.h"           /* CRG Interface defines */
54 #include "rgu.h"           /* RGU Interface defines */
55 #include "tfu.h"           /* RGU Interface defines */
56 #include "rg_sch_inf.h"    /* RGR Interface defines */
57 #include "lrg.h"           /* LRG Interface defines */
58 #include "rgr.h"           /* LRG Interface defines */
59 #include "rg.h"            /* MAC defines */
60 #include "rg_err.h"        /* MAC error defines */
61 #include "du_log.h"
62
63 /* header/extern include files (.x) */
64 #include "gen.x"           /* general */
65 #include "ssi.x"           /* system services */
66 #include "cm5.x"           /* system services */
67 #include "cm_tkns.x"       /* Common Token Definitions */
68 #include "cm_llist.x"      /* Common Link List Definitions */
69 #include "cm_lib.x"        /* Common Library Definitions */
70 #include "cm_hash.x"       /* Common Hash List Definitions */
71 #include "cm_mblk.x"       /* common memory link list library */
72 #include "cm_lte.x"        /* Common LTE Defines */
73 #include "crg.x"           /* CRG Interface includes */
74 #include "rgu.x"           /* RGU Interface includes */
75 #include "tfu.x"           /* RGU Interface includes */
76 #include "rg_sch_inf.x"    /* SCH Interface includes */
77 #include "rg_prg.x"    /* PRG Interface includes */
78 #include "lrg.x"           /* LRG Interface includes */
79 #include "rgr.x"           /* LRG Interface includes */
80 #include "du_app_mac_inf.h"
81 #include "rg.x"            /* MAC includes */
82 #ifdef SS_DIAG
83 #include "ss_diag.h"        /* Common log file */
84 #endif
85 #include "ss_rbuf.h"
86 #include "ss_rbuf.x"
87 #include "lwr_mac.h"         /* MAC CL defines */
88 #include "mac.h"
89 #include "lwr_mac_phy.h"
90 #include "lwr_mac_fsm.h"
91
92 #ifdef __cplusplus
93 extern "C" {
94 #endif /* __cplusplus */
95 EXTERN Void rgGetSId ARGS((SystemId *s));
96 #ifdef __cplusplus
97 }
98 #endif /* __cplusplus */
99
100 /* Public variable declaration */
101 ClCb   clGlobalCp;
102 extern MacCb  macCb;
103
104 int MacSchCellCfgReq(Pst *pst,MacCellCfg *macCellCfg);
105
106 /* forward references */
107 PRIVATE U16 rgLMMGenCfg ARGS((
108    Inst           inst,
109    RgCfg          *cfg           
110 ));
111
112 PRIVATE U16 rgLMMSapCfg ARGS((
113    Inst           inst,
114    RgCfg          *cfg,
115    Elmnt          sapType
116 ));
117
118 PRIVATE Void rgLMMShutdown ARGS((
119    Inst           inst
120 ));
121
122 PRIVATE Void rgLMMFillCfmPst ARGS((
123    Pst           *reqPst,
124    Pst           *cfmPst,
125    RgMngmt       *cfm
126 ));
127
128 PRIVATE Void rgLMMGenCntrl ARGS((
129 RgMngmt       *cntrl,
130 RgMngmt       *cfm,
131 Pst           *cfmPst
132 ));
133
134 PRIVATE Void rgLMMSapCntrl ARGS((
135 RgMngmt       *cntrl,
136 RgMngmt       *cfm,
137 Pst           *cfmPst
138 ));
139
140 extern int packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm);
141
142 packMacCellCfgConfirm packMacCellCfmOpts[] =
143 {
144    packMacCellCfgCfm,      /* packing for loosely coupled */
145    duHandleMacCellCfgCfm,      /* packing for tightly coupled */
146    packMacCellCfgCfm,    /* packing for light weight loosly coupled */
147 };
148
149 SchCellCfgFunc SchCellCfgOpts[] = 
150 {
151    packSchCellCfg,   /* packing for loosely coupled */
152         SchHdlCellCfgReq, /* packing for tightly coupled */
153    packSchCellCfg    /* packing for light weight loosly coupled */
154 };
155
156 \f
157 /**
158  * @brief Task Initiation callback function. 
159  *
160  * @details
161  *
162  *     Function : rgActvInit
163  *     
164  *     This function is supplied as one of parameters during MAC's 
165  *     task registration. SSI will invoke this function once, after
166  *     it creates and attaches this TAPA Task to a system task.
167  *     
168  *  @param[in]  Ent entity, the entity ID of this task.     
169  *  @param[in]  Inst inst, the instance ID of this task.
170  *  @param[in]  Region region, the region ID registered for memory 
171  *              usage of this task.
172  *  @param[in]  Reason reason.
173  *  @return  S16
174  *      -# ROK
175  **/
176 #ifdef ANSI
177 PUBLIC S16 rgActvInit
178 (
179 Ent entity,            /* entity */
180 Inst inst,             /* instance */
181 Region region,         /* region */
182 Reason reason          /* reason */
183 )
184 #else
185 PUBLIC S16 rgActvInit(entity, inst, region, reason)
186 Ent entity;            /* entity */
187 Inst inst;             /* instance */
188 Region region;         /* region */
189 Reason reason;         /* reason */
190 #endif
191 {
192    Inst macInst ;
193    TRC2(rgActvInit);
194
195    RG_IS_INST_VALID(inst);
196
197    macInst = inst - RG_INST_START;
198    /* Initialize the MAC TskInit structure to zero */
199    cmMemset ((U8 *)&rgCb[macInst], 0, sizeof(RgCb));
200
201    /* Initialize the MAC TskInit with received values */
202    rgCb[macInst].rgInit.ent = entity;
203    rgCb[macInst].rgInit.inst = inst;
204    rgCb[macInst].rgInit.region = region;
205    rgCb[macInst].rgInit.pool = 0;
206    rgCb[macInst].rgInit.reason = reason;
207    rgCb[macInst].rgInit.cfgDone = FALSE;
208    rgCb[macInst].rgInit.acnt = FALSE;
209    rgCb[macInst].rgInit.usta = FALSE;
210    rgCb[macInst].rgInit.trc = FALSE;
211    rgCb[macInst].trcLen = 0; 
212 #ifdef DEBUGP
213 #ifdef RG_DEBUG
214    /* disabling debugs by default */
215     rgCb[macInst].rgInit.dbgMask = 0xffffffff; 
216 #endif
217 #endif /* DEBUGP */
218 #ifdef SS_DIAG
219    rgCb[macInst].rgInit.logMask = 0x0;
220 #endif
221    rgCb[macInst].rgInit.procId = SFndProcId();
222    rgCb[macInst].tfuSap.numBndRetries = 0;
223
224    /* Initialize Sap state */
225    rgCb[macInst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
226    rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
227    rgCb[macInst].rguSap = NULLP;
228    rgCb[macInst].crgSap.sapSta.sapState = LRG_NOT_CFG;
229
230    rgCb[macInst].inactiveCell = NULLP;
231    rgCb[macInst].cell         = NULLP;
232 #ifdef SS_RBUF
233    SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX);
234    SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX);
235 #endif
236
237    /* Initializing CL control block */
238    clGlobalCp.region = region;
239    clGlobalCp.pool = 0;
240    clGlobalCp.clCfgDone = FALSE;
241    clGlobalCp.numOfCells = 0;
242    clGlobalCp.phyState = PHY_STATE_IDLE; 
243
244    if( cmHashListInit(&clGlobalCp.cellCbLst, MAX_NUM_CELL_SUPP, 0x0, FALSE, 
245                   CM_HASH_KEYTYPE_DEF, clGlobalCp.region, clGlobalCp.pool ) != ROK )
246    {
247       printf("\n Cellcb hash list initialization failed for MAC CL");
248       RETVALUE(RFAILED);
249    }
250
251    /* Initialize Scheduler as well */
252    schActvInit(ENTRG, (DEFAULT_CELLS + SCH_INST_START), DFLT_REGION, PWR_UP);
253
254    /* Initialize lower mac */
255    lwrMacInit();
256
257    RETVALUE(ROK);
258
259 } /* rgActvInit */
260 \f
261 /**
262  * @brief Layer Manager Configuration request handler. 
263  *
264  * @details
265  *
266  *     Function : RgMiLrgCfgReq
267  *     
268  *     This function handles the configuration
269  *     request received from the Layer Manager.
270  *     -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
271  *        functions rgHdlGenCfg() or rgHdlSapCfg().
272  *     -# Invokes RgMiLrgCfgCfm() to send back the confirmation to the LM.
273  *     
274  *  @param[in]  Pst *pst, the post structure     
275  *  @param[in]  RgMngmt *cfg, the configuration parameter's structure
276  *  @return  S16
277  *      -# ROK
278  **/
279 #ifdef ANSI
280 PUBLIC S16 RgMiLrgCfgReq
281 (
282 Pst      *pst,    /* post structure  */
283 RgMngmt  *cfg     /* config structure  */
284 )
285 #else
286 PUBLIC S16 RgMiLrgCfgReq(pst, cfg)
287 Pst      *pst;    /* post structure  */
288 RgMngmt  *cfg;    /* config structure  */
289 #endif    
290 {
291    U16       ret = LCM_PRIM_OK;
292    U16       reason = LCM_REASON_NOT_APPL;
293    RgMngmt   cfm;
294    Pst       cfmPst;
295    Inst      inst;
296
297    TRC2(RgMiLrgCfgReq)
298    
299
300    RG_DIAG_LVL0(inst,0x0a0b0001, RG_DIAG_NA, SS_DIAG_INV_ARG,
301               "Received CfgReq for MAC layer, Entity = %d, Instance = %d\n",
302               pst->srcEnt, pst->srcInst,0,0);
303
304    RG_IS_INST_VALID(pst->dstInst);
305    inst = pst->dstInst - RG_INST_START;
306
307    /* Fill the post structure for sending the confirmation */
308    rgLMMFillCfmPst(pst, &cfmPst, cfg);
309
310    cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
311
312 #ifdef LMINT3
313    cfm.hdr.transId = cfg->hdr.transId;
314 #endif
315
316
317    cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
318    switch(cfg->hdr.elmId.elmnt)
319    {
320       case STGEN:
321          reason = rgLMMGenCfg(inst,&cfg->t.cfg); 
322          break;
323       case STRGUSAP:
324       case STCRGSAP:
325       case STTFUSAP:
326          reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt);
327          break;
328       default:
329          ret = LCM_PRIM_NOK;
330          reason = LCM_REASON_INVALID_ELMNT;
331          RLOG1(L_ERROR, "Invalid Elmnt=%d",
332                   cfg->hdr.elmId.elmnt);
333          break;
334    }
335
336    if (reason != LCM_REASON_NOT_APPL)
337    {
338       ret = LCM_PRIM_NOK;
339    }
340
341    cfm.cfm.status = ret;
342    cfm.cfm.reason = reason;
343
344    RgMiLrgCfgCfm(&cfmPst, &cfm);
345    
346    RETVALUE(ROK);
347 }/*-- RgMiLrgCfgReq --*/
348
349 \f
350 /**
351  * @brief Layer Manager Statistics request handler. 
352  *
353  * @details
354  *
355  *     Function : RgMiLrgStsReq
356  *     
357  *     This function handles the statistics
358  *     request received from the Layer Manager.
359  *      -# Based on sts->hdr.elmId.elmnt, it retrieves either general or SAP
360  *      statistics from the rgCb global control block.
361  *      -# If action=ARST, it will reset the statistics parameters in rgCb to 0.
362  *      -# Invokes the RgMiLrgStsCfm to send back the confirmation to LM.
363  *     
364  *  @param[in]  Pst *pst, the post structure     
365  *  @param[in]  RgMngmt *sts, the statistics parameter's structure
366  *  @return  S16
367  *      -# ROK
368  **/
369 #ifdef ANSI
370 PUBLIC S16 RgMiLrgStsReq
371 (
372 Pst      *pst,    /* post structure  */
373 RgMngmt  *sts     /* statistics structure  */
374 )
375 #else
376 PUBLIC S16 RgMiLrgStsReq(pst, sts)
377 Pst      *pst;    /* post structure  */
378 RgMngmt  *sts;    /* statistics structure  */
379 #endif    
380 {
381    Pst       cfmPst;
382    RgMngmt   cfm;
383    Inst      inst;
384
385    TRC2(RgMiLrgStsReq)
386    
387
388    RG_IS_INST_VALID(pst->dstInst);
389    inst = pst->dstInst - RG_INST_START;
390    /* Fill the post structure for sending the confirmation */
391    rgLMMFillCfmPst(pst, &cfmPst, sts);
392
393    cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
394
395 #ifdef LMINT3
396    cfm.hdr.transId = sts->hdr.transId;
397 #endif
398    SGetDateTime(&cfm.t.sts.dt);
399    cfm.cfm.status = LCM_PRIM_OK;
400    cfm.cfm.reason = LCM_REASON_NOT_APPL;
401    cfm.hdr.elmId.elmnt = sts->hdr.elmId.elmnt;
402    cfm.t.sts.action = sts->t.sts.action;
403
404    /* Check if General Config Done */
405    if(rgCb[inst].rgInit.cfgDone != TRUE) 
406    {
407       cfm.cfm.status = LCM_PRIM_NOK;
408       cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
409       RgMiLrgStsCfm(&cfmPst,&cfm);
410       RLOG0(L_ERROR, "Gen Cfg not done");
411       RETVALUE(ROK);
412    }
413
414    switch(sts->hdr.elmId.elmnt)
415    {
416       case STGEN:
417          {
418             cmMemcpy((U8 *)&(cfm.t.sts.s.genSts), (U8 *)&rgCb[inst].genSts,
419                   sizeof(RgGenSts));
420             /* check if action is read and reset */
421             if(sts->t.sts.action == ARST)
422             {
423                rgCb[inst].genSts.numHarqFail = 0;
424             }
425             /* L2 statistics */
426 #ifdef MAC_SCH_STATS
427             {
428                RgGenSts *genSts = &(cfm.t.sts.s.genSts);
429                U8       cqi = 0;
430                for(cqi=0; cqi <= 14; cqi++)
431                {
432                   /* Filling DL ACK/NACK stats */
433                   genSts->nackAckStats.dlCqiStat[cqi].mcs = \
434                      hqFailStats.dlCqiStat[cqi].mcs;
435                   genSts->nackAckStats.dlCqiStat[cqi].numOfNacks = \
436                      hqFailStats.dlCqiStat[cqi].numOfNacks;
437                   genSts->nackAckStats.dlCqiStat[cqi].numOfAcks = 
438                      hqFailStats.dlCqiStat[cqi].numOfAcks;
439
440                   /* Filling UL ACK/NACK stats */
441                   genSts->nackAckStats.ulCqiStat[cqi].mcs = \
442                      hqFailStats.ulCqiStat[cqi].mcs;
443                   genSts->nackAckStats.ulCqiStat[cqi].numOfNacks = \
444                      hqFailStats.ulCqiStat[cqi].numOfNacks;
445                   genSts->nackAckStats.ulCqiStat[cqi].numOfAcks = \
446                      hqFailStats.ulCqiStat[cqi].numOfAcks;
447
448                   /* Filling DL HQ Retx stats */
449                   genSts->hqRetxStats.dlCqiStat[cqi].mcs = \
450                      hqRetxStats.dlCqiStat[cqi].mcs;
451                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_1 = \
452                      hqRetxStats.dlCqiStat[cqi].numOfHQ_1;
453                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_2 = \
454                      hqRetxStats.dlCqiStat[cqi].numOfHQ_2;
455                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_3 = \
456                      hqRetxStats.dlCqiStat[cqi].numOfHQ_3;
457                   genSts->hqRetxStats.dlCqiStat[cqi].numOfHQ_4 = \
458                      hqRetxStats.dlCqiStat[cqi].numOfHQ_4;
459                   genSts->hqRetxStats.dlCqiStat[cqi].totalTx = \
460                      hqRetxStats.dlCqiStat[cqi].totalTx;
461
462                   /* Filling UL HQ Retx stats */
463                   genSts->hqRetxStats.ulCqiStat[cqi].mcs = \
464                      hqRetxStats.ulCqiStat[cqi].mcs;
465                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_1 = \
466                      hqRetxStats.ulCqiStat[cqi].numOfHQ_1;
467                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_2 = \
468                      hqRetxStats.ulCqiStat[cqi].numOfHQ_2;
469                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_3 = \
470                      hqRetxStats.ulCqiStat[cqi].numOfHQ_3;
471                   genSts->hqRetxStats.ulCqiStat[cqi].numOfHQ_4 = \
472                      hqRetxStats.ulCqiStat[cqi].numOfHQ_4;
473                   genSts->hqRetxStats.ulCqiStat[cqi].totalTx = \
474                      hqRetxStats.ulCqiStat[cqi].totalTx;
475                }
476                /* Reset statistics */
477                if(sts->t.sts.action == ZEROSTS)
478                {
479                   cmMemset((U8 *)&hqRetxStats, 0, \
480                         sizeof(RgSchHqRetxStats));
481                   cmMemset((U8 *)&hqFailStats, 0, \
482                         sizeof(RgSchNackAckStats));
483                }
484             }
485 #endif /* MAC_SCH_STATS*/
486          }
487          break;
488       case STRGUSAP:
489          cmMemcpy((U8 *)&(cfm.t.sts.s.rguSts), (U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts,
490                   sizeof(RgSapSts));
491
492          /* check if action is read and reset */
493          if(sts->t.sts.action == ARST)
494             cmMemset((U8 *)&rgCb[inst].rguSap[sts->t.sts.sapInst].sapSts, 0, sizeof(RgSapSts));
495
496          break;
497       case STCRGSAP:
498          cmMemcpy((U8 *)&(cfm.t.sts.s.crgSts), (U8 *)&rgCb[inst].crgSap.sapSts,
499                   sizeof(RgSapSts));
500
501          /* check if action is read and reset */
502          if(sts->t.sts.action == ARST)
503             cmMemset((U8 *)&rgCb[inst].crgSap.sapSts, 0, sizeof(RgSapSts));
504
505          break;
506       case STTFUSAP:
507          cmMemcpy((U8 *)&(cfm.t.sts.s.tfuSts), (U8 *)&rgCb[inst].tfuSap.sapSts,
508                   sizeof(RgSapSts));
509
510          /* check if action is read and reset */
511          if(sts->t.sts.action == ARST)
512             cmMemset((U8 *)&rgCb[inst].tfuSap.sapSts, 0, sizeof(RgSapSts));
513
514          break;
515       default:
516          cfm.cfm.status = LCM_PRIM_NOK;
517          cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
518          RLOG1(L_ERROR, "Invalid Elmnt = %d",sts->hdr.elmId.elmnt);
519          break;     
520    }
521    RgMiLrgStsCfm(&cfmPst,&cfm);
522    RETVALUE(ROK);
523 }/*-- RgMiLrgStsReq --*/
524
525 \f
526 /**
527  * @brief Layer Manager Status request handler. 
528  *
529  * @details
530  *
531  *     Function : RgMiLrgStaReq
532  *     
533  *     This function handles the solicited status
534  *     request received from the Layer Manager.
535  *      -# Based on sta->hdr.elmId.elmnt, it retrieves the status of a
536  *      particular SAP from the rgCb global control block.
537  *      -# Invokes the RgMiLrgStaCfm to send back the confirmation to LM.
538  *     
539  *  @param[in]  Pst *pst, the post structure     
540  *  @param[in]  RgMngmt *sta, the status parameter's structure
541  *  @return  S16
542  *      -# ROK
543  **/
544 #ifdef ANSI
545 PUBLIC S16 RgMiLrgStaReq
546 (
547 Pst      *pst,    /* post structure  */
548 RgMngmt  *sta     /* status structure  */
549 )
550 #else
551 PUBLIC S16 RgMiLrgStaReq(pst, sta)
552 Pst      *pst;    /* post structure  */
553 RgMngmt  *sta;    /* status structure  */
554 #endif    
555 {
556    Pst       cfmPst;
557    RgMngmt   cfm;
558    Inst      inst ;
559
560    TRC2(RgMiLrgStaReq)
561    
562
563    RG_IS_INST_VALID(pst->dstInst);
564    inst = pst->dstInst - RG_INST_START;
565
566
567    /* Fill the post structure for sending the confirmation */
568    rgLMMFillCfmPst(pst, &cfmPst, sta);
569
570    if (sta->t.ssta.s.sysId.ptNmb != NULLP)
571    {
572       SPutSBuf(pst->region, pst->pool, (Data *)sta->t.ssta.s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE);
573    }
574    
575    cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
576    cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
577
578 #ifdef LMINT3
579    cfm.hdr.transId = sta->hdr.transId;
580 #endif
581    /* Check if General Config Done */
582    if(rgCb[inst].rgInit.cfgDone != TRUE) 
583    {
584       SGetDateTime(&cfm.t.ssta.dt);
585       if (SGetSBuf(cfmPst.region, cfmPst.pool, 
586           (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
587          != ROK)
588       {
589          RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
590          RETVALUE(ROK);
591       } 
592       cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
593       rgGetSId(&cfm.t.ssta.s.sysId);
594       cfm.cfm.status = LCM_PRIM_NOK;
595       cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
596       cfm.hdr.elmId.elmnt = sta->hdr.elmId.elmnt;
597       RgMiLrgStaCfm(&cfmPst, &cfm);
598       RLOG0(L_ERROR, "Gen Cfg not done");
599       RETVALUE(ROK);
600    }
601
602    switch(sta->hdr.elmId.elmnt)
603    {
604       case STGEN:
605          SGetDateTime(&cfm.t.ssta.dt);
606          if (SGetSBuf(cfmPst.region, cfmPst.pool, 
607              (Data **)&(cfm.t.ssta.s.sysId.ptNmb), LRG_MAX_PT_NUM_SIZE)
608             != ROK)
609          {
610             RLOG0(L_ERROR, "Memory Unavailable for Confirmation");
611             RETVALUE(ROK);
612          } 
613          cmMemset((U8 *)(cfm.t.ssta.s.sysId.ptNmb), 0, LRG_MAX_PT_NUM_SIZE);
614          rgGetSId(&cfm.t.ssta.s.sysId);
615          cfm.cfm.status = LCM_PRIM_OK;
616          cfm.cfm.reason = LCM_REASON_NOT_APPL;
617          RgMiLrgStaCfm(&cfmPst, &cfm);
618          break;
619       case STRGUSAP:
620          cfm.cfm.status = LCM_PRIM_OK;
621          cfm.cfm.reason = LCM_REASON_NOT_APPL;
622          SGetDateTime(&cfm.t.ssta.dt);
623          cmMemcpy((U8 *)&(cfm.t.ssta.s.rguSapSta), 
624                                 (U8 *)&rgCb[inst].rguSap[sta->t.ssta.sapInst].sapSta,
625             sizeof(RgSapSta));
626          RgMiLrgStaCfm(&cfmPst, &cfm);
627          break;
628       case STCRGSAP:
629          cfm.cfm.status = LCM_PRIM_OK;
630          cfm.cfm.reason = LCM_REASON_NOT_APPL;
631          SGetDateTime(&cfm.t.ssta.dt);
632          cmMemcpy((U8 *)&(cfm.t.ssta.s.crgSapSta), (U8 *)&rgCb[inst].crgSap.sapSta,
633          sizeof(RgSapSta));
634          RgMiLrgStaCfm(&cfmPst, &cfm);
635          break;
636       case STTFUSAP:
637          cfm.cfm.status = LCM_PRIM_OK;
638          cfm.cfm.reason = LCM_REASON_NOT_APPL;
639          SGetDateTime(&cfm.t.ssta.dt);
640          cmMemcpy((U8 *)&(cfm.t.ssta.s.tfuSapSta), (U8 *)&rgCb[inst].tfuSap.sapSta,
641          sizeof(RgSapSta));
642          RgMiLrgStaCfm(&cfmPst, &cfm);
643          break;
644       default:
645          cfm.cfm.status = LCM_PRIM_NOK;
646          cfm.cfm.reason = LCM_REASON_INVALID_ELMNT;
647          RgMiLrgStaCfm(&cfmPst, &cfm);
648          RLOG1(L_ERROR, "Invalid elmnt=%d",sta->hdr.elmId.elmnt);
649          break;     
650    }
651    RETVALUE(ROK);
652 }/*-- RgMiLrgStaReq --*/
653
654 \f
655 /**
656  * @brief Layer Manager Control request handler. 
657  *
658  * @details
659  *
660  *     Function : RgMiLrgCntrlReq
661  *     
662  *     This function handles the control
663  *     request received from the Layer Manager.
664  *      -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
665  *      and cntrl->t.cntrl.subAction, it performs the appropriate control action
666  *      of SAP (enable/disable), Debug (enable/disable), Trace (enable/disable)
667  *      and layer shutdown.
668  *      -# Invokes the RgMiLrgCntrlCfm to send back the confirmation to LM.
669  *     
670  *  @param[in]  Pst *pst, the post structure     
671  *  @param[in]  RgMngmt *cntrl, the control parameter's structure
672  *  @return  S16
673  *      -# ROK
674  **/
675 #ifdef ANSI
676 PUBLIC S16 RgMiLrgCntrlReq
677 (
678 Pst      *pst,    /* post structure  */
679 RgMngmt  *cntrl   /* control structure  */
680 )
681 #else
682 PUBLIC S16 RgMiLrgCntrlReq(pst, cntrl)
683 Pst      *pst;    /* post structure  */
684 RgMngmt  *cntrl;  /* control structure  */
685 #endif    
686 {
687    S16       ret = ROK;            /* return value */
688    Pst       cfmPst;
689    RgMngmt   cfm;
690    Inst      inst;
691    
692    TRC2(RgMiLrgCntrlReq)
693    
694    /* Fill the post structure for sending the confirmation */
695
696    RG_IS_INST_VALID(pst->dstInst);
697    inst = pst->dstInst - RG_INST_START;
698
699    rgLMMFillCfmPst(pst, &cfmPst, cntrl);
700
701    cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
702 #ifdef LMINT3
703    cfm.hdr.transId = cntrl->hdr.transId;
704 #endif
705    cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
706    cfm.t.cntrl.action = cntrl->t.cntrl.action;
707    cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
708
709    /* Check if General Config Done*/
710    if(rgCb[inst].rgInit.cfgDone != TRUE)
711    {
712       cfm.cfm.status = LCM_PRIM_NOK;
713       cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
714       cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
715       RgMiLrgCntrlCfm(&cfmPst, &cfm);
716       RLOG0(L_ERROR, "Gen Cfg not done");
717       RETVALUE(ROK);
718    }
719  
720    /* General Config done, process the Control request */   
721    switch(cntrl->hdr.elmId.elmnt)
722    {
723       case STGEN:
724          rgLMMGenCntrl(cntrl, &cfm, &cfmPst);
725          break;
726       case STTFUSAP:
727       case STRGUSAP:
728       case STCRGSAP:
729          rgLMMSapCntrl(cntrl, &cfm, &cfmPst);
730          break;
731       default:
732          cfm.cfm.status = LCM_PRIM_NOK;
733          cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
734          RgMiLrgCntrlCfm(&cfmPst, &cfm);
735          RLOG1(L_ERROR, "invalid elmnt=%d",cntrl->hdr.elmId.elmnt);
736          break;
737    }
738    RETVALUE(ret);
739 }/*-- RgMiLrgCntrlReq --*/
740
741 \f
742 /**
743  * @brief SAP Configuration Handler. 
744  *
745  * @details
746  *
747  *     Function : rgLMMSapCfg
748  *     
749  *     This function in called by RgMiLrgCfgReq(). It handles the
750  *     interface SAP configuration of the LTE MAC layer. It 
751  *     initializes the sapState to LRG_UNBND. Returns
752  *     reason for success/failure of this function.
753  *     
754  *  @param[in]  Inst        inst
755  *  @param[in]  RgCfg *cfg, the Configuaration information 
756  *  @return  U16
757  *      -# LCM_REASON_GENCFG_NOT_DONE
758  *      -# LCM_REASON_INVALID_SAP
759  *      -# LCM_REASON_NOT_APPL
760  **/
761 #ifdef ANSI
762 PRIVATE U16 rgLMMSapCfg
763 (
764 Inst  inst,
765 RgCfg *cfg,            /* Configuaration information */
766 Elmnt sapType             /* Sap Type */
767 )
768 #else
769 PRIVATE U16 rgLMMSapCfg(inst,cfg,sapType)
770 Inst  inst;
771 RgCfg *cfg;            /* Configuaration information */
772 Elmnt sapType;            /* Sap Type */
773 #endif
774 {
775    U16               ret = LCM_REASON_NOT_APPL;
776    RgLowSapCfgInfo   *lowSapCfg = NULLP;
777    RgUpSapCfgInfo    *upSapCfg = NULLP;
778    RgUpSapCb          *upSapCb  = NULLP;
779
780    TRC2(rgLMMSapCfg)
781
782    /* Check if Gen Config has been done */
783    if(rgCb[inst].rgInit.cfgDone != TRUE)
784       RETVALUE(LCM_REASON_GENCFG_NOT_DONE);
785
786    switch(sapType)
787    {   
788       case STRGUSAP:
789          if ((cfg->s.rguSap.spId > LRG_MAX_RGU_SAPS) &&
790              (cfg->s.rguSap.selector != RGU_SEL_TC) &&
791              (cfg->s.rguSap.selector != RGU_SEL_LC))
792          {
793             ret = LCM_REASON_INVALID_PAR_VAL;
794             RLOG0(L_ERROR, "unsupported Selector value for RGU");
795             break;
796          }
797          upSapCb = &(rgCb[inst].rguSap[cfg->s.rguSap.spId]);
798          if(upSapCb->sapSta.sapState == LRG_NOT_CFG)
799          { 
800             upSapCb->sapSta.sapState = LRG_UNBND;
801          }
802          upSapCfg = &(upSapCb->sapCfg);
803          upSapCfg->sapPst.dstEnt = cfg->s.rguSap.ent;
804          upSapCfg->sapPst.dstInst = cfg->s.rguSap.inst;
805          upSapCfg->sapPst.dstProcId = cfg->s.rguSap.procId;
806          upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
807          upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
808          upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
809          upSapCfg->sapPst.region = cfg->s.rguSap.mem.region;
810          upSapCfg->sapPst.pool = cfg->s.rguSap.mem.pool;
811          upSapCfg->sapPst.selector = cfg->s.rguSap.selector;
812          upSapCfg->sapPst.route = cfg->s.rguSap.route;
813          upSapCfg->sapPst.intfVer = 0; 
814          upSapCfg->sapPst.prior = cfg->s.rguSap.prior;
815          upSapCfg->suId = cfg->s.rguSap.suId;
816          upSapCfg->spId = cfg->s.rguSap.spId;
817          /*T2K uses 2 saps, T3K uses 1 sap. change the rgRguDlSap to 1 only if
818           * there is cfg request with sap is 1*/
819          break;
820       case STCRGSAP:
821          if ((cfg->s.crgSap.selector != CRG_SEL_TC) &&
822              (cfg->s.crgSap.selector != CRG_SEL_LC))
823          {
824             ret = LCM_REASON_INVALID_PAR_VAL;
825             RLOG0(L_ERROR, "unsupported Selector value for CRG");
826             break;
827          }
828          if(rgCb[inst].crgSap.sapSta.sapState == LRG_NOT_CFG)
829          { 
830             rgCb[inst].crgSap.sapSta.sapState = LRG_UNBND;
831          }
832          upSapCfg = &rgCb[inst].crgSap.sapCfg;
833
834          upSapCfg->sapPst.dstEnt = cfg->s.crgSap.ent;
835          upSapCfg->sapPst.dstInst = cfg->s.crgSap.inst;
836          upSapCfg->sapPst.dstProcId = cfg->s.crgSap.procId;
837          upSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
838          upSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
839          upSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
840          upSapCfg->sapPst.region = cfg->s.crgSap.mem.region;
841          upSapCfg->sapPst.pool = cfg->s.crgSap.mem.pool;
842          upSapCfg->sapPst.selector = cfg->s.crgSap.selector;
843          upSapCfg->sapPst.route = cfg->s.crgSap.route;
844          upSapCfg->sapPst.intfVer = 0; 
845          upSapCfg->sapPst.prior = cfg->s.crgSap.prior;
846          upSapCfg->suId = cfg->s.crgSap.suId;
847          upSapCfg->spId = cfg->s.crgSap.spId;
848          break;
849       case STTFUSAP:
850 #ifndef CL_MAC_LWLC 
851          if ((cfg->s.tfuSap.selector != TFU_SEL_TC) &&
852              (cfg->s.tfuSap.selector != TFU_SEL_LC))
853          {
854             ret = LCM_REASON_INVALID_PAR_VAL;
855             RLOG0(L_ERROR, "unsupported Selector value for TFU");
856             break;
857          }
858 #endif
859          if (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) 
860          { 
861             rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
862          }
863          lowSapCfg = &rgCb[inst].tfuSap.sapCfg;
864
865          lowSapCfg->sapPst.dstEnt = cfg->s.tfuSap.ent;
866          lowSapCfg->sapPst.dstInst = cfg->s.tfuSap.inst;
867          lowSapCfg->sapPst.dstProcId = rgCb[inst].rgInit.procId;
868          lowSapCfg->sapPst.srcEnt = rgCb[inst].rgInit.ent;
869          lowSapCfg->sapPst.srcInst = rgCb[inst].rgInit.inst;
870          lowSapCfg->sapPst.srcProcId = rgCb[inst].rgInit.procId;
871          lowSapCfg->sapPst.region = cfg->s.tfuSap.mem.region;
872          lowSapCfg->sapPst.pool = cfg->s.tfuSap.mem.pool;
873          lowSapCfg->sapPst.selector = cfg->s.tfuSap.selector;
874          lowSapCfg->sapPst.route = cfg->s.tfuSap.route;
875          lowSapCfg->sapPst.intfVer = 0; 
876          lowSapCfg->sapPst.prior = cfg->s.tfuSap.prior;
877          lowSapCfg->suId = cfg->s.tfuSap.suId;
878          lowSapCfg->spId = cfg->s.tfuSap.spId;
879          cmMemcpy((U8 *)&lowSapCfg->bndTmr, (U8 *)&cfg->s.tfuSap.bndTmr,
880                    sizeof(TmrCfg));
881          break;
882       default:
883          /* would never reach here */
884          break;
885    }
886    RETVALUE(ret);
887 }
888
889 \f
890 /**
891  * @brief General Configuration Handler. 
892  *
893  * @details
894  *
895  *     Function : rgLMMGenCfg
896  *     
897  *     This function in called by RgMiLrgCfgReq(). It handles the
898  *     general configuration of the LTE MAC layer. It initializes 
899  *     the hash lists of RgCb. Returns
900  *     reason for success/failure of this function.
901  *     
902  *  @param[in]  Inst        inst
903  *  @param[in]  RgCfg *cfg, the Configuaration information 
904  *  @return  U16
905  *      -# LCM_REASON_NOT_APPL 
906  *      -# LCM_REASON_INVALID_MSGTYPE
907  *      -# LCM_REASON_MEM_NOAVAIL
908  **/
909 #ifdef ANSI
910 PRIVATE U16 rgLMMGenCfg
911 (
912 Inst inst,
913 RgCfg *cfg            /* Configuaration information */
914 )
915 #else
916 PRIVATE U16 rgLMMGenCfg(inst,cfg)
917 Inst inst;
918 RgCfg *cfg;            /* Configuaration information */
919 #endif
920 {
921    U16    ret = LCM_REASON_NOT_APPL;
922
923    TRC2(rgLMMGenCfg)
924
925    /* Check if General Configuration is done already */
926    if (rgCb[inst].rgInit.cfgDone == TRUE)
927    {
928       RETVALUE(LCM_REASON_INVALID_MSGTYPE);
929    }
930    if ((cfg->s.genCfg.lmPst.selector != LRG_SEL_TC) &&
931        (cfg->s.genCfg.lmPst.selector != LRG_SEL_LC))
932    {
933       RLOG0(L_ERROR, "unsupported Selector value for RGU");
934       RETVALUE(LCM_REASON_INVALID_PAR_VAL);
935    }
936    /* Update the Pst structure for LM interface */
937    cmMemcpy((U8 *)&rgCb[inst].rgInit.lmPst, (U8 *)&cfg->s.genCfg.lmPst,
938              sizeof(Pst));
939
940    rgCb[inst].rgInit.lmPst.srcProcId = rgCb[inst].rgInit.procId;
941    rgCb[inst].rgInit.lmPst.srcEnt = rgCb[inst].rgInit.ent;
942    rgCb[inst].rgInit.lmPst.srcInst = rgCb[inst].rgInit.inst;
943    rgCb[inst].rgInit.lmPst.event = EVTNONE;
944
945    rgCb[inst].rgInit.region = cfg->s.genCfg.mem.region;
946    rgCb[inst].rgInit.pool = cfg->s.genCfg.mem.pool;
947    rgCb[inst].genCfg.tmrRes = cfg->s.genCfg.tmrRes;
948
949    macCb.macInst = rgCb[inst].rgInit.inst;
950
951    /* Initialize SAP States */
952    rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
953
954    if(cfg->s.genCfg.numRguSaps == 0)
955    {
956       RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Invalid numRguSap.\n"));
957       RETVALUE(RFAILED);
958    }
959
960    /* allocate RGR saps */
961    if (SGetSBuf(rgCb[inst].rgInit.region,
962                 rgCb[inst].rgInit.pool,
963                 (Data **)&rgCb[inst].rguSap,
964                 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps)) != ROK)
965    {
966       RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgGenCfg(): Failed to allocate mem for RGU SAP's.\n"));
967       RETVALUE(RFAILED);
968    }
969    rgCb[inst].numRguSaps = cfg->s.genCfg.numRguSaps;
970
971    for (int idx = 0; idx < rgCb[inst].numRguSaps; idx++)
972    {
973       rgCb[inst].rguSap[idx].sapSta.sapState = LRG_NOT_CFG;
974       cmMemset((U8 *)&rgCb[inst].rguSap[idx], 0, sizeof(RgUpSapCb));
975    }
976    rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
977    /* Initialize the timer blocks */
978    cmInitTimers(rgCb[inst].tmrBlk, RG_MAX_TIMER);
979    /* Initialzie the timer queue */   
980    cmMemset((U8 *)&rgCb[inst].tmrTq, 0, sizeof(CmTqType)*RG_TQ_SIZE);
981    /* Initialize the timer control point */
982    cmMemset((U8 *)&rgCb[inst].tmrTqCp, 0, sizeof(CmTqCp));
983    rgCb[inst].tmrTqCp.tmrLen = RG_TQ_SIZE;
984 #if 0
985    /* Timer Registration request to SSI */
986    if (SRegTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
987             (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr) != ROK)
988    {
989       
990       RLOG0(L_ERROR, "Failed to register timer");
991
992       SPutSBuf(rgCb[inst].rgInit.region,
993                 rgCb[inst].rgInit.pool,
994                 (Data *)rgCb[inst].rguSap,
995                 (sizeof(RgUpSapCb) * cfg->s.genCfg.numRguSaps));
996
997       RETVALUE(LCM_REASON_MEM_NOAVAIL);
998    }
999 #endif
1000    /* Set Config done in TskInit */
1001    rgCb[inst].rgInit.cfgDone = TRUE;
1002
1003    RETVALUE(ret);
1004 }
1005
1006 \f
1007 /***********************************************************
1008  *
1009  *     Func : rgLMMShutdown
1010  *        
1011  *
1012  *     Desc : Handles the MAC layer shutdown request. Calls 
1013  *     rgCFGFreeCellCb(RgCellCb*) to handle each cellCb deallocation.
1014  *            
1015  *
1016  *     Ret  : Void
1017  *
1018  *     Notes: 
1019  *
1020  *     File : rg_lmm.c 
1021  *
1022  **********************************************************/
1023 #ifdef ANSI
1024 PRIVATE Void rgLMMShutdown
1025 (
1026 Inst inst
1027 )
1028 #else
1029 PRIVATE Void rgLMMShutdown(inst)
1030 Inst inst;
1031 #endif
1032 {
1033    RgCellCb   *cell = rgCb[inst].cell;
1034    U8 idx;
1035
1036    TRC2(rgLMMShutdown)
1037
1038    /* Unbind the TFU Sap */
1039    if(rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM)
1040    {
1041       rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1042       if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1043       {
1044          rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap); 
1045       }
1046       rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1047    }
1048    if(rgCb[inst].tfuSap.sapSta.sapState == LRG_BND)
1049    {
1050       rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, LRG_UNBND);
1051       rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1052    }
1053
1054
1055    if(cell != NULLP)
1056    {
1057       for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1058       {
1059          rgTOMRlsSf(inst,&cell->subFrms[idx]);
1060       }
1061
1062       rgCFGFreeCellCb(cell);
1063    }
1064
1065    /* Deleting the RGU SAPs */
1066    SPutSBuf(rgCb[inst].rgInit.region,
1067                 rgCb[inst].rgInit.pool,
1068                 (Data *)rgCb[inst].rguSap,
1069                 (sizeof(RgUpSapCb) * rgCb[inst].numRguSaps));
1070    rgCb[inst].rguSap = NULLP;
1071
1072    rgCb[inst].inactiveCell = NULLP;
1073    rgCb[inst].cell         = NULLP;
1074
1075    /* De-register the Timer Service */
1076    (Void) SDeregTmrMt(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst,
1077                      (S16)rgCb[inst].genCfg.tmrRes, rgActvTmr); 
1078
1079    /* call back the task initialization function to intialize
1080     * the global RgCb Struct */
1081    rgActvInit(rgCb[inst].rgInit.ent, rgCb[inst].rgInit.inst, rgCb[inst].rgInit.region, 
1082               rgCb[inst].rgInit.reason);
1083
1084    RETVOID;
1085 }
1086
1087 \f
1088 /***********************************************************
1089  *
1090  *     Func : rgLMMGenCntrl 
1091  *        
1092  *
1093  *     Desc : Processes the LM control request for STGEN elmnt.
1094  *            
1095  *
1096  *     Ret  : Void
1097  *
1098  *     Notes: 
1099  *
1100  *     File : rg_lmm.c 
1101  *
1102  **********************************************************/
1103 #ifdef ANSI
1104 PRIVATE Void rgLMMGenCntrl 
1105 (
1106 RgMngmt       *cntrl,
1107 RgMngmt       *cfm,
1108 Pst           *cfmPst
1109 )
1110 #else
1111 PRIVATE Void rgLMMGenCntrl(cntrl, cfm, cfmPst)
1112 RgMngmt       *cntrl;
1113 RgMngmt       *cfm;
1114 Pst           *cfmPst;
1115 #endif
1116 {
1117    Inst      inst = (cfmPst->srcInst - RG_INST_START);
1118    TRC2(rgLMMGenCntrl)
1119
1120    cfm->cfm.status = LCM_PRIM_OK;
1121    cfm->cfm.reason = LCM_REASON_NOT_APPL;
1122    
1123
1124    switch(cntrl->t.cntrl.action)
1125    {
1126       case AENA:
1127          /* Action is Enable */
1128          switch(cntrl->t.cntrl.subAction)
1129          {
1130             case SATRC:
1131             /* Enable Traces */
1132                rgCb[inst].rgInit.trc = TRUE;
1133                rgCb[inst].trcLen = cntrl->t.cntrl.s.trcLen;
1134                /*Store the response and TransId for sending the Traces */
1135                cmMemcpy((U8 *)&rgCb[inst].genCfg.trcResp.response, 
1136                (U8 *)&cntrl->hdr.response, sizeof(Resp));
1137                rgCb[inst].genCfg.trcResp.transId = cntrl->hdr.transId;
1138                
1139                break;
1140             case SAUSTA:   
1141             /* Enable Unsolicited Status (alarms) */
1142                rgCb[inst].rgInit.usta = TRUE;
1143                /*Store the response and TransId for sending the Alarms */
1144                cmMemcpy((U8 *)&rgCb[inst].genCfg.ustaResp.response, 
1145                (U8 *)&cntrl->hdr.response, sizeof(Resp));
1146                rgCb[inst].genCfg.ustaResp.transId = cntrl->hdr.transId;
1147                break;
1148             case SADBG:
1149             /* Enable Debug Printing */
1150 #ifdef DEBUGP
1151                rgCb[inst].rgInit.dbgMask |= cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1152 #endif
1153                break;
1154 #ifdef SS_DIAG
1155             case SALOG:
1156                rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1157                break;
1158 #endif
1159
1160             default:
1161                cfm->cfm.status = LCM_PRIM_NOK;
1162                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1163                RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1164                break;
1165          }
1166          break;
1167       case ADISIMM:
1168          /* Action is Diable immidiately */
1169          switch(cntrl->t.cntrl.subAction)
1170          {
1171             case SATRC:
1172             /* Disable Traces */
1173                rgCb[inst].rgInit.trc = FALSE;
1174                break;
1175             case SAUSTA:
1176             /* Disable Unsolicited Status (alarms) */
1177                rgCb[inst].rgInit.usta = FALSE;
1178                break;
1179             case SADBG:
1180             /* Disable Debug Printing */
1181 #ifdef DEBUGP
1182                rgCb[inst].rgInit.dbgMask &=~cntrl->t.cntrl.s.rgDbgCntrl.dbgMask;
1183 #endif
1184                break;
1185 #ifdef SS_DIAG
1186             case SALOG:
1187                rgCb[inst].rgInit.logMask = cntrl->t.cntrl.s.logMask;
1188                 break;
1189 #endif
1190
1191             default:
1192                cfm->cfm.status = LCM_PRIM_NOK;
1193                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1194                RLOG1(L_ERROR, "invalid subaction=%d",cntrl->t.cntrl.subAction);
1195                break;
1196          }
1197          break;
1198       case ASHUTDOWN:
1199          /* Free all the memory dynamically allocated by MAC */
1200          rgLMMShutdown(inst);
1201          break;
1202       default:
1203          cfm->cfm.status = LCM_PRIM_NOK;
1204          cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1205          RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1206          break;
1207    }
1208    RgMiLrgCntrlCfm(cfmPst, cfm);
1209    RETVOID;
1210 }
1211
1212 \f
1213 /***********************************************************
1214  *
1215  *     Func : rgLMMSapCntrl 
1216  *        
1217  *
1218  *     Desc : Processes the LM control request for STxxxSAP elmnt.
1219  *            
1220  *
1221  *     Ret  : Void
1222  *
1223  *     Notes: 
1224  *
1225  *     File : rg_lmm.c 
1226  *
1227  **********************************************************/
1228 #ifdef ANSI
1229 PRIVATE Void rgLMMSapCntrl 
1230 (
1231 RgMngmt       *cntrl,
1232 RgMngmt       *cfm,
1233 Pst           *cfmPst
1234 )
1235 #else
1236 PRIVATE Void rgLMMSapCntrl(cntrl, cfm, cfmPst)
1237 RgMngmt       *cntrl;
1238 RgMngmt       *cfm;
1239 Pst           *cfmPst;
1240 #endif
1241 {
1242    Inst      inst = cfmPst->srcInst - RG_INST_START;
1243    TRC2(rgLMMSapCntrl)
1244
1245    /* Only TFU Sap can be controlled by LM */
1246    switch(cntrl->hdr.elmId.elmnt)
1247    {
1248       case STTFUSAP:
1249          switch(cntrl->t.cntrl.action)
1250          {
1251             case ABND:
1252             /* Bind Enable Request */
1253                if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1254                    (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1255                {
1256                   cfm->cfm.status = LCM_PRIM_NOK;
1257                   cfm->cfm.reason = LCM_REASON_INVALID_SAP;
1258                }
1259                else
1260                {
1261                   if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1262                   {
1263                      rgLMMStartTmr(inst,RG_BNDREQ_TMR, rgCb[inst].tfuSap.sapCfg.bndTmr.val, 
1264                      (PTR)&rgCb[inst].tfuSap);
1265                   }
1266                   /* Change SAP state */
1267                   rgCb[inst].tfuSap.sapSta.sapState = LRG_WAIT_BNDCFM;
1268                   rgCb[inst].tfuSap.numBndRetries++;
1269                   /* Store the response and TransId for sending 
1270                    * the Control confirm */
1271                   cmMemcpy((U8 *)&rgCb[inst].genCfg.bndCfmResp.response,
1272                            (U8 *)&cntrl->hdr.response, sizeof(Resp));
1273                   rgCb[inst].genCfg.bndCfmResp.transId = cntrl->hdr.transId;
1274
1275                   /* Sending Status Indication to Layer Manager */
1276                   cfm->cfm.status = LCM_PRIM_OK_NDONE;
1277                   cfm->cfm.reason = LCM_REASON_NOT_APPL;
1278                   RgMiLrgCntrlCfm(cfmPst, cfm);
1279
1280                   rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1281                                       rgCb[inst].tfuSap.sapCfg.spId);
1282                   RETVOID;
1283                }
1284                break;
1285             case AUBND:
1286             /* Unbind request */
1287
1288                /* Check if the SAP is configured */
1289                if( (rgCb[inst].tfuSap.sapSta.sapState == LRG_NOT_CFG) ||
1290                      (rgCb[inst].tfuSap.sapSta.sapState == LRG_UNBND))
1291                {
1292                   cfm->cfm.status = LCM_PRIM_NOK;
1293                   cfm->cfm.reason = LCM_REASON_INVALID_MSGTYPE;
1294                }
1295                else
1296                {
1297                   rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1298                   if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1299                   {
1300                      rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1301                   }
1302                   /* Change SAP state */
1303                   rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1304                   cfm->cfm.status = LCM_PRIM_OK;
1305                   cfm->cfm.reason = LCM_REASON_NOT_APPL;
1306                }
1307                break;
1308             case ADEL:
1309                /* Delete SAP, does initialization of SAP */
1310                if ((rgCb[inst].tfuSap.sapSta.sapState == LRG_WAIT_BNDCFM) ||
1311                    (rgCb[inst].tfuSap.sapSta.sapState == LRG_BND))
1312                {
1313                   rgLIMTfuUbndReq(inst,rgCb[inst].tfuSap.sapCfg.spId, TFU_UBNDREQ_MNGMT);
1314                   if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1315                   {
1316                      rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1317                   }
1318                }
1319                cmMemset((U8 *)&rgCb[inst].tfuSap, 0, sizeof(RgLowSapCb));
1320                rgCb[inst].tfuSap.sapSta.sapState = LRG_NOT_CFG;
1321                cfm->cfm.status = LCM_PRIM_OK;
1322                cfm->cfm.reason = LCM_REASON_NOT_APPL;
1323                break;
1324             default:
1325                cfm->cfm.status = LCM_PRIM_NOK;
1326                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1327                RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1328                cntrl->t.cntrl.action));
1329                break;
1330          }
1331          break;
1332       case STRGUSAP:
1333          switch(cntrl->t.cntrl.action)
1334          {
1335             case ADEL:
1336                cmMemset((U8 *)&rgCb[inst].rguSap[cntrl->t.cntrl.instId], 0, sizeof(RgUpSapCb));
1337                rgCb[inst].rguSap[cntrl->t.cntrl.instId].sapSta.sapState = LRG_NOT_CFG;
1338                cfm->cfm.status = LCM_PRIM_OK;
1339                cfm->cfm.reason = LCM_REASON_NOT_APPL;
1340                break;
1341             default:
1342                cfm->cfm.status = LCM_PRIM_NOK;
1343                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1344                RGDBGERRNEW(inst,(rgPBuf(inst), "\nrgLMMSapCntrl(): invalid action=%d",
1345                cntrl->t.cntrl.action));
1346                break;
1347          }
1348          break;
1349       case STCRGSAP:
1350          switch(cntrl->t.cntrl.action)
1351          {
1352             case ADEL:
1353                cmMemset((U8 *)&rgCb[inst].crgSap, 0, sizeof(RgUpSapCb));
1354                rgCb[inst].crgSap.sapSta.sapState = LRG_NOT_CFG;
1355                cfm->cfm.status = LCM_PRIM_OK;
1356                cfm->cfm.reason = LCM_REASON_NOT_APPL;
1357                break;
1358             default:
1359                cfm->cfm.status = LCM_PRIM_NOK;
1360                cfm->cfm.reason = LCM_REASON_INVALID_PAR_VAL;
1361                RLOG1(L_ERROR, "invalid action=%d",cntrl->t.cntrl.action);
1362                
1363                break;
1364          }
1365          break;
1366       default:
1367          /* Would never here. */
1368          RETVOID;
1369    }
1370    RgMiLrgCntrlCfm(cfmPst, cfm);
1371    RETVOID;
1372 }
1373
1374 \f
1375 /***********************************************************
1376  *
1377  *     Func : rgLMMFillCfmPst 
1378  *        
1379  *
1380  *     Desc : Fills the Confirmation Post Structure cfmPst using the reqPst 
1381  *            and the cfm->hdr.response.
1382  *            
1383  *
1384  *     Ret  : Void
1385  *
1386  *     Notes: 
1387  *
1388  *     File : rg_lmm.c 
1389  *
1390  **********************************************************/
1391 #ifdef ANSI
1392 PRIVATE Void rgLMMFillCfmPst
1393 (
1394 Pst           *reqPst,
1395 Pst           *cfmPst,
1396 RgMngmt       *cfm
1397 )
1398 #else
1399 PRIVATE Void rgLMMFillCfmPst(reqPst, cfmPst, cfm)
1400 Pst           *reqPst;
1401 Pst           *cfmPst;
1402 RgMngmt       *cfm;
1403 #endif
1404 {
1405    Inst inst;
1406    TRC2(rgLMMFillCfmPst)
1407    inst = (reqPst->dstInst - RG_INST_START);
1408
1409    cfmPst->srcEnt    = rgCb[inst].rgInit.ent;
1410    cfmPst->srcInst   = rgCb[inst].rgInit.inst;
1411    cfmPst->srcProcId = rgCb[inst].rgInit.procId;
1412    cfmPst->dstEnt    = reqPst->srcEnt;
1413    cfmPst->dstInst   = reqPst->srcInst;
1414    cfmPst->dstProcId = reqPst->srcProcId;
1415
1416    cfmPst->selector  = cfm->hdr.response.selector;
1417    cfmPst->prior     = cfm->hdr.response.prior;
1418    cfmPst->route     = cfm->hdr.response.route;
1419    cfmPst->region    = cfm->hdr.response.mem.region;
1420    cfmPst->pool      = cfm->hdr.response.mem.pool;
1421
1422    RETVOID;
1423 }
1424
1425 \f
1426 /**
1427  * @brief Timer start handler. 
1428  *
1429  * @details
1430  *
1431  *     Function : rgLMMStartTmr
1432  *     
1433  *     This function based on the input parameters starts the timer for 
1434  *     "tmrVal" duration. As of now MAC uses the timer functionality for 
1435  *     BndReq only. Hence there is no conditional code based on "tmrEvnt".
1436  *     
1437  *  @param[in]  Inst        inst
1438  *  @param[in]  S16   tmrEvnt, the Timer Event    
1439  *  @param[in]  U32   tmrVal,  the Wait Time
1440  *  @param[in]  PTR   cb,  Entry for which Timer expired
1441  *  @return  S16
1442  *      -# ROK
1443  **/
1444 #ifdef ANSI
1445 PUBLIC S16 rgLMMStartTmr
1446 (
1447 Inst               inst,
1448 S16                tmrEvnt,            /* Timer Event */
1449 U32                tmrVal,             /* Wait Time */
1450 PTR                cb                  /* Entry for which Timer Expired */
1451 )
1452 #else
1453 PUBLIC S16 rgLMMStartTmr(tmrEvnt, tmrVal, cb)
1454 Inst               inst;
1455 S16                tmrEvnt;            /* Timer Event */
1456 U32                tmrVal;             /* Wait Time */
1457 PTR                cb;                 /* Entry for which Timer Expired */
1458 #endif
1459 {
1460    CmTmrArg    arg;
1461
1462    TRC2(rgLMMStartTmr)
1463
1464    UNUSED(tmrEvnt);
1465
1466    /* Initialize the arg structure */
1467    cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1468
1469    arg.tqCp = &rgCb[inst].tmrTqCp;
1470    arg.tq = rgCb[inst].tmrTq;
1471    arg.timers = rgCb[inst].tmrBlk;
1472    arg.cb = cb;
1473    arg.tNum = 0;
1474    arg.max = RG_MAX_TIMER;
1475    arg.evnt = RG_BNDREQ_TMR;
1476    arg.wait = tmrVal;      
1477    cmPlcCbTq(&arg);
1478
1479    RETVALUE(ROK);
1480 }
1481
1482 \f
1483 /**
1484  * @brief Timer stop handler. 
1485  *
1486  * @details
1487  *
1488  *     Function : rgLMMStopTmr
1489  *     
1490  *     This function based on the input parameters stops the timer for 
1491  *     "tmrEvnt". As of now MAC uses the timer functionality for 
1492  *     BndReq only. Hence there is no conditional code based on "tmrEvnt".
1493  *     Once the bind happens and this timer is stopped, the timer functionality
1494  *     is deregistered with SSI. As there is no further use of timer processing.
1495  *     
1496  *  @param[in]  Inst        inst
1497  *  @param[in]  S16   tmrEvnt, the Timer Event    
1498  *  @param[in]  PTR   cb,  Entry for which Timer expired
1499  *  @return  S16
1500  *      -# ROK
1501  *      -# RFAILED
1502  **/
1503 #ifdef ANSI
1504 PUBLIC S16 rgLMMStopTmr
1505 (
1506 Inst               inst,             /* Scheduler instance */
1507 S16                tmrEvnt,            /* Timer Event */
1508 PTR                cb                  /* Entry for which Timer Expired */
1509 )
1510 #else
1511 PUBLIC S16 rgLMMStopTmr(inst,tmrEvnt, cb)
1512 Inst               inst;             /* Scheduler instance */
1513 S16                tmrEvnt;            /* Timer Event */
1514 PTR                cb;                 /* Entry for which Timer Expired */
1515 #endif
1516 {
1517    CmTmrArg   arg;
1518    U8         i;
1519    S16        ret; 
1520
1521    TRC2(rgLMMStopTmr)
1522
1523    ret = RFAILED;
1524
1525    for(i=0;i<RG_MAX_TIMER;i++)
1526    {
1527       /* Search for the Timer Blocks */
1528       if(rgCb[inst].tmrBlk[i].tmrEvnt == tmrEvnt)
1529       {
1530          /* Initialize the arg structure */
1531          cmMemset((U8 *)&arg, 0, sizeof(CmTmrArg));
1532
1533          arg.tqCp = &rgCb[inst].tmrTqCp;
1534          arg.tq = rgCb[inst].tmrTq;
1535          arg.timers = rgCb[inst].tmrBlk;
1536          arg.cb = cb;
1537          arg.max = RG_MAX_TIMER;
1538          arg.evnt = NOTUSED;
1539          arg.wait = NOTUSED;
1540
1541          arg.tNum = i;   
1542          cmRmvCbTq(&arg);
1543          ret = ROK;
1544          break;
1545       }
1546
1547    }
1548
1549
1550    RETVALUE(ret);
1551 }
1552
1553 \f
1554 /**
1555  * @brief Timer Expiry handler. 
1556  *
1557  * @details
1558  *
1559  *     Function : rgLMMTmrExpiry
1560  *     
1561  *     This is a callback function used as an input parameter to cmPrcTmr()
1562  *     to check expiry of any timer. In this function, the only concern is
1563  *     about tmrEvnt=Bind timer.
1564  *     
1565  *  @param[in]  PTR   cb,  Entry for which Timer expired
1566  *  @param[in]  S16   tmrEvnt, the Timer Event    
1567  *  @return  S16
1568  *      -# ROK
1569  **/
1570 #ifdef ANSI
1571 PUBLIC S16 rgLMMTmrExpiry
1572 (
1573 PTR cb,               /* Pointer to timer control block */
1574 S16 tmrEvnt           /* Timer Event */
1575 )
1576 #else
1577 PUBLIC S16 rgLMMTmrExpiry(cb,tmrEvnt)
1578 PTR cb;               /* Pointer to timer control block */
1579 S16 tmrEvnt;          /* Timer Event */
1580 #endif
1581 {
1582    S16        ret = ROK;
1583    RgLowSapCb *tfuSap = (RgLowSapCb *)cb;
1584    Inst          inst = tfuSap->sapCfg.sapPst.srcInst - RG_INST_START;
1585
1586    TRC2(rgLMMTmrExpiry)
1587
1588    
1589    switch(tmrEvnt)
1590    {
1591       case RG_BNDREQ_TMR:
1592          tfuSap->numBndRetries++;
1593          if(tfuSap->numBndRetries > RG_MAX_BNDRETRY)
1594          {
1595             rgLMMStaInd(inst,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
1596                         LCM_CAUSE_TMR_EXPIRED, NULLP);
1597          }
1598          else
1599          {
1600             /* Restart the bind timer */
1601             if (tfuSap->sapCfg.bndTmr.enb == TRUE)
1602             {
1603                ret = rgLMMStartTmr(inst,RG_BNDREQ_TMR, tfuSap->sapCfg.bndTmr.val,
1604                cb);
1605             }
1606
1607             /* Send bind request */
1608             rgLIMTfuBndReq(inst,rgCb[inst].tfuSap.sapCfg.suId,
1609                                 rgCb[inst].tfuSap.sapCfg.spId);
1610          }
1611          break;
1612       default:
1613          RLOG1(L_ERROR, "Invalid tmrEvnt=%d",tmrEvnt);
1614          ret = RFAILED;
1615          break;
1616    }
1617    RETVALUE(ret);
1618 }
1619
1620
1621 \f
1622 /**
1623  * @brief Layer Manager Unsolicited Status Indication generation. 
1624  *
1625  * @details
1626  *
1627  *     Function : rgLMMStaInd 
1628  *     
1629  *     This API is used by the other modules of MAC to send a unsolicited
1630  *     status indication to the Layer Manager.
1631  *     
1632  *  @param[in]  Inst        inst
1633  *  @param[in]  U16 category, the Alarm category
1634  *  @param[in]  U16 event, the Alarm event
1635  *  @param[in]  U16 cause, the cause of the Alarm
1636  *  @param[in]  RgUstaDgn *dgn, Alarm Diagonostics
1637  *  @return  S16
1638  *      -# ROK
1639  **/
1640 #ifdef ANSI
1641 PUBLIC S16 rgLMMStaInd
1642 (
1643 Inst inst,
1644 U16 category,
1645 U16 event,
1646 U16 cause,
1647 RgUstaDgn *dgn
1648 )
1649 #else
1650 PUBLIC S16 rgLMMStaInd(inst,category, event, cause, dgn) 
1651 Inst inst;
1652 U16 category;
1653 U16 event;
1654 U16 cause;
1655 RgUstaDgn *dgn;
1656 #endif
1657 {
1658    RgMngmt    usta;
1659
1660    TRC2(rgLMMStaInd)
1661
1662    if(rgCb[inst].rgInit.usta == FALSE)
1663    {
1664       RETVALUE(ROK);
1665    }
1666
1667    cmMemset((U8 *)&usta, 0, sizeof(RgMngmt));
1668
1669    SGetDateTime(&usta.t.usta.cmAlarm.dt);
1670    usta.t.usta.cmAlarm.category = category;
1671    usta.t.usta.cmAlarm.event = event;
1672    usta.t.usta.cmAlarm.cause = cause;
1673    if (dgn != NULLP)
1674    {
1675       cmMemcpy((U8 *)&usta.t.usta.dgn, (U8 *)dgn, sizeof(RgUstaDgn));
1676    }
1677
1678    rgCb[inst].rgInit.lmPst.selector = rgCb[inst].genCfg.ustaResp.response.selector;
1679    rgCb[inst].rgInit.lmPst.prior = rgCb[inst].genCfg.ustaResp.response.prior;
1680    rgCb[inst].rgInit.lmPst.route = rgCb[inst].genCfg.ustaResp.response.route;
1681    rgCb[inst].rgInit.lmPst.region = rgCb[inst].genCfg.ustaResp.response.mem.region;
1682    rgCb[inst].rgInit.lmPst.pool = rgCb[inst].genCfg.ustaResp.response.mem.pool;
1683    usta.hdr.transId = rgCb[inst].genCfg.ustaResp.transId;
1684
1685    RETVALUE(RgMiLrgStaInd(&rgCb[inst].rgInit.lmPst, &usta));
1686 }
1687
1688 \f
1689 /**
1690  * @brief Layer Manager Trace Indication generation. 
1691  *
1692  * @details
1693  *
1694  *     Function : rgLMMTrcInd 
1695  *     
1696  *     This API is used by the other modules of MAC to send a 
1697  *     Trace indication to the Layer Manager.
1698  *     
1699  *  @param[in]  Inst        inst
1700  *  @param[in]   Buffer *srcMbuf, the Message Buffer .
1701  *  @param[in]   U8 event, the trace event.
1702  *  @return Void 
1703  **/
1704 #ifdef ANSI
1705 PUBLIC Void rgLMMTrcInd
1706 (
1707 Inst   inst,
1708 Buffer *srcMbuf,    /* Message Buffer */
1709 U8 event            /* event */
1710 )
1711 #else
1712 PUBLIC Void rgLMMTrcInd(inst,srcMbuf,event)
1713 Inst   inst;
1714 Buffer *srcMbuf;    /* Message Buffer */
1715 U8 event;           /* event */
1716 #endif
1717 {
1718    Buffer   *dstMbuf = NULLP;   
1719    MsgLen   bufLen  = 0;
1720    Data     *tempBuf;
1721    MsgLen   tempCnt;
1722    RgMngmt  trc;
1723    Pst      pst;
1724
1725    TRC2(rgLMMTrcInd)
1726
1727
1728    if ((rgCb[inst].trcLen == LRG_NO_TRACE) || (srcMbuf == NULLP))
1729    {
1730       RLOG0(L_ERROR, "Trace Disabled.");
1731       RETVOID;
1732    }
1733    
1734    cmMemset((U8 *)&trc, 0, sizeof(RgMngmt));
1735
1736    pst = rgCb[inst].rgInit.lmPst;
1737    pst.selector = rgCb[inst].genCfg.trcResp.response.selector;
1738    pst.prior = rgCb[inst].genCfg.trcResp.response.prior;
1739    pst.route = rgCb[inst].genCfg.trcResp.response.route;
1740    pst.region = rgCb[inst].genCfg.trcResp.response.mem.region;
1741    pst.pool = rgCb[inst].genCfg.trcResp.response.mem.pool;
1742
1743    trc.hdr.transId = rgCb[inst].genCfg.trcResp.transId;
1744
1745    SGetDateTime(&trc.t.trc.dt);
1746       
1747    /* Check if the whole buffer is to be sent in Trace indication */
1748    if(rgCb[inst].trcLen == LRG_FULL_TRACE)
1749    {
1750       if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1751          != ROK)
1752       {
1753          RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1754          RETVOID;
1755       }
1756       trc.cfm.status = LCM_PRIM_OK;
1757       trc.cfm.reason = LCM_REASON_NOT_APPL;
1758       trc.t.trc.evnt = event;
1759          
1760       /* Send Trace Indication to Layer manager */
1761       RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1762    }
1763    /* check if only a specified number of bytes are to be sent */
1764    else if(rgCb[inst].trcLen > 0)
1765    {
1766       /* Get the length of the recvd message buffer */
1767       if (SFndLenMsg(srcMbuf, &bufLen) != ROK)
1768       {
1769          RLOG0(L_ERROR, "SFndLenMsg Failed.");
1770          RETVOID;
1771       }
1772       /* Check if the recvd buffer size is less than request trace len */
1773       if(bufLen < rgCb[inst].trcLen)
1774       {
1775          /* Copy the whole of the recvd buffer in trace indication */
1776       
1777          if (SCpyMsgMsg(srcMbuf, pst.region, pst.pool, &dstMbuf)
1778             != ROK)
1779          {
1780             RLOG0(L_ERROR, "SCpyMsgMsg Failed.");
1781             RETVOID;
1782          }
1783          
1784          trc.cfm.status = LCM_PRIM_OK;
1785          trc.cfm.reason = LCM_REASON_NOT_APPL;
1786          trc.t.trc.evnt = event;
1787
1788          /* Send Trace Indication to Layer manager */
1789          RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1790       }
1791       /* if the recvd buffer size is greater than request trace len */
1792       if(bufLen >= rgCb[inst].trcLen)
1793       {
1794          /* Get a temporary buffer to store the msg */
1795          if (rgAllocSBuf(inst,&tempBuf, rgCb[inst].trcLen) != ROK)
1796          {
1797             RLOG0(L_ERROR, "rgAllocSBuf Failed.");
1798             RETVOID;
1799          }
1800          
1801          /* Copy trcLen nos of bytes from the recvd message */
1802          if (SCpyMsgFix(srcMbuf,0,rgCb[inst].trcLen,tempBuf,&tempCnt) != ROK)   
1803          {
1804             RLOG0(L_ERROR, "SCpyMsgFix Failed.");
1805             RETVOID;
1806          }
1807
1808          if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK)
1809          {
1810             RLOG0(L_ERROR, "dstMbuf Allocation Failed");
1811             RETVOID;
1812          }
1813          /* Copy the tempBuf data to dst mBuf */
1814          if (SCpyFixMsg(tempBuf,dstMbuf,0,rgCb[inst].trcLen,&tempCnt) != ROK)
1815          {
1816             RLOG0(L_ERROR, "SCpyFixMsg Failed.");
1817             RETVOID;
1818          }
1819
1820          /*ccpu00117052 - MOD - Passing double pointer for proper NULLP 
1821                                assignment */
1822          /* Free the memory allocated for tempBuf */
1823          rgFreeSBuf(inst,&tempBuf, rgCb[inst].trcLen);
1824                
1825          trc.cfm.status = LCM_PRIM_OK;
1826          trc.cfm.reason = LCM_REASON_NOT_APPL;
1827          trc.t.trc.evnt = event;
1828       
1829          /* Send Trace Indication to Layer manager */
1830          RgMiLrgTrcInd(&pst, &trc, dstMbuf);
1831       }
1832    }
1833    RETVOID;
1834 }
1835
1836 \f
1837 /**
1838  * @brief Layer Manager Control Confirm generation handler
1839  *        for Bind Confirm reception at TFU interface.
1840  *        RgLiTfuBndCfm() forwards the confirmation to this 
1841  *        function. All SAP state related handling is restricted
1842  *        to LMM modules, hence the cfm forwarding.
1843  *
1844  * @details
1845  *
1846  *     Function : rgLMMBndCfm 
1847  *     
1848  *     This API is used by the LIM module of MAC to forward
1849  *     the Bind Confirm it receives over the TFU interface.
1850  *     
1851  *  @param[in]   Pst *pst, Post Structure
1852  *  @param[in]   SuId suId, Service user ID
1853  *  @param[in]   U8 status, Status
1854  *  @return  S16
1855  *      -# ROK
1856  **/
1857 #ifdef ANSI
1858 PUBLIC S16 rgLMMBndCfm
1859 (
1860 Pst *pst,               /* Post Structure */
1861 SuId suId,              /* Service user ID */
1862 U8 status               /* Status */
1863 )
1864 #else
1865 PUBLIC S16 rgLMMBndCfm(pst,suId,status)
1866 Pst *pst;               /* Post Structure */
1867 SuId suId;              /* Service user ID */
1868 U8 status;              /* Status */
1869 #endif
1870 {
1871    Inst      inst = pst->dstInst - RG_INST_START;
1872    S16       ret = ROK;
1873    RgMngmt   cntrlCfm;
1874    Pst       cfmPst;
1875
1876    TRC3(rgLMMBndCfm)
1877
1878    UNUSED(pst);
1879
1880    /* Check if the suId is valid */
1881    if(rgCb[inst].tfuSap.sapCfg.suId != suId)
1882    {
1883       RLOG0(L_ERROR, "Invalid SuId");
1884       RETVALUE(RFAILED);
1885    }
1886
1887    /* check the Sap State */
1888    switch(rgCb[inst].tfuSap.sapSta.sapState)
1889    {
1890       case LRG_WAIT_BNDCFM:
1891          break;
1892       case LRG_BND:
1893          /* SAP is already bound */
1894          RETVALUE(ROK);
1895       default:
1896          RETVALUE(RFAILED);
1897    }
1898
1899    cfmPst = rgCb[inst].rgInit.lmPst;
1900    cfmPst.selector = rgCb[inst].genCfg.bndCfmResp.response.selector;
1901    cfmPst.prior = rgCb[inst].genCfg.bndCfmResp.response.prior;
1902    cfmPst.route = rgCb[inst].genCfg.bndCfmResp.response.route;
1903    cfmPst.region = rgCb[inst].genCfg.bndCfmResp.response.mem.region;
1904    cfmPst.pool = rgCb[inst].genCfg.bndCfmResp.response.mem.pool;
1905    
1906    cmMemset((U8 *)&cntrlCfm, 0, sizeof(RgMngmt));
1907
1908    switch(status)
1909    {
1910       case CM_BND_OK: /* status is OK */
1911          /* Change SAP state to Bound */
1912          rgCb[inst].tfuSap.sapSta.sapState = LRG_BND;
1913          if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1914          {
1915             ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1916          }
1917          /* Send Control Confirm with status as OK to Layer Manager */
1918          cntrlCfm.cfm.status = LCM_PRIM_OK;
1919          cntrlCfm.cfm.reason = LCM_REASON_NOT_APPL;
1920          break;
1921
1922       default:
1923          /* Change SAP state to UnBound */
1924          rgCb[inst].tfuSap.sapSta.sapState = LRG_UNBND;
1925          if (rgCb[inst].tfuSap.sapCfg.bndTmr.enb == TRUE)
1926          {
1927             ret = rgLMMStopTmr(inst,RG_BNDREQ_TMR, (PTR)&rgCb[inst].tfuSap);
1928          }
1929          /* Send Control Confirm with status as NOK to Layer Manager */
1930          cntrlCfm.cfm.status = LCM_PRIM_NOK;
1931          cntrlCfm.cfm.reason = LCM_REASON_NEG_CFM;
1932          break;
1933    }
1934    rgCb[inst].tfuSap.numBndRetries = 0;
1935    cntrlCfm.hdr.elmId.elmnt = STTFUSAP;
1936    cntrlCfm.hdr.transId = rgCb[inst].genCfg.bndCfmResp.transId;
1937
1938    ret = RgMiLrgCntrlCfm(&cfmPst, &cntrlCfm);
1939
1940    RETVALUE(ret);
1941 }
1942
1943 \f
1944 /**
1945  * @brief LTE MAC timer call back function registered with SSI. 
1946  *
1947  * @details
1948  *
1949  *     Function :  rgActvTmr
1950  *     
1951  *     This function is invoked by SSI for every timer activation
1952  *     period expiry.
1953  *     
1954  *  @return  S16
1955  *      -# ROK
1956  **/
1957 #ifdef ANSI
1958 PUBLIC S16 rgActvTmr
1959 (
1960  Ent     ent,
1961  Inst    inst
1962 )
1963 #else
1964 PUBLIC S16 rgActvTmr(ent, inst)
1965 Ent     ent;
1966 Inst    inst;
1967 #endif
1968 {
1969    Inst macInst = (inst  - RG_INST_START);
1970    TRC3(rgActvTmr)
1971
1972    /* Check if any MAC timer has expired */ 
1973    cmPrcTmr(&rgCb[macInst].tmrTqCp, rgCb[macInst].tmrTq, (PFV) rgLMMTmrExpiry);
1974  
1975    RETVALUE(ROK);
1976  
1977 } /* end of rgActvTmr */
1978
1979 /**
1980  * @brief Layer Manager  Configuration request handler for Scheduler
1981  *
1982  * @details
1983  *
1984  *     Function : MacSchGenCfgReq
1985  *     
1986  *     This function receives general configurations for Scheduler
1987  *     from DU APP and forwards to Scheduler.
1988  *     
1989  *  @param[in]  Pst *pst, the post structure     
1990  *  @param[in]  RgMngmt *cfg, the configuration parameter's structure
1991  *  @return  S16
1992  *      -# ROK
1993  **/
1994 #ifdef ANSI
1995 PUBLIC int MacSchGenCfgReq
1996 (
1997 Pst      *pst,    /* post structure  */
1998 RgMngmt  *cfg     /* config structure  */
1999 )
2000 #else
2001 PUBLIC int MacSchGenCfgReq(pst, cfg)
2002 Pst      *pst;    /* post structure  */
2003 RgMngmt  *cfg;    /* config structure  */
2004 #endif    
2005 {
2006    printf("\nReceived Scheduler gen config at MAC");
2007    pst->dstInst = DEFAULT_CELLS + 1;
2008    HandleSchGenCfgReq(pst, cfg);
2009
2010    return ROK;
2011 }
2012
2013 /**
2014  * @brief Layer Manager Configuration response from Scheduler
2015  *
2016  * @details
2017  *
2018  *     Function : SchSendCfgCfm
2019  *     
2020  *     This function sends general configurations response from
2021  *     Scheduler to DU APP.
2022  *     
2023  *  @param[in]  Pst *pst, the post structure     
2024  *  @param[in]  RgMngmt *cfm, the configuration confirm structure
2025  *  @return  S16
2026  *      -# ROK
2027  **/
2028 #ifdef ANSI
2029 PUBLIC S16 SchSendCfgCfm 
2030 (
2031 Pst      *pst,    /* post structure  */
2032 RgMngmt  *cfm     /* config confirm structure  */
2033 )
2034 #else
2035 PUBLIC S16 SchSendCfgCfm(pst, cfm)
2036 Pst      *pst;    /* post structure  */
2037 RgMngmt  *cfm;    /* config confirm structure  */
2038 #endif    
2039 {
2040    printf("\nSending Scheduler config confirm to DU APP");
2041         pst->dstEnt = ENTDUAPP;
2042         pst->dstInst = 0;
2043         pst->srcInst = 0;
2044         pst->selector = MAC_SCH_LC_SELECTOR; 
2045    RgMiLrgSchCfgCfm(pst, cfm);
2046    
2047    RETVALUE(ROK);
2048 }
2049
2050 \f
2051 /***********************************************************
2052  *
2053  *     Func : macCellCfgFillCfmPst 
2054  *        
2055  *
2056  *     Desc : Fills the Confirmation Post Structure cfmPst 
2057  *
2058  *     Ret  : Void
2059  *
2060  *     Notes: 
2061  *
2062  *     File : rg_lmm.c 
2063  *
2064  **********************************************************/
2065 Void macCellCfgFillCfmPst
2066 (
2067 Pst           *reqPst,
2068 Pst           *cfmPst
2069 )
2070 {
2071    Inst inst;
2072    inst = reqPst->dstInst;
2073
2074    cfmPst->srcEnt    = rgCb[inst].rgInit.ent;
2075    cfmPst->srcInst   = rgCb[inst].rgInit.inst;
2076    cfmPst->srcProcId = rgCb[inst].rgInit.procId;
2077
2078    cfmPst->dstEnt    = ENTDUAPP;
2079    cfmPst->dstInst   = 0;
2080    cfmPst->dstProcId = cfmPst->srcProcId;
2081
2082    cfmPst->selector  = LRG_SEL_LC;
2083    cfmPst->prior     = reqPst->prior;
2084    cfmPst->route     = reqPst->route;
2085    cfmPst->region    = reqPst->region;
2086    cfmPst->pool      = reqPst->pool;
2087    cfmPst->event     = EVENT_MAC_CELL_CONFIG_CFM;
2088
2089    RETVOID;
2090 }
2091
2092 /**
2093  * @brief Layer Manager Configuration request handler. 
2094  *
2095  * @details
2096  *
2097  *     Function : MacHdlCellCfgReq 
2098  *     
2099  *     This function handles the gNB and cell configuration
2100  *     request received from DU APP.
2101  *     This API unapcks and forwards the config towards SCH
2102  *     
2103  *  @param[in]  Pst           *pst
2104  *  @param[in]  MacCellCfg    *macCellCfg 
2105  *  @return  S16
2106  *      -# ROK
2107  **/
2108 int MacHdlCellCfgReq
2109 (
2110  Pst           *pst,
2111  MacCellCfg    *macCellCfg
2112 )
2113 {
2114    Pst cfmPst;
2115    uint16_t ret = ROK;
2116    RgCellCb      *cellCb;
2117         MacCellCb     *macCellCb = NULLP;
2118    Inst inst = pst->dstInst;
2119
2120    cmMemset((U8 *)&cfmPst, 0, sizeof(Pst));
2121    MAC_ALLOC(cellCb,sizeof(RgCellCb));
2122
2123    if(cellCb == NULLP)
2124    {
2125       DU_LOG("\nMAC : cellCb is NULL at handling of macCellCfg\n");
2126       return RFAILED;
2127    }
2128
2129    memcpy(&cellCb->macCellCfg,macCellCfg,sizeof(MacCellCfg));
2130    rgCb[inst].cell = cellCb;
2131
2132    MAC_ALLOC(macCellCb,sizeof(MacCellCb));
2133         if(macCellCb == NULLP)
2134         {
2135       DU_LOG("\nMAC : macCellCb is NULL at handling of macCellCfg\n");
2136       return RFAILED;
2137    }
2138         memset(macCellCb, 0, sizeof(MacCellCb));
2139    macCb.macCell = macCellCb;
2140    macCb.macCell->cellId = macCellCfg->cellId;
2141    /* Send cell cfg to scheduler */
2142    ret = MacSchCellCfgReq(pst, macCellCfg);
2143         if(ret != ROK)
2144         {
2145                 MacCellCfgCfm macCellCfgCfm;
2146                 macCellCfgCfm.rsp = RSP_NOK;
2147                 macCellCfgCfm.transId = macCellCfg->transId;
2148                 macCellCfgFillCfmPst(pst,&cfmPst);
2149                 ret = (*packMacCellCfmOpts[cfmPst.selector])(&cfmPst,&macCellCfgCfm);
2150         }
2151 #ifdef INTEL_WLS
2152    LwrMacEnqueueWlsBlock();
2153 #endif
2154    return ret;
2155 } /* end of MacHdlCellCfgReq */
2156
2157 /**
2158  * @brief Layer Manager Configuration request handler. 
2159  *
2160  * @details
2161  *
2162  *     Function : MacSchCellCfgReq 
2163  *     
2164  *     This function sends cell configuration to SCH
2165  *     
2166  *  @param[in]  Pst           *pst
2167  *  @param[in]  MacCellCfg    *macCellCfg 
2168  *  @return  S16
2169  *      -# ROK
2170  **/
2171 int MacSchCellCfgReq
2172 (
2173  Pst           *pst,
2174  MacCellCfg    *macCellCfg
2175 )
2176 {
2177    SchCellCfg schCellCfg;
2178         Pst        cfgPst;
2179         int ret;
2180
2181    cmMemset((U8 *)&cfgPst, 0, sizeof(Pst));
2182         schCellCfg.cellId = macCellCfg->cellId;
2183         schCellCfg.phyCellId = macCellCfg->phyCellId;
2184         schCellCfg.bandwidth = macCellCfg->dlCarrCfg.bw;
2185         schCellCfg.dupMode = macCellCfg->dupType;
2186
2187         /* fill ssb scheduler parameters */
2188         schCellCfg.ssbSchCfg.ssbPbchPwr = macCellCfg->ssbCfg.ssbPbchPwr;
2189         schCellCfg.ssbSchCfg.scsCommon = macCellCfg->ssbCfg.scsCmn;
2190         schCellCfg.ssbSchCfg.ssbOffsetPointA = macCellCfg->ssbCfg.ssbOffsetPointA;
2191         schCellCfg.ssbSchCfg.ssbPeriod = macCellCfg->ssbCfg.ssbPeriod;
2192         schCellCfg.ssbSchCfg.ssbSubcOffset = macCellCfg->ssbCfg.ssbScOffset;
2193         for(uint8_t idx=0; idx<SSB_MASK_SIZE; idx++)
2194         {
2195       schCellCfg.ssbSchCfg.nSSBMask[idx] = macCellCfg->ssbCfg.ssbMask[idx]; 
2196         }
2197
2198         /* fill SIB1 scheduler parameters */
2199         schCellCfg.sib1SchCfg.sib1PduLen = macCellCfg->sib1Cfg.sib1PduLen; 
2200         schCellCfg.sib1SchCfg.sib1NewTxPeriod = macCellCfg->sib1Cfg.sib1NewTxPeriod; 
2201         schCellCfg.sib1SchCfg.sib1RepetitionPeriod = macCellCfg->sib1Cfg.sib1RepetitionPeriod; 
2202         schCellCfg.sib1SchCfg.coresetZeroIndex = macCellCfg->sib1Cfg.coresetZeroIndex; 
2203         schCellCfg.sib1SchCfg.searchSpaceZeroIndex = macCellCfg->sib1Cfg.searchSpaceZeroIndex; 
2204         schCellCfg.sib1SchCfg.sib1Mcs = macCellCfg->sib1Cfg.sib1Mcs; 
2205
2206         /* fill RACH config params */
2207         schCellCfg.schRachCfg.prachCfgIdx = macCellCfg->prachCfg.prachCfgIdx;
2208         schCellCfg.schRachCfg.prachSubcSpacing = \
2209            macCellCfg->prachCfg.prachSubcSpacing;
2210         schCellCfg.schRachCfg.msg1FreqStart = macCellCfg->prachCfg.msg1FreqStart;
2211         schCellCfg.schRachCfg.msg1Fdm       = macCellCfg->prachCfg.msg1Fdm;
2212         schCellCfg.schRachCfg.rootSeqLen    = macCellCfg->prachCfg.rootSeqLen;
2213         schCellCfg.schRachCfg.rootSeqIdx    = macCellCfg->prachCfg.fdm[0].rootSeqIdx;
2214         schCellCfg.schRachCfg.numRootSeq    = macCellCfg->prachCfg.fdm[0].numRootSeq;
2215         schCellCfg.schRachCfg.k1            = macCellCfg->prachCfg.fdm[0].k1;
2216         schCellCfg.schRachCfg.ssbPerRach    = macCellCfg->prachCfg.ssbPerRach;
2217         schCellCfg.schRachCfg.prachMultCarrBand = \
2218            macCellCfg->prachCfg.prachMultCarrBand;
2219         schCellCfg.schRachCfg.raContResTmr  = macCellCfg->prachCfg.raContResTmr;
2220         schCellCfg.schRachCfg.rsrpThreshSsb = macCellCfg->prachCfg.rsrpThreshSsb;
2221         schCellCfg.schRachCfg.raRspWindow   = macCellCfg->prachCfg.raRspWindow;
2222
2223    /* fill initial DL BWP */
2224         schCellCfg.schInitialDlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialDlBwp.bwp.firstPrb;
2225         schCellCfg.schInitialDlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialDlBwp.bwp.numPrb;
2226    schCellCfg.schInitialDlBwp.bwp.scs = macCellCfg->initialDlBwp.bwp.scs;
2227    schCellCfg.schInitialDlBwp.bwp.cyclicPrefix = macCellCfg->initialDlBwp.bwp.cyclicPrefix;
2228    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId =
2229            macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId;
2230    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId =
2231       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
2232    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
2233       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot;
2234    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.duration =
2235       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.duration;
2236    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
2237       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol;
2238    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1 =
2239       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel1;
2240    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2 =
2241       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel2;
2242    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4 =
2243       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel4;
2244    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8 =
2245       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel8;
2246    schCellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16 =
2247       macCellCfg->initialDlBwp.pdcchCommon.commonSearchSpace.candidate.aggLevel16;
2248    schCellCfg.schInitialDlBwp.pdschCommon.k0 = macCellCfg->initialDlBwp.pdschCommon.k0;
2249    schCellCfg.schInitialDlBwp.pdschCommon.mappingType =
2250       macCellCfg->initialDlBwp.pdschCommon.mappingType;
2251    schCellCfg.schInitialDlBwp.pdschCommon.startSymbol =
2252       macCellCfg->initialDlBwp.pdschCommon.startSymbol;
2253    schCellCfg.schInitialDlBwp.pdschCommon.lengthSymbol =
2254       macCellCfg->initialDlBwp.pdschCommon.lengthSymbol;
2255
2256    /* fill initial UL BWP */
2257         schCellCfg.schInitialUlBwp.bwp.freqAlloc.startPrb = macCellCfg->initialUlBwp.bwp.firstPrb;
2258         schCellCfg.schInitialUlBwp.bwp.freqAlloc.numPrb = macCellCfg->initialUlBwp.bwp.numPrb;
2259    schCellCfg.schInitialUlBwp.bwp.scs = macCellCfg->initialUlBwp.bwp.scs;
2260    schCellCfg.schInitialUlBwp.bwp.cyclicPrefix = macCellCfg->initialUlBwp.bwp.cyclicPrefix;
2261    schCellCfg.schInitialUlBwp.puschCommon.k2 = macCellCfg->initialUlBwp.puschCommon.k2;
2262    schCellCfg.schInitialUlBwp.puschCommon.mappingType =
2263       macCellCfg->initialUlBwp.puschCommon.mappingType;
2264    schCellCfg.schInitialUlBwp.puschCommon.startSymbol =
2265       macCellCfg->initialUlBwp.puschCommon.startSymbol;
2266    schCellCfg.schInitialUlBwp.puschCommon.lengthSymbol =
2267       macCellCfg->initialUlBwp.puschCommon.lengthSymbol;
2268
2269
2270    cfgPst.srcProcId = pst->dstProcId;
2271         cfgPst.dstProcId = pst->srcProcId;
2272         cfgPst.srcEnt    = ENTRG;
2273         cfgPst.srcInst   = 0;
2274         cfgPst.dstEnt    = ENTRG;
2275         cfgPst.dstInst   = 1;
2276         cfgPst.selector  = MAC_SCH_TC_SELECTOR;
2277         cfgPst.event     = EVENT_SCH_CELL_CFG;
2278
2279         ret = (*SchCellCfgOpts[cfgPst.selector])(&cfgPst, &schCellCfg);
2280         return ret;
2281 } /* end of MacSchCellCfgReq */
2282
2283
2284 /*******************************************************************
2285  *
2286  * @brief Sends Cell config confirm to DU APP
2287  *
2288  * @details
2289  *
2290  *    Function : MacSendCellCfgCfm 
2291  *
2292  *    Functionality:
2293  *      Sends Cell config confirm to DU APP
2294  *
2295  * @params[in] Response status
2296  * @return void
2297  *
2298  * ****************************************************************/
2299 void MacSendCellCfgCfm(uint8_t response)
2300 {
2301    Pst pst;
2302    RgCellCb      *cellCb;
2303    MacCellCfgCfm macCellCfgCfm;
2304  
2305    cmMemset((U8 *)&pst, 0, sizeof(Pst));
2306    cellCb = rgCb[macCb.macInst].cell;
2307  
2308    macCellCfgCfm.transId = cellCb->macCellCfg.transId;
2309    macCellCfgCfm.rsp = response;
2310
2311    memcpy((void *)&pst, (void *)&rgCb[macCb.macInst].rgInit.lmPst, sizeof(Pst));
2312    pst.event = EVENT_MAC_CELL_CONFIG_CFM;
2313    (*packMacCellCfmOpts[pst.selector])(&pst,&macCellCfgCfm);
2314 }
2315
2316
2317 /**
2318  * @brief Layer Manager Configuration response handler. 
2319  *
2320  * @details
2321  *
2322  *     Function : MacProcSchCellCfgCfm
2323  *     
2324  *     This function processes cell configuration to SCH
2325  *     
2326  *  @param[in]  Pst           *pst
2327  *  @param[in]  SchCellCfgCfm *schCellCfgCfm
2328  *  @return  int
2329  *      -# ROK
2330  **/
2331 int MacProcSchCellCfgCfm 
2332 (
2333  Pst           *pst,
2334  SchCellCfgCfm *schCellCfgCfm
2335 )
2336 {
2337         if(schCellCfgCfm->rsp == RSP_OK)
2338         {
2339       sendToLowerMac(CONFIG_REQUEST, 0, (void *)NULL);
2340         }
2341         else
2342         {
2343       MacSendCellCfgCfm(RSP_NOK);
2344         }
2345    return ROK;  
2346 }
2347
2348 /**********************************************************************
2349  
2350          End of file
2351 **********************************************************************/