Path: blob/main/sys/contrib/ncsw/Peripherals/FM/Pcd/fm_cc.c
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.c3536@Description FM Coarse Classifier implementation37*//***************************************************************************/38#include <sys/cdefs.h>39#include <sys/endian.h>40#include "std_ext.h"41#include "error_ext.h"42#include "string_ext.h"43#include "debug_ext.h"44#include "fm_pcd_ext.h"45#include "fm_muram_ext.h"4647#include "fm_common.h"48#include "fm_pcd.h"49#include "fm_hc.h"50#include "fm_cc.h"51#include "crc64.h"5253/****************************************/54/* static functions */55/****************************************/565758static t_Error CcRootTryLock(t_Handle h_FmPcdCcTree)59{60t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;6162ASSERT_COND(h_FmPcdCcTree);6364if (FmPcdLockTryLock(p_FmPcdCcTree->p_Lock))65return E_OK;6667return ERROR_CODE(E_BUSY);68}6970static void CcRootReleaseLock(t_Handle h_FmPcdCcTree)71{72t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;7374ASSERT_COND(h_FmPcdCcTree);7576FmPcdLockUnlock(p_FmPcdCcTree->p_Lock);77}7879static void UpdateNodeOwner(t_FmPcdCcNode *p_CcNode, bool add)80{81uint32_t intFlags;8283ASSERT_COND(p_CcNode);8485intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);8687if (add)88p_CcNode->owners++;89else90{91ASSERT_COND(p_CcNode->owners);92p_CcNode->owners--;93}9495XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);96}9798static __inline__ t_FmPcdStatsObj* DequeueStatsObj(t_List *p_List)99{100t_FmPcdStatsObj *p_StatsObj = NULL;101t_List *p_Next;102103if (!NCSW_LIST_IsEmpty(p_List))104{105p_Next = NCSW_LIST_FIRST(p_List);106p_StatsObj = NCSW_LIST_OBJECT(p_Next, t_FmPcdStatsObj, node);107ASSERT_COND(p_StatsObj);108NCSW_LIST_DelAndInit(p_Next);109}110111return p_StatsObj;112}113114static __inline__ void EnqueueStatsObj(t_List *p_List,115t_FmPcdStatsObj *p_StatsObj)116{117NCSW_LIST_AddToTail(&p_StatsObj->node, p_List);118}119120static void FreeStatObjects(t_List *p_List, t_Handle h_FmMuram)121{122t_FmPcdStatsObj *p_StatsObj;123124while (!NCSW_LIST_IsEmpty(p_List))125{126p_StatsObj = DequeueStatsObj(p_List);127ASSERT_COND(p_StatsObj);128129FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsAd);130FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsCounters);131132XX_Free(p_StatsObj);133}134}135136static t_FmPcdStatsObj* GetStatsObj(t_FmPcdCcNode *p_CcNode)137{138t_FmPcdStatsObj* p_StatsObj;139t_Handle h_FmMuram;140141ASSERT_COND(p_CcNode);142143/* If 'maxNumOfKeys' was passed, all statistics object were preallocated144upon node initialization */145if (p_CcNode->maxNumOfKeys)146{147p_StatsObj = DequeueStatsObj(&p_CcNode->availableStatsLst);148}149else150{151h_FmMuram = ((t_FmPcd *)(p_CcNode->h_FmPcd))->h_FmMuram;152ASSERT_COND(h_FmMuram);153154p_StatsObj = XX_Malloc(sizeof(t_FmPcdStatsObj));155if (!p_StatsObj)156{157REPORT_ERROR(MAJOR, E_NO_MEMORY, ("statistics object"));158return NULL;159}160161p_StatsObj->h_StatsAd = (t_Handle)FM_MURAM_AllocMem(162h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE, FM_PCD_CC_AD_TABLE_ALIGN);163if (!p_StatsObj->h_StatsAd)164{165XX_Free(p_StatsObj);166REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for statistics ADs"));167return NULL;168}169MemSet8(p_StatsObj->h_StatsAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);170171p_StatsObj->h_StatsCounters = (t_Handle)FM_MURAM_AllocMem(172h_FmMuram, p_CcNode->countersArraySize,173FM_PCD_CC_AD_TABLE_ALIGN);174if (!p_StatsObj->h_StatsCounters)175{176FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsAd);177XX_Free(p_StatsObj);178REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for statistics counters"));179return NULL;180}181MemSet8(p_StatsObj->h_StatsCounters, 0, p_CcNode->countersArraySize);182}183184return p_StatsObj;185}186187static void PutStatsObj(t_FmPcdCcNode *p_CcNode, t_FmPcdStatsObj *p_StatsObj)188{189t_Handle h_FmMuram;190191ASSERT_COND(p_CcNode);192ASSERT_COND(p_StatsObj);193194/* If 'maxNumOfKeys' was passed, all statistics object were preallocated195upon node initialization and now will be enqueued back to the list */196if (p_CcNode->maxNumOfKeys)197{198/* Nullify counters */199MemSet8(p_StatsObj->h_StatsCounters, 0, p_CcNode->countersArraySize);200201EnqueueStatsObj(&p_CcNode->availableStatsLst, p_StatsObj);202}203else204{205h_FmMuram = ((t_FmPcd *)(p_CcNode->h_FmPcd))->h_FmMuram;206ASSERT_COND(h_FmMuram);207208FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsAd);209FM_MURAM_FreeMem(h_FmMuram, p_StatsObj->h_StatsCounters);210211XX_Free(p_StatsObj);212}213}214215static void SetStatsCounters(t_AdOfTypeStats *p_StatsAd,216uint32_t statsCountersAddr)217{218uint32_t tmp = (statsCountersAddr & FM_PCD_AD_STATS_COUNTERS_ADDR_MASK);219220WRITE_UINT32(p_StatsAd->statsTableAddr, tmp);221}222223224static void UpdateStatsAd(t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,225t_Handle h_Ad, uint64_t physicalMuramBase)226{227t_AdOfTypeStats *p_StatsAd;228uint32_t statsCountersAddr, nextActionAddr, tmp;229#if (DPAA_VERSION >= 11)230uint32_t frameLengthRangesAddr;231#endif /* (DPAA_VERSION >= 11) */232233p_StatsAd = (t_AdOfTypeStats *)p_FmPcdCcStatsParams->h_StatsAd;234235tmp = FM_PCD_AD_STATS_TYPE;236237#if (DPAA_VERSION >= 11)238if (p_FmPcdCcStatsParams->h_StatsFLRs)239{240frameLengthRangesAddr = (uint32_t)((XX_VirtToPhys(241p_FmPcdCcStatsParams->h_StatsFLRs) - physicalMuramBase));242tmp |= (frameLengthRangesAddr & FM_PCD_AD_STATS_FLR_ADDR_MASK);243}244#endif /* (DPAA_VERSION >= 11) */245WRITE_UINT32(p_StatsAd->profileTableAddr, tmp);246247nextActionAddr = (uint32_t)((XX_VirtToPhys(h_Ad) - physicalMuramBase));248tmp = 0;249tmp |= (uint32_t)((nextActionAddr << FM_PCD_AD_STATS_NEXT_ACTION_SHIFT)250& FM_PCD_AD_STATS_NEXT_ACTION_MASK);251tmp |= (FM_PCD_AD_STATS_NAD_EN | FM_PCD_AD_STATS_OP_CODE);252253#if (DPAA_VERSION >= 11)254if (p_FmPcdCcStatsParams->h_StatsFLRs)255tmp |= FM_PCD_AD_STATS_FLR_EN;256#endif /* (DPAA_VERSION >= 11) */257258WRITE_UINT32(p_StatsAd->nextActionIndx, tmp);259260statsCountersAddr = (uint32_t)((XX_VirtToPhys(261p_FmPcdCcStatsParams->h_StatsCounters) - physicalMuramBase));262SetStatsCounters(p_StatsAd, statsCountersAddr);263}264265static void FillAdOfTypeContLookup(t_Handle h_Ad,266t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,267t_Handle h_FmPcd, t_Handle p_CcNode,268t_Handle h_Manip, t_Handle h_FrmReplic)269{270t_FmPcdCcNode *p_Node = (t_FmPcdCcNode *)p_CcNode;271t_AdOfTypeContLookup *p_AdContLookup = (t_AdOfTypeContLookup *)h_Ad;272t_Handle h_TmpAd;273t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;274uint32_t tmpReg32;275t_Handle p_AdNewPtr = NULL;276277UNUSED(h_Manip);278UNUSED(h_FrmReplic);279280/* there are 3 cases handled in this routine of building a "Continue lookup" type AD.281* Case 1: No Manip. The action descriptor is built within the match table.282* p_AdResult = p_AdNewPtr;283* Case 2: Manip exists. A new AD is created - p_AdNewPtr. It is initialized284* either in the FmPcdManipUpdateAdResultForCc routine or it was already285* initialized and returned here.286* p_AdResult (within the match table) will be initialized after287* this routine returns and point to the existing AD.288* Case 3: Manip exists. The action descriptor is built within the match table.289* FmPcdManipUpdateAdContLookupForCc returns a NULL p_AdNewPtr.290*/291292/* As default, the "new" ptr is the current one. i.e. the content of the result293* AD will be written into the match table itself (case (1))*/294p_AdNewPtr = p_AdContLookup;295296/* Initialize an action descriptor, if current statistics mode requires an Ad */297if (p_FmPcdCcStatsParams)298{299ASSERT_COND(p_FmPcdCcStatsParams->h_StatsAd);300ASSERT_COND(p_FmPcdCcStatsParams->h_StatsCounters);301302/* Swapping addresses between statistics Ad and the current lookup AD */303h_TmpAd = p_FmPcdCcStatsParams->h_StatsAd;304p_FmPcdCcStatsParams->h_StatsAd = h_Ad;305h_Ad = h_TmpAd;306307p_AdNewPtr = h_Ad;308p_AdContLookup = h_Ad;309310/* Init statistics Ad and connect current lookup AD as 'next action' from statistics Ad */311UpdateStatsAd(p_FmPcdCcStatsParams, h_Ad, p_FmPcd->physicalMuramBase);312}313314#if DPAA_VERSION >= 11315if (h_Manip && h_FrmReplic)316FmPcdManipUpdateAdContLookupForCc(317h_Manip,318h_Ad,319&p_AdNewPtr,320(uint32_t)((XX_VirtToPhys(321FrmReplicGroupGetSourceTableDescriptor(h_FrmReplic))322- p_FmPcd->physicalMuramBase)));323else324if (h_FrmReplic)325FrmReplicGroupUpdateAd(h_FrmReplic, h_Ad, &p_AdNewPtr);326else327#endif /* (DPAA_VERSION >= 11) */328if (h_Manip)329FmPcdManipUpdateAdContLookupForCc(330h_Manip,331h_Ad,332&p_AdNewPtr,333334#ifdef FM_CAPWAP_SUPPORT335/*no check for opcode of manip - this step can be reached only with capwap_applic_specific*/336(uint32_t)((XX_VirtToPhys(p_Node->h_AdTable) - p_FmPcd->physicalMuramBase))337#else /* not FM_CAPWAP_SUPPORT */338(uint32_t)((XX_VirtToPhys(p_Node->h_Ad)339- p_FmPcd->physicalMuramBase))340#endif /* not FM_CAPWAP_SUPPORT */341);342343/* if (p_AdNewPtr = NULL) --> Done. (case (3)) */344if (p_AdNewPtr)345{346/* cases (1) & (2) */347tmpReg32 = 0;348tmpReg32 |= FM_PCD_AD_CONT_LOOKUP_TYPE;349tmpReg32 |=350p_Node->sizeOfExtraction ? ((p_Node->sizeOfExtraction - 1) << 24) :3510;352tmpReg32 |= (uint32_t)(XX_VirtToPhys(p_Node->h_AdTable)353- p_FmPcd->physicalMuramBase);354WRITE_UINT32(p_AdContLookup->ccAdBase, tmpReg32);355356tmpReg32 = 0;357tmpReg32 |= p_Node->numOfKeys << 24;358tmpReg32 |= (p_Node->lclMask ? FM_PCD_AD_CONT_LOOKUP_LCL_MASK : 0);359tmpReg32 |=360p_Node->h_KeysMatchTable ? (uint32_t)(XX_VirtToPhys(361p_Node->h_KeysMatchTable) - p_FmPcd->physicalMuramBase) :3620;363WRITE_UINT32(p_AdContLookup->matchTblPtr, tmpReg32);364365tmpReg32 = 0;366tmpReg32 |= p_Node->prsArrayOffset << 24;367tmpReg32 |= p_Node->offset << 16;368tmpReg32 |= p_Node->parseCode;369WRITE_UINT32(p_AdContLookup->pcAndOffsets, tmpReg32);370371MemCpy8((void*)&p_AdContLookup->gmask, p_Node->p_GlblMask,372CC_GLBL_MASK_SIZE);373}374}375376static t_Error AllocAndFillAdForContLookupManip(t_Handle h_CcNode)377{378t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;379uint32_t intFlags;380381ASSERT_COND(p_CcNode);382383intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);384385if (!p_CcNode->h_Ad)386{387if (p_CcNode->maxNumOfKeys)388p_CcNode->h_Ad = p_CcNode->h_TmpAd;389else390p_CcNode->h_Ad = (t_Handle)FM_MURAM_AllocMem(391((t_FmPcd *)(p_CcNode->h_FmPcd))->h_FmMuram,392FM_PCD_CC_AD_ENTRY_SIZE, FM_PCD_CC_AD_TABLE_ALIGN);393394XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);395396if (!p_CcNode->h_Ad)397RETURN_ERROR(MAJOR, E_NO_MEMORY,398("MURAM allocation for CC action descriptor"));399400MemSet8(p_CcNode->h_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);401402FillAdOfTypeContLookup(p_CcNode->h_Ad, NULL, p_CcNode->h_FmPcd,403p_CcNode, NULL, NULL);404}405else406XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);407408return E_OK;409}410411static t_Error SetRequiredAction1(412t_Handle h_FmPcd, uint32_t requiredAction,413t_FmPcdCcKeyAndNextEngineParams *p_CcKeyAndNextEngineParamsTmp,414t_Handle h_AdTmp, uint16_t numOfEntries, t_Handle h_Tree)415{416t_AdOfTypeResult *p_AdTmp = (t_AdOfTypeResult *)h_AdTmp;417uint32_t tmpReg32;418t_Error err;419t_FmPcdCcNode *p_CcNode;420int i = 0;421uint16_t tmp = 0;422uint16_t profileId;423uint8_t relativeSchemeId, physicalSchemeId;424t_CcNodeInformation ccNodeInfo;425426for (i = 0; i < numOfEntries; i++)427{428if (i == 0)429h_AdTmp = PTR_MOVE(h_AdTmp, i*FM_PCD_CC_AD_ENTRY_SIZE);430else431h_AdTmp = PTR_MOVE(h_AdTmp, FM_PCD_CC_AD_ENTRY_SIZE);432433switch (p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.nextEngine)434{435case (e_FM_PCD_CC):436if (requiredAction)437{438p_CcNode =439p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.ccParams.h_CcNode;440ASSERT_COND(p_CcNode);441if (p_CcNode->shadowAction == requiredAction)442break;443if ((requiredAction & UPDATE_CC_WITH_TREE)444&& !(p_CcNode->shadowAction & UPDATE_CC_WITH_TREE))445{446447memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));448ccNodeInfo.h_CcNode = h_Tree;449EnqueueNodeInfoToRelevantLst(&p_CcNode->ccTreesLst,450&ccNodeInfo, NULL);451p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=452UPDATE_CC_WITH_TREE;453}454if ((requiredAction & UPDATE_CC_SHADOW_CLEAR)455&& !(p_CcNode->shadowAction & UPDATE_CC_SHADOW_CLEAR))456{457458p_CcNode->shadowAction = 0;459}460461if ((requiredAction & UPDATE_CC_WITH_DELETE_TREE)462&& !(p_CcNode->shadowAction463& UPDATE_CC_WITH_DELETE_TREE))464{465DequeueNodeInfoFromRelevantLst(&p_CcNode->ccTreesLst,466h_Tree, NULL);467p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=468UPDATE_CC_WITH_DELETE_TREE;469}470if (p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine471!= e_FM_PCD_INVALID)472tmp = (uint8_t)(p_CcNode->numOfKeys + 1);473else474tmp = p_CcNode->numOfKeys;475err = SetRequiredAction1(h_FmPcd, requiredAction,476p_CcNode->keyAndNextEngineParams,477p_CcNode->h_AdTable, tmp, h_Tree);478if (err != E_OK)479return err;480if (requiredAction != UPDATE_CC_SHADOW_CLEAR)481p_CcNode->shadowAction |= requiredAction;482}483break;484485case (e_FM_PCD_KG):486if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)487&& !(p_CcKeyAndNextEngineParamsTmp[i].shadowAction488& UPDATE_NIA_ENQ_WITHOUT_DMA))489{490physicalSchemeId =491FmPcdKgGetSchemeId(492p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.kgParams.h_DirectScheme);493relativeSchemeId = FmPcdKgGetRelativeSchemeId(494h_FmPcd, physicalSchemeId);495if (relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)496RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);497if (!FmPcdKgIsSchemeValidSw(498p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.kgParams.h_DirectScheme))499RETURN_ERROR(MAJOR, E_INVALID_STATE,500("Invalid direct scheme."));501if (!KgIsSchemeAlwaysDirect(h_FmPcd, relativeSchemeId))502RETURN_ERROR(503MAJOR, E_INVALID_STATE,504("For this action scheme has to be direct."));505err =506FmPcdKgCcGetSetParams(507h_FmPcd,508p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.kgParams.h_DirectScheme,509requiredAction, 0);510if (err != E_OK)511RETURN_ERROR(MAJOR, err, NO_MSG);512p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=513requiredAction;514}515break;516517case (e_FM_PCD_PLCR):518if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)519&& !(p_CcKeyAndNextEngineParamsTmp[i].shadowAction520& UPDATE_NIA_ENQ_WITHOUT_DMA))521{522if (!p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.overrideParams)523RETURN_ERROR(524MAJOR,525E_NOT_SUPPORTED,526("In this initialization only overrideFqid can be initialized"));527if (!p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.sharedProfile)528RETURN_ERROR(529MAJOR,530E_NOT_SUPPORTED,531("In this initialization only overrideFqid can be initialized"));532err =533FmPcdPlcrGetAbsoluteIdByProfileParams(534h_FmPcd,535e_FM_PCD_PLCR_SHARED,536NULL,537p_CcKeyAndNextEngineParamsTmp[i].nextEngineParams.params.plcrParams.newRelativeProfileId,538&profileId);539if (err != E_OK)540RETURN_ERROR(MAJOR, err, NO_MSG);541err = FmPcdPlcrCcGetSetParams(h_FmPcd, profileId,542requiredAction);543if (err != E_OK)544RETURN_ERROR(MAJOR, err, NO_MSG);545p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=546requiredAction;547}548break;549550case (e_FM_PCD_DONE):551if ((requiredAction & UPDATE_NIA_ENQ_WITHOUT_DMA)552&& !(p_CcKeyAndNextEngineParamsTmp[i].shadowAction553& UPDATE_NIA_ENQ_WITHOUT_DMA))554{555tmpReg32 = GET_UINT32(p_AdTmp->nia);556if ((tmpReg32 & GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd))557!= GET_NIA_BMI_AC_ENQ_FRAME(h_FmPcd))558RETURN_ERROR(559MAJOR,560E_INVALID_STATE,561("Next engine was previously assigned not as PCD_DONE"));562tmpReg32 |= NIA_BMI_AC_ENQ_FRAME_WITHOUT_DMA;563WRITE_UINT32(p_AdTmp->nia, tmpReg32);564p_CcKeyAndNextEngineParamsTmp[i].shadowAction |=565requiredAction;566}567break;568569default:570break;571}572}573574return E_OK;575}576577static t_Error SetRequiredAction(578t_Handle h_FmPcd, uint32_t requiredAction,579t_FmPcdCcKeyAndNextEngineParams *p_CcKeyAndNextEngineParamsTmp,580t_Handle h_AdTmp, uint16_t numOfEntries, t_Handle h_Tree)581{582t_Error err = SetRequiredAction1(h_FmPcd, requiredAction,583p_CcKeyAndNextEngineParamsTmp, h_AdTmp,584numOfEntries, h_Tree);585if (err != E_OK)586return err;587return SetRequiredAction1(h_FmPcd, UPDATE_CC_SHADOW_CLEAR,588p_CcKeyAndNextEngineParamsTmp, h_AdTmp,589numOfEntries, h_Tree);590}591592static t_Error ReleaseModifiedDataStructure(593t_Handle h_FmPcd, t_List *h_FmPcdOldPointersLst,594t_List *h_FmPcdNewPointersLst,595t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalParams,596bool useShadowStructs)597{598t_List *p_Pos;599t_Error err = E_OK;600t_CcNodeInformation ccNodeInfo, *p_CcNodeInformation;601t_Handle h_Muram;602t_FmPcdCcNode *p_FmPcdCcNextNode, *p_FmPcdCcWorkingOnNode;603t_List *p_UpdateLst;604uint32_t intFlags;605606SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);607SANITY_CHECK_RETURN_ERROR(p_AdditionalParams->h_CurrentNode,608E_INVALID_HANDLE);609SANITY_CHECK_RETURN_ERROR(h_FmPcdOldPointersLst, E_INVALID_HANDLE);610SANITY_CHECK_RETURN_ERROR(h_FmPcdNewPointersLst, E_INVALID_HANDLE);611612/* We don't update subtree of the new node with new tree because it was done in the previous stage */613if (p_AdditionalParams->h_NodeForAdd)614{615p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_AdditionalParams->h_NodeForAdd;616617if (!p_AdditionalParams->tree)618p_UpdateLst = &p_FmPcdCcNextNode->ccPrevNodesLst;619else620p_UpdateLst = &p_FmPcdCcNextNode->ccTreeIdLst;621622p_CcNodeInformation = FindNodeInfoInReleventLst(623p_UpdateLst, p_AdditionalParams->h_CurrentNode,624p_FmPcdCcNextNode->h_Spinlock);625626if (p_CcNodeInformation)627p_CcNodeInformation->index++;628else629{630memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));631ccNodeInfo.h_CcNode = (t_Handle)p_AdditionalParams->h_CurrentNode;632ccNodeInfo.index = 1;633EnqueueNodeInfoToRelevantLst(p_UpdateLst, &ccNodeInfo,634p_FmPcdCcNextNode->h_Spinlock);635}636if (p_AdditionalParams->h_ManipForAdd)637{638p_CcNodeInformation = FindNodeInfoInReleventLst(639FmPcdManipGetNodeLstPointedOnThisManip(640p_AdditionalParams->h_ManipForAdd),641p_AdditionalParams->h_CurrentNode,642FmPcdManipGetSpinlock(p_AdditionalParams->h_ManipForAdd));643644if (p_CcNodeInformation)645p_CcNodeInformation->index++;646else647{648memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));649ccNodeInfo.h_CcNode =650(t_Handle)p_AdditionalParams->h_CurrentNode;651ccNodeInfo.index = 1;652EnqueueNodeInfoToRelevantLst(653FmPcdManipGetNodeLstPointedOnThisManip(654p_AdditionalParams->h_ManipForAdd),655&ccNodeInfo,656FmPcdManipGetSpinlock(657p_AdditionalParams->h_ManipForAdd));658}659}660}661662if (p_AdditionalParams->h_NodeForRmv)663{664p_FmPcdCcNextNode = (t_FmPcdCcNode*)p_AdditionalParams->h_NodeForRmv;665666if (!p_AdditionalParams->tree)667{668p_UpdateLst = &p_FmPcdCcNextNode->ccPrevNodesLst;669p_FmPcdCcWorkingOnNode =670(t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode);671672for (p_Pos = NCSW_LIST_FIRST(&p_FmPcdCcWorkingOnNode->ccTreesLst);673p_Pos != (&p_FmPcdCcWorkingOnNode->ccTreesLst); p_Pos =674NCSW_LIST_NEXT(p_Pos))675{676p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);677678ASSERT_COND(p_CcNodeInformation->h_CcNode);679680err =681SetRequiredAction(682h_FmPcd,683UPDATE_CC_WITH_DELETE_TREE,684&((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams[p_AdditionalParams->savedKeyIndex],685PTR_MOVE(((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_AdTable, p_AdditionalParams->savedKeyIndex*FM_PCD_CC_AD_ENTRY_SIZE),6861, p_CcNodeInformation->h_CcNode);687}688}689else690{691p_UpdateLst = &p_FmPcdCcNextNode->ccTreeIdLst;692693err =694SetRequiredAction(695h_FmPcd,696UPDATE_CC_WITH_DELETE_TREE,697&((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams[p_AdditionalParams->savedKeyIndex],698UINT_TO_PTR(((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->ccTreeBaseAddr + p_AdditionalParams->savedKeyIndex*FM_PCD_CC_AD_ENTRY_SIZE),6991, p_AdditionalParams->h_CurrentNode);700}701if (err)702return err;703704/* We remove from the subtree of the removed node tree because it wasn't done in the previous stage705Update ccPrevNodesLst or ccTreeIdLst of the removed node706Update of the node owner */707p_CcNodeInformation = FindNodeInfoInReleventLst(708p_UpdateLst, p_AdditionalParams->h_CurrentNode,709p_FmPcdCcNextNode->h_Spinlock);710711ASSERT_COND(p_CcNodeInformation);712ASSERT_COND(p_CcNodeInformation->index);713714p_CcNodeInformation->index--;715716if (p_CcNodeInformation->index == 0)717DequeueNodeInfoFromRelevantLst(p_UpdateLst,718p_AdditionalParams->h_CurrentNode,719p_FmPcdCcNextNode->h_Spinlock);720721UpdateNodeOwner(p_FmPcdCcNextNode, FALSE);722723if (p_AdditionalParams->h_ManipForRmv)724{725p_CcNodeInformation = FindNodeInfoInReleventLst(726FmPcdManipGetNodeLstPointedOnThisManip(727p_AdditionalParams->h_ManipForRmv),728p_AdditionalParams->h_CurrentNode,729FmPcdManipGetSpinlock(p_AdditionalParams->h_ManipForRmv));730731ASSERT_COND(p_CcNodeInformation);732ASSERT_COND(p_CcNodeInformation->index);733734p_CcNodeInformation->index--;735736if (p_CcNodeInformation->index == 0)737DequeueNodeInfoFromRelevantLst(738FmPcdManipGetNodeLstPointedOnThisManip(739p_AdditionalParams->h_ManipForRmv),740p_AdditionalParams->h_CurrentNode,741FmPcdManipGetSpinlock(742p_AdditionalParams->h_ManipForRmv));743}744}745746if (p_AdditionalParams->h_ManipForRmv)747FmPcdManipUpdateOwner(p_AdditionalParams->h_ManipForRmv, FALSE);748749if (p_AdditionalParams->p_StatsObjForRmv)750PutStatsObj((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode),751p_AdditionalParams->p_StatsObjForRmv);752753#if (DPAA_VERSION >= 11)754if (p_AdditionalParams->h_FrmReplicForRmv)755FrmReplicGroupUpdateOwner(p_AdditionalParams->h_FrmReplicForRmv,756FALSE/* remove */);757#endif /* (DPAA_VERSION >= 11) */758759if (!useShadowStructs)760{761h_Muram = FmPcdGetMuramHandle(h_FmPcd);762ASSERT_COND(h_Muram);763764if ((p_AdditionalParams->tree && !((t_FmPcd *)h_FmPcd)->p_CcShadow)765|| (!p_AdditionalParams->tree766&& !((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->maxNumOfKeys))767{768/* We release new AD which was allocated and updated for copy from to actual AD */769for (p_Pos = NCSW_LIST_FIRST(h_FmPcdNewPointersLst);770p_Pos != (h_FmPcdNewPointersLst); p_Pos = NCSW_LIST_NEXT(p_Pos))771{772773p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);774ASSERT_COND(p_CcNodeInformation->h_CcNode);775FM_MURAM_FreeMem(h_Muram, p_CcNodeInformation->h_CcNode);776}777}778779/* Free Old data structure if it has to be freed - new data structure was allocated*/780if (p_AdditionalParams->p_AdTableOld)781FM_MURAM_FreeMem(h_Muram, p_AdditionalParams->p_AdTableOld);782783if (p_AdditionalParams->p_KeysMatchTableOld)784FM_MURAM_FreeMem(h_Muram, p_AdditionalParams->p_KeysMatchTableOld);785}786787/* Update current modified node with changed fields if it's required*/788if (!p_AdditionalParams->tree)789{790if (p_AdditionalParams->p_AdTableNew)791((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_AdTable =792p_AdditionalParams->p_AdTableNew;793794if (p_AdditionalParams->p_KeysMatchTableNew)795((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_KeysMatchTable =796p_AdditionalParams->p_KeysMatchTableNew;797798/* Locking node's spinlock before updating 'keys and next engine' structure,799as it maybe used to retrieve keys statistics */800intFlags =801XX_LockIntrSpinlock(802((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_Spinlock);803804((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->numOfKeys =805p_AdditionalParams->numOfKeys;806807memcpy(((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams,808&p_AdditionalParams->keyAndNextEngineParams,809sizeof(t_FmPcdCcKeyAndNextEngineParams) * (CC_MAX_NUM_OF_KEYS));810811XX_UnlockIntrSpinlock(812((t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode))->h_Spinlock,813intFlags);814}815else816{817uint8_t numEntries =818((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->numOfEntries;819ASSERT_COND(numEntries < FM_PCD_MAX_NUM_OF_CC_GROUPS);820memcpy(&((t_FmPcdCcTree *)(p_AdditionalParams->h_CurrentNode))->keyAndNextEngineParams,821&p_AdditionalParams->keyAndNextEngineParams,822sizeof(t_FmPcdCcKeyAndNextEngineParams) * numEntries);823}824825ReleaseLst(h_FmPcdOldPointersLst);826ReleaseLst(h_FmPcdNewPointersLst);827828XX_Free(p_AdditionalParams);829830return E_OK;831}832833static t_Handle BuildNewAd(834t_Handle h_Ad,835t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams,836t_FmPcdCcNode *p_CcNode,837t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)838{839t_FmPcdCcNode *p_FmPcdCcNodeTmp;840t_Handle h_OrigAd = NULL;841842p_FmPcdCcNodeTmp = (t_FmPcdCcNode*)XX_Malloc(sizeof(t_FmPcdCcNode));843if (!p_FmPcdCcNodeTmp)844{845REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_FmPcdCcNodeTmp"));846return NULL;847}848memset(p_FmPcdCcNodeTmp, 0, sizeof(t_FmPcdCcNode));849850p_FmPcdCcNodeTmp->numOfKeys = p_FmPcdModifyCcKeyAdditionalParams->numOfKeys;851p_FmPcdCcNodeTmp->h_KeysMatchTable =852p_FmPcdModifyCcKeyAdditionalParams->p_KeysMatchTableNew;853p_FmPcdCcNodeTmp->h_AdTable =854p_FmPcdModifyCcKeyAdditionalParams->p_AdTableNew;855856p_FmPcdCcNodeTmp->lclMask = p_CcNode->lclMask;857p_FmPcdCcNodeTmp->parseCode = p_CcNode->parseCode;858p_FmPcdCcNodeTmp->offset = p_CcNode->offset;859p_FmPcdCcNodeTmp->prsArrayOffset = p_CcNode->prsArrayOffset;860p_FmPcdCcNodeTmp->ctrlFlow = p_CcNode->ctrlFlow;861p_FmPcdCcNodeTmp->ccKeySizeAccExtraction = p_CcNode->ccKeySizeAccExtraction;862p_FmPcdCcNodeTmp->sizeOfExtraction = p_CcNode->sizeOfExtraction;863p_FmPcdCcNodeTmp->glblMaskSize = p_CcNode->glblMaskSize;864p_FmPcdCcNodeTmp->p_GlblMask = p_CcNode->p_GlblMask;865866if (p_FmPcdCcNextEngineParams->nextEngine == e_FM_PCD_CC)867{868if (p_FmPcdCcNextEngineParams->h_Manip)869{870h_OrigAd = p_CcNode->h_Ad;871if (AllocAndFillAdForContLookupManip(872p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode)873!= E_OK)874{875REPORT_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);876XX_Free(p_FmPcdCcNodeTmp);877return NULL;878}879}880FillAdOfTypeContLookup(h_Ad, NULL, p_CcNode->h_FmPcd, p_FmPcdCcNodeTmp,881h_OrigAd ? NULL : p_FmPcdCcNextEngineParams->h_Manip, NULL);882}883884#if (DPAA_VERSION >= 11)885if ((p_FmPcdCcNextEngineParams->nextEngine == e_FM_PCD_FR)886&& (p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic))887{888FillAdOfTypeContLookup(889h_Ad, NULL, p_CcNode->h_FmPcd, p_FmPcdCcNodeTmp,890p_FmPcdCcNextEngineParams->h_Manip,891p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic);892}893#endif /* (DPAA_VERSION >= 11) */894895XX_Free(p_FmPcdCcNodeTmp);896897return NULL;898}899900static t_Error DynamicChangeHc(901t_Handle h_FmPcd, t_List *h_OldPointersLst, t_List *h_NewPointersLst,902t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalParams,903bool useShadowStructs)904{905t_List *p_PosOld, *p_PosNew;906uint32_t oldAdAddrOffset, newAdAddrOffset;907uint16_t i = 0;908t_Error err = E_OK;909uint8_t numOfModifiedPtr;910911ASSERT_COND(h_FmPcd);912ASSERT_COND(h_OldPointersLst);913ASSERT_COND(h_NewPointersLst);914915numOfModifiedPtr = (uint8_t)NCSW_LIST_NumOfObjs(h_OldPointersLst);916917if (numOfModifiedPtr)918{919p_PosNew = NCSW_LIST_FIRST(h_NewPointersLst);920p_PosOld = NCSW_LIST_FIRST(h_OldPointersLst);921922/* Retrieve address of new AD */923newAdAddrOffset = FmPcdCcGetNodeAddrOffsetFromNodeInfo(h_FmPcd,924p_PosNew);925if (newAdAddrOffset == (uint32_t)ILLEGAL_BASE)926{927ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,928h_NewPointersLst,929p_AdditionalParams, useShadowStructs);930RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("New AD address"));931}932933for (i = 0; i < numOfModifiedPtr; i++)934{935/* Retrieve address of current AD */936oldAdAddrOffset = FmPcdCcGetNodeAddrOffsetFromNodeInfo(h_FmPcd,937p_PosOld);938if (oldAdAddrOffset == (uint32_t)ILLEGAL_BASE)939{940ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,941h_NewPointersLst,942p_AdditionalParams,943useShadowStructs);944RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Old AD address"));945}946947/* Invoke host command to copy from new AD to old AD */948err = FmHcPcdCcDoDynamicChange(((t_FmPcd *)h_FmPcd)->h_Hc,949oldAdAddrOffset, newAdAddrOffset);950if (err)951{952ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,953h_NewPointersLst,954p_AdditionalParams,955useShadowStructs);956RETURN_ERROR(957MAJOR,958err,959("For part of nodes changes are done - situation is danger"));960}961962p_PosOld = NCSW_LIST_NEXT(p_PosOld);963}964}965return E_OK;966}967968static t_Error DoDynamicChange(969t_Handle h_FmPcd, t_List *h_OldPointersLst, t_List *h_NewPointersLst,970t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalParams,971bool useShadowStructs)972{973t_FmPcdCcNode *p_CcNode =974(t_FmPcdCcNode *)(p_AdditionalParams->h_CurrentNode);975t_List *p_PosNew;976t_CcNodeInformation *p_CcNodeInfo;977t_FmPcdCcNextEngineParams nextEngineParams;978t_Handle h_Ad;979uint32_t keySize;980t_Error err = E_OK;981uint8_t numOfModifiedPtr;982983ASSERT_COND(h_FmPcd);984985memset(&nextEngineParams, 0, sizeof(t_FmPcdCcNextEngineParams));986987numOfModifiedPtr = (uint8_t)NCSW_LIST_NumOfObjs(h_OldPointersLst);988989if (numOfModifiedPtr)990{991992p_PosNew = NCSW_LIST_FIRST(h_NewPointersLst);993994/* Invoke host-command to copy from the new Ad to existing Ads */995err = DynamicChangeHc(h_FmPcd, h_OldPointersLst, h_NewPointersLst,996p_AdditionalParams, useShadowStructs);997if (err)998RETURN_ERROR(MAJOR, err, NO_MSG);9991000if (useShadowStructs)1001{1002/* When the host-command above has ended, the old structures are 'free'and we can update1003them by copying from the new shadow structures. */1004if (p_CcNode->lclMask)1005keySize = (uint32_t)(2 * p_CcNode->ccKeySizeAccExtraction);1006else1007keySize = p_CcNode->ccKeySizeAccExtraction;10081009MemCpy8(p_AdditionalParams->p_KeysMatchTableOld,1010p_AdditionalParams->p_KeysMatchTableNew,1011p_CcNode->maxNumOfKeys * keySize * sizeof(uint8_t));10121013MemCpy8(1014p_AdditionalParams->p_AdTableOld,1015p_AdditionalParams->p_AdTableNew,1016(uint32_t)((p_CcNode->maxNumOfKeys + 1)1017* FM_PCD_CC_AD_ENTRY_SIZE));10181019/* Retrieve the address of the allocated Ad */1020p_CcNodeInfo = CC_NODE_F_OBJECT(p_PosNew);1021h_Ad = p_CcNodeInfo->h_CcNode;10221023/* Build a new Ad that holds the old (now updated) structures */1024p_AdditionalParams->p_KeysMatchTableNew =1025p_AdditionalParams->p_KeysMatchTableOld;1026p_AdditionalParams->p_AdTableNew = p_AdditionalParams->p_AdTableOld;10271028nextEngineParams.nextEngine = e_FM_PCD_CC;1029nextEngineParams.params.ccParams.h_CcNode = (t_Handle)p_CcNode;10301031BuildNewAd(h_Ad, p_AdditionalParams, p_CcNode, &nextEngineParams);10321033/* HC to copy from the new Ad (old updated structures) to current Ad (uses shadow structures) */1034err = DynamicChangeHc(h_FmPcd, h_OldPointersLst, h_NewPointersLst,1035p_AdditionalParams, useShadowStructs);1036if (err)1037RETURN_ERROR(MAJOR, err, NO_MSG);1038}1039}10401041err = ReleaseModifiedDataStructure(h_FmPcd, h_OldPointersLst,1042h_NewPointersLst,1043p_AdditionalParams, useShadowStructs);1044if (err)1045RETURN_ERROR(MAJOR, err, NO_MSG);10461047return E_OK;1048}10491050#ifdef FM_CAPWAP_SUPPORT1051static bool IsCapwapApplSpecific(t_Handle h_Node)1052{1053t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_Node;1054bool isManipForCapwapApplSpecificBuild = FALSE;1055int i = 0;10561057ASSERT_COND(h_Node);1058/* assumption that this function called only for INDEXED_FLOW_ID - so no miss*/1059for (i = 0; i < p_CcNode->numOfKeys; i++)1060{1061if ( p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip &&1062FmPcdManipIsCapwapApplSpecific(p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip))1063{1064isManipForCapwapApplSpecificBuild = TRUE;1065break;1066}1067}1068return isManipForCapwapApplSpecificBuild;10691070}1071#endif /* FM_CAPWAP_SUPPORT */10721073static t_Error CcUpdateParam(1074t_Handle h_FmPcd, t_Handle h_PcdParams, t_Handle h_FmPort,1075t_FmPcdCcKeyAndNextEngineParams *p_CcKeyAndNextEngineParams,1076uint16_t numOfEntries, t_Handle h_Ad, bool validate, uint16_t level,1077t_Handle h_FmTree, bool modify)1078{1079t_FmPcdCcNode *p_CcNode;1080t_Error err;1081uint16_t tmp = 0;1082int i = 0;1083t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_FmTree;10841085level++;10861087if (p_CcTree->h_IpReassemblyManip)1088{1089err = FmPcdManipUpdate(h_FmPcd, h_PcdParams, h_FmPort,1090p_CcTree->h_IpReassemblyManip, NULL, validate,1091level, h_FmTree, modify);1092if (err)1093RETURN_ERROR(MAJOR, err, NO_MSG);1094}10951096if (p_CcTree->h_CapwapReassemblyManip)1097{1098err = FmPcdManipUpdate(h_FmPcd, h_PcdParams, h_FmPort,1099p_CcTree->h_CapwapReassemblyManip, NULL, validate,1100level, h_FmTree, modify);1101if (err)1102RETURN_ERROR(MAJOR, err, NO_MSG);1103}11041105if (numOfEntries)1106{1107for (i = 0; i < numOfEntries; i++)1108{1109if (i == 0)1110h_Ad = PTR_MOVE(h_Ad, i*FM_PCD_CC_AD_ENTRY_SIZE);1111else1112h_Ad = PTR_MOVE(h_Ad, FM_PCD_CC_AD_ENTRY_SIZE);11131114if (p_CcKeyAndNextEngineParams[i].nextEngineParams.nextEngine1115== e_FM_PCD_CC)1116{1117p_CcNode =1118p_CcKeyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;1119ASSERT_COND(p_CcNode);11201121if (p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip)1122{1123err =1124FmPcdManipUpdate(1125h_FmPcd,1126NULL,1127h_FmPort,1128p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip,1129h_Ad, validate, level, h_FmTree, modify);1130if (err)1131RETURN_ERROR(MAJOR, err, NO_MSG);1132}11331134if (p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine1135!= e_FM_PCD_INVALID)1136tmp = (uint8_t)(p_CcNode->numOfKeys + 1);1137else1138tmp = p_CcNode->numOfKeys;11391140err = CcUpdateParam(h_FmPcd, h_PcdParams, h_FmPort,1141p_CcNode->keyAndNextEngineParams, tmp,1142p_CcNode->h_AdTable, validate, level,1143h_FmTree, modify);1144if (err)1145RETURN_ERROR(MAJOR, err, NO_MSG);1146}1147else1148{1149if (p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip)1150{1151err =1152FmPcdManipUpdate(1153h_FmPcd,1154NULL,1155h_FmPort,1156p_CcKeyAndNextEngineParams[i].nextEngineParams.h_Manip,1157h_Ad, validate, level, h_FmTree, modify);1158if (err)1159RETURN_ERROR(MAJOR, err, NO_MSG);1160}1161}1162}1163}11641165return E_OK;1166}11671168static ccPrivateInfo_t IcDefineCode(t_FmPcdCcNodeParams *p_CcNodeParam)1169{1170switch (p_CcNodeParam->extractCcParams.extractNonHdr.action)1171{1172case (e_FM_PCD_ACTION_EXACT_MATCH):1173switch (p_CcNodeParam->extractCcParams.extractNonHdr.src)1174{1175case (e_FM_PCD_EXTRACT_FROM_KEY):1176return CC_PRIVATE_INFO_IC_KEY_EXACT_MATCH;1177case (e_FM_PCD_EXTRACT_FROM_HASH):1178return CC_PRIVATE_INFO_IC_HASH_EXACT_MATCH;1179default:1180return CC_PRIVATE_INFO_NONE;1181}11821183case (e_FM_PCD_ACTION_INDEXED_LOOKUP):1184switch (p_CcNodeParam->extractCcParams.extractNonHdr.src)1185{1186case (e_FM_PCD_EXTRACT_FROM_HASH):1187return CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP;1188case (e_FM_PCD_EXTRACT_FROM_FLOW_ID):1189return CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP;1190default:1191return CC_PRIVATE_INFO_NONE;1192}11931194default:1195break;1196}11971198return CC_PRIVATE_INFO_NONE;1199}12001201static t_CcNodeInformation * DequeueAdditionalInfoFromRelevantLst(1202t_List *p_List)1203{1204t_CcNodeInformation *p_CcNodeInfo = NULL;12051206if (!NCSW_LIST_IsEmpty(p_List))1207{1208p_CcNodeInfo = CC_NODE_F_OBJECT(p_List->p_Next);1209NCSW_LIST_DelAndInit(&p_CcNodeInfo->node);1210}12111212return p_CcNodeInfo;1213}12141215void ReleaseLst(t_List *p_List)1216{1217t_CcNodeInformation *p_CcNodeInfo = NULL;12181219if (!NCSW_LIST_IsEmpty(p_List))1220{1221p_CcNodeInfo = DequeueAdditionalInfoFromRelevantLst(p_List);1222while (p_CcNodeInfo)1223{1224XX_Free(p_CcNodeInfo);1225p_CcNodeInfo = DequeueAdditionalInfoFromRelevantLst(p_List);1226}1227}12281229NCSW_LIST_Del(p_List);1230}12311232static void DeleteNode(t_FmPcdCcNode *p_CcNode)1233{1234uint32_t i;12351236if (!p_CcNode)1237return;12381239if (p_CcNode->p_GlblMask)1240{1241XX_Free(p_CcNode->p_GlblMask);1242p_CcNode->p_GlblMask = NULL;1243}12441245if (p_CcNode->h_KeysMatchTable)1246{1247FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),1248p_CcNode->h_KeysMatchTable);1249p_CcNode->h_KeysMatchTable = NULL;1250}12511252if (p_CcNode->h_AdTable)1253{1254FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),1255p_CcNode->h_AdTable);1256p_CcNode->h_AdTable = NULL;1257}12581259if (p_CcNode->h_Ad)1260{1261FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),1262p_CcNode->h_Ad);1263p_CcNode->h_Ad = NULL;1264p_CcNode->h_TmpAd = NULL;1265}12661267if (p_CcNode->h_StatsFLRs)1268{1269FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),1270p_CcNode->h_StatsFLRs);1271p_CcNode->h_StatsFLRs = NULL;1272}12731274if (p_CcNode->h_Spinlock)1275{1276XX_FreeSpinlock(p_CcNode->h_Spinlock);1277p_CcNode->h_Spinlock = NULL;1278}12791280/* Restore the original counters pointer instead of the mutual pointer (mutual to all hash buckets) */1281if (p_CcNode->isHashBucket1282&& (p_CcNode->statisticsMode != e_FM_PCD_CC_STATS_MODE_NONE))1283p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].p_StatsObj->h_StatsCounters =1284p_CcNode->h_PrivMissStatsCounters;12851286/* Releasing all currently used statistics objects, including 'miss' entry */1287for (i = 0; i < p_CcNode->numOfKeys + 1; i++)1288if (p_CcNode->keyAndNextEngineParams[i].p_StatsObj)1289PutStatsObj(p_CcNode,1290p_CcNode->keyAndNextEngineParams[i].p_StatsObj);12911292if (!NCSW_LIST_IsEmpty(&p_CcNode->availableStatsLst))1293{1294t_Handle h_FmMuram = FmPcdGetMuramHandle(p_CcNode->h_FmPcd);1295ASSERT_COND(h_FmMuram);12961297FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);1298}12991300NCSW_LIST_Del(&p_CcNode->availableStatsLst);13011302ReleaseLst(&p_CcNode->ccPrevNodesLst);1303ReleaseLst(&p_CcNode->ccTreeIdLst);1304ReleaseLst(&p_CcNode->ccTreesLst);13051306XX_Free(p_CcNode);1307}13081309static void DeleteTree(t_FmPcdCcTree *p_FmPcdTree, t_FmPcd *p_FmPcd)1310{1311if (p_FmPcdTree)1312{1313if (p_FmPcdTree->ccTreeBaseAddr)1314{1315FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_FmPcd),1316UINT_TO_PTR(p_FmPcdTree->ccTreeBaseAddr));1317p_FmPcdTree->ccTreeBaseAddr = 0;1318}13191320ReleaseLst(&p_FmPcdTree->fmPortsLst);13211322XX_Free(p_FmPcdTree);1323}1324}13251326static void GetCcExtractKeySize(uint8_t parseCodeRealSize,1327uint8_t *parseCodeCcSize)1328{1329if ((parseCodeRealSize > 0) && (parseCodeRealSize < 2))1330*parseCodeCcSize = 1;1331else1332if (parseCodeRealSize == 2)1333*parseCodeCcSize = 2;1334else1335if ((parseCodeRealSize > 2) && (parseCodeRealSize <= 4))1336*parseCodeCcSize = 4;1337else1338if ((parseCodeRealSize > 4) && (parseCodeRealSize <= 8))1339*parseCodeCcSize = 8;1340else1341if ((parseCodeRealSize > 8) && (parseCodeRealSize <= 16))1342*parseCodeCcSize = 16;1343else1344if ((parseCodeRealSize > 16)1345&& (parseCodeRealSize <= 24))1346*parseCodeCcSize = 24;1347else1348if ((parseCodeRealSize > 24)1349&& (parseCodeRealSize <= 32))1350*parseCodeCcSize = 32;1351else1352if ((parseCodeRealSize > 32)1353&& (parseCodeRealSize <= 40))1354*parseCodeCcSize = 40;1355else1356if ((parseCodeRealSize > 40)1357&& (parseCodeRealSize <= 48))1358*parseCodeCcSize = 48;1359else1360if ((parseCodeRealSize > 48)1361&& (parseCodeRealSize <= 56))1362*parseCodeCcSize = 56;1363else1364*parseCodeCcSize = 0;1365}13661367static void GetSizeHeaderField(e_NetHeaderType hdr, t_FmPcdFields field,1368uint8_t *parseCodeRealSize)1369{1370switch (hdr)1371{1372case (HEADER_TYPE_ETH):1373switch (field.eth)1374{1375case (NET_HEADER_FIELD_ETH_DA):1376*parseCodeRealSize = 6;1377break;13781379case (NET_HEADER_FIELD_ETH_SA):1380*parseCodeRealSize = 6;1381break;13821383case (NET_HEADER_FIELD_ETH_TYPE):1384*parseCodeRealSize = 2;1385break;13861387default:1388REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported1"));1389*parseCodeRealSize = CC_SIZE_ILLEGAL;1390break;1391}1392break;13931394case (HEADER_TYPE_PPPoE):1395switch (field.pppoe)1396{1397case (NET_HEADER_FIELD_PPPoE_PID):1398*parseCodeRealSize = 2;1399break;14001401default:1402REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported1"));1403*parseCodeRealSize = CC_SIZE_ILLEGAL;1404break;1405}1406break;14071408case (HEADER_TYPE_VLAN):1409switch (field.vlan)1410{1411case (NET_HEADER_FIELD_VLAN_TCI):1412*parseCodeRealSize = 2;1413break;14141415default:1416REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported2"));1417*parseCodeRealSize = CC_SIZE_ILLEGAL;1418break;1419}1420break;14211422case (HEADER_TYPE_MPLS):1423switch (field.mpls)1424{1425case (NET_HEADER_FIELD_MPLS_LABEL_STACK):1426*parseCodeRealSize = 4;1427break;14281429default:1430REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported3"));1431*parseCodeRealSize = CC_SIZE_ILLEGAL;1432break;1433}1434break;14351436case (HEADER_TYPE_IPv4):1437switch (field.ipv4)1438{1439case (NET_HEADER_FIELD_IPv4_DST_IP):1440case (NET_HEADER_FIELD_IPv4_SRC_IP):1441*parseCodeRealSize = 4;1442break;14431444case (NET_HEADER_FIELD_IPv4_TOS):1445case (NET_HEADER_FIELD_IPv4_PROTO):1446*parseCodeRealSize = 1;1447break;14481449case (NET_HEADER_FIELD_IPv4_DST_IP1450| NET_HEADER_FIELD_IPv4_SRC_IP):1451*parseCodeRealSize = 8;1452break;14531454case (NET_HEADER_FIELD_IPv4_TTL):1455*parseCodeRealSize = 1;1456break;14571458default:1459REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported4"));1460*parseCodeRealSize = CC_SIZE_ILLEGAL;1461break;1462}1463break;14641465case (HEADER_TYPE_IPv6):1466switch (field.ipv6)1467{1468case (NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL1469| NET_HEADER_FIELD_IPv6_TC):1470*parseCodeRealSize = 4;1471break;14721473case (NET_HEADER_FIELD_IPv6_NEXT_HDR):1474case (NET_HEADER_FIELD_IPv6_HOP_LIMIT):1475*parseCodeRealSize = 1;1476break;14771478case (NET_HEADER_FIELD_IPv6_DST_IP):1479case (NET_HEADER_FIELD_IPv6_SRC_IP):1480*parseCodeRealSize = 16;1481break;14821483default:1484REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported5"));1485*parseCodeRealSize = CC_SIZE_ILLEGAL;1486break;1487}1488break;14891490case (HEADER_TYPE_IP):1491switch (field.ip)1492{1493case (NET_HEADER_FIELD_IP_DSCP):1494case (NET_HEADER_FIELD_IP_PROTO):1495*parseCodeRealSize = 1;1496break;14971498default:1499REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported5"));1500*parseCodeRealSize = CC_SIZE_ILLEGAL;1501break;1502}1503break;15041505case (HEADER_TYPE_GRE):1506switch (field.gre)1507{1508case (NET_HEADER_FIELD_GRE_TYPE):1509*parseCodeRealSize = 2;1510break;15111512default:1513REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported6"));1514*parseCodeRealSize = CC_SIZE_ILLEGAL;1515break;1516}1517break;15181519case (HEADER_TYPE_MINENCAP):1520switch (field.minencap)1521{1522case (NET_HEADER_FIELD_MINENCAP_TYPE):1523*parseCodeRealSize = 1;1524break;15251526case (NET_HEADER_FIELD_MINENCAP_DST_IP):1527case (NET_HEADER_FIELD_MINENCAP_SRC_IP):1528*parseCodeRealSize = 4;1529break;15301531case (NET_HEADER_FIELD_MINENCAP_SRC_IP1532| NET_HEADER_FIELD_MINENCAP_DST_IP):1533*parseCodeRealSize = 8;1534break;15351536default:1537REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported7"));1538*parseCodeRealSize = CC_SIZE_ILLEGAL;1539break;1540}1541break;15421543case (HEADER_TYPE_TCP):1544switch (field.tcp)1545{1546case (NET_HEADER_FIELD_TCP_PORT_SRC):1547case (NET_HEADER_FIELD_TCP_PORT_DST):1548*parseCodeRealSize = 2;1549break;15501551case (NET_HEADER_FIELD_TCP_PORT_SRC1552| NET_HEADER_FIELD_TCP_PORT_DST):1553*parseCodeRealSize = 4;1554break;15551556default:1557REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported8"));1558*parseCodeRealSize = CC_SIZE_ILLEGAL;1559break;1560}1561break;15621563case (HEADER_TYPE_UDP):1564switch (field.udp)1565{1566case (NET_HEADER_FIELD_UDP_PORT_SRC):1567case (NET_HEADER_FIELD_UDP_PORT_DST):1568*parseCodeRealSize = 2;1569break;15701571case (NET_HEADER_FIELD_UDP_PORT_SRC1572| NET_HEADER_FIELD_UDP_PORT_DST):1573*parseCodeRealSize = 4;1574break;15751576default:1577REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported9"));1578*parseCodeRealSize = CC_SIZE_ILLEGAL;1579break;1580}1581break;15821583default:1584REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported10"));1585*parseCodeRealSize = CC_SIZE_ILLEGAL;1586break;1587}1588}15891590t_Error ValidateNextEngineParams(1591t_Handle h_FmPcd, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,1592e_FmPcdCcStatsMode statsMode)1593{1594uint16_t absoluteProfileId;1595t_Error err = E_OK;1596uint8_t relativeSchemeId;15971598if ((statsMode == e_FM_PCD_CC_STATS_MODE_NONE)1599&& (p_FmPcdCcNextEngineParams->statisticsEn))1600RETURN_ERROR(1601MAJOR,1602E_CONFLICT,1603("Statistics are requested for a key, but statistics mode was set"1604"to 'NONE' upon initialization"));16051606switch (p_FmPcdCcNextEngineParams->nextEngine)1607{1608case (e_FM_PCD_INVALID):1609err = E_NOT_SUPPORTED;1610break;16111612case (e_FM_PCD_DONE):1613if ((p_FmPcdCcNextEngineParams->params.enqueueParams.action1614== e_FM_PCD_ENQ_FRAME)1615&& p_FmPcdCcNextEngineParams->params.enqueueParams.overrideFqid)1616{1617if (!p_FmPcdCcNextEngineParams->params.enqueueParams.newFqid)1618RETURN_ERROR(1619MAJOR,1620E_CONFLICT,1621("When overrideFqid is set, newFqid must not be zero"));1622if (p_FmPcdCcNextEngineParams->params.enqueueParams.newFqid1623& ~0x00FFFFFF)1624RETURN_ERROR(1625MAJOR, E_INVALID_VALUE,1626("fqidForCtrlFlow must be between 1 and 2^24-1"));1627}1628break;16291630case (e_FM_PCD_KG):1631relativeSchemeId =1632FmPcdKgGetRelativeSchemeId(1633h_FmPcd,1634FmPcdKgGetSchemeId(1635p_FmPcdCcNextEngineParams->params.kgParams.h_DirectScheme));1636if (relativeSchemeId == FM_PCD_KG_NUM_OF_SCHEMES)1637RETURN_ERROR(MAJOR, E_NOT_IN_RANGE, NO_MSG);1638if (!FmPcdKgIsSchemeValidSw(1639p_FmPcdCcNextEngineParams->params.kgParams.h_DirectScheme))1640RETURN_ERROR(MAJOR, E_INVALID_STATE,1641("not valid schemeIndex in KG next engine param"));1642if (!KgIsSchemeAlwaysDirect(h_FmPcd, relativeSchemeId))1643RETURN_ERROR(1644MAJOR,1645E_INVALID_STATE,1646("CC Node may point only to a scheme that is always direct."));1647break;16481649case (e_FM_PCD_PLCR):1650if (p_FmPcdCcNextEngineParams->params.plcrParams.overrideParams)1651{1652/* if private policer profile, it may be uninitialized yet, therefore no checks are done at this stage */1653if (p_FmPcdCcNextEngineParams->params.plcrParams.sharedProfile)1654{1655err =1656FmPcdPlcrGetAbsoluteIdByProfileParams(1657h_FmPcd,1658e_FM_PCD_PLCR_SHARED,1659NULL,1660p_FmPcdCcNextEngineParams->params.plcrParams.newRelativeProfileId,1661&absoluteProfileId);1662if (err)1663RETURN_ERROR(MAJOR, err,1664("Shared profile offset is out of range"));1665if (!FmPcdPlcrIsProfileValid(h_FmPcd, absoluteProfileId))1666RETURN_ERROR(MAJOR, E_INVALID_STATE,1667("Invalid profile"));1668}1669}1670break;16711672case (e_FM_PCD_HASH):1673p_FmPcdCcNextEngineParams->nextEngine = e_FM_PCD_CC;1674case (e_FM_PCD_CC):1675if (!p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode)1676RETURN_ERROR(MAJOR, E_NULL_POINTER,1677("handler to next Node is NULL"));1678break;16791680#if (DPAA_VERSION >= 11)1681case (e_FM_PCD_FR):1682if (!p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic)1683err = E_NOT_SUPPORTED;1684break;1685#endif /* (DPAA_VERSION >= 11) */16861687default:1688RETURN_ERROR(MAJOR, E_INVALID_STATE,1689("Next engine is not correct"));1690}169116921693return err;1694}16951696static uint8_t GetGenParseCode(e_FmPcdExtractFrom src,1697uint32_t offset, bool glblMask,1698uint8_t *parseArrayOffset, bool fromIc,1699ccPrivateInfo_t icCode)1700{1701if (!fromIc)1702{1703switch (src)1704{1705case (e_FM_PCD_EXTRACT_FROM_FRAME_START):1706if (glblMask)1707return CC_PC_GENERIC_WITH_MASK;1708else1709return CC_PC_GENERIC_WITHOUT_MASK;17101711case (e_FM_PCD_EXTRACT_FROM_CURR_END_OF_PARSE):1712*parseArrayOffset = CC_PC_PR_NEXT_HEADER_OFFSET;1713if (offset)1714return CC_PR_OFFSET;1715else1716return CC_PR_WITHOUT_OFFSET;17171718default:1719REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 'extract from' src"));1720return CC_PC_ILLEGAL;1721}1722}1723else1724{1725switch (icCode)1726{1727case (CC_PRIVATE_INFO_IC_KEY_EXACT_MATCH):1728*parseArrayOffset = 0x50;1729return CC_PC_GENERIC_IC_GMASK;17301731case (CC_PRIVATE_INFO_IC_HASH_EXACT_MATCH):1732*parseArrayOffset = 0x48;1733return CC_PC_GENERIC_IC_GMASK;17341735case (CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP):1736*parseArrayOffset = 0x48;1737return CC_PC_GENERIC_IC_HASH_INDEXED;17381739case (CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP):1740*parseArrayOffset = 0x16;1741return CC_PC_GENERIC_IC_HASH_INDEXED;17421743default:1744REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Illegal 'extract from' src"));1745break;1746}1747}17481749return CC_PC_ILLEGAL;1750}17511752static uint8_t GetFullFieldParseCode(e_NetHeaderType hdr, e_FmPcdHdrIndex index,1753t_FmPcdFields field)1754{1755switch (hdr)1756{1757case (HEADER_TYPE_NONE):1758ASSERT_COND(FALSE);1759return CC_PC_ILLEGAL;17601761case (HEADER_TYPE_ETH):1762switch (field.eth)1763{1764case (NET_HEADER_FIELD_ETH_DA):1765return CC_PC_FF_MACDST;1766case (NET_HEADER_FIELD_ETH_SA):1767return CC_PC_FF_MACSRC;1768case (NET_HEADER_FIELD_ETH_TYPE):1769return CC_PC_FF_ETYPE;1770default:1771REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));1772return CC_PC_ILLEGAL;1773}17741775case (HEADER_TYPE_VLAN):1776switch (field.vlan)1777{1778case (NET_HEADER_FIELD_VLAN_TCI):1779if ((index == e_FM_PCD_HDR_INDEX_NONE)1780|| (index == e_FM_PCD_HDR_INDEX_1))1781return CC_PC_FF_TCI1;1782if (index == e_FM_PCD_HDR_INDEX_LAST)1783return CC_PC_FF_TCI2;1784REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));1785return CC_PC_ILLEGAL;1786default:1787REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));1788return CC_PC_ILLEGAL;1789}17901791case (HEADER_TYPE_MPLS):1792switch (field.mpls)1793{1794case (NET_HEADER_FIELD_MPLS_LABEL_STACK):1795if ((index == e_FM_PCD_HDR_INDEX_NONE)1796|| (index == e_FM_PCD_HDR_INDEX_1))1797return CC_PC_FF_MPLS1;1798if (index == e_FM_PCD_HDR_INDEX_LAST)1799return CC_PC_FF_MPLS_LAST;1800REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS index"));1801return CC_PC_ILLEGAL;1802default:1803REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));1804return CC_PC_ILLEGAL;1805}18061807case (HEADER_TYPE_IPv4):1808switch (field.ipv4)1809{1810case (NET_HEADER_FIELD_IPv4_DST_IP):1811if ((index == e_FM_PCD_HDR_INDEX_NONE)1812|| (index == e_FM_PCD_HDR_INDEX_1))1813return CC_PC_FF_IPV4DST1;1814if (index == e_FM_PCD_HDR_INDEX_2)1815return CC_PC_FF_IPV4DST2;1816REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));1817return CC_PC_ILLEGAL;1818case (NET_HEADER_FIELD_IPv4_TOS):1819if ((index == e_FM_PCD_HDR_INDEX_NONE)1820|| (index == e_FM_PCD_HDR_INDEX_1))1821return CC_PC_FF_IPV4IPTOS_TC1;1822if (index == e_FM_PCD_HDR_INDEX_2)1823return CC_PC_FF_IPV4IPTOS_TC2;1824REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));1825return CC_PC_ILLEGAL;1826case (NET_HEADER_FIELD_IPv4_PROTO):1827if ((index == e_FM_PCD_HDR_INDEX_NONE)1828|| (index == e_FM_PCD_HDR_INDEX_1))1829return CC_PC_FF_IPV4PTYPE1;1830if (index == e_FM_PCD_HDR_INDEX_2)1831return CC_PC_FF_IPV4PTYPE2;1832REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));1833return CC_PC_ILLEGAL;1834case (NET_HEADER_FIELD_IPv4_SRC_IP):1835if ((index == e_FM_PCD_HDR_INDEX_NONE)1836|| (index == e_FM_PCD_HDR_INDEX_1))1837return CC_PC_FF_IPV4SRC1;1838if (index == e_FM_PCD_HDR_INDEX_2)1839return CC_PC_FF_IPV4SRC2;1840REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));1841return CC_PC_ILLEGAL;1842case (NET_HEADER_FIELD_IPv4_SRC_IP1843| NET_HEADER_FIELD_IPv4_DST_IP):1844if ((index == e_FM_PCD_HDR_INDEX_NONE)1845|| (index == e_FM_PCD_HDR_INDEX_1))1846return CC_PC_FF_IPV4SRC1_IPV4DST1;1847if (index == e_FM_PCD_HDR_INDEX_2)1848return CC_PC_FF_IPV4SRC2_IPV4DST2;1849REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv4 index"));1850return CC_PC_ILLEGAL;1851case (NET_HEADER_FIELD_IPv4_TTL):1852return CC_PC_FF_IPV4TTL;1853default:1854REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));1855return CC_PC_ILLEGAL;1856}18571858case (HEADER_TYPE_IPv6):1859switch (field.ipv6)1860{1861case (NET_HEADER_FIELD_IPv6_VER | NET_HEADER_FIELD_IPv6_FL1862| NET_HEADER_FIELD_IPv6_TC):1863if ((index == e_FM_PCD_HDR_INDEX_NONE)1864|| (index == e_FM_PCD_HDR_INDEX_1))1865return CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1;1866if (index == e_FM_PCD_HDR_INDEX_2)1867return CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2;1868REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));1869return CC_PC_ILLEGAL;18701871case (NET_HEADER_FIELD_IPv6_NEXT_HDR):1872if ((index == e_FM_PCD_HDR_INDEX_NONE)1873|| (index == e_FM_PCD_HDR_INDEX_1))1874return CC_PC_FF_IPV6PTYPE1;1875if (index == e_FM_PCD_HDR_INDEX_2)1876return CC_PC_FF_IPV6PTYPE2;1877if (index == e_FM_PCD_HDR_INDEX_LAST)1878return CC_PC_FF_IPPID;1879REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));1880return CC_PC_ILLEGAL;18811882case (NET_HEADER_FIELD_IPv6_DST_IP):1883if ((index == e_FM_PCD_HDR_INDEX_NONE)1884|| (index == e_FM_PCD_HDR_INDEX_1))1885return CC_PC_FF_IPV6DST1;1886if (index == e_FM_PCD_HDR_INDEX_2)1887return CC_PC_FF_IPV6DST2;1888REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));1889return CC_PC_ILLEGAL;18901891case (NET_HEADER_FIELD_IPv6_SRC_IP):1892if ((index == e_FM_PCD_HDR_INDEX_NONE)1893|| (index == e_FM_PCD_HDR_INDEX_1))1894return CC_PC_FF_IPV6SRC1;1895if (index == e_FM_PCD_HDR_INDEX_2)1896return CC_PC_FF_IPV6SRC2;1897REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IPv6 index"));1898return CC_PC_ILLEGAL;18991900case (NET_HEADER_FIELD_IPv6_HOP_LIMIT):1901return CC_PC_FF_IPV6HOP_LIMIT;19021903default:1904REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));1905return CC_PC_ILLEGAL;1906}19071908case (HEADER_TYPE_IP):1909switch (field.ip)1910{1911case (NET_HEADER_FIELD_IP_DSCP):1912if ((index == e_FM_PCD_HDR_INDEX_NONE)1913|| (index == e_FM_PCD_HDR_INDEX_1))1914return CC_PC_FF_IPDSCP;1915REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP index"));1916return CC_PC_ILLEGAL;19171918case (NET_HEADER_FIELD_IP_PROTO):1919if (index == e_FM_PCD_HDR_INDEX_LAST)1920return CC_PC_FF_IPPID;1921REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP index"));1922return CC_PC_ILLEGAL;19231924default:1925REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));1926return CC_PC_ILLEGAL;1927}19281929case (HEADER_TYPE_GRE):1930switch (field.gre)1931{1932case (NET_HEADER_FIELD_GRE_TYPE):1933return CC_PC_FF_GREPTYPE;19341935default:1936REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));1937return CC_PC_ILLEGAL;1938}19391940case (HEADER_TYPE_MINENCAP):1941switch (field.minencap)1942{1943case (NET_HEADER_FIELD_MINENCAP_TYPE):1944return CC_PC_FF_MINENCAP_PTYPE;19451946case (NET_HEADER_FIELD_MINENCAP_DST_IP):1947return CC_PC_FF_MINENCAP_IPDST;19481949case (NET_HEADER_FIELD_MINENCAP_SRC_IP):1950return CC_PC_FF_MINENCAP_IPSRC;19511952case (NET_HEADER_FIELD_MINENCAP_SRC_IP1953| NET_HEADER_FIELD_MINENCAP_DST_IP):1954return CC_PC_FF_MINENCAP_IPSRC_IPDST;19551956default:1957REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));1958return CC_PC_ILLEGAL;1959}19601961case (HEADER_TYPE_TCP):1962switch (field.tcp)1963{1964case (NET_HEADER_FIELD_TCP_PORT_SRC):1965return CC_PC_FF_L4PSRC;19661967case (NET_HEADER_FIELD_TCP_PORT_DST):1968return CC_PC_FF_L4PDST;19691970case (NET_HEADER_FIELD_TCP_PORT_DST1971| NET_HEADER_FIELD_TCP_PORT_SRC):1972return CC_PC_FF_L4PSRC_L4PDST;19731974default:1975REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));1976return CC_PC_ILLEGAL;1977}19781979case (HEADER_TYPE_PPPoE):1980switch (field.pppoe)1981{1982case (NET_HEADER_FIELD_PPPoE_PID):1983return CC_PC_FF_PPPPID;19841985default:1986REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));1987return CC_PC_ILLEGAL;1988}19891990case (HEADER_TYPE_UDP):1991switch (field.udp)1992{1993case (NET_HEADER_FIELD_UDP_PORT_SRC):1994return CC_PC_FF_L4PSRC;19951996case (NET_HEADER_FIELD_UDP_PORT_DST):1997return CC_PC_FF_L4PDST;19981999case (NET_HEADER_FIELD_UDP_PORT_DST2000| NET_HEADER_FIELD_UDP_PORT_SRC):2001return CC_PC_FF_L4PSRC_L4PDST;20022003default:2004REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));2005return CC_PC_ILLEGAL;2006}20072008default:2009REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));2010return CC_PC_ILLEGAL;2011}2012}20132014static uint8_t GetPrParseCode(e_NetHeaderType hdr, e_FmPcdHdrIndex hdrIndex,2015uint32_t offset, bool glblMask,2016uint8_t *parseArrayOffset)2017{2018bool offsetRelevant = FALSE;20192020if (offset)2021offsetRelevant = TRUE;20222023switch (hdr)2024{2025case (HEADER_TYPE_NONE):2026ASSERT_COND(FALSE);2027return CC_PC_ILLEGAL;20282029case (HEADER_TYPE_ETH):2030*parseArrayOffset = (uint8_t)CC_PC_PR_ETH_OFFSET;2031break;20322033case (HEADER_TYPE_USER_DEFINED_SHIM1):2034if (offset || glblMask)2035*parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM1_OFFSET;2036else2037return CC_PC_PR_SHIM1;2038break;20392040case (HEADER_TYPE_USER_DEFINED_SHIM2):2041if (offset || glblMask)2042*parseArrayOffset = (uint8_t)CC_PC_PR_USER_DEFINED_SHIM2_OFFSET;2043else2044return CC_PC_PR_SHIM2;2045break;20462047case (HEADER_TYPE_LLC_SNAP):2048*parseArrayOffset = CC_PC_PR_USER_LLC_SNAP_OFFSET;2049break;20502051case (HEADER_TYPE_PPPoE):2052*parseArrayOffset = CC_PC_PR_PPPOE_OFFSET;2053break;20542055case (HEADER_TYPE_MPLS):2056if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)2057|| (hdrIndex == e_FM_PCD_HDR_INDEX_1))2058*parseArrayOffset = CC_PC_PR_MPLS1_OFFSET;2059else2060if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)2061*parseArrayOffset = CC_PC_PR_MPLS_LAST_OFFSET;2062else2063{2064REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal MPLS header index"));2065return CC_PC_ILLEGAL;2066}2067break;20682069case (HEADER_TYPE_IPv4):2070case (HEADER_TYPE_IPv6):2071if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)2072|| (hdrIndex == e_FM_PCD_HDR_INDEX_1))2073*parseArrayOffset = CC_PC_PR_IP1_OFFSET;2074else2075if (hdrIndex == e_FM_PCD_HDR_INDEX_2)2076*parseArrayOffset = CC_PC_PR_IP_LAST_OFFSET;2077else2078{2079REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP header index"));2080return CC_PC_ILLEGAL;2081}2082break;20832084case (HEADER_TYPE_MINENCAP):2085*parseArrayOffset = CC_PC_PR_MINENC_OFFSET;2086break;20872088case (HEADER_TYPE_GRE):2089*parseArrayOffset = CC_PC_PR_GRE_OFFSET;2090break;20912092case (HEADER_TYPE_TCP):2093case (HEADER_TYPE_UDP):2094case (HEADER_TYPE_IPSEC_AH):2095case (HEADER_TYPE_IPSEC_ESP):2096case (HEADER_TYPE_DCCP):2097case (HEADER_TYPE_SCTP):2098*parseArrayOffset = CC_PC_PR_L4_OFFSET;2099break;21002101default:2102REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal IP header for this type of operation"));2103return CC_PC_ILLEGAL;2104}21052106if (offsetRelevant)2107return CC_PR_OFFSET;2108else2109return CC_PR_WITHOUT_OFFSET;2110}21112112static uint8_t GetFieldParseCode(e_NetHeaderType hdr, t_FmPcdFields field,2113uint32_t offset, uint8_t *parseArrayOffset,2114e_FmPcdHdrIndex hdrIndex)2115{2116bool offsetRelevant = FALSE;21172118if (offset)2119offsetRelevant = TRUE;21202121switch (hdr)2122{2123case (HEADER_TYPE_NONE):2124ASSERT_COND(FALSE);2125break;2126case (HEADER_TYPE_ETH):2127switch (field.eth)2128{2129case (NET_HEADER_FIELD_ETH_TYPE):2130*parseArrayOffset = CC_PC_PR_ETYPE_LAST_OFFSET;2131break;21322133default:2134REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));2135return CC_PC_ILLEGAL;2136}2137break;21382139case (HEADER_TYPE_VLAN):2140switch (field.vlan)2141{2142case (NET_HEADER_FIELD_VLAN_TCI):2143if ((hdrIndex == e_FM_PCD_HDR_INDEX_NONE)2144|| (hdrIndex == e_FM_PCD_HDR_INDEX_1))2145*parseArrayOffset = CC_PC_PR_VLAN1_OFFSET;2146else2147if (hdrIndex == e_FM_PCD_HDR_INDEX_LAST)2148*parseArrayOffset = CC_PC_PR_VLAN2_OFFSET;2149break;21502151default:2152REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Extraction not supported"));2153return CC_PC_ILLEGAL;2154}2155break;21562157default:2158REPORT_ERROR(MAJOR, E_NOT_SUPPORTED, ("Illegal header "));2159return CC_PC_ILLEGAL;2160}21612162if (offsetRelevant)2163return CC_PR_OFFSET;2164else2165return CC_PR_WITHOUT_OFFSET;2166}21672168static void FillAdOfTypeResult(t_Handle h_Ad,2169t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,2170t_FmPcd *p_FmPcd,2171t_FmPcdCcNextEngineParams *p_CcNextEngineParams)2172{2173t_AdOfTypeResult *p_AdResult = (t_AdOfTypeResult *)h_Ad;2174t_Handle h_TmpAd;2175uint32_t tmp = 0, tmpNia = 0;2176uint16_t profileId;2177t_Handle p_AdNewPtr = NULL;2178t_Error err = E_OK;21792180/* There are 3 cases handled in this routine of building a "result" type AD.2181* Case 1: No Manip. The action descriptor is built within the match table.2182* Case 2: Manip exists. A new AD is created - p_AdNewPtr. It is initialized2183* either in the FmPcdManipUpdateAdResultForCc routine or it was already2184* initialized and returned here.2185* p_AdResult (within the match table) will be initialized after2186* this routine returns and point to the existing AD.2187* Case 3: Manip exists. The action descriptor is built within the match table.2188* FmPcdManipUpdateAdResultForCc returns a NULL p_AdNewPtr.2189*2190* If statistics were enabled and the statistics mode of this node requires2191* a statistics Ad, it will be placed after the result Ad and before the2192* manip Ad, if manip Ad exists here.2193*/21942195/* As default, the "new" ptr is the current one. i.e. the content of the result2196* AD will be written into the match table itself (case (1))*/2197p_AdNewPtr = p_AdResult;21982199/* Initialize an action descriptor, if current statistics mode requires an Ad */2200if (p_FmPcdCcStatsParams)2201{2202ASSERT_COND(p_FmPcdCcStatsParams->h_StatsAd);2203ASSERT_COND(p_FmPcdCcStatsParams->h_StatsCounters);22042205/* Swapping addresses between statistics Ad and the current lookup AD addresses */2206h_TmpAd = p_FmPcdCcStatsParams->h_StatsAd;2207p_FmPcdCcStatsParams->h_StatsAd = h_Ad;2208h_Ad = h_TmpAd;22092210p_AdNewPtr = h_Ad;2211p_AdResult = h_Ad;22122213/* Init statistics Ad and connect current lookup AD as 'next action' from statistics Ad */2214UpdateStatsAd(p_FmPcdCcStatsParams, h_Ad, p_FmPcd->physicalMuramBase);2215}22162217/* Create manip and return p_AdNewPtr to either a new descriptor or NULL */2218if (p_CcNextEngineParams->h_Manip)2219FmPcdManipUpdateAdResultForCc(p_CcNextEngineParams->h_Manip,2220p_CcNextEngineParams, h_Ad, &p_AdNewPtr);22212222/* if (p_AdNewPtr = NULL) --> Done. (case (3)) */2223if (p_AdNewPtr)2224{2225/* case (1) and (2) */2226switch (p_CcNextEngineParams->nextEngine)2227{2228case (e_FM_PCD_DONE):2229if (p_CcNextEngineParams->params.enqueueParams.action2230== e_FM_PCD_ENQ_FRAME)2231{2232if (p_CcNextEngineParams->params.enqueueParams.overrideFqid)2233{2234tmp = FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE;2235tmp |=2236p_CcNextEngineParams->params.enqueueParams.newFqid;2237#if (DPAA_VERSION >= 11)2238tmp |=2239(p_CcNextEngineParams->params.enqueueParams.newRelativeStorageProfileId2240& FM_PCD_AD_RESULT_VSP_MASK)2241<< FM_PCD_AD_RESULT_VSP_SHIFT;2242#endif /* (DPAA_VERSION >= 11) */2243}2244else2245{2246tmp = FM_PCD_AD_RESULT_DATA_FLOW_TYPE;2247tmp |= FM_PCD_AD_RESULT_PLCR_DIS;2248}2249}22502251if (p_CcNextEngineParams->params.enqueueParams.action2252== e_FM_PCD_DROP_FRAME)2253tmpNia |= GET_NIA_BMI_AC_DISCARD_FRAME(p_FmPcd);2254else2255tmpNia |= GET_NIA_BMI_AC_ENQ_FRAME(p_FmPcd);2256break;22572258case (e_FM_PCD_KG):2259if (p_CcNextEngineParams->params.kgParams.overrideFqid)2260{2261tmp = FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE;2262tmp |= p_CcNextEngineParams->params.kgParams.newFqid;2263#if (DPAA_VERSION >= 11)2264tmp |=2265(p_CcNextEngineParams->params.kgParams.newRelativeStorageProfileId2266& FM_PCD_AD_RESULT_VSP_MASK)2267<< FM_PCD_AD_RESULT_VSP_SHIFT;2268#endif /* (DPAA_VERSION >= 11) */2269}2270else2271{2272tmp = FM_PCD_AD_RESULT_DATA_FLOW_TYPE;2273tmp |= FM_PCD_AD_RESULT_PLCR_DIS;2274}2275tmpNia = NIA_KG_DIRECT;2276tmpNia |= NIA_ENG_KG;2277tmpNia |= NIA_KG_CC_EN;2278tmpNia |= FmPcdKgGetSchemeId(2279p_CcNextEngineParams->params.kgParams.h_DirectScheme);2280break;22812282case (e_FM_PCD_PLCR):2283if (p_CcNextEngineParams->params.plcrParams.overrideParams)2284{2285tmp = FM_PCD_AD_RESULT_CONTRL_FLOW_TYPE;22862287/* if private policer profile, it may be uninitialized yet, therefore no checks are done at this stage */2288if (p_CcNextEngineParams->params.plcrParams.sharedProfile)2289{2290tmpNia |= NIA_PLCR_ABSOLUTE;2291err = FmPcdPlcrGetAbsoluteIdByProfileParams(2292(t_Handle)p_FmPcd,2293e_FM_PCD_PLCR_SHARED,2294NULL,2295p_CcNextEngineParams->params.plcrParams.newRelativeProfileId,2296&profileId);2297if (err != E_OK)2298return;22992300}2301else2302profileId =2303p_CcNextEngineParams->params.plcrParams.newRelativeProfileId;23042305tmp |= p_CcNextEngineParams->params.plcrParams.newFqid;2306#if (DPAA_VERSION >= 11)2307tmp |=2308(p_CcNextEngineParams->params.plcrParams.newRelativeStorageProfileId2309& FM_PCD_AD_RESULT_VSP_MASK)2310<< FM_PCD_AD_RESULT_VSP_SHIFT;2311#endif /* (DPAA_VERSION >= 11) */2312WRITE_UINT32(2313p_AdResult->plcrProfile,2314(uint32_t)((uint32_t)profileId << FM_PCD_AD_PROFILEID_FOR_CNTRL_SHIFT));2315}2316else2317tmp = FM_PCD_AD_RESULT_DATA_FLOW_TYPE;23182319tmpNia |=2320NIA_ENG_PLCR2321| p_CcNextEngineParams->params.plcrParams.newRelativeProfileId;2322break;23232324default:2325return;2326}WRITE_UINT32(p_AdResult->fqid, tmp);23272328if (p_CcNextEngineParams->h_Manip)2329{2330tmp = GET_UINT32(p_AdResult->plcrProfile);2331tmp |= (uint32_t)(XX_VirtToPhys(p_AdNewPtr)2332- (p_FmPcd->physicalMuramBase)) >> 4;2333WRITE_UINT32(p_AdResult->plcrProfile, tmp);23342335tmpNia |= FM_PCD_AD_RESULT_EXTENDED_MODE;2336tmpNia |= FM_PCD_AD_RESULT_NADEN;2337}23382339#if (DPAA_VERSION >= 11)2340tmpNia |= FM_PCD_AD_RESULT_NO_OM_VSPE;2341#endif /* (DPAA_VERSION >= 11) */2342WRITE_UINT32(p_AdResult->nia, tmpNia);2343}2344}23452346static t_Error CcUpdateParams(t_Handle h_FmPcd, t_Handle h_PcdParams,2347t_Handle h_FmPort, t_Handle h_FmTree,2348bool validate)2349{2350t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_FmTree;23512352return CcUpdateParam(h_FmPcd, h_PcdParams, h_FmPort,2353p_CcTree->keyAndNextEngineParams,2354p_CcTree->numOfEntries,2355UINT_TO_PTR(p_CcTree->ccTreeBaseAddr), validate, 0,2356h_FmTree, FALSE);2357}235823592360static void ReleaseNewNodeCommonPart(2361t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)2362{2363if (p_AdditionalInfo->p_AdTableNew)2364FM_MURAM_FreeMem(2365FmPcdGetMuramHandle(2366((t_FmPcdCcNode *)(p_AdditionalInfo->h_CurrentNode))->h_FmPcd),2367p_AdditionalInfo->p_AdTableNew);23682369if (p_AdditionalInfo->p_KeysMatchTableNew)2370FM_MURAM_FreeMem(2371FmPcdGetMuramHandle(2372((t_FmPcdCcNode *)(p_AdditionalInfo->h_CurrentNode))->h_FmPcd),2373p_AdditionalInfo->p_KeysMatchTableNew);2374}23752376static t_Error UpdateGblMask(t_FmPcdCcNode *p_CcNode, uint8_t keySize,2377uint8_t *p_Mask)2378{2379uint8_t prvGlblMaskSize = p_CcNode->glblMaskSize;23802381if (p_Mask && !p_CcNode->glblMaskUpdated && (keySize <= 4)2382&& !p_CcNode->lclMask)2383{2384if (p_CcNode->parseCode && (p_CcNode->parseCode != CC_PC_FF_TCI1)2385&& (p_CcNode->parseCode != CC_PC_FF_TCI2)2386&& (p_CcNode->parseCode != CC_PC_FF_MPLS1)2387&& (p_CcNode->parseCode != CC_PC_FF_MPLS_LAST)2388&& (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC1)2389&& (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC2)2390&& (p_CcNode->parseCode != CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1)2391&& (p_CcNode->parseCode != CC_PC_FF_IPDSCP)2392&& (p_CcNode->parseCode != CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2))2393{2394p_CcNode->glblMaskSize = 0;2395p_CcNode->lclMask = TRUE;2396}2397else2398{2399memcpy(p_CcNode->p_GlblMask, p_Mask, (sizeof(uint8_t)) * keySize);2400p_CcNode->glblMaskUpdated = TRUE;2401p_CcNode->glblMaskSize = 4;2402}2403}2404else2405if (p_Mask && (keySize <= 4) && !p_CcNode->lclMask)2406{2407if (memcmp(p_CcNode->p_GlblMask, p_Mask, keySize) != 0)2408{2409p_CcNode->lclMask = TRUE;2410p_CcNode->glblMaskSize = 0;2411}2412}2413else2414if (!p_Mask && p_CcNode->glblMaskUpdated && (keySize <= 4))2415{2416uint32_t tmpMask = 0xffffffff;2417if (memcmp(p_CcNode->p_GlblMask, &tmpMask, 4) != 0)2418{2419p_CcNode->lclMask = TRUE;2420p_CcNode->glblMaskSize = 0;2421}2422}2423else2424if (p_Mask)2425{2426p_CcNode->lclMask = TRUE;2427p_CcNode->glblMaskSize = 0;2428}24292430/* In static mode (maxNumOfKeys > 0), local mask is supported2431only is mask support was enabled at initialization */2432if (p_CcNode->maxNumOfKeys && (!p_CcNode->maskSupport) && p_CcNode->lclMask)2433{2434p_CcNode->lclMask = FALSE;2435p_CcNode->glblMaskSize = prvGlblMaskSize;2436return ERROR_CODE(E_NOT_SUPPORTED);2437}24382439return E_OK;2440}24412442static __inline__ t_Handle GetNewAd(t_Handle h_FmPcdCcNodeOrTree, bool isTree)2443{2444t_FmPcd *p_FmPcd;2445t_Handle h_Ad;24462447if (isTree)2448p_FmPcd = (t_FmPcd *)(((t_FmPcdCcTree *)h_FmPcdCcNodeOrTree)->h_FmPcd);2449else2450p_FmPcd = (t_FmPcd *)(((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->h_FmPcd);24512452if ((isTree && p_FmPcd->p_CcShadow)2453|| (!isTree && ((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->maxNumOfKeys))2454{2455/* The allocated shadow is divided as follows:24560 . . . 16 . . .2457---------------------------------------------------2458| Shadow | Shadow Keys | Shadow Next |2459| Ad | Match Table | Engine Table |2460| (16 bytes) | (maximal size) | (maximal size) |2461---------------------------------------------------2462*/2463if (!p_FmPcd->p_CcShadow)2464{2465REPORT_ERROR(MAJOR, E_NO_MEMORY, ("CC Shadow not allocated"));2466return NULL;2467}24682469h_Ad = p_FmPcd->p_CcShadow;2470}2471else2472{2473h_Ad = (t_Handle)FM_MURAM_AllocMem(FmPcdGetMuramHandle(p_FmPcd),2474FM_PCD_CC_AD_ENTRY_SIZE,2475FM_PCD_CC_AD_TABLE_ALIGN);2476if (!h_Ad)2477{2478REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC node action descriptor"));2479return NULL;2480}2481}24822483return h_Ad;2484}24852486static t_Error BuildNewNodeCommonPart(2487t_FmPcdCcNode *p_CcNode, int *size,2488t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)2489{2490t_FmPcd *p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;24912492if (p_CcNode->lclMask)2493*size = 2 * p_CcNode->ccKeySizeAccExtraction;2494else2495*size = p_CcNode->ccKeySizeAccExtraction;24962497if (p_CcNode->maxNumOfKeys == 0)2498{2499p_AdditionalInfo->p_AdTableNew = (t_Handle)FM_MURAM_AllocMem(2500FmPcdGetMuramHandle(p_FmPcd),2501(uint32_t)((p_AdditionalInfo->numOfKeys + 1)2502* FM_PCD_CC_AD_ENTRY_SIZE),2503FM_PCD_CC_AD_TABLE_ALIGN);2504if (!p_AdditionalInfo->p_AdTableNew)2505RETURN_ERROR(2506MAJOR, E_NO_MEMORY,2507("MURAM allocation for CC node action descriptors table"));25082509p_AdditionalInfo->p_KeysMatchTableNew = (t_Handle)FM_MURAM_AllocMem(2510FmPcdGetMuramHandle(p_FmPcd),2511(uint32_t)(*size * sizeof(uint8_t)2512* (p_AdditionalInfo->numOfKeys + 1)),2513FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN);2514if (!p_AdditionalInfo->p_KeysMatchTableNew)2515{2516FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_CcNode->h_FmPcd),2517p_AdditionalInfo->p_AdTableNew);2518p_AdditionalInfo->p_AdTableNew = NULL;2519RETURN_ERROR(MAJOR, E_NO_MEMORY,2520("MURAM allocation for CC node key match table"));2521}25222523MemSet8(2524(uint8_t*)p_AdditionalInfo->p_AdTableNew,25250,2526(uint32_t)((p_AdditionalInfo->numOfKeys + 1)2527* FM_PCD_CC_AD_ENTRY_SIZE));2528MemSet8((uint8_t*)p_AdditionalInfo->p_KeysMatchTableNew, 0,2529*size * sizeof(uint8_t) * (p_AdditionalInfo->numOfKeys + 1));2530}2531else2532{2533/* The allocated shadow is divided as follows:25340 . . . 16 . . .2535---------------------------------------------------2536| Shadow | Shadow Keys | Shadow Next |2537| Ad | Match Table | Engine Table |2538| (16 bytes) | (maximal size) | (maximal size) |2539---------------------------------------------------2540*/25412542if (!p_FmPcd->p_CcShadow)2543RETURN_ERROR(MAJOR, E_NO_MEMORY, ("CC Shadow not allocated"));25442545p_AdditionalInfo->p_KeysMatchTableNew =2546PTR_MOVE(p_FmPcd->p_CcShadow, FM_PCD_CC_AD_ENTRY_SIZE);2547p_AdditionalInfo->p_AdTableNew =2548PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, p_CcNode->keysMatchTableMaxSize);25492550MemSet8(2551(uint8_t*)p_AdditionalInfo->p_AdTableNew,25520,2553(uint32_t)((p_CcNode->maxNumOfKeys + 1)2554* FM_PCD_CC_AD_ENTRY_SIZE));2555MemSet8((uint8_t*)p_AdditionalInfo->p_KeysMatchTableNew, 0,2556(*size) * sizeof(uint8_t) * (p_CcNode->maxNumOfKeys));2557}25582559p_AdditionalInfo->p_AdTableOld = p_CcNode->h_AdTable;2560p_AdditionalInfo->p_KeysMatchTableOld = p_CcNode->h_KeysMatchTable;25612562return E_OK;2563}25642565static t_Error BuildNewNodeAddOrMdfyKeyAndNextEngine(2566t_Handle h_FmPcd, t_FmPcdCcNode *p_CcNode, uint16_t keyIndex,2567t_FmPcdCcKeyParams *p_KeyParams,2568t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo, bool add)2569{2570t_Error err = E_OK;2571t_Handle p_AdTableNewTmp, p_KeysMatchTableNewTmp;2572t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;2573int size;2574int i = 0, j = 0;2575t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;2576uint32_t requiredAction = 0;2577bool prvLclMask;2578t_CcNodeInformation *p_CcNodeInformation;2579t_FmPcdCcStatsParams statsParams = { 0 };2580t_List *p_Pos;2581t_FmPcdStatsObj *p_StatsObj;25822583/* Check that new NIA is legal */2584err = ValidateNextEngineParams(h_FmPcd, &p_KeyParams->ccNextEngineParams,2585p_CcNode->statisticsMode);2586if (err)2587RETURN_ERROR(MAJOR, err, NO_MSG);25882589prvLclMask = p_CcNode->lclMask;25902591/* Check that new key is not require update of localMask */2592err = UpdateGblMask(p_CcNode, p_CcNode->ccKeySizeAccExtraction,2593p_KeyParams->p_Mask);2594if (err)2595RETURN_ERROR(MAJOR, err, (NO_MSG));25962597/* Update internal data structure with new next engine for the given index */2598memcpy(&p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams,2599&p_KeyParams->ccNextEngineParams, sizeof(t_FmPcdCcNextEngineParams));26002601memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].key,2602p_KeyParams->p_Key, p_CcNode->userSizeOfExtraction);26032604if ((p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine2605== e_FM_PCD_CC)2606&& p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)2607{2608err =2609AllocAndFillAdForContLookupManip(2610p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode);2611if (err)2612RETURN_ERROR(MAJOR, err, (NO_MSG));2613}26142615if (p_KeyParams->p_Mask)2616memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask,2617p_KeyParams->p_Mask, p_CcNode->userSizeOfExtraction);2618else2619memset(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask, 0xFF,2620p_CcNode->userSizeOfExtraction);26212622/* Update numOfKeys */2623if (add)2624p_AdditionalInfo->numOfKeys = (uint8_t)(p_CcNode->numOfKeys + 1);2625else2626p_AdditionalInfo->numOfKeys = (uint8_t)p_CcNode->numOfKeys;26272628/* Allocate new tables in MURAM: keys match table and action descriptors table */2629err = BuildNewNodeCommonPart(p_CcNode, &size, p_AdditionalInfo);2630if (err)2631RETURN_ERROR(MAJOR, err, NO_MSG);26322633/* Check that manip is legal and what requiredAction is necessary for this manip */2634if (p_KeyParams->ccNextEngineParams.h_Manip)2635{2636err = FmPcdManipCheckParamsForCcNextEngine(2637&p_KeyParams->ccNextEngineParams, &requiredAction);2638if (err)2639RETURN_ERROR(MAJOR, err, (NO_MSG));2640}26412642p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction =2643requiredAction;2644p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction |=2645UPDATE_CC_WITH_TREE;26462647/* Update new Ad and new Key Table according to new requirement */2648i = 0;2649for (j = 0; j < p_AdditionalInfo->numOfKeys; j++)2650{2651p_AdTableNewTmp =2652PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j*FM_PCD_CC_AD_ENTRY_SIZE);26532654if (j == keyIndex)2655{2656if (p_KeyParams->ccNextEngineParams.statisticsEn)2657{2658/* Allocate a statistics object that holds statistics AD and counters.2659- For added key - New statistics AD and counters pointer need to be allocated2660new statistics object. If statistics were enabled, we need to replace the2661existing descriptor with a new descriptor with nullified counters.2662*/2663p_StatsObj = GetStatsObj(p_CcNode);2664ASSERT_COND(p_StatsObj);26652666/* Store allocated statistics object */2667ASSERT_COND(keyIndex < CC_MAX_NUM_OF_KEYS);2668p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj =2669p_StatsObj;26702671statsParams.h_StatsAd = p_StatsObj->h_StatsAd;2672statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;2673#if (DPAA_VERSION >= 11)2674statsParams.h_StatsFLRs = p_CcNode->h_StatsFLRs;26752676#endif /* (DPAA_VERSION >= 11) */26772678/* Building action descriptor for the received new key */2679NextStepAd(p_AdTableNewTmp, &statsParams,2680&p_KeyParams->ccNextEngineParams, p_FmPcd);2681}2682else2683{2684/* Building action descriptor for the received new key */2685NextStepAd(p_AdTableNewTmp, NULL,2686&p_KeyParams->ccNextEngineParams, p_FmPcd);2687}26882689/* Copy the received new key into keys match table */2690p_KeysMatchTableNewTmp =2691PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j*size*sizeof(uint8_t));26922693MemCpy8((void*)p_KeysMatchTableNewTmp, p_KeyParams->p_Key,2694p_CcNode->userSizeOfExtraction);26952696/* Update mask for the received new key */2697if (p_CcNode->lclMask)2698{2699if (p_KeyParams->p_Mask)2700{2701MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,2702p_CcNode->ccKeySizeAccExtraction),2703p_KeyParams->p_Mask,2704p_CcNode->userSizeOfExtraction);2705}2706else2707if (p_CcNode->ccKeySizeAccExtraction > 4)2708{2709MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,2710p_CcNode->ccKeySizeAccExtraction),27110xff, p_CcNode->userSizeOfExtraction);2712}2713else2714{2715MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,2716p_CcNode->ccKeySizeAccExtraction),2717p_CcNode->p_GlblMask,2718p_CcNode->userSizeOfExtraction);2719}2720}27212722/* If key modification requested, the old entry is omitted and replaced by the new parameters */2723if (!add)2724i++;2725}2726else2727{2728/* Copy existing action descriptors to the newly allocated Ad table */2729p_AdTableOldTmp =2730PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i*FM_PCD_CC_AD_ENTRY_SIZE);2731MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp,2732FM_PCD_CC_AD_ENTRY_SIZE);27332734/* Copy existing keys and their masks to the newly allocated keys match table */2735p_KeysMatchTableNewTmp =2736PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j * size * sizeof(uint8_t));2737p_KeysMatchTableOldTmp =2738PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableOld, i * size * sizeof(uint8_t));27392740if (p_CcNode->lclMask)2741{2742if (prvLclMask)2743{2744MemCpy8(2745PTR_MOVE(p_KeysMatchTableNewTmp, p_CcNode->ccKeySizeAccExtraction),2746PTR_MOVE(p_KeysMatchTableOldTmp, p_CcNode->ccKeySizeAccExtraction),2747p_CcNode->ccKeySizeAccExtraction);2748}2749else2750{2751p_KeysMatchTableOldTmp =2752PTR_MOVE(p_CcNode->h_KeysMatchTable,2753i * (int)p_CcNode->ccKeySizeAccExtraction * sizeof(uint8_t));27542755if (p_CcNode->ccKeySizeAccExtraction > 4)2756{2757MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,2758p_CcNode->ccKeySizeAccExtraction),27590xff, p_CcNode->userSizeOfExtraction);2760}2761else2762{2763MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,2764p_CcNode->ccKeySizeAccExtraction),2765p_CcNode->p_GlblMask,2766p_CcNode->userSizeOfExtraction);2767}2768}2769}27702771MemCpy8(p_KeysMatchTableNewTmp, p_KeysMatchTableOldTmp,2772p_CcNode->ccKeySizeAccExtraction);27732774i++;2775}2776}27772778/* Miss action descriptor */2779p_AdTableNewTmp =2780PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j * FM_PCD_CC_AD_ENTRY_SIZE);2781p_AdTableOldTmp =2782PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i * FM_PCD_CC_AD_ENTRY_SIZE);2783MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);27842785if (!NCSW_LIST_IsEmpty(&p_CcNode->ccTreesLst))2786{2787NCSW_LIST_FOR_EACH(p_Pos, &p_CcNode->ccTreesLst)2788{2789p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);2790ASSERT_COND(p_CcNodeInformation->h_CcNode);2791/* Update the manipulation which has to be updated from parameters of the port */2792/* It's has to be updated with restrictions defined in the function */2793err =2794SetRequiredAction(2795p_CcNode->h_FmPcd,2796p_CcNode->shadowAction2797| p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction,2798&p_AdditionalInfo->keyAndNextEngineParams[keyIndex],2799PTR_MOVE(p_AdditionalInfo->p_AdTableNew, keyIndex*FM_PCD_CC_AD_ENTRY_SIZE),28001, p_CcNodeInformation->h_CcNode);2801if (err)2802RETURN_ERROR(MAJOR, err, (NO_MSG));28032804err =2805CcUpdateParam(2806p_CcNode->h_FmPcd,2807NULL,2808NULL,2809&p_AdditionalInfo->keyAndNextEngineParams[keyIndex],28101,2811PTR_MOVE(p_AdditionalInfo->p_AdTableNew, keyIndex*FM_PCD_CC_AD_ENTRY_SIZE),2812TRUE, p_CcNodeInformation->index,2813p_CcNodeInformation->h_CcNode, TRUE);2814if (err)2815RETURN_ERROR(MAJOR, err, (NO_MSG));2816}2817}28182819if (p_CcNode->lclMask)2820memset(p_CcNode->p_GlblMask, 0xff, CC_GLBL_MASK_SIZE * sizeof(uint8_t));28212822if (p_KeyParams->ccNextEngineParams.nextEngine == e_FM_PCD_CC)2823p_AdditionalInfo->h_NodeForAdd =2824p_KeyParams->ccNextEngineParams.params.ccParams.h_CcNode;2825if (p_KeyParams->ccNextEngineParams.h_Manip)2826p_AdditionalInfo->h_ManipForAdd =2827p_KeyParams->ccNextEngineParams.h_Manip;28282829#if (DPAA_VERSION >= 11)2830if ((p_KeyParams->ccNextEngineParams.nextEngine == e_FM_PCD_FR)2831&& (p_KeyParams->ccNextEngineParams.params.frParams.h_FrmReplic))2832p_AdditionalInfo->h_FrmReplicForAdd =2833p_KeyParams->ccNextEngineParams.params.frParams.h_FrmReplic;2834#endif /* (DPAA_VERSION >= 11) */28352836if (!add)2837{2838if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine2839== e_FM_PCD_CC)2840p_AdditionalInfo->h_NodeForRmv =2841p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;28422843if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)2844p_AdditionalInfo->h_ManipForRmv =2845p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;28462847/* If statistics were previously enabled, store the old statistics object to be released */2848if (p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)2849{2850p_AdditionalInfo->p_StatsObjForRmv =2851p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj;2852}28532854#if (DPAA_VERSION >= 11)2855if ((p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine2856== e_FM_PCD_FR)2857&& (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))2858p_AdditionalInfo->h_FrmReplicForRmv =2859p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;2860#endif /* (DPAA_VERSION >= 11) */2861}28622863return E_OK;2864}28652866static t_Error BuildNewNodeRemoveKey(2867t_FmPcdCcNode *p_CcNode, uint16_t keyIndex,2868t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)2869{2870int i = 0, j = 0;2871t_Handle p_AdTableNewTmp, p_KeysMatchTableNewTmp;2872t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;2873int size;2874t_Error err = E_OK;28752876/*save new numOfKeys*/2877p_AdditionalInfo->numOfKeys = (uint16_t)(p_CcNode->numOfKeys - 1);28782879/*function which allocates in the memory new KeyTbl, AdTbl*/2880err = BuildNewNodeCommonPart(p_CcNode, &size, p_AdditionalInfo);2881if (err)2882RETURN_ERROR(MAJOR, err, NO_MSG);28832884/*update new Ad and new Key Table according to new requirement*/2885for (i = 0, j = 0; j < p_CcNode->numOfKeys; i++, j++)2886{2887if (j == keyIndex)2888j++;28892890if (j == p_CcNode->numOfKeys)2891break;2892p_AdTableNewTmp =2893PTR_MOVE(p_AdditionalInfo->p_AdTableNew, i * FM_PCD_CC_AD_ENTRY_SIZE);2894p_AdTableOldTmp =2895PTR_MOVE(p_AdditionalInfo->p_AdTableOld, j * FM_PCD_CC_AD_ENTRY_SIZE);2896MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);28972898p_KeysMatchTableOldTmp =2899PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableOld, j * size * sizeof(uint8_t));2900p_KeysMatchTableNewTmp =2901PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, i * size * sizeof(uint8_t));2902MemCpy8(p_KeysMatchTableNewTmp, p_KeysMatchTableOldTmp,2903size * sizeof(uint8_t));2904}29052906p_AdTableNewTmp =2907PTR_MOVE(p_AdditionalInfo->p_AdTableNew, i * FM_PCD_CC_AD_ENTRY_SIZE);2908p_AdTableOldTmp =2909PTR_MOVE(p_AdditionalInfo->p_AdTableOld, j * FM_PCD_CC_AD_ENTRY_SIZE);2910MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);29112912if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine2913== e_FM_PCD_CC)2914p_AdditionalInfo->h_NodeForRmv =2915p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;29162917if (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)2918p_AdditionalInfo->h_ManipForRmv =2919p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;29202921/* If statistics were previously enabled, store the old statistics object to be released */2922if (p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)2923{2924p_AdditionalInfo->p_StatsObjForRmv =2925p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj;2926}29272928#if (DPAA_VERSION >= 11)2929if ((p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine2930== e_FM_PCD_FR)2931&& (p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))2932p_AdditionalInfo->h_FrmReplicForRmv =2933p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;2934#endif /* (DPAA_VERSION >= 11) */29352936return E_OK;2937}29382939static t_Error BuildNewNodeModifyKey(2940t_FmPcdCcNode *p_CcNode, uint16_t keyIndex, uint8_t *p_Key,2941uint8_t *p_Mask, t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)2942{2943t_FmPcd *p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;2944t_Error err = E_OK;2945t_Handle p_AdTableNewTmp, p_KeysMatchTableNewTmp;2946t_Handle p_KeysMatchTableOldTmp, p_AdTableOldTmp;2947int size;2948int i = 0, j = 0;2949bool prvLclMask;2950t_FmPcdStatsObj *p_StatsObj, tmpStatsObj;2951p_AdditionalInfo->numOfKeys = p_CcNode->numOfKeys;29522953prvLclMask = p_CcNode->lclMask;29542955/* Check that new key is not require update of localMask */2956err = UpdateGblMask(p_CcNode, p_CcNode->ccKeySizeAccExtraction, p_Mask);2957if (err)2958RETURN_ERROR(MAJOR, err, (NO_MSG));29592960/* Update internal data structure with new next engine for the given index */2961memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].key, p_Key,2962p_CcNode->userSizeOfExtraction);29632964if (p_Mask)2965memcpy(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask, p_Mask,2966p_CcNode->userSizeOfExtraction);2967else2968memset(p_AdditionalInfo->keyAndNextEngineParams[keyIndex].mask, 0xFF,2969p_CcNode->userSizeOfExtraction);29702971/*function which build in the memory new KeyTbl, AdTbl*/2972err = BuildNewNodeCommonPart(p_CcNode, &size, p_AdditionalInfo);2973if (err)2974RETURN_ERROR(MAJOR, err, NO_MSG);29752976/*fill the New AdTable and New KeyTable*/2977for (j = 0, i = 0; j < p_AdditionalInfo->numOfKeys; j++, i++)2978{2979p_AdTableNewTmp =2980PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j*FM_PCD_CC_AD_ENTRY_SIZE);2981p_AdTableOldTmp =2982PTR_MOVE(p_AdditionalInfo->p_AdTableOld, i*FM_PCD_CC_AD_ENTRY_SIZE);29832984MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);29852986if (j == keyIndex)2987{2988ASSERT_COND(keyIndex < CC_MAX_NUM_OF_KEYS);2989if (p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)2990{2991/* As statistics were enabled, we need to update the existing2992statistics descriptor with a new nullified counters. */2993p_StatsObj = GetStatsObj(p_CcNode);2994ASSERT_COND(p_StatsObj);29952996SetStatsCounters(2997p_AdTableNewTmp,2998(uint32_t)((XX_VirtToPhys(p_StatsObj->h_StatsCounters)2999- p_FmPcd->physicalMuramBase)));30003001tmpStatsObj.h_StatsAd = p_StatsObj->h_StatsAd;3002tmpStatsObj.h_StatsCounters = p_StatsObj->h_StatsCounters;30033004/* As we need to replace only the counters, we build a new statistics3005object that holds the old AD and the new counters - this will be the3006currently used statistics object.3007The newly allocated AD is not required and may be released back to3008the available objects with the previous counters pointer. */3009p_StatsObj->h_StatsAd =3010p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsAd;30113012p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsAd =3013tmpStatsObj.h_StatsAd;30143015/* Store allocated statistics object */3016p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj =3017p_StatsObj;30183019/* As statistics were previously enabled, store the old statistics object to be released */3020p_AdditionalInfo->p_StatsObjForRmv =3021p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj;3022}30233024p_KeysMatchTableNewTmp =3025PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j * size * sizeof(uint8_t));30263027MemCpy8(p_KeysMatchTableNewTmp, p_Key,3028p_CcNode->userSizeOfExtraction);30293030if (p_CcNode->lclMask)3031{3032if (p_Mask)3033MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,3034p_CcNode->ccKeySizeAccExtraction),3035p_Mask, p_CcNode->userSizeOfExtraction);3036else3037if (p_CcNode->ccKeySizeAccExtraction > 4)3038MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,3039p_CcNode->ccKeySizeAccExtraction),30400xff, p_CcNode->userSizeOfExtraction);3041else3042MemCpy8(PTR_MOVE(p_KeysMatchTableNewTmp,3043p_CcNode->ccKeySizeAccExtraction),3044p_CcNode->p_GlblMask,3045p_CcNode->userSizeOfExtraction);3046}3047}3048else3049{3050p_KeysMatchTableNewTmp =3051PTR_MOVE(p_AdditionalInfo->p_KeysMatchTableNew, j * size * sizeof(uint8_t));3052p_KeysMatchTableOldTmp =3053PTR_MOVE(p_CcNode->h_KeysMatchTable, i * size * sizeof(uint8_t));30543055if (p_CcNode->lclMask)3056{3057if (prvLclMask)3058MemCpy8(3059PTR_MOVE(p_KeysMatchTableNewTmp, p_CcNode->ccKeySizeAccExtraction),3060PTR_MOVE(p_KeysMatchTableOldTmp, p_CcNode->ccKeySizeAccExtraction),3061p_CcNode->userSizeOfExtraction);3062else3063{3064p_KeysMatchTableOldTmp =3065PTR_MOVE(p_CcNode->h_KeysMatchTable,3066i * (int)p_CcNode->ccKeySizeAccExtraction * sizeof(uint8_t));30673068if (p_CcNode->ccKeySizeAccExtraction > 4)3069MemSet8(PTR_MOVE(p_KeysMatchTableNewTmp,3070p_CcNode->ccKeySizeAccExtraction),30710xff, p_CcNode->userSizeOfExtraction);3072else3073MemCpy8(3074PTR_MOVE(p_KeysMatchTableNewTmp, p_CcNode->ccKeySizeAccExtraction),3075p_CcNode->p_GlblMask,3076p_CcNode->userSizeOfExtraction);3077}3078}3079MemCpy8((void*)p_KeysMatchTableNewTmp, p_KeysMatchTableOldTmp,3080p_CcNode->ccKeySizeAccExtraction);3081}3082}30833084p_AdTableNewTmp =3085PTR_MOVE(p_AdditionalInfo->p_AdTableNew, j * FM_PCD_CC_AD_ENTRY_SIZE);3086p_AdTableOldTmp = PTR_MOVE(p_CcNode->h_AdTable, i * FM_PCD_CC_AD_ENTRY_SIZE);30873088MemCpy8(p_AdTableNewTmp, p_AdTableOldTmp, FM_PCD_CC_AD_ENTRY_SIZE);30893090return E_OK;3091}30923093static t_Error BuildNewNodeModifyNextEngine(3094t_Handle h_FmPcd, t_Handle h_FmPcdCcNodeOrTree, uint16_t keyIndex,3095t_FmPcdCcNextEngineParams *p_CcNextEngineParams, t_List *h_OldLst,3096t_List *h_NewLst, t_FmPcdModifyCcKeyAdditionalParams *p_AdditionalInfo)3097{3098t_Error err = E_OK;3099uint32_t requiredAction = 0;3100t_List *p_Pos;3101t_CcNodeInformation *p_CcNodeInformation, ccNodeInfo;3102t_Handle p_Ad;3103t_FmPcdCcNode *p_FmPcdCcNode1 = NULL;3104t_FmPcdCcTree *p_FmPcdCcTree = NULL;3105t_FmPcdStatsObj *p_StatsObj;3106t_FmPcdCcStatsParams statsParams = { 0 };31073108ASSERT_COND(p_CcNextEngineParams);31093110/* check that new NIA is legal */3111if (!p_AdditionalInfo->tree)3112err = ValidateNextEngineParams(3113h_FmPcd, p_CcNextEngineParams,3114((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->statisticsMode);3115else3116/* Statistics are not supported for CC root */3117err = ValidateNextEngineParams(h_FmPcd, p_CcNextEngineParams,3118e_FM_PCD_CC_STATS_MODE_NONE);3119if (err)3120RETURN_ERROR(MAJOR, err, NO_MSG);31213122/* Update internal data structure for next engine per index (index - key) */3123memcpy(&p_AdditionalInfo->keyAndNextEngineParams[keyIndex].nextEngineParams,3124p_CcNextEngineParams, sizeof(t_FmPcdCcNextEngineParams));31253126/* Check that manip is legal and what requiredAction is necessary for this manip */3127if (p_CcNextEngineParams->h_Manip)3128{3129err = FmPcdManipCheckParamsForCcNextEngine(p_CcNextEngineParams,3130&requiredAction);3131if (err)3132RETURN_ERROR(MAJOR, err, (NO_MSG));3133}31343135if (!p_AdditionalInfo->tree)3136{3137p_FmPcdCcNode1 = (t_FmPcdCcNode *)h_FmPcdCcNodeOrTree;3138p_AdditionalInfo->numOfKeys = p_FmPcdCcNode1->numOfKeys;3139p_Ad = p_FmPcdCcNode1->h_AdTable;31403141if (p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine3142== e_FM_PCD_CC)3143p_AdditionalInfo->h_NodeForRmv =3144p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;31453146if (p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)3147p_AdditionalInfo->h_ManipForRmv =3148p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;31493150#if (DPAA_VERSION >= 11)3151if ((p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine3152== e_FM_PCD_FR)3153&& (p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))3154p_AdditionalInfo->h_FrmReplicForRmv =3155p_FmPcdCcNode1->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;3156#endif /* (DPAA_VERSION >= 11) */3157}3158else3159{3160p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcNodeOrTree;3161p_Ad = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);31623163if (p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine3164== e_FM_PCD_CC)3165p_AdditionalInfo->h_NodeForRmv =3166p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.params.ccParams.h_CcNode;31673168if (p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip)3169p_AdditionalInfo->h_ManipForRmv =3170p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.h_Manip;31713172#if (DPAA_VERSION >= 11)3173if ((p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.nextEngine3174== e_FM_PCD_FR)3175&& (p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic))3176p_AdditionalInfo->h_FrmReplicForRmv =3177p_FmPcdCcTree->keyAndNextEngineParams[keyIndex].nextEngineParams.params.frParams.h_FrmReplic;3178#endif /* (DPAA_VERSION >= 11) */3179}31803181if ((p_CcNextEngineParams->nextEngine == e_FM_PCD_CC)3182&& p_CcNextEngineParams->h_Manip)3183{3184err = AllocAndFillAdForContLookupManip(3185p_CcNextEngineParams->params.ccParams.h_CcNode);3186if (err)3187RETURN_ERROR(MAJOR, err, (NO_MSG));3188}31893190ASSERT_COND(p_Ad);31913192memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));3193ccNodeInfo.h_CcNode = PTR_MOVE(p_Ad, keyIndex * FM_PCD_CC_AD_ENTRY_SIZE);31943195/* If statistics were enabled, this Ad is the statistics Ad. Need to follow its3196nextAction to retrieve the actual Nia-Ad. If statistics should remain enabled,3197only the actual Nia-Ad should be modified. */3198if ((!p_AdditionalInfo->tree)3199&& (((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj)3200&& (p_CcNextEngineParams->statisticsEn))3201ccNodeInfo.h_CcNode =3202((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsAd;32033204EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo, NULL);32053206memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));3207p_Ad = GetNewAd(h_FmPcdCcNodeOrTree, p_AdditionalInfo->tree);3208if (!p_Ad)3209RETURN_ERROR(MAJOR, E_NO_MEMORY,3210("MURAM allocation for CC node action descriptor"));3211MemSet8((uint8_t *)p_Ad, 0, FM_PCD_CC_AD_ENTRY_SIZE);32123213/* If statistics were not enabled before, but requested now - Allocate a statistics3214object that holds statistics AD and counters. */3215if ((!p_AdditionalInfo->tree)3216&& (!((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj)3217&& (p_CcNextEngineParams->statisticsEn))3218{3219p_StatsObj = GetStatsObj((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree);3220ASSERT_COND(p_StatsObj);32213222/* Store allocated statistics object */3223p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj =3224p_StatsObj;32253226statsParams.h_StatsAd = p_StatsObj->h_StatsAd;3227statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;32283229#if (DPAA_VERSION >= 11)3230statsParams.h_StatsFLRs =3231((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->h_StatsFLRs;32323233#endif /* (DPAA_VERSION >= 11) */32343235NextStepAd(p_Ad, &statsParams, p_CcNextEngineParams, h_FmPcd);3236}3237else3238NextStepAd(p_Ad, NULL, p_CcNextEngineParams, h_FmPcd);32393240ccNodeInfo.h_CcNode = p_Ad;3241EnqueueNodeInfoToRelevantLst(h_NewLst, &ccNodeInfo, NULL);32423243p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction =3244requiredAction;3245p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction |=3246UPDATE_CC_WITH_TREE;32473248if (!p_AdditionalInfo->tree)3249{3250ASSERT_COND(p_FmPcdCcNode1);3251if (!NCSW_LIST_IsEmpty(&p_FmPcdCcNode1->ccTreesLst))3252{3253NCSW_LIST_FOR_EACH(p_Pos, &p_FmPcdCcNode1->ccTreesLst)3254{3255p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);32563257ASSERT_COND(p_CcNodeInformation->h_CcNode);3258/* Update the manipulation which has to be updated from parameters of the port3259it's has to be updated with restrictions defined in the function */32603261err =3262SetRequiredAction(3263p_FmPcdCcNode1->h_FmPcd,3264p_FmPcdCcNode1->shadowAction3265| p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction,3266&p_AdditionalInfo->keyAndNextEngineParams[keyIndex],3267p_Ad, 1, p_CcNodeInformation->h_CcNode);3268if (err)3269RETURN_ERROR(MAJOR, err, (NO_MSG));32703271err = CcUpdateParam(3272p_FmPcdCcNode1->h_FmPcd, NULL, NULL,3273&p_AdditionalInfo->keyAndNextEngineParams[keyIndex], 1,3274p_Ad, TRUE, p_CcNodeInformation->index,3275p_CcNodeInformation->h_CcNode, TRUE);3276if (err)3277RETURN_ERROR(MAJOR, err, (NO_MSG));3278}3279}3280}3281else3282{3283ASSERT_COND(p_FmPcdCcTree);32843285err =3286SetRequiredAction(3287h_FmPcd,3288p_FmPcdCcTree->requiredAction3289| p_AdditionalInfo->keyAndNextEngineParams[keyIndex].requiredAction,3290&p_AdditionalInfo->keyAndNextEngineParams[keyIndex],3291p_Ad, 1, (t_Handle)p_FmPcdCcTree);3292if (err)3293RETURN_ERROR(MAJOR, err, (NO_MSG));32943295err = CcUpdateParam(h_FmPcd, NULL, NULL,3296&p_AdditionalInfo->keyAndNextEngineParams[keyIndex],32971, p_Ad, TRUE, 0, (t_Handle)p_FmPcdCcTree, TRUE);3298if (err)3299RETURN_ERROR(MAJOR, err, (NO_MSG));3300}33013302if (p_CcNextEngineParams->nextEngine == e_FM_PCD_CC)3303p_AdditionalInfo->h_NodeForAdd =3304p_CcNextEngineParams->params.ccParams.h_CcNode;3305if (p_CcNextEngineParams->h_Manip)3306p_AdditionalInfo->h_ManipForAdd = p_CcNextEngineParams->h_Manip;33073308/* If statistics were previously enabled, but now are disabled,3309store the old statistics object to be released */3310if ((!p_AdditionalInfo->tree)3311&& (((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj)3312&& (!p_CcNextEngineParams->statisticsEn))3313{3314p_AdditionalInfo->p_StatsObjForRmv =3315((t_FmPcdCcNode *)h_FmPcdCcNodeOrTree)->keyAndNextEngineParams[keyIndex].p_StatsObj;331633173318p_AdditionalInfo->keyAndNextEngineParams[keyIndex].p_StatsObj = NULL;3319}3320#if (DPAA_VERSION >= 11)3321if ((p_CcNextEngineParams->nextEngine == e_FM_PCD_FR)3322&& (p_CcNextEngineParams->params.frParams.h_FrmReplic))3323p_AdditionalInfo->h_FrmReplicForAdd =3324p_CcNextEngineParams->params.frParams.h_FrmReplic;3325#endif /* (DPAA_VERSION >= 11) */33263327return E_OK;3328}33293330static void UpdateAdPtrOfNodesWhichPointsOnCrntMdfNode(3331t_FmPcdCcNode *p_CrntMdfNode, t_List *h_OldLst,3332t_FmPcdCcNextEngineParams **p_NextEngineParams)3333{3334t_CcNodeInformation *p_CcNodeInformation;3335t_FmPcdCcNode *p_NodePtrOnCurrentMdfNode = NULL;3336t_List *p_Pos;3337int i = 0;3338t_Handle p_AdTablePtOnCrntCurrentMdfNode/*, p_AdTableNewModified*/;3339t_CcNodeInformation ccNodeInfo;33403341NCSW_LIST_FOR_EACH(p_Pos, &p_CrntMdfNode->ccPrevNodesLst)3342{3343p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);3344p_NodePtrOnCurrentMdfNode =3345(t_FmPcdCcNode *)p_CcNodeInformation->h_CcNode;33463347ASSERT_COND(p_NodePtrOnCurrentMdfNode);33483349/* Search in the previous node which exact index points on this current modified node for getting AD */3350for (i = 0; i < p_NodePtrOnCurrentMdfNode->numOfKeys + 1; i++)3351{3352if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine3353== e_FM_PCD_CC)3354{3355if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode3356== (t_Handle)p_CrntMdfNode)3357{3358if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip)3359p_AdTablePtOnCrntCurrentMdfNode = p_CrntMdfNode->h_Ad;3360else3361if (p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].p_StatsObj)3362p_AdTablePtOnCrntCurrentMdfNode =3363p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].p_StatsObj->h_StatsAd;3364else3365p_AdTablePtOnCrntCurrentMdfNode =3366PTR_MOVE(p_NodePtrOnCurrentMdfNode->h_AdTable, i*FM_PCD_CC_AD_ENTRY_SIZE);33673368memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));3369ccNodeInfo.h_CcNode = p_AdTablePtOnCrntCurrentMdfNode;3370EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo, NULL);33713372if (!(*p_NextEngineParams))3373*p_NextEngineParams =3374&p_NodePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams;3375}3376}3377}33783379ASSERT_COND(i != p_NodePtrOnCurrentMdfNode->numOfKeys);3380}3381}33823383static void UpdateAdPtrOfTreesWhichPointsOnCrntMdfNode(3384t_FmPcdCcNode *p_CrntMdfNode, t_List *h_OldLst,3385t_FmPcdCcNextEngineParams **p_NextEngineParams)3386{3387t_CcNodeInformation *p_CcNodeInformation;3388t_FmPcdCcTree *p_TreePtrOnCurrentMdfNode = NULL;3389t_List *p_Pos;3390int i = 0;3391t_Handle p_AdTableTmp;3392t_CcNodeInformation ccNodeInfo;33933394NCSW_LIST_FOR_EACH(p_Pos, &p_CrntMdfNode->ccTreeIdLst)3395{3396p_CcNodeInformation = CC_NODE_F_OBJECT(p_Pos);3397p_TreePtrOnCurrentMdfNode =3398(t_FmPcdCcTree *)p_CcNodeInformation->h_CcNode;33993400ASSERT_COND(p_TreePtrOnCurrentMdfNode);34013402/*search in the trees which exact index points on this current modified node for getting AD */3403for (i = 0; i < p_TreePtrOnCurrentMdfNode->numOfEntries; i++)3404{3405if (p_TreePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine3406== e_FM_PCD_CC)3407{3408if (p_TreePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode3409== (t_Handle)p_CrntMdfNode)3410{3411p_AdTableTmp =3412UINT_TO_PTR(p_TreePtrOnCurrentMdfNode->ccTreeBaseAddr + i*FM_PCD_CC_AD_ENTRY_SIZE);3413memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));3414ccNodeInfo.h_CcNode = p_AdTableTmp;3415EnqueueNodeInfoToRelevantLst(h_OldLst, &ccNodeInfo, NULL);34163417if (!(*p_NextEngineParams))3418*p_NextEngineParams =3419&p_TreePtrOnCurrentMdfNode->keyAndNextEngineParams[i].nextEngineParams;3420}3421}3422}34233424ASSERT_COND(i == p_TreePtrOnCurrentMdfNode->numOfEntries);3425}3426}34273428static t_FmPcdModifyCcKeyAdditionalParams * ModifyNodeCommonPart(3429t_Handle h_FmPcdCcNodeOrTree, uint16_t keyIndex,3430e_ModifyState modifyState, bool ttlCheck, bool hashCheck, bool tree)3431{3432t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams;3433int i = 0, j = 0;3434bool wasUpdate = FALSE;3435t_FmPcdCcNode *p_CcNode = NULL;3436t_FmPcdCcTree *p_FmPcdCcTree;3437uint16_t numOfKeys;3438t_FmPcdCcKeyAndNextEngineParams *p_KeyAndNextEngineParams;34393440SANITY_CHECK_RETURN_VALUE(h_FmPcdCcNodeOrTree, E_INVALID_HANDLE, NULL);34413442if (!tree)3443{3444p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNodeOrTree;3445numOfKeys = p_CcNode->numOfKeys;34463447/* node has to be pointed by another node or tree */34483449p_KeyAndNextEngineParams = (t_FmPcdCcKeyAndNextEngineParams *)XX_Malloc(3450sizeof(t_FmPcdCcKeyAndNextEngineParams) * (numOfKeys + 1));3451if (!p_KeyAndNextEngineParams)3452{3453REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Next engine and required action structure"));3454return NULL;3455}3456memcpy(p_KeyAndNextEngineParams, p_CcNode->keyAndNextEngineParams,3457(numOfKeys + 1) * sizeof(t_FmPcdCcKeyAndNextEngineParams));34583459if (ttlCheck)3460{3461if ((p_CcNode->parseCode == CC_PC_FF_IPV4TTL)3462|| (p_CcNode->parseCode == CC_PC_FF_IPV6HOP_LIMIT))3463{3464XX_Free(p_KeyAndNextEngineParams);3465REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("nodeId of CC_PC_FF_IPV4TTL or CC_PC_FF_IPV6HOP_LIMIT can not be used for this operation"));3466return NULL;3467}3468}34693470if (hashCheck)3471{3472if (p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED)3473{3474XX_Free(p_KeyAndNextEngineParams);3475REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("nodeId of CC_PC_GENERIC_IC_HASH_INDEXED can not be used for this operation"));3476return NULL;3477}3478}3479}3480else3481{3482p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcNodeOrTree;3483numOfKeys = p_FmPcdCcTree->numOfEntries;34843485p_KeyAndNextEngineParams = (t_FmPcdCcKeyAndNextEngineParams *)XX_Malloc(3486sizeof(t_FmPcdCcKeyAndNextEngineParams)3487* FM_PCD_MAX_NUM_OF_CC_GROUPS);3488if (!p_KeyAndNextEngineParams)3489{3490REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Next engine and required action structure"));3491return NULL;3492}3493memcpy(p_KeyAndNextEngineParams,3494p_FmPcdCcTree->keyAndNextEngineParams,3495FM_PCD_MAX_NUM_OF_CC_GROUPS3496* sizeof(t_FmPcdCcKeyAndNextEngineParams));3497}34983499p_FmPcdModifyCcKeyAdditionalParams =3500(t_FmPcdModifyCcKeyAdditionalParams *)XX_Malloc(3501sizeof(t_FmPcdModifyCcKeyAdditionalParams));3502if (!p_FmPcdModifyCcKeyAdditionalParams)3503{3504XX_Free(p_KeyAndNextEngineParams);3505REPORT_ERROR(MAJOR, E_NO_MEMORY, ("Allocation of internal data structure FAILED"));3506return NULL;3507}3508memset(p_FmPcdModifyCcKeyAdditionalParams, 0,3509sizeof(t_FmPcdModifyCcKeyAdditionalParams));35103511p_FmPcdModifyCcKeyAdditionalParams->h_CurrentNode = h_FmPcdCcNodeOrTree;3512p_FmPcdModifyCcKeyAdditionalParams->savedKeyIndex = keyIndex;35133514while (i < numOfKeys)3515{3516if ((j == keyIndex) && !wasUpdate)3517{3518if (modifyState == e_MODIFY_STATE_ADD)3519j++;3520else3521if (modifyState == e_MODIFY_STATE_REMOVE)3522i++;3523wasUpdate = TRUE;3524}3525else3526{3527memcpy(&p_FmPcdModifyCcKeyAdditionalParams->keyAndNextEngineParams[j],3528p_KeyAndNextEngineParams + i,3529sizeof(t_FmPcdCcKeyAndNextEngineParams));3530i++;3531j++;3532}3533}35343535if (keyIndex == numOfKeys)3536{3537if (modifyState == e_MODIFY_STATE_ADD)3538j++;3539}35403541memcpy(&p_FmPcdModifyCcKeyAdditionalParams->keyAndNextEngineParams[j],3542p_KeyAndNextEngineParams + numOfKeys,3543sizeof(t_FmPcdCcKeyAndNextEngineParams));35443545XX_Free(p_KeyAndNextEngineParams);35463547return p_FmPcdModifyCcKeyAdditionalParams;3548}35493550static t_Error UpdatePtrWhichPointOnCrntMdfNode(3551t_FmPcdCcNode *p_CcNode,3552t_FmPcdModifyCcKeyAdditionalParams *p_FmPcdModifyCcKeyAdditionalParams,3553t_List *h_OldLst, t_List *h_NewLst)3554{3555t_FmPcdCcNextEngineParams *p_NextEngineParams = NULL;3556t_CcNodeInformation ccNodeInfo = { 0 };3557t_Handle h_NewAd;3558t_Handle h_OrigAd = NULL;35593560/* Building a list of all action descriptors that point to the previous node */3561if (!NCSW_LIST_IsEmpty(&p_CcNode->ccPrevNodesLst))3562UpdateAdPtrOfNodesWhichPointsOnCrntMdfNode(p_CcNode, h_OldLst,3563&p_NextEngineParams);35643565if (!NCSW_LIST_IsEmpty(&p_CcNode->ccTreeIdLst))3566UpdateAdPtrOfTreesWhichPointsOnCrntMdfNode(p_CcNode, h_OldLst,3567&p_NextEngineParams);35683569/* This node must be found as next engine of one of its previous nodes or trees*/3570if (p_NextEngineParams)3571{3572/* Building a new action descriptor that points to the modified node */3573h_NewAd = GetNewAd(p_CcNode, FALSE);3574if (!h_NewAd)3575RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);3576MemSet8(h_NewAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);35773578h_OrigAd = p_CcNode->h_Ad;3579BuildNewAd(h_NewAd, p_FmPcdModifyCcKeyAdditionalParams, p_CcNode,3580p_NextEngineParams);35813582ccNodeInfo.h_CcNode = h_NewAd;3583EnqueueNodeInfoToRelevantLst(h_NewLst, &ccNodeInfo, NULL);35843585if (p_NextEngineParams->h_Manip && !h_OrigAd)3586FmPcdManipUpdateOwner(p_NextEngineParams->h_Manip, FALSE);3587}3588return E_OK;3589}35903591static void UpdateCcRootOwner(t_FmPcdCcTree *p_FmPcdCcTree, bool add)3592{3593ASSERT_COND(p_FmPcdCcTree);35943595/* this routine must be protected by the calling routine! */35963597if (add)3598p_FmPcdCcTree->owners++;3599else3600{3601ASSERT_COND(p_FmPcdCcTree->owners);3602p_FmPcdCcTree->owners--;3603}3604}36053606static t_Error CheckAndSetManipParamsWithCcNodeParams(t_FmPcdCcNode *p_CcNode)3607{3608t_Error err = E_OK;3609int i = 0;36103611for (i = 0; i < p_CcNode->numOfKeys; i++)3612{3613if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip)3614{3615err =3616FmPcdManipCheckParamsWithCcNodeParams(3617p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip,3618(t_Handle)p_CcNode);3619if (err)3620return err;3621}3622}36233624return err;3625}3626static t_Error ValidateAndCalcStatsParams(t_FmPcdCcNode *p_CcNode,3627t_FmPcdCcNodeParams *p_CcNodeParam,3628uint32_t *p_NumOfRanges,3629uint32_t *p_CountersArraySize)3630{3631e_FmPcdCcStatsMode statisticsMode = p_CcNode->statisticsMode;3632uint32_t i;36333634UNUSED(p_CcNodeParam);36353636switch (statisticsMode)3637{3638case e_FM_PCD_CC_STATS_MODE_NONE:3639for (i = 0; i < p_CcNode->numOfKeys; i++)3640if (p_CcNodeParam->keysParams.keyParams[i].ccNextEngineParams.statisticsEn)3641RETURN_ERROR(3642MAJOR,3643E_INVALID_VALUE,3644("Statistics cannot be enabled for key %d when statistics mode was set to 'NONE'", i));3645return E_OK;36463647case e_FM_PCD_CC_STATS_MODE_FRAME:3648case e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME:3649*p_NumOfRanges = 1;3650*p_CountersArraySize = 2 * FM_PCD_CC_STATS_COUNTER_SIZE;3651return E_OK;36523653#if (DPAA_VERSION >= 11)3654case e_FM_PCD_CC_STATS_MODE_RMON:3655{3656uint16_t *p_FrameLengthRanges =3657p_CcNodeParam->keysParams.frameLengthRanges;3658uint32_t i;36593660if (p_FrameLengthRanges[0] <= 0)3661RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Statistics mode"));36623663if (p_FrameLengthRanges[0] == 0xFFFF)3664{3665*p_NumOfRanges = 1;3666*p_CountersArraySize = 2 * FM_PCD_CC_STATS_COUNTER_SIZE;3667return E_OK;3668}36693670for (i = 1; i < FM_PCD_CC_STATS_MAX_NUM_OF_FLR; i++)3671{3672if (p_FrameLengthRanges[i - 1] >= p_FrameLengthRanges[i])3673RETURN_ERROR(3674MAJOR,3675E_INVALID_VALUE,3676("Frame length range must be larger at least by 1 from preceding range"));36773678/* Stop when last range is reached */3679if (p_FrameLengthRanges[i] == 0xFFFF)3680break;3681}36823683if ((i >= FM_PCD_CC_STATS_MAX_NUM_OF_FLR)3684|| (p_FrameLengthRanges[i] != 0xFFFF))3685RETURN_ERROR(MAJOR, E_INVALID_VALUE,3686("Last Frame length range must be 0xFFFF"));36873688*p_NumOfRanges = i + 1;36893690/* Allocate an extra counter for byte count, as counters3691array always begins with byte count */3692*p_CountersArraySize = (*p_NumOfRanges + 1)3693* FM_PCD_CC_STATS_COUNTER_SIZE;36943695}3696return E_OK;3697#endif /* (DPAA_VERSION >= 11) */36983699default:3700RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Statistics mode"));3701}3702}37033704static t_Error CheckParams(t_Handle h_FmPcd, t_FmPcdCcNodeParams *p_CcNodeParam,3705t_FmPcdCcNode *p_CcNode, bool *isKeyTblAlloc)3706{3707int tmp = 0;3708t_FmPcdCcKeyParams *p_KeyParams;3709t_Error err;3710uint32_t requiredAction = 0;37113712/* Validate statistics parameters */3713err = ValidateAndCalcStatsParams(p_CcNode, p_CcNodeParam,3714&(p_CcNode->numOfStatsFLRs),3715&(p_CcNode->countersArraySize));3716if (err)3717RETURN_ERROR(MAJOR, err, ("Invalid statistics parameters"));37183719/* Validate next engine parameters on Miss */3720err = ValidateNextEngineParams(3721h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,3722p_CcNode->statisticsMode);3723if (err)3724RETURN_ERROR(MAJOR, err,3725("For this node MissNextEngineParams are not valid"));37263727if (p_CcNodeParam->keysParams.ccNextEngineParamsForMiss.h_Manip)3728{3729err = FmPcdManipCheckParamsForCcNextEngine(3730&p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,3731&requiredAction);3732if (err)3733RETURN_ERROR(MAJOR, err, (NO_MSG));3734}37353736memcpy(&p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams,3737&p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,3738sizeof(t_FmPcdCcNextEngineParams));37393740p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].requiredAction =3741requiredAction;37423743if ((p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine3744== e_FM_PCD_CC)3745&& p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.h_Manip)3746{3747err =3748AllocAndFillAdForContLookupManip(3749p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.params.ccParams.h_CcNode);3750if (err)3751RETURN_ERROR(MAJOR, err, (NO_MSG));3752}37533754for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)3755{3756p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];37573758if (!p_KeyParams->p_Key)3759RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("p_Key is not initialized"));37603761err = ValidateNextEngineParams(h_FmPcd,3762&p_KeyParams->ccNextEngineParams,3763p_CcNode->statisticsMode);3764if (err)3765RETURN_ERROR(MAJOR, err, (NO_MSG));37663767err = UpdateGblMask(p_CcNode, p_CcNodeParam->keysParams.keySize,3768p_KeyParams->p_Mask);3769if (err)3770RETURN_ERROR(MAJOR, err, (NO_MSG));37713772if (p_KeyParams->ccNextEngineParams.h_Manip)3773{3774err = FmPcdManipCheckParamsForCcNextEngine(3775&p_KeyParams->ccNextEngineParams, &requiredAction);3776if (err)3777RETURN_ERROR(MAJOR, err, (NO_MSG));3778}37793780/* Store 'key' parameters - key, mask (if passed by the user) */3781memcpy(p_CcNode->keyAndNextEngineParams[tmp].key, p_KeyParams->p_Key,3782p_CcNodeParam->keysParams.keySize);37833784if (p_KeyParams->p_Mask)3785memcpy(p_CcNode->keyAndNextEngineParams[tmp].mask,3786p_KeyParams->p_Mask, p_CcNodeParam->keysParams.keySize);3787else3788memset((void *)(p_CcNode->keyAndNextEngineParams[tmp].mask), 0xFF,3789p_CcNodeParam->keysParams.keySize);37903791/* Store next engine parameters */3792memcpy(&p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams,3793&p_KeyParams->ccNextEngineParams,3794sizeof(t_FmPcdCcNextEngineParams));37953796p_CcNode->keyAndNextEngineParams[tmp].requiredAction = requiredAction;37973798if ((p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine3799== e_FM_PCD_CC)3800&& p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)3801{3802err =3803AllocAndFillAdForContLookupManip(3804p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode);3805if (err)3806RETURN_ERROR(MAJOR, err, (NO_MSG));3807}3808}38093810if (p_CcNode->maxNumOfKeys)3811{3812if (p_CcNode->maxNumOfKeys < p_CcNode->numOfKeys)3813RETURN_ERROR(3814MAJOR,3815E_INVALID_VALUE,3816("Number of keys exceed the provided maximal number of keys"));3817}38183819*isKeyTblAlloc = TRUE;38203821return E_OK;3822}38233824static t_Error Ipv4TtlOrIpv6HopLimitCheckParams(3825t_Handle h_FmPcd, t_FmPcdCcNodeParams *p_CcNodeParam,3826t_FmPcdCcNode *p_CcNode, bool *isKeyTblAlloc)3827{3828int tmp = 0;3829t_FmPcdCcKeyParams *p_KeyParams;3830t_Error err;3831uint8_t key = 0x01;3832uint32_t requiredAction = 0;38333834if (p_CcNode->numOfKeys != 1)3835RETURN_ERROR(3836MAJOR,3837E_INVALID_VALUE,3838("For node of the type IPV4_TTL or IPV6_HOP_LIMIT the maximal supported 'numOfKeys' is 1"));38393840if ((p_CcNodeParam->keysParams.maxNumOfKeys)3841&& (p_CcNodeParam->keysParams.maxNumOfKeys != 1))3842RETURN_ERROR(3843MAJOR,3844E_INVALID_VALUE,3845("For node of the type IPV4_TTL or IPV6_HOP_LIMIT the maximal supported 'maxNumOfKeys' is 1"));38463847/* Validate statistics parameters */3848err = ValidateAndCalcStatsParams(p_CcNode, p_CcNodeParam,3849&(p_CcNode->numOfStatsFLRs),3850&(p_CcNode->countersArraySize));3851if (err)3852RETURN_ERROR(MAJOR, err, ("Invalid statistics parameters"));38533854err = ValidateNextEngineParams(3855h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,3856p_CcNodeParam->keysParams.statisticsMode);3857if (err)3858RETURN_ERROR(MAJOR, err,3859("For this node MissNextEngineParams are not valid"));38603861if (p_CcNodeParam->keysParams.ccNextEngineParamsForMiss.h_Manip)3862{3863err = FmPcdManipCheckParamsForCcNextEngine(3864&p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,3865&requiredAction);3866if (err)3867RETURN_ERROR(MAJOR, err, (NO_MSG));3868}38693870memcpy(&p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams,3871&p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,3872sizeof(t_FmPcdCcNextEngineParams));38733874p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].requiredAction =3875requiredAction;38763877if ((p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.nextEngine3878== e_FM_PCD_CC)3879&& p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.h_Manip)3880{3881err =3882AllocAndFillAdForContLookupManip(3883p_CcNode->keyAndNextEngineParams[p_CcNode->numOfKeys].nextEngineParams.params.ccParams.h_CcNode);3884if (err)3885RETURN_ERROR(MAJOR, err, (NO_MSG));3886}38873888for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)3889{3890p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];38913892if (p_KeyParams->p_Mask)3893RETURN_ERROR(3894MAJOR,3895E_INVALID_VALUE,3896("For node of the type IPV4_TTL or IPV6_HOP_LIMIT p_Mask can not be initialized"));38973898if (memcmp(p_KeyParams->p_Key, &key, 1) != 0)3899RETURN_ERROR(3900MAJOR,3901E_INVALID_VALUE,3902("For node of the type IPV4_TTL or IPV6_HOP_LIMIT p_Key has to be 1"));39033904err = ValidateNextEngineParams(h_FmPcd,3905&p_KeyParams->ccNextEngineParams,3906p_CcNode->statisticsMode);3907if (err)3908RETURN_ERROR(MAJOR, err, (NO_MSG));39093910if (p_KeyParams->ccNextEngineParams.h_Manip)3911{3912err = FmPcdManipCheckParamsForCcNextEngine(3913&p_KeyParams->ccNextEngineParams, &requiredAction);3914if (err)3915RETURN_ERROR(MAJOR, err, (NO_MSG));3916}39173918/* Store 'key' parameters - key (fixed to 0x01), key size of 1 byte and full mask */3919p_CcNode->keyAndNextEngineParams[tmp].key[0] = key;3920p_CcNode->keyAndNextEngineParams[tmp].mask[0] = 0xFF;39213922/* Store NextEngine parameters */3923memcpy(&p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams,3924&p_KeyParams->ccNextEngineParams,3925sizeof(t_FmPcdCcNextEngineParams));39263927if ((p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine3928== e_FM_PCD_CC)3929&& p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)3930{3931err =3932AllocAndFillAdForContLookupManip(3933p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode);3934if (err)3935RETURN_ERROR(MAJOR, err, (NO_MSG));3936}3937p_CcNode->keyAndNextEngineParams[tmp].requiredAction = requiredAction;3938}39393940*isKeyTblAlloc = FALSE;39413942return E_OK;3943}39443945static t_Error IcHashIndexedCheckParams(t_Handle h_FmPcd,3946t_FmPcdCcNodeParams *p_CcNodeParam,3947t_FmPcdCcNode *p_CcNode,3948bool *isKeyTblAlloc)3949{3950int tmp = 0, countOnes = 0;3951t_FmPcdCcKeyParams *p_KeyParams;3952t_Error err;3953uint16_t glblMask = p_CcNodeParam->extractCcParams.extractNonHdr.icIndxMask;3954uint16_t countMask = (uint16_t)(glblMask >> 4);3955uint32_t requiredAction = 0;39563957if (glblMask & 0x000f)3958RETURN_ERROR(MAJOR, E_INVALID_VALUE,3959("icIndxMask has to be with last nibble 0"));39603961while (countMask)3962{3963countOnes++;3964countMask = (uint16_t)(countMask >> 1);3965}39663967if (!POWER_OF_2(p_CcNode->numOfKeys))3968RETURN_ERROR(3969MAJOR,3970E_INVALID_VALUE,3971("For Node of the type INDEXED numOfKeys has to be powerOfTwo"));39723973if (p_CcNode->numOfKeys != ((uint32_t)1 << countOnes))3974RETURN_ERROR(3975MAJOR,3976E_INVALID_VALUE,3977("For Node of the type IC_HASH_INDEXED numOfKeys has to be powerOfTwo"));39783979if (p_CcNodeParam->keysParams.maxNumOfKeys3980&& (p_CcNodeParam->keysParams.maxNumOfKeys != p_CcNode->numOfKeys))3981RETURN_ERROR(3982MAJOR,3983E_INVALID_VALUE,3984("For Node of the type INDEXED 'maxNumOfKeys' should be 0 or equal 'numOfKeys'"));39853986/* Validate statistics parameters */3987err = ValidateAndCalcStatsParams(p_CcNode, p_CcNodeParam,3988&(p_CcNode->numOfStatsFLRs),3989&(p_CcNode->countersArraySize));3990if (err)3991RETURN_ERROR(MAJOR, err, ("Invalid statistics parameters"));39923993err = ValidateNextEngineParams(3994h_FmPcd, &p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,3995p_CcNode->statisticsMode);3996if (GET_ERROR_TYPE(err) != E_NOT_SUPPORTED)3997RETURN_ERROR(3998MAJOR,3999err,4000("MissNextEngineParams for the node of the type IC_INDEX_HASH has to be UnInitialized"));40014002for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)4003{4004p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];40054006if (p_KeyParams->p_Mask || p_KeyParams->p_Key)4007RETURN_ERROR(4008MAJOR,4009E_INVALID_VALUE,4010("For Node of the type IC_HASH_INDEXED p_Key or p_Mask has to be NULL"));40114012if ((glblMask & (tmp * 16)) == (tmp * 16))4013{4014err = ValidateNextEngineParams(h_FmPcd,4015&p_KeyParams->ccNextEngineParams,4016p_CcNode->statisticsMode);4017if (err)4018RETURN_ERROR(4019MAJOR,4020err,4021("This index has to be initialized for the node of the type IC_INDEX_HASH according to settings of GlobalMask "));40224023if (p_KeyParams->ccNextEngineParams.h_Manip)4024{4025err = FmPcdManipCheckParamsForCcNextEngine(4026&p_KeyParams->ccNextEngineParams, &requiredAction);4027if (err)4028RETURN_ERROR(MAJOR, err, (NO_MSG));4029p_CcNode->keyAndNextEngineParams[tmp].requiredAction =4030requiredAction;4031}40324033memcpy(&p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams,4034&p_KeyParams->ccNextEngineParams,4035sizeof(t_FmPcdCcNextEngineParams));40364037if ((p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine4038== e_FM_PCD_CC)4039&& p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)4040{4041err =4042AllocAndFillAdForContLookupManip(4043p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode);4044if (err)4045RETURN_ERROR(MAJOR, err, (NO_MSG));4046}4047}4048else4049{4050err = ValidateNextEngineParams(h_FmPcd,4051&p_KeyParams->ccNextEngineParams,4052p_CcNode->statisticsMode);4053if (GET_ERROR_TYPE(err) != E_NOT_SUPPORTED)4054RETURN_ERROR(4055MAJOR,4056err,4057("This index has to be UnInitialized for the node of the type IC_INDEX_HASH according to settings of GlobalMask"));4058}4059}40604061*isKeyTblAlloc = FALSE;4062glblMask = htobe16(glblMask);4063memcpy(PTR_MOVE(p_CcNode->p_GlblMask, 2), &glblMask, 2);40644065return E_OK;4066}40674068static t_Error ModifyNextEngineParamNode(4069t_Handle h_FmPcd, t_Handle h_FmPcdCcNode, uint16_t keyIndex,4070t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)4071{4072t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;4073t_FmPcd *p_FmPcd;4074t_List h_OldPointersLst, h_NewPointersLst;4075t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;4076t_Error err = E_OK;40774078SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_VALUE);4079SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);40804081if (keyIndex >= p_CcNode->numOfKeys)4082RETURN_ERROR(MAJOR, E_INVALID_STATE,4083("keyIndex > previously cleared last index + 1"));40844085p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;40864087INIT_LIST(&h_OldPointersLst);4088INIT_LIST(&h_NewPointersLst);40894090p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,4091e_MODIFY_STATE_CHANGE, FALSE,4092FALSE, FALSE);4093if (!p_ModifyKeyParams)4094RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);40954096if (p_CcNode->maxNumOfKeys4097&& !TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))4098{4099XX_Free(p_ModifyKeyParams);4100return ERROR_CODE(E_BUSY);4101}41024103err = BuildNewNodeModifyNextEngine(h_FmPcd, p_CcNode, keyIndex,4104p_FmPcdCcNextEngineParams,4105&h_OldPointersLst, &h_NewPointersLst,4106p_ModifyKeyParams);4107if (err)4108{4109XX_Free(p_ModifyKeyParams);4110if (p_CcNode->maxNumOfKeys)4111RELEASE_LOCK(p_FmPcd->shadowLock);4112RETURN_ERROR(MAJOR, err, NO_MSG);4113}41144115err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,4116p_ModifyKeyParams, FALSE);41174118if (p_CcNode->maxNumOfKeys)4119RELEASE_LOCK(p_FmPcd->shadowLock);41204121return err;4122}41234124static t_Error FindKeyIndex(t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key,4125uint8_t *p_Mask, uint16_t *p_KeyIndex)4126{4127t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;4128uint8_t tmpMask[FM_PCD_MAX_SIZE_OF_KEY];4129uint16_t i;41304131ASSERT_COND(p_Key);4132ASSERT_COND(p_KeyIndex);4133ASSERT_COND(keySize < FM_PCD_MAX_SIZE_OF_KEY);41344135if (keySize != p_CcNode->userSizeOfExtraction)4136RETURN_ERROR(4137MINOR, E_INVALID_VALUE,4138("Key size doesn't match the extraction size of the node"));41394140/* If user didn't pass a mask for this key, we'll look for full extraction mask */4141if (!p_Mask)4142memset(tmpMask, 0xFF, keySize);41434144for (i = 0; i < p_CcNode->numOfKeys; i++)4145{4146/* Comparing received key */4147if (memcmp(p_Key, p_CcNode->keyAndNextEngineParams[i].key, keySize)4148== 0)4149{4150if (p_Mask)4151{4152/* If a user passed a mask for this key, it must match to the existing key's mask for a correct match */4153if (memcmp(p_Mask, p_CcNode->keyAndNextEngineParams[i].mask,4154keySize) == 0)4155{4156*p_KeyIndex = i;4157return E_OK;4158}4159}4160else4161{4162/* If user didn't pass a mask for this key, check if the existing key mask is full extraction */4163if (memcmp(tmpMask, p_CcNode->keyAndNextEngineParams[i].mask,4164keySize) == 0)4165{4166*p_KeyIndex = i;4167return E_OK;4168}4169}4170}4171}41724173return ERROR_CODE(E_NOT_FOUND);4174}41754176static t_Error CalcAndUpdateCcShadow(t_FmPcdCcNode *p_CcNode,4177bool isKeyTblAlloc,4178uint32_t *p_MatchTableSize,4179uint32_t *p_AdTableSize)4180{4181uint32_t shadowSize;4182t_Error err;41834184/* Calculate keys table maximal size - each entry consists of a key and a mask,4185(if local mask support is requested) */4186*p_MatchTableSize = p_CcNode->ccKeySizeAccExtraction * sizeof(uint8_t)4187* p_CcNode->maxNumOfKeys;41884189if (p_CcNode->maskSupport)4190*p_MatchTableSize *= 2;41914192/* Calculate next action descriptors table, including one more entry for miss */4193*p_AdTableSize = (uint32_t)((p_CcNode->maxNumOfKeys + 1)4194* FM_PCD_CC_AD_ENTRY_SIZE);41954196/* Calculate maximal shadow size of this node.4197All shadow structures will be used for runtime modifications host command. If4198keys table was allocated for this node, the keys table and next engines table may4199be modified in run time (entries added or removed), so shadow tables are requires.4200Otherwise, the only supported runtime modification is a specific next engine update4201and this requires shadow memory of a single AD */42024203/* Shadow size should be enough to hold the following 3 structures:4204* 1 - an action descriptor */4205shadowSize = FM_PCD_CC_AD_ENTRY_SIZE;42064207/* 2 - keys match table, if was allocated for the current node */4208if (isKeyTblAlloc)4209shadowSize += *p_MatchTableSize;42104211/* 3 - next action descriptors table */4212shadowSize += *p_AdTableSize;42134214/* Update shadow to the calculated size */4215err = FmPcdUpdateCcShadow(p_CcNode->h_FmPcd, (uint32_t)shadowSize,4216FM_PCD_CC_AD_TABLE_ALIGN);4217if (err != E_OK)4218{4219DeleteNode(p_CcNode);4220RETURN_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC node shadow"));4221}42224223return E_OK;4224}42254226static t_Error AllocStatsObjs(t_FmPcdCcNode *p_CcNode)4227{4228t_FmPcdStatsObj *p_StatsObj;4229t_Handle h_FmMuram, h_StatsAd, h_StatsCounters;4230uint32_t i;42314232h_FmMuram = FmPcdGetMuramHandle(p_CcNode->h_FmPcd);4233if (!h_FmMuram)4234RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("FM MURAM"));42354236/* Allocate statistics ADs and statistics counter. An extra pair (AD + counters)4237will be allocated to support runtime modifications */4238for (i = 0; i < p_CcNode->maxNumOfKeys + 2; i++)4239{4240/* Allocate list object structure */4241p_StatsObj = XX_Malloc(sizeof(t_FmPcdStatsObj));4242if (!p_StatsObj)4243{4244FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);4245RETURN_ERROR(MAJOR, E_NO_MEMORY, ("Statistics object"));4246}4247memset(p_StatsObj, 0, sizeof(t_FmPcdStatsObj));42484249/* Allocate statistics AD from MURAM */4250h_StatsAd = (t_Handle)FM_MURAM_AllocMem(h_FmMuram,4251FM_PCD_CC_AD_ENTRY_SIZE,4252FM_PCD_CC_AD_TABLE_ALIGN);4253if (!h_StatsAd)4254{4255FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);4256XX_Free(p_StatsObj);4257RETURN_ERROR(MAJOR, E_NO_MEMORY,4258("MURAM allocation for statistics ADs"));4259}4260MemSet8(h_StatsAd, 0, FM_PCD_CC_AD_ENTRY_SIZE);42614262/* Allocate statistics counters from MURAM */4263h_StatsCounters = (t_Handle)FM_MURAM_AllocMem(4264h_FmMuram, p_CcNode->countersArraySize,4265FM_PCD_CC_AD_TABLE_ALIGN);4266if (!h_StatsCounters)4267{4268FreeStatObjects(&p_CcNode->availableStatsLst, h_FmMuram);4269FM_MURAM_FreeMem(h_FmMuram, h_StatsAd);4270XX_Free(p_StatsObj);4271RETURN_ERROR(MAJOR, E_NO_MEMORY,4272("MURAM allocation for statistics counters"));4273}4274MemSet8(h_StatsCounters, 0, p_CcNode->countersArraySize);42754276p_StatsObj->h_StatsAd = h_StatsAd;4277p_StatsObj->h_StatsCounters = h_StatsCounters;42784279EnqueueStatsObj(&p_CcNode->availableStatsLst, p_StatsObj);4280}42814282return E_OK;4283}42844285static t_Error MatchTableGetKeyStatistics(4286t_FmPcdCcNode *p_CcNode, uint16_t keyIndex,4287t_FmPcdCcKeyStatistics *p_KeyStatistics)4288{4289uint32_t *p_StatsCounters, i;42904291if (p_CcNode->statisticsMode == e_FM_PCD_CC_STATS_MODE_NONE)4292RETURN_ERROR(MAJOR, E_INVALID_STATE,4293("Statistics were not enabled for this match table"));42944295if (!p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)4296RETURN_ERROR(MAJOR, E_INVALID_STATE,4297("Statistics were not enabled for this key"));42984299memset(p_KeyStatistics, 0, sizeof(t_FmPcdCcKeyStatistics));43004301p_StatsCounters =4302p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsCounters;4303ASSERT_COND(p_StatsCounters);43044305p_KeyStatistics->byteCount = GET_UINT32(*p_StatsCounters);43064307for (i = 1; i <= p_CcNode->numOfStatsFLRs; i++)4308{4309p_StatsCounters =4310PTR_MOVE(p_StatsCounters, FM_PCD_CC_STATS_COUNTER_SIZE);43114312p_KeyStatistics->frameCount += GET_UINT32(*p_StatsCounters);43134314#if (DPAA_VERSION >= 11)4315p_KeyStatistics->frameLengthRangeCount[i - 1] =4316GET_UINT32(*p_StatsCounters);4317#endif /* (DPAA_VERSION >= 11) */4318}43194320return E_OK;4321}43224323static t_Error MatchTableSet(t_Handle h_FmPcd, t_FmPcdCcNode *p_CcNode,4324t_FmPcdCcNodeParams *p_CcNodeParam)4325{4326t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;4327t_FmPcdCcNode *p_FmPcdCcNextNode;4328t_Error err = E_OK;4329uint32_t tmp, keySize;4330bool glblMask = FALSE;4331t_FmPcdCcKeyParams *p_KeyParams;4332t_Handle h_FmMuram, p_KeysMatchTblTmp, p_AdTableTmp;4333#if (DPAA_VERSION >= 11)4334t_Handle h_StatsFLRs;4335#endif /* (DPAA_VERSION >= 11) */4336bool fullField = FALSE;4337ccPrivateInfo_t icCode = CC_PRIVATE_INFO_NONE;4338bool isKeyTblAlloc, fromIc = FALSE;4339uint32_t matchTableSize, adTableSize;4340t_CcNodeInformation ccNodeInfo, *p_CcInformation;4341t_FmPcdStatsObj *p_StatsObj;4342t_FmPcdCcStatsParams statsParams = { 0 };4343t_Handle h_Manip;43444345ASSERT_COND(h_FmPcd);4346ASSERT_COND(p_CcNode);4347ASSERT_COND(p_CcNodeParam);43484349p_CcNode->p_GlblMask = (t_Handle)XX_Malloc(4350CC_GLBL_MASK_SIZE * sizeof(uint8_t));4351memset(p_CcNode->p_GlblMask, 0, CC_GLBL_MASK_SIZE * sizeof(uint8_t));43524353p_CcNode->h_FmPcd = h_FmPcd;4354p_CcNode->numOfKeys = p_CcNodeParam->keysParams.numOfKeys;4355p_CcNode->maxNumOfKeys = p_CcNodeParam->keysParams.maxNumOfKeys;4356p_CcNode->maskSupport = p_CcNodeParam->keysParams.maskSupport;4357p_CcNode->statisticsMode = p_CcNodeParam->keysParams.statisticsMode;43584359/* For backward compatibility - even if statistics mode is nullified,4360we'll fix it to frame mode so we can support per-key request for4361statistics using 'statisticsEn' in next engine parameters */4362if (!p_CcNode->maxNumOfKeys4363&& (p_CcNode->statisticsMode == e_FM_PCD_CC_STATS_MODE_NONE))4364p_CcNode->statisticsMode = e_FM_PCD_CC_STATS_MODE_FRAME;43654366h_FmMuram = FmPcdGetMuramHandle(h_FmPcd);4367if (!h_FmMuram)4368RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("FM MURAM"));43694370INIT_LIST(&p_CcNode->ccPrevNodesLst);4371INIT_LIST(&p_CcNode->ccTreeIdLst);4372INIT_LIST(&p_CcNode->ccTreesLst);4373INIT_LIST(&p_CcNode->availableStatsLst);43744375p_CcNode->h_Spinlock = XX_InitSpinlock();4376if (!p_CcNode->h_Spinlock)4377{4378DeleteNode(p_CcNode);4379RETURN_ERROR(MAJOR, E_NO_MEMORY, ("CC node spinlock"));4380}43814382if ((p_CcNodeParam->extractCcParams.type == e_FM_PCD_EXTRACT_BY_HDR)4383&& ((p_CcNodeParam->extractCcParams.extractByHdr.hdr4384== HEADER_TYPE_IPv4)4385|| (p_CcNodeParam->extractCcParams.extractByHdr.hdr4386== HEADER_TYPE_IPv6))4387&& (p_CcNodeParam->extractCcParams.extractByHdr.type4388== e_FM_PCD_EXTRACT_FULL_FIELD)4389&& ((p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField.ipv64390== NET_HEADER_FIELD_IPv6_HOP_LIMIT)4391|| (p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField.ipv44392== NET_HEADER_FIELD_IPv4_TTL)))4393{4394err = Ipv4TtlOrIpv6HopLimitCheckParams(h_FmPcd, p_CcNodeParam, p_CcNode,4395&isKeyTblAlloc);4396glblMask = FALSE;4397}4398else4399if ((p_CcNodeParam->extractCcParams.type == e_FM_PCD_EXTRACT_NON_HDR)4400&& ((p_CcNodeParam->extractCcParams.extractNonHdr.src4401== e_FM_PCD_EXTRACT_FROM_KEY)4402|| (p_CcNodeParam->extractCcParams.extractNonHdr.src4403== e_FM_PCD_EXTRACT_FROM_HASH)4404|| (p_CcNodeParam->extractCcParams.extractNonHdr.src4405== e_FM_PCD_EXTRACT_FROM_FLOW_ID)))4406{4407if ((p_CcNodeParam->extractCcParams.extractNonHdr.src4408== e_FM_PCD_EXTRACT_FROM_FLOW_ID)4409&& (p_CcNodeParam->extractCcParams.extractNonHdr.offset != 0))4410{4411DeleteNode(p_CcNode);4412RETURN_ERROR(4413MAJOR,4414E_INVALID_VALUE,4415("In the case of the extraction from e_FM_PCD_EXTRACT_FROM_FLOW_ID offset has to be 0"));4416}44174418icCode = IcDefineCode(p_CcNodeParam);4419fromIc = TRUE;4420if (icCode == CC_PRIVATE_INFO_NONE)4421{4422DeleteNode(p_CcNode);4423RETURN_ERROR(4424MAJOR,4425E_INVALID_STATE,4426("user asked extraction from IC and field in internal context or action wasn't initialized in the right way"));4427}44284429if ((icCode == CC_PRIVATE_INFO_IC_DEQ_FQID_INDEX_LOOKUP)4430|| (icCode == CC_PRIVATE_INFO_IC_HASH_INDEX_LOOKUP))4431{4432err = IcHashIndexedCheckParams(h_FmPcd, p_CcNodeParam, p_CcNode,4433&isKeyTblAlloc);4434glblMask = TRUE;4435}4436else4437{4438err = CheckParams(h_FmPcd, p_CcNodeParam, p_CcNode,4439&isKeyTblAlloc);4440if (p_CcNode->glblMaskSize)4441glblMask = TRUE;4442}4443}4444else4445{4446err = CheckParams(h_FmPcd, p_CcNodeParam, p_CcNode, &isKeyTblAlloc);4447if (p_CcNode->glblMaskSize)4448glblMask = TRUE;4449}44504451if (err)4452{4453DeleteNode(p_CcNode);4454RETURN_ERROR(MAJOR, err, NO_MSG);4455}44564457switch (p_CcNodeParam->extractCcParams.type)4458{4459case (e_FM_PCD_EXTRACT_BY_HDR):4460switch (p_CcNodeParam->extractCcParams.extractByHdr.type)4461{4462case (e_FM_PCD_EXTRACT_FULL_FIELD):4463p_CcNode->parseCode =4464GetFullFieldParseCode(4465p_CcNodeParam->extractCcParams.extractByHdr.hdr,4466p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex,4467p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField);4468GetSizeHeaderField(4469p_CcNodeParam->extractCcParams.extractByHdr.hdr,4470p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fullField,4471&p_CcNode->sizeOfExtraction);4472fullField = TRUE;4473if ((p_CcNode->parseCode != CC_PC_FF_TCI1)4474&& (p_CcNode->parseCode != CC_PC_FF_TCI2)4475&& (p_CcNode->parseCode != CC_PC_FF_MPLS1)4476&& (p_CcNode->parseCode != CC_PC_FF_MPLS_LAST)4477&& (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC1)4478&& (p_CcNode->parseCode != CC_PC_FF_IPV4IPTOS_TC2)4479&& (p_CcNode->parseCode4480!= CC_PC_FF_IPTOS_IPV6TC1_IPV6FLOW1)4481&& (p_CcNode->parseCode != CC_PC_FF_IPDSCP)4482&& (p_CcNode->parseCode4483!= CC_PC_FF_IPTOS_IPV6TC2_IPV6FLOW2)4484&& glblMask)4485{4486glblMask = FALSE;4487p_CcNode->glblMaskSize = 4;4488p_CcNode->lclMask = TRUE;4489}4490break;44914492case (e_FM_PCD_EXTRACT_FROM_HDR):4493p_CcNode->sizeOfExtraction =4494p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromHdr.size;4495p_CcNode->offset =4496p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromHdr.offset;4497p_CcNode->userOffset =4498p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromHdr.offset;4499p_CcNode->parseCode =4500GetPrParseCode(4501p_CcNodeParam->extractCcParams.extractByHdr.hdr,4502p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex,4503p_CcNode->offset, glblMask,4504&p_CcNode->prsArrayOffset);4505break;45064507case (e_FM_PCD_EXTRACT_FROM_FIELD):4508p_CcNode->offset =4509p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.offset;4510p_CcNode->userOffset =4511p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.offset;4512p_CcNode->sizeOfExtraction =4513p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.size;4514p_CcNode->parseCode =4515GetFieldParseCode(4516p_CcNodeParam->extractCcParams.extractByHdr.hdr,4517p_CcNodeParam->extractCcParams.extractByHdr.extractByHdrType.fromField.field,4518p_CcNode->offset,4519&p_CcNode->prsArrayOffset,4520p_CcNodeParam->extractCcParams.extractByHdr.hdrIndex);4521break;45224523default:4524DeleteNode(p_CcNode);4525RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);4526}4527break;45284529case (e_FM_PCD_EXTRACT_NON_HDR):4530/* get the field code for the generic extract */4531p_CcNode->sizeOfExtraction =4532p_CcNodeParam->extractCcParams.extractNonHdr.size;4533p_CcNode->offset =4534p_CcNodeParam->extractCcParams.extractNonHdr.offset;4535p_CcNode->userOffset =4536p_CcNodeParam->extractCcParams.extractNonHdr.offset;4537p_CcNode->parseCode = GetGenParseCode(4538p_CcNodeParam->extractCcParams.extractNonHdr.src,4539p_CcNode->offset, glblMask, &p_CcNode->prsArrayOffset,4540fromIc, icCode);45414542if (p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED)4543{4544if ((p_CcNode->offset + p_CcNode->sizeOfExtraction) > 8)4545{4546DeleteNode(p_CcNode);4547RETURN_ERROR(4548MAJOR,4549E_INVALID_SELECTION,4550("when node of the type CC_PC_GENERIC_IC_HASH_INDEXED offset + size can not be bigger then size of HASH 64 bits (8 bytes)"));4551}4552}4553if ((p_CcNode->parseCode == CC_PC_GENERIC_IC_GMASK)4554|| (p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED))4555{4556p_CcNode->offset += p_CcNode->prsArrayOffset;4557p_CcNode->prsArrayOffset = 0;4558}4559break;45604561default:4562DeleteNode(p_CcNode);4563RETURN_ERROR(MAJOR, E_INVALID_SELECTION, NO_MSG);4564}45654566if (p_CcNode->parseCode == CC_PC_ILLEGAL)4567{4568DeleteNode(p_CcNode);4569RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("illegal extraction type"));4570}45714572if ((p_CcNode->sizeOfExtraction > FM_PCD_MAX_SIZE_OF_KEY)4573|| !p_CcNode->sizeOfExtraction)4574{4575DeleteNode(p_CcNode);4576RETURN_ERROR(MAJOR, E_INVALID_VALUE,4577("sizeOfExatrction can not be greater than 56 and not 0"));4578}45794580if (p_CcNodeParam->keysParams.keySize != p_CcNode->sizeOfExtraction)4581{4582DeleteNode(p_CcNode);4583RETURN_ERROR(MAJOR, E_INVALID_VALUE,4584("keySize has to be equal to sizeOfExtraction"));4585}45864587p_CcNode->userSizeOfExtraction = p_CcNode->sizeOfExtraction;45884589if (!glblMask)4590memset(p_CcNode->p_GlblMask, 0xff, CC_GLBL_MASK_SIZE * sizeof(uint8_t));45914592err = CheckAndSetManipParamsWithCcNodeParams(p_CcNode);4593if (err != E_OK)4594{4595DeleteNode(p_CcNode);4596RETURN_ERROR(MAJOR, E_INVALID_VALUE,4597("keySize has to be equal to sizeOfExtraction"));4598}45994600/* Calculating matching table entry size by rounding up the user-defined size of extraction to valid entry size */4601GetCcExtractKeySize(p_CcNode->sizeOfExtraction,4602&p_CcNode->ccKeySizeAccExtraction);46034604/* If local mask is used, it is stored next to each key in the keys match table */4605if (p_CcNode->lclMask)4606keySize = (uint32_t)(2 * p_CcNode->ccKeySizeAccExtraction);4607else4608keySize = p_CcNode->ccKeySizeAccExtraction;46094610/* Update CC shadow with maximal size required by this node */4611if (p_CcNode->maxNumOfKeys)4612{4613err = CalcAndUpdateCcShadow(p_CcNode, isKeyTblAlloc, &matchTableSize,4614&adTableSize);4615if (err != E_OK)4616{4617DeleteNode(p_CcNode);4618RETURN_ERROR(MAJOR, err, NO_MSG);4619}46204621p_CcNode->keysMatchTableMaxSize = matchTableSize;46224623if (p_CcNode->statisticsMode != e_FM_PCD_CC_STATS_MODE_NONE)4624{4625err = AllocStatsObjs(p_CcNode);4626if (err != E_OK)4627{4628DeleteNode(p_CcNode);4629RETURN_ERROR(MAJOR, err, NO_MSG);4630}4631}46324633/* If manipulation will be initialized before this node, it will use the table4634descriptor in the AD table of previous node and this node will need an extra4635AD as his table descriptor. */4636p_CcNode->h_TmpAd = (t_Handle)FM_MURAM_AllocMem(4637h_FmMuram, FM_PCD_CC_AD_ENTRY_SIZE, FM_PCD_CC_AD_TABLE_ALIGN);4638if (!p_CcNode->h_TmpAd)4639{4640DeleteNode(p_CcNode);4641RETURN_ERROR(MAJOR, E_NO_MEMORY,4642("MURAM allocation for CC action descriptor"));4643}4644}4645else4646{4647matchTableSize = (uint32_t)(keySize * sizeof(uint8_t)4648* (p_CcNode->numOfKeys + 1));4649adTableSize = (uint32_t)(FM_PCD_CC_AD_ENTRY_SIZE4650* (p_CcNode->numOfKeys + 1));4651}46524653#if (DPAA_VERSION >= 11)4654switch (p_CcNode->statisticsMode)4655{46564657case e_FM_PCD_CC_STATS_MODE_RMON:4658/* If RMON statistics or RMON conditional statistics modes are requested,4659allocate frame length ranges array */4660p_CcNode->h_StatsFLRs = FM_MURAM_AllocMem(4661h_FmMuram,4662(uint32_t)(p_CcNode->numOfStatsFLRs)4663* FM_PCD_CC_STATS_FLR_SIZE,4664FM_PCD_CC_AD_TABLE_ALIGN);46654666if (!p_CcNode->h_StatsFLRs)4667{4668DeleteNode(p_CcNode);4669RETURN_ERROR(4670MAJOR, E_NO_MEMORY,4671("MURAM allocation for CC frame length ranges array"));4672}46734674/* Initialize using value received from the user */4675for (tmp = 0; tmp < p_CcNode->numOfStatsFLRs; tmp++)4676{4677uint16_t flr =4678cpu_to_be16(p_CcNodeParam->keysParams.frameLengthRanges[tmp]);46794680h_StatsFLRs =4681PTR_MOVE(p_CcNode->h_StatsFLRs, tmp * FM_PCD_CC_STATS_FLR_SIZE);46824683MemCpy8(h_StatsFLRs,4684&flr,4685FM_PCD_CC_STATS_FLR_SIZE);4686}4687break;46884689default:4690break;4691}4692#endif /* (DPAA_VERSION >= 11) */46934694/* Allocate keys match table. Not required for some CC nodes, for example for IPv4 TTL4695identification, IPv6 hop count identification, etc. */4696if (isKeyTblAlloc)4697{4698p_CcNode->h_KeysMatchTable = (t_Handle)FM_MURAM_AllocMem(4699h_FmMuram, matchTableSize, FM_PCD_CC_KEYS_MATCH_TABLE_ALIGN);4700if (!p_CcNode->h_KeysMatchTable)4701{4702DeleteNode(p_CcNode);4703RETURN_ERROR(MAJOR, E_NO_MEMORY,4704("MURAM allocation for CC node key match table"));4705}4706MemSet8((uint8_t *)p_CcNode->h_KeysMatchTable, 0, matchTableSize);4707}47084709/* Allocate action descriptors table */4710p_CcNode->h_AdTable = (t_Handle)FM_MURAM_AllocMem(h_FmMuram, adTableSize,4711FM_PCD_CC_AD_TABLE_ALIGN);4712if (!p_CcNode->h_AdTable)4713{4714DeleteNode(p_CcNode);4715RETURN_ERROR(MAJOR, E_NO_MEMORY,4716("MURAM allocation for CC node action descriptors table"));4717}4718MemSet8((uint8_t *)p_CcNode->h_AdTable, 0, adTableSize);47194720p_KeysMatchTblTmp = p_CcNode->h_KeysMatchTable;4721p_AdTableTmp = p_CcNode->h_AdTable;47224723/* For each key, create the key and the next step AD */4724for (tmp = 0; tmp < p_CcNode->numOfKeys; tmp++)4725{4726p_KeyParams = &p_CcNodeParam->keysParams.keyParams[tmp];47274728if (p_KeysMatchTblTmp)4729{4730/* Copy the key */4731MemCpy8((void*)p_KeysMatchTblTmp, p_KeyParams->p_Key,4732p_CcNode->sizeOfExtraction);47334734/* Copy the key mask or initialize it to 0xFF..F */4735if (p_CcNode->lclMask && p_KeyParams->p_Mask)4736{4737MemCpy8(PTR_MOVE(p_KeysMatchTblTmp,4738p_CcNode->ccKeySizeAccExtraction), /* User's size of extraction rounded up to a valid matching table entry size */4739p_KeyParams->p_Mask, p_CcNode->sizeOfExtraction); /* Exact size of extraction as received from the user */4740}4741else4742if (p_CcNode->lclMask)4743{4744MemSet8(PTR_MOVE(p_KeysMatchTblTmp,4745p_CcNode->ccKeySizeAccExtraction), /* User's size of extraction rounded up to a valid matching table entry size */47460xff, p_CcNode->sizeOfExtraction); /* Exact size of extraction as received from the user */4747}47484749p_KeysMatchTblTmp =4750PTR_MOVE(p_KeysMatchTblTmp, keySize * sizeof(uint8_t));4751}47524753/* Create the next action descriptor in the match table */4754if (p_KeyParams->ccNextEngineParams.statisticsEn)4755{4756p_StatsObj = GetStatsObj(p_CcNode);4757ASSERT_COND(p_StatsObj);47584759statsParams.h_StatsAd = p_StatsObj->h_StatsAd;4760statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;4761#if (DPAA_VERSION >= 11)4762statsParams.h_StatsFLRs = p_CcNode->h_StatsFLRs;47634764#endif /* (DPAA_VERSION >= 11) */4765NextStepAd(p_AdTableTmp, &statsParams,4766&p_KeyParams->ccNextEngineParams, p_FmPcd);47674768p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = p_StatsObj;4769}4770else4771{4772NextStepAd(p_AdTableTmp, NULL, &p_KeyParams->ccNextEngineParams,4773p_FmPcd);47744775p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = NULL;4776}47774778p_AdTableTmp = PTR_MOVE(p_AdTableTmp, FM_PCD_CC_AD_ENTRY_SIZE);4779}47804781/* Update next engine for the 'miss' entry */4782if (p_CcNodeParam->keysParams.ccNextEngineParamsForMiss.statisticsEn)4783{4784p_StatsObj = GetStatsObj(p_CcNode);4785ASSERT_COND(p_StatsObj);47864787/* All 'bucket' nodes of a hash table should share the same statistics counters,4788allocated by the hash table. So, if this node is a bucket of a hash table,4789we'll replace the locally allocated counters with the shared counters. */4790if (p_CcNode->isHashBucket)4791{4792ASSERT_COND(p_CcNode->h_MissStatsCounters);47934794/* Store original counters pointer and replace it with mutual preallocated pointer */4795p_CcNode->h_PrivMissStatsCounters = p_StatsObj->h_StatsCounters;4796p_StatsObj->h_StatsCounters = p_CcNode->h_MissStatsCounters;4797}47984799statsParams.h_StatsAd = p_StatsObj->h_StatsAd;4800statsParams.h_StatsCounters = p_StatsObj->h_StatsCounters;4801#if (DPAA_VERSION >= 11)4802statsParams.h_StatsFLRs = p_CcNode->h_StatsFLRs;48034804#endif /* (DPAA_VERSION >= 11) */48054806NextStepAd(p_AdTableTmp, &statsParams,4807&p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,4808p_FmPcd);48094810p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = p_StatsObj;4811}4812else4813{4814NextStepAd(p_AdTableTmp, NULL,4815&p_CcNodeParam->keysParams.ccNextEngineParamsForMiss,4816p_FmPcd);48174818p_CcNode->keyAndNextEngineParams[tmp].p_StatsObj = NULL;4819}48204821/* This parameter will be used to initialize the "key length" field in the action descriptor4822that points to this node and it should be 0 for full field extraction */4823if (fullField == TRUE)4824p_CcNode->sizeOfExtraction = 0;48254826for (tmp = 0; tmp < MIN(p_CcNode->numOfKeys + 1, CC_MAX_NUM_OF_KEYS); tmp++)4827{4828if (p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.nextEngine4829== e_FM_PCD_CC)4830{4831p_FmPcdCcNextNode =4832(t_FmPcdCcNode*)p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.params.ccParams.h_CcNode;4833p_CcInformation = FindNodeInfoInReleventLst(4834&p_FmPcdCcNextNode->ccPrevNodesLst, (t_Handle)p_CcNode,4835p_FmPcdCcNextNode->h_Spinlock);4836if (!p_CcInformation)4837{4838memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));4839ccNodeInfo.h_CcNode = (t_Handle)p_CcNode;4840ccNodeInfo.index = 1;4841EnqueueNodeInfoToRelevantLst(&p_FmPcdCcNextNode->ccPrevNodesLst,4842&ccNodeInfo,4843p_FmPcdCcNextNode->h_Spinlock);4844}4845else4846p_CcInformation->index++;48474848if (p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip)4849{4850h_Manip =4851p_CcNode->keyAndNextEngineParams[tmp].nextEngineParams.h_Manip;4852p_CcInformation = FindNodeInfoInReleventLst(4853FmPcdManipGetNodeLstPointedOnThisManip(h_Manip),4854(t_Handle)p_CcNode, FmPcdManipGetSpinlock(h_Manip));4855if (!p_CcInformation)4856{4857memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));4858ccNodeInfo.h_CcNode = (t_Handle)p_CcNode;4859ccNodeInfo.index = 1;4860EnqueueNodeInfoToRelevantLst(4861FmPcdManipGetNodeLstPointedOnThisManip(h_Manip),4862&ccNodeInfo, FmPcdManipGetSpinlock(h_Manip));4863}4864else4865p_CcInformation->index++;4866}4867}4868}48694870p_AdTableTmp = p_CcNode->h_AdTable;48714872if (!FmPcdLockTryLockAll(h_FmPcd))4873{4874FM_PCD_MatchTableDelete((t_Handle)p_CcNode);4875DBG(TRACE, ("FmPcdLockTryLockAll failed"));4876return ERROR_CODE(E_BUSY);4877}48784879/* Required action for each next engine */4880for (tmp = 0; tmp < MIN(p_CcNode->numOfKeys + 1, CC_MAX_NUM_OF_KEYS); tmp++)4881{4882if (p_CcNode->keyAndNextEngineParams[tmp].requiredAction)4883{4884err = SetRequiredAction(4885h_FmPcd,4886p_CcNode->keyAndNextEngineParams[tmp].requiredAction,4887&p_CcNode->keyAndNextEngineParams[tmp], p_AdTableTmp, 1,4888NULL);4889if (err)4890{4891FmPcdLockUnlockAll(h_FmPcd);4892FM_PCD_MatchTableDelete((t_Handle)p_CcNode);4893RETURN_ERROR(MAJOR, err, NO_MSG);4894}4895p_AdTableTmp = PTR_MOVE(p_AdTableTmp, FM_PCD_CC_AD_ENTRY_SIZE);4896}4897}48984899FmPcdLockUnlockAll(h_FmPcd);49004901return E_OK;4902}4903/************************** End of static functions **************************/49044905/*****************************************************************************/4906/* Inter-module API routines */4907/*****************************************************************************/49084909t_CcNodeInformation* FindNodeInfoInReleventLst(t_List *p_List, t_Handle h_Info,4910t_Handle h_Spinlock)4911{4912t_CcNodeInformation *p_CcInformation;4913t_List *p_Pos;4914uint32_t intFlags;49154916intFlags = XX_LockIntrSpinlock(h_Spinlock);49174918for (p_Pos = NCSW_LIST_FIRST(p_List); p_Pos != (p_List);4919p_Pos = NCSW_LIST_NEXT(p_Pos))4920{4921p_CcInformation = CC_NODE_F_OBJECT(p_Pos);49224923ASSERT_COND(p_CcInformation->h_CcNode);49244925if (p_CcInformation->h_CcNode == h_Info)4926{4927XX_UnlockIntrSpinlock(h_Spinlock, intFlags);4928return p_CcInformation;4929}4930}49314932XX_UnlockIntrSpinlock(h_Spinlock, intFlags);49334934return NULL;4935}49364937void EnqueueNodeInfoToRelevantLst(t_List *p_List, t_CcNodeInformation *p_CcInfo,4938t_Handle h_Spinlock)4939{4940t_CcNodeInformation *p_CcInformation;4941uint32_t intFlags = 0;49424943p_CcInformation = (t_CcNodeInformation *)XX_Malloc(4944sizeof(t_CcNodeInformation));49454946if (p_CcInformation)4947{4948memset(p_CcInformation, 0, sizeof(t_CcNodeInformation));4949memcpy(p_CcInformation, p_CcInfo, sizeof(t_CcNodeInformation));4950INIT_LIST(&p_CcInformation->node);49514952if (h_Spinlock)4953intFlags = XX_LockIntrSpinlock(h_Spinlock);49544955NCSW_LIST_AddToTail(&p_CcInformation->node, p_List);49564957if (h_Spinlock)4958XX_UnlockIntrSpinlock(h_Spinlock, intFlags);4959}4960else4961REPORT_ERROR(MAJOR, E_NO_MEMORY, ("CC Node Information"));4962}49634964void DequeueNodeInfoFromRelevantLst(t_List *p_List, t_Handle h_Info,4965t_Handle h_Spinlock)4966{4967t_CcNodeInformation *p_CcInformation = NULL;4968uint32_t intFlags = 0;4969t_List *p_Pos;49704971if (h_Spinlock)4972intFlags = XX_LockIntrSpinlock(h_Spinlock);49734974if (NCSW_LIST_IsEmpty(p_List))4975{4976XX_RestoreAllIntr(intFlags);4977return;4978}49794980for (p_Pos = NCSW_LIST_FIRST(p_List); p_Pos != (p_List);4981p_Pos = NCSW_LIST_NEXT(p_Pos))4982{4983p_CcInformation = CC_NODE_F_OBJECT(p_Pos);4984ASSERT_COND(p_CcInformation);4985ASSERT_COND(p_CcInformation->h_CcNode);4986if (p_CcInformation->h_CcNode == h_Info)4987break;4988}49894990if (p_CcInformation)4991{4992NCSW_LIST_DelAndInit(&p_CcInformation->node);4993XX_Free(p_CcInformation);4994}49954996if (h_Spinlock)4997XX_UnlockIntrSpinlock(h_Spinlock, intFlags);4998}49995000void NextStepAd(t_Handle h_Ad, t_FmPcdCcStatsParams *p_FmPcdCcStatsParams,5001t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams,5002t_FmPcd *p_FmPcd)5003{5004switch (p_FmPcdCcNextEngineParams->nextEngine)5005{5006case (e_FM_PCD_KG):5007case (e_FM_PCD_PLCR):5008case (e_FM_PCD_DONE):5009/* if NIA is not CC, create a "result" type AD */5010FillAdOfTypeResult(h_Ad, p_FmPcdCcStatsParams, p_FmPcd,5011p_FmPcdCcNextEngineParams);5012break;5013#if (DPAA_VERSION >= 11)5014case (e_FM_PCD_FR):5015if (p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic)5016{5017FillAdOfTypeContLookup(5018h_Ad, p_FmPcdCcStatsParams, p_FmPcd,5019p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode,5020p_FmPcdCcNextEngineParams->h_Manip,5021p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic);5022FrmReplicGroupUpdateOwner(5023p_FmPcdCcNextEngineParams->params.frParams.h_FrmReplic,5024TRUE/* add */);5025}5026break;5027#endif /* (DPAA_VERSION >= 11) */50285029case (e_FM_PCD_CC):5030/* if NIA is not CC, create a TD to continue the CC lookup */5031FillAdOfTypeContLookup(5032h_Ad, p_FmPcdCcStatsParams, p_FmPcd,5033p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode,5034p_FmPcdCcNextEngineParams->h_Manip, NULL);50355036UpdateNodeOwner(p_FmPcdCcNextEngineParams->params.ccParams.h_CcNode,5037TRUE);5038break;50395040default:5041return;5042}5043}50445045t_Error FmPcdCcTreeAddIPR(t_Handle h_FmPcd, t_Handle h_FmTree,5046t_Handle h_NetEnv, t_Handle h_IpReassemblyManip,5047bool createSchemes)5048{5049t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;5050t_FmPcdCcNextEngineParams nextEngineParams;5051t_NetEnvParams netEnvParams;5052t_Handle h_Ad;5053bool isIpv6Present;5054uint8_t ipv4GroupId, ipv6GroupId;5055t_Error err;50565057ASSERT_COND(p_FmPcdCcTree);50585059/* this routine must be protected by the calling routine! */50605061memset(&nextEngineParams, 0, sizeof(t_FmPcdCcNextEngineParams));5062memset(&netEnvParams, 0, sizeof(t_NetEnvParams));50635064h_Ad = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);50655066isIpv6Present = FmPcdManipIpReassmIsIpv6Hdr(h_IpReassemblyManip);50675068if (isIpv6Present5069&& (p_FmPcdCcTree->numOfEntries > (FM_PCD_MAX_NUM_OF_CC_GROUPS - 2)))5070RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("need two free entries for IPR"));50715072if (p_FmPcdCcTree->numOfEntries > (FM_PCD_MAX_NUM_OF_CC_GROUPS - 1))5073RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("need two free entries for IPR"));50745075nextEngineParams.nextEngine = e_FM_PCD_DONE;5076nextEngineParams.h_Manip = h_IpReassemblyManip;50775078/* Lock tree */5079err = CcRootTryLock(p_FmPcdCcTree);5080if (err)5081return ERROR_CODE(E_BUSY);50825083if (p_FmPcdCcTree->h_IpReassemblyManip == h_IpReassemblyManip)5084{5085CcRootReleaseLock(p_FmPcdCcTree);5086return E_OK;5087}50885089if ((p_FmPcdCcTree->h_IpReassemblyManip)5090&& (p_FmPcdCcTree->h_IpReassemblyManip != h_IpReassemblyManip))5091{5092CcRootReleaseLock(p_FmPcdCcTree);5093RETURN_ERROR(MAJOR, E_INVALID_STATE,5094("This tree was previously updated with different IPR"));5095}50965097/* Initialize IPR for the first time for this tree */5098if (isIpv6Present)5099{5100ipv6GroupId = p_FmPcdCcTree->numOfGrps++;5101p_FmPcdCcTree->fmPcdGroupParam[ipv6GroupId].baseGroupEntry =5102(FM_PCD_MAX_NUM_OF_CC_GROUPS - 2);51035104if (createSchemes)5105{5106err = FmPcdManipBuildIpReassmScheme(h_FmPcd, h_NetEnv,5107p_FmPcdCcTree,5108h_IpReassemblyManip, FALSE,5109ipv6GroupId);5110if (err)5111{5112p_FmPcdCcTree->numOfGrps--;5113CcRootReleaseLock(p_FmPcdCcTree);5114RETURN_ERROR(MAJOR, err, NO_MSG);5115}5116}51175118NextStepAd(5119PTR_MOVE(h_Ad, (FM_PCD_MAX_NUM_OF_CC_GROUPS-2) * FM_PCD_CC_AD_ENTRY_SIZE),5120NULL, &nextEngineParams, h_FmPcd);5121}51225123ipv4GroupId = p_FmPcdCcTree->numOfGrps++;5124p_FmPcdCcTree->fmPcdGroupParam[ipv4GroupId].totalBitsMask = 0;5125p_FmPcdCcTree->fmPcdGroupParam[ipv4GroupId].baseGroupEntry =5126(FM_PCD_MAX_NUM_OF_CC_GROUPS - 1);51275128if (createSchemes)5129{5130err = FmPcdManipBuildIpReassmScheme(h_FmPcd, h_NetEnv, p_FmPcdCcTree,5131h_IpReassemblyManip, TRUE,5132ipv4GroupId);5133if (err)5134{5135p_FmPcdCcTree->numOfGrps--;5136if (isIpv6Present)5137{5138p_FmPcdCcTree->numOfGrps--;5139FmPcdManipDeleteIpReassmSchemes(h_IpReassemblyManip);5140}5141CcRootReleaseLock(p_FmPcdCcTree);5142RETURN_ERROR(MAJOR, err, NO_MSG);5143}5144}51455146NextStepAd(5147PTR_MOVE(h_Ad, (FM_PCD_MAX_NUM_OF_CC_GROUPS-1) * FM_PCD_CC_AD_ENTRY_SIZE),5148NULL, &nextEngineParams, h_FmPcd);51495150p_FmPcdCcTree->h_IpReassemblyManip = h_IpReassemblyManip;51515152CcRootReleaseLock(p_FmPcdCcTree);51535154return E_OK;5155}51565157t_Error FmPcdCcTreeAddCPR(t_Handle h_FmPcd, t_Handle h_FmTree,5158t_Handle h_NetEnv, t_Handle h_ReassemblyManip,5159bool createSchemes)5160{5161t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;5162t_FmPcdCcNextEngineParams nextEngineParams;5163t_NetEnvParams netEnvParams;5164t_Handle h_Ad;5165uint8_t groupId;5166t_Error err;51675168ASSERT_COND(p_FmPcdCcTree);51695170/* this routine must be protected by the calling routine! */5171memset(&nextEngineParams, 0, sizeof(t_FmPcdCcNextEngineParams));5172memset(&netEnvParams, 0, sizeof(t_NetEnvParams));51735174h_Ad = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);51755176if (p_FmPcdCcTree->numOfEntries > (FM_PCD_MAX_NUM_OF_CC_GROUPS - 1))5177RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("need one free entries for CPR"));51785179nextEngineParams.nextEngine = e_FM_PCD_DONE;5180nextEngineParams.h_Manip = h_ReassemblyManip;51815182/* Lock tree */5183err = CcRootTryLock(p_FmPcdCcTree);5184if (err)5185return ERROR_CODE(E_BUSY);51865187if (p_FmPcdCcTree->h_CapwapReassemblyManip == h_ReassemblyManip)5188{5189CcRootReleaseLock(p_FmPcdCcTree);5190return E_OK;5191}51925193if ((p_FmPcdCcTree->h_CapwapReassemblyManip)5194&& (p_FmPcdCcTree->h_CapwapReassemblyManip != h_ReassemblyManip))5195{5196CcRootReleaseLock(p_FmPcdCcTree);5197RETURN_ERROR(MAJOR, E_INVALID_STATE,5198("This tree was previously updated with different CPR"));5199}52005201groupId = p_FmPcdCcTree->numOfGrps++;5202p_FmPcdCcTree->fmPcdGroupParam[groupId].baseGroupEntry =5203(FM_PCD_MAX_NUM_OF_CC_GROUPS - 1);52045205if (createSchemes)5206{5207err = FmPcdManipBuildCapwapReassmScheme(h_FmPcd, h_NetEnv,5208p_FmPcdCcTree,5209h_ReassemblyManip, groupId);5210if (err)5211{5212p_FmPcdCcTree->numOfGrps--;5213CcRootReleaseLock(p_FmPcdCcTree);5214RETURN_ERROR(MAJOR, err, NO_MSG);5215}5216}52175218NextStepAd(5219PTR_MOVE(h_Ad, (FM_PCD_MAX_NUM_OF_CC_GROUPS-1) * FM_PCD_CC_AD_ENTRY_SIZE),5220NULL, &nextEngineParams, h_FmPcd);52215222p_FmPcdCcTree->h_CapwapReassemblyManip = h_ReassemblyManip;52235224CcRootReleaseLock(p_FmPcdCcTree);52255226return E_OK;5227}52285229t_Handle FmPcdCcTreeGetSavedManipParams(t_Handle h_FmTree)5230{5231t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;52325233ASSERT_COND(p_FmPcdCcTree);52345235return p_FmPcdCcTree->h_FmPcdCcSavedManipParams;5236}52375238void FmPcdCcTreeSetSavedManipParams(t_Handle h_FmTree,5239t_Handle h_SavedManipParams)5240{5241t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmTree;52425243ASSERT_COND(p_FmPcdCcTree);52445245p_FmPcdCcTree->h_FmPcdCcSavedManipParams = h_SavedManipParams;5246}52475248uint8_t FmPcdCcGetParseCode(t_Handle h_CcNode)5249{5250t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;52515252ASSERT_COND(p_CcNode);52535254return p_CcNode->parseCode;5255}52565257uint8_t FmPcdCcGetOffset(t_Handle h_CcNode)5258{5259t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;52605261ASSERT_COND(p_CcNode);52625263return p_CcNode->offset;5264}52655266uint16_t FmPcdCcGetNumOfKeys(t_Handle h_CcNode)5267{5268t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;52695270ASSERT_COND(p_CcNode);52715272return p_CcNode->numOfKeys;5273}52745275t_Error FmPcdCcModifyNextEngineParamTree(5276t_Handle h_FmPcd, t_Handle h_FmPcdCcTree, uint8_t grpId, uint8_t index,5277t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)5278{5279t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;5280t_FmPcd *p_FmPcd;5281t_List h_OldPointersLst, h_NewPointersLst;5282uint16_t keyIndex;5283t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;5284t_Error err = E_OK;52855286SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);5287SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);5288SANITY_CHECK_RETURN_ERROR((grpId <= 7), E_INVALID_VALUE);52895290if (grpId >= p_FmPcdCcTree->numOfGrps)5291RETURN_ERROR(MAJOR, E_INVALID_HANDLE,5292("grpId you asked > numOfGroup of relevant tree"));52935294if (index >= p_FmPcdCcTree->fmPcdGroupParam[grpId].numOfEntriesInGroup)5295RETURN_ERROR(MAJOR, E_INVALID_HANDLE, ("index > numOfEntriesInGroup"));52965297p_FmPcd = (t_FmPcd *)h_FmPcd;52985299INIT_LIST(&h_OldPointersLst);5300INIT_LIST(&h_NewPointersLst);53015302keyIndex = (uint16_t)(p_FmPcdCcTree->fmPcdGroupParam[grpId].baseGroupEntry5303+ index);53045305p_ModifyKeyParams = ModifyNodeCommonPart(p_FmPcdCcTree, keyIndex,5306e_MODIFY_STATE_CHANGE, FALSE,5307FALSE, TRUE);5308if (!p_ModifyKeyParams)5309RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);53105311p_ModifyKeyParams->tree = TRUE;53125313if (p_FmPcd->p_CcShadow5314&& !TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))5315{5316XX_Free(p_ModifyKeyParams);5317return ERROR_CODE(E_BUSY);5318}53195320err = BuildNewNodeModifyNextEngine(p_FmPcd, p_FmPcdCcTree, keyIndex,5321p_FmPcdCcNextEngineParams,5322&h_OldPointersLst, &h_NewPointersLst,5323p_ModifyKeyParams);5324if (err)5325{5326XX_Free(p_ModifyKeyParams);5327RETURN_ERROR(MAJOR, err, NO_MSG);5328}53295330err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,5331p_ModifyKeyParams, FALSE);53325333if (p_FmPcd->p_CcShadow)5334RELEASE_LOCK(p_FmPcd->shadowLock);53355336return err;53375338}53395340t_Error FmPcdCcRemoveKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,5341uint16_t keyIndex)5342{53435344t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;5345t_FmPcd *p_FmPcd;5346t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;5347t_List h_OldPointersLst, h_NewPointersLst;5348bool useShadowStructs = FALSE;5349t_Error err = E_OK;53505351if (keyIndex >= p_CcNode->numOfKeys)5352RETURN_ERROR(MAJOR, E_INVALID_VALUE,5353("impossible to remove key when numOfKeys <= keyIndex"));53545355if (p_CcNode->h_FmPcd != h_FmPcd)5356RETURN_ERROR(5357MAJOR,5358E_INVALID_VALUE,5359("handler to FmPcd is different from the handle provided at node initialization time"));53605361p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;53625363INIT_LIST(&h_OldPointersLst);5364INIT_LIST(&h_NewPointersLst);53655366p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,5367e_MODIFY_STATE_REMOVE, TRUE, TRUE,5368FALSE);5369if (!p_ModifyKeyParams)5370RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);53715372if (p_CcNode->maxNumOfKeys)5373{5374if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))5375{5376XX_Free(p_ModifyKeyParams);5377return ERROR_CODE(E_BUSY);5378}53795380useShadowStructs = TRUE;5381}53825383err = BuildNewNodeRemoveKey(p_CcNode, keyIndex, p_ModifyKeyParams);5384if (err)5385{5386XX_Free(p_ModifyKeyParams);5387if (p_CcNode->maxNumOfKeys)5388RELEASE_LOCK(p_FmPcd->shadowLock);5389RETURN_ERROR(MAJOR, err, NO_MSG);5390}53915392err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,5393&h_OldPointersLst,5394&h_NewPointersLst);5395if (err)5396{5397ReleaseNewNodeCommonPart(p_ModifyKeyParams);5398XX_Free(p_ModifyKeyParams);5399if (p_CcNode->maxNumOfKeys)5400RELEASE_LOCK(p_FmPcd->shadowLock);5401RETURN_ERROR(MAJOR, err, NO_MSG);5402}54035404err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,5405p_ModifyKeyParams, useShadowStructs);54065407if (p_CcNode->maxNumOfKeys)5408RELEASE_LOCK(p_FmPcd->shadowLock);54095410return err;5411}54125413t_Error FmPcdCcModifyKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,5414uint16_t keyIndex, uint8_t keySize, uint8_t *p_Key,5415uint8_t *p_Mask)5416{5417t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;5418t_FmPcd *p_FmPcd;5419t_List h_OldPointersLst, h_NewPointersLst;5420t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;5421uint16_t tmpKeyIndex;5422bool useShadowStructs = FALSE;5423t_Error err = E_OK;54245425if (keyIndex >= p_CcNode->numOfKeys)5426RETURN_ERROR(MAJOR, E_INVALID_STATE,5427("keyIndex > previously cleared last index + 1"));54285429if (keySize != p_CcNode->userSizeOfExtraction)5430RETURN_ERROR(5431MAJOR,5432E_INVALID_VALUE,5433("size for ModifyKey has to be the same as defined in SetNode"));54345435if (p_CcNode->h_FmPcd != h_FmPcd)5436RETURN_ERROR(5437MAJOR,5438E_INVALID_VALUE,5439("handler to FmPcd is different from the handle provided at node initialization time"));54405441err = FindKeyIndex(h_FmPcdCcNode, keySize, p_Key, p_Mask, &tmpKeyIndex);5442if (GET_ERROR_TYPE(err) != E_NOT_FOUND)5443RETURN_ERROR(5444MINOR,5445E_ALREADY_EXISTS,5446("The received key and mask pair was already found in the match table of the provided node"));54475448p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;54495450INIT_LIST(&h_OldPointersLst);5451INIT_LIST(&h_NewPointersLst);54525453p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,5454e_MODIFY_STATE_CHANGE, TRUE, TRUE,5455FALSE);5456if (!p_ModifyKeyParams)5457RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);54585459if (p_CcNode->maxNumOfKeys)5460{5461if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))5462{5463XX_Free(p_ModifyKeyParams);5464return ERROR_CODE(E_BUSY);5465}54665467useShadowStructs = TRUE;5468}54695470err = BuildNewNodeModifyKey(p_CcNode, keyIndex, p_Key, p_Mask,5471p_ModifyKeyParams);5472if (err)5473{5474XX_Free(p_ModifyKeyParams);5475if (p_CcNode->maxNumOfKeys)5476RELEASE_LOCK(p_FmPcd->shadowLock);5477RETURN_ERROR(MAJOR, err, NO_MSG);5478}54795480err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,5481&h_OldPointersLst,5482&h_NewPointersLst);5483if (err)5484{5485ReleaseNewNodeCommonPart(p_ModifyKeyParams);5486XX_Free(p_ModifyKeyParams);5487if (p_CcNode->maxNumOfKeys)5488RELEASE_LOCK(p_FmPcd->shadowLock);5489RETURN_ERROR(MAJOR, err, NO_MSG);5490}54915492err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,5493p_ModifyKeyParams, useShadowStructs);54945495if (p_CcNode->maxNumOfKeys)5496RELEASE_LOCK(p_FmPcd->shadowLock);54975498return err;5499}55005501t_Error FmPcdCcModifyMissNextEngineParamNode(5502t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,5503t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)5504{5505t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;5506t_FmPcd *p_FmPcd;5507t_List h_OldPointersLst, h_NewPointersLst;5508uint16_t keyIndex;5509t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;5510t_Error err = E_OK;55115512SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_VALUE);55135514keyIndex = p_CcNode->numOfKeys;55155516p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;55175518INIT_LIST(&h_OldPointersLst);5519INIT_LIST(&h_NewPointersLst);55205521p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,5522e_MODIFY_STATE_CHANGE, FALSE, TRUE,5523FALSE);5524if (!p_ModifyKeyParams)5525RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);55265527if (p_CcNode->maxNumOfKeys5528&& !TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))5529{5530XX_Free(p_ModifyKeyParams);5531return ERROR_CODE(E_BUSY);5532}55335534err = BuildNewNodeModifyNextEngine(h_FmPcd, p_CcNode, keyIndex,5535p_FmPcdCcNextEngineParams,5536&h_OldPointersLst, &h_NewPointersLst,5537p_ModifyKeyParams);5538if (err)5539{5540XX_Free(p_ModifyKeyParams);5541if (p_CcNode->maxNumOfKeys)5542RELEASE_LOCK(p_FmPcd->shadowLock);5543RETURN_ERROR(MAJOR, err, NO_MSG);5544}55455546err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,5547p_ModifyKeyParams, FALSE);55485549if (p_CcNode->maxNumOfKeys)5550RELEASE_LOCK(p_FmPcd->shadowLock);55515552return err;5553}55545555t_Error FmPcdCcAddKey(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,5556uint16_t keyIndex, uint8_t keySize,5557t_FmPcdCcKeyParams *p_FmPcdCcKeyParams)5558{5559t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;5560t_FmPcd *p_FmPcd;5561t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;5562t_List h_OldPointersLst, h_NewPointersLst;5563bool useShadowStructs = FALSE;5564uint16_t tmpKeyIndex;5565t_Error err = E_OK;55665567if (keyIndex > p_CcNode->numOfKeys)5568RETURN_ERROR(MAJOR, E_NOT_IN_RANGE,5569("keyIndex > previously cleared last index + 1"));55705571if (keySize != p_CcNode->userSizeOfExtraction)5572RETURN_ERROR(5573MAJOR,5574E_INVALID_VALUE,5575("keySize has to be defined as it was defined in initialization step"));55765577if (p_CcNode->h_FmPcd != h_FmPcd)5578RETURN_ERROR(5579MAJOR,5580E_INVALID_VALUE,5581("handler to FmPcd is different from the handle provided at node initialization time"));55825583if (p_CcNode->maxNumOfKeys)5584{5585if (p_CcNode->numOfKeys == p_CcNode->maxNumOfKeys)5586RETURN_ERROR(5587MAJOR,5588E_FULL,5589("number of keys exceeds the maximal number of keys provided at node initialization time"));5590}5591else5592if (p_CcNode->numOfKeys == FM_PCD_MAX_NUM_OF_KEYS)5593RETURN_ERROR(5594MAJOR,5595E_INVALID_VALUE,5596("number of keys can not be larger than %d", FM_PCD_MAX_NUM_OF_KEYS));55975598err = FindKeyIndex(h_FmPcdCcNode, keySize, p_FmPcdCcKeyParams->p_Key,5599p_FmPcdCcKeyParams->p_Mask, &tmpKeyIndex);5600if (GET_ERROR_TYPE(err) != E_NOT_FOUND)5601RETURN_ERROR(5602MAJOR,5603E_ALREADY_EXISTS,5604("The received key and mask pair was already found in the match table of the provided node"));56055606p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;56075608INIT_LIST(&h_OldPointersLst);5609INIT_LIST(&h_NewPointersLst);56105611p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,5612e_MODIFY_STATE_ADD, TRUE, TRUE,5613FALSE);5614if (!p_ModifyKeyParams)5615RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);56165617if (p_CcNode->maxNumOfKeys)5618{5619if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))5620{5621XX_Free(p_ModifyKeyParams);5622return ERROR_CODE(E_BUSY);5623}56245625useShadowStructs = TRUE;5626}56275628err = BuildNewNodeAddOrMdfyKeyAndNextEngine(h_FmPcd, p_CcNode, keyIndex,5629p_FmPcdCcKeyParams,5630p_ModifyKeyParams, TRUE);5631if (err)5632{5633ReleaseNewNodeCommonPart(p_ModifyKeyParams);5634XX_Free(p_ModifyKeyParams);5635if (p_CcNode->maxNumOfKeys)5636RELEASE_LOCK(p_FmPcd->shadowLock);5637RETURN_ERROR(MAJOR, err, NO_MSG);5638}56395640err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,5641&h_OldPointersLst,5642&h_NewPointersLst);5643if (err)5644{5645ReleaseNewNodeCommonPart(p_ModifyKeyParams);5646XX_Free(p_ModifyKeyParams);5647if (p_CcNode->maxNumOfKeys)5648RELEASE_LOCK(p_FmPcd->shadowLock);5649RETURN_ERROR(MAJOR, err, NO_MSG);5650}56515652err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,5653p_ModifyKeyParams, useShadowStructs);5654if (p_CcNode->maxNumOfKeys)5655RELEASE_LOCK(p_FmPcd->shadowLock);56565657return err;5658}56595660t_Error FmPcdCcModifyKeyAndNextEngine(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,5661uint16_t keyIndex, uint8_t keySize,5662t_FmPcdCcKeyParams *p_FmPcdCcKeyParams)5663{5664t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;5665t_FmPcd *p_FmPcd;5666t_List h_OldPointersLst, h_NewPointersLst;5667t_FmPcdModifyCcKeyAdditionalParams *p_ModifyKeyParams;5668uint16_t tmpKeyIndex;5669bool useShadowStructs = FALSE;5670t_Error err = E_OK;56715672if (keyIndex > p_CcNode->numOfKeys)5673RETURN_ERROR(MAJOR, E_INVALID_STATE,5674("keyIndex > previously cleared last index + 1"));56755676if (keySize != p_CcNode->userSizeOfExtraction)5677RETURN_ERROR(5678MAJOR,5679E_INVALID_VALUE,5680("keySize has to be defined as it was defined in initialization step"));56815682if (p_CcNode->h_FmPcd != h_FmPcd)5683RETURN_ERROR(5684MAJOR,5685E_INVALID_VALUE,5686("handler to FmPcd is different from the handle provided at node initialization time"));56875688err = FindKeyIndex(h_FmPcdCcNode, keySize, p_FmPcdCcKeyParams->p_Key,5689p_FmPcdCcKeyParams->p_Mask, &tmpKeyIndex);5690if (GET_ERROR_TYPE(err) != E_NOT_FOUND)5691RETURN_ERROR(5692MINOR,5693E_ALREADY_EXISTS,5694("The received key and mask pair was already found in the match table of the provided node"));56955696p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;56975698INIT_LIST(&h_OldPointersLst);5699INIT_LIST(&h_NewPointersLst);57005701p_ModifyKeyParams = ModifyNodeCommonPart(p_CcNode, keyIndex,5702e_MODIFY_STATE_CHANGE, TRUE, TRUE,5703FALSE);5704if (!p_ModifyKeyParams)5705RETURN_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);57065707if (p_CcNode->maxNumOfKeys)5708{5709if (!TRY_LOCK(p_FmPcd->h_ShadowSpinlock, &p_FmPcd->shadowLock))5710{5711XX_Free(p_ModifyKeyParams);5712return ERROR_CODE(E_BUSY);5713}57145715useShadowStructs = TRUE;5716}57175718err = BuildNewNodeAddOrMdfyKeyAndNextEngine(h_FmPcd, p_CcNode, keyIndex,5719p_FmPcdCcKeyParams,5720p_ModifyKeyParams, FALSE);5721if (err)5722{5723ReleaseNewNodeCommonPart(p_ModifyKeyParams);5724XX_Free(p_ModifyKeyParams);5725if (p_CcNode->maxNumOfKeys)5726RELEASE_LOCK(p_FmPcd->shadowLock);5727RETURN_ERROR(MAJOR, err, NO_MSG);5728}57295730err = UpdatePtrWhichPointOnCrntMdfNode(p_CcNode, p_ModifyKeyParams,5731&h_OldPointersLst,5732&h_NewPointersLst);5733if (err)5734{5735ReleaseNewNodeCommonPart(p_ModifyKeyParams);5736XX_Free(p_ModifyKeyParams);5737if (p_CcNode->maxNumOfKeys)5738RELEASE_LOCK(p_FmPcd->shadowLock);5739RETURN_ERROR(MAJOR, err, NO_MSG);5740}57415742err = DoDynamicChange(p_FmPcd, &h_OldPointersLst, &h_NewPointersLst,5743p_ModifyKeyParams, useShadowStructs);57445745if (p_CcNode->maxNumOfKeys)5746RELEASE_LOCK(p_FmPcd->shadowLock);57475748return err;5749}57505751uint32_t FmPcdCcGetNodeAddrOffsetFromNodeInfo(t_Handle h_FmPcd,5752t_Handle h_Pointer)5753{5754t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;5755t_CcNodeInformation *p_CcNodeInfo;57565757SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE,5758(uint32_t)ILLEGAL_BASE);57595760p_CcNodeInfo = CC_NODE_F_OBJECT(h_Pointer);57615762return (uint32_t)(XX_VirtToPhys(p_CcNodeInfo->h_CcNode)5763- p_FmPcd->physicalMuramBase);5764}57655766t_Error FmPcdCcGetGrpParams(t_Handle h_FmPcdCcTree, uint8_t grpId,5767uint32_t *p_GrpBits, uint8_t *p_GrpBase)5768{5769t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;57705771SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);57725773if (grpId >= p_FmPcdCcTree->numOfGrps)5774RETURN_ERROR(MAJOR, E_INVALID_HANDLE,5775("grpId you asked > numOfGroup of relevant tree"));57765777*p_GrpBits = p_FmPcdCcTree->fmPcdGroupParam[grpId].totalBitsMask;5778*p_GrpBase = p_FmPcdCcTree->fmPcdGroupParam[grpId].baseGroupEntry;57795780return E_OK;5781}57825783t_Error FmPcdCcBindTree(t_Handle h_FmPcd, t_Handle h_PcdParams,5784t_Handle h_FmPcdCcTree, uint32_t *p_Offset,5785t_Handle h_FmPort)5786{5787t_FmPcd *p_FmPcd = (t_FmPcd*)h_FmPcd;5788t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;5789t_Error err = E_OK;57905791SANITY_CHECK_RETURN_ERROR(h_FmPcd, E_INVALID_HANDLE);5792SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);57935794/* this routine must be protected by the calling routine by locking all PCD modules! */57955796err = CcUpdateParams(h_FmPcd, h_PcdParams, h_FmPort, h_FmPcdCcTree, TRUE);57975798if (err == E_OK)5799UpdateCcRootOwner(p_FmPcdCcTree, TRUE);58005801*p_Offset = (uint32_t)(XX_VirtToPhys(5802UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr))5803- p_FmPcd->physicalMuramBase);58045805return err;5806}58075808t_Error FmPcdCcUnbindTree(t_Handle h_FmPcd, t_Handle h_FmPcdCcTree)5809{5810t_FmPcdCcTree *p_FmPcdCcTree = (t_FmPcdCcTree *)h_FmPcdCcTree;58115812/* this routine must be protected by the calling routine by locking all PCD modules! */58135814UNUSED(h_FmPcd);58155816SANITY_CHECK_RETURN_ERROR(h_FmPcdCcTree, E_INVALID_HANDLE);58175818UpdateCcRootOwner(p_FmPcdCcTree, FALSE);58195820return E_OK;5821}58225823t_Error FmPcdCcNodeTreeTryLock(t_Handle h_FmPcd, t_Handle h_FmPcdCcNode,5824t_List *p_List)5825{5826t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_FmPcdCcNode;5827t_List *p_Pos, *p_Tmp;5828t_CcNodeInformation *p_CcNodeInfo, nodeInfo;5829uint32_t intFlags;5830t_Error err = E_OK;58315832intFlags = FmPcdLock(h_FmPcd);58335834NCSW_LIST_FOR_EACH(p_Pos, &p_CcNode->ccTreesLst)5835{5836p_CcNodeInfo = CC_NODE_F_OBJECT(p_Pos);5837ASSERT_COND(p_CcNodeInfo->h_CcNode);58385839err = CcRootTryLock(p_CcNodeInfo->h_CcNode);58405841if (err)5842{5843NCSW_LIST_FOR_EACH(p_Tmp, &p_CcNode->ccTreesLst)5844{5845if (p_Tmp == p_Pos)5846break;58475848CcRootReleaseLock(p_CcNodeInfo->h_CcNode);5849}5850break;5851}58525853memset(&nodeInfo, 0, sizeof(t_CcNodeInformation));5854nodeInfo.h_CcNode = p_CcNodeInfo->h_CcNode;5855EnqueueNodeInfoToRelevantLst(p_List, &nodeInfo, NULL);5856}58575858FmPcdUnlock(h_FmPcd, intFlags);5859CORE_MemoryBarrier();58605861return err;5862}58635864void FmPcdCcNodeTreeReleaseLock(t_Handle h_FmPcd, t_List *p_List)5865{5866t_List *p_Pos;5867t_CcNodeInformation *p_CcNodeInfo;5868t_Handle h_FmPcdCcTree;5869uint32_t intFlags;58705871intFlags = FmPcdLock(h_FmPcd);58725873NCSW_LIST_FOR_EACH(p_Pos, p_List)5874{5875p_CcNodeInfo = CC_NODE_F_OBJECT(p_Pos);5876h_FmPcdCcTree = p_CcNodeInfo->h_CcNode;5877CcRootReleaseLock(h_FmPcdCcTree);5878}58795880ReleaseLst(p_List);58815882FmPcdUnlock(h_FmPcd, intFlags);5883CORE_MemoryBarrier();5884}58855886t_Error FmPcdUpdateCcShadow(t_FmPcd *p_FmPcd, uint32_t size, uint32_t align)5887{5888uint32_t intFlags;5889uint32_t newSize = 0, newAlign = 0;5890bool allocFail = FALSE;58915892ASSERT_COND(p_FmPcd);58935894if (!size)5895RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("size must be larger then 0"));58965897if (!POWER_OF_2(align))5898RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("alignment must be power of 2"));58995900newSize = p_FmPcd->ccShadowSize;5901newAlign = p_FmPcd->ccShadowAlign;59025903/* Check if current shadow is large enough to hold the requested size */5904if (size > p_FmPcd->ccShadowSize)5905newSize = size;59065907/* Check if current shadow matches the requested alignment */5908if (align > p_FmPcd->ccShadowAlign)5909newAlign = align;59105911/* If a bigger shadow size or bigger shadow alignment are required,5912a new shadow will be allocated */5913if ((newSize != p_FmPcd->ccShadowSize)5914|| (newAlign != p_FmPcd->ccShadowAlign))5915{5916intFlags = FmPcdLock(p_FmPcd);59175918if (p_FmPcd->p_CcShadow)5919{5920FM_MURAM_FreeMem(FmPcdGetMuramHandle(p_FmPcd), p_FmPcd->p_CcShadow);5921p_FmPcd->ccShadowSize = 0;5922p_FmPcd->ccShadowAlign = 0;5923}59245925p_FmPcd->p_CcShadow = FM_MURAM_AllocMem(FmPcdGetMuramHandle(p_FmPcd),5926newSize, newAlign);5927if (!p_FmPcd->p_CcShadow)5928{5929allocFail = TRUE;59305931/* If new shadow size allocation failed,5932re-allocate with previous parameters */5933p_FmPcd->p_CcShadow = FM_MURAM_AllocMem(5934FmPcdGetMuramHandle(p_FmPcd), p_FmPcd->ccShadowSize,5935p_FmPcd->ccShadowAlign);5936}59375938FmPcdUnlock(p_FmPcd, intFlags);59395940if (allocFail)5941RETURN_ERROR(MAJOR, E_NO_MEMORY,5942("MURAM allocation for CC Shadow memory"));59435944p_FmPcd->ccShadowSize = newSize;5945p_FmPcd->ccShadowAlign = newAlign;5946}59475948return E_OK;5949}59505951#if (DPAA_VERSION >= 11)5952void FmPcdCcGetAdTablesThatPointOnReplicGroup(t_Handle h_Node,5953t_Handle h_ReplicGroup,5954t_List *p_AdTables,5955uint32_t *p_NumOfAdTables)5956{5957t_FmPcdCcNode *p_CurrentNode = (t_FmPcdCcNode *)h_Node;5958int i = 0;5959void * p_AdTable;5960t_CcNodeInformation ccNodeInfo;59615962ASSERT_COND(h_Node);5963*p_NumOfAdTables = 0;59645965/* search in the current node which exact index points on this current replicator group for getting AD */5966for (i = 0; i < p_CurrentNode->numOfKeys + 1; i++)5967{5968if ((p_CurrentNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine5969== e_FM_PCD_FR)5970&& ((p_CurrentNode->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic5971== (t_Handle)h_ReplicGroup)))5972{5973/* save the current ad table in the list */5974/* this entry uses the input replicator group */5975p_AdTable =5976PTR_MOVE(p_CurrentNode->h_AdTable, i*FM_PCD_CC_AD_ENTRY_SIZE);5977memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));5978ccNodeInfo.h_CcNode = p_AdTable;5979EnqueueNodeInfoToRelevantLst(p_AdTables, &ccNodeInfo, NULL);5980(*p_NumOfAdTables)++;5981}5982}59835984ASSERT_COND(i != p_CurrentNode->numOfKeys);5985}5986#endif /* (DPAA_VERSION >= 11) */5987/*********************** End of inter-module routines ************************/59885989/****************************************/5990/* API Init unit functions */5991/****************************************/59925993t_Handle FM_PCD_CcRootBuild(t_Handle h_FmPcd,5994t_FmPcdCcTreeParams *p_PcdGroupsParam)5995{5996t_FmPcd *p_FmPcd = (t_FmPcd *)h_FmPcd;5997t_Error err = E_OK;5998int i = 0, j = 0, k = 0;5999t_FmPcdCcTree *p_FmPcdCcTree;6000uint8_t numOfEntries;6001t_Handle p_CcTreeTmp;6002t_FmPcdCcGrpParams *p_FmPcdCcGroupParams;6003t_FmPcdCcKeyAndNextEngineParams *p_Params, *p_KeyAndNextEngineParams;6004t_NetEnvParams netEnvParams;6005uint8_t lastOne = 0;6006uint32_t requiredAction = 0;6007t_FmPcdCcNode *p_FmPcdCcNextNode;6008t_CcNodeInformation ccNodeInfo, *p_CcInformation;60096010SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);6011SANITY_CHECK_RETURN_VALUE(p_PcdGroupsParam, E_INVALID_HANDLE, NULL);60126013if (p_PcdGroupsParam->numOfGrps > FM_PCD_MAX_NUM_OF_CC_GROUPS)6014{6015REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("numOfGrps should not exceed %d", FM_PCD_MAX_NUM_OF_CC_GROUPS));6016return NULL;6017}60186019p_FmPcdCcTree = (t_FmPcdCcTree*)XX_Malloc(sizeof(t_FmPcdCcTree));6020if (!p_FmPcdCcTree)6021{6022REPORT_ERROR(MAJOR, E_NO_MEMORY, ("PCD tree structure"));6023return NULL;6024}6025memset(p_FmPcdCcTree, 0, sizeof(t_FmPcdCcTree));6026p_FmPcdCcTree->h_FmPcd = h_FmPcd;60276028p_Params = (t_FmPcdCcKeyAndNextEngineParams*)XX_Malloc(6029FM_PCD_MAX_NUM_OF_CC_GROUPS6030* sizeof(t_FmPcdCcKeyAndNextEngineParams));6031memset(p_Params,60320,6033FM_PCD_MAX_NUM_OF_CC_GROUPS6034* sizeof(t_FmPcdCcKeyAndNextEngineParams));60356036INIT_LIST(&p_FmPcdCcTree->fmPortsLst);60376038#ifdef FM_CAPWAP_SUPPORT6039if ((p_PcdGroupsParam->numOfGrps == 1) &&6040(p_PcdGroupsParam->ccGrpParams[0].numOfDistinctionUnits == 0) &&6041(p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].nextEngine == e_FM_PCD_CC) &&6042p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].params.ccParams.h_CcNode &&6043IsCapwapApplSpecific(p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].params.ccParams.h_CcNode))6044{6045p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].h_Manip = FmPcdManipApplSpecificBuild();6046if (!p_PcdGroupsParam->ccGrpParams[0].nextEnginePerEntriesInGrp[0].h_Manip)6047{6048DeleteTree(p_FmPcdCcTree,p_FmPcd);6049XX_Free(p_Params);6050REPORT_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);6051return NULL;6052}6053}6054#endif /* FM_CAPWAP_SUPPORT */60556056numOfEntries = 0;6057p_FmPcdCcTree->netEnvId = FmPcdGetNetEnvId(p_PcdGroupsParam->h_NetEnv);60586059for (i = 0; i < p_PcdGroupsParam->numOfGrps; i++)6060{6061p_FmPcdCcGroupParams = &p_PcdGroupsParam->ccGrpParams[i];60626063if (p_FmPcdCcGroupParams->numOfDistinctionUnits6064> FM_PCD_MAX_NUM_OF_CC_UNITS)6065{6066DeleteTree(p_FmPcdCcTree, p_FmPcd);6067XX_Free(p_Params);6068REPORT_ERROR(MAJOR, E_INVALID_VALUE,6069("numOfDistinctionUnits (group %d) should not exceed %d", i, FM_PCD_MAX_NUM_OF_CC_UNITS));6070return NULL;6071}60726073p_FmPcdCcTree->fmPcdGroupParam[i].baseGroupEntry = numOfEntries;6074p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup = (uint8_t)(0x016075<< p_FmPcdCcGroupParams->numOfDistinctionUnits);6076numOfEntries += p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup;6077if (numOfEntries > FM_PCD_MAX_NUM_OF_CC_GROUPS)6078{6079DeleteTree(p_FmPcdCcTree, p_FmPcd);6080XX_Free(p_Params);6081REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("numOfEntries can not be larger than %d", FM_PCD_MAX_NUM_OF_CC_GROUPS));6082return NULL;6083}60846085if (lastOne)6086{6087if (p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup > lastOne)6088{6089DeleteTree(p_FmPcdCcTree, p_FmPcd);6090XX_Free(p_Params);6091REPORT_ERROR(MAJOR, E_CONFLICT, ("numOfEntries per group must be set in descending order"));6092return NULL;6093}6094}60956096lastOne = p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup;60976098netEnvParams.netEnvId = p_FmPcdCcTree->netEnvId;6099netEnvParams.numOfDistinctionUnits =6100p_FmPcdCcGroupParams->numOfDistinctionUnits;61016102memcpy(netEnvParams.unitIds, &p_FmPcdCcGroupParams->unitIds,6103(sizeof(uint8_t)) * p_FmPcdCcGroupParams->numOfDistinctionUnits);61046105err = PcdGetUnitsVector(p_FmPcd, &netEnvParams);6106if (err)6107{6108DeleteTree(p_FmPcdCcTree, p_FmPcd);6109XX_Free(p_Params);6110REPORT_ERROR(MAJOR, err, NO_MSG);6111return NULL;6112}61136114p_FmPcdCcTree->fmPcdGroupParam[i].totalBitsMask = netEnvParams.vector;6115for (j = 0; j < p_FmPcdCcTree->fmPcdGroupParam[i].numOfEntriesInGroup;6116j++)6117{6118err = ValidateNextEngineParams(6119h_FmPcd,6120&p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j],6121e_FM_PCD_CC_STATS_MODE_NONE);6122if (err)6123{6124DeleteTree(p_FmPcdCcTree, p_FmPcd);6125XX_Free(p_Params);6126REPORT_ERROR(MAJOR, err, (NO_MSG));6127return NULL;6128}61296130if (p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j].h_Manip)6131{6132err = FmPcdManipCheckParamsForCcNextEngine(6133&p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j],6134&requiredAction);6135if (err)6136{6137DeleteTree(p_FmPcdCcTree, p_FmPcd);6138XX_Free(p_Params);6139REPORT_ERROR(MAJOR, E_INVALID_STATE, NO_MSG);6140return NULL;6141}6142}6143p_KeyAndNextEngineParams = p_Params + k;61446145memcpy(&p_KeyAndNextEngineParams->nextEngineParams,6146&p_FmPcdCcGroupParams->nextEnginePerEntriesInGrp[j],6147sizeof(t_FmPcdCcNextEngineParams));61486149if ((p_KeyAndNextEngineParams->nextEngineParams.nextEngine6150== e_FM_PCD_CC)6151&& p_KeyAndNextEngineParams->nextEngineParams.h_Manip)6152{6153err =6154AllocAndFillAdForContLookupManip(6155p_KeyAndNextEngineParams->nextEngineParams.params.ccParams.h_CcNode);6156if (err)6157{6158DeleteTree(p_FmPcdCcTree, p_FmPcd);6159XX_Free(p_Params);6160REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC Tree"));6161return NULL;6162}6163}61646165requiredAction |= UPDATE_CC_WITH_TREE;6166p_KeyAndNextEngineParams->requiredAction = requiredAction;61676168k++;6169}6170}61716172p_FmPcdCcTree->numOfEntries = (uint8_t)k;6173p_FmPcdCcTree->numOfGrps = p_PcdGroupsParam->numOfGrps;61746175p_FmPcdCcTree->ccTreeBaseAddr =6176PTR_TO_UINT(FM_MURAM_AllocMem(FmPcdGetMuramHandle(h_FmPcd),6177(uint32_t)( FM_PCD_MAX_NUM_OF_CC_GROUPS * FM_PCD_CC_AD_ENTRY_SIZE),6178FM_PCD_CC_TREE_ADDR_ALIGN));6179if (!p_FmPcdCcTree->ccTreeBaseAddr)6180{6181DeleteTree(p_FmPcdCcTree, p_FmPcd);6182XX_Free(p_Params);6183REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for CC Tree"));6184return NULL;6185}6186MemSet8(6187UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr), 0,6188(uint32_t)(FM_PCD_MAX_NUM_OF_CC_GROUPS * FM_PCD_CC_AD_ENTRY_SIZE));61896190p_CcTreeTmp = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);61916192for (i = 0; i < numOfEntries; i++)6193{6194p_KeyAndNextEngineParams = p_Params + i;61956196NextStepAd(p_CcTreeTmp, NULL,6197&p_KeyAndNextEngineParams->nextEngineParams, p_FmPcd);61986199p_CcTreeTmp = PTR_MOVE(p_CcTreeTmp, FM_PCD_CC_AD_ENTRY_SIZE);62006201memcpy(&p_FmPcdCcTree->keyAndNextEngineParams[i],6202p_KeyAndNextEngineParams,6203sizeof(t_FmPcdCcKeyAndNextEngineParams));62046205if (p_FmPcdCcTree->keyAndNextEngineParams[i].nextEngineParams.nextEngine6206== e_FM_PCD_CC)6207{6208p_FmPcdCcNextNode =6209(t_FmPcdCcNode*)p_FmPcdCcTree->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;6210p_CcInformation = FindNodeInfoInReleventLst(6211&p_FmPcdCcNextNode->ccTreeIdLst, (t_Handle)p_FmPcdCcTree,6212p_FmPcdCcNextNode->h_Spinlock);62136214if (!p_CcInformation)6215{6216memset(&ccNodeInfo, 0, sizeof(t_CcNodeInformation));6217ccNodeInfo.h_CcNode = (t_Handle)p_FmPcdCcTree;6218ccNodeInfo.index = 1;6219EnqueueNodeInfoToRelevantLst(&p_FmPcdCcNextNode->ccTreeIdLst,6220&ccNodeInfo,6221p_FmPcdCcNextNode->h_Spinlock);6222}6223else6224p_CcInformation->index++;6225}6226}62276228FmPcdIncNetEnvOwners(h_FmPcd, p_FmPcdCcTree->netEnvId);6229p_CcTreeTmp = UINT_TO_PTR(p_FmPcdCcTree->ccTreeBaseAddr);62306231if (!FmPcdLockTryLockAll(p_FmPcd))6232{6233FM_PCD_CcRootDelete(p_FmPcdCcTree);6234XX_Free(p_Params);6235DBG(TRACE, ("FmPcdLockTryLockAll failed"));6236return NULL;6237}62386239for (i = 0; i < numOfEntries; i++)6240{6241if (p_FmPcdCcTree->keyAndNextEngineParams[i].requiredAction)6242{6243err = SetRequiredAction(6244h_FmPcd,6245p_FmPcdCcTree->keyAndNextEngineParams[i].requiredAction,6246&p_FmPcdCcTree->keyAndNextEngineParams[i], p_CcTreeTmp, 1,6247p_FmPcdCcTree);6248if (err)6249{6250FmPcdLockUnlockAll(p_FmPcd);6251FM_PCD_CcRootDelete(p_FmPcdCcTree);6252XX_Free(p_Params);6253REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));6254return NULL;6255}6256p_CcTreeTmp = PTR_MOVE(p_CcTreeTmp, FM_PCD_CC_AD_ENTRY_SIZE);6257}6258}62596260FmPcdLockUnlockAll(p_FmPcd);6261p_FmPcdCcTree->p_Lock = FmPcdAcquireLock(p_FmPcd);6262if (!p_FmPcdCcTree->p_Lock)6263{6264FM_PCD_CcRootDelete(p_FmPcdCcTree);6265XX_Free(p_Params);6266REPORT_ERROR(MAJOR, E_NO_MEMORY, ("FM CC lock"));6267return NULL;6268}62696270XX_Free(p_Params);62716272return p_FmPcdCcTree;6273}62746275t_Error FM_PCD_CcRootDelete(t_Handle h_CcTree)6276{6277t_FmPcd *p_FmPcd;6278t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_CcTree;6279int i = 0;62806281SANITY_CHECK_RETURN_ERROR(p_CcTree, E_INVALID_STATE);6282p_FmPcd = (t_FmPcd *)p_CcTree->h_FmPcd;6283SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);62846285FmPcdDecNetEnvOwners(p_FmPcd, p_CcTree->netEnvId);62866287if (p_CcTree->owners)6288RETURN_ERROR(6289MAJOR,6290E_INVALID_SELECTION,6291("the tree with this ID can not be removed because this tree is occupied, first - unbind this tree"));62926293/* Delete ip-reassembly schemes if exist */6294if (p_CcTree->h_IpReassemblyManip)6295{6296FmPcdManipDeleteIpReassmSchemes(p_CcTree->h_IpReassemblyManip);6297FmPcdManipUpdateOwner(p_CcTree->h_IpReassemblyManip, FALSE);6298}62996300/* Delete capwap-reassembly schemes if exist */6301if (p_CcTree->h_CapwapReassemblyManip)6302{6303FmPcdManipDeleteCapwapReassmSchemes(p_CcTree->h_CapwapReassemblyManip);6304FmPcdManipUpdateOwner(p_CcTree->h_CapwapReassemblyManip, FALSE);6305}63066307for (i = 0; i < p_CcTree->numOfEntries; i++)6308{6309if (p_CcTree->keyAndNextEngineParams[i].nextEngineParams.nextEngine6310== e_FM_PCD_CC)6311UpdateNodeOwner(6312p_CcTree->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode,6313FALSE);63146315if (p_CcTree->keyAndNextEngineParams[i].nextEngineParams.h_Manip)6316FmPcdManipUpdateOwner(6317p_CcTree->keyAndNextEngineParams[i].nextEngineParams.h_Manip,6318FALSE);63196320#ifdef FM_CAPWAP_SUPPORT6321if ((p_CcTree->numOfGrps == 1) &&6322(p_CcTree->fmPcdGroupParam[0].numOfEntriesInGroup == 1) &&6323(p_CcTree->keyAndNextEngineParams[0].nextEngineParams.nextEngine == e_FM_PCD_CC) &&6324p_CcTree->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode &&6325IsCapwapApplSpecific(p_CcTree->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode))6326{6327if (FM_PCD_ManipNodeDelete(p_CcTree->keyAndNextEngineParams[0].nextEngineParams.h_Manip) != E_OK)6328return E_INVALID_STATE;6329}6330#endif /* FM_CAPWAP_SUPPORT */63316332#if (DPAA_VERSION >= 11)6333if ((p_CcTree->keyAndNextEngineParams[i].nextEngineParams.nextEngine6334== e_FM_PCD_FR)6335&& (p_CcTree->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic))6336FrmReplicGroupUpdateOwner(6337p_CcTree->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic,6338FALSE);6339#endif /* (DPAA_VERSION >= 11) */6340}63416342if (p_CcTree->p_Lock)6343FmPcdReleaseLock(p_CcTree->h_FmPcd, p_CcTree->p_Lock);63446345DeleteTree(p_CcTree, p_FmPcd);63466347return E_OK;6348}63496350t_Error FM_PCD_CcRootModifyNextEngine(6351t_Handle h_CcTree, uint8_t grpId, uint8_t index,6352t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)6353{6354t_FmPcd *p_FmPcd;6355t_FmPcdCcTree *p_CcTree = (t_FmPcdCcTree *)h_CcTree;6356t_Error err = E_OK;63576358SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);6359SANITY_CHECK_RETURN_ERROR(p_CcTree, E_INVALID_STATE);6360p_FmPcd = (t_FmPcd *)p_CcTree->h_FmPcd;6361SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);63626363if (!FmPcdLockTryLockAll(p_FmPcd))6364{6365DBG(TRACE, ("FmPcdLockTryLockAll failed"));6366return ERROR_CODE(E_BUSY);6367}63686369err = FmPcdCcModifyNextEngineParamTree(p_FmPcd, p_CcTree, grpId, index,6370p_FmPcdCcNextEngineParams);6371FmPcdLockUnlockAll(p_FmPcd);63726373if (err)6374{6375RETURN_ERROR(MAJOR, err, NO_MSG);6376}63776378return E_OK;6379}63806381t_Handle FM_PCD_MatchTableSet(t_Handle h_FmPcd,6382t_FmPcdCcNodeParams *p_CcNodeParam)6383{6384t_FmPcdCcNode *p_CcNode;6385t_Error err;63866387SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);6388SANITY_CHECK_RETURN_VALUE(p_CcNodeParam, E_NULL_POINTER, NULL);63896390p_CcNode = (t_FmPcdCcNode*)XX_Malloc(sizeof(t_FmPcdCcNode));6391if (!p_CcNode)6392{6393REPORT_ERROR(MAJOR, E_NO_MEMORY, ("No memory"));6394return NULL;6395}6396memset(p_CcNode, 0, sizeof(t_FmPcdCcNode));63976398err = MatchTableSet(h_FmPcd, p_CcNode, p_CcNodeParam);63996400switch(GET_ERROR_TYPE(err)6401) {6402case E_OK:6403break;64046405case E_BUSY:6406DBG(TRACE, ("E_BUSY error"));6407return NULL;64086409default:6410REPORT_ERROR(MAJOR, err, NO_MSG);6411return NULL;6412}64136414return p_CcNode;6415}64166417t_Error FM_PCD_MatchTableDelete(t_Handle h_CcNode)6418{6419t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6420int i = 0;64216422SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6423SANITY_CHECK_RETURN_ERROR(p_CcNode->h_FmPcd, E_INVALID_HANDLE);64246425if (p_CcNode->owners)6426RETURN_ERROR(6427MAJOR,6428E_INVALID_STATE,6429("This node cannot be removed because it is occupied; first unbind this node"));64306431for (i = 0; i < p_CcNode->numOfKeys; i++)6432if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine6433== e_FM_PCD_CC)6434UpdateNodeOwner(6435p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode,6436FALSE);64376438if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine6439== e_FM_PCD_CC)6440UpdateNodeOwner(6441p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode,6442FALSE);64436444/* Handle also Miss entry */6445for (i = 0; i < p_CcNode->numOfKeys + 1; i++)6446{6447if (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip)6448FmPcdManipUpdateOwner(6449p_CcNode->keyAndNextEngineParams[i].nextEngineParams.h_Manip,6450FALSE);64516452#if (DPAA_VERSION >= 11)6453if ((p_CcNode->keyAndNextEngineParams[i].nextEngineParams.nextEngine6454== e_FM_PCD_FR)6455&& (p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic))6456{6457FrmReplicGroupUpdateOwner(6458p_CcNode->keyAndNextEngineParams[i].nextEngineParams.params.frParams.h_FrmReplic,6459FALSE);6460}6461#endif /* (DPAA_VERSION >= 11) */6462}64636464DeleteNode(p_CcNode);64656466return E_OK;6467}64686469t_Error FM_PCD_MatchTableAddKey(t_Handle h_CcNode, uint16_t keyIndex,6470uint8_t keySize,6471t_FmPcdCcKeyParams *p_KeyParams)6472{6473t_FmPcd *p_FmPcd;6474t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6475t_Error err = E_OK;64766477SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);6478SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6479p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;6480SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);6481SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);64826483if (keyIndex == FM_PCD_LAST_KEY_INDEX)6484keyIndex = p_CcNode->numOfKeys;64856486if (!FmPcdLockTryLockAll(p_FmPcd))6487{6488DBG(TRACE, ("FmPcdLockTryLockAll failed"));6489return ERROR_CODE(E_BUSY);6490}64916492err = FmPcdCcAddKey(p_FmPcd, p_CcNode, keyIndex, keySize, p_KeyParams);64936494FmPcdLockUnlockAll(p_FmPcd);64956496switch(GET_ERROR_TYPE(err)6497) {6498case E_OK:6499return E_OK;65006501case E_BUSY:6502DBG(TRACE, ("E_BUSY error"));6503return ERROR_CODE(E_BUSY);65046505default:6506RETURN_ERROR(MAJOR, err, NO_MSG);6507}6508}65096510t_Error FM_PCD_MatchTableRemoveKey(t_Handle h_CcNode, uint16_t keyIndex)6511{6512t_FmPcd *p_FmPcd;6513t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6514t_Error err = E_OK;65156516SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6517p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;6518SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);6519SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);65206521if (!FmPcdLockTryLockAll(p_FmPcd))6522{6523DBG(TRACE, ("FmPcdLockTryLockAll failed"));6524return ERROR_CODE(E_BUSY);6525}65266527err = FmPcdCcRemoveKey(p_FmPcd, p_CcNode, keyIndex);65286529FmPcdLockUnlockAll(p_FmPcd);65306531switch(GET_ERROR_TYPE(err)6532) {6533case E_OK:6534return E_OK;65356536case E_BUSY:6537DBG(TRACE, ("E_BUSY error"));6538return ERROR_CODE(E_BUSY);65396540default:6541RETURN_ERROR(MAJOR, err, NO_MSG);6542}65436544return E_OK;6545}65466547t_Error FM_PCD_MatchTableModifyKey(t_Handle h_CcNode, uint16_t keyIndex,6548uint8_t keySize, uint8_t *p_Key,6549uint8_t *p_Mask)6550{6551t_FmPcd *p_FmPcd;6552t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6553t_Error err = E_OK;65546555SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6556SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);6557p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;6558SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);6559SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);656065616562if (!FmPcdLockTryLockAll(p_FmPcd))6563{6564DBG(TRACE, ("FmPcdLockTryLockAll failed"));6565return ERROR_CODE(E_BUSY);6566}65676568err = FmPcdCcModifyKey(p_FmPcd, p_CcNode, keyIndex, keySize, p_Key, p_Mask);65696570FmPcdLockUnlockAll(p_FmPcd);65716572switch(GET_ERROR_TYPE(err)6573) {6574case E_OK:6575return E_OK;65766577case E_BUSY:6578DBG(TRACE, ("E_BUSY error"));6579return ERROR_CODE(E_BUSY);65806581default:6582RETURN_ERROR(MAJOR, err, NO_MSG);6583}6584}65856586t_Error FM_PCD_MatchTableModifyNextEngine(6587t_Handle h_CcNode, uint16_t keyIndex,6588t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)6589{6590t_FmPcd *p_FmPcd;6591t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6592t_Error err = E_OK;65936594SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);6595SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6596p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;6597SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);6598SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);65996600if (!FmPcdLockTryLockAll(p_FmPcd))6601{6602DBG(TRACE, ("FmPcdLockTryLockAll failed"));6603return ERROR_CODE(E_BUSY);6604}66056606err = ModifyNextEngineParamNode(p_FmPcd, p_CcNode, keyIndex,6607p_FmPcdCcNextEngineParams);66086609FmPcdLockUnlockAll(p_FmPcd);66106611switch(GET_ERROR_TYPE(err)6612) {6613case E_OK:6614return E_OK;66156616case E_BUSY:6617DBG(TRACE, ("E_BUSY error"));6618return ERROR_CODE(E_BUSY);66196620default:6621RETURN_ERROR(MAJOR, err, NO_MSG);6622}6623}66246625t_Error FM_PCD_MatchTableModifyMissNextEngine(6626t_Handle h_CcNode, t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)6627{6628t_FmPcd *p_FmPcd;6629t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6630t_Error err = E_OK;66316632SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);6633SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6634p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;6635SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);6636SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);66376638if (!FmPcdLockTryLockAll(p_FmPcd))6639{6640DBG(TRACE, ("FmPcdLockTryLockAll failed"));6641return ERROR_CODE(E_BUSY);6642}66436644err = FmPcdCcModifyMissNextEngineParamNode(p_FmPcd, p_CcNode,6645p_FmPcdCcNextEngineParams);66466647FmPcdLockUnlockAll(p_FmPcd);66486649switch(GET_ERROR_TYPE(err)6650) {6651case E_OK:6652return E_OK;66536654case E_BUSY:6655DBG(TRACE, ("E_BUSY error"));6656return ERROR_CODE(E_BUSY);66576658default:6659RETURN_ERROR(MAJOR, err, NO_MSG);6660}6661}66626663t_Error FM_PCD_MatchTableModifyKeyAndNextEngine(t_Handle h_CcNode,6664uint16_t keyIndex,6665uint8_t keySize,6666t_FmPcdCcKeyParams *p_KeyParams)6667{6668t_FmPcd *p_FmPcd;6669t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6670t_Error err = E_OK;66716672SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);6673SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6674p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;6675SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);6676SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);66776678if (!FmPcdLockTryLockAll(p_FmPcd))6679{6680DBG(TRACE, ("FmPcdLockTryLockAll failed"));6681return ERROR_CODE(E_BUSY);6682}66836684err = FmPcdCcModifyKeyAndNextEngine(p_FmPcd, p_CcNode, keyIndex, keySize,6685p_KeyParams);66866687FmPcdLockUnlockAll(p_FmPcd);66886689switch(GET_ERROR_TYPE(err)6690) {6691case E_OK:6692return E_OK;66936694case E_BUSY:6695DBG(TRACE, ("E_BUSY error"));6696return ERROR_CODE(E_BUSY);66976698default:6699RETURN_ERROR(MAJOR, err, NO_MSG);6700}6701}67026703t_Error FM_PCD_MatchTableFindNRemoveKey(t_Handle h_CcNode, uint8_t keySize,6704uint8_t *p_Key, uint8_t *p_Mask)6705{6706t_FmPcd *p_FmPcd;6707t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6708uint16_t keyIndex;6709t_Error err;67106711SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);6712SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6713p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;6714SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);6715SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);67166717if (!FmPcdLockTryLockAll(p_FmPcd))6718{6719DBG(TRACE, ("FmPcdLockTryLockAll failed"));6720return ERROR_CODE(E_BUSY);6721}67226723err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);6724if (GET_ERROR_TYPE(err) != E_OK)6725{6726FmPcdLockUnlockAll(p_FmPcd);6727RETURN_ERROR(6728MAJOR,6729err,6730("The received key and mask pair was not found in the match table of the provided node"));6731}67326733err = FmPcdCcRemoveKey(p_FmPcd, p_CcNode, keyIndex);67346735FmPcdLockUnlockAll(p_FmPcd);67366737switch(GET_ERROR_TYPE(err)6738) {6739case E_OK:6740return E_OK;67416742case E_BUSY:6743DBG(TRACE, ("E_BUSY error"));6744return ERROR_CODE(E_BUSY);67456746default:6747RETURN_ERROR(MAJOR, err, NO_MSG);6748}6749}67506751t_Error FM_PCD_MatchTableFindNModifyNextEngine(6752t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask,6753t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)6754{6755t_FmPcd *p_FmPcd;6756t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6757uint16_t keyIndex;6758t_Error err;67596760SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);6761SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);6762SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6763p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;6764SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);6765SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);67666767if (!FmPcdLockTryLockAll(p_FmPcd))6768{6769DBG(TRACE, ("FmPcdLockTryLockAll failed"));6770return ERROR_CODE(E_BUSY);6771}67726773err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);6774if (GET_ERROR_TYPE(err) != E_OK)6775{6776FmPcdLockUnlockAll(p_FmPcd);6777RETURN_ERROR(6778MAJOR,6779err,6780("The received key and mask pair was not found in the match table of the provided node"));6781}67826783err = ModifyNextEngineParamNode(p_FmPcd, p_CcNode, keyIndex,6784p_FmPcdCcNextEngineParams);67856786FmPcdLockUnlockAll(p_FmPcd);67876788switch(GET_ERROR_TYPE(err)6789) {6790case E_OK:6791return E_OK;67926793case E_BUSY:6794DBG(TRACE, ("E_BUSY error"));6795return ERROR_CODE(E_BUSY);67966797default:6798RETURN_ERROR(MAJOR, err, NO_MSG);6799}6800}68016802t_Error FM_PCD_MatchTableFindNModifyKeyAndNextEngine(6803t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask,6804t_FmPcdCcKeyParams *p_KeyParams)6805{6806t_FmPcd *p_FmPcd;6807t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6808uint16_t keyIndex;6809t_Error err;68106811SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);6812SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);6813SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6814p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;6815SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);6816SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);68176818if (!FmPcdLockTryLockAll(p_FmPcd))6819{6820DBG(TRACE, ("FmPcdLockTryLockAll failed"));6821return ERROR_CODE(E_BUSY);6822}68236824err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);6825if (GET_ERROR_TYPE(err) != E_OK)6826{6827FmPcdLockUnlockAll(p_FmPcd);6828RETURN_ERROR(6829MAJOR,6830err,6831("The received key and mask pair was not found in the match table of the provided node"));6832}68336834err = FmPcdCcModifyKeyAndNextEngine(p_FmPcd, h_CcNode, keyIndex, keySize,6835p_KeyParams);68366837FmPcdLockUnlockAll(p_FmPcd);68386839switch(GET_ERROR_TYPE(err)6840) {6841case E_OK:6842return E_OK;68436844case E_BUSY:6845DBG(TRACE, ("E_BUSY error"));6846return ERROR_CODE(E_BUSY);68476848default:6849RETURN_ERROR(MAJOR, err, NO_MSG);6850}6851}68526853t_Error FM_PCD_MatchTableFindNModifyKey(t_Handle h_CcNode, uint8_t keySize,6854uint8_t *p_Key, uint8_t *p_Mask,6855uint8_t *p_NewKey, uint8_t *p_NewMask)6856{6857t_FmPcd *p_FmPcd;6858t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6859t_List h_List;6860uint16_t keyIndex;6861t_Error err;68626863SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);6864SANITY_CHECK_RETURN_ERROR(p_NewKey, E_NULL_POINTER);6865SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6866p_FmPcd = (t_FmPcd *)p_CcNode->h_FmPcd;6867SANITY_CHECK_RETURN_ERROR(p_FmPcd, E_INVALID_HANDLE);6868SANITY_CHECK_RETURN_ERROR(p_FmPcd->h_Hc, E_INVALID_HANDLE);68696870INIT_LIST(&h_List);68716872err = FmPcdCcNodeTreeTryLock(p_FmPcd, p_CcNode, &h_List);6873if (err)6874{6875DBG(TRACE, ("Node's trees lock failed"));6876return ERROR_CODE(E_BUSY);6877}68786879err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);6880if (GET_ERROR_TYPE(err) != E_OK)6881{6882FmPcdCcNodeTreeReleaseLock(p_FmPcd, &h_List);6883RETURN_ERROR(MAJOR, err,6884("The received key and mask pair was not found in the "6885"match table of the provided node"));6886}68876888err = FmPcdCcModifyKey(p_FmPcd, p_CcNode, keyIndex, keySize, p_NewKey,6889p_NewMask);68906891FmPcdCcNodeTreeReleaseLock(p_FmPcd, &h_List);68926893switch(GET_ERROR_TYPE(err)6894) {6895case E_OK:6896return E_OK;68976898case E_BUSY:6899DBG(TRACE, ("E_BUSY error"));6900return ERROR_CODE(E_BUSY);69016902default:6903RETURN_ERROR(MAJOR, err, NO_MSG);6904}6905}69066907t_Error FM_PCD_MatchTableGetNextEngine(6908t_Handle h_CcNode, uint16_t keyIndex,6909t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)6910{6911t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;69126913SANITY_CHECK_RETURN_ERROR(p_CcNode, E_INVALID_HANDLE);6914SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);69156916if (keyIndex >= p_CcNode->numOfKeys)6917RETURN_ERROR(MAJOR, E_INVALID_STATE,6918("keyIndex exceeds current number of keys"));69196920if (keyIndex > (FM_PCD_MAX_NUM_OF_KEYS - 1))6921RETURN_ERROR(6922MAJOR,6923E_INVALID_VALUE,6924("keyIndex can not be larger than %d", (FM_PCD_MAX_NUM_OF_KEYS - 1)));69256926memcpy(p_FmPcdCcNextEngineParams,6927&p_CcNode->keyAndNextEngineParams[keyIndex].nextEngineParams,6928sizeof(t_FmPcdCcNextEngineParams));69296930return E_OK;6931}693269336934uint32_t FM_PCD_MatchTableGetKeyCounter(t_Handle h_CcNode, uint16_t keyIndex)6935{6936t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6937uint32_t *p_StatsCounters, frameCount;6938uint32_t intFlags;69396940SANITY_CHECK_RETURN_VALUE(p_CcNode, E_INVALID_HANDLE, 0);69416942if (p_CcNode->statisticsMode == e_FM_PCD_CC_STATS_MODE_NONE)6943{6944REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Statistics were not enabled for this match table"));6945return 0;6946}69476948if ((p_CcNode->statisticsMode != e_FM_PCD_CC_STATS_MODE_FRAME)6949&& (p_CcNode->statisticsMode6950!= e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME))6951{6952REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Frame count is not supported in the statistics mode of this match table"));6953return 0;6954}69556956intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);69576958if (keyIndex >= p_CcNode->numOfKeys)6959{6960XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);6961REPORT_ERROR(MAJOR, E_INVALID_STATE, ("The provided keyIndex exceeds the number of keys in this match table"));6962return 0;6963}69646965if (!p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj)6966{6967XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);6968REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Statistics were not enabled for this key"));6969return 0;6970}69716972p_StatsCounters =6973p_CcNode->keyAndNextEngineParams[keyIndex].p_StatsObj->h_StatsCounters;6974ASSERT_COND(p_StatsCounters);69756976/* The first counter is byte counter, so we need to advance to the next counter */6977frameCount = GET_UINT32(*(uint32_t *)(PTR_MOVE(p_StatsCounters,6978FM_PCD_CC_STATS_COUNTER_SIZE)));69796980XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);69816982return frameCount;6983}69846985t_Error FM_PCD_MatchTableGetKeyStatistics(6986t_Handle h_CcNode, uint16_t keyIndex,6987t_FmPcdCcKeyStatistics *p_KeyStatistics)6988{6989t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;6990uint32_t intFlags;6991t_Error err;69926993SANITY_CHECK_RETURN_ERROR(h_CcNode, E_INVALID_HANDLE);6994SANITY_CHECK_RETURN_ERROR(p_KeyStatistics, E_NULL_POINTER);69956996intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);69976998if (keyIndex >= p_CcNode->numOfKeys)6999RETURN_ERROR(7000MAJOR,7001E_INVALID_STATE,7002("The provided keyIndex exceeds the number of keys in this match table"));70037004err = MatchTableGetKeyStatistics(p_CcNode, keyIndex, p_KeyStatistics);70057006XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);70077008if (err != E_OK)7009RETURN_ERROR(MAJOR, err, NO_MSG);70107011return E_OK;7012}70137014t_Error FM_PCD_MatchTableGetMissStatistics(7015t_Handle h_CcNode, t_FmPcdCcKeyStatistics *p_MissStatistics)7016{7017t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;7018uint32_t intFlags;7019t_Error err;70207021SANITY_CHECK_RETURN_ERROR(h_CcNode, E_INVALID_HANDLE);7022SANITY_CHECK_RETURN_ERROR(p_MissStatistics, E_NULL_POINTER);70237024intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);70257026err = MatchTableGetKeyStatistics(p_CcNode, p_CcNode->numOfKeys,7027p_MissStatistics);70287029XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);70307031if (err != E_OK)7032RETURN_ERROR(MAJOR, err, NO_MSG);70337034return E_OK;7035}70367037t_Error FM_PCD_MatchTableFindNGetKeyStatistics(7038t_Handle h_CcNode, uint8_t keySize, uint8_t *p_Key, uint8_t *p_Mask,7039t_FmPcdCcKeyStatistics *p_KeyStatistics)7040{7041t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;7042uint16_t keyIndex;7043uint32_t intFlags;7044t_Error err;70457046SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);7047SANITY_CHECK_RETURN_ERROR(p_KeyStatistics, E_NULL_POINTER);70487049intFlags = XX_LockIntrSpinlock(p_CcNode->h_Spinlock);70507051err = FindKeyIndex(p_CcNode, keySize, p_Key, p_Mask, &keyIndex);7052if (GET_ERROR_TYPE(err) != E_OK)7053{7054XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);7055RETURN_ERROR(MAJOR, err,7056("The received key and mask pair was not found in the "7057"match table of the provided node"));7058}70597060ASSERT_COND(keyIndex < p_CcNode->numOfKeys);70617062err = MatchTableGetKeyStatistics(p_CcNode, keyIndex, p_KeyStatistics);70637064XX_UnlockIntrSpinlock(p_CcNode->h_Spinlock, intFlags);70657066if (err != E_OK)7067RETURN_ERROR(MAJOR, err, NO_MSG);70687069return E_OK;7070}70717072t_Error FM_PCD_MatchTableGetIndexedHashBucket(t_Handle h_CcNode,7073uint8_t keySize, uint8_t *p_Key,7074uint8_t hashShift,7075t_Handle *p_CcNodeBucketHandle,7076uint8_t *p_BucketIndex,7077uint16_t *p_LastIndex)7078{7079t_FmPcdCcNode *p_CcNode = (t_FmPcdCcNode *)h_CcNode;7080uint16_t glblMask;7081uint64_t crc64 = 0;70827083SANITY_CHECK_RETURN_ERROR(h_CcNode, E_INVALID_HANDLE);7084SANITY_CHECK_RETURN_ERROR(7085p_CcNode->parseCode == CC_PC_GENERIC_IC_HASH_INDEXED,7086E_INVALID_STATE);7087SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);7088SANITY_CHECK_RETURN_ERROR(p_CcNodeBucketHandle, E_NULL_POINTER);70897090memcpy(&glblMask, PTR_MOVE(p_CcNode->p_GlblMask, 2), 2);7091glblMask = be16toh(glblMask);70927093crc64 = crc64_init();7094crc64 = crc64_compute(p_Key, keySize, crc64);7095crc64 >>= hashShift;70967097*p_BucketIndex = (uint8_t)(((crc64 >> (8 * (6 - p_CcNode->userOffset)))7098& glblMask) >> 4);7099if (*p_BucketIndex >= p_CcNode->numOfKeys)7100RETURN_ERROR(MINOR, E_NOT_IN_RANGE, ("bucket index!"));71017102*p_CcNodeBucketHandle =7103p_CcNode->keyAndNextEngineParams[*p_BucketIndex].nextEngineParams.params.ccParams.h_CcNode;7104if (!*p_CcNodeBucketHandle)7105RETURN_ERROR(MINOR, E_NOT_FOUND, ("bucket!"));71067107*p_LastIndex = ((t_FmPcdCcNode *)*p_CcNodeBucketHandle)->numOfKeys;71087109return E_OK;7110}71117112t_Handle FM_PCD_HashTableSet(t_Handle h_FmPcd, t_FmPcdHashTableParams *p_Param)7113{7114t_FmPcdCcNode *p_CcNodeHashTbl;7115t_FmPcdCcNodeParams *p_IndxHashCcNodeParam, *p_ExactMatchCcNodeParam;7116t_FmPcdCcNode *p_CcNode;7117t_Handle h_MissStatsCounters = NULL;7118t_FmPcdCcKeyParams *p_HashKeyParams;7119int i;7120uint16_t numOfSets, numOfWays, countMask, onesCount = 0;7121bool statsEnForMiss = FALSE;7122t_Error err;71237124SANITY_CHECK_RETURN_VALUE(h_FmPcd, E_INVALID_HANDLE, NULL);7125SANITY_CHECK_RETURN_VALUE(p_Param, E_NULL_POINTER, NULL);71267127if (p_Param->maxNumOfKeys == 0)7128{7129REPORT_ERROR(MINOR, E_INVALID_VALUE, ("Max number of keys must be higher then 0"));7130return NULL;7131}71327133if (p_Param->hashResMask == 0)7134{7135REPORT_ERROR(MINOR, E_INVALID_VALUE, ("Hash result mask must differ from 0"));7136return NULL;7137}71387139/*Fix: QorIQ SDK / QSDK-2131*/7140if (p_Param->ccNextEngineParamsForMiss.nextEngine == e_FM_PCD_INVALID)7141{7142REPORT_ERROR(MAJOR, E_INVALID_VALUE, ("Next PCD Engine for on-miss entry is invalid. On-miss entry is always required. You can use e_FM_PCD_DONE."));7143return NULL;7144}71457146#if (DPAA_VERSION >= 11)7147if (p_Param->statisticsMode == e_FM_PCD_CC_STATS_MODE_RMON)7148{7149REPORT_ERROR(MAJOR, E_INVALID_VALUE,7150("RMON statistics mode is not supported for hash table"));7151return NULL;7152}7153#endif /* (DPAA_VERSION >= 11) */71547155p_ExactMatchCcNodeParam = (t_FmPcdCcNodeParams*)XX_Malloc(7156sizeof(t_FmPcdCcNodeParams));7157if (!p_ExactMatchCcNodeParam)7158{7159REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_ExactMatchCcNodeParam"));7160return NULL;7161}7162memset(p_ExactMatchCcNodeParam, 0, sizeof(t_FmPcdCcNodeParams));71637164p_IndxHashCcNodeParam = (t_FmPcdCcNodeParams*)XX_Malloc(7165sizeof(t_FmPcdCcNodeParams));7166if (!p_IndxHashCcNodeParam)7167{7168XX_Free(p_ExactMatchCcNodeParam);7169REPORT_ERROR(MAJOR, E_NO_MEMORY, ("p_IndxHashCcNodeParam"));7170return NULL;7171}7172memset(p_IndxHashCcNodeParam, 0, sizeof(t_FmPcdCcNodeParams));71737174/* Calculate number of sets and number of ways of the hash table */7175countMask = (uint16_t)(p_Param->hashResMask >> 4);7176while (countMask)7177{7178onesCount++;7179countMask = (uint16_t)(countMask >> 1);7180}71817182numOfSets = (uint16_t)(1 << onesCount);7183numOfWays = (uint16_t)DIV_CEIL(p_Param->maxNumOfKeys, numOfSets);71847185if (p_Param->maxNumOfKeys % numOfSets)7186DBG(INFO, ("'maxNumOfKeys' is not a multiple of hash number of ways, so number of ways will be rounded up"));71877188if ((p_Param->statisticsMode == e_FM_PCD_CC_STATS_MODE_FRAME)7189|| (p_Param->statisticsMode == e_FM_PCD_CC_STATS_MODE_BYTE_AND_FRAME))7190{7191/* Allocating a statistics counters table that will be used by all7192'miss' entries of the hash table */7193h_MissStatsCounters = (t_Handle)FM_MURAM_AllocMem(7194FmPcdGetMuramHandle(h_FmPcd), 2 * FM_PCD_CC_STATS_COUNTER_SIZE,7195FM_PCD_CC_AD_TABLE_ALIGN);7196if (!h_MissStatsCounters)7197{7198REPORT_ERROR(MAJOR, E_NO_MEMORY, ("MURAM allocation for statistics table for hash miss"));7199XX_Free(p_IndxHashCcNodeParam);7200XX_Free(p_ExactMatchCcNodeParam);7201return NULL;7202}7203memset(h_MissStatsCounters, 0, (2 * FM_PCD_CC_STATS_COUNTER_SIZE));72047205/* Always enable statistics for 'miss', so that a statistics AD will be7206initialized from the start. We'll store the requested 'statistics enable'7207value and it will be used when statistics are read by the user. */7208statsEnForMiss = p_Param->ccNextEngineParamsForMiss.statisticsEn;7209p_Param->ccNextEngineParamsForMiss.statisticsEn = TRUE;7210}72117212/* Building exact-match node params, will be used to create the hash buckets */7213p_ExactMatchCcNodeParam->extractCcParams.type = e_FM_PCD_EXTRACT_NON_HDR;72147215p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.src =7216e_FM_PCD_EXTRACT_FROM_KEY;7217p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.action =7218e_FM_PCD_ACTION_EXACT_MATCH;7219p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.offset = 0;7220p_ExactMatchCcNodeParam->extractCcParams.extractNonHdr.size =7221p_Param->matchKeySize;72227223p_ExactMatchCcNodeParam->keysParams.maxNumOfKeys = numOfWays;7224p_ExactMatchCcNodeParam->keysParams.maskSupport = FALSE;7225p_ExactMatchCcNodeParam->keysParams.statisticsMode =7226p_Param->statisticsMode;7227p_ExactMatchCcNodeParam->keysParams.numOfKeys = 0;7228p_ExactMatchCcNodeParam->keysParams.keySize = p_Param->matchKeySize;7229p_ExactMatchCcNodeParam->keysParams.ccNextEngineParamsForMiss =7230p_Param->ccNextEngineParamsForMiss;72317232p_HashKeyParams = p_IndxHashCcNodeParam->keysParams.keyParams;72337234for (i = 0; i < numOfSets; i++)7235{7236/* Each exact-match node will be marked as a 'bucket' and provided with7237a pointer to statistics counters, to be used for 'miss' entry7238statistics */7239p_CcNode = (t_FmPcdCcNode *)XX_Malloc(sizeof(t_FmPcdCcNode));7240if (!p_CcNode)7241break;7242memset(p_CcNode, 0, sizeof(t_FmPcdCcNode));72437244p_CcNode->isHashBucket = TRUE;7245p_CcNode->h_MissStatsCounters = h_MissStatsCounters;72467247err = MatchTableSet(h_FmPcd, p_CcNode, p_ExactMatchCcNodeParam);7248if (err)7249break;72507251p_HashKeyParams[i].ccNextEngineParams.nextEngine = e_FM_PCD_CC;7252p_HashKeyParams[i].ccNextEngineParams.statisticsEn = FALSE;7253p_HashKeyParams[i].ccNextEngineParams.params.ccParams.h_CcNode =7254p_CcNode;7255}72567257if (i < numOfSets)7258{7259for (i = i - 1; i >= 0; i--)7260FM_PCD_MatchTableDelete(7261p_HashKeyParams[i].ccNextEngineParams.params.ccParams.h_CcNode);72627263FM_MURAM_FreeMem(FmPcdGetMuramHandle(h_FmPcd), h_MissStatsCounters);72647265REPORT_ERROR(MAJOR, E_NULL_POINTER, NO_MSG);7266XX_Free(p_IndxHashCcNodeParam);7267XX_Free(p_ExactMatchCcNodeParam);7268return NULL;7269}72707271/* Creating indexed-hash CC node */7272p_IndxHashCcNodeParam->extractCcParams.type = e_FM_PCD_EXTRACT_NON_HDR;7273p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.src =7274e_FM_PCD_EXTRACT_FROM_HASH;7275p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.action =7276e_FM_PCD_ACTION_INDEXED_LOOKUP;7277p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.icIndxMask =7278p_Param->hashResMask;7279p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.offset =7280p_Param->hashShift;7281p_IndxHashCcNodeParam->extractCcParams.extractNonHdr.size = 2;72827283p_IndxHashCcNodeParam->keysParams.maxNumOfKeys = numOfSets;7284p_IndxHashCcNodeParam->keysParams.maskSupport = FALSE;7285p_IndxHashCcNodeParam->keysParams.statisticsMode =7286e_FM_PCD_CC_STATS_MODE_NONE;7287/* Number of keys of this node is number of sets of the hash */7288p_IndxHashCcNodeParam->keysParams.numOfKeys = numOfSets;7289p_IndxHashCcNodeParam->keysParams.keySize = 2;72907291p_CcNodeHashTbl = FM_PCD_MatchTableSet(h_FmPcd, p_IndxHashCcNodeParam);72927293if (p_CcNodeHashTbl)7294{7295p_CcNodeHashTbl->kgHashShift = p_Param->kgHashShift;72967297/* Storing the allocated counters for buckets 'miss' in the hash table7298and if statistics for miss were enabled. */7299p_CcNodeHashTbl->h_MissStatsCounters = h_MissStatsCounters;7300p_CcNodeHashTbl->statsEnForMiss = statsEnForMiss;7301}73027303XX_Free(p_IndxHashCcNodeParam);7304XX_Free(p_ExactMatchCcNodeParam);73057306return p_CcNodeHashTbl;7307}73087309t_Error FM_PCD_HashTableDelete(t_Handle h_HashTbl)7310{7311t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;7312t_Handle h_FmPcd;7313t_Handle *p_HashBuckets, h_MissStatsCounters;7314uint16_t i, numOfBuckets;7315t_Error err;73167317SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);73187319/* Store all hash buckets before the hash is freed */7320numOfBuckets = p_HashTbl->numOfKeys;73217322p_HashBuckets = (t_Handle *)XX_Malloc(numOfBuckets * sizeof(t_Handle));7323if (!p_HashBuckets)7324RETURN_ERROR(MAJOR, E_NO_MEMORY, NO_MSG);73257326for (i = 0; i < numOfBuckets; i++)7327p_HashBuckets[i] =7328p_HashTbl->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;73297330h_FmPcd = p_HashTbl->h_FmPcd;7331h_MissStatsCounters = p_HashTbl->h_MissStatsCounters;73327333/* Free the hash */7334err = FM_PCD_MatchTableDelete(p_HashTbl);73357336/* Free each hash bucket */7337for (i = 0; i < numOfBuckets; i++)7338err |= FM_PCD_MatchTableDelete(p_HashBuckets[i]);73397340XX_Free(p_HashBuckets);73417342/* Free statistics counters for 'miss', if these were allocated */7343if (h_MissStatsCounters)7344FM_MURAM_FreeMem(FmPcdGetMuramHandle(h_FmPcd), h_MissStatsCounters);73457346if (err)7347RETURN_ERROR(MAJOR, err, NO_MSG);73487349return E_OK;7350}73517352t_Error FM_PCD_HashTableAddKey(t_Handle h_HashTbl, uint8_t keySize,7353t_FmPcdCcKeyParams *p_KeyParams)7354{7355t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;7356t_Handle h_HashBucket;7357uint8_t bucketIndex;7358uint16_t lastIndex;7359t_Error err;73607361SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);7362SANITY_CHECK_RETURN_ERROR(p_KeyParams, E_NULL_POINTER);7363SANITY_CHECK_RETURN_ERROR(p_KeyParams->p_Key, E_NULL_POINTER);73647365if (p_KeyParams->p_Mask)7366RETURN_ERROR(MAJOR, E_INVALID_VALUE,7367("Keys masks not supported for hash table"));73687369err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize,7370p_KeyParams->p_Key,7371p_HashTbl->kgHashShift,7372&h_HashBucket, &bucketIndex,7373&lastIndex);7374if (err)7375RETURN_ERROR(MAJOR, err, NO_MSG);73767377return FM_PCD_MatchTableAddKey(h_HashBucket, FM_PCD_LAST_KEY_INDEX, keySize,7378p_KeyParams);7379}73807381t_Error FM_PCD_HashTableRemoveKey(t_Handle h_HashTbl, uint8_t keySize,7382uint8_t *p_Key)7383{7384t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;7385t_Handle h_HashBucket;7386uint8_t bucketIndex;7387uint16_t lastIndex;7388t_Error err;73897390SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);7391SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);73927393err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize, p_Key,7394p_HashTbl->kgHashShift,7395&h_HashBucket, &bucketIndex,7396&lastIndex);7397if (err)7398RETURN_ERROR(MAJOR, err, NO_MSG);73997400return FM_PCD_MatchTableFindNRemoveKey(h_HashBucket, keySize, p_Key, NULL);7401}74027403t_Error FM_PCD_HashTableModifyNextEngine(7404t_Handle h_HashTbl, uint8_t keySize, uint8_t *p_Key,7405t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)7406{7407t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;7408t_Handle h_HashBucket;7409uint8_t bucketIndex;7410uint16_t lastIndex;7411t_Error err;74127413SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);7414SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);7415SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);74167417err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize, p_Key,7418p_HashTbl->kgHashShift,7419&h_HashBucket, &bucketIndex,7420&lastIndex);7421if (err)7422RETURN_ERROR(MAJOR, err, NO_MSG);74237424return FM_PCD_MatchTableFindNModifyNextEngine(h_HashBucket, keySize, p_Key,7425NULL,7426p_FmPcdCcNextEngineParams);7427}74287429t_Error FM_PCD_HashTableModifyMissNextEngine(7430t_Handle h_HashTbl,7431t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)7432{7433t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;7434t_Handle h_HashBucket;7435uint8_t i;7436bool nullifyMissStats = FALSE;7437t_Error err;74387439SANITY_CHECK_RETURN_ERROR(h_HashTbl, E_INVALID_HANDLE);7440SANITY_CHECK_RETURN_ERROR(p_FmPcdCcNextEngineParams, E_NULL_POINTER);74417442if ((!p_HashTbl->h_MissStatsCounters)7443&& (p_FmPcdCcNextEngineParams->statisticsEn))7444RETURN_ERROR(7445MAJOR,7446E_CONFLICT,7447("Statistics are requested for a key, but statistics mode was set"7448"to 'NONE' upon initialization"));74497450if (p_HashTbl->h_MissStatsCounters)7451{7452if ((!p_HashTbl->statsEnForMiss)7453&& (p_FmPcdCcNextEngineParams->statisticsEn))7454nullifyMissStats = TRUE;74557456if ((p_HashTbl->statsEnForMiss)7457&& (!p_FmPcdCcNextEngineParams->statisticsEn))7458{7459p_HashTbl->statsEnForMiss = FALSE;7460p_FmPcdCcNextEngineParams->statisticsEn = TRUE;7461}7462}74637464for (i = 0; i < p_HashTbl->numOfKeys; i++)7465{7466h_HashBucket =7467p_HashTbl->keyAndNextEngineParams[i].nextEngineParams.params.ccParams.h_CcNode;74687469err = FM_PCD_MatchTableModifyMissNextEngine(h_HashBucket,7470p_FmPcdCcNextEngineParams);7471if (err)7472RETURN_ERROR(MAJOR, err, NO_MSG);7473}74747475if (nullifyMissStats)7476{7477memset(p_HashTbl->h_MissStatsCounters, 0,7478(2 * FM_PCD_CC_STATS_COUNTER_SIZE));7479memset(p_HashTbl->h_MissStatsCounters, 0,7480(2 * FM_PCD_CC_STATS_COUNTER_SIZE));7481p_HashTbl->statsEnForMiss = TRUE;7482}74837484return E_OK;7485}748674877488t_Error FM_PCD_HashTableGetMissNextEngine(7489t_Handle h_HashTbl,7490t_FmPcdCcNextEngineParams *p_FmPcdCcNextEngineParams)7491{7492t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;7493t_FmPcdCcNode *p_HashBucket;74947495SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);74967497/* Miss next engine of each bucket was initialized with the next engine of the hash table */7498p_HashBucket =7499p_HashTbl->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode;75007501memcpy(p_FmPcdCcNextEngineParams,7502&p_HashBucket->keyAndNextEngineParams[p_HashBucket->numOfKeys].nextEngineParams,7503sizeof(t_FmPcdCcNextEngineParams));75047505return E_OK;7506}75077508t_Error FM_PCD_HashTableFindNGetKeyStatistics(7509t_Handle h_HashTbl, uint8_t keySize, uint8_t *p_Key,7510t_FmPcdCcKeyStatistics *p_KeyStatistics)7511{7512t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;7513t_Handle h_HashBucket;7514uint8_t bucketIndex;7515uint16_t lastIndex;7516t_Error err;75177518SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);7519SANITY_CHECK_RETURN_ERROR(p_Key, E_NULL_POINTER);7520SANITY_CHECK_RETURN_ERROR(p_KeyStatistics, E_NULL_POINTER);75217522err = FM_PCD_MatchTableGetIndexedHashBucket(p_HashTbl, keySize, p_Key,7523p_HashTbl->kgHashShift,7524&h_HashBucket, &bucketIndex,7525&lastIndex);7526if (err)7527RETURN_ERROR(MAJOR, err, NO_MSG);75287529return FM_PCD_MatchTableFindNGetKeyStatistics(h_HashBucket, keySize, p_Key,7530NULL, p_KeyStatistics);7531}75327533t_Error FM_PCD_HashTableGetMissStatistics(7534t_Handle h_HashTbl, t_FmPcdCcKeyStatistics *p_MissStatistics)7535{7536t_FmPcdCcNode *p_HashTbl = (t_FmPcdCcNode *)h_HashTbl;7537t_Handle h_HashBucket;75387539SANITY_CHECK_RETURN_ERROR(p_HashTbl, E_INVALID_HANDLE);7540SANITY_CHECK_RETURN_ERROR(p_MissStatistics, E_NULL_POINTER);75417542if (!p_HashTbl->statsEnForMiss)7543RETURN_ERROR(MAJOR, E_INVALID_STATE,7544("Statistics were not enabled for miss"));75457546h_HashBucket =7547p_HashTbl->keyAndNextEngineParams[0].nextEngineParams.params.ccParams.h_CcNode;75487549return FM_PCD_MatchTableGetMissStatistics(h_HashBucket, p_MissStatistics);7550}755175527553