VOS_VOID CDS_SaveIpfDlSrcMem(const IPF_CONFIG_DLPARAM_S *pstIpfDlBdBuff, VOS_UINT32 ulSaveNum) { LUP_QUEUE_STRU *pstDlFreeQue; VOS_UINT32 ulCnt; TTF_MEM_ST *pstSrcMem; CDS_ASSERT(VOS_NULL_PTR != pstIpfDlBdBuff); if (ulSaveNum > IPF_DLBD_DESC_SIZE) { CDS_ERROR_LOG1(UEPS_PID_CDS,"CDS_SaveIpfDlMemInfo:Input Bd Num Error.",ulSaveNum); return ; } pstDlFreeQue = CDS_IPF_DL_SRCMEM_FREE_QUE(); CDS_ASSERT(VOS_NULL_PTR != pstDlFreeQue); for (ulCnt = 0; ulCnt < ulSaveNum; ulCnt ++) { pstSrcMem = (TTF_MEM_ST*)pstIpfDlBdBuff[ulCnt].u32Data; if (PS_SUCC != LUP_EnQue(pstDlFreeQue,pstSrcMem)) { CDS_ERROR_LOG2(UEPS_PID_CDS,"CDS_SaveIpfDlMemInfo: Src Mem Leak.",ulCnt,ulSaveNum); vos_printf("CDS_SaveIpfDlMemInfo: Buffer Full!! cnt=%d,ulSaveNum=%d\n",ulCnt,ulSaveNum); TTF_MemFree(UEPS_PID_CDS,pstSrcMem); CDS_DBG_DL_IPF_SAVE_SRCMEM_FAIL_NUM(1); continue; } CDS_DBG_DL_IPF_SAVE_SRCMEM_SUCC_NUM(1); } return ; }
BST_ERR_ENUM_UINT8 BST_PAL_NetApiPacketFree( BST_VOID *pstItem ) { if( BST_NULL_PTR == pstItem ) { return BST_ERR_INVALID_PTR; } TTF_MemFree( UEPS_PID_BASTET, pstItem ); return BST_NO_ERROR_MSG; }
VOS_VOID CDS_FreeIpfDlSrcMem(VOS_VOID) { LUP_QUEUE_STRU *pstDlFreeQue ; BSP_U32 ulIdleCD; VOS_UINT32 ulIdleBD; VOS_UINT32 ulBusyBD; VOS_UINT32 ulCanFree; VOS_UINT32 ulQueCnt; VOS_UINT32 ulCnt; TTF_MEM_ST *pstSrcTtf; pstDlFreeQue = CDS_IPF_DL_SRCMEM_FREE_QUE(); CDS_ASSERT(VOS_NULL_PTR != pstDlFreeQue); ulQueCnt = LUP_QueCnt(pstDlFreeQue); if (0 == ulQueCnt) { return; } /*get busy bd num*/ ulIdleBD = BSP_IPF_GetDlBDNum(&ulIdleCD); ulBusyBD = IPF_DLBD_DESC_SIZE - ulIdleBD; if (ulQueCnt >= ulBusyBD) { ulCanFree = ulQueCnt - ulBusyBD; } else { CDS_ERROR_LOG3(UEPS_PID_CDS, "CDS_FreeIpfDlSrcMem:Buff Num Less IPF Busy BD Num.quecnt,busybd,idlebd",ulQueCnt,ulBusyBD,ulIdleBD); vos_printf("CDS_FreeIpfDlSrcMem : src free que less than busy bd. quecnt=%d,busybd=%d,idlebd=%d.\n",ulQueCnt,ulBusyBD,ulIdleBD); CDS_DBG_DL_IPF_FREE_SRCMEM_ERROR(1); return; } /*free src mem*/ for (ulCnt = 0; ulCnt < ulCanFree; ulCnt ++) { if (PS_SUCC != LUP_DeQue(pstDlFreeQue,&pstSrcTtf)) { return; } TTF_MemFree(UEPS_PID_CDS,pstSrcTtf); CDS_DBG_DL_IPF_FREE_SRCMEM_NUM(1); } return; }
VOS_VOID CDS_UlProcImsData(MODEM_ID_ENUM_UINT16 enModemId) { VOS_UINT32 ulCnt; TTF_MEM_ST *pstIpPkt; VOS_INT32 lLock; CDS_ENTITY_STRU *pstCdsEntity; VOS_UINT16 usResult; pstCdsEntity = CDS_GetCdsEntity(enModemId); if (VOS_NULL_PTR == pstCdsEntity) { return; } for (ulCnt = 0; ulCnt < CDS_IMS_QUE_SIZE; ulCnt ++) { lLock = VOS_SplIMP(); if (PS_SUCC != LUP_DeQue(pstCdsEntity->pstIMSDataQue, (VOS_VOID**)(&pstIpPkt))) { VOS_Splx(lLock); break; } VOS_Splx(lLock); /*上行软过滤*/ usResult = 0; if (PS_SUCC != CDS_IpSoftFilter(pstIpPkt, &usResult,pstCdsEntity)) { TTF_MemFree(UEPS_PID_CDS, pstIpPkt); CDS_DBG_IMS_UL_SOFT_FILTER_FAIL_NUM(1); continue; } /*将过滤结果存到TTF中*/ CDS_UL_SAVE_IPFRSLT_TO_TTF(pstIpPkt,usResult); /*鈎包*/ CDS_SendIpPacket2PC(pstIpPkt); /*发送到空口*/ CDS_UlDispatchDataByRanMode(pstCdsEntity,pstIpPkt); CDS_DBG_IMS_UL_SEND_PKT_TO_RAN_NUM(1); } return; }
VOS_VOID CDS_DlProcImsUtPkt(CDS_IMS_SDU_STRU *pstImsSdu, const CDS_ENTITY_STRU *pstCdsEntity) { VOS_UINT32 ulResult; VOS_UINT8 ucDeftRabId; TTF_MEM_ST *pstIpPkt; CDS_DBG_IMS_DL_RX_IMS_Ut_PKT_NUM(1); if (MMC_CDS_MODE_GU == pstCdsEntity->enRanMode) { ulResult = CDS_GUGetDefaultRabId(pstImsSdu->ucRabId,&ucDeftRabId,pstCdsEntity->usModemId); } else { ulResult = CDS_ERABM_GetDefaultEpsbId(pstImsSdu->ucDrbId,&ucDeftRabId); } if (PS_SUCC != ulResult) { TTF_MemFree(UEPS_PID_CDS, pstImsSdu->pstSdu); CDS_DBG_IMS_DL_Ut_PKT_PROC_ERR_NUM(1); return; } /*保存必要信息*/ pstIpPkt = pstImsSdu->pstSdu; CDS_DL_SAVE_LEN_MODEMID_RABID_TO_TTF(pstIpPkt, pstImsSdu->ulSduLen, pstCdsEntity->usModemId, ucDeftRabId); /*入队*/ if (PS_SUCC != CDS_RxDlSdu(pstIpPkt)) { CDS_DBG_DL_LTE_ENQUE_FAIL_NUM(1); CDS_DBG_IMS_DL_Ut_PKT_PROC_ERR_NUM(1); return; } CDS_DBG_DL_LTE_ENQUE_SUCC_NUM(1); CDS_DBG_IMS_DL_Ut_PKT_PROC_SUCC_NUM(1); return; }
TTF_MEM_ST* CDS_TtfMemCopyAlloc(TTF_MEM_ST *pstSrc, VOS_UINT32 ulLen) { TTF_MEM_ST *pstDest; pstDest = CDS_AllocTtfMem(ulLen); if (VOS_NULL_PTR == pstDest) { return VOS_NULL_PTR; } /*内存拷贝*/ if (PS_SUCC != TTF_MemGetHeadData(UEPS_PID_CDS, pstSrc, pstDest->pData, pstDest->usUsed)) { TTF_MemFree(UEPS_PID_CDS,pstDest); return VOS_NULL_PTR; } return pstDest; }
/******************************************************************************* Module: RABM_RelSaveData Function: 释放缓存的数据 Input: RABM_DATA_SAVE_STRU *pLink 存储数据首地址 VOS_UINT8 ucMsgType 消息类型 Output: VOS_VOID NOTE: Return: VOS_VOID History: 1. 张志勇 2003.12.11 新规作成 *******************************************************************************/ VOS_VOID RABM_RelSaveData( RABM_DATA_SAVE_STRU *pLink, /* 存储数据首地址 */ VOS_UINT8 ucMsgType /* 消息类型 */ ) { RABM_DATA_LINK_STRU *pTemp1 = RABM_POINTER_NULL; VOS_UINT8 i; pTemp1 = pLink->Data.pNxt; for( i = 0; i < pLink->ucNum; i++ ) { if ( RABM_DOWNLINK == ucMsgType ) { /* 缓存的下行数据 */ RABM_PdcpFree(((PDCP_RABM_DATA_BUF_STRU *) pLink->Data.pData)->pucData); } else { /*释放零拷贝内存块:*/ TTF_MemFree(WUEPS_PID_RABM, ((TAFRABM_PS_DATA_REQ_STRU *) pLink->Data.pData)->pData); } RABM_PdcpFree(pLink->Data.pData); /* 释放消息 */ if(RABM_POINTER_NULL != pTemp1) { /* 缓存的数据不为0 */ pLink->Data.pData = pTemp1->pData; /* 更新缓存的数据 */ pLink->Data.pNxt = pTemp1->pNxt; /* 更新缓存的数据链表 */ RABM_Free(pTemp1); /* 释放链表节点 */ } pTemp1 = pLink->Data.pNxt; /* 更新指针位置 */ } pLink->ucNum = 0; return; }
VOS_VOID TTF_MemFreeFromQue(VOS_VOID) { TTF_MEM_ST *pstTtfMem = VOS_NULL_PTR; VOS_UINT32 ulResult; if (g_pstCcpuTTFMemFreeQue == VOS_NULL_PTR) { vos_printf("CDS_TTFMemFree: g_pstCcpuTTFMemFreeQue is null\n"); return; } if (g_pstCcpuTTFMemFreeQue->ulMaxNum != (TTF_MEM_FREE_QUE_LEN+1)) { vos_printf("CDS_TTFMemFree: g_pstCcpuTTFMemFreeQue ulMaxNum err\n"); return; } while(PS_TRUE != (LUP_IsQueEmpty(g_pstCcpuTTFMemFreeQue))) { ulResult = LUP_DeQue(g_pstCcpuTTFMemFreeQue, (VOS_VOID **)&pstTtfMem); g_stTtfMemRbMntnEntity.ulTtfMemRbDeQTotalCnt++; if (PS_SUCC != ulResult) { g_stTtfMemRbMntnEntity.ulTtfMemRbDeQFailCnt++; vos_printf("TTF_MemFreeFromQue: LUP_DeQue fail!\n"); return; } TTF_MemFree(UEPS_PID_TTF_MEM_RB_FREE, pstTtfMem); } return; }/* TTF_MemFreeFromQue */
VOS_UINT32 CDS_ConfigUlAdq(VOS_UINT32 ulAdType, VOS_UINT32 ulCanCfgAdNum) { VOS_UINT32 ulCnt; VOS_UINT32 ulAdLen; TTF_MEM_ST *pstDstMem; IPF_AD_DESC_S *pstAdDesc; VOS_UINT32 ulTmp; /*入参判断*/ if ((0 == ulCanCfgAdNum) || (CDS_IPF_ULAD_DESC_SIZE < ulCanCfgAdNum)) { return 0; } if (ulAdType >= IPF_AD_MAX) { return 0; } /*设置申请内存长度*/ if (IPF_AD_0 == ulAdType) { ulAdLen = CDS_IPF_AD_0_PKT_LEN; } else { ulAdLen = CDS_IPF_AD_1_PKT_LEN; } /*循环申请内存,配置AD描述符*/ for (ulCnt = 0; ulCnt < ulCanCfgAdNum; ulCnt ++) { pstDstMem = CDS_AllocTtfMem(ulAdLen); if (VOS_NULL_PTR == pstDstMem) { break; } /*配置AD DESC*/ CDS_DBG_UL_ADQ_ALLOC_MEM_NUM(1); pstAdDesc = &(g_stCdsIpfCtrlEntity.astUlAdBuff[ulCnt]); pstAdDesc->u32OutPtr0 = (VOS_UINT32)(pstDstMem->pData); pstAdDesc->u32OutPtr1 = (VOS_UINT32)pstDstMem; } if (0 == ulCnt) { return 0; } /*配置AD*/ if (IPF_SUCCESS != BSP_IPF_ConfigUlAd((IPF_AD_TYPE_E)ulAdType,ulCnt,g_stCdsIpfCtrlEntity.astUlAdBuff)) { /*配置失败,释放内存*/ ulTmp = ulCnt; for (ulCnt = 0; ulCnt < ulTmp; ulCnt ++) { pstAdDesc = &(g_stCdsIpfCtrlEntity.astUlAdBuff[ulCnt]); pstDstMem = (TTF_MEM_ST*)(pstAdDesc->u32OutPtr1); TTF_MemFree(UEPS_PID_CDS,pstDstMem); CDS_DBG_UL_ADQ_FREE_MEM_NUM(1); } CDS_DBG_UL_ADQ_CFG_ADQ_FAIL_NUM(1); return 0; } CDS_DBG_UL_ADQ_CFG_AD_NUM(ulCnt); CDS_DBG_UL_ADQ_CFG_ADQ_SUCC_NUM(1); return ulCnt; }
VOS_VOID CDS_ConfigDlIPF(VOS_VOID) { VOS_UINT32 ulIdleBD; BSP_U32 ulIdleCD; VOS_UINT32 ulCnt; VOS_UINT32 ulCfgCD; TTF_MEM_ST *pstSrcMem; IPF_CONFIG_DLPARAM_S *pstDlCfgPara; int intLockLevel; /*触发下行IPF释放源内存*/ CDS_FreeIpfDlSrcMem(); /*获得下行空闲BD/CD个数*/ ulIdleBD = (VOS_UINT32)BSP_IPF_GetDlBDNum(&ulIdleCD); if (0 == ulIdleBD) { /*没有空闲BD*/ CDS_DBG_DL_IPF_CFG_HAVE_NO_BD(1); return; } if (ulIdleBD > IPF_DLBD_DESC_SIZE) { CDS_ERROR_LOG1(UEPS_PID_CDS,"CDS_GUConfigDlIPF : DL Idle BD Num Error.",ulIdleBD); return; } if (0 == ulIdleCD) { /*没有空闲CD*/ CDS_DBG_DL_IPF_CFG_HAVE_NO_CD(1); return; } ulCfgCD = 0; for (ulCnt = 0; ulCnt < ulIdleBD; ulCnt ++) { /**/ pstDlCfgPara = &(g_stCdsIpfCtrlEntity.astDlIpfCfgPara[ulCnt]); if (PS_SUCC != LUP_PeekQueHead(CDS_GET_IPF_DL_SDU_QUE(),&pstSrcMem)) { break; } /*Get BD*/ ulCfgCD += CDS_GetTtfMemCnt(pstSrcMem); if (ulCfgCD > ulIdleCD) { CDS_DBG_DL_IPF_CFG_CD_NOT_ENOUGH(1); break; } /*真实出队*/ intLockLevel = VOS_SplIMP(); if (PS_SUCC != LUP_DeQue(CDS_GET_IPF_DL_SDU_QUE(),&pstSrcMem)) { /*异常保护,应该不会*/ VOS_Splx(intLockLevel); break; } VOS_Splx(intLockLevel); pstDlCfgPara->u32Data = (VOS_UINT32)(pstSrcMem); pstDlCfgPara->u16Len = CDS_DL_GET_PKT_LEN_FROM_TTF(pstSrcMem); pstDlCfgPara->u16UsrField1 = CDS_DL_GET_MODEMID_RABID_FROM_TTF(pstSrcMem); if (MODEM_ID_0 == CDS_DL_GET_MODEMID_FROM_TTF(pstSrcMem)) { CDS_DL_BD_SET_ATTR_WITH_FC_HDR(pstDlCfgPara->u16Attribute,IPF_MODEM0_DLFC); } else { CDS_DL_BD_SET_ATTR_WITH_FC_HDR(pstDlCfgPara->u16Attribute,IPF_MODEM1_DLFC); } } /*配置下行过滤包数为0,直接返回*/ if (0 == ulCnt) { return; } /*最后一个BD设置中断标志*/ pstDlCfgPara = &(g_stCdsIpfCtrlEntity.astDlIpfCfgPara[ulCnt - 1]); CDS_DL_BD_SET_ATTR_INT_FLG(pstDlCfgPara->u16Attribute); /*配置上行IPF过滤*/ if (IPF_SUCCESS != BSP_IPF_ConfigDownFilter(ulCnt,g_stCdsIpfCtrlEntity.astDlIpfCfgPara)) { /*配置失败后,源内存释放*/ ulIdleBD = ulCnt; for (ulCnt = 0; ulCnt < ulIdleBD; ulCnt ++) { pstDlCfgPara = &(g_stCdsIpfCtrlEntity.astDlIpfCfgPara[ulCnt]); pstSrcMem = (TTF_MEM_ST*)(pstDlCfgPara->u32Data); TTF_MemFree(UEPS_PID_CDS,pstSrcMem); } CDS_DBG_DL_IPF_CFG_BD_FAIL_NUM(ulIdleBD); return; } /*缓存Src Mem*/ CDS_SaveIpfDlSrcMem(g_stCdsIpfCtrlEntity.astDlIpfCfgPara,ulCnt); CDS_DBG_DL_IPF_CFG_BD_SUCC_NUM(ulCnt); return; }
VOS_VOID CDS_ConfigDlIPF(VOS_VOID) { VOS_UINT32 ulIdleBD; BSP_U32 ulIdleCD; VOS_UINT32 ulCnt; VOS_UINT32 ulCfgCD; TTF_MEM_ST *pstDestMem; TTF_MEM_ST *pstSrcMem; IPF_CONFIG_DLPARAM_S *pstDlCfgPara; int intLockLevel; VOS_UINT16 usSduLen; /*触发下行IPF释放源内存*/ CDS_FreeIpfDlSrcMem(); /*获得下行空闲BD/CD个数*/ ulIdleBD = BSP_IPF_GetDlBDNum(&ulIdleCD); if (0 == ulIdleBD) { /*没有空闲BD*/ CDS_DBG_DL_IPF_CFG_HAVE_NO_BD(1); return; } if (ulIdleBD > IPF_DLBD_DESC_SIZE) { CDS_ERROR_LOG1(UEPS_PID_CDS,"CDS_GUConfigDlIPF : DL Idle BD Num Error.",ulIdleBD); return; } if (0 == ulIdleCD) { /*没有空闲CD*/ CDS_DBG_DL_IPF_CFG_HAVE_NO_CD(1); return; } ulCfgCD = 0; for (ulCnt = 0; ulCnt < ulIdleBD; ulCnt ++) { /**/ pstDlCfgPara = &(g_stCdsIpfCtrlEntity.astDlIpfCfgPara[ulCnt]); if (PS_SUCC != LUP_PeekQueHead(CDS_GET_IPF_DL_SDU_QUE(),&pstSrcMem)) { break; } /*Get BD*/ ulCfgCD += CDS_GetTtfMemCnt(pstSrcMem); if (ulCfgCD > ulIdleCD) { CDS_DBG_DL_IPF_CFG_CD_NOT_ENOUGH(1); break; } /*申请目的内存*/ usSduLen = CDS_DL_GET_PKT_LEN_FROM_TTF(pstSrcMem); pstDestMem = TTF_MemBlkAlloc(UEPS_PID_CDS, TTF_MEM_POOL_ID_DL_SHARE,usSduLen); if (VOS_NULL_PTR == pstDestMem) { if ((0 == usSduLen) || (CDS_DL_SDU_MAX_LEN < usSduLen)) { intLockLevel = VOS_SplIMP(); (VOS_VOID)LUP_DeQue(CDS_GET_IPF_DL_SDU_QUE(),&pstSrcMem); VOS_Splx(intLockLevel); TTF_MemFree(UEPS_PID_CDS,pstSrcMem); CDS_DBG_DL_IPF_CFG_BD_SDU_LEN_ERROR(1); } CDS_DBG_DL_IPF_CFG_BD_ALLOC_MEM_FAIL(1); break; } pstDestMem->usUsed = usSduLen; /*真实出队*/ intLockLevel = VOS_SplIMP(); if (PS_SUCC != LUP_DeQue(CDS_GET_IPF_DL_SDU_QUE(),&pstSrcMem)) { /*异常保护,应该不会*/ VOS_Splx(intLockLevel); vos_printf("CDS_GUConfigDlIPF : Should not be here !\r\n"); TTF_MemFree(UEPS_PID_CDS,pstDestMem); break; } VOS_Splx(intLockLevel); pstDlCfgPara->u16UsrField = CDS_DL_GET_RABID_FROM_TTF(pstSrcMem); pstDlCfgPara->pstDstTtf = pstDestMem; pstDlCfgPara->pstSrcTtf = pstSrcMem; } /*配置下行过滤包数为0,直接返回*/ if (0 == ulCnt) { return; } /*配置上行IPF过滤*/ if (IPF_SUCCESS != BSP_IPF_ConfigDownFilter(ulCnt,g_stCdsIpfCtrlEntity.astDlIpfCfgPara,PS_TRUE)) { /*配置失败后,源内存释放*/ ulIdleBD = ulCnt; for (ulCnt = 0; ulCnt < ulIdleBD; ulCnt ++) { pstDlCfgPara = &(g_stCdsIpfCtrlEntity.astDlIpfCfgPara[ulCnt]); TTF_MemFree(UEPS_PID_CDS,pstDlCfgPara->pstDstTtf); TTF_MemFree(UEPS_PID_CDS,pstDlCfgPara->pstSrcTtf); } CDS_DBG_DL_IPF_CFG_BD_FAIL_NUM(ulIdleBD); return; } CDS_SaveIpfDlSrcMem(g_stCdsIpfCtrlEntity.astDlIpfCfgPara,ulCnt); CDS_DBG_DL_IPF_CFG_BD_SUCC_NUM(ulCnt); return; }
VOS_INT32 NAS_CsDomainDataReq( VOS_INT8 cRbId, VOS_UINT32 ulDataLength, VOS_UINT8 *pucData ) { RABM_RLC_TM_DATA_REQ_STRU *pTmMsg; RABM_RLC_UM_DATA_REQ_STRU *pUmMsg; RABM_RLC_AM_DATA_REQ_STRU *pAmMsg; VOS_UINT32 ulLenOct; VOS_UINT8 ucRbMode; VOS_VOID *pMsg; TTF_MEM_ST *pData; ucRbMode = NAS_GetRbTxMode(RRC_NAS_CS_DOMAIN, cRbId); switch(ucRbMode) { case WUE_RLC_TM_MODE: pTmMsg = (RABM_RLC_TM_DATA_REQ_STRU *)PS_ALLOC_MSG_WITH_HEADER_LEN( WUEPS_PID_RABM,sizeof(RABM_RLC_TM_DATA_REQ_STRU)); if( VOS_NULL == pTmMsg ) { PS_LOG(WUEPS_PID_RABM, 0, PS_PRINT_ERROR, "NAS_CsDomainDataReq, Error, call PS_ALLOC_MSG_WITH_HEADER_LEN fail\n"); return AS_NO_MEMORY; } PS_MEM_SET((VOS_INT8*)pTmMsg + VOS_MSG_HEAD_LENGTH,0, sizeof(RABM_RLC_TM_DATA_REQ_STRU) - VOS_MSG_HEAD_LENGTH); pTmMsg->ulSenderCpuId = VOS_LOCAL_CPUID; pTmMsg->ulSenderPid = WUEPS_PID_RABM; pTmMsg->ulReceiverCpuId = VOS_LOCAL_CPUID; pTmMsg->ulReceiverPid = WUEPS_PID_RLC; pTmMsg->ulLength = sizeof(RABM_RLC_TM_DATA_REQ_STRU) - VOS_MSG_HEAD_LENGTH; pTmMsg->enMsgName = ID_RABM_RLC_TM_DATA_REQ; pTmMsg->ucRbId = (VOS_UINT8)cRbId; pTmMsg->usDataBitLen = (VOS_UINT16)ulDataLength; ulLenOct = (ulDataLength + 7)/ 8; pData = TTF_MemBlkCopyAlloc(WUEPS_PID_RABM, TTF_MEM_POOL_ID_UL_RLC_SDU, pucData, (VOS_UINT16)ulLenOct); if ( VOS_NULL_PTR == pData ) { /*释放消息内存:*/ PS_FREE_MSG(WUEPS_PID_RABM, pTmMsg); PS_LOG(WUEPS_PID_RABM, 0, PS_PRINT_ERROR, "NAS_CsDomainDataReq, Error, call TTF_MemCopyAlloc fail\n"); return AS_NO_MEMORY; } pTmMsg->pstDataMem = pData; pMsg = (VOS_VOID *)pTmMsg; break; case WUE_RLC_UM_MODE: if(0 != (ulDataLength % 8)) { PS_LOG(WUEPS_PID_RABM, 0, PS_PRINT_ERROR, "NAS_CsDomainDataReq, Error, 配置的RLC UL SDU长度不是整字节\n"); return AS_DATA_LENGTH_ERR; } pUmMsg = (RABM_RLC_UM_DATA_REQ_STRU *)PS_ALLOC_MSG_WITH_HEADER_LEN( WUEPS_PID_RABM,sizeof(RABM_RLC_UM_DATA_REQ_STRU)); if( VOS_NULL == pUmMsg ) { PS_LOG(WUEPS_PID_RABM, 0, PS_PRINT_ERROR, "NAS_CsDomainDataReq, Error, call PS_ALLOC_MSG_WITH_HEADER_LEN fail\n"); return AS_NO_MEMORY; } PS_MEM_SET((VOS_INT8*)pUmMsg + VOS_MSG_HEAD_LENGTH,0, sizeof(RABM_RLC_UM_DATA_REQ_STRU) - VOS_MSG_HEAD_LENGTH); pUmMsg->ulSenderCpuId = VOS_LOCAL_CPUID; pUmMsg->ulSenderPid = WUEPS_PID_RABM; pUmMsg->ulReceiverCpuId = VOS_LOCAL_CPUID; pUmMsg->ulReceiverPid = WUEPS_PID_RLC; pUmMsg->ulLength = sizeof(RABM_RLC_UM_DATA_REQ_STRU) - VOS_MSG_HEAD_LENGTH; pUmMsg->enMsgName = ID_RABM_RLC_UM_DATA_REQ; pUmMsg->ucRbId = (VOS_UINT8)cRbId; /* 此成员为TD新加的, GU这边没用这个成员, 所以可以不使用TD的宏 */ pUmMsg->usDataBitLen = (VOS_UINT16)ulDataLength; ulLenOct = ulDataLength / 8; pData = TTF_MemBlkCopyAlloc(WUEPS_PID_RABM, TTF_MEM_POOL_ID_UL_RLC_SDU, pucData, (VOS_UINT16)ulLenOct); if ( VOS_NULL_PTR == pData ) { /*释放消息内存:*/ PS_FREE_MSG(WUEPS_PID_RABM, pUmMsg); PS_LOG(WUEPS_PID_RABM, 0, PS_PRINT_ERROR, "NAS_CsDomainDataReq, Error, call TTF_MemCopyAlloc fail\n"); return AS_NO_MEMORY; } pUmMsg->pstDataMem = pData; pMsg = (VOS_VOID *)pUmMsg; break; case WUE_RLC_AM_MODE: ulLenOct = (ulDataLength + 7) / 8; pAmMsg = (RABM_RLC_AM_DATA_REQ_STRU *)PS_ALLOC_MSG_WITH_HEADER_LEN( WUEPS_PID_RABM,sizeof(RABM_RLC_AM_DATA_REQ_STRU)); if( VOS_NULL == pAmMsg ) { PS_LOG(WUEPS_PID_RABM, 0, PS_PRINT_ERROR, "NAS_CsDomainDataReq, Error, call PS_ALLOC_MSG_WITH_HEADER_LEN fail\n"); return AS_NO_MEMORY; } PS_MEM_SET((VOS_INT8*)pAmMsg + VOS_MSG_HEAD_LENGTH,0, sizeof(RABM_RLC_AM_DATA_REQ_STRU) - VOS_MSG_HEAD_LENGTH); pAmMsg->ulSenderCpuId = VOS_LOCAL_CPUID; pAmMsg->ulSenderPid = WUEPS_PID_RABM; pAmMsg->ulReceiverCpuId = VOS_LOCAL_CPUID; pAmMsg->ulReceiverPid = WUEPS_PID_RLC; pAmMsg->ulLength = sizeof(RABM_RLC_AM_DATA_REQ_STRU) - VOS_MSG_HEAD_LENGTH; pAmMsg->enMsgName = ID_RABM_RLC_AM_DATA_REQ; pAmMsg->ucRbId = (VOS_UINT8)cRbId; /* 此成员为TD新加的, GU这边没用这个成员, 所以可以不使用TD的宏 */ pAmMsg->usDataBitLen = (VOS_UINT16)ulDataLength; pData = TTF_MemBlkCopyAlloc(WUEPS_PID_RABM, TTF_MEM_POOL_ID_UL_RLC_SDU, pucData, (VOS_UINT16)ulLenOct); if ( VOS_NULL_PTR == pData ) { /*释放消息内存:*/ PS_FREE_MSG(WUEPS_PID_RABM, pAmMsg); PS_LOG(WUEPS_PID_RABM, 0, PS_PRINT_ERROR, "NAS_CsDomainDataReq, Error, call TTF_MemCopyAlloc fail\n"); return AS_NO_MEMORY; } pAmMsg->pstDataMem = pData; pMsg = (VOS_VOID *)pAmMsg; break; case WUE_RLC_MODE_BUTT: PS_LOG(WUEPS_PID_RABM, 0, PS_PRINT_WARNING, "NAS_CsDomainDataReq, Error, No Rlc Rb exist\n"); return AS_RB_NO_EXIST; default: PS_LOG(WUEPS_PID_RABM, 0, PS_PRINT_WARNING, "NAS_CsDomainDataReq, Error, Rb Tx Mode error!\n"); return AS_RB_NO_EXIST; } if ( VOS_OK != NAS_UTRANCTRL_SndAsMsg(WUEPS_PID_RABM, (struct MsgCB **)&pMsg) ) { /*发送消息失败,释放申请的零拷贝内存*/ TTF_MemFree(WUEPS_PID_RABM, pData); return AS_SEND_FAILED; } return AS_SUCCESS; }
VOS_VOID CDS_DlProcImsData(CDS_IMS_SDU_STRU *pstImsSdu, const CDS_ENTITY_STRU *pstCdsEntity) { TTF_MEM_ST *pstImsPkt; CDS_DBG_IMS_DL_RX_IMS_PKT_NUM(1); /*如果是非连续内存,则拷贝到连续内存上;否则继续使用原来的内存*/ if (VOS_NULL_PTR == pstImsSdu->pstSdu->pNext) { pstImsPkt = pstImsSdu->pstSdu; } else { pstImsPkt = CDS_TtfMemCopyAlloc(pstImsSdu->pstSdu,pstImsSdu->ulSduLen); TTF_MemFree(UEPS_PID_CDS,pstImsSdu->pstSdu); } if (VOS_NULL_PTR == pstImsPkt) { CDS_ERROR_LOG1(UEPS_PID_CDS,"CDS_DlProcImsData : Copy Alloc Ttf Mem Fail.Len=",pstImsSdu->ulSduLen); CDS_DBG_IMS_DL_ALLOC_MEM_FAIL_NUM(1); return ; } /*保存必要信息*/ CDS_DL_SAVE_LEN_MODEMID_RABID_TO_TTF(pstImsPkt, pstImsPkt->usUsed, pstCdsEntity->usModemId, pstImsSdu->ucRabId); /*抓包*/ CDS_SendIpPacket2PC(pstImsPkt); /*NDCLIENT数据包,发送到NDCLIENT*/ if ((PS_TRUE == CDS_IsImsDefBearer(pstImsSdu->ucRabId,pstCdsEntity)) && (PS_TRUE == CDS_IsNdClientPkt(pstImsPkt))) { CDS_SendNdDataIndMsg(pstImsPkt,pstImsSdu->ucRabId,pstCdsEntity); TTF_MemFree(UEPS_PID_CDS,pstImsPkt); CDS_DBG_IMS_DL_RX_ND_PKT_NUM(1); return; } else if (PS_TRUE == CDS_IsImsUtPkt(pstImsPkt, pstCdsEntity)) { /*更新内存指针*/ pstImsSdu->pstSdu = pstImsPkt; CDS_DlProcImsUtPkt(pstImsSdu,pstCdsEntity); return; } /*发送到IMS NIC*/ if (PS_SUCC != IMS_NIC_DlDataRcv(pstImsPkt->pData, pstImsPkt->usUsed, pstCdsEntity->usModemId)) { TTF_MemFree(UEPS_PID_CDS,pstImsPkt); CDS_DBG_IMS_DL_SEND_TO_NIC_FAIL_NUM(1); return; } /*释放内存*/ TTF_MemFree(UEPS_PID_CDS,pstImsPkt); CDS_DBG_IMS_DL_SEND_TO_NIC_SUCC_NUM(1); return; }
VOS_UINT32 CDS_RxDataFromImsNIC(const VOS_UINT8 *pData, VOS_UINT16 usLen,MODEM_ID_ENUM_UINT16 enModemId) { CDS_ENTITY_STRU *pstCdsEntity; TTF_MEM_ST *pstTtfPkt; VOS_INT32 lLock; CDS_DBG_IMS_UL_RX_FUN_CALL_NUM(1); /*入参判断*/ if (VOS_NULL_PTR == pData) { CDS_ERROR_LOG(UEPS_PID_CDS, "CDS_RxPktFromImsNIC:Input Para is NULL"); CDS_DBG_IMS_UL_RX_FUN_PARA_ERR(1); return PS_FAIL; } if ((0 == usLen) || (usLen > ETH_MAX_MTU)) { CDS_ERROR_LOG1(UEPS_PID_CDS,"CDS_RxPktFromImsNIC ; Packet Length Error.",usLen); CDS_DBG_IMS_UL_RX_FUN_PARA_ERR(1); return PS_FAIL; } pstCdsEntity = CDS_GetCdsEntity(enModemId); if (VOS_NULL_PTR == pstCdsEntity) { CDS_ERROR_LOG1(UEPS_PID_CDS,"CDS_RxPktFromImsNIC ; Modem ID Error.",enModemId); CDS_DBG_IMS_UL_RX_FUN_PARA_ERR(1); return PS_FAIL; } CDS_DBG_IMS_UL_RX_NIC_PKT_NUM(1); /*申请TTF内存,并将其拷贝到TTF内存中*/ pstTtfPkt = CDS_AllocTtfMem(usLen); if (VOS_NULL_PTR == pstTtfPkt) { CDS_ERROR_LOG(UEPS_PID_CDS,"CDS_RxDataFromImsNIC: Alloc Mem Fail."); CDS_DBG_IMS_UL_ALLOC_MEM_FAIL_NUM(1); return PS_FAIL; } PS_MEM_CPY(pstTtfPkt->pData,pData,usLen); /*入队*/ lLock = VOS_SplIMP(); if (PS_SUCC != LUP_EnQue(pstCdsEntity->pstIMSDataQue,pstTtfPkt)) { VOS_Splx(lLock); CDS_DBG_IMS_UL_EN_QUE_FAIL_NUM(1); TTF_MemFree(UEPS_PID_CDS, pstTtfPkt); CDS_SendEventToCds(CDS_EVENT_UL_IMS_PROC); CDS_DBG_IMS_UL_TRIGGER_IMS_EVENT_NUM(1); return PS_FAIL; } VOS_Splx(lLock); CDS_DBG_IMS_UL_EN_QUE_SUCC_NUM(1); /*wakeup cds*/ CDS_SendEventToCds(CDS_EVENT_UL_IMS_PROC); CDS_DBG_IMS_UL_TRIGGER_IMS_EVENT_NUM(1); return PS_SUCC; }
/******************************************************************************* Module: RABM_SaveData Function: 缓存数据 Input: RABM_DATA_SAVE_STRU *pSaveDataPtr 缓存数据的链表指针 VOS_VOID *pMsg 被缓存的数据 VOS_UINT8 ucMsgType 消息类型 Output: VOS_VOID NOTE: Return: VOS_VOID History: 1. 张志勇 2003.12.11 新规作成 *******************************************************************************/ VOS_VOID RABM_SaveData( RABM_DATA_SAVE_STRU *pSaveDataPtr, /* 缓存数据的链表指针 */ VOS_VOID *pMsg, /* 被缓存的数据 */ VOS_UINT8 ucMsgType /* 消息类型 */ ) { RABM_DATA_LINK_STRU *pTemp1 = RABM_POINTER_NULL; RABM_DATA_LINK_STRU *pTemp2 = RABM_POINTER_NULL; VOS_VOID *pSaveMsg = RABM_POINTER_NULL; VOS_UINT32 ulDataLen = 0; if ( RABM_UPLINK == ucMsgType ) { /* 获得上行数据的长度 */ ulDataLen = ((TAFRABM_PS_DATA_REQ_STRU *)pMsg)->MsgHeader.ulLength + VOS_MSG_HEAD_LENGTH; } else { /* 获得下行数据的长度 */ ulDataLen = sizeof(PDCP_RABM_DATA_BUF_STRU); } pSaveMsg = RABM_Malloc(ulDataLen); if(VOS_NULL_PTR == pSaveMsg) { return; } PS_NAS_MEM_CPY(pSaveMsg, pMsg, ulDataLen); /* 获得数据 */ if(0 == pSaveDataPtr->ucNum) { /* 是链表中的第一个数据 */ pSaveDataPtr->Data.pData = pSaveMsg; /* 存储数据消息 */ pSaveDataPtr->Data.pNxt = RABM_POINTER_NULL; /* 初始化链表指针 */ } else if(1 == pSaveDataPtr->ucNum) { pSaveDataPtr->Data.pNxt = (RABM_DATA_LINK_STRU *) RABM_Malloc(sizeof(RABM_DATA_LINK_STRU)); pSaveDataPtr->Data.pNxt->pData = pSaveMsg; /* 存储数据消息 */ pSaveDataPtr->Data.pNxt->pNxt = RABM_POINTER_NULL; } else { pTemp1 = pSaveDataPtr->Data.pNxt; pTemp2 = pTemp1; if(0xff != pSaveDataPtr->ucNum) { for( ; ; ) { /* 查找链表尾 */ if(RABM_POINTER_NULL != pTemp1->pNxt) { pTemp1 = pTemp2->pNxt; } else { break; } pTemp2 = pTemp1; } pTemp1->pNxt = (RABM_DATA_LINK_STRU *) RABM_Malloc(sizeof(RABM_DATA_LINK_STRU)); pTemp1->pNxt->pData = pSaveMsg; /* 存储数据消息 */ pTemp1->pNxt->pNxt = RABM_POINTER_NULL; /* 初始化链表指针 */ } else { /*释放上行数据的零拷贝内存*/ if (RABM_UPLINK == ucMsgType) { TTF_MemFree(WUEPS_PID_RABM, ((TAFRABM_PS_DATA_REQ_STRU *)pMsg)->pData); } RABM_Free(pSaveMsg); return; } } pSaveDataPtr->ucNum++; /* 更新缓存的数据个数 */ }