Path: blob/main/sys/contrib/ncsw/Peripherals/FM/MACSEC/fm_macsec.h
48417 views
/*1* Copyright 2008-2015 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*/3132/******************************************************************************33@File fm_macsec.h3435@Description FM MACSEC internal structures and definitions.36*//***************************************************************************/37#ifndef __FM_MACSEC_H38#define __FM_MACSEC_H3940#include "error_ext.h"41#include "std_ext.h"42#include "fm_macsec_ext.h"4344#include "fm_common.h"454647#define __ERR_MODULE__ MODULE_FM_MACSEC484950typedef struct51{52t_Error (*f_FM_MACSEC_Init) (t_Handle h_FmMacsec);53t_Error (*f_FM_MACSEC_Free) (t_Handle h_FmMacsec);5455t_Error (*f_FM_MACSEC_ConfigUnknownSciFrameTreatment) (t_Handle h_FmMacsec, e_FmMacsecUnknownSciFrameTreatment treatMode);56t_Error (*f_FM_MACSEC_ConfigInvalidTagsFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);57t_Error (*f_FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment) (t_Handle h_FmMacsec, bool discardUncontrolled);58t_Error (*f_FM_MACSEC_ConfigChangedTextWithNoEncryptFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);59t_Error (*f_FM_MACSEC_ConfigUntagFrameTreatment) (t_Handle h_FmMacsec, e_FmMacsecUntagFrameTreatment treatMode);60t_Error (*f_FM_MACSEC_ConfigOnlyScbIsSetFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);61t_Error (*f_FM_MACSEC_ConfigPnExhaustionThreshold) (t_Handle h_FmMacsec, uint32_t pnExhThr);62t_Error (*f_FM_MACSEC_ConfigKeysUnreadable) (t_Handle h_FmMacsec);63t_Error (*f_FM_MACSEC_ConfigSectagWithoutSCI) (t_Handle h_FmMacsec);64t_Error (*f_FM_MACSEC_ConfigException) (t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);6566t_Error (*f_FM_MACSEC_GetRevision) (t_Handle h_FmMacsec, uint32_t *p_MacsecRevision);67t_Error (*f_FM_MACSEC_Enable) (t_Handle h_FmMacsec);68t_Error (*f_FM_MACSEC_Disable) (t_Handle h_FmMacsec);69t_Error (*f_FM_MACSEC_SetException) (t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);7071} t_FmMacsecControllerDriver;7273t_Handle FM_MACSEC_GUEST_Config(t_FmMacsecParams *p_FmMacsecParam);74t_Handle FM_MACSEC_MASTER_Config(t_FmMacsecParams *p_FmMacsecParams);7576/***********************************************************************/77/* MACSEC internal routines */78/***********************************************************************/7980/**************************************************************************//**8182@Group FM_MACSEC_InterModule_grp FM MACSEC Inter-Module Unit8384@Description FM MACSEC Inter Module functions -85These are not User API routines but routines that may be called86from other modules. This will be the case in a single core environment,87where instead of using the XX messaging mechanism, the routines may be88called from other modules. In a multicore environment, the other modules may89be run by other cores and therefore these routines may not be called directly.9091@{92*//***************************************************************************/9394#define MAX_NUM_OF_SA_PER_SC 49596typedef enum97{98e_SC_RX = 0,99e_SC_TX100} e_ScType;101102typedef enum103{104e_SC_SA_A = 0,105e_SC_SA_B ,106e_SC_SA_C ,107e_SC_SA_D108} e_ScSaId;109110typedef struct111{112uint32_t scId;113macsecSCI_t sci;114bool replayProtect;115uint32_t replayWindow;116e_FmMacsecValidFrameBehavior validateFrames;117uint16_t confidentialityOffset;118e_FmMacsecSecYCipherSuite cipherSuite;119} t_RxScParams;120121typedef struct122{123uint32_t scId;124macsecSCI_t sci;125bool protectFrames;126e_FmMacsecSciInsertionMode sciInsertionMode;127bool confidentialityEnable;128uint16_t confidentialityOffset;129e_FmMacsecSecYCipherSuite cipherSuite;130} t_TxScParams;131132typedef enum e_FmMacsecGlobalExceptions {133e_FM_MACSEC_EX_TX_SC, /**< Tx Sc 0 frame discarded error. */134e_FM_MACSEC_EX_ECC /**< MACSEC memory ECC multiple-bit error. */135} e_FmMacsecGlobalExceptions;136137typedef enum e_FmMacsecGlobalEvents {138e_FM_MACSEC_EV_TX_SC_NEXT_PN /**< Tx Sc 0 Next Pn exhaustion threshold reached. */139} e_FmMacsecGlobalEvents;140141/**************************************************************************//**142@Description Enum for inter-module interrupts registration143*//***************************************************************************/144typedef enum e_FmMacsecEventModules{145e_FM_MACSEC_MOD_SC_TX,146e_FM_MACSEC_MOD_DUMMY_LAST147} e_FmMacsecEventModules;148149typedef enum e_FmMacsecInterModuleEvent {150e_FM_MACSEC_EV_SC_TX,151e_FM_MACSEC_EV_ERR_SC_TX,152e_FM_MACSEC_EV_DUMMY_LAST153} e_FmMacsecInterModuleEvent;154155#define NUM_OF_INTER_MODULE_EVENTS (NUM_OF_TX_SC * 2)156157#define GET_MACSEC_MODULE_EVENT(mod, id, intrType, event) \158switch(mod){ \159case e_FM_MACSEC_MOD_SC_TX: \160event = (intrType == e_FM_INTR_TYPE_ERR) ? \161e_FM_MACSEC_EV_ERR_SC_TX: \162e_FM_MACSEC_EV_SC_TX; \163event += (uint8_t)(2 * id);break; \164break; \165default:event = e_FM_MACSEC_EV_DUMMY_LAST; \166break;}167168void FmMacsecRegisterIntr(t_Handle h_FmMacsec,169e_FmMacsecEventModules module,170uint8_t modId,171e_FmIntrType intrType,172void (*f_Isr) (t_Handle h_Arg, uint32_t id),173t_Handle h_Arg);174175void FmMacsecUnregisterIntr(t_Handle h_FmMacsec,176e_FmMacsecEventModules module,177uint8_t modId,178e_FmIntrType intrType);179180t_Error FmMacsecAllocScs(t_Handle h_FmMacsec, e_ScType type, bool isPtp, uint32_t numOfScs, uint32_t *p_ScIds);181t_Error FmMacsecFreeScs(t_Handle h_FmMacsec, e_ScType type, uint32_t numOfScs, uint32_t *p_ScIds);182t_Error FmMacsecCreateRxSc(t_Handle h_FmMacsec, t_RxScParams *p_RxScParams);183t_Error FmMacsecDeleteRxSc(t_Handle h_FmMacsec, uint32_t scId);184t_Error FmMacsecCreateTxSc(t_Handle h_FmMacsec, t_TxScParams *p_RxScParams);185t_Error FmMacsecDeleteTxSc(t_Handle h_FmMacsec, uint32_t scId);186t_Error FmMacsecCreateRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an, uint32_t lowestPn, macsecSAKey_t key);187t_Error FmMacsecCreateTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecSAKey_t key);188t_Error FmMacsecDeleteRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId);189t_Error FmMacsecDeleteTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId);190t_Error FmMacsecRxSaSetReceive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, bool enableReceive);191t_Error FmMacsecRxSaUpdateNextPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtNextPN);192t_Error FmMacsecRxSaUpdateLowestPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtLowestPN);193t_Error FmMacsecTxSaSetActive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an);194t_Error FmMacsecTxSaGetActive(t_Handle h_FmMacsec, uint32_t scId, macsecAN_t *p_An);195t_Error FmMacsecSetPTP(t_Handle h_FmMacsec, bool enable);196197t_Error FmMacsecSetException(t_Handle h_FmMacsec, e_FmMacsecGlobalExceptions exception, uint32_t scId, bool enable);198t_Error FmMacsecSetEvent(t_Handle h_FmMacsec, e_FmMacsecGlobalEvents event, uint32_t scId, bool enable);199200201202#endif /* __FM_MACSEC_H */203204205