VOS_VOID  TAF_APS_SaveDsFlowInfoToNv( VOS_VOID )
{
    TAF_APS_DSFLOW_STATS_CTX_STRU      *pstApsDsFlowCtx;
    TAF_APS_DSFLOW_NV_STRU              stApsDsflowNv;
    TAF_DSFLOW_QUERY_INFO_STRU          stDsFlowQryInfo;

    /* 初始化 */
    pstApsDsFlowCtx = TAF_APS_GetDsFlowCtxAddr();
    PS_MEM_SET(&stApsDsflowNv, 0, sizeof(TAF_APS_DSFLOW_NV_STRU));
    PS_MEM_SET(&stDsFlowQryInfo, 0, sizeof(TAF_DSFLOW_QUERY_INFO_STRU));

    if (VOS_TRUE == pstApsDsFlowCtx->ucApsDsFlowSave2NvFlg)
    {

        /* 获取历史流量信息项 */
        TAF_APS_QryAllRabDsFlowStats(&stDsFlowQryInfo);

        /* 刷新流量信息相关NV项 */
        stApsDsflowNv.ulDSLastLinkTime          = stDsFlowQryInfo.stCurrentFlowInfo.ulDSLinkTime;
        stApsDsflowNv.ulDSTotalLinkTime         = stDsFlowQryInfo.stTotalFlowInfo.ulDSLinkTime;
        stApsDsflowNv.ulDSTotalReceiveFluxHigh  = stDsFlowQryInfo.stTotalFlowInfo.ulDSReceiveFluxHigh;
        stApsDsflowNv.ulDSTotalReceiveFluxLow   = stDsFlowQryInfo.stTotalFlowInfo.ulDSReceiveFluxLow;
        stApsDsflowNv.ulDSTotalSendFluxHigh     = stDsFlowQryInfo.stTotalFlowInfo.ulDSSendFluxHigh;
        stApsDsflowNv.ulDSTotalSendFluxLow      = stDsFlowQryInfo.stTotalFlowInfo.ulDSSendFluxLow;

        /* 写NV项 */
        if (NV_OK != NV_Write(en_NV_Item_DSFLOW_REPORT, &stApsDsflowNv, sizeof(TAF_APS_DSFLOW_NV_STRU)))
        {
            TAF_ERROR_LOG(WUEPS_PID_TAF, "TAF_APS_SaveDsFlowInfoToNv: Write NVIM Failed");
        }
    }
    else
    {
        TAF_NORMAL_LOG(WUEPS_PID_TAF, "TAF_APS_SaveDsFlowInfoToNv: Save2NvFlg is not set.");
    }

    return;
}
VOS_VOID TAF_APS_ProcApDsFlowRpt(VOS_VOID)
{
    TAF_APS_DSFLOW_STATS_CTX_STRU      *pstDsflowCtx = VOS_NULL_PTR;
    TAF_APDSFLOW_REPORT_STRU            stApDsFlowRptInfo;
    TAF_DSFLOW_REPORT_STRU              stTotalDsFlowRptInfo;
    TAF_DSFLOW_QUERY_INFO_STRU          stDsFlowQryInfo;
    TAF_CTRL_STRU                       stCtrlHdr;
    VOS_UINT32                          ulTotalFluxThresHigh;
    VOS_UINT32                          ulTotalFluxThresLow;
    VOS_UINT32                          ulTotalFluxHigh;
    VOS_UINT32                          ulTotalFluxLow;
    VOS_UINT32                          ulResult;

    PS_MEM_SET(&stApDsFlowRptInfo, 0x00, sizeof(TAF_APDSFLOW_REPORT_STRU));
    PS_MEM_SET(&stTotalDsFlowRptInfo, 0x00, sizeof(TAF_DSFLOW_REPORT_STRU));
    PS_MEM_SET(&stDsFlowQryInfo, 0x00, sizeof(TAF_DSFLOW_QUERY_INFO_STRU));

    pstDsflowCtx = TAF_APS_GetDsFlowCtxAddr();

    if (VOS_TRUE == pstDsflowCtx->ulFluxThresRptFlg)
    {
        /* 查询所有激活RAB承载的上报流量信息 */
        TAF_APS_QryAllRabDsFlowReportInfo(&stTotalDsFlowRptInfo);

        /* 查询所有RAB承载的流量信息 */
        TAF_APS_QryAllRabDsFlowStats(&stDsFlowQryInfo);

        /* 累计上下行流量 */
        TAF_APS_BIT64_ADD(ulTotalFluxHigh,
                          ulTotalFluxLow,
                          stDsFlowQryInfo.stTotalFlowInfo.ulDSReceiveFluxHigh,
                          stDsFlowQryInfo.stTotalFlowInfo.ulDSReceiveFluxLow,
                          stDsFlowQryInfo.stTotalFlowInfo.ulDSSendFluxHigh,
                          stDsFlowQryInfo.stTotalFlowInfo.ulDSSendFluxLow);

        /* 计算累计流量上报阈值 */
        TAF_APS_BIT64_ADD(ulTotalFluxThresHigh,
                          ulTotalFluxThresLow,
                          pstDsflowCtx->ulTotalFluxHigh,
                          pstDsflowCtx->ulTotalFluxLow,
                          pstDsflowCtx->ulFluxThresHigh,
                          pstDsflowCtx->ulFluxThresLow);

        /* 检查是否达到流量上报阈值 */
        TAF_APS_BIT64_COMPARE(ulTotalFluxHigh,
                              ulTotalFluxLow,
                              ulTotalFluxThresHigh,
                              ulTotalFluxThresLow,
                              ulResult);

        if ((TAF_APS_BIT64_GREAT == ulResult) || (TAF_APS_BIT64_EQUAL == ulResult))
        {
            /* 更新累计流量 */
            pstDsflowCtx->ulTotalFluxHigh       = ulTotalFluxHigh;
            pstDsflowCtx->ulTotalFluxLow        = ulTotalFluxLow;

            /* 填写控制头 */
            TAF_APS_CFG_AT_EVT_CTRL_HDR(&stCtrlHdr, MN_CLIENT_ID_BROADCAST, 0);

            /* 填写事件内容 */
            stApDsFlowRptInfo.ulCurrentTxRate   = stTotalDsFlowRptInfo.ulCurrentSendRate;
            stApDsFlowRptInfo.ulCurrentRxRate   = stTotalDsFlowRptInfo.ulCurrentReceiveRate;
            stApDsFlowRptInfo.stCurrentFlowInfo = stTotalDsFlowRptInfo.stCurrentFlowInfo;
            stApDsFlowRptInfo.stTotalFlowInfo   = stDsFlowQryInfo.stTotalFlowInfo;

            /* 流量阈值上报 */
            TAF_APS_SndApDsFlowRptInd(&stCtrlHdr, &stApDsFlowRptInfo);
        }
    }

    return;
}