Added code for MAC-PHY interface, DU_APP, F1AP, SCTP and CU stub
[o-du/l2.git] / src / phy_stub / l1_bdy1.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 /*This file contains stub for PHY to handle messages to/from MAC CL */ 
20
21 #include "envdep.h"
22 #include "gen.h"
23 #include "ssi.h"
24
25 #include "gen.x"
26 #include "ssi.x"
27
28 #include "rg_cl_phy.h"
29
30 EXTERN void phyToMac ARGS((U16 msgType, U32 msgLen,void *msg));
31
32 /*******************************************************************
33  *
34  * @brief Builds and sends config response to MAC CL
35  *
36  * @details
37  *
38  *    Function : l1BldAndSndCfgRsp
39  *
40  *    Functionality:
41  *          - Builds and sends config response to MAC
42  *
43  * @params[in] Config request message pointer
44  * @return ROK     - success
45  *         RFAILED - failure
46  *
47  * ****************************************************************/
48
49 S16 l1BldAndSndCfgRsp(void *msg)
50 {
51    L1L2ConfigReq *FAPIConfigReq;
52    L1L2ConfigRsp *FAPIConfigRsp;
53    U8 cci;
54
55    FAPIConfigReq = (L1L2ConfigReq *)msg;
56    cci = FAPIConfigReq->carrierId;
57    SPutSBuf(0, 0, (Data *)msg, FAPIConfigReq->hdr.msgLen);
58
59    if(SGetSBuf(0, 0, (Data **)&FAPIConfigRsp, sizeof(L1L2ConfigRsp)) != ROK)
60    {
61        printf("\nMemory allocation failed for PHY Config Response");
62        RETVALUE(RFAILED);
63    }
64    
65    FAPIConfigRsp->hdr.nMsg = 1;
66    FAPIConfigRsp->hdr.msgType = MSG_TYPE_CONFIG_RSP;
67    FAPIConfigRsp->hdr.msgLen = sizeof(L1L2ConfigRsp);
68
69    FAPIConfigRsp->carrierId = cci;
70    FAPIConfigRsp->status = MSG_OK;
71    FAPIConfigRsp->numUnsuppTlv = 0;
72    FAPIConfigRsp->unsuppTlvLst = NULLP;
73    FAPIConfigRsp->numInvTlvForPhySta = 0;
74    FAPIConfigRsp->phyIdleCfgTlvLst = NULLP;
75    FAPIConfigRsp->phyRunCfgTlvLst = NULLP;
76    FAPIConfigRsp->numMissingTlv = 0;
77    FAPIConfigRsp->missingTlvLst = NULLP;
78
79    phyToMac(MSG_TYPE_CONFIG_RSP, sizeof(L1L2ConfigRsp), FAPIConfigRsp);
80
81    RETVALUE(ROK);
82 }
83
84 /*******************************************************************
85  *
86  * @brief Handles config request received from MAC 
87  *
88  * @details
89  *
90  *    Function : l1HndlConfigReq
91  *
92  *    Functionality:
93  *          -Handles config request received from MAC
94  *
95  * @params[in]   Message length
96  *               Config request message pointer
97  *
98  * @return void
99  *
100  * ****************************************************************/
101
102 void l1HndlConfigReq(U16 msgLen, void *msg)
103 {
104     printf("\nReceived configuration request");
105
106     /* TO DO : validate all received TLVs and send back any unsupported/missing TLV */
107
108     if(l1BldAndSndCfgRsp(msg) != ROK)
109     {
110        printf("\nFailed Sending config response");
111     }
112 }
113
114 /*******************************************************************
115  *
116  * @brief Receives message from MAC
117  *
118  * @details
119  *
120  *    Function : macToPhy
121  *
122  *    Functionality:
123  *       - Receives message from MAC and calls handler
124  *
125  * @params[in] Message type
126  *             Message length
127  *             Message pointer
128  *
129  * @return void
130  *
131  * ****************************************************************/
132
133 void macToPhy(U16 msgType, U32 msgLen, void *msg)
134 {
135    switch(msgType)
136    {
137       case MSG_TYPE_CONFIG_REQ:
138          l1HndlConfigReq(msgLen, msg);
139          break;
140       default:
141          printf("\nInvalid message type[%x] received at PHY", msgType);
142    }
143
144 }
145
146 /**********************************************************************
147          End of file
148 **********************************************************************/