042c89d2c52c5f57f5e499b48c8461de20809e7b
[o-du/l2.git] / src / 5gnrmac / mac_slot_ind.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 /* header include files (.h) */
19 #include "common_def.h"
20 #include "lrg.h"
21 #include "lrg.x"
22 #include "du_app_mac_inf.h"
23 #include "mac_sch_interface.h"
24 #include "lwr_mac_upr_inf.h"
25 #include "rlc_mac_inf.h"
26 #include "mac.h"
27 #include "mac_upr_inf_api.h"
28 #include "lwr_mac.h"
29 #include "lwr_mac_fsm.h"
30 #include "mac_utils.h"
31 #include "mac_harq_dl.h"
32 #include "lwr_mac_phy.h"
33
34 /**
35  * @brief process DL allocation from scheduler
36  *
37  * @details
38  *
39  *     Function : MacProcDlAlloc 
40  *      
41  *      This function copied dl sch info in the mac slot info
42  *           
43  *  @param[in]  Pst            *pst
44  *  @param[in]  DL allocation from scheduler
45  *  @return
46  *      -# ROK 
47  *      -# RFAILED 
48  **/
49 uint8_t MacProcDlAlloc(Pst *pst, DlSchedInfo *dlSchedInfo)
50 {
51    uint8_t   schInfoIdx = 0, cwIdx = 0;
52    uint8_t   ueId = 0, ueIdx = 0;
53    uint16_t  cellIdx = 0;
54    uint8_t   *retxTb = NULLP, *txPdu = NULLP;
55    uint16_t  txPduLen = 0;
56    MacDlSlot      *currDlSlot = NULLP;
57    DlMsgSchInfo   schedInfo;
58    DlHarqProcCb   *hqProcCb = NULLP;
59
60 #ifdef CALL_FLOW_DEBUG_LOG
61    DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_DL_SCH_INFO\n");
62 #endif
63    if(dlSchedInfo != NULLP)
64    {
65       GET_CELL_IDX(dlSchedInfo->cellId, cellIdx);
66       if(dlSchedInfo->isBroadcastPres)
67       {
68          currDlSlot = &macCb.macCell[cellIdx]->\
69                       dlSlot[dlSchedInfo->schSlotValue.broadcastTime.slot];
70          currDlSlot->dlInfo.isBroadcastPres = true;
71          memcpy(&currDlSlot->dlInfo.brdcstAlloc, &dlSchedInfo->brdcstAlloc, sizeof(DlBrdcstAlloc));
72       }
73
74       for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
75       {
76          if(dlSchedInfo->rarAlloc[ueIdx] != NULLP)
77          {
78             currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlSchedInfo->schSlotValue.rarTime.slot];
79             currDlSlot->dlInfo.rarAlloc[ueIdx] = dlSchedInfo->rarAlloc[ueIdx];
80
81             /* MUXing of RAR */
82             fillRarPdu(&currDlSlot->dlInfo.rarAlloc[ueIdx]->rarInfo);
83          }
84
85          if(dlSchedInfo->dlMsgAlloc[ueIdx] != NULLP)
86          {
87             currDlSlot = &macCb.macCell[cellIdx]->\
88                          dlSlot[dlSchedInfo->schSlotValue.dlMsgTime.slot];
89             currDlSlot->dlInfo.dlMsgAlloc[ueIdx] = dlSchedInfo->dlMsgAlloc[ueIdx]; /* copy msg4 alloc pointer in MAC slot info */
90             currDlSlot->dlInfo.cellId = dlSchedInfo->cellId;
91
92             /* Check if the downlink pdu is msg4 */
93             for(schInfoIdx=0; schInfoIdx < dlSchedInfo->dlMsgAlloc[ueIdx]->numSchedInfo; schInfoIdx++)
94             {
95                if(dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.isMsg4Pdu)
96                {
97                   GET_UE_ID(dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.crnti, ueId);
98                   ueIdx = ueId -1;
99                   schedInfo = dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx];
100                   hqProcCb = &macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4HqInfo;
101
102                   if(!dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].isRetx)
103                   {
104                      /* First transmission of MSG4 */
105                      hqProcCb->procId = schedInfo.dlMsgInfo.harqProcNum;
106                      for(cwIdx = 0; cwIdx < schedInfo.dlMsgPdschCfg.numCodewords; cwIdx++)
107                      {
108                         memcpy(&hqProcCb->tbInfo[hqProcCb->numTb].txTime, &dlSchedInfo->schSlotValue.dlMsgTime, \
109                               sizeof(SlotTimingInfo));
110                         hqProcCb->tbInfo[hqProcCb->numTb].tbSize = schedInfo.dlMsgPdschCfg.codeword[cwIdx].tbSize;
111                         hqProcCb->numTb++;
112                      }
113                   }
114                   else
115                   {
116                      /* MSG4 retransmission */
117                      if(hqProcCb->procId == schedInfo.dlMsgInfo.harqProcNum)
118                      {
119                         memcpy(&hqProcCb->tbInfo[0].txTime, &dlSchedInfo->schSlotValue.dlMsgTime, \
120                                                      sizeof(SlotTimingInfo));
121                      }
122                   }
123                }
124                else
125                {
126                   memcpy(&currDlSlot->dlInfo.schSlotValue, &dlSchedInfo->schSlotValue, sizeof(SchSlotValue));
127                   
128                   if(!dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].isRetx)
129                   {
130                      /* If new data transmission is scheduled, send schedule results to RLC */
131                      if((dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == PDSCH_PDU) ||
132                            (dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == BOTH))
133                      {
134                         sendSchedRptToRlc(currDlSlot->dlInfo, dlSchedInfo->schSlotValue.dlMsgTime, ueIdx, schInfoIdx);
135
136                         /* Add HARQ Proc to DL HARQ Proc Entity in UE */
137                         addDlHqProcInUe(currDlSlot->dlInfo.schSlotValue.dlMsgTime, &macCb.macCell[cellIdx]->ueCb[ueIdx], \
138                            dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx]);
139                      }
140                   }
141                   else
142                   {
143                      /* For retransmission, fetch PDU to be retransmitted from DL HARQ entity and schedule on corresponding slot */
144                      
145                      /* As of now this loop will run only once for one TB. 
146                       * TODO : update handling of fetched TB appropriately when support for two TB is added 
147                       */
148                      for(cwIdx = 0; \
149                            cwIdx < dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgPdschCfg.numCodewords;\
150                            cwIdx++)
151                      {
152                         /* Fetch TB to be retransmitted */
153                         txPduLen = dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgPdschCfg.codeword[cwIdx].tbSize;
154                         retxTb = fetchTbfromDlHarqProc(currDlSlot->dlInfo.schSlotValue.dlMsgTime, \
155                               &macCb.macCell[cellIdx]->ueCb[ueIdx], \
156                               dlSchedInfo->dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.harqProcNum, txPduLen);
157
158                         /* Store PDU in corresponding DL slot */
159                         MAC_ALLOC(txPdu, txPduLen);
160                         if(!txPdu)
161                         {
162                            DU_LOG("\nERROR  -->  MAC : Memory allocation failed in MacProcDlAlloc");
163                            return RFAILED;
164                         }   
165                         memcpy(txPdu, retxTb,  txPduLen);
166
167                         currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPduLen = txPduLen;
168                         currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.dlMsgPdu = txPdu;
169                      }
170                   }
171                }
172             }
173          }
174       }
175
176       if(dlSchedInfo->ulGrant != NULLP)
177       {
178          currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlSchedInfo->schSlotValue.ulDciTime.slot];
179          currDlSlot->dlInfo.ulGrant = dlSchedInfo->ulGrant;
180       }
181    }
182    return ROK;
183 }
184
185 /**
186  * @brief process DL Paging allocation from scheduler
187  *
188  * @details
189  *
190  *     Function : MacProcDlPageAlloc 
191  *      
192  *      This function copied dl Pag info in the mac slot info
193  *           
194  *  @param[in]  Pst            *pst
195  *  @param[in]  DL Paging allocation from scheduler
196  *  @return
197  *      -# ROK 
198  *      -# RFAILED 
199  **/
200 uint8_t MacProcDlPageAlloc(Pst *pst, DlPageAlloc *dlPageAlloc)
201 {
202    uint16_t  cellIdx = 0;
203    MacDlSlot *currDlSlot = NULLP;
204
205 #ifdef CALL_FLOW_DEBUG_LOG
206    DU_LOG("\nCall Flow: ENTSCH -> ENTMAC : EVENT_DL_PAGING_ALLOC\n");
207 #endif
208    if(dlPageAlloc != NULLP)
209    {
210       GET_CELL_IDX(dlPageAlloc->cellId, cellIdx);
211
212       currDlSlot = &macCb.macCell[cellIdx]->dlSlot[dlPageAlloc->dlPageTime.slot];
213       MAC_ALLOC(currDlSlot->pageAllocInfo, sizeof(DlPageAlloc));
214       if(currDlSlot->pageAllocInfo == NULLP)
215       {
216          DU_LOG("\nERROR  --> MAC : MacProcDlPageAlloc : Memory Allocation is failed!");
217          return RFAILED;
218       }
219       memcpy(currDlSlot->pageAllocInfo, dlPageAlloc, sizeof(DlPageAlloc));
220    }
221    else
222    {
223       DU_LOG("\nERROR  --> MAC : DL Paging Allocation is failed!");
224       return RFAILED;
225    }
226    return ROK;
227 }
228
229 /**
230  * @brief Forming and filling the MUX Pdu
231  * @details
232  *
233  *     Function : fillMsg4Pdu
234  * 
235  *      Forming and filling of Msg4Pdu
236  *           
237  *  @param[in]  DlMsgAlloc  *msg4Alloc
238  *  @return  void
239  **/
240 void fillMsg4Pdu(uint16_t cellId, DlMsgSchInfo *msg4SchInfo)
241 {
242    uint8_t   ueId = 0, ueIdx = 0;
243    uint16_t  cellIdx;
244    uint16_t  msg4TxPduLen;
245    MacDlData msg4DlData;
246    MacCeInfo  macCeData;
247    DlHarqProcCb *hqProcCb;
248
249    GET_CELL_IDX(cellId, cellIdx);
250
251    memset(&msg4DlData, 0, sizeof(MacDlData));
252    memset(&macCeData, 0, sizeof(MacCeInfo));
253
254    GET_UE_ID(msg4SchInfo->dlMsgInfo.crnti, ueId);
255    ueIdx = ueId -1;
256
257    if(macCb.macCell[cellIdx] == NULLP)
258    {
259       DU_LOG("\nERROR -->  MAC: Cell Id[%d] not found", cellId);
260       return;
261    }
262
263    hqProcCb = &macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4HqInfo;
264    msg4TxPduLen = hqProcCb->tbInfo[0].tbSize - TX_PAYLOAD_HDR_LEN;
265
266    if(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu != NULLP)
267    {
268       MAC_ALLOC(msg4DlData.pduInfo[msg4DlData.numPdu].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
269       if(msg4DlData.pduInfo[msg4DlData.numPdu].dlPdu != NULLP)
270       {
271          fillMsg4DlData(&msg4DlData, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen, \
272             macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu);
273          fillMacCe(&macCeData, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg3Pdu);
274
275          /* Forming Mux Pdu */
276          hqProcCb->tbInfo[0].tb = NULLP;
277          MAC_ALLOC(hqProcCb->tbInfo[0].tb, msg4TxPduLen);
278          if(hqProcCb->tbInfo[0].tb != NULLP)
279          {
280             memset(hqProcCb->tbInfo[0].tb, 0, msg4TxPduLen);
281             macMuxPdu(&msg4DlData, &macCeData, hqProcCb->tbInfo[0].tb, msg4TxPduLen);
282          }
283          else
284          {
285             DU_LOG("\nERROR  -->  MAC: Failed allocating memory for msg4TxPdu");
286          }
287          /* Free memory allocated */
288          MAC_FREE(msg4DlData.pduInfo[msg4DlData.numPdu-1].dlPdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
289          MAC_FREE(macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu, macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen);
290          macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4Pdu = NULLP;
291          macCb.macCell[cellIdx]->macRaCb[ueIdx].msg4PduLen = 0;
292          msg4DlData.numPdu--;
293
294       }
295    }
296
297    /* storing msg4 Pdu in macDlSlot */
298    if(hqProcCb->tbInfo[0].tb)
299    {
300       msg4SchInfo->dlMsgInfo.dlMsgPduLen = msg4TxPduLen;
301       MAC_ALLOC(msg4SchInfo->dlMsgInfo.dlMsgPdu, msg4SchInfo->dlMsgInfo.dlMsgPduLen);
302       if(msg4SchInfo->dlMsgInfo.dlMsgPdu != NULLP)
303       {
304          memcpy(msg4SchInfo->dlMsgInfo.dlMsgPdu, hqProcCb->tbInfo[0].tb, \
305                msg4SchInfo->dlMsgInfo.dlMsgPduLen);
306       }
307    }
308    else
309    {
310       DU_LOG("\nERROR  -->  MAC: Failed at fillMsg4Pdu()");
311    }
312 }
313
314 /**
315  * @brief Builds and Send the Muxed Pdu to Lower MAC
316  *
317  * @details
318  *
319  *     Function : buildAndSendMuxPdu
320  * 
321  *      Build and Sends the Muxed Pdu to Lower MAC.
322  *           
323  *  @param[in]  SlotTimingInfo    *slotInd
324  *  @return  void
325  **/
326
327 void buildAndSendMuxPdu(SlotTimingInfo currTimingInfo)
328 {
329    uint8_t   ueIdx;
330    uint8_t   schInfoIdx;
331    uint16_t  cellIdx;
332    MacDlSlot *currDlSlot = NULLP;
333    SlotTimingInfo muxTimingInfo;
334    memset(&muxTimingInfo, 0, sizeof(SlotTimingInfo));
335
336    GET_CELL_IDX(currTimingInfo.cellId, cellIdx);
337
338    ADD_DELTA_TO_TIME(currTimingInfo, muxTimingInfo, PHY_DELTA_DL, macCb.macCell[cellIdx]->numOfSlots);
339    currDlSlot = &macCb.macCell[cellIdx]->dlSlot[muxTimingInfo.slot];
340
341    for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
342    {
343       if(currDlSlot->dlInfo.dlMsgAlloc[ueIdx])
344       {
345          for(schInfoIdx=0; schInfoIdx<currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->numSchedInfo; schInfoIdx++)
346          {
347             if((currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].dlMsgInfo.isMsg4Pdu) &&
348                   ((currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == PDSCH_PDU) ||
349                    (currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx].pduPres == BOTH)))
350             {
351                fillMsg4Pdu(currTimingInfo.cellId, &currDlSlot->dlInfo.dlMsgAlloc[ueIdx]->dlMsgSchedInfo[schInfoIdx]);
352             }
353          }
354       }
355    }
356 }
357
358 /**
359  * @brief Transmission time interval indication from PHY.
360  *
361  * @details
362  *
363  *     Function : sendSlotIndMacToSch
364  * 
365  *      This API is invoked by MAC to send slot ind to scheduler.
366  *           
367  *  @param[in]  SlotTimingInfo    *slotInd
368  *  @return  
369  *      -# ROK 
370  *      -# RFAILED 
371  **/
372 int sendSlotIndMacToSch(SlotTimingInfo *slotInd)
373 {
374    /* fill Pst structure to send to lwr_mac to MAC */
375    Pst pst;
376
377    FILL_PST_MAC_TO_SCH(pst, EVENT_SLOT_IND_TO_SCH);
378    return(SchMessageRouter(&pst, (void *)slotInd));
379 }
380
381 /*******************************************************************
382  *
383  * @brief Send cell up indication to DU APP
384  *
385  * @details
386  *
387  *    Function : sendCellUpIndMacToDuApp
388  *
389  *    Functionality:
390  *       Send cell up indication to DU APP
391  *
392  * @params[in] Cell Up indication info 
393  * @return ROK     - success
394  *         RFAILED - failure
395  *
396  * ****************************************************************/
397 int sendCellUpIndMacToDuApp(uint16_t cellId)
398 {
399    Pst pst;
400    uint16_t ret;
401    OduCellId *oduCellId;
402
403    /*  Allocate sharable memory */
404    MAC_ALLOC_SHRABL_BUF(oduCellId, sizeof(OduCellId));
405    if(!oduCellId)
406    {
407       DU_LOG("\nERROR  -->  MAC : Memory allocation failed for cell up indication");
408       return RFAILED;
409    }
410    oduCellId->cellId = cellId;
411
412    /* Fill Pst */
413    FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_CELL_UP_IND);
414
415    ret = MacDuAppCellUpInd(&pst, oduCellId);
416    if(ret != ROK)
417    {
418       DU_LOG("\nERROR  -->  MAC: Failed to send cell up indication to DU APP");
419       MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, oduCellId, sizeof(OduCellId));
420    }
421
422    return ret;
423 } /* sendCellUpIndMacToDuApp */
424
425 /*******************************************************************
426  *
427  * @brief Send slot indication to DU APP
428  *
429  * @details
430  *
431  *    Function : sendSlotIndToDuApp
432  *
433  *    Functionality:
434  *       Send cell up indication to DU APP
435  *
436  * @params[in] Cell Up indication info 
437  * @return ROK     - success
438  *         RFAILED - failure
439  *
440  * ****************************************************************/
441 uint8_t sendSlotIndToDuApp(SlotTimingInfo *slotInd)
442 {
443    Pst pst;
444    uint16_t ret;
445    SlotTimingInfo *slotIndInfo;
446
447    /*  Allocate sharable memory */
448    MAC_ALLOC_SHRABL_BUF(slotIndInfo, sizeof(SlotTimingInfo));
449    if(!slotIndInfo)
450    {
451       DU_LOG("\nERROR  -->  MAC : Memory allocation failed for slot indication");
452       return RFAILED;
453    }
454    memcpy(slotIndInfo, slotInd,sizeof(SlotTimingInfo));
455
456    /* Fill Pst */
457    FILL_PST_MAC_TO_DUAPP(pst, EVENT_MAC_SLOT_IND);
458
459    ret = MacDuAppSlotInd(&pst, slotIndInfo);
460    if(ret != ROK)
461    {
462       DU_LOG("\nERROR  -->  MAC: Failed to send slot up indication to DU APP");
463       MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, slotIndInfo, sizeof(SlotTimingInfo));
464    }
465
466    return ret;
467 }
468 /*******************************************************************
469  *
470  * @brief Process slot indication at MAC
471  *
472  * @details
473  *
474  *    Function : macProcSlotInd
475  *
476  *    Functionality: Process slot indication at MAC
477  *
478  * @params[in] Slot indication info
479  * @return ROK     - success
480  *         RFAILED - failure
481  *
482  * ****************************************************************/
483 uint8_t macProcSlotInd(SlotTimingInfo slotInd)
484 {
485    uint16_t  cellIdx = 0;
486
487    GET_CELL_IDX(slotInd.cellId, cellIdx);
488    
489    if(macCb.macCell[cellIdx] == NULLP)
490    {
491       DU_LOG("ERROR  --> MAC : macProcSlotInd(): CellId[%d] does not exist. Error occurred at SFN [%d] Slot [%d]",\
492       slotInd.cellId, slotInd.sfn, slotInd.slot);
493       return RFAILED;
494    }
495    /* Store current time info */
496    macCb.macCell[cellIdx]->currTime.cellId = slotInd.cellId;
497    macCb.macCell[cellIdx]->currTime.slot = slotInd.slot;
498    macCb.macCell[cellIdx]->currTime.sfn = slotInd.sfn;
499
500    /* Mux Pdu for Msg4 */
501    buildAndSendMuxPdu(slotInd);
502
503    /* Trigger for DL TTI REQ */
504    fillDlTtiReq(slotInd);
505
506    return ROK;
507 }  /* macProcSlotInd */
508
509 /**
510  * @brief Transmission time interval indication from PHY.
511  *
512  * @details
513  *
514  *     Function : fapiMacSlotInd 
515  *      
516  *      This API is invoked by PHY to indicate TTI indication to MAC for a cell.
517  *           
518  *  @param[in]  Pst            *pst
519  *  @param[in]  SuId           suId 
520  *  @param[in]  SlotTimingInfo    *slotInd
521  *  @return  
522  *      -# ROK 
523  *      -# RFAILED 
524  **/
525 uint8_t fapiMacSlotInd(Pst *pst, SlotTimingInfo *slotInd)
526 {
527    uint8_t               ret = ROK;
528    uint16_t              cellIdx;
529    volatile uint32_t     startTime=0;
530
531 #ifdef ODU_SLOT_IND_DEBUG_LOG
532    DU_LOG("\nDEBUG  -->  MAC : Slot Indication received. [%d : %d]", slotInd->sfn, slotInd->slot);
533 #endif
534    /*starting Task*/
535    ODU_START_TASK(&startTime, PID_MAC_TTI_IND);
536    gSlotCount++;
537
538    if(gSlotCount == 1)
539    {
540            GET_CELL_IDX(slotInd->cellId, cellIdx);
541            macCb.macCell[cellIdx]->state = CELL_STATE_UP;
542    }
543
544 /* When testing L2 with Intel-L1, any changes specific to 
545  * timer mode testing must be guarded under INTEL_TIMER_MODE*/
546 #ifndef INTEL_TIMER_MODE
547    /* send slot indication to scheduler */
548    ret = sendSlotIndMacToSch(slotInd);
549    if(ret != ROK)
550    {
551       DU_LOG("\nERROR  -->  MAC : Sending of slot ind msg from MAC to SCH failed");
552       MAC_FREE_SHRABL_BUF(pst->region, pst->pool, slotInd, sizeof(SlotTimingInfo));
553       return ret;
554    }
555
556    ret = macProcSlotInd(*slotInd);
557    if(ret != ROK)
558    {
559       DU_LOG("\nERROR  -->  MAC : macProcSlotInd failed");
560       MAC_FREE_SHRABL_BUF(pst->region, pst->pool, slotInd, sizeof(SlotTimingInfo));
561       return ret;
562    }
563 #endif
564
565    /*First Slot Ind is for CellUp. Any other Slot, will be notified to DUAPP as
566     * SLOT_IND*/
567    if(gSlotCount == 1)   
568    {
569       /* send cell up indication to du app */
570       ret = sendCellUpIndMacToDuApp(slotInd->cellId);
571
572    }
573    else
574    {
575       /* send slot indication to du app */
576       ret = sendSlotIndToDuApp(slotInd);
577    }
578    
579    if(ret != ROK)
580    {
581       DU_LOG("\nERROR  -->  MAC :Sending of slot ind msg from MAC to DU APP failed");
582       MAC_FREE_SHRABL_BUF(pst->region, pst->pool, slotInd, sizeof(SlotTimingInfo));
583       return ret;
584    }
585
586    /*stoping Task*/
587    ODU_STOP_TASK(startTime, PID_MAC_TTI_IND);
588    MAC_FREE_SHRABL_BUF(pst->region, pst->pool, slotInd, sizeof(SlotTimingInfo));
589
590 #ifdef INTEL_WLS_MEM
591    lwrMacCb.phySlotIndCntr++;
592    if(lwrMacCb.phySlotIndCntr > WLS_MEM_FREE_PRD)
593    {
594       lwrMacCb.phySlotIndCntr = 1;
595    }
596    freeWlsBlockList(lwrMacCb.phySlotIndCntr - 1);
597 #endif
598
599    return ret;
600 }  /* fapiMacSlotInd */
601
602 /**********************************************************************
603   End of file
604  **********************************************************************/
605