VOS_VOID ADS_UL_RcvTiRptStatsInfoExpired( VOS_UINT32 ulTimerName, VOS_UINT32 ulParam ) { ADS_LOG_RPT_STATS_INFO_STRU *pstMsg = VOS_NULL_PTR; /* 将记录的统计信息通过SDT消息勾出来 */ pstMsg = (ADS_LOG_RPT_STATS_INFO_STRU*)PS_MEM_ALLOC(ACPU_PID_ADS_UL, sizeof(ADS_LOG_RPT_STATS_INFO_STRU)); if (VOS_NULL_PTR == pstMsg) { ADS_ERROR_LOG(ACPU_PID_ADS_UL, "ADS_UL_RcvTiRptStatsInfoExpired: ERROR:Alloc Mem Fail"); return; } PS_MEM_SET(pstMsg, 0, sizeof(ADS_LOG_RPT_STATS_INFO_STRU)); pstMsg->stLogHeader.ulReceiverCpuId = VOS_LOCAL_CPUID; pstMsg->stLogHeader.ulSenderCpuId = VOS_LOCAL_CPUID; pstMsg->stLogHeader.ulSenderPid = ACPU_PID_ADS_UL; pstMsg->stLogHeader.ulReceiverPid = ACPU_PID_ADS_UL; pstMsg->stLogHeader.ulLength = sizeof(ADS_LOG_RPT_STATS_INFO_STRU) - VOS_MSG_HEAD_LENGTH;; pstMsg->stLogHeader.enMsgId = ID_ADS_LOG_RPT_STATS_INFO; PS_MEM_CPY(&pstMsg->stAdsStats, &g_stAdsStats, sizeof(g_stAdsStats)); OM_AcpuTraceMsgHook(pstMsg); PS_MEM_FREE(ACPU_PID_ADS_UL, pstMsg); /* 重新启动上报统计信息定时器 */ ADS_StartTimer(ACPU_PID_ADS_UL, ulTimerName, TI_ADS_RPT_STATS_LEN); return ; }
VOS_VOID ADS_UL_RcvTiDsFlowStatsExpired( VOS_UINT32 ulTimerName, VOS_UINT32 ulParam ) { VOS_UINT32 ulTaBytes; VOS_UINT32 ulRate; VOS_UINT8 ucInstance; ucInstance = ADS_INSTANCE_INDEX_0; /* 根据ulTimerName获取实例index */ if (TI_ADS_DSFLOW_STATS_0 != ulTimerName) { ucInstance = (ucInstance + 1) % ADS_INSTANCE_MAX_NUM; } /* 如果没有上行队列存在, 无需统计流量 */ if (VOS_FALSE == ADS_UL_IsAnyQueueExist(ucInstance)) { ADS_NORMAL_LOG(ACPU_PID_ADS_DL, "ADS_UL_RcvTiDsFlowStatsExpired: no queue is exist!"); return; } /* 获取2秒的下行数据个数 */ ulTaBytes = ADS_GET_DL_PERIOD_PKT_NUM(ucInstance); /* 每2秒钟计算一次,单位为:byte/s */ ulRate = ulTaBytes>>1; ADS_SET_CURRENT_DL_RATE(ucInstance, ulRate); /* 获取2秒的上行流量 */ ulTaBytes = ADS_GET_UL_PERIOD_PKT_NUM(ucInstance); /* 每2秒钟计算一次,单位为:byte/s */ ulRate = ulTaBytes>>1; ADS_SET_CURRENT_UL_RATE(ucInstance, ulRate); /* 每个流量统计周期结束后,需要将周期统计Byte数清除 */ ADS_CLEAR_UL_PERIOD_PKT_NUM(ucInstance); ADS_CLEAR_DL_PERIOD_PKT_NUM(ucInstance); /* 启动流量统计定时器*/ ADS_StartTimer(ACPU_PID_ADS_UL, ulTimerName, TI_ADS_DSFLOW_STATS_LEN); return ; }
VOS_VOID ADS_UL_StartRptStatsInfoTimer( VOS_UINT8 ucInstance, VOS_UINT8 ucRabId ) { /* 如果上行队列存在, 则启动上报统计信息定时器 */ if (VOS_OK == ADS_UL_IsQueueExistent(ucInstance, ucRabId)) { ADS_StartTimer(ACPU_PID_ADS_UL, TI_ADS_RPT_STATS_INFO, TI_ADS_RPT_STATS_LEN); } return; }
VOS_VOID ADS_UL_StartDsFlowStats( VOS_UINT8 ucInstance, VOS_UINT8 ucRabId ) { /* 如果上行队列存在, 则启动流量统计定时器 */ if (VOS_OK == ADS_UL_IsQueueExistent(ucInstance, ucRabId)) { ADS_StartTimer(ACPU_PID_ADS_UL, ADS_GET_DSFLOW_TMR_ID(ucInstance), TI_ADS_DSFLOW_STATS_LEN); } return; }
VOS_VOID ADS_UL_RcvTiDataStatExpired( VOS_UINT32 ulTimerName, VOS_UINT32 ulParam ) { VOS_UINT32 ulStatPktNum; ulStatPktNum = ADS_UL_GET_STAT_PKT_NUM(); /* 根据数据包个数调整赞包门限 */ if (ulStatPktNum < ADS_UL_GET_WATER_LEVEL_ONE()) { ADS_UL_SET_SEND_DATA_NUM_THREDHOLD(ADS_UL_DATA_THRESHOLD_ONE); ADS_DBG_UL_LEVEL_ONE_CNT(1); } else if (ulStatPktNum < ADS_UL_GET_WATER_LEVEL_TWO()) { ADS_UL_SET_SEND_DATA_NUM_THREDHOLD(ADS_UL_DATA_THRESHOLD_TWO); ADS_DBG_UL_LEVEL_TWO_CNT(1); } else if (ulStatPktNum < ADS_UL_GET_WATER_LEVEL_THREE()) { ADS_UL_SET_SEND_DATA_NUM_THREDHOLD(ADS_UL_DATA_THRESHOLD_THREE); ADS_DBG_UL_LEVEL_THREE_CNT(1); } else { ADS_UL_SET_SEND_DATA_NUM_THREDHOLD(ADS_UL_DATA_THRESHOLD_FOUR); ADS_DBG_UL_LEVEL_FOUR_CNT(1); } /* 100ms内没有数据包则该定时器不再启动 */ if (0 != ulStatPktNum) { /* 重新启动上行统计定时器 */ ADS_StartTimer(ACPU_PID_ADS_UL, TI_ADS_UL_DATA_STAT, ADS_UL_GET_STAT_TIMER_LEN()); } /* 清空统计包的个数 */ ADS_UL_CLR_STAT_PKT_NUM(); return; }
VOS_UINT32 ADS_UL_InsertQueue( VOS_UINT8 ucInstanceIndex, IMM_ZC_STRU *pstData, VOS_UINT8 ucRabId ) { VOS_UINT32 ulNonEmptyEvent; VOS_UINT32 ulAllUlQueueDataNum; #if(FEATURE_OFF == FEATURE_SKB_EXP) VOS_UINT ulQueueLen; #endif VOS_ULONG ulLockLevel; ulNonEmptyEvent = VOS_FALSE; /* 此接口不释放pstData,由上层模块根据函数返回值判断是否需要释放内存 */ /* 判断RabId是否为有效值 */ if (VOS_OK != ADS_IsValidRabId(ucRabId)) { ADS_WARNING_LOG1(ACPU_PID_ADS_UL, "ADS_UL_InsertQueue: ucRabId is", ucRabId); return VOS_ERR; } /* 队列加锁 */ /*lint -e571*/ VOS_SpinLockIntLock(ADS_UL_GET_QUEUE_LINK_SPINLOCK(ucInstanceIndex, ucRabId), ulLockLevel); /*lint +e571*/ /* 结点存在,但队列不存在 */ if (VOS_OK != ADS_UL_IsQueueExistent(ucInstanceIndex, ucRabId)) { /* 队列操作完成解锁 */ VOS_SpinUnlockIntUnlock(ADS_UL_GET_QUEUE_LINK_SPINLOCK(ucInstanceIndex, ucRabId), ulLockLevel); ADS_WARNING_LOG(ACPU_PID_ADS_UL, "ADS_UL_InsertQueue:the queue is not ext!"); return VOS_ERR; } #if(FEATURE_OFF == FEATURE_SKB_EXP) ulQueueLen = IMM_ZcQueueLen(ADS_UL_GET_QUEUE_LINK_PTR(ucInstanceIndex, ucRabId)); if (ulQueueLen >= ADS_UL_GET_MAX_QUEUE_LENGTH(ucInstanceIndex)) { /* 队列操作完成解锁 */ VOS_SpinUnlockIntUnlock(ADS_UL_GET_QUEUE_LINK_SPINLOCK(ucInstanceIndex, ucRabId), ulLockLevel); ADS_DBG_UL_DROPPED_PACKET_NUM(1); return VOS_ERR; } /* 插入队列前将数据打上时间戳 */ pstData->tstamp.tv64 = (VOS_INT64)VOS_GetSlice(); #endif /* 插入队列 */ IMM_ZcQueueTail(ADS_UL_GET_QUEUE_LINK_PTR(ucInstanceIndex, ucRabId), pstData); /* 队列由空变为非空 */ if (1 == IMM_ZcQueueLen(ADS_UL_GET_QUEUE_LINK_PTR(ucInstanceIndex, ucRabId))) { ulNonEmptyEvent = VOS_TRUE; } /* 队列操作完成解锁 */ VOS_SpinUnlockIntUnlock(ADS_UL_GET_QUEUE_LINK_SPINLOCK(ucInstanceIndex, ucRabId), ulLockLevel); ulAllUlQueueDataNum = ADS_UL_GetAllQueueDataNum(); #if(FEATURE_OFF == FEATURE_SKB_EXP) if (VOS_TRUE == ADS_UL_GET_THRESHOLD_ACTIVE_FLAG()) { /* (1).jiffies超时,则直接触发发数,并停止发数定时器 (2).队列中数据已到攒包门限且当前没有在处理数据,触发上行缓存缓存处理事件 (3).队列由空变为非空时启动数据统计定时器以及保护定时器 */ ADS_UL_ADD_STAT_PKT_NUM(1); /* 超时长度为非零则需要启动触发发数 */ if (0 != ADS_UL_GET_JIFFIES_EXP_TMR_LEN()) { if (ADS_TIME_AFTER_EQ(ADS_GET_CURR_KERNEL_TIME(), (ADS_UL_GET_JIFFIES_TMR_CNT() + ADS_UL_GET_JIFFIES_EXP_TMR_LEN()))) { ADS_UL_SndEvent(ADS_UL_EVENT_DATA_PROC); ADS_StopTimer(ACPU_PID_ADS_UL, TI_ADS_UL_SEND, ADS_TIMER_STOP_CAUSE_USER); ADS_UL_SET_JIFFIES_TMR_CNT(ADS_GET_CURR_KERNEL_TIME()); return VOS_OK; } } if (ADS_UL_IS_REACH_THRESHOLD_DYNAMIC(ulAllUlQueueDataNum, ADS_UL_GET_SENDING_FLAG())) { ADS_UL_SndEvent(ADS_UL_EVENT_DATA_PROC); } /* 队列由空变为非空 */ if (VOS_TRUE == ulNonEmptyEvent) { ADS_StartTimer(ACPU_PID_ADS_UL, TI_ADS_UL_DATA_STAT, ADS_UL_GET_STAT_TIMER_LEN()); ADS_StartTimer(ACPU_PID_ADS_UL, TI_ADS_UL_SEND, ADS_UL_GET_PROTECT_TIMER_LEN()); } } else { /* (1).队列由空变为非空时触发上行缓存处理事件 (2).队列中数据已到攒包门限的整数倍且当前没有在处理数据 触发上行缓存缓存处理事件 */ if (VOS_TRUE == ulNonEmptyEvent) { ADS_UL_SndEvent(ADS_UL_EVENT_DATA_PROC); } else { if (ADS_UL_IS_REACH_THRESHOLD(ulAllUlQueueDataNum, ADS_UL_GET_SENDING_FLAG())) { ADS_UL_SndEvent(ADS_UL_EVENT_DATA_PROC); } } } #else /* (1).从TCP/IP协议栈过来的的数据,ucTailPktInd为0. 当队列由空到非空, 或是达到攒包门限且当前没有在数据处理时触发上行缓存处理事件. (2).USB过来的数据非最后一个包ucTailPktInd为2,最后一个包ucTailPktInd为1 当为最后一个IP包, 或是达到攒包门限且当前没有在数据处理时触发上行缓存处理事件. */ if (0 == pstData->private_mem.ucTailPktInd) { if ((VOS_TRUE == ulNonEmptyEvent) || (ADS_UL_IS_REACH_THRESHOLD(ulAllUlQueueDataNum, ADS_UL_GET_SENDING_FLAG()))) { ADS_UL_SndEvent(ADS_UL_EVENT_DATA_PROC); } } else { if ((1 == pstData->private_mem.ucTailPktInd) || (ADS_UL_IS_REACH_THRESHOLD(ulAllUlQueueDataNum, ADS_UL_GET_SENDING_FLAG()))) { ADS_UL_SndEvent(ADS_UL_EVENT_DATA_PROC); } } #endif return VOS_OK; }
VOS_VOID ADS_UL_ProcLinkData(VOS_VOID) { VOS_UINT32 ulAllUlQueueDataNum; VOS_UINT32 ulIpfUlBdNum; VOS_UINT32 ulSndBdNum; /* 判断当前是否允许发送,如果不允许发送,直接退出 */ if ((VOS_FALSE == ADS_UL_GET_MODEM_SND_PERMIT_FLAG(ADS_INSTANCE_INDEX_0)) && (VOS_FALSE == ADS_UL_GET_MODEM_SND_PERMIT_FLAG((ADS_INSTANCE_INDEX_0 + 1) % ADS_INSTANCE_MAX_NUM))) { ADS_NORMAL_LOG(ACPU_PID_ADS_UL, "ADS_UL_ProcLinkData: not permit send!"); return; } /* 处理队列时中的数据 */ for (;;) { /* 获取上行可以发送的BD数。 */ #if(FEATURE_OFF == FEATURE_SKB_EXP) ulIpfUlBdNum = BSP_IPF_GetUlDescNum(); #else ulIpfUlBdNum = BSP_IPF_GetUlBDNum(); #endif if (0 == ulIpfUlBdNum) { ADS_DBG_UL_CFG_IPF_HAVE_NO_BDCD(1); /* 设置发送结束标志 */ ADS_UL_SET_SENDING_FLAG(VOS_FALSE); /* 启动定时器退出 */ ADS_StartTimer(ACPU_PID_ADS_UL, TI_ADS_UL_SEND, ADS_UL_GET_PROTECT_TIMER_LEN()); break; } /* 设置正在发送标志 */ ADS_UL_SET_SENDING_FLAG(VOS_TRUE); /* 获取当前所有队列中的数据包个数 */ ulAllUlQueueDataNum = ADS_UL_GetAllQueueDataNum(); /* 计算当前可发送的BD数目 */ ulSndBdNum = PS_MIN(ulIpfUlBdNum, ulAllUlQueueDataNum); #if(FEATURE_OFF == FEATURE_SKB_EXP) ADS_UL_FreeIpfUlConfigSuccSrcMem(); #endif /* 配置BD,写入IPF */ ADS_UL_ConfigBD(ulSndBdNum); /* 获取当前所有队列中的数据包个数 */ ulAllUlQueueDataNum = ADS_UL_GetAllQueueDataNum(); /* 当前队列中没有数据,退出,等待下次队列由空变为非空处理 */ if (0 == ulAllUlQueueDataNum) { /* 设置发送结束标志 */ ADS_UL_SET_SENDING_FLAG(VOS_FALSE); break; } /* 当前队列中有数据,但是需要继续攒包 */ else if (ulAllUlQueueDataNum <= ADS_UL_SEND_DATA_NUM_THREDHOLD) { ADS_StartTimer(ACPU_PID_ADS_UL, TI_ADS_UL_SEND, ADS_UL_GET_PROTECT_TIMER_LEN()); /* 设置发送结束标志 */ ADS_UL_SET_SENDING_FLAG(VOS_FALSE); break; } else { continue; } } return; }