1 /* 2 * Copyright 2008-2015 Freescale Semiconductor Inc. 3 * 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. 14 * 15 * 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 19 * later version. 20 * 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. 31 */ 32 33 /****************************************************************************** 34 @File fm_macsec.h 35 36 @Description FM MACSEC internal structures and definitions. 37 *//***************************************************************************/ 38 #ifndef __FM_MACSEC_H 39 #define __FM_MACSEC_H 40 41 #include "error_ext.h" 42 #include "std_ext.h" 43 #include "fm_macsec_ext.h" 44 45 #include "fm_common.h" 46 47 48 #define __ERR_MODULE__ MODULE_FM_MACSEC 49 50 51 typedef struct 52 { 53 t_Error (*f_FM_MACSEC_Init) (t_Handle h_FmMacsec); 54 t_Error (*f_FM_MACSEC_Free) (t_Handle h_FmMacsec); 55 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); 66 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); 71 72 } t_FmMacsecControllerDriver; 73 74 t_Handle FM_MACSEC_GUEST_Config(t_FmMacsecParams *p_FmMacsecParam); 75 t_Handle FM_MACSEC_MASTER_Config(t_FmMacsecParams *p_FmMacsecParams); 76 77 /***********************************************************************/ 78 /* MACSEC internal routines */ 79 /***********************************************************************/ 80 81 /**************************************************************************//** 82 83 @Group FM_MACSEC_InterModule_grp FM MACSEC Inter-Module Unit 84 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. 91 92 @{ 93 *//***************************************************************************/ 94 95 #define MAX_NUM_OF_SA_PER_SC 4 96 97 typedef enum 98 { 99 e_SC_RX = 0, 100 e_SC_TX 101 } e_ScType; 102 103 typedef enum 104 { 105 e_SC_SA_A = 0, 106 e_SC_SA_B , 107 e_SC_SA_C , 108 e_SC_SA_D 109 } e_ScSaId; 110 111 typedef struct 112 { 113 uint32_t scId; 114 macsecSCI_t sci; 115 bool replayProtect; 116 uint32_t replayWindow; 117 e_FmMacsecValidFrameBehavior validateFrames; 118 uint16_t confidentialityOffset; 119 e_FmMacsecSecYCipherSuite cipherSuite; 120 } t_RxScParams; 121 122 typedef struct 123 { 124 uint32_t scId; 125 macsecSCI_t sci; 126 bool protectFrames; 127 e_FmMacsecSciInsertionMode sciInsertionMode; 128 bool confidentialityEnable; 129 uint16_t confidentialityOffset; 130 e_FmMacsecSecYCipherSuite cipherSuite; 131 } t_TxScParams; 132 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; 137 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; 141 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; 149 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; 155 156 #define NUM_OF_INTER_MODULE_EVENTS (NUM_OF_TX_SC * 2) 157 158 #define GET_MACSEC_MODULE_EVENT(mod, id, intrType, event) \ 159 switch(mod){ \ 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; \ 165 break; \ 166 default:event = e_FM_MACSEC_EV_DUMMY_LAST; \ 167 break;} 168 169 void FmMacsecRegisterIntr(t_Handle h_FmMacsec, 170 e_FmMacsecEventModules module, 171 uint8_t modId, 172 e_FmIntrType intrType, 173 void (*f_Isr) (t_Handle h_Arg, uint32_t id), 174 t_Handle h_Arg); 175 176 void FmMacsecUnregisterIntr(t_Handle h_FmMacsec, 177 e_FmMacsecEventModules module, 178 uint8_t modId, 179 e_FmIntrType intrType); 180 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); 197 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); 200 201 202 203 #endif /* __FM_MACSEC_H */ 204