WLS code changes at Lower Mac - PHY inteface
[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 #ifdef FAPI
32 #include "fapi.h"
33 #endif
34
35 /* header/extern include files (.x) */
36 #include "gen.x"           /* general */
37 #include "ssi.x"           /* system services */
38 #include "cm_tkns.x"       /* Common Token Definitions */
39 #include "cm_llist.x"      /* Common Link List Definitions */
40 #include "cm_lib.x"        /* Common Library Definitions */
41 #include "cm_hash.x"       /* Common Hash List Definitions */
42 #include "cm_lte.x"        /* Common LTE Defines */
43 #include "cm_mblk.x"        /* Common LTE Defines */
44 #include "tfu.x"           /* RGU Interface includes */
45 #include "du_log.h"
46 #include "lwr_mac_fsm.h"
47 #include "lwr_mac_phy.h"
48
49 #ifdef FAPI
50
51 /* function pointers for packing macCellCfg Request */
52 typedef S16 (*packSlotIndMsg) ARGS((
53    Pst           *pst,
54    SlotIndInfo   *slotInd
55 ));
56
57 S16 packLcSlotInd (Pst *pst, SlotIndInfo *slotInd);
58 S16 packTcSlotInd (Pst *pst, SlotIndInfo *slotInd);
59 S16 packLwlcSlotInd (Pst *pst, SlotIndInfo *slotInd);
60
61 packSlotIndMsg packSlotIndOpts[] =
62 {
63    packLcSlotInd, /* packing for loosely coupled */
64    fapiMacSlotInd, /* packing for tightly coupled */
65    packLwlcSlotInd, /* packing for light weight loosly coupled */
66 };
67
68 S16 packLcSlotInd (Pst *pst, SlotIndInfo *slotInd)
69 {
70    Buffer *mBuf = NULLP;
71    if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) 
72    {
73       RETVALUE(RFAILED);
74    }
75
76    /* pack SFN and slot value */
77    CMCHKPK(SPkU16,slotInd->sfn, mBuf);
78    CMCHKPK(SPkU16,slotInd->slot, mBuf);
79
80    RETVALUE(SPstTsk(pst,mBuf));
81 }
82
83 S16 packTcSlotInd (Pst *pst, SlotIndInfo *slotInd)
84 {
85    return ROK;
86 }
87
88 S16 packLwlcSlotInd (Pst *pst, SlotIndInfo *slotInd)
89 {
90    return ROK;
91 }
92
93 U16 handleSlotInd(fapi_slot_ind_t *fapiSlotInd)
94 {
95    /* fill Pst structure to send to lwr_mac to MAC */
96    Pst pst;
97    uint16_t ret;
98    SlotIndInfo slotInd;
99
100    pst.srcProcId = 0;
101    pst.dstProcId = 0;
102    pst.srcEnt = ENTTF;
103    pst.dstEnt = ENTRG;
104    pst.srcInst = 0;
105    pst.dstInst = 0;
106    pst.event = EVENT_SLOT_IND_TO_MAC;
107    pst.region = 0;
108    pst.pool =  0;
109    pst.selector = MAC_SELECTOR_TC;
110
111    slotInd.sfn = fapiSlotInd->sfn;
112    slotInd.slot = fapiSlotInd->slot;
113
114    ret = (*packSlotIndOpts[pst.selector])(&pst, &slotInd);
115
116 #ifdef INTEL_WLS
117    slotIndIdx++;
118    if(slotIndIdx > WLS_MEM_FREE_PRD)
119    {
120       slotIndIdx = 1;
121    }
122    freeWlsBlockList(slotIndIdx - 1);
123 #endif
124
125    return ret;
126 }
127 #endif
128
129 void handlePhyMessages(uint16_t msgType, uint32_t msgSize, void *msg)
130 {
131 #ifdef FAPI
132    /* extract the header */
133    fapi_msg_t *header;
134    header = (fapi_msg_t *)msg;
135
136    switch(header->message_type_id)
137    {
138       case FAPI_PARAM_RESPONSE:
139       case FAPI_CONFIG_RESPONSE:
140       {
141          sendToLowerMac(msgType, msgSize, msg);
142          break;
143       }
144       case FAPI_SLOT_INDICATION:
145       {
146          if(clGlobalCp.phyState == PHY_STATE_CONFIGURED)
147          {
148             DU_LOG("\nLOWER MAC: PHY has moved to running state \n");
149             clGlobalCp.phyState = PHY_STATE_RUNNING;
150          }
151
152          fapi_slot_ind_t *slotInd;
153          slotInd  = (fapi_slot_ind_t *)msg;
154          handleSlotInd(slotInd);
155          break;
156       }
157       case FAPI_ERROR_INDICATION:
158       {
159          break;
160       }
161       case FAPI_RX_DATA_INDICATION:
162       {
163          break;
164       }  
165       case FAPI_CRC_INDICATION:
166       {
167          break;
168       }  
169       case FAPI_UCI_INDICATION:
170       {
171          break;
172       }  
173       case FAPI_SRS_INDICATION:
174       {
175          break;
176       }  
177       case FAPI_RACH_INDICATION:
178       {
179          break;
180       }  
181    }
182 #ifdef INTEL_WLS
183    WLS_MEM_FREE(msg, LWR_MAC_WLS_BUF_SIZE); 
184 #endif
185 #endif
186 }
187
188 /**********************************************************************
189          End of file
190 **********************************************************************/