RARandSib1Transmission
[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 "envopt.h"        /* environment options */
20 #include "envdep.h"        /* environment dependent */
21 #include "envind.h"        /* environment independent */
22 #include "gen.h"           /* general */
23 #include "ssi.h"           /* system services */
24 #include "cm_tkns.h"       /* Common Token Defines */
25 #include "cm_llist.h"      /* Common Link List Defines */
26 #include "cm_hash.h"       /* Common Hash List Defines */
27 #include "cm_mblk.h"       /* common memory link list library */
28 #include "cm_lte.h"        /* Common LTE Defines */
29 #include "tfu.h"           /* RGU Interface includes */
30 #include "lrg.h"
31 #include "gen.x"           /* general */
32 #include "ssi.x"           /* system services */
33 #include "cm5.x"           /* system services */
34 #include "cm_tkns.x"       /* Common Token Definitions */
35 #include "cm_llist.x"      /* Common Link List Definitions */
36 #include "cm_lib.x"        /* Common Library Definitions */
37 #include "cm_hash.x"       /* Common Hash List Definitions */
38 #include "cm_mblk.x"       /* common memory link list library */
39 #include "cm_lte.x"        /* Common LTE Defines */
40 #include "tfu.x"           /* RGU Interface includes */
41 #include "lrg.x"
42 #include "du_app_mac_inf.h"
43 #include "mac.h"
44 #include "du_log.h"
45
46 /**
47  * @brief process DL allocation from scheduler
48  *
49  * @details
50  *
51  *     Function : MacProcDlAlloc 
52  *      
53  *      This function copied dl sch info in the mac slot info
54  *           
55  *  @param[in]  Pst            *pst
56  *  @param[in]  DL allocation from scheduler
57  *  @return  S16
58  *      -# ROK 
59  *      -# RFAILED 
60  **/
61 int MacProcDlAlloc(Pst *pst, DlAlloc *dlAlloc)
62 {
63    if(dlAlloc != NULLP)
64    {
65                 MacDlSlot *currDlSlot =
66                 &macCb.macCell->dlSlot[dlAlloc->slotIndInfo.slot % MAX_SLOT_SUPPORTED];
67       memcpy(&currDlSlot->dlInfo, dlAlloc, sizeof(DlAlloc)); 
68    }
69    return ROK;
70 }
71
72 /**
73  * @brief Transmission time interval indication from PHY.
74  *
75  * @details
76  *
77  *     Function : fapiMacSlotInd 
78  *      
79  *      This API is invoked by PHY to indicate TTI indication to MAC for a cell.
80  *           
81  *  @param[in]  Pst            *pst
82  *  @param[in]  SuId           suId 
83  *  @param[in]  SlotIndInfo    *slotInd
84  *  @return  S16
85  *      -# ROK 
86  *      -# RFAILED 
87  **/
88 PUBLIC S16 fapiMacSlotInd 
89 (
90 Pst                 *pst, 
91 SlotIndInfo         *slotInd
92 )
93 {
94    S16              ret;
95    VOLATILE U32     startTime=0;
96    Inst             inst;
97
98    DU_LOG("\nMAC : Slot Indication received");
99    
100    inst = pst->dstInst;
101    /*starting Task*/
102    SStartTask(&startTime, PID_MAC_TTI_IND);
103
104    /* send slot indication to scheduler */
105    ret = sendSlotIndMacToSch(slotInd);
106    if(ret != ROK)
107    {
108       DU_LOG("\nMAC : Sending of slot ind msg from MAC to SCH failed");
109       RETVALUE(ret);
110    }
111
112    ret = macProcessSlotInd(inst,*slotInd);
113    if(ret != ROK)
114    {
115       DU_LOG("\nMAC : macProcessSlotInd failed");
116       RETVALUE(ret);
117    }
118
119    /* send slot indication to du app */
120    ret = sendSlotIndMacToDuApp(slotInd);
121    if(ret != ROK)
122    {
123       DU_LOG("\nMAC :Sending of slot ind msg from MAC to DU APP failed");
124       RETVALUE(ret);
125    }
126
127    /*stoping Task*/
128    SStopTask(startTime, PID_MAC_TTI_IND);
129
130    RETVALUE(ret);
131 }  /* fapiMacSlotInd */
132
133 /**********************************************************************
134   End of file
135  **********************************************************************/
136