⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swl2ptb.h

📁 vt6528芯片交换机API函数和文档运行程序
💻 H
字号:
/*
 * 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:    swl2ptb.h
 *
 * Purpose: L2+ table operation functions
 *
 * Author:  Henry Lin
 *
 * Date:    Dec 10, 2004
 *
 */


#ifndef __SWL2PTB_H__
#define __SWL2PTB_H__

#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__CCONFIG_H__)
#include "cconfig.h"
#endif




/*---------------------  Export Definitions  ------------------------*/
// L2+ action code table
#define L2PAC_BIT_L2PAC_VID_S           0
#define L2PAC_BIT_L2PAC_VID_E           12
#define L2PAC_ACTCODE_BIT_VID_TYPE_S    12
#define L2PAC_ACTCODE_BIT_VID_TYPE_E    12
#define L2PAC_BIT_PRI_CFG_S             13
#define L2PAC_BIT_PRI_CFG_E             15
#define L2PAC_BIT_REDIR_PORT_IDX_S      16
#define L2PAC_BIT_REDIR_PORT_IDX_E      25
#define L2PAC_BIT_REDIR_TYPE_S          26
#define L2PAC_BIT_REDIR_TYPE_E          26
#define L2PAC_BIT_REDIR_EN_S            27
#define L2PAC_BIT_REDIR_EN_E            27
#define L2PAC_BIT_PRI_VALID_S           28
#define L2PAC_BIT_PRI_VALID_E           28
#define L2PAC_BIT_MIRR_EN_S             29
#define L2PAC_BIT_MIRR_EN_E             29
#define L2PAC_BIT_FILT_EN_S             30
#define L2PAC_BIT_FILT_EN_E             30
#define L2PAC_BIT_SECU_DROP_S           31
#define L2PAC_BIT_SECU_DROP_E           31
#define L2PAC_BIT_BINDING_ID_S          32
#define L2PAC_BIT_BINDING_ID_E          39
#define L2PAC_BIT_OVERR_TAG_S           40
#define L2PAC_BIT_OVERR_TAG_E           41
#define L2PAC_BIT_L2PVID_VALID_S        42
#define L2PAC_BIT_L2PVID_VALID_E        42


// TCAM value table
//  for IPv4
#define TCAM_BIT_IPOPT_S                0
#define TCAM_BIT_IPOPT_E                31
#define TCAM_BIT_DSTIP_S                32
#define TCAM_BIT_DSTIP_E                63
#define TCAM_BIT_SRCIP_S                64
#define TCAM_BIT_SRCIP_E                95
#define TCAM_BIT_IPPRO_S                96
#define TCAM_BIT_IPPRO_E                103
//  for not IPv4
#define TCAM_BIT_AFT_SV_S               0
#define TCAM_BIT_AFT_SV_E               103

#define TCAM_BIT_SRC_ID_S               104
#define TCAM_BIT_SRC_ID_E               108
#define TCAM_BIT_IPFRG_S                109
#define TCAM_BIT_IPFRG_E                109
#define TCAM_BIT_IPLEN_S                110
#define TCAM_BIT_IPLEN_E                110
#define TCAM_BIT_IPV4_S                 111
#define TCAM_BIT_IPV4_E                 111
#define TCAM_BIT_VID_S                  112
#define TCAM_BIT_VID_E                  123
#define TCAM_BIT_VLAN_TYPE_S            124
#define TCAM_BIT_VLAN_TYPE_E            124
#define TCAM_BIT_TCP_SYN_S              125
#define TCAM_BIT_TCP_SYN_E              125
#define TCAM_BIT_DMAC_TYPE_S            126
#define TCAM_BIT_DMAC_TYPE_E            127

// L2+ hit counters table
#define L2PCNTER_BIT_PKTCNT_S           0   
#define L2PCNTER_BIT_PKTCNT_E           31      
#define L2PCNTER_BIT_OCTCNT_S           32
#define L2PCNTER_BIT_OCTCNT_E           68


//Type of TCAM mask
#define MSK_DMAC_TYPE                   0x0001
#define MSK_TCP_SYN                     0x0002
#define MSK_VLAN_TYPE                   0x0004
#define MSK_VID                         0x0008
#define MSK_IPV4                        0x0010
#define MSK_IPV4_LEN                    0x0020
#define MSK_IP_FRG                      0x0040
#define MSK_PORT_ID                     0x0080
#define MSK_IP_PROTO                    0x0100  // only uses by Ipv4
#define MSK_SRC_IP                      0x0200  // only uses by Ipv4
#define MSK_DST_IP                      0x0400  // only uses by Ipv4
#define MSK_L4                          0x0800  // only uses by Ipv4

