piqos.c

来自「vt6528芯片交换机API函数和文档运行程序」· C语言 代码 · 共 146 行

C
146
字号
/*
 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
 * All rights reserved.
 *
 * This software is copyrighted by and is the sole property of
 * VIA Networking Technologies, Inc. This software may only be used
 * in accordance with the corresponding license agreement. Any unauthorized
 * use, duplication, transmission, distribution, or disclosure of this
 * software is expressly forbidden.
 *
 * This software is provided by VIA Networking Technologies, Inc. "as is"
 * and any express or implied warranties, including, but not limited to, the
 * implied warranties of merchantability and fitness for a particular purpose
 * are disclaimed. In no event shall VIA Networking Technologies, Inc.
 * be liable for any direct, indirect, incidental, special, exemplary, or
 * consequential damages.
 *
 *
 * File:    pipc_qos.c
 *
 * Purpose: Port control and QoS module shared UI callback functions
 *
 * Author:  Tevin Chen
 *
 * Date:    Jan 08, 2002
 *
 * Functions:
 *
 * Revision History:
 *
 */


#include "str.h"
#include "swport.h"
#include "swqos.h"
#include "piportmp.h"
#include "pigencfg.h"
#include "pieeprom.h"
#include "pidef.h"


/*---------------------  Static Definitions -------------------------*/

/*---------------------  Static Classes  ----------------------------*/

/*---------------------  Static Variables  --------------------------*/

/*---------------------  Static Functions  --------------------------*/

/*---------------------  Export Variables  --------------------------*/

/*---------------------  Export Macros  -----------------------------*/

/*---------------------  Export Functions  --------------------------*/

void PIQOS_vSetEepDefault (SQosPageCfg* pSPageCfg_Qos, BOOL bWriteDefault)
{
    pSPageCfg_Qos->byQosMode = DEFAULT_QOS_MODE;
    pSPageCfg_Qos->w8021pMap = DEFAULT_8021P_MAP;
    
    STR_pvMemset(pSPageCfg_Qos->abyStaticPrior, 0, EEP_SIZE_PORT_QOS); //TOCHECK: remove DEFAULT_STATIC_PRIORITY, set 0  first
    
    if (bWriteDefault) {
        // Set value to nvram software cache.    
        STR_pvMemcpy(g_pu8NVRSwCache + (EEP_ADDR_QOS_CFG - NVR_ADDR_DATA_AREA_START), (PUINT8)pSPageCfg_Qos, EEP_SIZE_QOS_CFG);
    }
    else {
        PIEEP_vSetCfgIntoEep((PUINT8)pSPageCfg_Qos, EEP_ADDR_QOS_CFG, EEP_SIZE_QOS_CFG);
        NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);        
    }
}

void PIQOS_vOp(SQosPageCfg* pSPageCfg_Qos, UINT8 byOp)
{
    UINT32 dwPhyPortMask;
    UINT8 byPhyPID, byLogPortIndex=0;

    for (byLogPortIndex=0; byLogPortIndex<g_byLogIdNum; byLogPortIndex++)
    {
        dwPhyPortMask = PIPORTMP_dwLogPtrToPhyMsk(byLogPortIndex);

        for (byPhyPID=0; byPhyPID<SWITCH_PORT_NUM; byPhyPID++)
        {
            if (dwPhyPortMask & 0x00000001)
            {
                if (byOp == QOS_OP_EEP_TO_BUF)
                {
                    PIEEP_vGetCfgFromEep(EEP_ADDR_PORT_QOS + byPhyPID,
                                         1,
                                         (PUINT8)(pSPageCfg_Qos->abyStaticPrior + byLogPortIndex));
                    break;
                }
                // buf to eep and hw
                else //if ((byOp == QOS_OP_BUF_TO_HW)||(byOp == QOS_OP_BUF_TO_EEP_HW))
                {
                    // set port priority (if QoS is disabled, disable static priority)
                    if (pSPageCfg_Qos->byQosMode == QOS_FCFS)
                        SWQOS_vSetPortPrior(byPhyPID, FALSE, pSPageCfg_Qos->abyStaticPrior[byLogPortIndex]);
                    else{
                    
                        if (pSPageCfg_Qos->abyStaticPrior[byLogPortIndex] == 0) //Disable
                            SWQOS_vSetPortPrior(byPhyPID, FALSE, pSPageCfg_Qos->abyStaticPrior[byLogPortIndex]);
                        else
                            SWQOS_vSetPortPrior(byPhyPID, TRUE, pSPageCfg_Qos->abyStaticPrior[byLogPortIndex] - 1);
                    }


                    if (byOp == QOS_OP_BUF_TO_EEP_HW)
                        STR_pvMemcpy (g_pu8NVRSwCache + (EEP_ADDR_PORT_QOS + byPhyPID - NVR_ADDR_DATA_AREA_START), 
                                (PUINT8)(pSPageCfg_Qos->abyStaticPrior + byLogPortIndex), 1);

                }   // end if byOp
            }   // end if (dwPhyPortMask & 0x00000001)
            dwPhyPortMask >>= 1;
        } // end for byPhyPID
    } // end for byLogPortIndex

    if (byOp == QOS_OP_EEP_TO_BUF)
    {
        // get qos cfg
        PIEEP_vGetCfgFromEep(EEP_ADDR_MISC_QOS, EEP_SIZE_MISC_QOS, (PUINT8)pSPageCfg_Qos);
    }
    else // if ((byOp == QOS_OP_BUF_TO_HW)||(byOp == QOS_OP_BUF_TO_EEP_HW))
    {
        if (pSPageCfg_Qos->byQosMode >= QOS_WRR){
            SWQOS_vSetQosCfg(QOS_WRR);
            SWQOS_vSetOutQueWght(pSPageCfg_Qos->byQosMode-QOS_WRR);
        }
        else
            SWQOS_vSetQosCfg(pSPageCfg_Qos->byQosMode);

        SWQOS_vSet8021pPriorMap(pSPageCfg_Qos->w8021pMap);
    }


    if (byOp == QOS_OP_BUF_TO_EEP_HW)
    {
        PIEEP_vSetCfgIntoEep (g_pu8NVRSwCache + (EEP_ADDR_PORT_QOS - NVR_ADDR_DATA_AREA_START),
                EEP_ADDR_PORT_QOS,
                EEP_SIZE_PORT_QOS);
        PIEEP_vSetCfgIntoEep((PUINT8)pSPageCfg_Qos, EEP_ADDR_MISC_QOS, EEP_SIZE_MISC_QOS);
        NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?