2 * Copyright 2008-2015 Freescale Semiconductor Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of Freescale Semiconductor nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
16 * ALTERNATIVELY, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL") as published by the Free Software
18 * Foundation, either version 2 of that License or (at your option) any
21 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 /******************************************************************************
36 @Description FM MACSEC internal structures and definitions.
37 *//***************************************************************************/
41 #include "error_ext.h"
43 #include "fm_macsec_ext.h"
45 #include "fm_common.h"
48 #define __ERR_MODULE__ MODULE_FM_MACSEC
53 t_Error (*f_FM_MACSEC_Init) (t_Handle h_FmMacsec);
54 t_Error (*f_FM_MACSEC_Free) (t_Handle h_FmMacsec);
56 t_Error (*f_FM_MACSEC_ConfigUnknownSciFrameTreatment) (t_Handle h_FmMacsec, e_FmMacsecUnknownSciFrameTreatment treatMode);
57 t_Error (*f_FM_MACSEC_ConfigInvalidTagsFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);
58 t_Error (*f_FM_MACSEC_ConfigEncryptWithNoChangedTextFrameTreatment) (t_Handle h_FmMacsec, bool discardUncontrolled);
59 t_Error (*f_FM_MACSEC_ConfigChangedTextWithNoEncryptFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);
60 t_Error (*f_FM_MACSEC_ConfigUntagFrameTreatment) (t_Handle h_FmMacsec, e_FmMacsecUntagFrameTreatment treatMode);
61 t_Error (*f_FM_MACSEC_ConfigOnlyScbIsSetFrameTreatment) (t_Handle h_FmMacsec, bool deliverUncontrolled);
62 t_Error (*f_FM_MACSEC_ConfigPnExhaustionThreshold) (t_Handle h_FmMacsec, uint32_t pnExhThr);
63 t_Error (*f_FM_MACSEC_ConfigKeysUnreadable) (t_Handle h_FmMacsec);
64 t_Error (*f_FM_MACSEC_ConfigSectagWithoutSCI) (t_Handle h_FmMacsec);
65 t_Error (*f_FM_MACSEC_ConfigException) (t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);
67 t_Error (*f_FM_MACSEC_GetRevision) (t_Handle h_FmMacsec, uint32_t *p_MacsecRevision);
68 t_Error (*f_FM_MACSEC_Enable) (t_Handle h_FmMacsec);
69 t_Error (*f_FM_MACSEC_Disable) (t_Handle h_FmMacsec);
70 t_Error (*f_FM_MACSEC_SetException) (t_Handle h_FmMacsec, e_FmMacsecExceptions exception, bool enable);
72 } t_FmMacsecControllerDriver;
74 t_Handle FM_MACSEC_GUEST_Config(t_FmMacsecParams *p_FmMacsecParam);
75 t_Handle FM_MACSEC_MASTER_Config(t_FmMacsecParams *p_FmMacsecParams);
77 /***********************************************************************/
78 /* MACSEC internal routines */
79 /***********************************************************************/
81 /**************************************************************************//**
83 @Group FM_MACSEC_InterModule_grp FM MACSEC Inter-Module Unit
85 @Description FM MACSEC Inter Module functions -
86 These are not User API routines but routines that may be called
87 from other modules. This will be the case in a single core environment,
88 where instead of using the XX messaging mechanism, the routines may be
89 called from other modules. In a multicore environment, the other modules may
90 be run by other cores and therefore these routines may not be called directly.
93 *//***************************************************************************/
95 #define MAX_NUM_OF_SA_PER_SC 4
116 uint32_t replayWindow;
117 e_FmMacsecValidFrameBehavior validateFrames;
118 uint16_t confidentialityOffset;
119 e_FmMacsecSecYCipherSuite cipherSuite;
127 e_FmMacsecSciInsertionMode sciInsertionMode;
128 bool confidentialityEnable;
129 uint16_t confidentialityOffset;
130 e_FmMacsecSecYCipherSuite cipherSuite;
133 typedef enum e_FmMacsecGlobalExceptions {
134 e_FM_MACSEC_EX_TX_SC, /**< Tx Sc 0 frame discarded error. */
135 e_FM_MACSEC_EX_ECC /**< MACSEC memory ECC multiple-bit error. */
136 } e_FmMacsecGlobalExceptions;
138 typedef enum e_FmMacsecGlobalEvents {
139 e_FM_MACSEC_EV_TX_SC_NEXT_PN /**< Tx Sc 0 Next Pn exhaustion threshold reached. */
140 } e_FmMacsecGlobalEvents;
142 /**************************************************************************//**
143 @Description Enum for inter-module interrupts registration
144 *//***************************************************************************/
145 typedef enum e_FmMacsecEventModules{
146 e_FM_MACSEC_MOD_SC_TX,
147 e_FM_MACSEC_MOD_DUMMY_LAST
148 } e_FmMacsecEventModules;
150 typedef enum e_FmMacsecInterModuleEvent {
151 e_FM_MACSEC_EV_SC_TX,
152 e_FM_MACSEC_EV_ERR_SC_TX,
153 e_FM_MACSEC_EV_DUMMY_LAST
154 } e_FmMacsecInterModuleEvent;
156 #define NUM_OF_INTER_MODULE_EVENTS (NUM_OF_TX_SC * 2)
158 #define GET_MACSEC_MODULE_EVENT(mod, id, intrType, event) \
160 case e_FM_MACSEC_MOD_SC_TX: \
161 event = (intrType == e_FM_INTR_TYPE_ERR) ? \
162 e_FM_MACSEC_EV_ERR_SC_TX: \
163 e_FM_MACSEC_EV_SC_TX; \
164 event += (uint8_t)(2 * id);break; \
166 default:event = e_FM_MACSEC_EV_DUMMY_LAST; \
169 void FmMacsecRegisterIntr(t_Handle h_FmMacsec,
170 e_FmMacsecEventModules module,
172 e_FmIntrType intrType,
173 void (*f_Isr) (t_Handle h_Arg, uint32_t id),
176 void FmMacsecUnregisterIntr(t_Handle h_FmMacsec,
177 e_FmMacsecEventModules module,
179 e_FmIntrType intrType);
181 t_Error FmMacsecAllocScs(t_Handle h_FmMacsec, e_ScType type, bool isPtp, uint32_t numOfScs, uint32_t *p_ScIds);
182 t_Error FmMacsecFreeScs(t_Handle h_FmMacsec, e_ScType type, uint32_t numOfScs, uint32_t *p_ScIds);
183 t_Error FmMacsecCreateRxSc(t_Handle h_FmMacsec, t_RxScParams *p_RxScParams);
184 t_Error FmMacsecDeleteRxSc(t_Handle h_FmMacsec, uint32_t scId);
185 t_Error FmMacsecCreateTxSc(t_Handle h_FmMacsec, t_TxScParams *p_RxScParams);
186 t_Error FmMacsecDeleteTxSc(t_Handle h_FmMacsec, uint32_t scId);
187 t_Error FmMacsecCreateRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an, uint32_t lowestPn, macsecSAKey_t key);
188 t_Error FmMacsecCreateTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecSAKey_t key);
189 t_Error FmMacsecDeleteRxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId);
190 t_Error FmMacsecDeleteTxSa(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId);
191 t_Error FmMacsecRxSaSetReceive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, bool enableReceive);
192 t_Error FmMacsecRxSaUpdateNextPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtNextPN);
193 t_Error FmMacsecRxSaUpdateLowestPn(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, uint32_t updtLowestPN);
194 t_Error FmMacsecTxSaSetActive(t_Handle h_FmMacsec, uint32_t scId, e_ScSaId saId, macsecAN_t an);
195 t_Error FmMacsecTxSaGetActive(t_Handle h_FmMacsec, uint32_t scId, macsecAN_t *p_An);
196 t_Error FmMacsecSetPTP(t_Handle h_FmMacsec, bool enable);
198 t_Error FmMacsecSetException(t_Handle h_FmMacsec, e_FmMacsecGlobalExceptions exception, uint32_t scId, bool enable);
199 t_Error FmMacsecSetEvent(t_Handle h_FmMacsec, e_FmMacsecGlobalEvents event, uint32_t scId, bool enable);
203 #endif /* __FM_MACSEC_H */