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 *******************************************************************************/
22 #include "pdcpuDlDataProc.h"
23 #include "nguUlDataProc.h"
27 INT8 sdapMatchQosFlowId(SdapInstance_t *pSdapInstance, INT64 qosFlowId, UINT64 *pDrbId, UINT8 *pFlag)
32 SdapDrbCfg_t sdapDrbCfg = {0};
34 for(i = 0; i < pSdapInstance->drbNum; i++)
36 drbId = pSdapInstance->drbId[i];
38 VOS_MemCpy(&sdapDrbCfg, &pSdapInstance->drbCfg[drbId - 1], sizeof(SdapDrbCfg_t));
40 for(j = 0; j < sdapDrbCfg.qfiNum; j++)
42 if(qosFlowId == sdapDrbCfg.qfi[j])
50 /* 没有查找到DRB,映射到默认的DRB */
53 for(i = 0; i < pSdapInstance->drbNum; i++)
55 drbId = pSdapInstance->drbId[i];
57 /* 一个实例,即一个会话内,有且只有一个默认的DRB */
58 if(DEFAULT_DRB_TRUE == pSdapInstance->drbCfg[drbId - 1].sdapCfg.defaultDrbInd)
70 INT8 sdapPackPduHead(SdapInstance_t *pSdapInstance, INT64 qosFlowId, UINT64 *pDrbId, MsgbBuff_t *pMsgBuff, UINT8 rqi)
75 sdapDlHeader_t sdapHeader = {0};
78 if(VOS_OK != sdapMatchQosFlowId(pSdapInstance, qosFlowId, pDrbId, &updateFlag))
83 if(*pDrbId < 1 || *pDrbId > 32)
88 /*表明默认DRB上,增加了一条QOS的映射*/
91 qosNum = pSdapInstance->drbCfg[*pDrbId -1].qfiNum;
92 pSdapInstance->drbCfg[*pDrbId -1].qfi[qosNum] = qosFlowId;
93 pSdapInstance->drbCfg[*pDrbId -1].qfiNum++;
96 if(SDAP_HEADER_PRESENT == pSdapInstance->drbCfg[*pDrbId - 1].sdapCfg.sdapDlHeaderInd)
98 sdapHeader.QFI = qosFlowId;
104 sdapHeader.RQI = rqi;
106 pduHeadLen = sizeof(sdapDlHeader_t);
108 p = msgbHeadPush(pMsgBuff, pduHeadLen);
109 VOS_MemCpy(p, &sdapHeader, pduHeadLen);
118 INT32 sdapDlDataProc(UINT64 upE1apId, UINT64 sessId, INT64 qosFlowId, MsgbBuff_t *pMsgBuff, UINT8 rqi)
126 SdapGlobalDtat_t *pGlobalData = NULL;
127 SdapInstance_t *pSdapInstance = NULL;
128 UINT8 *pMsgHead = NULL;
136 pGlobalData = sdapGetUeGlobalData(upE1apId, &flag);
138 if(NULL == pGlobalData || 0 == flag)
143 for(i = 0; i < pGlobalData->sessNum; i++)
145 if(sessId == pGlobalData->sessId[i])
147 pSdapInstance = &pGlobalData->sdapInstance[sessId];
152 if(NULL == pSdapInstance)
157 sduLen = msgbDataUsedLen(pMsgBuff); //length of sdap sdu, not include sdap pdu head
158 pMsgHead = msgbData(pMsgBuff);//start of sdap sdu, not include sdap pdu head
160 if(0 > sduLen || NULL == pMsgHead)
165 pduHeadLen = sdapPackPduHead(pSdapInstance, qosFlowId, &drbId, pMsgBuff, rqi);
167 if(VOS_ERROR == pduHeadLen)
173 pdcpuDlDataProc(upE1apId, drbId, pMsgBuff, 1);
178 INT8 sdapUnPackPduHead(MsgbBuff_t *pMsgBuff)
183 UINT8 *pMsgHead = msgbData(pMsgBuff);
184 UINT16 pduLen = msgbDataUsedLen(pMsgBuff);
186 initBits(&bit, pMsgHead, pduLen, 0);
189 bitSize = SDAP_HEADER_LEN*8;
191 if(-1 == unpackBits(&bit, bitSize))
196 return SDAP_HEADER_LEN;
199 INT32 sdapUlDataProc(UINT64 upE1apId, UINT64 sessId, UINT64 drbId, MsgbBuff_t *pMsgBuff)
205 sdapUlHeader_t *pHead = NULL;
206 UINT8 qosFlowId = 0xff;
209 SdapGlobalDtat_t *pGlobalData = NULL;
210 SdapInstance_t *pSdapInstance = NULL;
211 SdapDrbCfg_t *pDrbCfgInfo = NULL;
219 pGlobalData = sdapGetUeGlobalData(upE1apId, &flag);
221 if(NULL == pGlobalData || 0 == flag)
227 for(i = 0; i < pGlobalData->sessNum; i++)
229 if(sessId == pGlobalData->sessId[i])
231 pSdapInstance = &pGlobalData->sdapInstance[sessId];
236 if(NULL == pSdapInstance)
242 for(i = 0; i < pSdapInstance->drbNum; i++)
244 if(drbId == pSdapInstance->drbId[i])
246 pDrbCfgInfo = &pSdapInstance->drbCfg[drbId - 1];
251 if(NULL == pDrbCfgInfo)
257 if(SDAP_HEADER_PRESENT == pDrbCfgInfo->sdapCfg.sdapUlHeaderInd)
259 pduHeadLen = sdapUnPackPduHead(pMsgBuff);
261 pHead = (sdapUlHeader_t *)msgbData(pMsgBuff);
262 qosFlowId = pHead->QFI;
263 pduType = pHead->TYPE;
267 /* receive control pdu */
271 /* check qosFlowId */
272 for(i = 0; i < pDrbCfgInfo->qfiNum; i++)
274 if(pDrbCfgInfo->qfi[i] == qosFlowId)
280 if(i < pDrbCfgInfo->qfiNum)
283 msgbHeadPull(pMsgBuff, pduHeadLen);
293 /* 调用NG-U的上行数据处理接口 */
294 return nguUlDataProc(upE1apId, sessId, qosFlowId, pMsgBuff);