1 /******************************************************************************
3 * Copyright (c) 2020 ICT/CAS.
5 * Licensed under the O-RAN Software License, Version 1.0 (the "Software 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 * https://www.o-ran.org/software
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.
17 *******************************************************************************/
20 #include "vos_types.h"
21 #include "vos_linklist.h"
23 #include "cuupCommon.h"
27 #include "gnbCommon.h"
28 #include "cuupUeIdTransf.h"
30 #include "cuupTest.h" //for test
32 extern PdcpuUeInfo_t *gPdcpuUeInfo[MAX_UE_NUM];
33 extern CuupUeIdxTable_t gPdcpuUeIdxTable;
34 extern ULONG gPdcpuModuleId;
36 ULONG gPdcpuDlModuleId;
38 INT32 pdcpuDlInit(ULONG userModuleId)
40 gPdcpuDlModuleId = userModuleId;
45 INT32 pdcpuPackPduHead(PdcpRlcMode_e rlc_mode,PdcpSnSize_e snSize, UINT32 sn, MsgbBuff_t *msgb)
49 UINT8 *pPduHead = NULL;
52 if(LEN12BITS == snSize)
54 pduHeadLen = PDCP_SN_12_HEAD_LEN;
55 }else if(LEN18BITS == snSize)
57 pduHeadLen = PDCP_SN_18_HEAD_LEN;
60 pdcpuLog(LOG_ERR,"[PDCPU] sn size is wrong!\n");
63 pPduHead = VOS_Malloc(pduHeadLen,gPdcpuDlModuleId);
64 pdcpuNullCheck(pPduHead);
65 VOS_MemZero(pPduHead, pduHeadLen);
67 if(snSize == LEN12BITS)
69 if(sn >= MAX_PDCP_SN_12)
71 pdcpuLog(LOG_ERR,"[PDCPU] sn too big\n");
74 initBits(&bit, pPduHead, 16, 0);
76 skipBits(&bit, 3, BIT_PACKED);
77 packBits(&bit, 4, ((sn & 0xf00)>>8));
78 packBits(&bit, 8, sn & 0x0ff);
79 }else if(snSize == LEN18BITS)
81 if(sn >= MAX_PDCP_SN_18)
83 pdcpuLog(LOG_ERR,"[PDCPU] sn too big\n");
86 initBits(&bit, pPduHead, 24, 0);
88 skipBits(&bit, 5, BIT_PACKED);
89 packBits(&bit, 2, ((sn & 0x00030000)>>16));
90 packBits(&bit, 8, ((sn & 0x0000ff00)>>8));
91 packBits(&bit, 8, sn & 0x000000ff);
94 pdcpuLog(LOG_ERR,"[PDCPU] sn size error\n");
98 p = msgbHeadPush(msgb, pduHeadLen);
101 VOS_MemCpy(p, pPduHead, pduHeadLen);
104 pdcpuLog(LOG_ERR,"[PDCPU] msgbHeadPush failed!\n");
118 /*******************************************************************************
119 * pdcp-u dl data process
121 * ueE1apId: E1AP ID of the UE
122 * drbId: ID of data radio bearer
127 *******************************************************************************/
128 INT32 pdcpuDlDataProc(UINT64 ueE1apId, UINT8 drbId, MsgbBuff_t *pMsgBuff, UINT8 sdapPduType)
134 PdcpRlcMode_e rlcMode;
135 PdcpDrbEntity_t *pPdcpDrbEntity = NULL;
138 if(VOS_ERROR == cuupGetUeIdx(ueE1apId, &ueIdx, &gPdcpuUeIdxTable))
140 pdcpuLog(LOG_ERR,"[PDCPU] get ueIdx failed,ueE1apId:%d\n",ueE1apId);
143 pdcpuCheckUeIdx(ueIdx);
144 pdcpuCheckDrbId(drbId);
146 pdcpuGetEntity(ueIdx, drbId, pPdcpDrbEntity);
147 pdcpuNullCheck(pPdcpDrbEntity);
148 rlcMode = pPdcpDrbEntity->rlcMode;
151 pdcpuNullCheck(pMsgBuff);
154 UINT32 count = pPdcpDrbEntity->stateVar.txNext++;
156 // check out count wrapping around whether or not
157 if(0xffffffff == count)
159 pdcpuLog(LOG_ERR,"[PDCPU] count value is going to wrap around!\n");
163 snSize = pPdcpDrbEntity->pdcpSnSizeDl;
164 if(snSize == LEN12BITS)
166 sn = GET_SN_12_SN(count);
167 }else if(snSize == LEN18BITS)
169 sn = GET_SN_18_SN(count);
172 pdcpuLog(LOG_ERR,"[PDCPU] sn size is wrong!\n");
177 pduHeadLen = pdcpuPackPduHead(rlcMode, snSize, sn, pMsgBuff);
178 if(VOS_ERROR == pduHeadLen)
180 pdcpuLog(LOG_ERR,"[PDCPU] pack pdcp pdu head failed!\n");
184 //8. 否则:cuf1u将数据发送成功后,释放
185 if(VOS_OK == cuf1uDlDataProc(ueE1apId, drbId, pMsgBuff, NULL))
187 //vos_info_print("there is no buffer\n");
193 pdcpuLog(LOG_ERR,"[PDCPU] cuf1u send failed\n");