#define L2_BPTN_VALID                   0x01    //bit[0] and bit[64]
#define AFT_SV_BYTE_NUM                 13 

/*---------------------  Export Types  ------------------------------*/
// L2+ action code entry structure       
struct tagSL2pACEntry {
    BOOL    bL2pVidValid;
    UINT8   u8OverTag;
    UINT8   u8BindId;
    BOOL    bSecDrop;
    BOOL    bFilter;
    BOOL    bMirror;
    BOOL    bPriValid;
    BOOL    bRedirEn;
    BOOL    bRedirType;
    UINT16  u16RedirPortIndx;   // Src port ID/multicast mask
    UINT8   u8Pri;
    UINT16  u16L2pVid;
};

typedef struct tagSL2pACEntry SL2pACEntry;

// TCAM table entry structure       

//IPv4 field in T-CAM value entry
__PACKED struct tagSIpv4Fld {
    UINT8   u8IpProto;
    UINT32  u32SrcIp;
    UINT32  u32DstIp;
    UINT32  u32IpOption;    //if TCP/UDP, is source and destination port number
#if __PAD_ALGN_3
    UINT8    byPadA[__PAD_ALGN_3];
#endif
} __PACKED_GCC;

struct tagSTcamEntry {
    UINT8   u8DmacType;
    BOOL    bTcpSynBit;
    BOOL    bVlanTag;
    UINT16  u16Vid;
    BOOL    bIpv4;
    BOOL    bIpHd20Oct;
    BOOL    bIpFrag;
    UINT8   u8PortId;

    union{
        struct tagSIpv4Fld  SIpv4Fld;
        UINT8   au8AftSV[AFT_SV_BYTE_NUM];
    }UCfg13B;
};

typedef struct tagSTcamEntry STcamEntry;

// L2+ rule hit counters
struct tagSL2pHitCnt {
    UINT8   au8HitOctCnt[5];
    UINT32  u32HitPktCnt;
};

typedef struct tagSL2pHitCnt SL2pHitCnt;

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

/*---------------------  Export Classes  ----------------------------*/

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

/*---------------------  Export Functions  --------------------------*/
BOOL SWL2PTB_bIsEntryValidByIndex(UINT8 u8EntryIdx);
void SWL2PTB_vSetEntryInValidByIndex(UINT8 u8EntryIdx);
UINT16 SWL2PTB_u16FindEmptyEntry(void);

BOOL SWTCAM_bGetEntry(UINT8 u8EntryIdx, STcamEntry* pSEntry, BOOL bMaskTbl);
BOOL SWTCAM_bInsEntry(UINT8 u8EntryIdx, STcamEntry* pSEntry, BOOL bMaskTbl);
BOOL SWTCAM_bDelEntry(UINT8 u8EntryIdx);
void SWTCAM_vMskEntry(STcamEntry* pSEntry, BOOL bIsIpv4, UINT16 u16Type, UINT16 u16ByteMsk);
void SWTCAM_vUnMskEntry(STcamEntry* pSEntry, BOOL bIsIpv4, UINT16 u16Type, UINT16 u16ByteMsk);


BOOL SWL2PAC_bGetEntry(UINT8 u8EntryIdx, SL2pACEntry* pSEntry);
BOOL SWL2PAC_bInsEntry(UINT8 u8EntryIdx, SL2pACEntry* pSEntry);

BOOL SWL2PCNT_bGetCnt(UINT8 u8EntryIdx, SL2pHitCnt* pSEntry);
BOOL SWL2PCNT_bClrCnt(UINT8 u8EntryIdx);


void SWL2P_vGetMirPort(PUINT8 pbyPortId, PBOOL pbEnable);
void SWL2P_vSetMirPort(UINT8 byPortId, BOOL bEnable);

//For analyzer use(Debug use)
BOOL SWL2PTB_bIsEntryValid(UINT32 u32Addr);
void SWL2PTB_vSetEntryValid(UINT32 u32Addr);
void SWL2PTB_vSetEntryInValid(UINT32 u32Addr);
BOOL SWL2PCNT_bClrCntByAddr(UINT32 u32Addr);

#endif // __SWL2TB_H__


⌨️ 快捷键说明

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