VOS_VOID ADS_UL_UpdateQueueInPdpDeactived( VOS_UINT8 ucInstanceIndex, VOS_UINT8 ucRabId ) { VOS_UINT32 i; VOS_UINT32 ulIndex; ADS_UL_CTX_STRU *pstAdsUlCtx; pstAdsUlCtx = ADS_GetUlCtx(ucInstanceIndex); /* 根据删除的PDP索引,将其后面的元素向前移动一位 */ ulIndex = ADS_UL_GetInsertIndex(ucInstanceIndex, ucRabId); if (ulIndex >= ADS_RAB_NUM_MAX) { return; } for (i = ulIndex; i < ADS_RAB_NUM_MAX - 1; i++) { pstAdsUlCtx->aucPrioIndex[i] = pstAdsUlCtx->aucPrioIndex[i + 1]; } pstAdsUlCtx->aucPrioIndex[ADS_RAB_NUM_MAX - 1] = ADS_RAB_ID_INVALID; }
VOS_VOID ADS_UL_OrderQueueIndex( VOS_UINT8 ucInstanceIndex, VOS_UINT8 ucIndex ) { VOS_UINT32 i; VOS_UINT32 j; ADS_UL_CTX_STRU *pstAdsUlCtx; pstAdsUlCtx = ADS_GetUlCtx(ucInstanceIndex); /* 如果该PDP的优先级比较高,需要插入到其他PDP的前面,比其优先级低的需要向后移一位 */ for (i = 0; i < ADS_RAB_NUM_MAX; i++) { if (pstAdsUlCtx->astAdsUlQueue[ucIndex].enPrio < pstAdsUlCtx->astAdsUlQueue[pstAdsUlCtx->aucPrioIndex[i]].enPrio) { for (j = ADS_RAB_NUM_MAX - 1; j > i; j--) { pstAdsUlCtx->aucPrioIndex[j] = pstAdsUlCtx->aucPrioIndex[j - 1]; } pstAdsUlCtx->aucPrioIndex[i] = ucIndex; break; } } }
VOS_VOID ADS_UL_UpdateQueueInPdpModified( VOS_UINT8 ucInstanceIndex, ADS_QCI_TYPE_ENUM_UINT8 enPrio, VOS_UINT8 ucRabId ) { VOS_UINT32 i; VOS_UINT32 ulIndex; ADS_UL_CTX_STRU *pstAdsUlCtx; pstAdsUlCtx = ADS_GetUlCtx(ucInstanceIndex); /* 将修改的优先级更新到对于的队列管理中 */ pstAdsUlCtx->astAdsUlQueue[ucRabId].enPrio = enPrio; /* 获取修改的RABID在aucPrioIndex数组中位置 */ ulIndex = ADS_UL_GetInsertIndex(ucInstanceIndex, ucRabId); /* 没有找到,则不做处理 */ if (ulIndex >= ADS_RAB_NUM_MAX) { return; } /* 先将修改对应位后面的向前移动一位 */ for (i = ulIndex; i < ADS_RAB_NUM_MAX - 1; i++) { pstAdsUlCtx->aucPrioIndex[i] = pstAdsUlCtx->aucPrioIndex[i + 1]; } pstAdsUlCtx->aucPrioIndex[ADS_RAB_NUM_MAX - 1] = ADS_RAB_ID_INVALID; /* 移动后相当于是重新插入到队列管理中 */ ADS_UL_OrderQueueIndex(ucInstanceIndex, ucRabId); }
VOS_UINT32 ADS_UL_CreateQueue( VOS_UINT8 ucInstanceIndex, VOS_UINT8 ucRabId, ADS_QCI_TYPE_ENUM_UINT8 enPrio, ADS_CDS_IPF_PKT_TYPE_ENUM_UINT8 enPktType ) { IMM_ZC_HEAD_STRU *pstUlQueue; ADS_UL_CTX_STRU *pstAdsUlCtx; pstAdsUlCtx = ADS_GetUlCtx(ucInstanceIndex); /* RabId的队列已经存在 */ if (VOS_OK == ADS_UL_IsQueueExistent(ucInstanceIndex, ucRabId)) { /* 对应的调度优先级也一样或者是比之前的要低,不更新QCI直接返回OK */ if (enPrio >= pstAdsUlCtx->astAdsUlQueue[ucRabId].enPrio) { return VOS_OK; } /* 如果对应的调度优先级比之前的要高,需要更新该PDP的队列优先级,并对队列管理进行排序 */ else { ADS_UL_UpdateQueueInPdpModified(ucInstanceIndex, enPrio, ucRabId); return VOS_OK; } } /* ucRabID的队列不存在, 需要创建队列头结点 */ pstUlQueue = (IMM_ZC_HEAD_STRU *)PS_MEM_ALLOC(ACPU_PID_ADS_UL, sizeof(IMM_ZC_HEAD_STRU)); if (VOS_NULL_PTR == pstUlQueue) { ADS_ERROR_LOG(ACPU_PID_ADS_UL, "ADS_UL_CreateQueue: pstUlQueue is null"); return VOS_ERR; } /* 队列初始化 */ IMM_ZcQueueHeadInit(pstUlQueue); /* 将队列信息更新到上行上下文 */ ADS_UL_SetQueue(ucInstanceIndex, ucRabId, VOS_TRUE, pstUlQueue, enPrio, enPktType); /* 队列不可能被用尽,一个RABID对应一个队列,而无效的已经在消息处理处屏蔽, 故不需要判断是否满,可以直接重新排序 */ ADS_UL_OrderQueueIndex(ucInstanceIndex, ucRabId); /*lint -e429*/ return VOS_OK; /*lint +e429*/ }
VOS_UINT32 ADS_UL_RcvCdsClearDataInd(MsgBlock *pMsg) { VOS_UINT8 ucRabId; ADS_UL_CTX_STRU *pstAdsUlCtx; CDS_ADS_CLEAR_DATA_IND_STRU *pstClearData; VOS_UINT8 ucInstanceIndex; pstClearData = (CDS_ADS_CLEAR_DATA_IND_STRU *)pMsg; /* AT接口修改后,获取此值 */ ucInstanceIndex = (VOS_UINT8)pstClearData->enModemId; pstAdsUlCtx = ADS_GetUlCtx(ucInstanceIndex); ucRabId = pstClearData->ucRabId; if (CDS_ADS_ALL_RABID == pstClearData->ucRabId) { for (ucRabId = ADS_RAB_ID_MIN; ucRabId <= ADS_RAB_ID_MAX; ucRabId++) { if (VOS_OK == ADS_UL_IsQueueExistent(ucInstanceIndex, ucRabId)) { /* 销毁队列中的数据 */ ADS_UL_ClearQueue(ucRabId, pstAdsUlCtx->astAdsUlQueue[ucRabId].pstAdsUlLink); } } } else { /* 判断RabId是否为有效值 */ if (VOS_OK == ADS_IsValidRabId(pstClearData->ucRabId)) { /* 结点存在,但队列不存在 */ if (VOS_OK == ADS_UL_IsQueueExistent(ucInstanceIndex, pstClearData->ucRabId)) { /* 销毁队列中的数据 */ ADS_UL_ClearQueue(ucRabId, pstAdsUlCtx->astAdsUlQueue[ucRabId].pstAdsUlLink); } else { ADS_WARNING_LOG(ACPU_PID_ADS_UL, "ADS_UL_RcvCdsClearDataInd:Queue is not exist"); } } else { ADS_WARNING_LOG1(ACPU_PID_ADS_UL, "ADS_UL_RcvCdsClearDataInd: Invalid RabId is", pstClearData->ucRabId); } } /* 回复ID_CDS_ADS_CLEAR_DATA_RSP消息 */ ADS_UL_SendCdsClearDataRsp(pstClearData->enModemId, pstClearData->ucRabId); return VOS_OK; }
VOS_UINT32 ADS_UL_GetInsertIndex( VOS_UINT8 ucInstanceIndex, VOS_UINT8 ucRabId ) { VOS_UINT32 i; ADS_UL_CTX_STRU *pstAdsUlCtx; pstAdsUlCtx = ADS_GetUlCtx(ucInstanceIndex); /* 根据优先级来获取上行上下文中队列的Index值 */ for (i = 0; i < ADS_RAB_NUM_MAX; i++) { if (pstAdsUlCtx->aucPrioIndex[i] == ucRabId) { break; } } return i; }
/***************************************************************************** 函 数 名 : ADS_UL_CheckAllQueueEmpty 功能描述 : 所有的PDP都去激活,队列为空 输入参数 : VOS_UINT8 ucInstanceIndex 输出参数 : 无 返 回 值 : VOS_UINT32 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2012年8月31日 作 者 : l60609 修改内容 : 新生成函数 2.日 期 : 2012年11月24日 作 者 : l60609 修改内容 : DSDA Phase II:双实例 *****************************************************************************/ VOS_UINT32 ADS_UL_CheckAllQueueEmpty(VOS_UINT8 ucInstanceIndex) { VOS_UINT32 i; ADS_UL_CTX_STRU *pstAdsUlCtx = VOS_NULL_PTR; pstAdsUlCtx = ADS_GetUlCtx(ucInstanceIndex); for (i = ADS_RAB_ID_MIN; i < ADS_RAB_ID_MAX + 1; i++) { if (VOS_FALSE != pstAdsUlCtx->astAdsUlQueue[i].ucIsQueueValid) { break; } } /* 所有的PDP都去激活 */ if ((ADS_RAB_ID_MAX + 1) != i) { return VOS_FALSE; } return VOS_TRUE; }
IMM_ZC_STRU* ADS_UL_GetInstanceNextQueueNode( VOS_UINT8 ucInstanceIndex, VOS_UINT8 *pucRabId ) { VOS_UINT32 i; VOS_UINT8 *pucCurIndex; ADS_UL_CTX_STRU *pstAdsUlCtx; IMM_ZC_STRU *pstNode; pstAdsUlCtx = ADS_GetUlCtx(ucInstanceIndex); pucCurIndex = &pstAdsUlCtx->ucAdsUlCurIndex; pstNode = VOS_NULL_PTR; /* 优先级方式 */ for (i = 0; i < ADS_RAB_NUM_MAX; i++) { /* 因为队列已经有序,当前队列无效则代表后面所有队列都无效 需跳过后面所有无效队列,继续从头查找 */ if (VOS_NULL_PTR == ADS_UL_GET_QUEUE_LINK_INFO(ucInstanceIndex, *pucCurIndex)) { i += ADS_RAB_NUM_MAX - (*pucCurIndex + 1U); *pucCurIndex = 0; continue; } /* 队列为有效队列但无数据时,继续向后查找 */ if (0 == ADS_UL_GET_QUEUE_LINK_INFO(ucInstanceIndex, *pucCurIndex)->qlen) { /* 发送下一个队列的数据时,将本队列记录数清空 */ ADS_UL_CLR_RECORD_NUM_IN_WEIGHTED(ucInstanceIndex, *pucCurIndex); *pucCurIndex = (*pucCurIndex + 1) % ADS_RAB_NUM_MAX; continue; } /* 当前队列不允许发送, 继续向后查找 */ if (VOS_FALSE == ADS_UL_GET_RAB_SND_PERMIT_FLAG(ucInstanceIndex, ADS_UL_GET_PRIO_QUEUE_INDEX(ucInstanceIndex, *pucCurIndex))) { *pucCurIndex = (*pucCurIndex + 1) % ADS_RAB_NUM_MAX; continue; } /* 根据优先级等级对应的加权数发送数据 */ /* 优先级高的先发送 */ if (ADS_UL_GET_RECORD_NUM_IN_WEIGHTED(ucInstanceIndex, *pucCurIndex) < ADS_UL_GET_QUEUE_PRI_WEIGHTED_NUM(ucInstanceIndex, *pucCurIndex)) { /* 获取队列头结点 */ pstNode = IMM_ZcDequeueHead(ADS_UL_GET_QUEUE_LINK_INFO(ucInstanceIndex, *pucCurIndex)); /* 获取该结点的RabId */ *pucRabId = ADS_UL_GET_PRIO_QUEUE_INDEX(ucInstanceIndex, *pucCurIndex); /* 本队列记录数增加 1*/ ADS_UL_SET_RECORD_NUM_IN_WEIGHTED(ucInstanceIndex, *pucCurIndex, 1); /* 如果已经发送完本队列的优先级加权数个数的数据,则跳到下个队列发送数据 */ if (ADS_UL_GET_RECORD_NUM_IN_WEIGHTED(ucInstanceIndex, *pucCurIndex) == ADS_UL_GET_QUEUE_PRI_WEIGHTED_NUM(ucInstanceIndex, *pucCurIndex)) { /* 发送下一个队列的数据时,将本队列记录数清空 */ ADS_UL_CLR_RECORD_NUM_IN_WEIGHTED(ucInstanceIndex, *pucCurIndex); *pucCurIndex = (*pucCurIndex + 1) % ADS_RAB_NUM_MAX; } break; } } return pstNode; }