1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /*This file contains stub for PHY to handle messages to/from MAC CL */
28 #include "rg_cl_phy.h"
30 EXTERN void phyToMac ARGS((U16 msgType, U32 msgLen,void *msg));
32 /*******************************************************************
34 * @brief Builds and sends config response to MAC CL
38 * Function : l1BldAndSndCfgRsp
41 * - Builds and sends config response to MAC
43 * @params[in] Config request message pointer
44 * @return ROK - success
47 * ****************************************************************/
49 S16 l1BldAndSndCfgRsp(void *msg)
51 L1L2ConfigReq *FAPIConfigReq;
52 L1L2ConfigRsp *FAPIConfigRsp;
55 FAPIConfigReq = (L1L2ConfigReq *)msg;
56 cci = FAPIConfigReq->carrierId;
57 SPutSBuf(0, 0, (Data *)msg, FAPIConfigReq->hdr.msgLen);
59 if(SGetSBuf(0, 0, (Data **)&FAPIConfigRsp, sizeof(L1L2ConfigRsp)) != ROK)
61 printf("\nMemory allocation failed for PHY Config Response");
65 FAPIConfigRsp->hdr.nMsg = 1;
66 FAPIConfigRsp->hdr.msgType = MSG_TYPE_CONFIG_RSP;
67 FAPIConfigRsp->hdr.msgLen = sizeof(L1L2ConfigRsp);
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;
79 phyToMac(MSG_TYPE_CONFIG_RSP, sizeof(L1L2ConfigRsp), FAPIConfigRsp);
84 /*******************************************************************
86 * @brief Handles config request received from MAC
90 * Function : l1HndlConfigReq
93 * -Handles config request received from MAC
95 * @params[in] Message length
96 * Config request message pointer
100 * ****************************************************************/
102 void l1HndlConfigReq(U16 msgLen, void *msg)
104 printf("\nReceived configuration request");
106 /* TO DO : validate all received TLVs and send back any unsupported/missing TLV */
108 if(l1BldAndSndCfgRsp(msg) != ROK)
110 printf("\nFailed Sending config response");
114 /*******************************************************************
116 * @brief Receives message from MAC
120 * Function : macToPhy
123 * - Receives message from MAC and calls handler
125 * @params[in] Message type
131 * ****************************************************************/
133 void macToPhy(U16 msgType, U32 msgLen, void *msg)
137 case MSG_TYPE_CONFIG_REQ:
138 l1HndlConfigReq(msgLen, msg);
141 printf("\nInvalid message type[%x] received at PHY", msgType);
146 /**********************************************************************
148 **********************************************************************/