FAPI code enclosed under FAPI flag
[o-du/l2.git] / src / 5gnrmac / lwr_mac_handle_phy.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 /* header include files (.h) */
20 #include "envopt.h"        /* environment options */
21 #include "envdep.h"        /* environment dependent */
22 #include "envind.h"        /* environment independent */
23 #include "gen.h"           /* general */
24 #include "ssi.h"           /* system services */
25 #include "cm_tkns.h"       /* Common Token Defines */
26 #include "cm_llist.h"      /* Common Link List Defines */
27 #include "cm_hash.h"       /* Common Hash List Defines */
28 #include "cm_lte.h"        /* Common LTE Defines */
29 #include "cm_mblk.h"        /* Common LTE Defines */
30 #include "tfu.h"           /* RGU Interface defines */
31 //#include "rg.h"
32 #ifdef FAPI
33 #include "fapi.h"
34 #endif
35
36 /* header/extern include files (.x) */
37 #include "gen.x"           /* general */
38 #include "ssi.x"           /* system services */
39 #include "cm_tkns.x"       /* Common Token Definitions */
40 #include "cm_llist.x"      /* Common Link List Definitions */
41 #include "cm_lib.x"        /* Common Library Definitions */
42 #include "cm_hash.x"       /* Common Hash List Definitions */
43 #include "cm_lte.x"        /* Common LTE Defines */
44 #include "cm_mblk.x"        /* Common LTE Defines */
45 #include "tfu.x"           /* RGU Interface includes */
46 //#include "rg.x"
47
48 #ifdef FAPI
49 /* function pointers for packing macCellCfg Request */
50 typedef S16 (*packSlotIndMsg) ARGS((
51    Pst           *pst,
52    fapi_slot_ind_t *slotInd
53 ));
54
55 S16 packLcSlotInd (Pst *pst, SlotIndInfo *slotInd);
56 S16 packTcSlotInd (Pst *pst, fapi_slot_ind_t *slotInd);
57 S16 packLwlcSlotInd (Pst *pst, fapi_slot_ind_t *slotInd);
58
59 packSlotIndMsg packSlotIndOpts[] =
60 {
61    packLcSlotInd, /* packing for loosely coupled */
62    fapiMacSlotInd, /* packing for tightly coupled */
63    packLwlcSlotInd, /* packing for light weight loosly coupled */
64 };
65
66 S16 packLcSlotInd (Pst *pst, SlotIndInfo *slotInd)
67 {
68    Buffer *mBuf = NULLP;
69    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
70    {
71       RETVALUE(RFAILED);
72    }
73
74    /* pack SFN and slot value */
75    CMCHKPK(SPkU16,slotInd->sfn, mBuf);
76    CMCHKPK(SPkU16,slotInd->slot, mBuf);
77
78    RETVALUE(SPstTsk(pst,mBuf));
79 }
80
81 S16 packTcSlotInd (Pst *pst, fapi_slot_ind_t *slotInd)
82 {
83    return ROK;
84 }
85
86 S16 packLwlcSlotInd (Pst *pst, fapi_slot_ind_t *slotInd)
87 {
88    return ROK;
89 }
90
91 U16 handleSlotInd(fapi_slot_ind_t *fapiSlotInd)
92 {
93    /* fill Pst structure to send to lwr_mac to MAC */
94    Pst pst;
95    SlotIndInfo slotInd;
96
97    pst.srcProcId = 0;
98    pst.dstProcId = 0;
99    pst.srcEnt = ENTTF;
100    pst.dstEnt = ENTRG;
101    pst.srcInst = 0;
102    pst.dstInst = 0;
103    pst.event = EVENT_SLOT_IND_TO_MAC;
104    pst.region = 0;
105    pst.pool =  0;
106    pst.selector = MAC_SELECTOR_TC;
107
108    slotInd.sfn = fapiSlotInd->sfn;
109    slotInd.slot = fapiSlotInd->slot;
110
111    return (*packSlotIndOpts[pst.selector])(&pst, &slotInd);
112 }
113 #endif
114
115 void handlePhyMessages(void *msg)
116 {
117 #ifdef FAPI
118    /* extract the header */
119    fapi_msg_t *header;
120    header = (fapi_msg_t *)msg;
121
122    switch(header->message_type_id)
123    {
124       case FAPI_SLOT_INDICATION:
125       {
126          fapi_slot_ind_t *slotInd;
127          slotInd  = (fapi_slot_ind_t *)msg;
128          handleSlotInd(slotInd);
129          break;
130       }
131       case FAPI_ERROR_INDICATION:
132       {
133          break;
134       }
135       case FAPI_RX_DATA_INDICATION:
136       {
137          break;
138       }  
139       case FAPI_CRC_INDICATION:
140       {
141          break;
142       }  
143       case FAPI_UCI_INDICATION:
144       {
145          break;
146       }  
147       case FAPI_SRS_INDICATION:
148       {
149          break;
150       }  
151       case FAPI_RACH_INDICATION:
152       {
153          break;
154       }  
155    }
156 #endif
157 }
158
159 /**********************************************************************
160          End of file
161 **********************************************************************/