Path: blob/main/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.h
48524 views
/*1* Copyright 2008-2012 Freescale Semiconductor Inc.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions are met:5* * Redistributions of source code must retain the above copyright6* notice, this list of conditions and the following disclaimer.7* * Redistributions in binary form must reproduce the above copyright8* notice, this list of conditions and the following disclaimer in the9* documentation and/or other materials provided with the distribution.10* * Neither the name of Freescale Semiconductor nor the11* names of its contributors may be used to endorse or promote products12* derived from this software without specific prior written permission.13*14*15* ALTERNATIVELY, this software may be distributed under the terms of the16* GNU General Public License ("GPL") as published by the Free Software17* Foundation, either version 2 of that License or (at your option) any18* later version.19*20* THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY21* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED22* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE23* DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY24* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES25* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;26* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND27* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT28* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS29* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.30*/313233/******************************************************************************34@File fm_cc.h3536@Description FM PCD CC ...37*//***************************************************************************/38#ifndef __FM_CC_H39#define __FM_CC_H4041#include "std_ext.h"42#include "error_ext.h"43#include "list_ext.h"4445#include "fm_pcd.h"464748/***********************************************************************/49/* Coarse classification defines */50/***********************************************************************/5152#define CC_MAX_NUM_OF_KEYS (FM_PCD_MAX_NUM_OF_KEYS + 1)5354#define CC_PC_FF_MACDST 0x0055#define CC_PC_FF_MACSRC 0x0156#define CC_PC_FF_ETYPE 0x025758#define CC_PC_FF_TCI1 0x0359#define CC_PC_FF_TCI2 0x046061#define CC_PC_FF_MPLS1 0x0662#define CC_PC_FF_MPLS_LAST 0x076364#define CC_PC_FF_IPV4DST1 0x0865#define CC_PC_FF_IPV4DST2 0x1666#define CC_PC_FF_IPV4IPTOS_TC1 0x0967#define CC_PC_FF_IPV4IPTOS_TC2 0x1768#define CC_PC_FF_IPV4PTYPE1 0x0A69#define CC_PC_FF_IPV4PTYPE2 0x1870#define CC_PC_FF_IPV4SRC1 0x0b71#define CC_PC_FF_IPV4SRC2 0x1972#define CC_PC_FF_IPV4SRC1_IPV4DST1 0x0c73#define CC_PC_FF_IPV4SRC2_IPV4DST2 0x1a74#define CC_PC_FF_IPV4TTL 0x29757677#define CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1 0x0d /*TODO - CLASS - what is it? TOS*/78#define CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2 0x1b79#define CC_PC_FF_IPV6PTYPE1 0x0e80#define CC_PC_FF_IPV6PTYPE2 0x1c81#define CC_PC_FF_IPV6DST1 0x0f82#define CC_PC_FF_IPV6DST2 0x1d83#define CC_PC_FF_IPV6SRC1 0x1084#define CC_PC_FF_IPV6SRC2 0x1e85#define CC_PC_FF_IPV6HOP_LIMIT 0x2a86#define CC_PC_FF_IPPID 0x2487#define CC_PC_FF_IPDSCP 0x768889#define CC_PC_FF_GREPTYPE 0x119091#define CC_PC_FF_MINENCAP_PTYPE 0x1292#define CC_PC_FF_MINENCAP_IPDST 0x1393#define CC_PC_FF_MINENCAP_IPSRC 0x1494#define CC_PC_FF_MINENCAP_IPSRC_IPDST 0x159596#define CC_PC_FF_L4PSRC 0x1f97#define CC_PC_FF_L4PDST 0x2098#define CC_PC_FF_L4PSRC_L4PDST 0x2199100#define CC_PC_FF_PPPPID 0x05101102#define CC_PC_PR_SHIM1 0x22103#define CC_PC_PR_SHIM2 0x23104105#define CC_PC_GENERIC_WITHOUT_MASK 0x27106#define CC_PC_GENERIC_WITH_MASK 0x28107#define CC_PC_GENERIC_IC_GMASK 0x2B108#define CC_PC_GENERIC_IC_HASH_INDEXED 0x2C109#define CC_PC_GENERIC_IC_AGING_MASK 0x2D110111#define CC_PR_OFFSET 0x25112#define CC_PR_WITHOUT_OFFSET 0x26113114#define CC_PC_PR_ETH_OFFSET 19115#define CC_PC_PR_USER_DEFINED_SHIM1_OFFSET 16116#define CC_PC_PR_USER_DEFINED_SHIM2_OFFSET 17117#define CC_PC_PR_USER_LLC_SNAP_OFFSET 20118#define CC_PC_PR_VLAN1_OFFSET 21119#define CC_PC_PR_VLAN2_OFFSET 22120#define CC_PC_PR_PPPOE_OFFSET 24121#define CC_PC_PR_MPLS1_OFFSET 25122#define CC_PC_PR_MPLS_LAST_OFFSET 26123#define CC_PC_PR_IP1_OFFSET 27124#define CC_PC_PR_IP_LAST_OFFSET 28125#define CC_PC_PR_MINENC_OFFSET 28126#define CC_PC_PR_L4_OFFSET 30127#define CC_PC_PR_GRE_OFFSET 29128#define CC_PC_PR_ETYPE_LAST_OFFSET 23129#define CC_PC_PR_NEXT_HEADER_OFFSET 31130131#define CC_PC_ILLEGAL 0xff132#define CC_SIZE_ILLEGAL 0133134#define FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN 16135#define FM_PCD_CC_AD_TABLE_ALIGN 16136#define FM_PCD_CC_AD_ENTRY_SIZE 16137#define FM_PCD_CC_NUM_OF_KEYS 255138#define FM_PCD_CC_TREE_ADDR_ALIGN 256139140#define FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE 0x00000000141#define FM_PCD_AD_RESULT_DATA_FLOW_TYPE 0x80000000142#define FM_PCD_AD_RESULT_PLCR_DIS 0x20000000143#define FM_PCD_AD_RESULT_EXTENDED_MODE 0x80000000144#define FM_PCD_AD_RESULT_NADEN 0x20000000145#define FM_PCD_AD_RESULT_STATISTICS_EN 0x40000000146147#define FM_PCD_AD_CONT_LOOKUP_TYPE 0x40000000148#define FM_PCD_AD_CONT_LOOKUP_LCL_MASK 0x00800000149150#define FM_PCD_AD_STATS_TYPE 0x40000000151#define FM_PCD_AD_STATS_FLR_ADDR_MASK 0x00FFFFFF152#define FM_PCD_AD_STATS_COUNTERS_ADDR_MASK 0x00FFFFFF153#define FM_PCD_AD_STATS_NEXT_ACTION_MASK 0xFFFF0000154#define FM_PCD_AD_STATS_NEXT_ACTION_SHIFT 12155#define FM_PCD_AD_STATS_NAD_EN 0x00008000156#define FM_PCD_AD_STATS_OP_CODE 0x00000036157#define FM_PCD_AD_STATS_FLR_EN 0x00004000158#define FM_PCD_AD_STATS_COND_EN 0x00002000159160161162#define FM_PCD_AD_BYPASS_TYPE 0xc0000000163164#define FM_PCD_AD_TYPE_MASK 0xc0000000165#define FM_PCD_AD_OPCODE_MASK 0x0000000f166167#define FM_PCD_AD_PROFILEID_FOR_CNTRL_SHIFT 16168#if (DPAA_VERSION >= 11)169#define FM_PCD_AD_RESULT_VSP_SHIFT 24170#define FM_PCD_AD_RESULT_NO_OM_VSPE 0x02000000171#define FM_PCD_AD_RESULT_VSP_MASK 0x3f172#define FM_PCD_AD_NCSPFQIDM_MASK 0x80000000173#endif /* (DPAA_VERSION >= 11) */174175#define GLBL_MASK_FOR_HASH_INDEXED 0xfff00000176#define CC_GLBL_MASK_SIZE 4177#define CC_AGING_MASK_SIZE 4178179typedef uint32_t ccPrivateInfo_t; /**< private info of CC: */180181#define CC_PRIVATE_INFO_NONE 0182#define CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP 0x80000000183#define CC_PRIVATE_INFO_IC_HASH_EXACT_MATCH 0x40000000184#define CC_PRIVATE_INFO_IC_KEY_EXACT_MATCH 0x20000000185#define CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP 0x10000000186187#define CC_BUILD_AGING_MASK(numOfKeys) ((((1LL << ((numOfKeys) + 1)) - 1)) << (31 - (numOfKeys)))188/***********************************************************************/189/* Memory map */190/***********************************************************************/191#if defined(__MWERKS__) && !defined(__GNUC__)192#pragma pack(push,1)193#endif /* defined(__MWERKS__) && ... */194195typedef struct196{197volatile uint32_t fqid;198volatile uint32_t plcrProfile;199volatile uint32_t nia;200volatile uint32_t res;201} t_AdOfTypeResult;202203typedef struct204{205volatile uint32_t ccAdBase;206volatile uint32_t matchTblPtr;207volatile uint32_t pcAndOffsets;208volatile uint32_t gmask;209} t_AdOfTypeContLookup;210211typedef struct212{213volatile uint32_t profileTableAddr;214volatile uint32_t reserved;215volatile uint32_t nextActionIndx;216volatile uint32_t statsTableAddr;217} t_AdOfTypeStats;218219typedef union220{221volatile t_AdOfTypeResult adResult;222volatile t_AdOfTypeContLookup adContLookup;223} t_Ad;224225#if defined(__MWERKS__) && !defined(__GNUC__)226#pragma pack(pop)227#endif /* defined(__MWERKS__) && ... */228229230/***********************************************************************/231/* Driver's internal structures */232/***********************************************************************/233234typedef struct t_FmPcdStatsObj235{236t_Handle h_StatsAd;237t_Handle h_StatsCounters;238t_List node;239} t_FmPcdStatsObj;240241typedef struct242{243uint8_t key[FM_PCD_MAX_SIZE_OF_KEY];244uint8_t mask[FM_PCD_MAX_SIZE_OF_KEY];245246t_FmPcdCcNextEngineParams nextEngineParams;247uint32_t requiredAction;248uint32_t shadowAction;249250t_FmPcdStatsObj *p_StatsObj;251252} t_FmPcdCcKeyAndNextEngineParams;253254typedef struct255{256t_Handle p_Ad;257e_FmPcdEngine fmPcdEngine;258bool adAllocated;259bool isTree;260261uint32_t myInfo;262t_List *h_CcNextNodesLst;263t_Handle h_AdditionalInfo;264t_Handle h_Node;265} t_FmPcdModifyCcAdditionalParams;266267typedef struct268{269t_Handle p_AdTableNew;270t_Handle p_KeysMatchTableNew;271t_Handle p_AdTableOld;272t_Handle p_KeysMatchTableOld;273uint16_t numOfKeys;274t_Handle h_CurrentNode;275uint16_t savedKeyIndex;276t_Handle h_NodeForAdd;277t_Handle h_NodeForRmv;278t_Handle h_ManipForRmv;279t_Handle h_ManipForAdd;280t_FmPcdStatsObj *p_StatsObjForRmv;281#if (DPAA_VERSION >= 11)282t_Handle h_FrmReplicForAdd;283t_Handle h_FrmReplicForRmv;284#endif /* (DPAA_VERSION >= 11) */285bool tree;286287t_FmPcdCcKeyAndNextEngineParams keyAndNextEngineParams[CC_MAX_NUM_OF_KEYS];288} t_FmPcdModifyCcKeyAdditionalParams;289290typedef struct291{292t_Handle h_Manip;293t_Handle h_CcNode;294} t_CcNextEngineInfo;295296typedef struct297{298uint16_t numOfKeys;299uint16_t maxNumOfKeys;300301bool maskSupport;302uint32_t keysMatchTableMaxSize;303304e_FmPcdCcStatsMode statisticsMode;305uint32_t numOfStatsFLRs;306uint32_t countersArraySize;307308bool isHashBucket; /**< Valid for match table node that is a bucket of a hash table only */309t_Handle h_MissStatsCounters; /**< Valid for hash table node and match table that is a bucket;310Holds the statistics counters allocated by the hash table and311are shared by all hash table buckets; */312t_Handle h_PrivMissStatsCounters; /**< Valid for match table node that is a bucket of a hash table only;313Holds the statistics counters that were allocated for this node314and replaced by the shared counters (allocated by the hash table); */315bool statsEnForMiss; /**< Valid for hash table node only; TRUE is statistics are currently316enabled for hash 'miss', FALSE otherwise; This parameter effects the317returned statistics count to user, statistics AD always present for 'miss'318for all hash buckets; */319bool glblMaskUpdated;320t_Handle p_GlblMask;321bool lclMask;322uint8_t parseCode;323uint8_t offset;324uint8_t prsArrayOffset;325bool ctrlFlow;326uint16_t owners;327328uint8_t ccKeySizeAccExtraction;329uint8_t sizeOfExtraction;330uint8_t glblMaskSize;331332t_Handle h_KeysMatchTable;333t_Handle h_AdTable;334t_Handle h_StatsAds;335t_Handle h_TmpAd;336t_Handle h_Ad;337t_Handle h_StatsFLRs;338339t_List availableStatsLst;340341t_List ccPrevNodesLst;342343t_List ccTreeIdLst;344t_List ccTreesLst;345346t_Handle h_FmPcd;347uint32_t shadowAction;348uint8_t userSizeOfExtraction;349uint8_t userOffset;350uint8_t kgHashShift; /* used in hash-table */351352t_Handle h_Spinlock;353354t_FmPcdCcKeyAndNextEngineParams keyAndNextEngineParams[CC_MAX_NUM_OF_KEYS];355} t_FmPcdCcNode;356357typedef struct358{359t_FmPcdCcNode *p_FmPcdCcNode;360bool occupied;361uint16_t owners;362volatile bool lock;363} t_FmPcdCcNodeArray;364365typedef struct366{367uint8_t numOfEntriesInGroup;368uint32_t totalBitsMask;369uint8_t baseGroupEntry;370} t_FmPcdCcGroupParam;371372typedef struct373{374t_Handle h_FmPcd;375uint8_t netEnvId;376uintptr_t ccTreeBaseAddr;377uint8_t numOfGrps;378t_FmPcdCcGroupParam fmPcdGroupParam[FM_PCD_MAX_NUM_OF_CC_GROUPS];379t_List fmPortsLst;380t_FmPcdLock *p_Lock;381uint8_t numOfEntries;382uint16_t owners;383t_Handle h_FmPcdCcSavedManipParams;384bool modifiedState;385uint32_t requiredAction;386t_Handle h_IpReassemblyManip;387t_Handle h_CapwapReassemblyManip;388389t_FmPcdCcKeyAndNextEngineParams keyAndNextEngineParams[FM_PCD_MAX_NUM_OF_CC_GROUPS];390} t_FmPcdCcTree;391392393t_Error FmPcdCcNodeTreeTryLock(t_Handle h_FmPcd,t_Handle h_FmPcdCcNode, t_List *p_List);394void FmPcdCcNodeTreeReleaseLock(t_Handle h_FmPcd, t_List *p_List);395t_Error FmPcdUpdateCcShadow (t_FmPcd *p_FmPcd, uint32_t size, uint32_t align);396397398#endif /* __FM_CC_H */399400401