/***************************************************************************** 函 数 名 : spm_send_laser_ctl_cfg 功能描述 : 组织子卡常用控制命令IPS消息 输入参数 : ATG_DCI_CMD_COMMON_CTRL *pstCommonCtrl NBB_BYTE ucSubCardNo 输出参数 : 无 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2013年8月14日 作 者 : gaos 修改内容 : 新生成函数 *****************************************************************************/ NBB_INT spm_send_laser_ctl_cfg(ATG_DCI_CMD_COMMON_CTRL *pstCommonCtrl, NBB_BYTE ucSubCardNo NBB_CCXT_T NBB_CXT) { NBB_BYTE ucMessage[80]; NBB_INT iRv = 0; ATG_SBI_CMD_COMMON_CTRL *pSbiCommonCtrl; NBB_TRC_ENTRY("spm_send_laser_ctl_cfg"); if (pstCommonCtrl == NULL) { NBB_TRC_DETAIL((NBB_FORMAT " ***ERROR***:spm_send_laser_ctl_cfg(pstCommonCtrl==NULL)")); OS_PRINTF("***ERROR***:spm_send_laser_ctl_cfg(pstCommonCtrl==NULL)\n"); OS_SPRINTF(ucMessage, "***ERROR***:spm_send_laser_ctl_cfg(pstCommonCtrl==NULL)\n"); iRv = ERROR; goto EXIT_LABEL; } if (SHARED.sub_card_cb[ucSubCardNo-1] != NULL) { pSbiCommonCtrl = (ATG_SBI_CMD_COMMON_CTRL*) NBB_GET_BUFFER(NBB_NULL_HANDLE, NBB_ALIGN_OFFSET(sizeof(ATG_SBI_CMD_COMMON_CTRL)), 0, NBB_RETRY_DATA | NBB_BUF_PKT); if (NULL == pSbiCommonCtrl) { NBB_TRC_DETAIL((NBB_FORMAT " ***ERROR***:spm_send_laser_ctl_cfg(pSbiCommonCtrl==NULL)")); OS_PRINTF("***ERROR***:spm_send_laser_ctl_cfg(pSbiCommonCtrl==NULL)\n"); OS_SPRINTF(ucMessage, "***ERROR***:spm_send_laser_ctl_cfg(pSbiCommonCtrl==NULL)\n"); iRv = ERROR; goto EXIT_LABEL; } /*************************************************************************/ /* 初始化消息。 */ /*************************************************************************/ NBB_ZERO_IPS(pSbiCommonCtrl); pSbiCommonCtrl->ips_hdr.ips_type = IPS_ATG_SBI_CMD_COMMON_CTRL; pSbiCommonCtrl->key = 1; OS_MEMCPY(pSbiCommonCtrl->cmd_buffer, pstCommonCtrl->cmd_buffer, sizeof(NBB_BYTE)*ATG_DCI_CMD_MAX_LEN); spm_snd_sbi_ips(SHARED.sub_card_cb[ucSubCardNo-1], pSbiCommonCtrl, &(pSbiCommonCtrl->ips_hdr) NBB_CCXT); } EXIT_LABEL: NBB_TRC_EXIT(); return iRv; }
/***************************************************************************** 函 数 名 : spm_qos_find_classify_cb 功能描述 : 查找classify模板相关配置 输入参数 : classify模板的index 输出参数 : 返 回 值 : 调用函数 : 被调函数 : 修改历史 : 日 期 : 2013年1月15日 星期二 作 者 : zenglu 修改内容 : 新生成函数 *****************************************************************************/ NBB_LONG spm_set_control_que_bandwidth_cfg(NBB_ULONG oper, ATG_DCI_QUEUE_BANDWIDTH *pcb) { /***************************************************************************/ /* Local Variables */ /***************************************************************************/ NBB_LONG ret = ATG_DCI_RC_OK; NBB_CHAR uc_message[QOS_MSG_INFO_LEN]; NBB_TRC_ENTRY(__FUNCTION__); if((ATG_DCI_RC_OK != g_qos_defend_cfg_print) && (NULL != pcb)) { printf("%s %s,line=%d queue_id=%d,cir=%lu,pir=%lu,cbs=%lu,pbs=%lu\n\n", QOS_CFG_STRING,__FUNCTION__,__LINE__,pcb->queue_id, pcb->cir,pcb->pir,pcb->cbs,pcb->pbs); OS_SPRINTF(uc_message,"%s %s,%d queue_id=%d,cir=%lu,pir=%lu,cbs=%lu,pbs=%lu\n\n", QOS_CFG_STRING,__FUNCTION__,__LINE__,pcb->queue_id, pcb->cir,pcb->pir,pcb->cbs,pcb->pbs); BMU_SLOG(BMU_INFO, SPM_QOS_LOG_DIR, uc_message); } if(ATG_DCI_OPER_ADD == oper) { if(NULL == pcb) { printf("%s,%s,line=%d param==NULL\n",QOS_ERROR_STRING,__FUNCTION__,__LINE__); NBB_EXCEPTION((PCT_SPM| QOS_PD, 1, "s d s s s s d d d d", "**QOS ERROR** param==NULL",ATG_DCI_RC_ADD_FAILED, "","","","", 0,0,0,0)); ret = ATG_DCI_RC_ADD_FAILED; goto EXIT_LABEL; } #if defined (SPU) || defined (SRC) ret = ApiAradSetPortQueueCirEir(0,QOS_RCU_PORT,pcb->queue_id,pcb->cir, pcb->pir - pcb->cir, pcb->cbs, pcb->pbs); #endif if(0 != ret) { printf("%s,%s,line=%d ApiAradSetPortQueueCirEir queue_id=%d," "cir=%lu,pir=%lu,cbs=%lu,pbs=%lu,ret=%ld\n", QOS_ERROR_STRING,__FUNCTION__,__LINE__,pcb->queue_id,pcb->cir, pcb->pir,pcb->cbs,pcb->pbs,ret); NBB_EXCEPTION((PCT_SPM| QOS_PD, 1, "s d s s s s d d d d", "**QOS ERROR** ApiAradSetPortQueueCirEir",ret, "queue_id","cir","pir","cbs", pcb->queue_id,pcb->cir,pcb->pir,pcb->cbs)); goto EXIT_LABEL; } } /*异常跳出*/ EXIT_LABEL: NBB_TRC_EXIT(); return ret; }
/** * osGetTaskStatM * */ IEC_UINT osGetTaskStatM(IEC_UDINT ulID, IEC_UDINT *ulpSize, IEC_UDINT *ulpRes) { IEC_UINT uRes = OK; #if defined(RTS_CFG_LINUX) IEC_UDINT hFile = 0; IEC_CHAR szBuff[2048]; IEC_UDINT ulShared, ulText, ulLib, ulData, ulDirty; OS_SPRINTF(szBuff, FILE_PIDSTATM, ulID); uRes = fileOpen(&hFile, szBuff, FIO_MODE_READ, TRUE); if (uRes != OK) { RETURN(uRes); } uRes = fileReadLine(hFile, szBuff, sizeof(szBuff)); if (uRes != OK) { fileClose(hFile); RETURN(uRes); } uRes = fileClose(hFile); /* Overall Size | Resident | Shared | Text (TRS) | Library (LRS) * Data (DRS) | Dirty * (in pages à 4096kb) */ uRes = (IEC_UINT)OS_SSCANF(szBuff, "%u %u %u %u %u %u %u", ulpSize, ulpRes, &ulShared, &ulText, &ulLib, &ulData, &ulDirty); if (uRes < 7) { RETURN(ERR_INVALID_DATA); } uRes = OK; *ulpSize *= 4096; *ulpRes *= 4096; #else *ulpSize = *ulpRes = 0; #endif RETURN(uRes); }
/** * osStrStat * */ IEC_UINT osStrStat(IEC_CHAR *szBuff, IEC_UDINT uLen) { IEC_UINT uRes = OK; SProcTime PT; uRes = osGetStat(&PT); if (uRes != OK) { RETURN(uRes); } OS_SPRINTF(szBuff, "Time: User:%6u Syst:%6u Idle:%6u", PT.ulUser * 10u, PT.ulSyst * 10u, PT.ulIdle * 10u); RETURN(uRes); }
/** * osStrMemInfo * */ IEC_UINT osStrMemInfo(IEC_CHAR *szBuff, IEC_UDINT uLen, IEC_UDINT *ulpMemTotal) { IEC_UINT uRes = OK; IEC_UDINT ulUsed = 0; IEC_UDINT ulFree = 0; uRes = osGetMemInfo(ulpMemTotal, &ulUsed, &ulFree); if (uRes != OK) { RETURN(uRes); } OS_SPRINTF(szBuff, "Memory: Totl:%6u Used:%6u Free:%6u", *ulpMemTotal / 1024u, ulUsed / 1024u, ulFree / 1024u); RETURN(uRes); }
/** * osStrLoadAvg * */ IEC_UINT osStrLoadAvg(IEC_CHAR *szBuff, IEC_UDINT uLen) { IEC_UINT uRes = OK; IEC_REAL f1, f5, f15; IEC_UDINT ulPReady; IEC_UDINT ulPSum; uRes = osGetLoadAvg(&f1, &f5, &f15, &ulPReady, &ulPSum); if (uRes != OK) { RETURN(uRes); } OS_SPRINTF(szBuff, "LoadAVG: 1min:% 6.2f 5min:% 6.2f 15mn:% 6.2f Proc: %2u/%2u", f1, f5, f15, ulPReady, ulPSum); RETURN(uRes); }
/** * osStrTaskStatM * */ IEC_UINT osStrTaskStatM(IEC_UDINT ulID, IEC_CHAR *szBuff, IEC_UDINT uLen, IEC_UDINT ulOveral) { IEC_UINT uRes = OK; IEC_UDINT ulSize; IEC_UDINT ulRes; IEC_UDINT ulLocOveral = ulOveral != 0 ? ulOveral : 1; uRes = osGetTaskStatM(ulID, &ulSize, &ulRes); if (uRes != OK) { RETURN(uRes); } OS_SPRINTF(szBuff, "Memy_%-5u: Totl:%6u Size:% 5.1f%% Phys:% 5.1f%%", ulID, ulSize / 1024, (100.0 * (IEC_REAL)ulSize) / (IEC_REAL)ulLocOveral, (100.0 * (IEC_REAL)ulRes) / (IEC_REAL)ulLocOveral); RETURN(uRes); }
/** * osStrTaskStatDiff * */ IEC_UINT osStrTaskStatDiff(IEC_UDINT ulID, IEC_CHAR *szBuff, IEC_UDINT uLen, IEC_UDINT ulOveral, STaskTime *pTT) { IEC_UINT uRes = OK; STaskTime TT_Diff; IEC_REAL fSum; IEC_REAL fOveral = (IEC_REAL)(ulOveral != 0 ? ulOveral : 1); uRes = osGetTaskStatDiff(ulID, pTT, &TT_Diff); if (uRes != OK) { RETURN(uRes); } fSum = (IEC_REAL)(TT_Diff.ulUser + TT_Diff.ulSyst); OS_SPRINTF(szBuff, "Load_%-5u: User:% 5.1f%% Syst:% 5.1f%% Sum: % 5.1f%%", ulID, (100.0 * (IEC_REAL)TT_Diff.ulUser) / fOveral, (100.0 * (IEC_REAL)TT_Diff.ulSyst) / fOveral, (100.0 * (IEC_REAL)fSum) / fOveral); RETURN(uRes); }
/** * osStrStatDiff * */ IEC_UINT osStrStatDiff(IEC_CHAR *szBuff, IEC_UDINT uLen, IEC_UDINT *ulpOveral, SProcTime *pPT) { IEC_UINT uRes = OK; SProcTime PT_Diff; IEC_REAL fSum; uRes = osGetStatDiff(pPT, &PT_Diff); if (uRes != OK) { RETURN(uRes); } *ulpOveral = PT_Diff.ulUser + PT_Diff.ulNice + PT_Diff.ulSyst + PT_Diff.ulIdle; fSum = (IEC_REAL)(*ulpOveral != 0 ? *ulpOveral : 1); OS_SPRINTF(szBuff, "Load: User:% 5.1f%% Syst:% 5.1f%% Sum: % 5.1f%% Idle:% 5.1f%%", (100.0 * (IEC_REAL)PT_Diff.ulUser) / fSum, (100.0 * (IEC_REAL)PT_Diff.ulSyst) / fSum, (100.0 * (IEC_REAL)(PT_Diff.ulUser + PT_Diff.ulSyst)) / fSum, (100.0 * (IEC_REAL)PT_Diff.ulIdle) / fSum); RETURN(uRes); }
NBB_INT spm_arp_basic_data_proc(ATG_DCI_SET_ARP *pst_set_arp,NBB_ULONG ul_oper_basic, SPM_ARP_CB *pst_arp) { NBB_CHAR uc_message[SPM_MSG_INFO_LEN]; NBB_INT ret = SUCCESS; ATG_DCI_ARP_BASIC_DATA *pst_basic_data = NULL; NBB_BYTE *puc_basic_data_start = NULL; ARP_T stArp; NBB_TRC_ENTRY("spm_vc_basic_data_proc"); if (NULL == pst_set_arp) { return ADD_ARP_BASIC_ARP_IPS_IS_NULL; } if (NULL == pst_arp) { return ADD_ARP_BASIC_ARP_CFG_IS_NULL; } OS_MEMSET(&stArp,0,sizeof(ARP_T)); if(ATG_DCI_OPER_ADD == ul_oper_basic) { /* 计算第一个entry的地址。*/ puc_basic_data_start = (NBB_BYTE *)NTL_OFFLEN_GET_POINTER(pst_set_arp, &pst_set_arp->basic_data); /* 如果指针为NULL,无数据 */ if (puc_basic_data_start == NULL) { return ADD_ARP_BASIC_DATA_START_IS_NULL; } else { pst_basic_data = (ATG_DCI_ARP_BASIC_DATA *)puc_basic_data_start; if (arp_cfg_print_setting == SPM_PRINT_CFG) { printf(" 1)基本配置\n"); spm_dbg_print_arp_basic_cfg(pst_basic_data); } OS_SPRINTF(uc_message, " 1)基本配置\n"); BMU_SLOG(BMU_INFO, SPM_L2_LOG_DIR, uc_message); spm_dbg_record_arp_basic_cfg(pst_basic_data); //先保存配置 if (pst_arp->basic_cfg_cb == NULL) { pst_arp->basic_cfg_cb = (ATG_DCI_ARP_BASIC_DATA *)NBB_MM_ALLOC(sizeof(ATG_DCI_ARP_BASIC_DATA), NBB_NORETRY_ACT, MEM_SPM_ARP_BASIC_CB); if(NULL == pst_arp->basic_cfg_cb) { return ADD_ARP_BASIC_MEM_BASIC_NULL; } } OS_MEMCPY(pst_arp->basic_cfg_cb, pst_basic_data, sizeof(ATG_DCI_ARP_BASIC_DATA)); ret = spm_arp_drv_add_arp(pst_arp); } } return ret; }
/***************************************************************************** 函 数 名 : spm_vpls_basic_proc 功能描述 : VPLS的基本配置处理 输入参数 : ATG_DCI_SET_VPLS *pstSetVpls SPM_VPLS_CB *pst_vpls_cb NBB_ULONG oper_basic 输出参数 : 无 返 回 值 : SUCCESS/ERROR 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2016年1月22日 作 者 : huxl 修改内容 : 新生成函数 *****************************************************************************/ NBB_INT spm_vpls_basic_proc(ATG_DCI_SET_VPLS *pst_set_vpls, SPM_VPLS_CB *pst_vpls_cb, NBB_ULONG oper_basic) { NBB_INT ret = SUCCESS; NBB_BYTE *basic_data_start = NULL; ATG_DCI_VPLS_BASIC_DATA *basic_data = NULL; NBB_CHAR print_message[SPM_MSG_INFO_LEN] = {0}; NBB_ULONG ulMacLearnLimt = 0; NBB_BYTE ucC3Num = 0; NBB_TRC_ENTRY("spm_vpls_basic_proc"); if((NULL == pst_set_vpls) || (NULL == pst_vpls_cb)) { //记录错误信息 ret = JUDGE_VPLS_BASIC_PROC_POINT; goto EXIT_LABEL; } switch(oper_basic) { case ATG_DCI_OPER_DEL: break; case ATG_DCI_OPER_UPDATE: break; case ATG_DCI_OPER_ADD: //基本配置首地址 basic_data_start = (NBB_BYTE *) NTL_OFFLEN_GET_POINTER(pst_set_vpls, &pst_set_vpls->basic_data); if(NULL == basic_data_start) { //记录错误信息 ret = VPLS_BASIC_CFG_NULL; goto EXIT_LABEL; } basic_data = (ATG_DCI_VPLS_BASIC_DATA *)basic_data_start; if (g_vpls_cfg_print_setting == SPM_PRINT_CFG) { printf(" 1)基本配置\n"); spm_dbg_print_vpls_basic_cfg(basic_data); } OS_SPRINTF(print_message," 1)基本配置\n"); BMU_SLOG(BMU_INFO, SPM_L2_LOG_DIR, print_message); spm_dbg_record_vpls_basic_cfg(basic_data); if(NULL == pst_vpls_cb->basic_cfg_cb) { pst_vpls_cb->basic_cfg_cb = (ATG_DCI_VPLS_BASIC_DATA *)NBB_MM_ALLOC(sizeof(ATG_DCI_VPLS_BASIC_DATA), NBB_NORETRY_ACT,MEM_SPM_VPLS_BASIC_CB); if(NULL == pst_vpls_cb->basic_cfg_cb) { //记录错误信息 ret = ALLOC_VPLS_BASIC_MEM_ERR; goto EXIT_LABEL; } } if(NULL != pst_vpls_cb->basic_cfg_cb) { NBB_MEMCPY(pst_vpls_cb->basic_cfg_cb, basic_data, sizeof(ATG_DCI_VPLS_BASIC_DATA)); } ulMacLearnLimt = pst_vpls_cb->basic_cfg_cb->mac_learning_capacity; /*MAC地址容量学习,只在业务盘*/ ret = spm_vpls_mac_learning(pst_vpls_cb->vpls_id_key,ulMacLearnLimt); if(SUCCESS != ret) { ret = SPU_CLEARN_MAC_ERR; goto EXIT_LABEL; } /*使能IGMP*/ ucC3Num = SHARED.c3_num; ret = spm_set_vsi_igmp_enable(pst_vpls_cb->vpls_id_key, ucC3Num, 1); if(SUCCESS != ret) { ret = BASIC_FLAG_ENABLE_IGMP_FAILED;//此处的错误值待定,用以区分具体哪里出错 goto EXIT_LABEL; } break; default: break; } EXIT_LABEL : NBB_TRC_EXIT(); return ret; }
/** * osGetTaskStat * */ IEC_UINT osGetTaskStat(IEC_UDINT ulID, STaskTime *pTT) { IEC_UINT uRes = OK; #if defined(RTS_CFG_LINUX) IEC_UDINT hFile = 0; IEC_CHAR szBuff[2048]; IEC_CHAR szDummy[2048]; IEC_UDINT i; IEC_UDINT j; int d1, d2, d3, d4, d5; unsigned long u1, u2, u3, u4, u5; OS_SPRINTF(szBuff, FILE_PIDSTAT, ulID); uRes = fileOpen(&hFile, szBuff, FIO_MODE_READ, TRUE); if (uRes != OK) { RETURN(uRes); } uRes = fileReadLine(hFile, szBuff, sizeof(szBuff)); if (uRes != OK) { fileClose(hFile); RETURN(uRes); } uRes = fileClose(hFile); for (i = 0; szBuff[i] && szBuff[i] != ')'; i++) { ; } for (j = i; szBuff[j] != '0' && j < i + 3; j++) { ; } /* See /usr/src/linuxXXX/fs/proc/array.c */ uRes = (IEC_UINT)OS_SSCANF(szBuff + j,"%d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %s", &d1, &d2, &d3, &d4, &d5, &u1, &u2, &u3, &u4, &u5, (unsigned long *)&pTT->ulUser, (unsigned long *)&pTT->ulSyst, szDummy); if (uRes < 13) { RETURN(ERR_INVALID_DATA); } uRes = OK; #else OS_MEMSET(pTT, 0x00, sizeof(STaskTime)); #endif RETURN(uRes); }