Rach Indication
[o-du/l2.git] / src / 5gnrmac / rg_lim.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 Entry point fucntions
26   
27      File:     rg_lim.c 
28   
29 **********************************************************************/
30
31 /** @file rg_lim.c.
32 @brief It has APIs exposed by Lower Interface Modulue of MAC. It acts as an 
33 Interface handler for lower interface APIs.
34 */
35 static const char* RLOG_MODULE_NAME="MAC";
36 static int RLOG_FILE_ID=182;
37 static int RLOG_MODULE_ID=4096;
38 /* header include files -- defines (.h) */
39 #include "envopt.h"        /* environment options */
40 #include "envdep.h"        /* environment dependent */
41 #include "envind.h"        /* environment independent */
42 #include "gen.h"           /* general layer */
43 #include "ssi.h"           /* system services */
44 #include "cm5.h"           /* common timers defines */
45 #include "cm_hash.h"       /* common hash list defines */
46 #include "cm_llist.h"      /* common linked list defines */
47 #include "cm_mblk.h"       /* memory management */
48 #include "cm_tkns.h"       /* common tokens */
49 #include "cm_lte.h"       /* common tokens */
50 #include "rgu.h"           /* RGU defines */
51 #include "tfu.h"           /* RGU defines */
52 #include "lrg.h"           /* layer management defines for LTE-MAC */
53 #include "crg.h"           /* layer management defines for LTE-MAC */
54 #include "rg_sch_inf.h"           /* layer management defines for LTE-MAC */
55 #include "rg_env.h"        /* customisable defines and macros for MAC */
56 #include "rg.h"            /* defines and macros for MAC */
57 #include "du_log.h"
58
59 /* header/extern include files (.x) */
60 #include "gen.x"           /* general layer typedefs */
61 #include "ssi.x"           /* system services typedefs */
62 #include "cm5.x"           /* common timers */
63 #include "cm_hash.x"       /* common hash list */
64 #include "cm_lib.x"        /* common library */
65 #include "cm_llist.x"      /* common linked list */
66 #include "cm_mblk.x"       /* memory management */
67 #include "cm_tkns.x"       /* common tokens */
68 #include "cm_lte.x"       /* common tokens */
69 #include "rgu.x"           /* RGU types */
70 #include "tfu.x"           /* RGU types */
71 #include "lrg.x"           /* layer management typedefs for MAC */
72 #include "crg.x"           /* layer management typedefs for MAC */
73 #include "rg_sch_inf.x"    /* SCH interface typedefs */
74 #include "rg_prg.x"    /* PRG interface typedefs */
75 #include "du_app_mac_inf.h"
76 #include "rg.x"            /* typedefs for MAC */
77
78 #include "mac_upr_inf_api.h"
79 #include "mac.h"
80
81 /* local externs */
82 #ifdef UNUSED_FUNC
83 PRIVATE S16  rgLIMValidateSap ARGS((Inst inst,SuId suId));
84 #endif
85 PRIVATE Void rgLIMUtlFreeDatIndEvnt ARGS((TfuDatIndInfo *datInd,
86                                           Bool error));
87
88 /* function pointers for packing slot ind from mac to sch */
89 //S16 packMacSchSlotInd(Pst *pst, SlotIndInfo *slotInd);
90
91 MacSchSlotIndFunc macSchSlotIndOpts[] =
92 {
93    packMacSchSlotInd,  
94    macSchSlotInd,                                             
95    packMacSchSlotInd
96 }; 
97
98 #ifdef RG_UNUSED
99 PRIVATE Void rgLIMUtlFreeDatReqEvnt ARGS((TfuDatReqInfo *datReq,
100                                           Bool error));
101 #endif
102 /* forward references */
103
104 /**
105  * @brief This API is invoked to send TFU SAP bind request to PHY.
106  *
107  * @details
108  *
109  *     Function : rgLIMTfuBndReq
110  *      
111  *      This API is invoked to send TFU SAP bind request to PHY. It fills in 
112  *      the Pst structure, spId and suId values and invokes bind request
113  *      primitive at TFU.
114  *           
115  *  @param[in]  Inst        inst
116  *  @param[in]  SuId            suId 
117  *  @param[in]  SpId            spId
118  *  @return  S16
119  *      -# ROK 
120  *      -# RFAILED 
121  **/
122 #ifdef ANSI
123 PUBLIC S16 rgLIMTfuBndReq
124 (
125 Inst    inst,
126 SuId    suId, 
127 SpId    spId
128 )
129 #else
130 PUBLIC S16 rgLIMTfuBndReq(inst,suId, spId)
131 Inst    inst;
132 SuId    suId; 
133 SpId    spId;
134 #endif
135 {
136    S16         ret;
137    RgLowSapCb  *tfuSap;
138    Pst         pst;
139
140    TRC2(rgLIMTfuBndReq);
141
142    /* Get the lower SAP control block from the layer control block. */
143    tfuSap = &(rgCb[inst].tfuSap);
144    (Void)cmMemcpy ((U8*)&pst, (U8*)&(tfuSap->sapCfg.sapPst), sizeof(Pst));
145    if((ret = RgLiTfuBndReq (&pst, suId, spId)) != ROK)
146    {
147       RLOG0(L_ERROR,"Call to RgLiTfuBndReq() failed");
148    }
149    RETVALUE(ret);
150 }  /* rgLIMTfuBndReq */
151
152
153 /**
154  * @brief This API is invoked to send TFU SAP unbind request to PHY.
155  *
156  * @details
157  *
158  *     Function : rgLIMTfuBndReq
159  *      
160  *      This API is invoked to send TFU SAP unbind request to PHY. It fills in 
161  *      the Pst structure and spId value and invokes unbind request
162  *      primitive at TFU.
163  *           
164  *  @param[in]  Inst        inst
165  *  @param[in]  SpId            spId
166  *  @param[in]  Reason          reason 
167  *  @return  S16
168  *      -# ROK 
169  *      -# RFAILED 
170  **/
171 #ifdef ANSI
172 PUBLIC S16 rgLIMTfuUbndReq
173 (
174 Inst    inst,
175 SpId    spId, 
176 Reason  reason
177 )
178 #else
179 PUBLIC S16 rgLIMTfuUbndReq(inst,spId, reason)
180 Inst    inst;
181 SpId    spId; 
182 Reason  reason;
183 #endif
184 {
185    S16         ret;
186    RgLowSapCb  *tfuSap;
187    Pst         pst;
188
189    TRC2(rgLIMTfuUbndReq);
190
191    /* Get the lower SAP control block from the layer control block. */
192    tfuSap = &(rgCb[inst].tfuSap);
193    cmMemcpy ((U8*)&pst, (U8*)&(tfuSap->sapCfg.sapPst), sizeof(Pst));
194    if((ret = RgLiTfuUbndReq (&pst, tfuSap->sapCfg.spId, reason)) != ROK)
195    {
196       RLOG0(L_ERROR,"Call to RgLiTfuUbndReq() failed");
197    }
198    RETVALUE(ret);
199
200 }  /* rgLIMTfuUbndReq */
201
202
203 /**
204  * @brief Bind confirm API for TFU SAP 
205  *
206  * @details
207  *
208  *     Function : RgLiTfuBndCfm
209  *      
210  *      This API is invoked by PHY to confirm TFU SAP bind. 
211  *     
212  *           
213  *  @param[in]  Pst   *pst 
214  *  @param[in]  SuId  suId 
215  *  @param[in]  U8    status
216  *  @return  S16
217  *      -# ROK 
218  *      -# RFAILED 
219  **/
220 #ifdef ANSI
221 PUBLIC S16 RgLiTfuBndCfm 
222 (
223 Pst     *pst,
224 SuId    suId, 
225 U8      status
226 )
227 #else
228 PUBLIC S16 RgLiTfuBndCfm(pst, suId, status)
229 Pst     *pst; 
230 SuId    suId; 
231 U8      status;
232 #endif
233 {
234    Inst inst;
235    S16 ret;
236    RgLowSapCb  *tfuSap;
237
238    TRC3(RgLiTfuBndCfm);
239
240
241    RG_IS_INST_VALID(pst->dstInst);
242    inst = pst->dstInst - RG_INST_START;
243    /* Lets validate suId first */
244    /* CA_Change */
245    tfuSap = &(rgCb[inst].tfuSap);
246
247    if (suId != tfuSap->sapCfg.suId)
248    {
249       RLOG2(L_ERROR,"Incorrect SuId. Configured (%d) Recieved (%d)",
250             tfuSap->sapCfg.suId, suId);
251       RETVALUE(RFAILED);
252    }
253    ret = rgLMMBndCfm (pst, suId, status);
254    RETVALUE(ret);
255 }  /* RgLiTfuBndCfm */
256
257  /** @brief This function Validates the SAP information received along with the
258   * primitive from the lower layer. 
259   * Function:
260   *   Validates SAP information.
261  *  @param[in]  Inst        inst
262   * @param  suId The SAP Id
263   * @return 
264   *   -# ROK
265   *   -# RFAILED
266   */
267 #ifdef UNUSED_FUNC
268 #ifdef ANSI
269 PRIVATE S16 rgLIMValidateSap
270 (
271  Inst    inst,
272  SuId    suId
273 )
274 #else
275 PRIVATE S16 rgLIMValidateSap(inst,suId)
276  Inst    inst;
277  SuId    suId;
278 #endif
279 {
280    RgLowSapCb  *tfuSap;
281
282    TRC2(rgLIMValidateSap)
283
284    tfuSap = &(rgCb[inst].tfuSap);
285
286    /* First lets check the suId */
287    if( suId != tfuSap->sapCfg.suId)
288    {
289       RLOG2(L_ERROR,"Incorrect SuId. Configured (%d) Recieved (%d)",
290             tfuSap->sapCfg.suId, suId);
291       RETVALUE(RFAILED);
292    }
293    if (tfuSap->sapSta.sapState != LRG_BND)
294    {
295       RLOG1(L_ERROR,"Lower SAP not enabled SuId (%d)",
296             tfuSap->sapCfg.suId);
297       RETVALUE(RFAILED);
298    }
299    RETVALUE(ROK);
300 } /* end of rgLIMValidateSap */
301 #endif
302 /** @brief This function frees up the TfuDatIndInfo structure
303  *
304  * @details
305  *
306  *     Function: rgLIMUtlFreeDatIndEvnt 
307  *       - Function frees up the TfuDatIndInfo structure, in case of error it shall
308  *       free up the buffer's present in the datIndLst.
309  *
310  *         Processing steps:
311  * @param  [in] TfuDatIndInfo *datInd
312  * @param  [in] Bool          *error
313  * @return 
314  */
315 #ifdef ANSI
316 PRIVATE Void rgLIMUtlFreeDatIndEvnt 
317 (
318  TfuDatIndInfo *datInd,
319  Bool          error
320  )
321 #else
322 PRIVATE Void rgLIMUtlFreeDatIndEvnt(datInd, error)
323  TfuDatIndInfo *datInd;
324  Bool          error;
325 #endif
326 {
327
328    TfuDatInfo     *datInfo;
329    CmLList        *node;
330
331    TRC2(rgLIMUtlFreeDatIndEvnt);
332    /* Steps of freeing up the TfuDatInd.
333     * 1. loop through the datIndLst and free up all the buffers.
334     * 2. free up the whole event
335     */
336    if ((error == TRUE) && (datInd->datIndLst.count > 0))
337    {
338       node =  datInd->datIndLst.first;
339       while (node)
340       {
341          datInfo = (TfuDatInfo*)node->node;
342          RG_FREE_MSG(datInfo->mBuf);
343          node = node->next;
344       }
345    }
346    RG_FREE_MEM(datInd);
347    RETVOID;
348 } /* end of rgLIMUtlFreeDatIndEvnt*/
349
350 /**
351  * @brief Downlink data indication from PHY.
352  *
353  * @details
354  *
355  *     Function : RgLiTfuDatInd
356  *      
357  *      This API is invoked by PHY to send data indication to MAC on 
358  *      recieving data from UEs.
359  *           
360  *  @param[in]  Pst              *pst
361  *  @param[in]  SuId             suId 
362  *  @param[in]  TfuDatIndInfo    *datInd
363  *  @return  S16
364  *      -# ROK 
365  *      -# RFAILED 
366  **/
367 #ifdef ANSI
368 PUBLIC S16 RgLiTfuDatInd
369 (
370 Pst                *pst, 
371 SuId               suId, 
372 TfuDatIndInfo    *datInd
373 )
374 #else
375 PUBLIC S16 RgLiTfuDatInd(pst, suId, datInd)
376 Pst                *pst; 
377 SuId               suId; 
378 TfuDatIndInfo    *datInd;
379 #endif
380 {
381    Inst             inst;
382    S16              ret;
383    VOLATILE U32     startTime=0;
384
385    TRC3(RgLiTfuDatInd);
386
387   // printf("5GTF:: DatindRcvd\n");
388
389    RG_IS_INST_VALID(pst->dstInst);
390    inst = pst->dstInst - RG_INST_START;
391    /*starting Task*/
392    SStartTask(&startTime, PID_MAC_TFU_DATIND);
393
394 #ifndef NO_ERRCLS 
395    if ((ret = rgLIMValidateSap (inst,suId)) != ROK)
396    {
397       RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"SAP Validation failed");
398       rgLIMUtlFreeDatIndEvnt(datInd, TRUE);
399       RETVALUE(ret);
400    }
401 #endif
402    /* Now call the TOM (Tfu ownership module) primitive to process further */
403    rgCb[inst].tfuSap.sapSts.numPduRcvd += 
404                     datInd->datIndLst.count;
405    ret = rgTOMDatInd(inst,datInd);
406    /* Fix: sriky memory corruption precautions */
407    /* Free up the memory for the request structure */
408    if (ret == ROK)
409    {
410       rgLIMUtlFreeDatIndEvnt(datInd, FALSE);
411    }
412    else
413    {
414       rgLIMUtlFreeDatIndEvnt(datInd, TRUE);
415    }
416
417    /*stoping Task*/
418    SStopTask(startTime, PID_MAC_TFU_DATIND);
419
420    RETVALUE(ret);
421 }  /* RgLiTfuDatInd*/
422
423 #ifdef RG_UNUSED
424 /** @brief This function frees up the TfuDatReqInfo structure.
425  *
426  * @details
427  *
428  *     Function: rgLIMUtlFreeDatReqEvnt
429  *       - Function frees up the TfuDatReqInfo structure, in case of error it shall
430  *       free up the buffer's present in the PDUs list.
431  *
432  *         Processing steps:
433  * @param  [in] TfuDatReqInfo *datReq
434  * @param  [in] Bool          *error
435  * @return 
436  */
437 #ifdef ANSI
438 PRIVATE Void rgLIMUtlFreeDatReqEvnt
439 (
440  TfuDatReqInfo *datReq,
441  Bool          error
442  )
443 #else
444 PRIVATE Void rgLIMUtlFreeDatReqEvnt(datReq, error)
445  TfuDatReqInfo *datReq;
446  Bool          error;
447 #endif
448 {
449
450    TfuDatReqPduInfo *datInfo;
451    CmLList          *node;
452    U8               i;
453
454    TRC2(rgLIMUtlFreeDatReqEvnt);
455    /* Steps of freeing up the TfuDatReq.
456     * 1. Free the bch buffer.
457     * 2. loop through the pdus list and free up all the buffers.
458     * 3. free up the whole event
459     */
460    if (error)
461    {
462       if (datReq->bchDat.pres == PRSNT_NODEF)
463       {
464          RG_FREE_MSG(datReq->bchDat.val);
465       }
466       if (datReq->pdus.count > 0)
467       {
468          node =  datReq->pdus.first;
469          while (node)
470          {
471             datInfo = (TfuDatReqPduInfo*)node->node;
472             for (i=0; i<datInfo->nmbOfTBs; i++)
473             {
474                if (datInfo->mBuf[i] != NULLP)
475                {
476                   RG_FREE_MSG(datInfo->mBuf[i]);
477                }
478             }
479             node = node->next;
480          }
481       }
482    }
483    RG_FREE_MEM(datReq);
484    RETVOID;
485 } /* end of rgLIMUtlFreeDatReqEvnt*/
486 #endif
487 /**
488  * @brief This API is invoked to send Data to PHY.
489  *
490  * @details
491  *
492  *     Function : rgLIMTfuDatReq
493  *      
494  *      This API is invoked to send Data to PHY. It 
495  *      fills in the Pst structure, spId value and invokes Data
496  *      request primitive at TFU.
497  *           
498  *  @param[in]  Inst        inst
499  *  @param[in]  TfuDatReqInfo *datReq
500  *  @return  S16
501  *      -# ROK 
502  *      -# RFAILED 
503  **/
504 #ifdef ANSI
505 PUBLIC S16 rgLIMTfuDatReq 
506 (
507 Inst          inst,
508 TfuDatReqInfo *datReq
509 )
510 #else
511 PUBLIC S16 rgLIMTfuDatReq(inst,datReq)
512 Inst          inst;
513 TfuDatReqInfo *datReq;
514 #endif
515 {
516    S16         ret;
517    RgLowSapCb  *tfuSap;
518
519    TRC2(rgLIMTfuDatReq)
520
521    /* Get the lower SAP control block from the layer control block. */
522    tfuSap = &(rgCb[inst].tfuSap);
523
524 #ifndef NO_ERRCLS
525    if (tfuSap->sapSta.sapState != LRG_BND)
526    {
527       RLOG_ARG1(L_ERROR,DBG_CELLID,datReq->cellId,"Lower SAP not bound (%d)",
528             tfuSap->sapSta.sapState);
529 #ifdef RG_UNUSED
530       /* This case will never be hit if sap is not bound then we dont get TTI */
531       rgLIMUtlFreeDatReqEvnt(datReq, TRUE);
532 #endif
533       RETVALUE(RFAILED);
534    }
535 #endif
536
537    tfuSap->sapSts.numPduTxmit += datReq->pdus.count; 
538
539    /* Using existing pst - for optimization */
540    if((ret = RgLiTfuDatReq (&tfuSap->sapCfg.sapPst, tfuSap->sapCfg.spId, 
541                             datReq)) != ROK)
542    {
543       RLOG_ARG0(L_ERROR,DBG_CELLID,datReq->cellId,"Call to RgLiTfuDatReq() failed");
544    }
545    RETVALUE(ret);
546 }  /* rgLIMTfuDatReq*/
547
548 #ifdef L2_OPTMZ
549 /**
550  * @brief This API is invoked to send Data to PHY.
551  *
552  * @details
553  *
554  *     Function : rgLIMTfuDelDatReq
555  *      
556  *      This API is invoked to send Data to PHY. It 
557  *      fills in the Pst structure, spId value and invokes Data
558  *      request primitive at TFU.
559  *           
560  *  @param[in]  Inst        inst
561  *  @param[in]  TfuDelDatReqInfo *datReq
562  *  @return  S16
563  *      -# ROK 
564  *      -# RFAILED 
565  **/
566 #ifdef ANSI
567 PUBLIC S16 rgLIMTfuDelDatReq 
568 (
569 Inst          inst,
570 TfuDelDatReqInfo *delDatReq
571 )
572 #else
573 PUBLIC S16 rgLIMTfuDatReq(inst,delDatReq)
574 Inst          inst;
575 TfuDelDatReqInfo *delDatReq;
576 #endif
577 {
578    S16         ret;
579    RgLowSapCb  *tfuSap;
580
581    TRC2(rgLIMTfuDelDatReq)
582
583    /* Get the lower SAP control block from the layer control block. */
584    tfuSap = &(rgCb[inst].tfuSap);
585
586 #ifndef NO_ERRCLS
587    if (tfuSap->sapSta.sapState != LRG_BND)
588    {
589       RLOG_ARG1(L_ERROR,DBG_CELLID,delDatReq->cellId,"Lower SAP not bound (%d)",
590             tfuSap->sapSta.sapState);
591       RETVALUE(RFAILED);
592    }
593 #endif
594
595    if((ret = RgLiTfuDelDatReq (&tfuSap->sapCfg.sapPst, tfuSap->sapCfg.spId, 
596                             delDatReq)) != ROK)
597    {
598       RLOG_ARG0(L_ERROR,DBG_CELLID,delDatReq->cellId,"Call to RgLiTfuDelDatReq() failed");
599    }
600    RETVALUE(ret);
601 }  /* rgLIMTfuDatReq*/
602 #endif /*L2_OPTMZ */
603
604 /*******************************************************************
605  *
606  * @brief Fills post structure
607  *
608  * @details
609  *
610  *    Function : fillMacToSchPst
611  *
612  *    Functionality:
613  *      Fills post structure to be used when sending msg from 
614  *      MAC to SCH
615  *
616  * @params[in] Post structure pointer 
617  * @return ROK     - success
618  *         RFAILED - failure
619  *
620  * ****************************************************************/
621 void fillMacToSchPst(Pst *pst)
622 {
623    pst->srcProcId = 0;
624    pst->dstProcId = 0;
625    pst->srcEnt = ENTRG;
626    pst->dstEnt = ENTRG;
627    pst->srcInst = 0;
628    pst->dstInst = 1;
629    pst->region = 0;
630    pst->pool =  0;
631    pst->selector = MAC_SELECTOR_TC;
632 }
633
634 /*******************************************************************
635  *
636  * @brief MAC handler for config response from PHY
637  *
638  * @details
639  *
640  *    Function : fapiMacConfigRsp
641  *
642  *    Functionality:
643  *     Processes config response from PHY and sends cell config
644  *     confirm to DU APP
645  *
646  * @params[in] 
647  * @return void
648  *
649  * ****************************************************************/
650 void fapiMacConfigRsp()
651 {
652    /* TODO : Processing of config response from PHY */
653
654    /* Send cell config cfm to DU APP */
655    MacSendCellCfgCfm(RSP_OK);
656 }
657
658 /**
659  * @brief Transmission time interval indication from PHY.
660  *
661  * @details
662  *
663  *     Function : sendSlotIndMacToSch
664  * 
665  *      This API is invoked by MAC to send slot ind to scheduler.
666  *           
667  *  @param[in]  SlotIndInfo    *slotInd
668  *  @return  S16
669  *      -# ROK 
670  *      -# RFAILED 
671  **/
672 int sendSlotIndMacToSch(SlotIndInfo *slotInd)
673 {
674    /* fill Pst structure to send to lwr_mac to MAC */
675    Pst pst;
676
677    fillMacToSchPst(&pst);
678    pst.event = EVENT_SLOT_IND_TO_SCH;
679
680    return(*macSchSlotIndOpts[pst.selector])(&pst,slotInd);
681 }
682
683
684 /*******************************************************************
685  *
686  * @brief Send slot indication to DU APP
687  *
688  * @details
689  *
690  *    Function : sendSlotIndMacToDuApp
691  *
692  *    Functionality:
693  *       Send slot indication to DU APP
694  *
695  * @params[in] Slot indication info 
696  * @return ROK     - success
697  *         RFAILED - failure
698  *
699  * ****************************************************************/
700 int sendSlotIndMacToDuApp(SlotIndInfo *slotInd)
701 {
702    Pst pst;
703    SlotInfo  *slotInfo;
704   
705    /* Send Slot Indication to DU APP */
706    MAC_ALLOC(slotInfo, sizeof(SlotInfo));
707    if(!slotInfo)
708    {
709       DU_LOG("\nMAC : Slot Indication memory allocation failed");
710       return RFAILED;
711    }
712
713    slotInfo->cellId = macCb.macCell->cellId;
714    slotInfo->sfn = slotInd->sfn;
715    slotInfo->slot = slotInd->slot;
716
717    /* Fill Pst */
718    pst.selector  = DU_MAC_LWLC;
719    pst.srcEnt    = ENTRG;
720    pst.dstEnt    = ENTDUAPP;
721    pst.dstInst   = 0;
722    pst.srcInst   = macCb.macInst;
723    pst.dstProcId = rgCb[pst.srcInst].rgInit.procId;
724    pst.srcProcId = rgCb[pst.srcInst].rgInit.procId;
725    pst.region = MAC_MEM_REGION;
726    pst.pool = MAC_POOL;
727    pst.event = EVENT_MAC_SLOT_IND;
728    pst.route = 0;
729    pst.prior = 0;
730    pst.intfVer = 0;
731  
732    return MacDuAppSlotInd(&pst, slotInfo);
733   
734 }
735
736 /**
737  * @brief Transmission time interval indication from PHY.
738  *
739  * @details
740  *
741  *     Function : fapiMacSlotInd 
742  *      
743  *      This API is invoked by PHY to indicate TTI indication to MAC for a cell.
744  *           
745  *  @param[in]  Pst            *pst
746  *  @param[in]  SuId           suId 
747  *  @param[in]  SlotIndInfo    *slotInd
748  *  @return  S16
749  *      -# ROK 
750  *      -# RFAILED 
751  **/
752 PUBLIC S16 fapiMacSlotInd 
753 (
754 Pst                 *pst, 
755 SlotIndInfo         *slotInd
756 )
757 {
758    S16              ret;
759    VOLATILE U32     startTime=0;
760    Inst             inst;
761
762    DU_LOG("\nMAC : Slot Indication received");
763    
764    RG_IS_INST_VALID(pst->dstInst);
765    inst = pst->dstInst - RG_INST_START;
766    /*starting Task*/
767    SStartTask(&startTime, PID_MAC_TTI_IND);
768
769    /* send slot indication to scheduler */
770    ret = sendSlotIndMacToSch(slotInd);
771    if(ret != ROK)
772    {
773       DU_LOG("\nMAC : Sending of slot ind msg from MAC to SCH failed");
774       RETVALUE(ret);
775    }
776
777    /* Now call the TOM (Tfu ownership module) primitive to process further */
778    ret = macProcessSlotInd(inst,*slotInd);
779    if(ret != ROK)
780    {
781       DU_LOG("\nMAC : macProcessSlotInd failed");
782       RETVALUE(ret);
783    }
784
785    /* send slot indication to du app */
786    ret = sendSlotIndMacToDuApp(slotInd);
787    if(ret != ROK)
788    {
789       DU_LOG("\nMAC :Sending of slot ind msg from MAC to DU APP failed");
790       RETVALUE(ret);
791    }
792
793    /*stoping Task*/
794    SStopTask(startTime, PID_MAC_TTI_IND);
795
796    RETVALUE(ret);
797 }  /* fapiMacSlotInd */
798
799 #if defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
800  /**
801  * @brief Transmission of non-rt indication from CL.
802  *
803  * @details
804  *
805  *     Function : RgLiTfuNonRtInd 
806  *      
807  *      This API is invoked by CL to indicate non-rt processing indication to MAC for a cell.
808  *           
809  *  @param[in]  Pst            *pst
810  *  @param[in]  SuId           suId 
811  *  @return  S16
812  *      -# ROK 
813  *      -# RFAILED 
814  **/
815 #ifdef ANSI
816 PUBLIC S16 RgLiTfuNonRtInd
817 (
818 Pst                 *pst,
819 SuId                suId
820 )
821 #else
822 PUBLIC S16 RgLiTfuNonRtInd(pst, suId)
823 Pst                 *pst;
824 SuId                suId;
825 #endif
826 {
827    TRC3(RgLiTfuNonRtInd);
828
829 #ifdef NO_ERRCLS
830    if (rgLIMValidateSap (pst->dstInst - RG_INST_START, suId) != ROK)
831    {
832       RGDBGERRNEW(pst->dstInst - RG_INST_START, (rgPBuf(pst->dstInst - RG_INST_START),"RgLiTfuNonRtInd() SAP Validation failed.\n"));
833       RETVALUE(RFAILED);
834    }
835 #endif
836    rgDHMFreeTbBufs(pst->dstInst - RG_INST_START);
837    RETVALUE(ROK);
838 }  /* RgLiTfuNonRtInd */
839
840 #endif
841 /**********************************************************************
842  
843          End of file
844 **********************************************************************/