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 *******************************************************************************/
24 uint64_t ulDatNum = 0;
26 PUBLIC S16 macStubBOStatus(Pst *pst, SpId spId, RlcMacBOStatus *boSta)
29 RlcMacSchedRep *schRep;
31 DU_LOG("\nMAC : Received BO status from RLC");
33 // SGetSBuf(pst->region, pst->pool, (Data **)&rspPst, sizeof(Pst));
35 rspPst.selector = RGU_SEL_TC;
36 rspPst.srcEnt = pst->dstEnt;
37 rspPst.dstEnt = pst->srcEnt;
38 rspPst.dstInst = pst->srcInst;
39 rspPst.dstProcId = pst->srcProcId;
40 rspPst.srcProcId = pst->dstProcId;
41 rspPst.region = pst->region;
42 rspPst.pool = pst->pool;
44 /* Filling Scheduling Report */
45 KW_SHRABL_STATIC_BUF_ALLOC(pst->region, pst->pool, schRep, sizeof(RlcMacSchedRep));
47 schRep->cellId = boSta->cellId;
48 schRep->rnti = boSta->rnti;
50 schRep->lchSta[0].commCh = boSta->commCh;
51 schRep->lchSta[0].lchStaInd.lcId = boSta->lcId;
52 schRep->lchSta[0].lchStaInd.totBufSize = boSta->bo + 5; /* Extra buffer space including RLC and MAC Header size */
54 DU_LOG("\nMAC : Sending scheduling report to RLC");
56 RlcMacProcSchedRep(&rspPst, 1, schRep);
62 PUBLIC S16 macStubSendDlData(Pst *pst, SpId spId, RlcMacData *dlData)
70 DU_LOG("\nMAC_STUB : Received DL data from RLC to be sent to PHY");
72 SPutMsg(dlData->pduInfo[0].pduBuf);
73 dlData->pduInfo[0].pduBuf = NULL;
76 KW_FREE_SHRABL_BUF(pst->region, pst->pool,
77 dlData, sizeof(RlcMacData));
79 KW_ALLOC_SHRABL_BUF(pst->region, pst->pool,
80 ulData, sizeof(RlcMacData));
82 SRegInfoShow(2, &availmem);
83 cmMemcpy((U8 *)ulData, (U8 *)dlData, sizeof(RlcMacData));
87 SGetMsg(pst->region, pst->pool, &mBuf);
88 macStubBuildUlData(mBuf);
89 ulData->pduInfo[0].pduBuf = mBuf;
91 /* Fill response post */
92 rspPst.selector = RGU_SEL_TC;
93 rspPst.srcEnt = pst->dstEnt;
94 rspPst.dstEnt = pst->srcEnt;
95 rspPst.dstInst = pst->srcInst;
96 rspPst.dstProcId = pst->srcProcId;
97 rspPst.srcProcId = pst->dstProcId;
98 rspPst.region = pst->region;
99 rspPst.pool = pst->pool;
102 DU_LOG("\nMAC_STUB : UL data number %d", ulDatNum);
103 RlcMacProcUlData(&rspPst, 1, ulData);
107 void macStubBuildUlData(Buffer *mBuf)
109 char data[30] = "This is EGTP data from DU";
113 SAddPstMsgMult((Data *)data, datSize, mBuf);
115 /* filling IPv4 header */
118 U32 ipv4_du, ipv4_cu;
120 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
121 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
124 SFndLenMsg(mBuf, &mLen);
126 cmMemset((U8 *)&ipv4Hdr, 0, sizeof(CmIpv4Hdr));
127 ipv4Hdr.length = CM_IPV4_HDRLEN + mLen;
128 ipv4Hdr.hdrVer = 0x45;
130 ipv4Hdr.srcAddr = CM_INET_NTOH_U32(ipv4_du);
131 ipv4Hdr.destAddr = CM_INET_NTOH_U32(ipv4_cu);
133 /* Packing IPv4 header into buffer */
135 Data revPkArray[CM_IPV4_HDRLEN];
136 Data pkArray[CM_IPV4_HDRLEN];
138 /* initialize locals */
140 cmMemset(revPkArray, 0, CM_IPV4_HDRLEN);
141 cmMemset(pkArray, 0, CM_IPV4_HDRLEN);
143 /* Pack Header Version */
144 pkArray[cnt++] = ipv4Hdr.hdrVer;
147 pkArray[cnt++] = ipv4Hdr.tos;
149 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.length);
150 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.length);
153 pkArray[cnt++] = (Data) GetHiByte(ipv4Hdr.id);
154 pkArray[cnt++] = (Data) GetLoByte(ipv4Hdr.id);
157 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.off);
158 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.off);
161 pkArray[cnt++] = ipv4Hdr.ttl;
164 pkArray[cnt++] = ipv4Hdr.proto;
167 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.chkSum);
168 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.chkSum);
170 /* Pack Source Address */
171 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.srcAddr));
172 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.srcAddr));
173 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.srcAddr));
174 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.srcAddr));
176 /* Pack Destination Address */
177 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.destAddr));
178 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.destAddr));
179 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.destAddr));
180 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.destAddr));
182 for (idx = 0; idx < CM_IPV4_HDRLEN; idx++)
183 revPkArray[idx] = pkArray[CM_IPV4_HDRLEN - idx -1];
185 /* this function automatically reverses revPkArray */
186 ret = SAddPreMsgMult(revPkArray, (MsgLen)cnt, mBuf);
188 SAddPreMsgMult((Data *)&rlcDatSn, sizeof(uint8_t), mBuf);
190 SRegInfoShow(0, &availmem);
191 SRegInfoShow(1, &availmem);
192 SRegInfoShow(2, &availmem);
193 SRegInfoShow(3, &availmem);
194 SRegInfoShow(4, &availmem);
201 } /* macStubBuildUlData */
203 #endif /* EGTP_TEST */
205 /**********************************************************************
207 **********************************************************************/