1 /******************************************************************************
2 ###############################################################################
3 # Copyright (c) [2017-2020] [ICT/CAS] #
4 # Licensed under the ORAN Software License v1.0 (License) #
5 ###############################################################################
6 ******************************************************************************/
8 #include "vos_string.h"
9 #include "vos_linklist.h"
12 #include "cuupCommon.h"
13 #include "cuModuleInterface.h"
14 #include "gnbCommon.h"
15 #include "upcContext.h"
18 PdcpuUeInfo_t *gPdcpuUeInfo[MAX_UE_NUM];
19 extern ULONG gPdcpuModuleId;
21 /* not used at the moment */
22 /*void pdcpuSetLessCountFun(const void* cpv_first, const void* cpv_second, void* pv_output)
24 assert(cpv_first != NULL && cpv_second != NULL && pv_output != NULL);
26 *(bool_t*)pv_output = (((PdcpuDataBuffNode_t *)cpv_first)->count) < (((PdcpuDataBuffNode_t *)cpv_second)->count) ? true : false;
30 /** 释放一个 PdcpuDataBuffNode_t 数据,赋值给plist->del */
31 VOID pdcpuFreeDataBuffNode(VOID *p)
33 PdcpuDataBuffNode_t *pNode = NULL;
39 pNode = (PdcpuDataBuffNode_t *)p;
40 if(NULL != pNode->pData)
42 msgbFree(pNode->pData);
51 /*******************************************************************************
52 * discard all stored PDCP PDUs in the transmitting buffer
54 * pTxPduList: transmitting buffer list
58 *******************************************************************************/
59 INT32 pdcpuDiscardTransmitBuff(plist pTxPduList)
64 /*******************************************************************************
65 * transmit or retransmit all stored PDCP PDUs in the transmitting buffer
67 * pTxPduList: transmitting buffer list
71 *******************************************************************************/
72 INT32 pdcpuDeliverTransmitBuff(PdcpDrbEntity_t *pPdcpuEntity)
77 /*******************************************************************************
78 * deliver the PDCP SDUs stored in the receiving buffer to upper layers
79 * in ascending order of associated COUNT values
81 * pTxPduList: transmitting buffer list
85 *******************************************************************************/
86 INT32 pdcpuDeliverRecvBuff(PdcpDrbEntity_t *pPdcpuEntity)
92 /*******************************************************************************
93 * To construct and send a PDCP status report
95 * pPdcpuEntity: pdcpu entity
99 *******************************************************************************/
100 INT32 pdcpuConstructStatusReport(PdcpDrbEntity_t *pPdcpuEntity)
105 /*******************************************************************************
106 * To perform PDCP data recovery
108 * ueE1apId: UE E1AP ID
113 *******************************************************************************/
114 INT32 pdcpuDataRecovery(PdcpDrbEntity_t *pPdcpuEntity)
119 INT32 pdcpuRecfgRohc(PdcpDrbEntity_t *pPdcpuEntity, upcTempDrbInfo_t *pDrbItem)
126 INT32 pdcpuSetSn(PdcpSnSize_e *pSn, PdcpSNSize_e snCfg)
128 if(PDCP_SN_SIZE_S12 == snCfg)
132 }else if(PDCP_SN_SIZE_S18 == snCfg)
138 pdcpuLog(LOG_ERR,"[PDCPU] input sn size is wrong!\n");
145 INT32 pdcpuSetRlcMode(PdcpRlcMode_e *pRlcMode, CuRlcMode_e rlcCfg)
150 pdcpuLog(LOG_ERR,"[PDCPU] input-TM MODE is wrong!\n");
157 case RLCMODE_UM_BIDIRECTIONAL:
158 case RLCMODE_UM_UNIDIRECTIONAL_UL:
159 case RLCMODE_UM_UNIDIRECTIONAL_DL:
164 pdcpuLog(LOG_ERR,"[PDCPU] input-rlc mode is wrong\n");
169 /*******************************************************************************
170 * To get SDAP DATA PDU header length configuration
176 *******************************************************************************/
177 INT32 pdcpuGetSdapHeadLen(SdapHeader_e sdapHeadInd, UINT8 *sdapHeadLen)
179 if(SDAP_HEADER_PRESENT == sdapHeadInd)
181 *sdapHeadLen = 1; /*Data PDU with SDAP header*/
183 }else if(SDAP_HEADER_ABSENT == sdapHeadInd)
185 *sdapHeadLen = 0; /*Data PDU without SDAP header*/
189 pdcpuLog(LOG_ERR,"[PDCPU] sdap head cfg is wrong\n");
197 /*******************************************************************************
198 * To create PDCP-U entity
200 * ueE1apId: UE E1AP ID
201 * pDrbItem : DRB to setup item
205 *******************************************************************************/
206 INT32 pdcpuCreateEntity(UINT64 ueE1apId, UINT16 ueIdx, UINT16 pduSessionId, upcTempDrbInfo_t *pDrbItem)
208 UINT8 drbId = pDrbItem->drbId;
209 PdcpuUeInfo_t *pPdcpUeInfo = NULL;
210 PdcpDrbEntity_t *pPdcpuEntity = NULL;
213 pdcpuCheckUeIdx(ueIdx);
214 pdcpuCheckDrbId(drbId);
216 /* examine ue info */
217 if(NULL == gPdcpuUeInfo[ueIdx])
219 pPdcpUeInfo = VOS_Malloc(sizeof(PdcpuUeInfo_t), gPdcpuModuleId);
220 pdcpuNullCheck(pPdcpUeInfo);
221 VOS_MemZero(pPdcpUeInfo, sizeof(PdcpuUeInfo_t));
222 gPdcpuUeInfo[ueIdx] = pPdcpUeInfo;
225 pPdcpUeInfo = gPdcpuUeInfo[ueIdx];
228 /* examine drb info */
229 if(NULL != pPdcpUeInfo->pdcpDrbEntity[drbId])
231 pPdcpuEntity = pPdcpUeInfo->pdcpDrbEntity[drbId];
234 pPdcpuEntity = VOS_Malloc(sizeof(PdcpDrbEntity_t), gPdcpuModuleId);
235 pdcpuNullCheck(pPdcpuEntity);
236 VOS_MemZero(pPdcpuEntity, sizeof(PdcpDrbEntity_t));
237 pPdcpUeInfo->pdcpDrbEntity[drbId] = pPdcpuEntity;
239 PDCPConfiguration_t *pPdcpCfg = &(pDrbItem->pdcpConfig);
240 pPdcpuEntity->ueE1apId = ueE1apId;
241 pPdcpuEntity->ueIdx = ueIdx;
242 pPdcpuEntity->pduSessionId = pduSessionId;
243 pPdcpuEntity->drbId = drbId;
245 if(0 != ((pPdcpCfg->bitMask)&PDCP_CONFIGURATION_OUT_OF_ORDER_DELIVERY_PRESENT))
247 pdcpuLog(LOG_INFO,"[PDCPU] 乱序递交已设置\n");
248 pPdcpuEntity->outOfOrderDelivery= TRUE;
252 ret += pdcpuSetRlcMode(&pPdcpuEntity->rlcMode, pPdcpCfg->rlcMode);
254 /* set sn size- Cond Setup2(38.331) */
255 ret += pdcpuSetSn(&pPdcpuEntity->pdcpSnSizeUl, pPdcpCfg->pdcpSNSizeUl);
256 ret += pdcpuSetSn(&pPdcpuEntity->pdcpSnSizeDl, pPdcpCfg->pdcpSNSizeDl);
259 /* set sdap head length */
260 ret += pdcpuGetSdapHeadLen(pDrbItem->sdapConfig.sdapDlHeaderInd, &pPdcpuEntity->sdapDlHeadLen);
261 ret += pdcpuGetSdapHeadLen(pDrbItem->sdapConfig.sdapUlHeaderInd, &pPdcpuEntity->sdapUlHeadLen);
263 /* check the above return results */
266 pdcpuLog(LOG_ERR,"[PDCPU] input parameter is wrong\n");
267 VOS_Free(pPdcpuEntity);
268 pPdcpUeInfo->pdcpDrbEntity[drbId] = NULL;
273 /* set security enable information */
274 PdcpuSecEnableInfo_t *pEnableInfo = gPdcpuUeInfo[ueIdx]->secEnableInfo[pduSessionId];
275 pdcpuNullCheck(pEnableInfo);
276 pPdcpuEntity->integrityProtection = pEnableInfo->integrityEnableFlag;
277 pPdcpuEntity->ciperingEnabled = pEnableInfo->cipherEnableFlag;
279 /* not support: ulDataSplitThreshold, pdcpDuplication */
281 /* set state variable */
282 VOS_MemZero(&(pPdcpuEntity->stateVar), sizeof(PdcpStateVar_t));
285 /* initial transmitting buffer */
286 pPdcpuEntity->txListLock = VOS_SemMCreate(VOS_SEM_Q_FIFO);
287 pPdcpuEntity->pTxPduList = cl_lib_list_new("pdcpuTxPduList", gPdcpuModuleId);
289 /* initial receiving buffer */
290 pPdcpuEntity->rxListLock = VOS_SemMCreate(VOS_SEM_Q_FIFO);
291 pPdcpuEntity->pRxSduList = cl_lib_list_new("pdcpuRxSduList", gPdcpuModuleId);
293 printfDrbEntity(pPdcpuEntity);