1 /*
2 * Copyright 2021-2023 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 /**
8 * @file Netc_EthSwt_Ip.c
9 * @internal
10 * @addtogroup NETC_ETHSWT_IP NETC_ETHSWT Driver
11 * @{
12 */
13
14 #ifdef __cplusplus
15 extern "C"{
16 #endif
17
18 /*==================================================================================================
19 * INCLUDE FILES
20 * 1) system and project includes
21 * 2) needed interfaces from external units
22 * 3) internal and external interfaces from this unit
23 ==================================================================================================*/
24 #include "Netc_EthSwt_Ip.h"
25 #include "SchM_EthSwt_43_NETC.h"
26 #include "Netc_EthSwt_Ip_Types.h"
27 #include "Netc_EthSwt_Ip_Cfg_Defines.h"
28 #include "OsIf.h" /* Used for timeouts. */
29
30 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
31 #include "Devassert.h"
32 #endif
33
34 /*==================================================================================================
35 * SOURCE FILE VERSION INFORMATION
36 ==================================================================================================*/
37 #define NETC_ETHSWT_IP_VENDOR_ID_C 43
38 #define NETC_ETHSWT_IP_AR_RELEASE_MAJOR_VERSION_C 4
39 #define NETC_ETHSWT_IP_AR_RELEASE_MINOR_VERSION_C 7
40 #define NETC_ETHSWT_IP_AR_RELEASE_REVISION_VERSION_C 0
41 #define NETC_ETHSWT_IP_SW_MAJOR_VERSION_C 1
42 #define NETC_ETHSWT_IP_SW_MINOR_VERSION_C 0
43 #define NETC_ETHSWT_IP_SW_PATCH_VERSION_C 0
44
45 /*==================================================================================================
46 * FILE VERSION CHECKS
47 ==================================================================================================*/
48 /* Checks against Netc_EthSwt_Ip.h */
49 #if (NETC_ETHSWT_IP_VENDOR_ID_C != NETC_ETHSWT_IP_VENDOR_ID)
50 #error "Netc_EthSwt_Ip.c and Netc_EthSwt_Ip.h have different vendor ids"
51 #endif
52 #if (( NETC_ETHSWT_IP_AR_RELEASE_MAJOR_VERSION_C != NETC_ETHSWT_IP_AR_RELEASE_MAJOR_VERSION) || \
53 ( NETC_ETHSWT_IP_AR_RELEASE_MINOR_VERSION_C != NETC_ETHSWT_IP_AR_RELEASE_MINOR_VERSION) || \
54 ( NETC_ETHSWT_IP_AR_RELEASE_REVISION_VERSION_C != NETC_ETHSWT_IP_AR_RELEASE_REVISION_VERSION))
55 #error "AUTOSAR Version Numbers of Netc_EthSwt_Ip.c and Netc_EthSwt_Ip.h are different"
56 #endif
57 #if (( NETC_ETHSWT_IP_SW_MAJOR_VERSION_C != NETC_ETHSWT_IP_SW_MAJOR_VERSION) || \
58 ( NETC_ETHSWT_IP_SW_MINOR_VERSION_C != NETC_ETHSWT_IP_SW_MINOR_VERSION) || \
59 ( NETC_ETHSWT_IP_SW_PATCH_VERSION_C != NETC_ETHSWT_IP_SW_PATCH_VERSION))
60 #error "Software Version Numbers of Netc_EthSwt_Ip.c and Netc_EthSwt_Ip.h are different"
61 #endif
62
63 /* Checks against Netc_EthSwt_Ip_Types.h */
64 #if (NETC_ETHSWT_IP_VENDOR_ID_C != NETC_ETHSWT_IP_TYPES_VENDOR_ID)
65 #error "Netc_EthSwt_Ip.c and Netc_EthSwt_Ip_Types.h have different vendor ids"
66 #endif
67 #if (( NETC_ETHSWT_IP_AR_RELEASE_MAJOR_VERSION_C != NETC_ETHSWT_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
68 ( NETC_ETHSWT_IP_AR_RELEASE_MINOR_VERSION_C != NETC_ETHSWT_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
69 ( NETC_ETHSWT_IP_AR_RELEASE_REVISION_VERSION_C != NETC_ETHSWT_IP_TYPES_AR_RELEASE_REVISION_VERSION))
70 #error "AUTOSAR Version Numbers of Netc_EthSwt_Ip.c and Netc_EthSwt_Ip_Types.h are different"
71 #endif
72 #if (( NETC_ETHSWT_IP_SW_MAJOR_VERSION_C != NETC_ETHSWT_IP_TYPES_SW_MAJOR_VERSION) || \
73 ( NETC_ETHSWT_IP_SW_MINOR_VERSION_C != NETC_ETHSWT_IP_TYPES_SW_MINOR_VERSION) || \
74 ( NETC_ETHSWT_IP_SW_PATCH_VERSION_C != NETC_ETHSWT_IP_TYPES_SW_PATCH_VERSION))
75 #error "Software Version Numbers of Netc_EthSwt_Ip.c and Netc_EthSwt_Ip_Types.h are different"
76 #endif
77
78 /* Checks against Netc_EthSwt_Ip_Cfg_Defines.h */
79 #if (NETC_ETHSWT_IP_VENDOR_ID_C != NETC_ETHSWT_IP_CFG_DEFINES_VENDOR_ID)
80 #error "Netc_EthSwt_Ip.c and Netc_EthSwt_Ip_Cfg_Defines.h have different vendor ids"
81 #endif
82 #if (( NETC_ETHSWT_IP_AR_RELEASE_MAJOR_VERSION_C != NETC_ETHSWT_IP_CFG_DEFINES_AR_RELEASE_MAJOR_VERSION) || \
83 ( NETC_ETHSWT_IP_AR_RELEASE_MINOR_VERSION_C != NETC_ETHSWT_IP_CFG_DEFINES_AR_RELEASE_MINOR_VERSION) || \
84 ( NETC_ETHSWT_IP_AR_RELEASE_REVISION_VERSION_C != NETC_ETHSWT_IP_CFG_DEFINES_AR_RELEASE_REVISION_VERSION))
85 #error "AUTOSAR Version Numbers of Netc_EthSwt_Ip.c and Netc_EthSwt_Ip_Cfg_Defines.h are different"
86 #endif
87 #if (( NETC_ETHSWT_IP_SW_MAJOR_VERSION_C != NETC_ETHSWT_IP_CFG_DEFINES_SW_MAJOR_VERSION) || \
88 ( NETC_ETHSWT_IP_SW_MINOR_VERSION_C != NETC_ETHSWT_IP_CFG_DEFINES_SW_MINOR_VERSION) || \
89 ( NETC_ETHSWT_IP_SW_PATCH_VERSION_C != NETC_ETHSWT_IP_CFG_DEFINES_SW_PATCH_VERSION))
90 #error "Software Version Numbers of Netc_EthSwt_Ip.c and Netc_EthSwt_Ip_Cfg_Defines.h are different"
91 #endif
92 /*==================================================================================================
93 * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
94 ==================================================================================================*/
95
96 /*==================================================================================================
97 * LOCAL MACROS
98 ==================================================================================================*/
99 #define SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_MII_MODE (1U)
100 #define SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RMII_MODE (3U)
101 #define SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RGMII_MODE (4U)
102 #define SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_SGMII_MODE (5U)
103 #define SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT (0U)
104 #define SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT (1U)
105 #define SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT (2U)
106 #define SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_2500MBIT (3U)
107
108 /*==================================================================================================
109 * LOCAL CONSTANTS
110 ==================================================================================================*/
111 #define NETC_ETHSWT_IP_FIELD_REP_IN_4BITS (4U)
112 #define NETC_ETHSWT_IP_FIELD_REP_IN_TOP_OF_32BITS (16U)
113
114 #define NETC_ETHSWT_IP_RXTAGA_ACCEPT_UNTAGGED (1U)
115 #define NETC_ETHSWT_IP_RXTAGA_ACCEPT_PRIO_TAGGED (2U)
116 #define NETC_ETHSWT_IP_RXTAGA_ACCEPT_SINGLE_TAGGED (4U)
117 #define NETC_ETHSWT_IP_RXTAGA_ACCEPT_DOUBLE_TAGGED (8U)
118
119 /* Formula for speed: 10Mbps * (PSPEED+1) */
120 #define NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS (0U)
121 #define NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS (9U)
122 #define NETC_ETHSWT_IP_SHAPING_PSPEED_1000MBITS (99U)
123 #define NETC_ETHSWT_IP_SHAPING_PSPEED_2000MBITS (199U)
124 #define NETC_ETHSWT_IP_SHAPING_PSPEED_2500MBITS (249U)
125
126 #define NETC_ETHSWT_IP_NUM_SHAPING_CLASS (8U)
127
128 #define NETC_ETHSWT_IP_NUM_AGING_CYCLE (127U)
129 #define NETC_ETHSWT_IP_NUM_AGING_CYCLE_FLOAT (127.0F)
130
131 #define NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID (0xFFFFU)
132
133 #define NETC_ETHSWT_IP_ONE_FLOAT (1.0F)
134
135 #define MAX_32BIT ((uint32)0xFFFFFFFFUL)
136
137 /*==================================================================================================
138 * LOCAL VARIABLES
139 ==================================================================================================*/
140
141
142 /*==================================================================================================
143 * GLOBAL CONSTANTS
144 ==================================================================================================*/
145
146 /*==================================================================================================
147 * GLOBAL VARIABLES
148 ==================================================================================================*/
149 #define ETHSWT_43_NETC_START_SEC_VAR_INIT_BOOLEAN
150 #include "EthSwt_43_NETC_MemMap.h"
151
152 /* Flag to determine if mirroring is active or not */
153 static boolean MirrorConfigurationDone = FALSE;
154
155 #define ETHSWT_43_NETC_STOP_SEC_VAR_INIT_BOOLEAN
156 #include "EthSwt_43_NETC_MemMap.h"
157
158 #define ETHSWT_43_NETC_START_SEC_VAR_CLEARED_BOOLEAN
159 #include "EthSwt_43_NETC_MemMap.h"
160
161 /* Enabled status for Time Aware Shaper of each port */
162 static boolean PortTimeAwareShaperEnabled[NETC_ETHSWT_NUMBER_OF_PORTS];
163
164 #define ETHSWT_43_NETC_STOP_SEC_VAR_CLEARED_BOOLEAN
165 #include "EthSwt_43_NETC_MemMap.h"
166
167 #define ETHSWT_43_NETC_START_SEC_VAR_INIT_UNSPECIFIED
168 #include "EthSwt_43_NETC_MemMap.h"
169
170 /* Base address of the registers for the MAC Ports */
171 Netc_EthSwt_Ip_PortBaseType* Netc_EthSwt_Ip_PortBaseTable[] = { (Netc_EthSwt_Ip_PortBaseType*)IP_NETC__SW0_ETH_MAC_PORT0_BASE, (Netc_EthSwt_Ip_PortBaseType*)IP_NETC__SW0_ETH_MAC_PORT1_BASE };
172
173 /* Base address of the registers for the pseudo Port */
174 Netc_EthSwt_Ip_PseudoPortBaseType* Netc_EthSwt_Ip_PseudoPortBaseTable[] = { IP_NETC__SW0_PSEUDO_MAC_PORT2 };
175 SW_PORT0_Type *Netc_EthSwt_Ip_SW0_PortxBaseAddr[NETC_ETHSWT_NUMBER_OF_PORTS] = {(SW_PORT0_Type*)IP_NETC__SW0_PORT0_BASE, (SW_PORT0_Type*)IP_NETC__SW0_PORT1_BASE, (SW_PORT0_Type*)IP_NETC__SW0_PORT2_BASE};
176 #define ETHSWT_43_NETC_STOP_SEC_VAR_INIT_UNSPECIFIED
177 #include "EthSwt_43_NETC_MemMap.h"
178
179 #define ETHSWT_43_NETC_START_SEC_VAR_CLEARED_UNSPECIFIED
180 #include "EthSwt_43_NETC_MemMap.h"
181
182 /* Table entries for Time Aware Shaping configuration of each Port */
183 static Netc_EthSwt_Ip_TimeGateSchedulingEntryDataType TimeGateSchedulingEntryData[NETC_ETHSWT_NUMBER_OF_PORTS];
184
185 #define ETHSWT_43_NETC_STOP_SEC_VAR_CLEARED_UNSPECIFIED
186 #include "EthSwt_43_NETC_MemMap.h"
187
188 #define ETHSWT_43_NETC_START_SEC_VAR_INIT_32
189 #include "EthSwt_43_NETC_MemMap.h"
190
191 /* reference clock for 1588 timer. 0x0UL means the 1588 timer is not enabled. */
192 static uint32 TimerOriginalRefClk = 0x0UL;
193 /* reference clcok for clock correction and set ratio */
194 static uint32 TimerRefClk = 0x0UL;
195
196 /* Ingress Port Filter Entry ID for mirroing */
197 uint32 MirroringIngressPortFilterEntryId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
198
199 /* Steps used to skip cycles that will not incress the FDB aging counters. */
200 static uint32 Netc_EthSwt_Ip_MainFunctionCycle[FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS] = {0UL};
201
202 #define ETHSWT_43_NETC_STOP_SEC_VAR_INIT_32
203 #include "EthSwt_43_NETC_MemMap.h"
204
205 #define ETHSWT_43_NETC_START_SEC_VAR_CLEARED_32
206 #include "EthSwt_43_NETC_MemMap.h"
207
208 /* The frequency of the NETC module for computing CBS parameters */
209 static uint32 Netc_EthSwt_Ip_NetcClockFrequency;
210
211 #define ETHSWT_43_NETC_STOP_SEC_VAR_CLEARED_32
212 #include "EthSwt_43_NETC_MemMap.h"
213
214 #define ETHSWT_43_NETC_START_SEC_VAR_CLEARED_16
215 #include "EthSwt_43_NETC_MemMap.h"
216
217 /* The timeout set for FDB aging */
218 static uint16 Netc_EthSwt_Ip_FdbTableEntryTimeout[FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS];
219
220 #define ETHSWT_43_NETC_STOP_SEC_VAR_CLEARED_16
221 #include "EthSwt_43_NETC_MemMap.h"
222
223 #define ETHSWT_43_NETC_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
224 #include "EthSwt_43_NETC_MemMap.h"
225
226 /* A shadow buffer for the mirroring configuration to be used when the application is reading the active configuration */
227 VAR_SEC_NOCACHE(MirrorCfgBackup) static Netc_EthSwt_Ip_SwitchMirrorCfgType MirrorCfgBackup;
228
229 /* Structure used for filling in the actual command buffer descriptor used in table operations */
230 VAR_SEC_NOCACHE(CmdBDRConfig) static volatile Netc_EthSwt_Ip_CmdBDType CmdBDRConfig[NETC_ETHSWT_IP_CBDR_NUM];
231
232 /* Key element data for ingress port filter table */
233 VAR_SEC_NOCACHE(Netc_EthSwt_Ip_IPFKeyeData) static volatile uint32 Netc_EthSwt_Ip_IPFKeyeData[NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_KEYE_DATA_LEN];
234
235 /* a 128 bytes aligned command ring descriptor buffer */
236 VAR_SEC_NOCACHE(SwtcommandRingDescriptor0) VAR_ALIGN(static Netc_EthSwt_Ip_NTMPMessageHeaderFormatType SwtcommandRingDescriptor0[NETC_ETHSWT_IP_ACTUAL_CBDR0_LENGTH], NETC_ETHSWT_IP_CBD_ALIGNED_SIZE)
237
238 /* a 16 bytes aligned FDB table request data buffer */
239 VAR_SEC_NOCACHE(TableDataBuffer) VAR_ALIGN(static volatile Netc_EthSwt_Ip_SwitchTableDataType TableDataBuffer, NETC_ETHSWT_IP_TABLE_ALIGNED_SIZE)
240
241 #define ETHSWT_43_NETC_STOP_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
242 #include "EthSwt_43_NETC_MemMap.h"
243
244
245 /*==================================================================================================
246 * LOCAL FUNCTION PROTOTYPES
247 ==================================================================================================*/
248 #define ETHSWT_43_NETC_START_SEC_CODE
249 #include "EthSwt_43_NETC_MemMap.h"
250
251 /*!
252 * @brief : Function for accessing 64 bits counters.
253 * @details : Function for extracting the counter value using base/offset
254 *
255 * @param[in] baseAddressValue base address in uint32
256 * @param[in] offsetAddressValue offset from the base
257 *
258 * @return Register value
259 */
260 static inline uint64 Netc_EthSwt_Ip_Extract64bitsFrom32bitsReg(const uint32 baseAddressValue, const uint32 offsetAddressValue);
261
262 /**
263 * @brief : Function for accessing counter in a table.
264 * @details : Function for getting the counters using an offset
265 *
266 * @param[in] base: Base address of the table.
267 * @param[in] offset: Offset the table.
268 *
269 * @return Result the counter value
270 */
271 static inline uint64 Netc_EthSwt_Ip_ComputedRegisterValueExtractionSingleCounter(const Netc_EthSwt_Ip_PortBaseType* base, const Netc_EthSwt_Ip_SingleCounterType offset);
272
273 /**
274 * @brief : Function for accessing counter in a table.
275 * @details : Function for getting the counters using an offset
276 *
277 * @param[in] base: Base address of the table.
278 * @param[in] offset: Offset the table.
279 *
280 * @return Result the counter value
281 */
282 static inline uint64 Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(const Netc_EthSwt_Ip_PseudoPortBaseType* base, const Netc_EthSwt_Ip_PseudoPortCounterType offset);
283
284 /**
285 * @brief : Function for accessing 64 bits counters in a table.
286 * @details : Function for getting the 64 bits counters using two 32 bits accesses.
287 *
288 * @param[in] reg: 64bits register pointer.
289 *
290 * @return Result the counter value
291 */
292 static inline uint64 Netc_EthSwt_Ip_GetCounterLocal(const volatile uint64 *Reg);
293
294 /**
295 * @brief Command BD Rings initialization function
296 * @details Initialize command ring for switch
297 *
298 * @param[in] cbdrIndex: Index of switch command BD rings. There are only two switch command BD rings.
299 *
300 * @return Result of the operation
301 * @retval 0 : NETC_ETHSWT_CBDRSTATUS_SUCCES, success
302 * @retval 1 : NETC_ETHSWT_CBDRSTATUS_INDEX_ERROR, fail
303 */
304 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_InitCommandBDR(uint8 SwitchIdx, uint8 cbdrIndex);
305
306 /**
307 * @brief Command request function
308 * @details Add one entry with different commands to command ring
309 *
310 * @param[in] cbdrIndex: Index of switch command BD rings
311 * OperationData: a pointer points to a structure with elements table id, access method, and cmd
312 *
313 * @return Result of the operation
314 * @retval 0 : NETC_ETHSWT_CBDRSTATUS_SUCCES, success
315 * @retval 2 : NETC_ETHSWT_CBDRSTATUS_RINGFULL, fail
316 */
317 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_SendCommand(uint8 SwitchIdx, uint8 cbdrIndex, const NetcEthSwt_Ip_ReqHeaderTableOperationDataType *OperationData);
318
319 /**
320 * @brief Get Matched table entries function
321 * @details Check how many table entry exist
322 *
323 * @param[in] cbdrIndex: Index of switch command BD rings
324 *
325 * @param[out] NumOfEntry: Number of matched entry found
326 *
327 * @return Result of the operation
328 * @retval 0 : NETC_ETHSWT_CBDRSTATUS_SUCCES, success
329 * @retval others: fail
330 */
331 static void Netc_EthSwt_Ip_GetMatchedEntries(uint8 cbdrIndex, uint32 *NumOfEntry);
332
333 /**
334 * @brief FDB table initialization function
335 * @details Fill in the FDB table request data buffer
336 *
337 * @param[in] ActionsData: The data of Action Field of FDB table request data buffer
338 * pAccessKey: A pointer points the data of Access Key field of FDB table request data buffer
339 * pCfgeData: A pointer points the data of Cfge field of FDB table request data buffer
340 * accessMethod: The value of ACCESS_METHOD. it determins the content of the Access Key field
341 *
342 * @return Result of the operation
343 * @retval 0 : NETC_ETHSWT_CBDRSTATUS_SUCCES, success
344 * @retval 6 : NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR, fail
345 */
346 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_FillInFdbTableReqDataBuff(uint32 ActionsData, const uint32 *pAccessKey, const Netc_EthSwt_Ip_FDBTableCFGEDataType *pCfgeData, Netc_EthSwt_Ip_AccessMethodType accessMethod);
347
348 /**
349 * @brief Vlan Filter table initialization function
350 * @details Fill in the Vlan Filter table request data buffer
351 *
352 * @param[in] ActionsData: The data of Action Field of Vlan Filter table request data buffer
353 * AccessKeyData: The data of Access Key field in Vlan Filter table request data buffer, it could be Entry_Id, VID, Resume_Entry_Id according to different Access Method.
354 * pCfgeData: A pointer points the data of Cfge field of Vlan Filter table request data buffer
355 * accessMethod: The value of ACCESS_METHOD. it determins the content of the Access Key field
356 *
357 * @return Result of the operation
358 * @retval 0 : NETC_ETHSWT_CBDRSTATUS_SUCCES, success
359 * @retval 6 : NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR, fail
360 */
361 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff(uint32 ActionsData, uint32 AccessKeyData, const Netc_EthSwt_Ip_VlanFilterTableCFGEDataType *pCfgeData, Netc_EthSwt_Ip_AccessMethodType accessMethod);
362
363 static Std_ReturnType Netc_EthSwt_Ip_MacPortConfig( uint8 SwitchIdx, uint8 SwitchPortIdx,
364 Netc_EthSwt_Ip_XmiiModeType EthSwtPortPhysicalLayerType,
365 EthTrcv_BaudRateType EthSwtPortMacLayerSpeed,
366 Netc_EthSwt_Ip_PortDuplexType EthSwtPortMacLayerDuplexMode
367 );
368 /**
369 * @brief Prepare to use a timeout.
370 *
371 * @param StartTimeOut Current value of selected counter.
372 * @param ElapsedTimeOut Reset elapsed time to 0.
373 * @param TimeoutTicksOut TimeoutUs converted from microsecond units to ticks units.
374 * @param TimeoutUs Timeout value in microsecond.
375 */
376 static inline void Netc_EthSwt_Ip_StartTimeOut( uint32 *StartTimeOut,
377 uint32 *ElapsedTimeOut,
378 uint32 *TimeoutTicksOut,
379 uint32 TimeoutUs
380 );
381
382 /**
383 * @brief Checks for timeout expiration condition.
384 *
385 * @param StartTimeInOut Initial value of the counter.
386 * @param ElapsedTimeInOut Current ticks passed.
387 * @param TimeoutTicks Number of ticks after timout will be activated.
388 *
389 * @return boolean TRUE - timout activated.
390 * FALSE - timeout is not yet reached.
391 */
392 static inline boolean Netc_EthSwt_Ip_TimeoutExpired( uint32 *StartTimeInOut,
393 uint32 *ElapsedTimeInOut,
394 uint32 TimeoutTicks
395 );
396
397 #if (NETC_ETHSWT_NUMBER_OF_FDB_ENTRIES > 0U)
398 /**
399 * @brief FDB table configuration function
400 *
401 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
402 *
403 * @return Result of the operation
404 * @retval 0 : E_OK, success
405 * @retval 1 : E_NOT_OK, fail
406 */
407 static Std_ReturnType Netc_EthSwt_Ip_ConfigFDBTable(const Netc_EthSwt_Ip_ConfigType * Config);
408 #endif
409
410 #if (NETC_ETHSWT_NUMBER_OF_STREAMIDENTIFICATION_ENTRIES > 0U)
411 /**
412 * @brief IngressStreamIdentification table configuration function
413 *
414 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
415 *
416 * @return Result of the operation
417 * @retval 0 : E_OK, success
418 * @retval 1 : E_NOT_OK, fail
419 */
420 static Std_ReturnType Netc_EthSwt_Ip_ConfigISITable(const Netc_EthSwt_Ip_ConfigType * Config);
421 #endif
422
423 #if (NETC_ETHSWT_NUMBER_OF_SEQTAG_ENTRIES > 0U)
424 /**
425 * @brief IngressSequenceGeneration table configuration function
426 *
427 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
428 *
429 * @return Result of the operation
430 * @retval 0 : E_OK, success
431 * @retval 1 : E_NOT_OK, fail
432 */
433 static Std_ReturnType Netc_EthSwt_Ip_ConfigSeqGenTable(const Netc_EthSwt_Ip_ConfigType * Config);
434 #endif
435
436 #if (NETC_ETHSWT_NUMBER_OF_SEQRECOVERY_ENTRIES > 0U)
437 /**
438 * @brief EgressSequenceRecovery table configuration function
439 *
440 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
441 *
442 * @return Result of the operation
443 * @retval 0 : E_OK, success
444 * @retval 1 : E_NOT_OK, fail
445 */
446 static Std_ReturnType Netc_EthSwt_Ip_ConfigSeqRecTable(const Netc_EthSwt_Ip_ConfigType * Config);
447 #endif
448
449 #if (NETC_ETHSWT_NUMBER_OF_FRAMEMODIFICATION_ENTRIES > 0U)
450 /**
451 * @brief FrameModification table configuration function
452 *
453 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
454 *
455 * @return Result of the operation
456 * @retval 0 : E_OK, success
457 * @retval 1 : E_NOT_OK, fail
458 */
459 static Std_ReturnType Netc_EthSwt_Ip_ConfigFrmModificationTable(const Netc_EthSwt_Ip_ConfigType * Config);
460 #endif
461
462 #if (NETC_ETHSWT_NUMBER_OF_EGRESSTREATMENT_ENTRIES > 0U)
463 /**
464 * @brief EgressTreatment table configuration function
465 *
466 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
467 *
468 * @return Result of the operation
469 * @retval 0 : E_OK, success
470 * @retval 1 : E_NOT_OK, fail
471 */
472 static Std_ReturnType Netc_EthSwt_Ip_ConfigEgressTreatmentTable(const Netc_EthSwt_Ip_ConfigType * Config);
473 #endif
474
475 #if (NETC_ETHSWT_NUMBER_OF_INGRESSSTREAM_ENTRIES > 0U)
476 /**
477 * @brief IngressStream table configuration function
478 *
479 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
480 *
481 * @return Result of the operation
482 * @retval 0 : E_OK, success
483 * @retval 1 : E_NOT_OK, fail
484 */
485 static Std_ReturnType Netc_EthSwt_Ip_ConfigIngressStreamTable(const Netc_EthSwt_Ip_ConfigType * Config);
486 #endif
487
488 #if (NETC_ETHSWT_NUMBER_OF_VLANFILTER_ENTRIES > 0U)
489 /**
490 * @brief VLAN filter table configuration function
491 *
492 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
493 *
494 * @return Result of the operation
495 * @retval 0 : E_OK, success
496 * @retval 1 : E_NOT_OK, fail
497 */
498 static Std_ReturnType Netc_EthSwt_Ip_ConfigVLANFilterTable(const Netc_EthSwt_Ip_ConfigType * Config);
499 #endif
500
501 /**
502 * @brief Time aware shaper configuration function
503 *
504 * @param[in] SwitchIdx: Switch ID
505 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
506 *
507 * @return Result of the operation
508 * @retval 0 : E_OK, success
509 * @retval 1 : E_NOT_OK, fail
510 */
511 static Std_ReturnType Netc_EthSwt_Ip_ConfigTAS(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config);
512
513 /**
514 * @brief Switch registers and ports configuration function
515 *
516 * @param[in] SwitchIdx: Switch ID
517 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
518 *
519 * @return Result of the operation
520 * @retval 0 : E_OK, success
521 * @retval 1 : E_NOT_OK, fail
522 */
523 static Std_ReturnType Netc_EthSwt_Ip_ConfigSwt(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config);
524
525 /* inline function for enabling PCIE for the timer, MDIO, switch, and ENETC */
526 static inline void Netc_EthSwt_Ip_EnablePCIE(void);
527
528 static inline Std_ReturnType Netc_EthSwt_Ip_PortRateEnumToRate(EthTrcv_BaudRateType baudRate, uint64 *portTxRate);
529
530 static Std_ReturnType Netc_EthSwt_Ip_IerbReady(void);
531
532 static inline void Netc_EthSwt_Ip_FillInTableDataBuffForSearchingFDBTable(const uint32 * ActionsData, const uint32 * ResumeEntryId, const Netc_EthSwt_Ip_FDBTableSearchCriteriaDataType * SearchCriteriaData);
533
534 static inline Std_ReturnType Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable( uint8 SwitchIdx,
535 uint32 * ResumeEntryId,
536 uint32 * EntryId, uint32 * agingCount, boolean * FoundEntry
537 );
538
539 static inline Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteFdbTableEntryById( uint8 SwitchIdx,
540 uint32 EntryId
541 );
542
543 #if(NETC_ETHSWT_IP_CONFIG_LINK_PROTOCOL == STD_ON)
544 /**
545 * @brief Config link protocol for switch mac ports.
546 * @details
547 *
548 * @param[in] SwitchIdx Index of the switch within the context of the Ethernet Switch Driver
549 * @param[in] SwitchPortIdx Index of the port at the addressed switch
550 * @param[in] EthSwtPortPhysicalLayerType Supported MII protocol: 0 MII, 1 RMII, 2 RGMII
551 *
552 */
553 static void Netc_EthSwt_Ip_ConfigLinkProtocol(uint8 SwitchIdx, uint8 SwitchPortIdx, Netc_EthSwt_Ip_XmiiModeType EthSwtPortPhysicalLayerType);
554 #endif
555
556 #if (NETC_ETHSWT_NUMBER_OF_RP_ENTRIES > 0U)
557 /**
558 * @brief Rate policer configuration function
559 *
560 * @param[in] SwitchIdx: Switch ID
561 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
562 *
563 * @return Result of the operation
564 * @retval 0 : E_OK, success
565 * @retval 1 : E_NOT_OK, fail
566 */
567 static Std_ReturnType Netc_EthSwt_Ip_ConfigRP(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config);
568 #endif
569
570 #if (NETC_ETHSWT_NUMBER_OF_SGCL_ENTRIES > 0U)
571 /**
572 * @brief Stream Gate Control List configuration function
573 *
574 * @param[in] SwitchIdx: Switch ID
575 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
576 *
577 * @return Result of the operation
578 * @retval 0 : E_OK, success
579 * @retval 1 : E_NOT_OK, fail
580 */
581 static Std_ReturnType Netc_EthSwt_Ip_ConfigSGCL(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config);
582 #endif
583
584 #if (NETC_ETHSWT_NUMBER_OF_SGI_ENTRIES > 0U)
585 /**
586 * @brief Stream Gate Instance configuration function
587 *
588 * @param[in] SwitchIdx: Switch ID
589 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
590 *
591 * @return Result of the operation
592 * @retval 0 : E_OK, success
593 * @retval 1 : E_NOT_OK, fail
594 */
595 static Std_ReturnType Netc_EthSwt_Ip_ConfigSGI(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config);
596 #endif
597
598 /*==================================================================================================
599 * LOCAL FUNCTIONS
600 ==================================================================================================*/
Netc_EthSwt_Ip_StartTimeOut(uint32 * StartTimeOut,uint32 * ElapsedTimeOut,uint32 * TimeoutTicksOut,uint32 TimeoutUs)601 static inline void Netc_EthSwt_Ip_StartTimeOut( uint32 *StartTimeOut,
602 uint32 *ElapsedTimeOut,
603 uint32 *TimeoutTicksOut,
604 uint32 TimeoutUs
605 )
606 {
607 *StartTimeOut = OsIf_GetCounter(NETC_ETHSWT_IP_TIMEOUT_TYPE);
608 *ElapsedTimeOut = 0U;
609 *TimeoutTicksOut = OsIf_MicrosToTicks(TimeoutUs, NETC_ETHSWT_IP_TIMEOUT_TYPE);
610 }
611
Netc_EthSwt_Ip_TimeoutExpired(uint32 * StartTimeInOut,uint32 * ElapsedTimeInOut,uint32 TimeoutTicks)612 static inline boolean Netc_EthSwt_Ip_TimeoutExpired( uint32 *StartTimeInOut,
613 uint32 *ElapsedTimeInOut,
614 uint32 TimeoutTicks
615 )
616 {
617 uint32 elapsedTime;
618
619 /* get elapsed ticks */
620 elapsedTime = OsIf_GetElapsed(StartTimeInOut, NETC_ETHSWT_IP_TIMEOUT_TYPE);
621
622 /* Need to verify overflow of addition */
623 if(((uint64)elapsedTime + *ElapsedTimeInOut) < ((uint32)MAX_32BIT))
624 {
625 *ElapsedTimeInOut += elapsedTime;
626 }
627 else
628 {
629 *ElapsedTimeInOut = ((uint32)MAX_32BIT);
630 }
631
632 return ((*ElapsedTimeInOut >= TimeoutTicks) ? TRUE : FALSE);
633 }
634
Netc_EthSwt_Ip_IerbReady(void)635 static Std_ReturnType Netc_EthSwt_Ip_IerbReady(void)
636 {
637 Std_ReturnType status = E_OK;
638 uint32 StartTime;
639 uint32 ElapsedTime;
640 uint32 TimeoutTicks;
641
642 /* Verify ready and IERB is valid */
643 /* Setup timeout timer */
644 Netc_EthSwt_Ip_StartTimeOut(&StartTime, &ElapsedTime, &TimeoutTicks, NETC_ETHSWT_IP_TIMEOUT_VALUE_US);
645 do
646 {
647 if (
648 (0UL == (IP_NETC__SW0_COMMON->OSR & NETC_F2_COMMON_OSR_STATE_MASK)) &&
649 (0UL == (IP_NETC__SW0_COMMON->OSR & NETC_F2_COMMON_OSR_ITM_STATE_MASK))
650 )
651 {
652 status = E_OK;
653 break;
654 }
655 else
656 {
657 status = E_NOT_OK;
658 }
659 }while(!Netc_EthSwt_Ip_TimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks));
660
661 return status;
662 }
663
Netc_EthSwt_Ip_PortRateEnumToRate(EthTrcv_BaudRateType baudRate,uint64 * portTxRate)664 static inline Std_ReturnType Netc_EthSwt_Ip_PortRateEnumToRate(EthTrcv_BaudRateType baudRate, uint64 *portTxRate)
665 {
666 Std_ReturnType status = E_OK;
667 /* Translate enum in uint32 for calculations and PSPEED config */
668 switch(baudRate) {
669 case ETHTRCV_BAUD_RATE_10MBIT:
670 *portTxRate = 10000000UL;
671 break;
672 case ETHTRCV_BAUD_RATE_100MBIT:
673 *portTxRate = 100000000UL;
674 break;
675 case ETHTRCV_BAUD_RATE_1000MBIT:
676 *portTxRate = 1000000000UL;
677 break;
678 default:
679 *portTxRate = 1000000000UL;
680 status = E_NOT_OK;
681 break;
682 };
683 return status;
684 }
685
686 /*FUNCTION**********************************************************************
687 *
688 * Function Name : Netc_EthSwt_Ip_EMDIOConfiguration
689 * Description : function for configuring the EMDIO
690 *
691 *END**************************************************************************/
692 static Std_ReturnType Netc_EthSwt_Ip_EMDIOConfiguration( uint8 SwitchIdx );
693
694 /*FUNCTION**********************************************************************
695 *
696 * Function Name : Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable
697 * Description : Ethernet Switch search entry ID in FDB table and increment aging count.
698 *END**************************************************************************/
Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable(uint8 SwitchIdx,uint32 * ResumeEntryId,uint32 * EntryId,uint32 * agingCount,boolean * FoundEntry)699 static inline Std_ReturnType Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable( uint8 SwitchIdx,
700 uint32 * ResumeEntryId,
701 uint32 * EntryId, uint32 * agingCount, boolean * FoundEntry
702 )
703 {
704 Std_ReturnType status = E_OK;
705 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
706 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
707 uint32 NumOfElement = 0U;
708 uint32 TableEntryId;
709 uint32 ActionsData;
710 uint32 ActionsDataResponse;
711
712 Netc_EthSwt_Ip_FDBTableSearchCriteriaDataType SearchCriteriaData;
713
714 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
715 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
716 #endif
717 *FoundEntry = FALSE;
718 SearchCriteriaData.SearchResumeEntryId=0U;
719 SearchCriteriaData.SearchActeData.ActivityCounter=0U;
720 SearchCriteriaData.SearchActeData.ActivityFlag=FALSE;
721 SearchCriteriaData.SearchCfgeData.SearchPortBitMap=0U;
722 SearchCriteriaData.SearchKeyeData.SearchFid=0U;
723 SearchCriteriaData.SearchKeyeData.SearchMulticastMacAddr=FALSE;
724
725 SearchCriteriaData.SearchMatchCriteria = (NETC_ETHSWT_IP_FDBTABLE_MATCH_CFGE_DYNAMIC_FIELD); /* Match DYNAMIC field */
726 SearchCriteriaData.SearchCfgeData.SearchDynamicEntry = TRUE; /* Search DYNAMIC entry */
727
728 /* +++ fill in FdbTabeDataBuffer for request +++ */
729 /* set the query options with full query */
730 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
731 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U) \
732 | NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(1U) \
733 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(0U);
734 Netc_EthSwt_Ip_FillInTableDataBuffForSearchingFDBTable(&ActionsData, ResumeEntryId, &SearchCriteriaData);
735 /* --- fill in FdbTabeDataBuffer for request --- */
736
737 /* do the full query with Search Method */
738 /* fill in operation data for config field of Request Header*/
739 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
740 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
741 OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
742 OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
743 OperationData.Cmd = NETC_ETHSWT_QUERY_FOLLOWEDBY_UPDATE_CMD;
744 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_REQBUFFER_LEN);
745 OperationData.RspBuffLength = (NETC_ETHSWT_IP_FDBTABLE_RESBUFFER_LEN); /* full query needs more space for response data */
746
747 /* send the "Query" command */
748 /* [notes]: there is an error "0x8A" in NTMP response header during this query operation but it is not a real error. there should be another errata for "0x8A" later. */
749 CBDRStatus = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
750
751 #if defined(ERR_IPV_NETC_051243)
752 #if (STD_ON == ERR_IPV_NETC_051243)
753 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES))
754 {
755 #endif
756 #else
757 if (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES)
758 {
759 #endif
760 /* check if found a matched entry */
761 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
762
763 /* found a matched entry */
764 TableEntryId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
765 if ((1U == NumOfElement) && (TableEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
766 {
767 *EntryId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_ENTRYID];
768 ActionsDataResponse = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_ACTEDATA];
769 *agingCount = (ActionsDataResponse & NETC_ETHSWT_IP_FDBTABLE_REPFMT_ACTE_DATA_FIELD_ACT_CNT_MASK);
770 /* Predicting the update action effect after the search */
771 if(NETC_ETHSWT_IP_FDBTABLE_REPFMT_ACTE_DATA_FIELD_ACT_FLAG_INACTIVE_FIELD ==
772 (ActionsDataResponse & NETC_ETHSWT_IP_FDBTABLE_REPFMT_ACTE_DATA_FIELD_ACT_FLAG_MASK))
773 {
774 if(*agingCount<=NETC_ETHSWT_IP_NUM_AGING_CYCLE)
775 {
776 *agingCount += 1U;
777 }
778 }
779 else
780 {
781 *agingCount = 0U;
782 }
783 *FoundEntry = TRUE;
784 }
785
786 /* get the resume_entry_id and be ready for the next query operation */
787 /* [notes]: if the searching is completed, or there is no matched entry found, then TableDataBuffer.TableDataField[0U] will be writen with MAX_32BIT by hardware */
788 *ResumeEntryId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
789 }
790 else
791 {
792 status = E_NOT_OK;
793 }
794
795 return status;
796 }
797
798 /*FUNCTION**********************************************************************
799 *
800 * Function Name : Netc_EthSwt_Ip_DeleteFdbTableEntryById
801 * Description : Ethernet Switch use the entry ID in FDB table and delete it.
802 *END**************************************************************************/
803 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteFdbTableEntryById( uint8 SwitchIdx,
804 uint32 EntryId
805 )
806 {
807 Std_ReturnType status = E_OK;
808 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
809 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
810 uint32 NumOfElement = 0U;
811 uint32 EntryStatus;
812
813 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
814 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
815 #endif
816 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_42();
817 /* +++ fill in FdbTabeDataBuffer for request +++ */
818 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = \
819 NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
820 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U) \
821 | NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(0U) \
822 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(0U);
823
824 /* fill in Access Key data with search criteria data format */
825 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EntryId;
826 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_42();
827
828 /* fill in operation data for config field of Request Header*/
829 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
830 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
831 OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
832 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
833 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
834 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN);
835 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
836
837 /* send the "Delete" command */
838 /* [notes]: there is an error "0x8A" in NTMP response header during this query operation but it is not a real error. there should be another errata for "0x8A" later. */
839 CBDRStatus = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
840
841 #if defined(ERR_IPV_NETC_051243)
842 #if (STD_ON == ERR_IPV_NETC_051243)
843 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES))
844 {
845 #endif
846 #else
847 if (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES)
848 {
849 #endif
850 /* check if found a matched entry */
851 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
852
853 /* found a matched entry */
854 EntryStatus = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
855 if (!((1U == NumOfElement) && (EntryStatus != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID)))
856 {
857 status = E_NOT_OK;
858 }
859 }
860 else
861 {
862 status = E_NOT_OK;
863 }
864
865 return status;
866 }
867
868 #if (NETC_ETHSWT_NUMBER_OF_RP_ENTRIES > 0U)
869 /*FUNCTION**********************************************************************
870 *
871 * Function Name : Netc_EthSwt_Ip_ConfigRP
872 * Description : function for configuring the Rate Policer for the switch
873 *
874 *END**************************************************************************/
875 static Std_ReturnType Netc_EthSwt_Ip_ConfigRP(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
876 {
877 Std_ReturnType status = E_OK;
878 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_CBDRSTATUS_SUCCES;
879 uint32 RPIndex = 0U;
880 uint32 MatchedEntries = 0UL;
881 Netc_EthSwt_Ip_RatePolicerEntryDataType RPTableEntry = {0};
882
883 for (RPIndex = 0U; RPIndex < Config->NumberOfRPEntries; RPIndex++)
884 {
885 RPTableEntry = (*(Config->EthSwtRatePolicerEntries))[RPIndex];
886 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntry(SwitchIdx, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &RPTableEntry);
887
888 if (CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES)
889 {
890 status = E_NOT_OK;
891 break;
892 }
893 }
894
895 return status;
896 }
897 #endif
898
899 #if (NETC_ETHSWT_NUMBER_OF_SGCL_ENTRIES > 0U)
900 /*FUNCTION**********************************************************************
901 *
902 * Function Name : Netc_EthSwt_Ip_ConfigSGCL
903 * Description : function for configuring the Stream Gate Control Lists for the switch
904 *
905 *END**************************************************************************/
906 static Std_ReturnType Netc_EthSwt_Ip_ConfigSGCL(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
907 {
908 Std_ReturnType status = E_OK;
909 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_CBDRSTATUS_SUCCES;
910 uint32 SGCLIndex = 0U;
911 uint32 MatchedEntries = 0UL;
912 Netc_EthSwt_Ip_SGCLTableDataType SGCLTableEntry = {0};
913
914 for (SGCLIndex = 0U; SGCLIndex < Config->NumberOfSGCLEntries; SGCLIndex++)
915 {
916 SGCLTableEntry = (*(Config->StreamGateControlListEntries))[SGCLIndex];
917 CBDRStatus = Netc_EthSwt_Ip_AddStreamGateControlListTableEntry(SwitchIdx, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &SGCLTableEntry);
918
919 if (CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES)
920 {
921 status = E_NOT_OK;
922 break;
923 }
924 }
925
926 return status;
927 }
928 #endif
929
930 #if (NETC_ETHSWT_NUMBER_OF_SGI_ENTRIES > 0U)
931 /*FUNCTION**********************************************************************
932 *
933 * Function Name : Netc_EthSwt_Ip_ConfigSGI
934 * Description : function for configuring the Stream Gate Instance Table for the switch
935 *
936 *END**************************************************************************/
937 static Std_ReturnType Netc_EthSwt_Ip_ConfigSGI(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
938 {
939 Std_ReturnType status = E_OK;
940 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_CBDRSTATUS_SUCCES;
941 uint32 SGIIndex = 0U;
942 uint32 MatchedEntries = 0UL;
943 Netc_EthSwt_Ip_StreamGateInstanceEntryDataType SGITableEntry = {0};
944
945 for (SGIIndex = 0U; SGIIndex < Config->NumberOfSGIEntries; SGIIndex++)
946 {
947 SGITableEntry = (*(Config->StreamGateInstanceEntries))[SGIIndex];
948 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateStreamGateInstanceTableEntry(SwitchIdx, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &SGITableEntry);
949
950 if (CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES)
951 {
952 status = E_NOT_OK;
953 break;
954 }
955 }
956
957 return status;
958 }
959 #endif
960
961 /*==================================================================================================
962 * GLOBAL FUNCTIONS
963 ==================================================================================================*/
964
965 /*FUNCTION**********************************************************************
966 *
967 * Function Name : Netc_EthSwt_Ip_SetPortMode
968 * Description : function for setting the port mode
969 * implements Netc_EthSwt_Ip_SetPortMode_Activity
970 *END**************************************************************************/
971 Std_ReturnType Netc_EthSwt_Ip_SetPortMode(uint8 SwitchIdx,
972 uint8 SwitchPortIdx,
973 boolean PortEnable)
974 {
975 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
976 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
977 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
978 #endif
979
980 (void) SwitchIdx;
981
982 if(TRUE == PortEnable)
983 {
984 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_07();
985 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->POR &= ~(SW_PORT0_POR_TXDIS_MASK | SW_PORT0_POR_RXDIS_MASK);
986
987 /* Write the PM0_COMMAND_CONFIG only for the MAC ports */
988 if (SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
989 {
990 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG |= (SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_RX_EN_MASK | \
991 SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_TX_EN_MASK);
992 }
993 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_07();
994
995 }
996 else
997 {
998 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_07();
999 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->POR |= (SW_PORT0_POR_TXDIS_MASK | SW_PORT0_POR_RXDIS_MASK);
1000
1001 /* Write the PM0_COMMAND_CONFIG only for the MAC ports */
1002 if (SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
1003 {
1004 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG &= ~(SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_RX_EN_MASK | \
1005 SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_TX_EN_MASK);
1006 }
1007 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_07();
1008 }
1009
1010 return E_OK;
1011 }
1012
1013
1014 /*FUNCTION**********************************************************************
1015 *
1016 * Function Name : Netc_EthSwt_Ip_GetPortMode
1017 * Description : function for getting the port mode
1018 * implements Netc_EthSwt_Ip_GetPortMode_Activity
1019 *END**************************************************************************/
1020 Std_ReturnType Netc_EthSwt_Ip_GetPortMode(uint8 SwitchIdx,
1021 uint8 SwitchPortIdx,
1022 boolean *PortEnable)
1023 {
1024 uint32 macPortConfig;
1025 Std_ReturnType status = E_OK;
1026
1027 (void) SwitchIdx;
1028 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
1029 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1030 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
1031 #endif
1032
1033 if (SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
1034 {
1035 macPortConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG;
1036
1037 if ( (((SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_TX_EN_MASK & macPortConfig) >> SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_TX_EN_SHIFT) ^ \
1038 ((SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_RX_EN_MASK & macPortConfig) >> SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_RX_EN_SHIFT)) == 1UL
1039 ) /* Test for different mode for RX and TX with XOR */
1040 {
1041 *PortEnable = FALSE;
1042 status = E_NOT_OK;
1043 }
1044 else
1045 {
1046 if((macPortConfig & SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_TX_EN_MASK) == SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_TX_EN_MASK)
1047 {
1048 *PortEnable = TRUE;
1049 }
1050 else
1051 {
1052 *PortEnable = FALSE;
1053 }
1054 }
1055 }
1056 else
1057 {
1058 if (0UL == (Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->POR & (SW_PORT0_POR_TXDIS_MASK | SW_PORT0_POR_RXDIS_MASK)))
1059 {
1060 *PortEnable = TRUE;
1061 }
1062 else
1063 {
1064 *PortEnable = FALSE;
1065 }
1066 }
1067
1068 return status;
1069 }
1070
1071 /*FUNCTION**********************************************************************
1072 *
1073 * Function Name : Netc_EthSwt_Ip_GetPortSpeed
1074 * Description : Ethernet Switch get baud rate function.
1075 * implements Netc_EthSwt_Ip_GetPortSpeed_Activity
1076 *END**************************************************************************/
1077 Std_ReturnType Netc_EthSwt_Ip_GetPortSpeed( uint8 SwitchIdx,
1078 uint8 SwitchPortIdx,
1079 EthTrcv_BaudRateType * BaudRate
1080 )
1081 {
1082 Std_ReturnType status = E_OK;
1083 uint32 interfaceModeConfig;
1084
1085 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
1086 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1087 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
1088 #endif
1089
1090 (void) SwitchIdx;
1091 if(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
1092 {
1093 interfaceModeConfig = (Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE);
1094
1095 switch((interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE_MASK) >> SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE_SHIFT)
1096 {
1097 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_MII_MODE: /* MII mode */
1098 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RMII_MODE: /* RMII mode */
1099 if((interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_M10_MASK) == SW_ETH_MAC_PORT1_PM0_IF_MODE_M10_MASK)
1100 {
1101 *BaudRate = ETHTRCV_BAUD_RATE_10MBIT;
1102 }
1103 else
1104 {
1105 *BaudRate = ETHTRCV_BAUD_RATE_100MBIT;
1106 }
1107 break;
1108 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RGMII_MODE: /* RGMII mode */
1109 switch((interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK) >> SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_SHIFT)
1110 {
1111 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT: /* 1000Mbps */
1112 *BaudRate = ETHTRCV_BAUD_RATE_1000MBIT;
1113 break;
1114 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT: /* 100Mbps */
1115 *BaudRate = ETHTRCV_BAUD_RATE_100MBIT;
1116 break;
1117 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT: /* 10Mbps */
1118 *BaudRate = ETHTRCV_BAUD_RATE_10MBIT;
1119 break;
1120 default:
1121 status = E_NOT_OK;
1122 break;
1123 }
1124 break;
1125 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_SGMII_MODE: /* RGMII mode */
1126 switch((interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK) >> SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_SHIFT)
1127 {
1128 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_2500MBIT: /* 2500Mbps */
1129 *BaudRate = ETHTRCV_BAUD_RATE_2500MBIT;
1130 break;
1131 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT: /* 1000Mbps */
1132 *BaudRate = ETHTRCV_BAUD_RATE_1000MBIT;
1133 break;
1134 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT: /* 100Mbps */
1135 *BaudRate = ETHTRCV_BAUD_RATE_100MBIT;
1136 break;
1137 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT: /* 10Mbps */
1138 *BaudRate = ETHTRCV_BAUD_RATE_10MBIT;
1139 break;
1140 default:
1141 status = E_NOT_OK;
1142 break;
1143 }
1144 break;
1145 default:
1146 status = E_NOT_OK;
1147 break;
1148 }
1149 }
1150 else
1151 {
1152 *BaudRate = ETHTRCV_BAUD_RATE_1000MBIT;
1153 }
1154
1155 return status;
1156 }
1157
1158 /*FUNCTION**********************************************************************
1159 *
1160 * Function Name : Netc_EthSwt_Ip_SetPortSpeed
1161 * Description : Ethernet Switch set baud rate function.
1162 * implements Netc_EthSwt_Ip_SetPortSpeed_Activity
1163 *END**************************************************************************/
1164 Std_ReturnType Netc_EthSwt_Ip_SetPortSpeed( uint8 SwitchIdx,
1165 uint8 SwitchPortIdx,
1166 EthTrcv_BaudRateType BaudRate
1167 )
1168 {
1169 Std_ReturnType status = E_OK;
1170 uint32 interfaceType;
1171 uint32 interfaceModeConfig = 0UL;
1172 uint32 shapingPSpeedConfig = 0UL; /* used for shaping of the port */
1173
1174 (void) SwitchIdx;
1175 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
1176 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1177 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
1178 #endif
1179
1180 if(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
1181 {
1182 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_01();
1183 interfaceModeConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE;
1184
1185 interfaceType = ((interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE_MASK) >> SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE_SHIFT) ;
1186 switch(interfaceType)
1187 {
1188 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_MII_MODE: /* MII mode */
1189 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RMII_MODE: /* RMII mode */
1190 {
1191 if(BaudRate == ETHTRCV_BAUD_RATE_10MBIT)
1192 {
1193 interfaceModeConfig |= SW_ETH_MAC_PORT1_PM0_IF_MODE_M10_MASK;
1194 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
1195 }
1196 else if(BaudRate == ETHTRCV_BAUD_RATE_100MBIT)
1197 {
1198 interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_M10_MASK);
1199 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
1200 }
1201 else
1202 {
1203 status = E_NOT_OK;
1204 }
1205 break;
1206 }
1207 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RGMII_MODE: /* RGMII mode */
1208 {
1209 switch(BaudRate)
1210 {
1211 case ETHTRCV_BAUD_RATE_10MBIT: /* 10Mbps */
1212 {
1213 interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1214 interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT));
1215 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
1216 break;
1217 }
1218 case ETHTRCV_BAUD_RATE_100MBIT: /* 100Mbps */
1219 {
1220 interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1221 interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT));
1222 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
1223 break;
1224 }
1225 case ETHTRCV_BAUD_RATE_1000MBIT: /* 1000Mbps */
1226 {
1227 interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1228 interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT));
1229 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_1000MBITS;
1230 break;
1231 }
1232 default:
1233 {
1234 status = E_NOT_OK;
1235 break;
1236 }
1237 }
1238 break;
1239 }
1240 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_SGMII_MODE: /* SGMII mode */
1241 {
1242 switch(BaudRate)
1243 {
1244 case ETHTRCV_BAUD_RATE_10MBIT: /* 10Mbps */
1245 {
1246 interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1247 interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT));
1248 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
1249 break;
1250 }
1251 case ETHTRCV_BAUD_RATE_100MBIT: /* 100Mbps */
1252 {
1253 interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1254 interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT));
1255 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
1256 break;
1257 }
1258 case ETHTRCV_BAUD_RATE_1000MBIT: /* 1000Mbps */
1259 {
1260 interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1261 interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT));
1262 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_1000MBITS;
1263 break;
1264 }
1265 case ETHTRCV_BAUD_RATE_2500MBIT: /* 2500Mbps */
1266 {
1267 interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1268 interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_2500MBIT));
1269 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_2500MBITS;
1270 break;
1271 }
1272 default:
1273 {
1274 status = E_NOT_OK;
1275 break;
1276 }
1277 }
1278 break;
1279 }
1280 default:
1281 {
1282 status = E_NOT_OK;
1283 break;
1284 }
1285 }
1286 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE = interfaceModeConfig;
1287
1288 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR &= ~SW_PORT0_PCR_PSPEED_MASK;
1289 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR |= SW_PORT0_PCR_PSPEED(shapingPSpeedConfig);
1290 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_01();
1291 }
1292 else
1293 {
1294 /* pseudo port */
1295 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_01();
1296 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR &= ~SW_PORT0_PCR_PSPEED_MASK;
1297 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR |= SW_PORT0_PCR_PSPEED(NETC_ETHSWT_IP_SHAPING_PSPEED_2000MBITS);
1298 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_01();
1299 }
1300
1301 return status;
1302 }
1303
1304 /*FUNCTION**********************************************************************
1305 *
1306 * Function Name : Netc_EthSwt_Ip_GetDuplexMode
1307 * Description : Ethernet Switch get duplex mode function.
1308 * implements Netc_EthSwt_Ip_GetDuplexMode_Activity
1309 *END**************************************************************************/
1310 Std_ReturnType Netc_EthSwt_Ip_GetDuplexMode( uint8 SwitchIdx,
1311 uint8 SwitchPortIdx,
1312 EthTrcv_DuplexModeType * DuplexMode
1313 )
1314 {
1315 Std_ReturnType status = E_OK;
1316 uint32 interfaceModeConfig;
1317
1318 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
1319 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1320 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
1321 #endif
1322
1323 (void) SwitchIdx;
1324 if(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
1325 {
1326 interfaceModeConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE;
1327
1328 /* Full duplex is 0 in HD field */
1329 if (SW_ETH_MAC_PORT1_PM0_IF_MODE_HD_MASK == (interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_HD_MASK))
1330 {
1331 *DuplexMode = ETHTRCV_DUPLEX_MODE_HALF;
1332 }
1333 else /* ETHTRCV_DUPLEX_MODE_HALF */
1334 {
1335 *DuplexMode = ETHTRCV_DUPLEX_MODE_FULL;
1336 }
1337 }
1338 else
1339 {
1340 *DuplexMode = ETHTRCV_DUPLEX_MODE_FULL;
1341 }
1342
1343 return status;
1344 }
1345
1346 /*FUNCTION**********************************************************************
1347 *
1348 * Function Name : Netc_EthSwt_Ip_SetMacAddr
1349 * Description : This function sets the MAC address of a certain port of switch
1350 * implements Netc_EthSwt_Ip_SetMacAddr_Activity
1351 *END**************************************************************************/
1352 Std_ReturnType Netc_EthSwt_Ip_SetMacAddr(uint8 SwitchIdx, uint8 PortIndex, const uint8 *MacAddr)
1353 {
1354 Std_ReturnType status = E_OK;
1355
1356 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
1357 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1358 DevAssert(PortIndex < NETC_ETHSWT_NUMBER_OF_PORTS);
1359 DevAssert(MacAddr != NULL_PTR);
1360 #endif
1361
1362 (void)SwitchIdx;
1363
1364 Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PMAR0 = (uint32)(MacAddr[0U]) | ((uint32)(MacAddr[1U]) << 8U) | ((uint32)(MacAddr[2U]) << 16U) | ((uint32)(MacAddr[3U]) << 24U);
1365 Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PMAR1 = (uint32)(MacAddr[4U]) | ((uint32)(MacAddr[5U]) << 8U);
1366
1367 return status;
1368 }
1369
1370 /*FUNCTION**********************************************************************
1371 *
1372 * Function Name : Netc_EthSwt_Ip_GetMacAddr
1373 * Description : This function reads the MAC address of a certain port
1374 * implements Netc_EthSwt_Ip_GetMacAddr_Activity
1375 *END**************************************************************************/
1376 void Netc_EthSwt_Ip_GetMacAddr(uint8 SwitchIdx, uint8 PortIndex, uint8 *MacAddr)
1377 {
1378 uint32 msbMacAddr;
1379 uint32 lsbMacAddr;
1380 uint8 macAddrIdx;
1381
1382 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
1383 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1384 DevAssert(PortIndex < NETC_ETHSWT_NUMBER_OF_PORTS);
1385 DevAssert(MacAddr != NULL_PTR);
1386 #endif
1387
1388 (void)SwitchIdx;
1389
1390 /* read data from registers */
1391 msbMacAddr = Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PMAR0;
1392 lsbMacAddr = Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PMAR1;
1393
1394 /* copy mac address in the correct order */
1395 for (macAddrIdx = 0U; macAddrIdx < 4U; macAddrIdx++)
1396 {
1397 MacAddr[macAddrIdx] = (uint8)(msbMacAddr & NETC_ETHSWT_IP_0XFF_MASK);
1398 msbMacAddr >>= 8U;
1399 }
1400
1401 MacAddr[4U] = (uint8)(lsbMacAddr & NETC_ETHSWT_IP_0XFF_MASK);
1402 lsbMacAddr >>= 8U;
1403 MacAddr[5U] = (uint8)(lsbMacAddr & NETC_ETHSWT_IP_0XFF_MASK);
1404
1405 }
1406
1407 /*FUNCTION**********************************************************************
1408 *
1409 * Function Name : Netc_EthSwt_Ip_GetPortMacAddr
1410 * Description : Ethernet Switch get port MAC address function.
1411 * implements Netc_EthSwt_Ip_GetPortMacAddr_Activity
1412 *END**************************************************************************/
1413 Std_ReturnType Netc_EthSwt_Ip_GetPortMacAddr( uint8 SwitchIdx, uint16 Fid, const uint8 * MacAddr, uint8 * PortIdx )
1414 {
1415 Std_ReturnType status = E_OK;
1416 Netc_EthSwt_Ip_CBDRStatusType QueryStatus;
1417 uint8 PortIndex;
1418 uint8 NumOfMatchedPorts = 0U;
1419 uint8 MacByteIdx;
1420 uint32 NumOfMatchedElement = 0x0UL;
1421 Netc_EthSwt_Ip_FdbEntryDataType FdbTableEntry = {0U};
1422 uint32 PortBitMap = 0x0UL;
1423 Netc_EthSwt_Ip_FDBTableSearchCriteriaDataType SearchCriteriaData = {0U};
1424 uint32 ResumeEntryId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
1425 boolean MatchedEntryFound = FALSE;
1426
1427 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
1428 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1429 DevAssert(MacAddr != NULL_PTR);
1430 DevAssert(PortIdx != NULL_PTR);
1431 #endif
1432
1433 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
1434 {
1435 FdbTableEntry.MacAddr[MacByteIdx] = MacAddr[MacByteIdx];
1436 }
1437 FdbTableEntry.FID = Fid;
1438
1439 if (FdbTableEntry.FID == NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID)
1440 {
1441 do
1442 {
1443 NumOfMatchedElement = 1; /* set the flag for finding a matched entry */
1444 SearchCriteriaData.SearchMatchCriteria = NETC_ETHSWT_IP_FDBTABLE_MATCH_ANY_CRITERIA;
1445 QueryStatus = Netc_EthSwt_Ip_SearchFdbTable(SwitchIdx, &ResumeEntryId, &SearchCriteriaData, &FdbTableEntry);
1446
1447 /* check if we found a matched entry */
1448 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
1449 {
1450 if (FdbTableEntry.MacAddr[MacByteIdx] != MacAddr[MacByteIdx])
1451 {
1452 NumOfMatchedElement = 0U;
1453 break;
1454 }
1455 }
1456
1457 /* find a matched entry */
1458 if (1U == NumOfMatchedElement)
1459 {
1460 MatchedEntryFound = TRUE;
1461 /* get the port bitmap value from Fdb table response data buffer. */
1462 PortBitMap |= FdbTableEntry.SwitchPortEgressBitMask; /* for those FDB entries that have same mac address but different bit mask and FID, we will do the 'or' operation for bit mask */
1463 }
1464 } while (ResumeEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID);
1465 }
1466 else
1467 {
1468 QueryStatus = Netc_EthSwt_Ip_QueryFdbTableEntry(SwitchIdx, &NumOfMatchedElement, &FdbTableEntry);
1469
1470 /* find a matched entry */
1471 if (1U == NumOfMatchedElement)
1472 {
1473 MatchedEntryFound = TRUE;
1474 /* get the port bitmap value from Fdb table response data buffer */
1475 PortBitMap = FdbTableEntry.SwitchPortEgressBitMask;
1476 }
1477 }
1478
1479 if (QueryStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES)
1480 {
1481 /* find a matched entry */
1482 if (TRUE == MatchedEntryFound)
1483 {
1484 /* check matched port number */
1485 for (PortIndex = 0U; PortIndex < NETC_ETHSWT_IP_BITMAPLEN; PortIndex++)
1486 {
1487 if (1U == (PortBitMap & (0x1U)))
1488 {
1489 NumOfMatchedPorts += 1U;
1490 *PortIdx = PortIndex;
1491 }
1492 PortBitMap >>= 1U;
1493 }
1494
1495 /* no matched ports found */
1496 if (0U == NumOfMatchedPorts)
1497 {
1498 *PortIdx = NETC_ETHSWT_IP_NOMATCHEDPORTMACADDR;
1499 }
1500
1501 /* multiple matched ports found */
1502 if (NumOfMatchedPorts > 1U)
1503 {
1504 status = E_NOT_OK;
1505 *PortIdx = NETC_ETHSWT_IP_NOMATCHEDPORTMACADDR;
1506 }
1507 }
1508 else
1509 {
1510 /* no entry found */
1511 *PortIdx = NETC_ETHSWT_IP_NOMATCHEDPORTMACADDR;
1512 }
1513 }
1514 else
1515 {
1516 status = E_NOT_OK;
1517 }
1518
1519 return status;
1520 }
1521
1522 /*FUNCTION**********************************************************************
1523 *
1524 * Function Name : Netc_EthSwt_Ip_QueryFdbTableEntry
1525 * Description : Ethernet Switch query FDB table entry function.
1526 * implements Netc_EthSwt_Ip_QueryFdbTableEntry_Activity
1527 *END**************************************************************************/
1528 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryFdbTableEntry( uint8 SwitchIdx,
1529 uint32 *MatchedEntries,
1530 Netc_EthSwt_Ip_FdbEntryDataType * FdbTableEntry
1531 )
1532 {
1533 Netc_EthSwt_Ip_CBDRStatusType status;
1534 uint32 KeyeData[3U];
1535 uint32 ActionsData;
1536 uint32 MacAddrL;
1537 uint32 MacAddrH;
1538 uint32 CfgeData;
1539 uint8 MacByteIdx;
1540 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
1541
1542 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
1543 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1544 DevAssert(MatchedEntries != NULL_PTR);
1545 DevAssert(FdbTableEntry != NULL_PTR);
1546 #endif
1547
1548 /* clear the variable MatchedEntries first */
1549 *MatchedEntries = 0U;
1550
1551 /* always do the full query. 0x0 = Full query. */
1552 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY);
1553
1554 KeyeData[0U] = ((uint32)(FdbTableEntry->MacAddr[0U]) | ((uint32)(FdbTableEntry->MacAddr[1U]) << 8U) | ((uint32)(FdbTableEntry->MacAddr[2U]) << 16U) | ((uint32)(FdbTableEntry->MacAddr[3U]) << 24U));
1555 KeyeData[1U] = ((uint32)(FdbTableEntry->MacAddr[4U]) | ((uint32)(FdbTableEntry->MacAddr[5U]) << 8U));
1556 KeyeData[2U] = FdbTableEntry->FID;
1557
1558 /* no need CFGE_DATA and only use "NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH" as the access method */
1559 status = Netc_EthSwt_Ip_FillInFdbTableReqDataBuff(ActionsData, &KeyeData[0U], NULL_PTR, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
1560 if (NETC_ETHSWT_CBDRSTATUS_SUCCES == status)
1561 {
1562 /* fill in operation data for config field of Request Header*/
1563 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
1564 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
1565 OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
1566 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH; /* for query command, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
1567 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
1568 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN); /* set request data buffer length */
1569 OperationData.RspBuffLength = (NETC_ETHSWT_IP_FDBTABLE_RESBUFFER_LEN); /* set response data buffer with normal length */
1570
1571 /* send command */
1572 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
1573 #if defined(ERR_IPV_NETC_051243)
1574 #if (STD_ON == ERR_IPV_NETC_051243)
1575 /* Error code 0x8A is not a real error. check it on Errata. */
1576 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
1577 {
1578 #endif
1579 #else
1580 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
1581 {
1582 #endif
1583 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
1584 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
1585
1586 /* found a matched entry */
1587 if (1U == *MatchedEntries)
1588 {
1589 /* fill in "Netc_EthSwt_Ip_FdbEntryDataType" structure with data in response data buffer */
1590 MacAddrL = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_L];
1591 MacAddrH = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_H];
1592 for (MacByteIdx = 0U; MacByteIdx < 4U; MacByteIdx++ )
1593 {
1594 FdbTableEntry->MacAddr[MacByteIdx] = (uint8)(MacAddrL & NETC_ETHSWT_IP_0XFF_MASK);
1595 MacAddrL >>= 8U;
1596 }
1597 FdbTableEntry->MacAddr[4U] = (uint8)(MacAddrH & NETC_ETHSWT_IP_0XFF_MASK);
1598 FdbTableEntry->MacAddr[5U] = (uint8)((MacAddrH >> 8U) & NETC_ETHSWT_IP_0XFF_MASK);
1599
1600 FdbTableEntry->FID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_FID] & NETC_ETHSWT_IP_FDBTABLE_KEYE_DATA_FID_MASK);
1601 FdbTableEntry->SwitchPortEgressBitMask = (TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_PORTBITMAP] & NETC_ETHSWT_IP_FDBTABLE_CFGE_PORT_BITMAP_MASK);
1602
1603 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_CFGECONFIG];
1604 FdbTableEntry->TimeStampCapture = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE_SHIFT) != 0x0UL) ? TRUE : FALSE;
1605 FdbTableEntry->DynamicEntry = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC_SHIFT) != 0x0UL) ? TRUE : FALSE;
1606 FdbTableEntry->CutThroughDisable = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_SHIFT);
1607 FdbTableEntry->IngressMirroringEnable = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE_SHIFT) != 0x0UL) ? TRUE : FALSE;
1608 FdbTableEntry->EgressPort = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_SHIFT);
1609 FdbTableEntry->OverridETEID = (uint8)(CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_OETEID_MASK);
1610
1611 FdbTableEntry->ET_EID = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_ETEID];
1612 }
1613 }
1614 }
1615 else
1616 {
1617 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
1618 }
1619
1620
1621 return status;
1622 }
1623
1624
1625
1626 /*FUNCTION**********************************************************************
1627 *
1628 * Function Name : Netc_EthSwt_Ip_DeleteFdbTableEntry
1629 * Description : Ethernet Switch delete FDB table entry function.
1630 * implements Netc_EthSwt_Ip_DeleteFdbTableEntry_Activity
1631 *END**************************************************************************/
1632 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteFdbTableEntry( uint8 SwitchIdx,
1633 uint32 *MatchedEntries,
1634 const Netc_EthSwt_Ip_FdbEntryDataType * FdbTableEntry
1635 )
1636 {
1637 Netc_EthSwt_Ip_CBDRStatusType status;
1638 uint32 KeyeData[3U];
1639 uint32 ActionsData = 0U;
1640 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
1641
1642 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
1643 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1644 DevAssert(MatchedEntries != NULL_PTR);
1645 DevAssert(FdbTableEntry != NULL_PTR);
1646 #endif
1647
1648 /* clear the variable MatchedEntries first */
1649 *MatchedEntries = 0U;
1650
1651 /* Delete command will ignore ActionsData data field */
1652 KeyeData[0U] = ((uint32)(FdbTableEntry->MacAddr[0U]) | ((uint32)(FdbTableEntry->MacAddr[1U]) << 8U) | ((uint32)(FdbTableEntry->MacAddr[2U]) << 16U) | ((uint32)(FdbTableEntry->MacAddr[3U]) << 24U));
1653 KeyeData[1U] = ((uint32)(FdbTableEntry->MacAddr[4U]) | ((uint32)(FdbTableEntry->MacAddr[5U]) << 8U));
1654 KeyeData[2U] = FdbTableEntry->FID;
1655
1656 /* no need CFGE_DATA and only use "NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH" as the access method */
1657 status = Netc_EthSwt_Ip_FillInFdbTableReqDataBuff(ActionsData, &KeyeData[0U], NULL_PTR, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
1658 if (NETC_ETHSWT_CBDRSTATUS_SUCCES == status)
1659 {
1660 /* fill in operation data for config field of Request Header*/
1661 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
1662 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
1663 OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
1664 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH; /* for delete command, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
1665 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
1666 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN); /* set request data buffer length */
1667 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
1668
1669 /* send the "Delete" command */
1670 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
1671 #if defined(ERR_IPV_NETC_051243)
1672 #if (STD_ON == ERR_IPV_NETC_051243)
1673 /* Error code 0x8A is not a real error. check it on Errata. */
1674 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
1675 {
1676 #endif
1677 #else
1678 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
1679 {
1680 #endif
1681 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
1682 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
1683 }
1684 }
1685 else
1686 {
1687 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
1688 }
1689
1690
1691 return status;
1692 }
1693
1694 /*FUNCTION**********************************************************************
1695 *
1696 * Function Name : Netc_EthSwt_Ip_AddOrUpdateFdbTableEntry
1697 * Description : Ethernet Switch Add or Update FDB table entry function.
1698 * implements Netc_EthSwt_Ip_AddOrUpdateFdbTableEntry_Activity
1699 *END**************************************************************************/
1700 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateFdbTableEntry( uint8 SwitchIdx,
1701 Netc_EthSwt_Ip_CommandsType Cmd,
1702 uint32 *MatchedEntries,
1703 const Netc_EthSwt_Ip_FdbEntryDataType * FdbTableEntry
1704 )
1705 {
1706 Netc_EthSwt_Ip_CBDRStatusType status;
1707 uint32 KeyeData[3U];
1708 uint32 ActionsData;
1709 Netc_EthSwt_Ip_FDBTableCFGEDataType CfgeData;
1710 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
1711
1712 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
1713 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1714 DevAssert(FdbTableEntry != NULL_PTR);
1715 DevAssert(MatchedEntries != NULL_PTR);
1716 DevAssert(FdbTableEntry->DynamicEntry == FALSE); /* users should not be allowed to add dynamic entries */
1717 #endif
1718
1719 /* clear the variable MatchedEntries first */
1720 *MatchedEntries = 0U;
1721
1722 /* only support Add, Update and AddOrUpdate commands */
1723 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd) && (NETC_ETHSWT_ADD_OR_UPDATE_CMD != Cmd))
1724 {
1725 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
1726 }
1727 else
1728 {
1729 /* set ACTEU and CFGEU flag */
1730 ActionsData = (NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(1U) \
1731 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U));
1732
1733 KeyeData[0U] = ((uint32)(FdbTableEntry->MacAddr[0U]) | ((uint32)(FdbTableEntry->MacAddr[1U]) << 8U) | ((uint32)(FdbTableEntry->MacAddr[2U]) << 16U) | ((uint32)(FdbTableEntry->MacAddr[3U]) << 24U));
1734 KeyeData[1U] = ((uint32)(FdbTableEntry->MacAddr[4U]) | ((uint32)(FdbTableEntry->MacAddr[5U]) << 8U));
1735 KeyeData[2U] = FdbTableEntry->FID;
1736
1737 CfgeData.Cfge_PortBitmap = NETC_ETHSWT_IP_FDBTABLE_CFGE_PORT_BITMAP(FdbTableEntry->SwitchPortEgressBitMask);
1738 CfgeData.Cfge_ConfigField = (NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE(FdbTableEntry->TimeStampCapture ? 1U : 0U) \
1739 | NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC(FdbTableEntry->DynamicEntry ? 1U : 0U) \
1740 | NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD(FdbTableEntry->CutThroughDisable) \
1741 | NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE(FdbTableEntry->IngressMirroringEnable ? 1U : 0U) \
1742 | NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT(FdbTableEntry->EgressPort) \
1743 | NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_OETEID(FdbTableEntry->OverridETEID));
1744
1745 CfgeData.Cfge_EtEid = FdbTableEntry->ET_EID;
1746
1747 /* only supports "NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH" access method */
1748 status = Netc_EthSwt_Ip_FillInFdbTableReqDataBuff(ActionsData, &KeyeData[0U], &CfgeData, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
1749 if (NETC_ETHSWT_CBDRSTATUS_SUCCES == status)
1750 {
1751 /* fill in operation data for config field of Request Header*/
1752 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
1753 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
1754 OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
1755 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH; /* for Add, Update, or AddorUpdate command, the Access Method should only be NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH */
1756 OperationData.Cmd = Cmd;
1757 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_REQBUFFER_LEN);
1758 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
1759
1760 /* send command */
1761 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
1762 #if defined(ERR_IPV_NETC_051243)
1763 #if (STD_ON == ERR_IPV_NETC_051243)
1764 /* Error code 0x8A is not a real error. check it on Errata. */
1765 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
1766 {
1767 #endif
1768 #else
1769 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
1770 {
1771 #endif
1772 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
1773 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
1774 }
1775 }
1776 else
1777 {
1778 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
1779 }
1780 }
1781
1782 return status;
1783 }
1784
1785 /* inline function for verifying conditions in function FillInFdbTableListData() */
1786 static inline void VerifyFillInFdbTableListDataFuncCond(const uint32 *ResumeId, boolean *StatciEntryQuerying, boolean *QueryDone)
1787 {
1788 if (NETC_ETHSWT_IP_BD_NULL_ENTRY_ID == *ResumeId)
1789 {
1790 if (TRUE == *StatciEntryQuerying)
1791 {
1792 *StatciEntryQuerying = FALSE;
1793 }
1794 else
1795 {
1796 *QueryDone = TRUE;
1797 }
1798 }
1799 }
1800
1801 /*FUNCTION**********************************************************************
1802 *
1803 * Function Name : SearchAndFillInFdbTableList
1804 * Description : inline function for searching and filling in FdbTableList data in function Netc_EthSwt_Ip_GetFdbTable().
1805 *
1806 *END**************************************************************************/
1807 static inline Std_ReturnType SearchAndFillInFdbTableList(uint32 *ResumeId, uint16 *NumOfExistingEntry, Netc_EthSwt_Ip_FdbEntryDataType *FdbTableList,
1808 boolean *StatciEntryQuerying, boolean *QueryDone)
1809 {
1810 Std_ReturnType status = E_OK;
1811 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
1812 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
1813 uint32 NumOfElement = 0U;
1814 uint32 MacAddrL;
1815 uint32 MacAddrH;
1816 uint32 CfgeData;
1817 uint8 MacAddrByteIdx;
1818 uint32 ActionsData;
1819
1820 /* set the query options with full query */
1821 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
1822 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U) \
1823 | NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(0U) \
1824 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(0U);
1825
1826 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_46();
1827 /* fill in FdbTabeDataBuffer for request */
1828 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData;
1829 /* fill in Access Key data with search criteria data format */
1830 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_RESUMEENTRYID] = *ResumeId; /* resume entry id */
1831 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MACADDRESS_L] = 0U;
1832 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MACADDRESS_H] = 0U;
1833 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_FID] = 0U;
1834 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_PORTBITMAP] = 0U;
1835 /* search static entries first then dynamic entries. set CFGE_DATA[DYNAMIC] to 0x0 meaning it will match static entries, set CFGE_DATA[DYNAMIC] to 0x1 meaning it will match dynamic entries */
1836 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_CFGECONFIG] = (TRUE == *StatciEntryQuerying) ? NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC(0U) : NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC(1U);
1837
1838 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ETEID] = 0U;
1839 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_CFGEMC(1U); /* 0x1: Match CFGE_DATA[DYNAMIC] field */
1840
1841 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_46();
1842 /* do the full query with Search Method */
1843 /* fill in operation data for config field of Request Header*/
1844 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
1845 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
1846 OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
1847 OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
1848 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
1849 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN);
1850 OperationData.RspBuffLength = (NETC_ETHSWT_IP_FDBTABLE_RESBUFFER_LEN); /* full query needs more space for response data */
1851
1852 /* send the "Query" command */
1853 /* [notes]: there is an error "0x8A" in NTMP response header during this query operation but it is not a real error. there should be another errata for "0x8A" later. */
1854 CBDRStatus = Netc_EthSwt_Ip_SendCommand(0U, NETC_ETHSWT_IP_CBDR_0, &OperationData);
1855
1856 #if defined(ERR_IPV_NETC_051243)
1857 #if (STD_ON == ERR_IPV_NETC_051243)
1858 /* check the status of query command */
1859 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES))
1860 {
1861 #endif
1862 #else
1863 if (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES)
1864 {
1865 #endif
1866 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
1867
1868 /* get the resume_entry_id and be ready for the next query operation */
1869 *ResumeId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
1870 /* ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED */
1871 /* found a matched entry */
1872 if ((1U == NumOfElement) && (*ResumeId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
1873 {
1874 /* fill in "Netc_EthSwt_Ip_FdbEntryDataType" structure with data in response data buffer */
1875 MacAddrL = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_L];
1876 MacAddrH = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_H];
1877 for (MacAddrByteIdx = 0U; MacAddrByteIdx < 4U; MacAddrByteIdx++ )
1878 {
1879 FdbTableList[(*NumOfExistingEntry)].MacAddr[MacAddrByteIdx] = (uint8)(MacAddrL & NETC_ETHSWT_IP_0XFF_MASK);
1880 MacAddrL >>= 8U;
1881 }
1882 FdbTableList[(*NumOfExistingEntry)].MacAddr[4U] = (uint8)(MacAddrH & NETC_ETHSWT_IP_0XFF_MASK);
1883 FdbTableList[(*NumOfExistingEntry)].MacAddr[5U] = (uint8)((MacAddrH >> 8U) & NETC_ETHSWT_IP_0XFF_MASK);
1884
1885 FdbTableList[(*NumOfExistingEntry)].FID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_FID] & NETC_ETHSWT_IP_FDBTABLE_KEYE_DATA_FID_MASK);
1886 FdbTableList[(*NumOfExistingEntry)].SwitchPortEgressBitMask = (TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_PORTBITMAP] & NETC_ETHSWT_IP_FDBTABLE_CFGE_PORT_BITMAP_MASK);
1887
1888 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_CFGECONFIG];
1889 FdbTableList[(*NumOfExistingEntry)].TimeStampCapture = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE_SHIFT) != 0x0UL) ? TRUE : FALSE;
1890 FdbTableList[(*NumOfExistingEntry)].DynamicEntry = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC_SHIFT) != 0x0UL) ? TRUE : FALSE;
1891 FdbTableList[(*NumOfExistingEntry)].CutThroughDisable = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_SHIFT);
1892 FdbTableList[(*NumOfExistingEntry)].IngressMirroringEnable = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE_SHIFT) != 0x0UL) ? TRUE : FALSE;
1893 FdbTableList[(*NumOfExistingEntry)].EgressPort = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_SHIFT);
1894 FdbTableList[(*NumOfExistingEntry)].OverridETEID = (uint8)(CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_OETEID_MASK);
1895
1896 FdbTableList[(*NumOfExistingEntry)].ET_EID = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_ETEID];
1897
1898 /* increase the NumOfExistingEntry */
1899 (*NumOfExistingEntry) += 1U;
1900 }
1901
1902 VerifyFillInFdbTableListDataFuncCond(ResumeId, StatciEntryQuerying, QueryDone);
1903 }
1904 else
1905 {
1906 status = E_NOT_OK;
1907 }
1908
1909 return status;
1910 }
1911
1912 /*FUNCTION**********************************************************************
1913 *
1914 * Function Name : Netc_EthSwt_Ip_GetFdbTable
1915 * Description : Ethernet Switch get FDB table function.
1916 * implements Netc_EthSwt_Ip_GetFdbTable_Activity
1917 *END**************************************************************************/
1918 Std_ReturnType Netc_EthSwt_Ip_GetFdbTable( uint8 SwitchIdx,
1919 uint16 * NumberOfElements,
1920 Netc_EthSwt_Ip_FdbEntryDataType * FdbTableList
1921 )
1922 {
1923 Std_ReturnType status = E_OK;
1924 uint16 NumOfExistingEntry = 0U;
1925 uint16 NumOfInUseEntry;
1926 uint32 ResumeId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
1927 boolean StatciEntryQuerying = TRUE;
1928 boolean QueryDone = FALSE;
1929
1930 /* [notes]: we will have to read entries one by one because of the errata ERR051048.
1931 - ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED
1932 - Description: The NUM_MATCHED field in the command NTMP response header may be incorrect when
1933 the search access method is used for the following tables: FDB table 15, L2 IPv4 Multicast
1934 Filter table 16, VLAN Filter table 18, Ingress Stream Identification table 30, or Ingress Stream
1935 Filter table 32.
1936 - Workaround: For the query command, limit the message response buffer size (RESPONSE_LENGTH field in the request header)
1937 so that NETC returns no more than one entry at a time. Under this condition, the NUM_MATCHED field value is correct
1938 */
1939
1940 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
1941 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1942 DevAssert(NumberOfElements != NULL_PTR);
1943 if (*NumberOfElements > 0U)
1944 {
1945 DevAssert(FdbTableList != NULL_PTR);
1946 }
1947 #endif
1948
1949 (void)SwitchIdx;
1950 /*
1951 * Number of static FDB entries in-use (hash-based and CAM-based entries) is indicated in FDBHTOR0[STATIC_ENTRIES].
1952 * Number of dynamic FDB entries in-use (hash-based and CAMbased entries) is indicated in FDBHTOR1[DYN_ENTRIES].
1953 */
1954 NumOfInUseEntry = (uint16)(IP_NETC__SW0_BASE->FDBHTOR0 & NETC_ETHSWT_IP_0XFFFF_MASK) + (uint16)(IP_NETC__SW0_BASE->FDBHTOR1 & NETC_ETHSWT_IP_0XFFFF_MASK); /* get how many entries exist in module */
1955
1956 /* if *NumberOfElements == 0U or NumOfInUseEntry == 0U, return the NumOfInUseEntry directly and will not do the query and fill in the structure */
1957 if ((*NumberOfElements == 0U) || (NumOfInUseEntry == 0U))
1958 {
1959 NumOfExistingEntry = NumOfInUseEntry;
1960 }
1961 else /* if *NumberOfElements > 0, do the query and fill in the structure */
1962 {
1963 do
1964 {
1965 /* check if the FdbTableList is full or we get all existing entries */
1966 if ((NumOfExistingEntry >= *NumberOfElements) || (NumOfExistingEntry >= NumOfInUseEntry) || (status == (uint8)(E_NOT_OK)) || (QueryDone == TRUE))
1967 {
1968 break;
1969 }
1970
1971 status = SearchAndFillInFdbTableList(&ResumeId, &NumOfExistingEntry, FdbTableList, &StatciEntryQuerying, &QueryDone);
1972
1973 } while ((TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS] != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID) || (FALSE == StatciEntryQuerying)); /* Status == MAX_32BIT means the query operation is completed */
1974 }
1975
1976 /* return the Number of elements which are currently available in the EthSwitch module or number of elements copied to FdbTableList*/
1977 *NumberOfElements = NumOfExistingEntry;
1978
1979 return status;
1980 }
1981
1982 /* inline function for filling in TableDataBuff in Netc_EthSwt_Ip_SearchFdbTable() function. */
1983 static inline void Netc_EthSwt_Ip_FillInTableDataBuffForSearchingFDBTable(const uint32 * ActionsData, const uint32 * ResumeEntryId, const Netc_EthSwt_Ip_FDBTableSearchCriteriaDataType * SearchCriteriaData)
1984 {
1985 uint8 MatchCriteriaData;
1986
1987 /* +++ fill in FdbTabeDataBuffer for request +++ */
1988 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = *ActionsData;
1989
1990 /* fill in Access Key data with search criteria data format */
1991 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_RESUMEENTRYID] = *ResumeEntryId; /* ResumeEntryId should start from MAX_32BIT */
1992 /* no need to fill in ETEID data for searching purpose */
1993 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ETEID] = 0U;
1994
1995 /* remap and fill in Match Criteria flag */
1996 if (SearchCriteriaData->SearchMatchCriteria >= NETC_ETHSWT_IP_FDBTABLE_MATCH_KEYE_FID_FIELD)
1997 {
1998 MatchCriteriaData = ((uint8)(SearchCriteriaData->SearchMatchCriteria) - NETC_ETHSWT_IP_FDBTABLE_KEYE_MATCH_CRITERIA_ADJUSTING_FACTOR);
1999 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_KEYEMC(MatchCriteriaData);
2000
2001 /* fill in Key Element Match Criteria data */
2002 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MACADDRESS_L] = NETC_ETHSWT_IP_MULTICASTBIT_OF_MAC_ADDRESS(SearchCriteriaData->SearchKeyeData.SearchMulticastMacAddr ? 1U : 0U);
2003 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_FID] = SearchCriteriaData->SearchKeyeData.SearchFid;
2004 }
2005 else if (SearchCriteriaData->SearchMatchCriteria >= NETC_ETHSWT_IP_FDBTABLE_MATCH_CFGE_DYNAMIC_FIELD)
2006 {
2007 MatchCriteriaData = ((uint8)(SearchCriteriaData->SearchMatchCriteria) - NETC_ETHSWT_IP_FDBTABLE_CFGE_MATCH_CRITERIA_ADJUSTING_FACTOR);
2008 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_CFGEMC(MatchCriteriaData);
2009
2010 /* fill in CFGE Match Criteria data*/
2011 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_PORTBITMAP] = SearchCriteriaData->SearchCfgeData.SearchPortBitMap;
2012 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_CFGECONFIG] = NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC(SearchCriteriaData->SearchCfgeData.SearchDynamicEntry ? 1U : 0U);
2013 }
2014 else if (SearchCriteriaData->SearchMatchCriteria == NETC_ETHSWT_IP_FDBTABLE_MATCH_ACTE_DATA_FIELD)
2015 {
2016 MatchCriteriaData = (uint8)(SearchCriteriaData->SearchMatchCriteria);
2017 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ACTEMC(MatchCriteriaData);
2018 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_08();
2019 /* fill in ACTE Match Criteria data*/
2020 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] |= (NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ACTCNT(SearchCriteriaData->SearchActeData.ActivityCounter) \
2021 | NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ACTFLAG(SearchCriteriaData->SearchActeData.ActivityFlag ? 1U : 0U));
2022 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_08();
2023 }
2024 else
2025 {
2026 /* MATCH_ANY_CRITERIA */
2027 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = 0x0UL;
2028 }
2029
2030 /* --- fill in FdbTabeDataBuffer for request --- */
2031 }
2032 /*FUNCTION**********************************************************************
2033 *
2034 * Function Name : Netc_EthSwt_Ip_SearchFdbTable
2035 * Description : Ethernet Switch search FDB table one by one.
2036 * implements Netc_EthSwt_Ip_SearchFdbTable_Activity
2037 *END**************************************************************************/
2038 Std_ReturnType Netc_EthSwt_Ip_SearchFdbTable( uint8 SwitchIdx,
2039 uint32 * ResumeEntryId,
2040 const Netc_EthSwt_Ip_FDBTableSearchCriteriaDataType * SearchCriteriaData,
2041 Netc_EthSwt_Ip_FdbEntryDataType * FdbTableEntry
2042 )
2043 {
2044 Std_ReturnType status = E_OK;
2045 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
2046 uint8 MacBeyteIdx;
2047 uint32 MacAddrL;
2048 uint32 MacAddrH;
2049 uint32 CfgeData;
2050 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
2051 uint32 NumOfElement = 0U;
2052 uint32 TableEntryId;
2053 uint32 ActionsData;
2054
2055 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2056 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2057 DevAssert(SearchCriteriaData != NULL_PTR);
2058 DevAssert(SearchCriteriaData->SearchMatchCriteria <= (NETC_ETHSWT_IP_FDBTABLE_MATCH_KEYE_FID_AND_MULTICAST_BIT_OF_MACADDR));
2059 DevAssert(FdbTableEntry != NULL_PTR);
2060 #endif
2061
2062 /* +++ fill in FdbTabeDataBuffer for request +++ */
2063 /* set the query options with full query */
2064 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
2065 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U) \
2066 | NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(0U) \
2067 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(0U);
2068 Netc_EthSwt_Ip_FillInTableDataBuffForSearchingFDBTable(&ActionsData, ResumeEntryId, SearchCriteriaData);
2069 /* --- fill in FdbTabeDataBuffer for request --- */
2070
2071 /* do the full query with Search Method */
2072 /* fill in operation data for config field of Request Header*/
2073 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2074 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2075 OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
2076 OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
2077 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
2078 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN);
2079 OperationData.RspBuffLength = (NETC_ETHSWT_IP_FDBTABLE_RESBUFFER_LEN); /* full query needs more space for response data */
2080
2081 /* send the "Query" command */
2082 /* [notes]: there is an error "0x8A" in NTMP response header during this query operation but it is not a real error. there should be another errata for "0x8A" later. */
2083 CBDRStatus = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
2084
2085 #if defined(ERR_IPV_NETC_051243)
2086 #if (STD_ON == ERR_IPV_NETC_051243)
2087 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES))
2088 {
2089 #endif
2090 #else
2091 if (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES)
2092 {
2093 #endif
2094 /* check if found a matched entry */
2095 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
2096
2097 /* found a matched entry */
2098 TableEntryId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
2099 if ((1U == NumOfElement) && (TableEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
2100 {
2101 /* fill in "Netc_EthSwt_Ip_FdbEntryDataType" structure with data in response data buffer */
2102 MacAddrL = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_L];
2103 MacAddrH = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_H];
2104 for (MacBeyteIdx = 0U; MacBeyteIdx < 4U; MacBeyteIdx++ )
2105 {
2106 FdbTableEntry->MacAddr[MacBeyteIdx] = (uint8)(MacAddrL & NETC_ETHSWT_IP_0XFF_MASK);
2107 MacAddrL >>= 8U;
2108 }
2109 FdbTableEntry->MacAddr[4U] = (uint8)(MacAddrH & NETC_ETHSWT_IP_0XFF_MASK);
2110 FdbTableEntry->MacAddr[5U] = (uint8)((MacAddrH >> 8U) & NETC_ETHSWT_IP_0XFF_MASK);
2111
2112 FdbTableEntry->FID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_FID] & NETC_ETHSWT_IP_FDBTABLE_KEYE_DATA_FID_MASK);
2113 FdbTableEntry->SwitchPortEgressBitMask = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_PORTBITMAP] & NETC_ETHSWT_IP_FDBTABLE_CFGE_PORT_BITMAP_MASK;
2114
2115 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_CFGECONFIG];
2116 FdbTableEntry->TimeStampCapture = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE_SHIFT) == 0x0UL) ? FALSE : TRUE;
2117 FdbTableEntry->DynamicEntry = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC_SHIFT) == 0x0UL) ? FALSE : TRUE;
2118 FdbTableEntry->CutThroughDisable = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_SHIFT);
2119 FdbTableEntry->IngressMirroringEnable = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE_SHIFT) == 0x0UL) ? FALSE : TRUE;
2120 FdbTableEntry->EgressPort = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_SHIFT);
2121 FdbTableEntry->OverridETEID = (uint8)(CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_OETEID_MASK);
2122
2123 FdbTableEntry->ET_EID = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_ETEID];
2124 }
2125
2126 /* get the resume_entry_id and be ready for the next query operation */
2127 /* [notes]: if the searching is completed, or there is no matched entry found, then TableDataBuffer.TableDataField[0U] will be writen with MAX_32BIT by hardware */
2128 *ResumeEntryId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
2129 }
2130 else
2131 {
2132 status = E_NOT_OK;
2133 }
2134
2135 return status;
2136 }
2137
2138 /* inline function for searching and filling in VlanFilterTableList in function Netc_EthSwt_Ip_GetVlanFilterTable() */
2139 static inline Std_ReturnType SearchAndFIllInVlanFilterTableList(uint32 *ResumeId, uint16 *NumOfExistingEntry, Netc_EthSwt_Ip_VlanFilterEntryDataType * VlanFilterTableList)
2140 {
2141 Std_ReturnType status = E_OK;
2142 uint32 ActionsData;
2143 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
2144 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
2145 uint32 NumOfElement = 0U;
2146 uint32 CfgeData;
2147
2148 /* set the query options with full query */
2149 ActionsData = (NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
2150 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U));
2151 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_48();
2152
2153 /* fill in TabeDataBuffer for request */
2154 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData;
2155 /* fill in Access Key data with search criteria data format */
2156 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_REQFMT_RESUMEENTRYID_FIELD] = *ResumeId; /* resume entry id */
2157 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_48();
2158
2159 /* do the full query with Search Method */
2160 /* fill in operation data for config field of Request Header*/
2161 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2162 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2163 OperationData.TableId = NETC_ETHSWT_IP_VLAN_FILTER_TABLE_ID;
2164 OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
2165 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
2166 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
2167 OperationData.RspBuffLength = (NETC_ETHSWT_IP_VLANFILTERTABLE_RESBUFFER_LEN); /* full query needs more space for response data */
2168
2169 /* send the "Query" command */
2170 /* [notes]: there is an error "0x8A" in NTMP response header during this query operation but it is not a real error. there should be another errata for "0x8A" later. */
2171 CBDRStatus = Netc_EthSwt_Ip_SendCommand(0U, NETC_ETHSWT_IP_CBDR_0, &OperationData);
2172
2173 #if defined(ERR_IPV_NETC_051243)
2174 #if (STD_ON == ERR_IPV_NETC_051243)
2175 /* check the status of query command */
2176 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES))
2177 {
2178 #endif
2179 #else
2180 if (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES)
2181 {
2182 #endif
2183 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
2184
2185 /* get the resume_entry_id and be ready for the next query operation */
2186 *ResumeId = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABLE_RSPDATA_STATUS];
2187
2188 /* ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED */
2189 /* found a matched entry */
2190 if ((1U == NumOfElement) && (*ResumeId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
2191 {
2192 /* fill in "Netc_EthSwt_Ip_VlanFilterEntryDataType" structure with data in response data buffer */
2193 VlanFilterTableList[(*NumOfExistingEntry)].VlanID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_VID] & NETC_ETHSWT_VLANFILTERTABLE_KEYEDATA_VID_MASK);
2194
2195 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA0];
2196 VlanFilterTableList[(*NumOfExistingEntry)].SpanningTreeGroupMemberId = (uint8)((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_STG_ID_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_STG_ID_SHIFT);
2197 VlanFilterTableList[(*NumOfExistingEntry)].PortMembershipBitmap = (CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_PORT_MEMBERSHIP_MASK);
2198
2199 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1];
2200 VlanFilterTableList[(*NumOfExistingEntry)].FID = (uint16)(CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_FID_MASK);
2201 VlanFilterTableList[(*NumOfExistingEntry)].MacLearningOptions = (uint8)((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MLO_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MLO_SHIFT);
2202 VlanFilterTableList[(*NumOfExistingEntry)].MacForwardingOptions = (uint8)((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MFO_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MFO_SHIFT);
2203 VlanFilterTableList[(*NumOfExistingEntry)].IpMulticastFilteringEnable = (((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFE_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFE_SHIFT) == 0x0UL) ? FALSE : TRUE;
2204 VlanFilterTableList[(*NumOfExistingEntry)].IpMulticastFloodingEnable = (((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFLE_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFLE_SHIFT) == 0x0UL) ? FALSE : TRUE;
2205
2206 VlanFilterTableList[(*NumOfExistingEntry)].EgressTreatmentApplicabilityPortBitmap = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA2] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_ETA_PORT_BITMAP_MASK;
2207 VlanFilterTableList[(*NumOfExistingEntry)].BaseEgressTreatmentEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA3];
2208
2209 /* increase the NumOfExistingEntry */
2210 (*NumOfExistingEntry) += 1U;
2211 }
2212 }
2213 else
2214 {
2215 status = E_NOT_OK;
2216 }
2217
2218 return status;
2219 }
2220
2221 /*FUNCTION**********************************************************************
2222 *
2223 * Function Name : Netc_EthSwt_Ip_GetVlanFilterTable
2224 * Description : Ethernet Switch get Vlan Filter table function.
2225 * implements Netc_EthSwt_Ip_GetVlanFilterTable_Activity
2226 *END**************************************************************************/
2227 Std_ReturnType Netc_EthSwt_Ip_GetVlanFilterTable( uint8 SwitchIdx,
2228 uint16 * NumberOfElements,
2229 Netc_EthSwt_Ip_VlanFilterEntryDataType * VlanFilterTableList
2230 )
2231 {
2232 Std_ReturnType status = E_OK;
2233 uint16 NumOfExistingEntry = 0U;
2234 uint16 NumOfInUseEntry;
2235 uint32 ResumeId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
2236
2237 /* [notes]: we will have to read entries one by one because of the errata ERR051048.
2238 - ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED
2239 - Description: The NUM_MATCHED field in the command NTMP response header may be incorrect when
2240 the search access method is used for the following tables: FDB table 15, L2 IPv4 Multicast
2241 Filter table 16, VLAN Filter table 18, Ingress Stream Identification table 30, or Ingress Stream
2242 Filter table 32.
2243 - Workaround: For the query command, limit the message response buffer size (RESPONSE_LENGTH field in the request header)
2244 so that NETC returns no more than one entry at a time. Under this condition, the NUM_MATCHED field value is correct
2245 */
2246
2247 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2248 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2249 DevAssert(NumberOfElements != NULL_PTR);
2250 if (*NumberOfElements > 0U)
2251 {
2252 DevAssert(VlanFilterTableList != NULL_PTR);
2253 }
2254 #endif
2255
2256 (void)SwitchIdx;
2257 /* Number of entries in-use by the VLAN Filter table is indicated in VFHTOR[NUM_ENTRIES]. */
2258 NumOfInUseEntry = (uint16)(IP_NETC__SW0_BASE->VFHTOR & NETC_ETHSWT_IP_0XFFFF_MASK); /* get how many entries exist in module */
2259
2260 /* if *NumberOfElements == 0U or NumOfInUseEntry == 0U, return the NumOfInUseEntry directly and will not do the query and fill in the structure */
2261 if ((*NumberOfElements == 0U) || (NumOfInUseEntry == 0U))
2262 {
2263 NumOfExistingEntry = NumOfInUseEntry;
2264 }
2265 else /* if *NumberOfElements > 0, do the query and fill in the structure */
2266 {
2267 do {
2268 /* check if the VlanFilterTableList is full or we get all existing entries */
2269 if ((NumOfExistingEntry >= *NumberOfElements) || (NumOfExistingEntry >= NumOfInUseEntry) || (status == (uint8)(E_NOT_OK)))
2270 {
2271 break;
2272 }
2273
2274 status = SearchAndFIllInVlanFilterTableList(&ResumeId, &NumOfExistingEntry, VlanFilterTableList);
2275 } while (TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABLE_RSPDATA_STATUS] != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID); /* Status == MAX_32BIT means the query operation is completed */
2276 }
2277
2278 /* return the Number of elements which are currently available in the EthSwitch module or number of elements copied to VlanFilterTableList*/
2279 *NumberOfElements = NumOfExistingEntry;
2280
2281 return status;
2282 }
2283
2284 /*FUNCTION**********************************************************************
2285 *
2286 * Function Name : Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry
2287 * Description : Ethernet Switch add, update or addorupdate Vlan Filter table entry function.
2288 * implements Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry_Activity
2289 *END**************************************************************************/
2290 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry( uint8 SwitchIdx,
2291 Netc_EthSwt_Ip_CommandsType Cmd,
2292 uint32 *MatchedEntries,
2293 const Netc_EthSwt_Ip_VlanFilterEntryDataType * VlanFilterTableEntry
2294 )
2295 {
2296 Netc_EthSwt_Ip_CBDRStatusType status;
2297 uint32 AccessKeyData;
2298 uint32 ActionsData;
2299 Netc_EthSwt_Ip_VlanFilterTableCFGEDataType VlanFilterCfgeData;
2300 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
2301
2302 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2303 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2304 DevAssert(MatchedEntries != NULL_PTR);
2305 DevAssert(VlanFilterTableEntry != NULL_PTR);
2306 #endif
2307
2308 /* clear the variable MatchedEntries first */
2309 *MatchedEntries = 0U;
2310
2311 /* only support Add, Update and AddOrUpdate commands */
2312 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd) && (NETC_ETHSWT_ADD_OR_UPDATE_CMD != Cmd))
2313 {
2314 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
2315 }
2316 else
2317 {
2318 /* fill in Vlan Filter Table Request Data Buffer */
2319 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U);
2320
2321 AccessKeyData = VlanFilterTableEntry->VlanID;
2322
2323 VlanFilterCfgeData.Cfge_Data[0U] = (NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_STG_ID(VlanFilterTableEntry->SpanningTreeGroupMemberId) \
2324 | NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_PORT_MEMBERSHIP(VlanFilterTableEntry->PortMembershipBitmap));
2325 VlanFilterCfgeData.Cfge_Data[1U] = (NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFLE(VlanFilterTableEntry->IpMulticastFloodingEnable ? 1U :0U) \
2326 | NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFE(VlanFilterTableEntry->IpMulticastFilteringEnable ? 1U : 0U) \
2327 | NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MFO(VlanFilterTableEntry->MacForwardingOptions) \
2328 | NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MLO(VlanFilterTableEntry->MacLearningOptions) \
2329 | NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_FID(VlanFilterTableEntry->FID));
2330 VlanFilterCfgeData.Cfge_Data[2U] = NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_ETA_PORT_BITMAP(VlanFilterTableEntry->EgressTreatmentApplicabilityPortBitmap);
2331 VlanFilterCfgeData.Cfge_Data[3U] = NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_BASE_ET_EID(VlanFilterTableEntry->BaseEgressTreatmentEntryID);
2332
2333 /* For Add, Update and AddOrUpdate commands, we only provide NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method for users */
2334 status = Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff(ActionsData, AccessKeyData, &VlanFilterCfgeData, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
2335 if (NETC_ETHSWT_CBDRSTATUS_SUCCES == status)
2336 {
2337 /* fill in operation data for config field of Request Header*/
2338 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2339 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2340 OperationData.TableId = NETC_ETHSWT_IP_VLAN_FILTER_TABLE_ID;
2341 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH; /* for Add command, the Access Method should only be NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH */
2342 OperationData.Cmd = Cmd;
2343 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_VLANFILTERTABLE_REQBUFFER_LEN);
2344 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
2345
2346 /* send the command */
2347 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
2348 #if defined(ERR_IPV_NETC_051243)
2349 #if (STD_ON == ERR_IPV_NETC_051243)
2350 /* Error code 0x8A is not a real error. check it on Errata. */
2351 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
2352 {
2353 #endif
2354 #else
2355 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
2356 {
2357 #endif
2358 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
2359 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2360 }
2361 }
2362 else
2363 {
2364 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
2365 }
2366 }
2367
2368 return status;
2369 }
2370
2371 /*FUNCTION**********************************************************************
2372 *
2373 * Function Name : Netc_EthSwt_Ip_QueryVlanFilterTableEntry
2374 * Description : Ethernet Switch query Vlan Filter table entry function.
2375 * implements Netc_EthSwt_Ip_QueryVlanFilterTableEntry_Activity
2376 *END**************************************************************************/
2377 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryVlanFilterTableEntry( uint8 SwitchIdx,
2378 uint32 *MatchedEntries,
2379 Netc_EthSwt_Ip_VlanFilterEntryDataType * VlanFilterTableEntry
2380 )
2381 {
2382 Netc_EthSwt_Ip_CBDRStatusType status;
2383 uint32 AccessKeyData;
2384 uint32 ActionsData;
2385 uint32 CfgeData;
2386 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
2387
2388 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2389 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2390 DevAssert(MatchedEntries != NULL_PTR);
2391 #endif
2392
2393 /* clear the variable MatchedEntries first */
2394 *MatchedEntries = 0U;
2395
2396 /* fill in Vlan Filter Table Request Data Buffer */
2397 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY); /* for "query" command we only provide "full query" for users */
2398
2399 AccessKeyData = VlanFilterTableEntry->VlanID;
2400
2401 /* for query command, we don't need the CFGE_DATA field */
2402 status = Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff(ActionsData, AccessKeyData, NULL_PTR, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
2403 if (NETC_ETHSWT_CBDRSTATUS_SUCCES == status)
2404 {
2405 /* fill in operation data for config field of NTMP Request Header*/
2406 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2407 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2408 OperationData.TableId = NETC_ETHSWT_IP_VLAN_FILTER_TABLE_ID;
2409 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
2410 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
2411 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
2412 OperationData.RspBuffLength = (NETC_ETHSWT_IP_VLANFILTERTABLE_RESBUFFER_LEN); /* set response data buffer length */
2413
2414 /* send the "Query" command */
2415 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
2416 #if defined(ERR_IPV_NETC_051243)
2417 #if (STD_ON == ERR_IPV_NETC_051243)
2418 /* Error code 0x8A is not a real error. check it on Errata. */
2419 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
2420 {
2421 #endif
2422 #else
2423 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
2424 {
2425 #endif
2426 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
2427 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2428
2429 /* found a matched entry */
2430 if (1U == *MatchedEntries)
2431 {
2432 /* fill in "Netc_EthSwt_Ip_VlanFilterEntryDataType" structure with data in response data buffer */
2433 VlanFilterTableEntry->VlanID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_VID] & NETC_ETHSWT_VLANFILTERTABLE_KEYEDATA_VID_MASK);
2434
2435 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA0];
2436 VlanFilterTableEntry->SpanningTreeGroupMemberId = (uint8)((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_STG_ID_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_STG_ID_SHIFT);
2437 VlanFilterTableEntry->PortMembershipBitmap = (CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_PORT_MEMBERSHIP_MASK);
2438
2439 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1];
2440 VlanFilterTableEntry->FID = (uint16)(CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_FID_MASK);
2441 VlanFilterTableEntry->MacLearningOptions = (uint8)((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MLO_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MLO_SHIFT);
2442 VlanFilterTableEntry->MacForwardingOptions = (uint8)((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MFO_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MFO_SHIFT);
2443 VlanFilterTableEntry->IpMulticastFilteringEnable = (((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFE_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFE_SHIFT) != 0x0UL) ? TRUE : FALSE;
2444 VlanFilterTableEntry->IpMulticastFloodingEnable = (((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFLE_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFLE_SHIFT) != 0x0UL) ? TRUE : FALSE;
2445
2446 VlanFilterTableEntry->EgressTreatmentApplicabilityPortBitmap = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA2] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_ETA_PORT_BITMAP_MASK;
2447 VlanFilterTableEntry->BaseEgressTreatmentEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA3];
2448 }
2449 }
2450 }
2451 else
2452 {
2453 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
2454 }
2455
2456 return status;
2457 }
2458
2459 /*FUNCTION**********************************************************************
2460 *
2461 * Function Name : Netc_EthSwt_Ip_DeleteVlanFilterTableEntry
2462 * Description : Ethernet Switch delete Vlan Filter table entry function.
2463 * implements Netc_EthSwt_Ip_DeleteVlanFilterTableEntry_Activity
2464 *END**************************************************************************/
2465 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteVlanFilterTableEntry( uint8 SwitchIdx,
2466 uint32 *MatchedEntries,
2467 uint32 VlanFilterTableEntryId
2468 )
2469 {
2470 Netc_EthSwt_Ip_CBDRStatusType status;
2471 uint32 AccessKeyData;
2472 uint32 ActionsData = 0U;
2473 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
2474
2475 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2476 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2477 DevAssert(MatchedEntries != NULL_PTR);
2478 #endif
2479
2480 /* clear the variable MatchedEntries first */
2481 *MatchedEntries = 0U;
2482
2483 /* fill in Vlan Filter Table Request Data Buffer */
2484 AccessKeyData = VlanFilterTableEntryId;
2485
2486 /* for delete command, we don't need the CFGE_DATA field */
2487 status = Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff(ActionsData, AccessKeyData, NULL_PTR, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
2488 if (NETC_ETHSWT_CBDRSTATUS_SUCCES == status)
2489 {
2490 /* fill in operation data for config field of NTMP Request Header*/
2491 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2492 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2493 OperationData.TableId = NETC_ETHSWT_IP_VLAN_FILTER_TABLE_ID;
2494 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
2495 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
2496 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
2497 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
2498
2499 /* send the "Delete" command */
2500 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
2501 #if defined(ERR_IPV_NETC_051243)
2502 #if (STD_ON == ERR_IPV_NETC_051243)
2503 /* Error code 0x8A is not a real error. check it on Errata. */
2504 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
2505 {
2506 #endif
2507 #else
2508 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
2509 {
2510 #endif
2511 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
2512 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2513 }
2514 }
2515 else
2516 {
2517 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
2518 }
2519
2520 return status;
2521 }
2522
2523 /*FUNCTION**********************************************************************
2524 *
2525 * Function Name : Netc_EthSwt_Ip_QueryEgressCountTableEntry
2526 * Description : Ethernet Switch query Egress count table entry function.
2527 * implements Netc_EthSwt_Ip_QueryEgressCountTableEntry_Activity
2528 *END**************************************************************************/
2529 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryEgressCountTableEntry( uint8 SwitchIdx,
2530 uint32 EntryId,
2531 uint32 *MatchedEntries,
2532 Netc_EthSwt_Ip_ECTableStatisticsDataType *StatisticsData
2533 )
2534 {
2535 Netc_EthSwt_Ip_CBDRStatusType status;
2536 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
2537
2538 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2539 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2540 DevAssert(StatisticsData != NULL_PTR);
2541 DevAssert(MatchedEntries != NULL_PTR);
2542 DevAssert((EntryId > 0U) && (EntryId <= (IP_NETC__SW0_COMMON->ECTCAPR & NETC_F2_COMMON_ECTCAPR_NUM_ENTRIES_MASK)));
2543 #endif
2544
2545 /* clear the variable MatchedEntries first */
2546 *MatchedEntries = 0U;
2547 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_44();
2548
2549 /* fill in Egress Count Table Request Data Buffer */
2550 /* fill in Actions field. only support "full query" action and no need to update Statistics Element */
2551 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = (NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
2552 | NETC_ETHSWT_IP_EGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD_STSEU(NETC_ETHSWT_EGRESSCOUNTTABLE_NO_UPDATE_STATISTICS_ELEMENT));
2553 /* fill in Access Key field, only support Entry ID Match method */
2554 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EntryId;
2555 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_44();
2556
2557 /* fill in operation data for config field of NTMP Request Header*/
2558 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2559 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2560 OperationData.TableId = NETC_ETHSWT_IP_EGRESS_COUNT_TABLE_ID;
2561 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support Entry ID Match method */
2562 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
2563 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
2564 OperationData.RspBuffLength = (NETC_ETHSWT_IP_EGRESSCOUNTTABLE_RSPBUFFER_LEN); /* set response data buffer length */
2565
2566 /* send the "Query" command */
2567 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
2568 #if defined(ERR_IPV_NETC_051243)
2569 #if (STD_ON == ERR_IPV_NETC_051243)
2570 /* Error code 0x8A is not a real error. check it on Errata. */
2571 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
2572 {
2573 #endif
2574 #else
2575 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
2576 {
2577 #endif
2578 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
2579 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2580 /* found a matched entry */
2581 if (*MatchedEntries == 1U)
2582 {
2583 /* get the Enqueued Frame Count data */
2584 StatisticsData->EnqueuedFrmCnt = ((uint64)(TableDataBuffer.TableDataField[NETC_ETHSWT_ECTABLE_RSPDATA_ENQFRMCNT_H]) << NETC_ETHSWT_IP_32BIT_SHIFT);
2585 StatisticsData->EnqueuedFrmCnt |= (uint64)(TableDataBuffer.TableDataField[NETC_ETHSWT_ECTABLE_RSPDATA_ENQFRMCNT_L]);
2586
2587 /* get the Rejected Frame Count */
2588 StatisticsData->RejectedFrmCnt = ((uint64)(TableDataBuffer.TableDataField[NETC_ETHSWT_ECTABLE_RSPDATA_REJFRMCNT_H]) << NETC_ETHSWT_IP_32BIT_SHIFT);
2589 StatisticsData->RejectedFrmCnt |= (uint64)(TableDataBuffer.TableDataField[NETC_ETHSWT_ECTABLE_RSPDATA_REJFRMCNT_L]);
2590 }
2591 }
2592
2593 return status;
2594 }
2595
2596 /*FUNCTION**********************************************************************
2597 *
2598 * Function Name : Netc_EthSwt_Ip_ResetEgressCountTableEntry
2599 * Description : Ethernet Switch reset Egress count table entry function.
2600 * implements Netc_EthSwt_Ip_ResetEgressCountTableEntry_Activity
2601 *END**************************************************************************/
2602 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_ResetEgressCountTableEntry( uint8 SwitchIdx,
2603 uint32 EntryId,
2604 uint32 *MatchedEntries
2605 )
2606 {
2607 Netc_EthSwt_Ip_CBDRStatusType status;
2608 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
2609
2610 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2611 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2612 DevAssert(MatchedEntries != NULL_PTR);
2613 DevAssert((EntryId > 0U) && (EntryId <= (IP_NETC__SW0_COMMON->ECTCAPR & NETC_F2_COMMON_ECTCAPR_NUM_ENTRIES_MASK)));
2614 #endif
2615
2616 /* clear the variable MatchedEntries first */
2617 *MatchedEntries = 0U;
2618
2619 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_49();
2620 /* fill in Egress Count Table Request Data Buffer */
2621 /* fill in Actions field. only support "full query" action and set STSEU to reset Statistics Element */
2622 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD] = (NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
2623 | NETC_ETHSWT_IP_EGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD_STSEU(NETC_ETHSWT_EGRESSCOUNTTABLE_RESET_STATISTICS_ELEMENT));
2624 /* fill in Access Key field, only support Entry ID Match method */
2625 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSCOUNTTABLE_REQFMT_ACCESSKEY_FIELD] = EntryId;
2626 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_49();
2627
2628 /* fill in operation data for config field of NTMP Request Header*/
2629 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2630 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2631 OperationData.TableId = NETC_ETHSWT_IP_EGRESS_COUNT_TABLE_ID;
2632 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support Entry ID Match method */
2633 OperationData.Cmd = NETC_ETHSWT_UPDATE_CMD;
2634 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
2635 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
2636
2637 /* send the "Update" command */
2638 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
2639 #if defined(ERR_IPV_NETC_051243)
2640 #if (STD_ON == ERR_IPV_NETC_051243)
2641 /* Error code 0x8A is not a real error. check it on Errata. */
2642 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
2643 {
2644 #endif
2645 #else
2646 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
2647 {
2648 #endif
2649 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
2650 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2651 }
2652
2653 return status;
2654 }
2655
2656 /*FUNCTION**********************************************************************
2657 *
2658 * Function Name : Netc_EthSwt_Ip_AddOrUpdateEgressTreatmentTableEntry
2659 * Description : Ethernet Switch add, update or addorupdate Egress Treatment table entry function.
2660 * implements Netc_EthSwt_Ip_AddOrUpdateEgressTreatmentTableEntry_Activity
2661 *END**************************************************************************/
2662 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateEgressTreatmentTableEntry( uint8 SwitchIdx,
2663 Netc_EthSwt_Ip_CommandsType Cmd,
2664 uint32 *MatchedEntries,
2665 const Netc_EthSwt_Ip_EgressTreatmentEntryDataType * EgressTreatmentTableEntry
2666 )
2667 {
2668 Netc_EthSwt_Ip_CBDRStatusType status;
2669 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
2670
2671 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2672 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2673 DevAssert(MatchedEntries != NULL_PTR);
2674 DevAssert(EgressTreatmentTableEntry != NULL_PTR);
2675 #endif
2676
2677 /* clear the variable MatchedEntries first */
2678 *MatchedEntries = 0U;
2679
2680 /* only support Add, Update and AddOrUpdate commands */
2681 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd) && (NETC_ETHSWT_ADD_OR_UPDATE_CMD != Cmd))
2682 {
2683 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
2684 }
2685 else
2686 {
2687 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_50();
2688 /* fill in Egress Treatment Table Request Data Buffer */
2689 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U);
2690 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EgressTreatmentTableEntry->EgressTreatmentEntryID;
2691
2692 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = (NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_DATA_LEN(EgressTreatmentTableEntry->EgressFrmModificationDataLength) \
2693 | NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_LEN_CHANGE(EgressTreatmentTableEntry->EgressFrmModificationLengthChange) \
2694 | NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_COUNTER_ACTION(EgressTreatmentTableEntry->EgressCounterAction) \
2695 | NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_SEQUENCE_ACTION(EgressTreatmentTableEntry->EgressSequenceAction) \
2696 | NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_MODE(EgressTreatmentTableEntry->EgressFrmModificationMode));
2697 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = EgressTreatmentTableEntry->EgressFrmModificationEID;
2698 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = EgressTreatmentTableEntry->EgressCountTableEID;
2699 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = EgressTreatmentTableEntry->EgressSeqActionsTargetEID;
2700 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_50();
2701
2702 /* fill in operation data for config field of Request Header*/
2703 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2704 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2705 OperationData.TableId = NETC_ETHSWT_IP_EGRESS_TREATMENT_TABLE_ID;
2706 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
2707 OperationData.Cmd = Cmd;
2708 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ETMTABLE_REQBUFFER_LEN);
2709 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
2710
2711 /* send the command */
2712 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
2713 #if defined(ERR_IPV_NETC_051243)
2714 #if (STD_ON == ERR_IPV_NETC_051243)
2715 /* Error code 0x8A is not a real error. check it on Errata. */
2716 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
2717 {
2718 #endif
2719 #else
2720 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
2721 {
2722 #endif
2723 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
2724 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2725 }
2726
2727 }
2728
2729 return status;
2730 }
2731
2732 /*FUNCTION**********************************************************************
2733 *
2734 * Function Name : Netc_EthSwt_Ip_QueryEgressTreatmentTableEntry
2735 * Description : Ethernet Switch query Egress Treatment table entry function.
2736 * implements Netc_EthSwt_Ip_QueryEgressTreatmentTableEntry_Activity
2737 *END**************************************************************************/
2738 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryEgressTreatmentTableEntry( uint8 SwitchIdx,
2739 uint32 *MatchedEntries,
2740 Netc_EthSwt_Ip_EgressTreatmentEntryDataType * EgressTreatmentTableEntry
2741 )
2742 {
2743 Netc_EthSwt_Ip_CBDRStatusType status;
2744 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
2745 uint32 CfgeData;
2746
2747 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2748 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2749 DevAssert(MatchedEntries != NULL_PTR);
2750 #endif
2751
2752 /* clear the variable MatchedEntries first */
2753 *MatchedEntries = 0U;
2754 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_51();
2755 /* fill in Egress Treatment Table Request Data Buffer */
2756 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY); /* only supports Full Query */
2757 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EgressTreatmentTableEntry->EgressTreatmentEntryID;
2758 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_51();
2759
2760 /* fill in operation data for config field of Request Header*/
2761 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2762 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2763 OperationData.TableId = NETC_ETHSWT_IP_EGRESS_TREATMENT_TABLE_ID;
2764 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
2765 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
2766 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
2767 OperationData.RspBuffLength = (NETC_ETHSWT_IP_EGRESSTREAMENTTABLE_RESBUFFER_LEN);
2768
2769 /* send the command */
2770 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
2771 #if defined(ERR_IPV_NETC_051243)
2772 #if (STD_ON == ERR_IPV_NETC_051243)
2773 /* Error code 0x8A is not a real error. check it on Errata. */
2774 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
2775 {
2776 #endif
2777 #else
2778 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
2779 {
2780 #endif
2781 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
2782 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2783
2784 /* found a matched entry */
2785 if (1U == *MatchedEntries)
2786 {
2787 /* fill in "Netc_EthSwt_Ip_EgressTreatmentEntryDataType" structure with data in response data buffer */
2788 EgressTreatmentTableEntry->EgressTreatmentEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSTREATMENTTABLE_RSPFMT_ENTRYID_FIELD];
2789
2790 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSTREATMENTTABLE_RSPFMT_CFGEDATA0];
2791 EgressTreatmentTableEntry->EgressFrmModificationDataLength = (uint16)((CfgeData & NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_DATA_LEN_MASK) >> NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_DATA_LEN_SHIFT);
2792 EgressTreatmentTableEntry->EgressFrmModificationLengthChange = (uint8)((CfgeData & NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_LEN_CHANGE_MASK) >> NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_LEN_CHANGE_SHIFT);
2793 EgressTreatmentTableEntry->EgressCounterAction = ((CfgeData & NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_COUNTER_ACTION_MASK) >> NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_COUNTER_ACTION_SHIFT);
2794 EgressTreatmentTableEntry->EgressSequenceAction = ((CfgeData & NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_SEQUENCE_ACTION_MASK) >> NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_SEQUENCE_ACTION_SHIFT);
2795 EgressTreatmentTableEntry->EgressFrmModificationMode = (CfgeData & NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_MODE_MASK);
2796
2797 EgressTreatmentTableEntry->EgressFrmModificationEID = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSTREATMENTTABLE_RSPFMT_CFGEDATA1]; /* fill in EFM_EID field */
2798 EgressTreatmentTableEntry->EgressCountTableEID = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSTREATMENTTABLE_RSPFMT_CFGEDATA2]; /* fill in EC_EID field */
2799 EgressTreatmentTableEntry->EgressSeqActionsTargetEID = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSTREATMENTTABLE_RSPFMT_CFGEDATA3]; /* fill in ESQA_TGT_EID field */
2800 }
2801 }
2802
2803 return status;
2804 }
2805
2806 /*FUNCTION**********************************************************************
2807 *
2808 * Function Name : Netc_EthSwt_Ip_DeleteEgressTreatmentTableEntry
2809 * Description : Ethernet Switch delete Egress Treatment table entry function.
2810 * implements Netc_EthSwt_Ip_DeleteEgressTreatmentTableEntry_Activity
2811 *END**************************************************************************/
2812 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteEgressTreatmentTableEntry( uint8 SwitchIdx,
2813 uint32 EgressTreatmentTableEntryId,
2814 uint32 *MatchedEntries
2815 )
2816 {
2817 Netc_EthSwt_Ip_CBDRStatusType status;
2818 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
2819
2820 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2821 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2822 DevAssert(MatchedEntries != NULL_PTR);
2823 #endif
2824
2825 /* clear the variable MatchedEntries first */
2826 *MatchedEntries = 0U;
2827 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_52();
2828
2829 /* fill in Egress Treatment Table Request Data Buffer */
2830 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = 0U; /* no need to fill in Actions field */
2831 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EgressTreatmentTableEntryId;
2832 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_52();
2833
2834 /* fill in operation data for config field of Request Header*/
2835 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2836 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2837 OperationData.TableId = NETC_ETHSWT_IP_EGRESS_TREATMENT_TABLE_ID;
2838 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
2839 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
2840 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
2841 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
2842
2843 /* send the command */
2844 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
2845 #if defined(ERR_IPV_NETC_051243)
2846 #if (STD_ON == ERR_IPV_NETC_051243)
2847 /* Error code 0x8A is not a real error. check it on Errata. */
2848 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
2849 {
2850 #endif
2851 #else
2852 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
2853 {
2854 #endif
2855 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
2856 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2857 }
2858
2859 return status;
2860 }
2861
2862 /*FUNCTION**********************************************************************
2863 *
2864 * Function Name : Netc_EthSwt_Ip_AddOrUpdateFrmModificationTableEntry
2865 * Description : Ethernet Switch add, update or addorupdate Frame Modification table entry function.
2866 * implements Netc_EthSwt_Ip_AddOrUpdateFrmModificationTableEntry_Activity
2867 *END**************************************************************************/
2868 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateFrmModificationTableEntry( uint8 SwitchIdx,
2869 Netc_EthSwt_Ip_CommandsType Cmd,
2870 uint32 *MatchedEntries,
2871 const Netc_EthSwt_Ip_FrmModificationEntryDataType * FrmModificationTableEntry
2872 )
2873 {
2874 Netc_EthSwt_Ip_CBDRStatusType status;
2875 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
2876 uint16 MacAddrH;
2877 uint32 MacAddrL = 0x0UL;
2878 uint8 MacByteIdx;
2879
2880 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2881 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2882 DevAssert(MatchedEntries != NULL_PTR);
2883 DevAssert(FrmModificationTableEntry != NULL_PTR);
2884 #endif
2885
2886 /* clear the variable MatchedEntries first */
2887 *MatchedEntries = 0U;
2888
2889 /* only support Add, Update and AddOrUpdate commands */
2890 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd) && (NETC_ETHSWT_ADD_OR_UPDATE_CMD != Cmd))
2891 {
2892 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
2893 }
2894 else
2895 {
2896 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_53();
2897 /* fill in Frame Modification Table Request Data Buffer */
2898 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U); /* Configuration Element Update */
2899 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = FrmModificationTableEntry->FrmModificationEntryID; /* Entry ID */
2900
2901 /* be careful to the order of dest mac address, it is in big endian */
2902 for (MacByteIdx = 5U; MacByteIdx > 2U; MacByteIdx-- ) /* Get the Dest Mac Address */
2903 {
2904 MacAddrL |= FrmModificationTableEntry->DestMacAddr[MacByteIdx];
2905 MacAddrL <<= 8U;
2906 }
2907 MacAddrL |= FrmModificationTableEntry->DestMacAddr[2U];
2908 MacAddrH = ((uint16)(FrmModificationTableEntry->DestMacAddr[1U]) << 8U) | FrmModificationTableEntry->DestMacAddr[0U];
2909
2910 /* fill in CFGE Data */
2911 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = (NENETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_DEST_MAC_ADDR_H(MacAddrH) \
2912 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SRC_MAC_ADDR_PORT(FrmModificationTableEntry->SrcMacAddrRegisterPort) \
2913 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SEQUENCE_TAG_ACTION(FrmModificationTableEntry->SequenceTagAction) \
2914 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VID_ACTION(FrmModificationTableEntry->OuterVidActions) \
2915 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_VLAN_HEADER_ACTION(FrmModificationTableEntry->L2HeaderVlanActions) \
2916 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_MAC_HEADER_ACTION(FrmModificationTableEntry->L2HeaderMacActions) \
2917 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_LAYER2_ACTION(FrmModificationTableEntry->L2Actions));
2918 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = MacAddrL;
2919 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = (NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_PAYLOAD_ACTION(FrmModificationTableEntry->PayloadActions) \
2920 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_DEI_ACTION(FrmModificationTableEntry->OuterDeiAction) \
2921 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_PCP_ACTION(FrmModificationTableEntry->OuterPcpAction) \
2922 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_TPID_ACTION(FrmModificationTableEntry->OuterTpidAction) \
2923 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_DEI(FrmModificationTableEntry->OuterVlanDei) \
2924 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_PCP(FrmModificationTableEntry->OuterVlanPcp) \
2925 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_VID(FrmModificationTableEntry->OuterVlanVID));
2926 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_PAYLOAD_OFFSET(FrmModificationTableEntry->PayloadOffset);
2927 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_FRM_MODI_BYTES(FrmModificationTableEntry->FrmModificationDataBytes);
2928 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA5] = FrmModificationTableEntry->FrmModificationDataEntryID; /* Frame Modification Data Tabel Entry ID */
2929 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_53();
2930
2931 /* fill in operation data for config field of Request Header*/
2932 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2933 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2934 OperationData.TableId = NETC_ETHSWT_IP_FRM_MODIFICATION_TABLE_ID;
2935 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support "Entry ID" match method */
2936 OperationData.Cmd = Cmd;
2937 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FRMTABLE_REQBUFFER_LEN);
2938 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
2939
2940 /* send the command */
2941 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
2942 #if defined(ERR_IPV_NETC_051243)
2943 #if (STD_ON == ERR_IPV_NETC_051243)
2944 /* Error code 0x8A is not a real error. check it on Errata. */
2945 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
2946 {
2947 #endif
2948 #else
2949 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
2950 {
2951 #endif
2952 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
2953 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2954 }
2955 }
2956
2957 return status;
2958 }
2959
2960 /*FUNCTION**********************************************************************
2961 *
2962 * Function Name : Netc_EthSwt_Ip_QueryFrmModificationTableEntry
2963 * Description : Ethernet Switch query Frame Modification table entry function.
2964 * implements Netc_EthSwt_Ip_QueryFrmModificationTableEntry_Activity
2965 *END**************************************************************************/
2966 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryFrmModificationTableEntry( uint8 SwitchIdx,
2967 uint32 *MatchedEntries,
2968 Netc_EthSwt_Ip_FrmModificationEntryDataType * FrmModificationTableEntry
2969 )
2970 {
2971 Netc_EthSwt_Ip_CBDRStatusType status;
2972 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
2973 uint16 MacAddrH;
2974 uint32 MacAddrL;
2975 uint8 MacByteIdx;
2976 uint32 CfgeData;
2977
2978 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2979 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2980 DevAssert(MatchedEntries != NULL_PTR);
2981 DevAssert(FrmModificationTableEntry != NULL_PTR);
2982 #endif
2983
2984 /* clear the variable MatchedEntries first */
2985 *MatchedEntries = 0U;
2986 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_54();
2987
2988 /* fill in Frame Modification Table Request Data Buffer */
2989 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY); /* only support "Full Query" */
2990 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = FrmModificationTableEntry->FrmModificationEntryID; /* Entry ID */
2991 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_54();
2992
2993 /* fill in operation data for config field of Request Header*/
2994 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2995 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2996 OperationData.TableId = NETC_ETHSWT_IP_FRM_MODIFICATION_TABLE_ID;
2997 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support "Entry ID" match method */
2998 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
2999 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
3000 OperationData.RspBuffLength = (NETC_ETHSWT_IP_FRMTABLE_RSPBUFFER_LEN);
3001
3002 /* send the command */
3003 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
3004 #if defined(ERR_IPV_NETC_051243)
3005 #if (STD_ON == ERR_IPV_NETC_051243)
3006 /* Error code 0x8A is not a real error. check it on Errata. */
3007 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
3008 {
3009 #endif
3010 #else
3011 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
3012 {
3013 #endif
3014 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
3015 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3016 /* found a matched entry */
3017 if (1U == *MatchedEntries)
3018 {
3019 /* fill in structure Netc_EthSwt_Ip_FrmModificationEntryDataType with data in response data buffer */
3020 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA0];
3021 MacAddrH = (uint16)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_DEST_MAC_ADDR_H_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_DEST_MAC_ADDR_H_SHIFT);
3022 MacAddrL = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA1];
3023 for (MacByteIdx = 0U; MacByteIdx < 4U; MacByteIdx++)
3024 {
3025 FrmModificationTableEntry->DestMacAddr[MacByteIdx] = (uint8)(MacAddrL & NETC_ETHSWT_IP_0XFF_MASK);
3026 MacAddrL >>= 8U;
3027 }
3028 FrmModificationTableEntry->DestMacAddr[4U] = (uint8)(MacAddrH & NETC_ETHSWT_IP_0XFF_MASK);
3029 FrmModificationTableEntry->DestMacAddr[5U] = (uint8)(MacAddrH >> 8U);
3030
3031 FrmModificationTableEntry->SrcMacAddrRegisterPort = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SRC_MAC_ADDR_PORT_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SRC_MAC_ADDR_PORT_SHIFT);
3032 FrmModificationTableEntry->SequenceTagAction = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SEQUENCE_TAG_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SEQUENCE_TAG_ACTION_SHIFT);
3033 FrmModificationTableEntry->OuterVidActions = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VID_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VID_ACTION_SHIFT);
3034 FrmModificationTableEntry->L2HeaderVlanActions = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_VLAN_HEADER_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_VLAN_HEADER_ACTION_SHIFT);
3035 FrmModificationTableEntry->L2HeaderMacActions = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_MAC_HEADER_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_MAC_HEADER_ACTION_SHIFT);
3036 FrmModificationTableEntry->L2Actions = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_LAYER2_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_LAYER2_ACTION_SHIFT);
3037
3038 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA2];
3039 FrmModificationTableEntry->PayloadActions = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_PAYLOAD_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_PAYLOAD_ACTION_SHIFT);
3040 FrmModificationTableEntry->OuterDeiAction = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_DEI_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_DEI_ACTION_SHIFT);
3041 FrmModificationTableEntry->OuterPcpAction = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_PCP_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_PCP_ACTION_SHIFT);
3042 FrmModificationTableEntry->OuterTpidAction = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_TPID_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_TPID_ACTION_SHIFT);
3043 FrmModificationTableEntry->OuterVlanDei = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_DEI_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_DEI_SHIFT);
3044 FrmModificationTableEntry->OuterVlanPcp = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_PCP_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_PCP_SHIFT);
3045 FrmModificationTableEntry->OuterVlanVID = (uint16)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_VID_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_VID_SHIFT);
3046
3047 FrmModificationTableEntry->PayloadOffset = (uint8)(TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA3] & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_PAYLOAD_OFFSET_MASK);
3048 FrmModificationTableEntry->FrmModificationDataBytes = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA4] & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_FRM_MODI_BYTES_MASK);
3049 FrmModificationTableEntry->FrmModificationDataEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA5];
3050 }
3051 }
3052
3053
3054 return status;
3055 }
3056
3057 /*FUNCTION**********************************************************************
3058 *
3059 * Function Name : Netc_EthSwt_Ip_DeleteFrmModificationTableEntry
3060 * Description : Ethernet Switch delete Frame Modification table entry function.
3061 * implements Netc_EthSwt_Ip_DeleteFrmModificationTableEntry_Activity
3062 *END**************************************************************************/
3063 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteFrmModificationTableEntry( uint8 SwitchIdx,
3064 uint32 FrmModificationEntryID,
3065 uint32 *MatchedEntries
3066 )
3067 {
3068 Netc_EthSwt_Ip_CBDRStatusType status;
3069 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
3070
3071 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3072 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3073 DevAssert(MatchedEntries != NULL_PTR);
3074 #endif
3075
3076 /* clear the variable MatchedEntries first */
3077 *MatchedEntries = 0U;
3078 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_55();
3079
3080 /* fill in Frame Modification Table Request Data Buffer */
3081 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = 0U; /* no need to fill in Actions field */
3082 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = FrmModificationEntryID; /* Entry ID */
3083 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_55();
3084
3085 /* fill in operation data for config field of Request Header*/
3086 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3087 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3088 OperationData.TableId = NETC_ETHSWT_IP_FRM_MODIFICATION_TABLE_ID;
3089 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support "Entry ID" match method */
3090 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
3091 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
3092 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
3093
3094 /* send the command */
3095 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
3096 #if defined(ERR_IPV_NETC_051243)
3097 #if (STD_ON == ERR_IPV_NETC_051243)
3098 /* Error code 0x8A is not a real error. check it on Errata. */
3099 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
3100 {
3101 #endif
3102 #else
3103 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
3104 {
3105 #endif
3106 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
3107 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3108 }
3109
3110 return status;
3111 }
3112
3113 /*FUNCTION**********************************************************************
3114 *
3115 * Function Name : Netc_EthSwt_Ip_EnableIngressPortFiltering
3116 * Description : Ethernet switch enables the ingress port filtering lookup function.
3117 * implements Netc_EthSwt_Ip_EnableIngressPortFiltering_Activity
3118 *END**************************************************************************/
3119 Std_ReturnType Netc_EthSwt_Ip_EnableIngressPortFiltering( uint8 SwitchIdx, uint8 SwitchPortIdx, boolean Enable )
3120 {
3121 Std_ReturnType Status = E_OK;
3122 uint32 RegVal;
3123
3124 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3125 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3126 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
3127 #endif
3128
3129 (void)SwitchIdx;
3130
3131 /* Convert the value */
3132 RegVal = (Enable) ? (0x1UL) : (0x0UL);
3133
3134 /* write the PIPFCR[EN] bit */
3135 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PIPFCR = RegVal;
3136
3137 return Status;
3138 }
3139
3140 /* inline function for filling in Access Keye data in function Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff() */
3141 static inline Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_FillInAccessKeyeData(const Netc_EthSwt_Ip_AccessMethodType accessMethod, const volatile uint32 *pAccessKey)
3142 {
3143 uint8 ItemIdx;
3144 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
3145
3146 switch (accessMethod)
3147 {
3148 case NETC_ETHSWT_ENTRY_ID_MATCH:
3149 /* fill in Entry_ID field */
3150 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = pAccessKey[0U];
3151 break;
3152 case NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH:
3153 /* Not Applicable for Ingress Port Filter table*/
3154 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
3155 break;
3156 case NETC_ETHSWT_SEARCH_METHOD:
3157 /* fill in Resume_Entry_ID field */
3158 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = pAccessKey[0U];
3159 break;
3160 case NETC_ETHSWT_TERNARY_MATCH_KEY_ELEMENT_MATCH:
3161 /* fill in keye_data field */
3162 for (ItemIdx = 1U; ItemIdx <= NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_KEYE_DATA_LEN; ItemIdx++)
3163 {
3164 TableDataBuffer.TableDataField[ItemIdx] = pAccessKey[ItemIdx - 1U];
3165 }
3166 break;
3167 default:
3168 /* Not Applicable for Ingress Port Filter table*/
3169 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
3170 break;
3171 }
3172
3173 return status;
3174 }
3175
3176 /*FUNCTION**********************************************************************
3177 *
3178 * Function Name : Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff
3179 * Description : Internal function for initializing the Ingress Port Filter Table Request Data Buffer.
3180 *
3181 *END**************************************************************************/
3182 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff( uint32 ActionsData,
3183 const volatile uint32 *pAccessKey,
3184 const Netc_EthSwt_Ip_IngressPortFilterCfgeDataType *pCfgeData,
3185 Netc_EthSwt_Ip_AccessMethodType accessMethod
3186 )
3187 {
3188 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
3189
3190 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_56();
3191 /* ------initialize the table request data buffer------ */
3192 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
3193
3194 /* initialize ACCESS_KEY */
3195 status = Netc_EthSwt_Ip_FillInAccessKeyeData(accessMethod, pAccessKey);
3196
3197 /* initialize CFGE_DATA. This portion is present only for commands which perform an update or add. */
3198 if (pCfgeData != NULL_PTR)
3199 {
3200 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSPORTFILTER_CFGE_CONFIG_FIELD] = (NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_IPV(pCfgeData->CfgeIpv) \
3201 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_OIPV(pCfgeData->CfgeOverrideIpv ? 1U : 0U) \
3202 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_DR(pCfgeData->CfgeDr) \
3203 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_ODR(pCfgeData->CfgeOverrideDr ? 1U : 0U) \
3204 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTFA(pCfgeData->CfgeFilterForwardingAction) \
3205 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_IMIRE(pCfgeData->CfgeIngressMirroringEnable ? 1U : 0U) \
3206 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_WOLTE(pCfgeData->CfgeWakeOnLanTriggerEnable ? 1U : 0U) \
3207 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTA(pCfgeData->CfgeFilterAction) \
3208 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_RPR(pCfgeData->CfgeRelativePrecedentResolution) \
3209 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_CTD(pCfgeData->CfgeCutThroughDisable? 1U : 0U) \
3210 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_HR(pCfgeData->CfgeHostReason) \
3211 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_TIMECAP(pCfgeData->CfgeTimestampCaptureEable ? 1U : 0U));
3212 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSPORTFILTER_CFGE_FLTATGT_FIELD] = pCfgeData->CfgeTargetForSelectedFilterAction;
3213 }
3214 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_56();
3215
3216 return status;
3217 }
3218
3219 /*FUNCTION**********************************************************************
3220 *
3221 * Function Name : Netc_EthSwt_Ip_AddIngressPortFilterTableEntry
3222 * Description : Ethernet Switch adds Ingress Port Filter table entry function.
3223 * implements Netc_EthSwt_Ip_AddIngressPortFilterTableEntry_Activity
3224 *END**************************************************************************/
3225 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddIngressPortFilterTableEntry( uint8 SwitchIdx,
3226 uint32 *MatchedEntries,
3227 Netc_EthSwt_Ip_IngressPortFilterEntryDataType * IngressPortFilterTableEntry
3228 )
3229 {
3230 Netc_EthSwt_Ip_CBDRStatusType status;
3231 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
3232 uint32 ActionsData;
3233 uint8 ByteIdx;
3234 uint8 CfgeDataIdx;
3235 uint8 PayloadIdx;
3236
3237 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3238 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3239 DevAssert(MatchedEntries != NULL_PTR);
3240 DevAssert(IngressPortFilterTableEntry != NULL_PTR);
3241 #endif
3242
3243 /* clear the variable MatchedEntries first */
3244 *MatchedEntries = 0U;
3245
3246 /* set STSEU and CFGEU flag */
3247 ActionsData = (NETC_ETHSWT_IP_IPFTABLE_REQFMT_ACTIONS_FIELD_STSEU(1U) | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U));
3248
3249 /* inialize KEYE_DATA */
3250 Netc_EthSwt_Ip_IPFKeyeData[0U] = IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePrecedence;
3251 Netc_EthSwt_Ip_IPFKeyeData[2U] = ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeFrmAttributeFlagsMask) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3252 | IngressPortFilterTableEntry->IngressPortFilterkeyeData.keyeFrmAttributeFlags;
3253 Netc_EthSwt_Ip_IPFKeyeData[3U] = NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPORTMASK(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSourcePortIDMask) \
3254 | NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPRTID(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSourcePortID) \
3255 | NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_DSCPMASK(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePointMask) \
3256 | NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_DIFFSCP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePoint);
3257 Netc_EthSwt_Ip_IPFKeyeData[4U] = ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformationMask) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3258 | (IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformation << NETC_ETHSWT_IP_8BIT_SHIFT); /* big endian for TCI */
3259 Netc_EthSwt_Ip_IPFKeyeData[5U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[0U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[1U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3260 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[2U]) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3261 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[3U]) << NETC_ETHSWT_IP_24BIT_SHIFT);
3262 Netc_EthSwt_Ip_IPFKeyeData[6U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[4U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[5U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3263 | (((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[0U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[1U]) << NETC_ETHSWT_IP_8BIT_SHIFT)) << NETC_ETHSWT_IP_16BIT_SHIFT);
3264 Netc_EthSwt_Ip_IPFKeyeData[7U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[2U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[3U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3265 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[4U]) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3266 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[5U]) << NETC_ETHSWT_IP_24BIT_SHIFT);
3267 Netc_EthSwt_Ip_IPFKeyeData[8U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[0U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[1U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3268 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[2U]) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3269 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[3U]) << NETC_ETHSWT_IP_24BIT_SHIFT);
3270 Netc_EthSwt_Ip_IPFKeyeData[9U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[4U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[5U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3271 | (((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[0U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[1U]) << NETC_ETHSWT_IP_8BIT_SHIFT)) << NETC_ETHSWT_IP_16BIT_SHIFT);
3272 Netc_EthSwt_Ip_IPFKeyeData[10U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[2U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[3U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3273 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[4U]) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3274 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[5U]) << NETC_ETHSWT_IP_24BIT_SHIFT);
3275 Netc_EthSwt_Ip_IPFKeyeData[11U] = ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformationMask) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3276 | IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformation;
3277 Netc_EthSwt_Ip_IPFKeyeData[12U] = ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeEtherTypeMask) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3278 | IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeEtherTypeMask;
3279 Netc_EthSwt_Ip_IPFKeyeData[13U] = ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPProtocolMask) << NETC_ETHSWT_IP_8BIT_SHIFT) | (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPProtocol);
3280 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3281 {
3282 Netc_EthSwt_Ip_IPFKeyeData[ByteIdx + 17U] = IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPSourceAddress[ByteIdx];
3283 }
3284 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3285 {
3286 Netc_EthSwt_Ip_IPFKeyeData[ByteIdx + 23U] = IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPSourceAddressMask[ByteIdx];
3287 }
3288 Netc_EthSwt_Ip_IPFKeyeData[27U] = ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4SourcePortMask) << NETC_ETHSWT_IP_16BIT_SHIFT) | IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4SourcePort;
3289 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3290 {
3291 Netc_EthSwt_Ip_IPFKeyeData[ByteIdx + 29U] = IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPDestinationAddress[ByteIdx];
3292 }
3293 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3294 {
3295 Netc_EthSwt_Ip_IPFKeyeData[ByteIdx + 35U] = IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPDestinationAddressMask[ByteIdx];
3296 }
3297 Netc_EthSwt_Ip_IPFKeyeData[39U] = ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4DestinationPortMask) << NETC_ETHSWT_IP_16BIT_SHIFT) | IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4DestinationPort;
3298
3299 CfgeDataIdx = 0U;
3300 PayloadIdx = 0U;
3301 for (ByteIdx = 0U; ByteIdx < 12U; ByteIdx++)
3302 {
3303 Netc_EthSwt_Ip_IPFKeyeData[CfgeDataIdx + 41U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytes[ByteIdx + PayloadIdx]) \
3304 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytesMask[ByteIdx + PayloadIdx]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3305 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytes[ByteIdx + PayloadIdx + 1U]) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3306 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytesMask[ByteIdx + PayloadIdx + 1U]) << NETC_ETHSWT_IP_24BIT_SHIFT);
3307 PayloadIdx++;
3308 CfgeDataIdx++;
3309 }
3310
3311 /* only supports "NETC_ETHSWT_TERNARY_MATCH_KEY_ELEMENT_MATCH" access method */
3312 status = Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff(ActionsData, &Netc_EthSwt_Ip_IPFKeyeData[0U], &(IngressPortFilterTableEntry->IngressPortFilterCfgeData), NETC_ETHSWT_TERNARY_MATCH_KEY_ELEMENT_MATCH);
3313 if (NETC_ETHSWT_CBDRSTATUS_SUCCES == status)
3314 {
3315 /* fill in operation data for config field of Request Header*/
3316 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3317 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3318 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_PORT_FILTER_TABLE_ID;
3319 OperationData.AccessMethod = NETC_ETHSWT_TERNARY_MATCH_KEY_ELEMENT_MATCH; /* for Adding an ingress port filter entry, the Access Method should only be NETC_ETHSWT_TERNARY_MATCH_KEY_ELEMENT_MATCH */
3320 OperationData.Cmd = NETC_ETHSWT_ADD_FOLLOWEDBY_QUERY_CMD; /* can only use "Add followed by a Query" command to add an ingress port filter table entry */
3321 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_REQBUFFER_LEN);
3322 OperationData.RspBuffLength = (NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_RSPBUFFER_LEN);
3323
3324 /* send command */
3325 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
3326 #if defined(ERR_IPV_NETC_051243)
3327 #if (STD_ON == ERR_IPV_NETC_051243)
3328 /* Error code 0x8A is not a real error. check it on Errata. */
3329 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
3330 {
3331 #endif
3332 #else
3333 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
3334 {
3335 #endif
3336 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
3337 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3338 /* It's an "Add followed by a Query", but even if this entry is added successfully, the MatchedEntry is still 0. So here we can not check the MatchedEntries parameter. */
3339 IngressPortFilterTableEntry->IngressPortFilterEntryID = TableDataBuffer.TableDataField[1U]; /* Get the Entry_ID from response data buffer */
3340 }
3341 }
3342 else
3343 {
3344 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
3345 }
3346
3347 return status;
3348 }
3349
3350 /* inline function for filling in part of keye data in function FillInIPFTableEntryData() */
3351 static inline void FillInKeyeDataForIPF(Netc_EthSwt_Ip_IngressPortFilterEntryDataType * IngressPortFilterTableEntry)
3352 {
3353 uint8 ByteIdx;
3354 uint8 PayloadIdx;
3355 uint8 CfgeDataIdx;
3356
3357 for (ByteIdx = 2U; ByteIdx < 6U; ByteIdx++)
3358 {
3359 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[ByteIdx] = (uint8)(TableDataBuffer.TableDataField[12U] & NETC_ETHSWT_IP_0XFF_MASK);
3360 TableDataBuffer.TableDataField[12U] >>= NETC_ETHSWT_IP_8BIT_SHIFT;
3361 }
3362 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformation = (uint16)(TableDataBuffer.TableDataField[13U] & NETC_ETHSWT_IP_0XFFFF_MASK);
3363 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformationMask = (uint16)((TableDataBuffer.TableDataField[13U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFFFF_MASK);
3364 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeEtherType = (uint16)(TableDataBuffer.TableDataField[14U] & NETC_ETHSWT_IP_0XFFFF_MASK);
3365 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeEtherTypeMask = (uint16)((TableDataBuffer.TableDataField[14U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFFFF_MASK);
3366 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPProtocol = (uint8)(TableDataBuffer.TableDataField[15U] & NETC_ETHSWT_IP_0XFF_MASK);
3367 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPProtocolMask = (uint8)((TableDataBuffer.TableDataField[15U] >> NETC_ETHSWT_IP_8BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3368 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3369 {
3370 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPSourceAddress[ByteIdx] = TableDataBuffer.TableDataField[ByteIdx + 19U];
3371 }
3372 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3373 {
3374 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPSourceAddressMask[ByteIdx] = TableDataBuffer.TableDataField[ByteIdx + 25U];
3375 }
3376 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4SourcePort = (uint16)(TableDataBuffer.TableDataField[29U] & NETC_ETHSWT_IP_0XFFFF_MASK);
3377 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4SourcePortMask = (uint16)((TableDataBuffer.TableDataField[29U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFFFF_MASK);
3378 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3379 {
3380 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPDestinationAddress[ByteIdx] = TableDataBuffer.TableDataField[ByteIdx + 31U];
3381 }
3382 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3383 {
3384 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPDestinationAddressMask[ByteIdx] = TableDataBuffer.TableDataField[ByteIdx + 37U];
3385 }
3386 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4DestinationPort = (uint16)(TableDataBuffer.TableDataField[41U] & NETC_ETHSWT_IP_0XFFFF_MASK);
3387 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4DestinationPortMask = (uint16)((TableDataBuffer.TableDataField[41U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFFFF_MASK);
3388
3389 CfgeDataIdx = 0U;
3390 PayloadIdx = 0U;
3391 for (ByteIdx = 0U; ByteIdx < 12U; ByteIdx++)
3392 {
3393 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytes[ByteIdx + PayloadIdx] = (uint8)(TableDataBuffer.TableDataField[CfgeDataIdx + 43U] & NETC_ETHSWT_IP_0XFF_MASK);
3394 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytes[ByteIdx + PayloadIdx + 1U] = (uint8)((TableDataBuffer.TableDataField[CfgeDataIdx + 43U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3395 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytesMask[ByteIdx + PayloadIdx] = (uint8)((TableDataBuffer.TableDataField[CfgeDataIdx + 43U] >> NETC_ETHSWT_IP_8BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3396 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytesMask[ByteIdx + PayloadIdx + 1U] = (uint8)((TableDataBuffer.TableDataField[CfgeDataIdx + 43U] >> NETC_ETHSWT_IP_24BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3397 PayloadIdx++;
3398 CfgeDataIdx++;
3399 }
3400 }
3401
3402 /* inline function for filling in IngressPortFilterTableEntry data in function Netc_EthSwt_Ip_QueryIngressPortFilterTableEntry() */
3403 static inline void FillInIPFTableEntryData(Netc_EthSwt_Ip_IngressPortFilterEntryDataType * IngressPortFilterTableEntry)
3404 {
3405 uint8 ByteIdx;
3406 uint32 CfgeData;
3407
3408 /* fill in structure Netc_EthSwt_Ip_IngressPortFilterEntryDataType with data from response data buffer */
3409 IngressPortFilterTableEntry->IngressPortFilterEntryID = TableDataBuffer.TableDataField[1U]; /* Entry_ID */
3410
3411 /* KEYE_DATA */
3412 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePrecedence = (uint16)(TableDataBuffer.TableDataField[2U] & NETC_ETHSWT_IP_0XFFFF_MASK);
3413 IngressPortFilterTableEntry->IngressPortFilterkeyeData.keyeFrmAttributeFlags = (uint16)(TableDataBuffer.TableDataField[4U] & NETC_ETHSWT_IP_0XFFFF_MASK);
3414 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeFrmAttributeFlagsMask = (uint16)((TableDataBuffer.TableDataField[4U] & NETC_ETHSWT_IP_0XFFFF0000_MASK) >> NETC_ETHSWT_IP_16BIT_SHIFT);
3415 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePoint = (uint8)(TableDataBuffer.TableDataField[5U] & NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_DIFFSCP_MASK);
3416 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePointMask = (uint8)((TableDataBuffer.TableDataField[5U] & NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_DSCPMASK_MASK) \
3417 >> NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_DSCPMASK_SHIFT);
3418 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSourcePortID = (uint8)((TableDataBuffer.TableDataField[5U] & NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPRTID_MASK) \
3419 >> NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPRTID_SHIFT);
3420 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSourcePortIDMask = (uint8)((TableDataBuffer.TableDataField[5U] & NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPORTMASK_MASK) \
3421 >> NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPORTMASK_SHIFT);
3422 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformation = (uint16)(TableDataBuffer.TableDataField[6U] & NETC_ETHSWT_IP_0XFFFF_MASK);
3423 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformationMask = (uint16)((TableDataBuffer.TableDataField[6U] & NETC_ETHSWT_IP_0XFFFF0000_MASK) >> NETC_ETHSWT_IP_16BIT_SHIFT);
3424 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3425 {
3426 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[ByteIdx] = (uint8)(TableDataBuffer.TableDataField[7U] & NETC_ETHSWT_IP_0XFF_MASK);
3427 TableDataBuffer.TableDataField[7U] >>= NETC_ETHSWT_IP_8BIT_SHIFT;
3428 }
3429 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[4U] = (uint8)(TableDataBuffer.TableDataField[8U] & NETC_ETHSWT_IP_0XFF_MASK);
3430 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[5U] = (uint8)((TableDataBuffer.TableDataField[8U] >> NETC_ETHSWT_IP_8BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3431 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[0U] = (uint8)((TableDataBuffer.TableDataField[8U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3432 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[1U] = (uint8)((TableDataBuffer.TableDataField[8U] >> NETC_ETHSWT_IP_24BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3433 for (ByteIdx = 2U; ByteIdx < 6U; ByteIdx++)
3434 {
3435 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[ByteIdx] = (uint8)(TableDataBuffer.TableDataField[9U] & NETC_ETHSWT_IP_0XFF_MASK);
3436 TableDataBuffer.TableDataField[9U] >>= NETC_ETHSWT_IP_8BIT_SHIFT;
3437 }
3438 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3439 {
3440 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[ByteIdx] = (uint8)(TableDataBuffer.TableDataField[10U] & NETC_ETHSWT_IP_0XFF_MASK);
3441 TableDataBuffer.TableDataField[10U] >>= NETC_ETHSWT_IP_8BIT_SHIFT;
3442 }
3443 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[4U] = (uint8)(TableDataBuffer.TableDataField[11U] & NETC_ETHSWT_IP_0XFF_MASK);
3444 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[5U] = (uint8)((TableDataBuffer.TableDataField[11U] >> NETC_ETHSWT_IP_8BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3445 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[0U] = (uint8)((TableDataBuffer.TableDataField[11U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3446 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[1U] = ((uint8)(TableDataBuffer.TableDataField[11U] >> NETC_ETHSWT_IP_24BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3447
3448 FillInKeyeDataForIPF(IngressPortFilterTableEntry); /* fill in the rest part of the KEYE_DATA */
3449
3450 /* Match Count data */
3451 IngressPortFilterTableEntry->IngressPortFilterMatchCount = (uint64)(TableDataBuffer.TableDataField[55U]);
3452 IngressPortFilterTableEntry->IngressPortFilterMatchCount |= ((uint64)(TableDataBuffer.TableDataField[56U]) << NETC_ETHSWT_IP_32BIT_SHIFT);
3453
3454 /* CFGE_DATA */
3455 CfgeData = TableDataBuffer.TableDataField[57U]; /* config field in CFGE_DATA */
3456 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeIpv = (uint8)(CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_IPV_MASK);
3457 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeOverrideIpv = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_OIPV_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_OIPV_SHIFT) != 0x0UL) ? TRUE : FALSE;
3458 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeDr = (uint8)((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_DR_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_DR_SHIFT);
3459 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeOverrideDr = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_ODR_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_ODR_SHIFT) != 0x0UL) ? TRUE : FALSE;
3460 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeFilterForwardingAction = ((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTFA_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTFA_SHIFT);
3461 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeIngressMirroringEnable = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_IMIRE_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_IMIRE_SHIFT) != 0x0UL) ? TRUE : FALSE;
3462 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeWakeOnLanTriggerEnable = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_WOLTE_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_WOLTE_SHIFT) != 0x0UL) ? TRUE : FALSE;
3463 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeFilterAction = ((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTA_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTA_SHIFT);
3464 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeRelativePrecedentResolution = (uint8)((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_RPR_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_RPR_SHIFT);
3465 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeCutThroughDisable = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_CTD_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_CTD_SHIFT) != 0x0UL) ? TRUE : FALSE;
3466 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeHostReason = (uint8)((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_HR_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_HR_SHIFT);
3467 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeTimestampCaptureEable = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_TIMECAP_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_TIMECAP_SHIFT) != 0x0UL) ? TRUE : FALSE;
3468 }
3469
3470 /*FUNCTION**********************************************************************
3471 *
3472 * Function Name : Netc_EthSwt_Ip_QueryIngressPortFilterTableEntry
3473 * Description : Ethernet Switch querys Ingress Port Filter table entry function.
3474 * implements Netc_EthSwt_Ip_QueryIngressPortFilterTableEntry_Activity
3475 *END**************************************************************************/
3476 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngressPortFilterTableEntry( uint8 SwitchIdx,
3477 uint32 *MatchedEntries,
3478 Netc_EthSwt_Ip_IngressPortFilterEntryDataType * IngressPortFilterTableEntry
3479 )
3480 {
3481 Netc_EthSwt_Ip_CBDRStatusType status;
3482 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
3483 uint32 KeyeData[NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_KEYE_DATA_LEN];
3484 uint32 ActionsData;
3485
3486
3487 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3488 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3489 DevAssert(MatchedEntries != NULL_PTR);
3490 DevAssert(IngressPortFilterTableEntry != NULL_PTR);
3491 #endif
3492
3493 /* clear the variable MatchedEntries first */
3494 *MatchedEntries = 0U;
3495
3496 /* only support "full query" */
3497 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY);
3498
3499 /* inialize KEYE_DATA with Entry_ID */
3500 KeyeData[0U] = IngressPortFilterTableEntry->IngressPortFilterEntryID;
3501
3502 status = Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff(ActionsData, &KeyeData[0U], NULL_PTR, NETC_ETHSWT_ENTRY_ID_MATCH);
3503 if (NETC_ETHSWT_CBDRSTATUS_SUCCES == status)
3504 {
3505 /* fill in operation data for config field of Request Header*/
3506 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3507 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3508 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_PORT_FILTER_TABLE_ID;
3509 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
3510 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
3511 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_REQBUFFER_LEN);
3512 OperationData.RspBuffLength = (NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_RSPBUFFER_LEN);
3513
3514 /* send command */
3515 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
3516 #if defined(ERR_IPV_NETC_051243)
3517 #if (STD_ON == ERR_IPV_NETC_051243)
3518 /* Error code 0x8A is not a real error. check it on Errata. */
3519 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
3520 {
3521 #endif
3522 #else
3523 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
3524 {
3525 #endif
3526 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
3527 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3528 /* if found a matched entry, then fill in the structure */
3529 if (1U == *MatchedEntries)
3530 {
3531 FillInIPFTableEntryData(IngressPortFilterTableEntry);
3532 }
3533 }
3534 }
3535 else
3536 {
3537 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
3538 }
3539
3540 return status;
3541 }
3542
3543 /*FUNCTION**********************************************************************
3544 *
3545 * Function Name : Netc_EthSwt_Ip_DeleteIngressPortFilterTableEntry
3546 * Description : Ethernet Switch deletes Ingress Port Filter table entry function.
3547 * implements Netc_EthSwt_Ip_DeleteIngressPortFilterTableEntry_Activity
3548 *END**************************************************************************/
3549 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngressPortFilterTableEntry( uint8 SwitchIdx,
3550 uint32 *MatchedEntries,
3551 uint32 IngressPortFilterEntry
3552 )
3553 {
3554 Netc_EthSwt_Ip_CBDRStatusType status;
3555 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
3556 uint32 KeyeData[1U];
3557 uint32 ActionsData = 0x0UL;
3558
3559 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3560 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3561 DevAssert(MatchedEntries != NULL_PTR);
3562 #endif
3563
3564 /* clear the variable MatchedEntries first */
3565 *MatchedEntries = 0U;
3566
3567 /* inialize KEYE_DATA with Entry_ID */
3568 KeyeData[0U] = IngressPortFilterEntry;
3569
3570 status = Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff(ActionsData, &KeyeData[0U], NULL_PTR, NETC_ETHSWT_ENTRY_ID_MATCH);
3571 if (NETC_ETHSWT_CBDRSTATUS_SUCCES == status)
3572 {
3573 /* fill in operation data for config field of Request Header*/
3574 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3575 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3576 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_PORT_FILTER_TABLE_ID;
3577 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
3578 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
3579 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_REQBUFFER_LEN);
3580 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
3581
3582 /* send command */
3583 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
3584 #if defined(ERR_IPV_NETC_051243)
3585 #if (STD_ON == ERR_IPV_NETC_051243)
3586 /* Error code 0x8A is not a real error. check it on Errata. */
3587 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
3588 {
3589 #endif
3590 #else
3591 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
3592 {
3593 #endif
3594 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
3595 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3596 }
3597 }
3598 else
3599 {
3600 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
3601 }
3602
3603 return status;
3604 }
3605
3606 /*FUNCTION**********************************************************************
3607 *
3608 * Function Name : Netc_EthSwt_Ip_ConfigPortTimeGateScheduling
3609 * Description : Ethernet Switch enables or disables Time Gate Scheduling function on a port.
3610 * implements Netc_EthSwt_Ip_ConfigPortTimeGateScheduling_Activity
3611 *
3612 *END**************************************************************************/
3613 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_ConfigPortTimeGateScheduling( uint8 SwitchIdx,
3614 uint8 SwitchPortIdx,
3615 boolean Enable
3616 )
3617 {
3618 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
3619 uint32 RegValue;
3620 uint32 GateControlListState;
3621 uint32 StartTime;
3622 uint32 ElapsedTime;
3623 uint32 TimeoutTicks;
3624 boolean TimeExpired;
3625
3626 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3627 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3628 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
3629 #endif
3630
3631 (void)SwitchIdx;
3632 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_60();
3633 /* read the reg value first */
3634 RegValue = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PTGSCR;
3635 if ((RegValue & SW_PORT0_PTGSCR_TGE_MASK) != SW_PORT0_PTGSCR_TGE_MASK) /* time gating is disabled */
3636 {
3637 if (TRUE == Enable)
3638 {
3639 /* Software must also wait until PTGAGLSR[TG] is deasserted before re-enabling. */
3640 Netc_EthSwt_Ip_StartTimeOut(&StartTime, &ElapsedTime, &TimeoutTicks, NETC_ETHSWT_IP_TIMEOUT_VALUE_US);
3641 do {
3642 /* get the state of gate control list */
3643 GateControlListState = (Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PTGAGLSR & SW_PORT0_PTGAGLSR_TG_MASK);
3644 TimeExpired = Netc_EthSwt_Ip_TimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks);
3645 } while ((GateControlListState != 0x0U) && (FALSE == TimeExpired));
3646
3647 if (GateControlListState == 0x0U)
3648 {
3649 RegValue |= SW_PORT0_PTGSCR_TGE(1U); /* Enable time gating */
3650 }
3651 else
3652 {
3653 status = E_NOT_OK; /* fail to enable time gating because Operational gate control list is active */
3654 }
3655 }
3656 }
3657 else /* time gating is enabled */
3658 {
3659 if (FALSE == Enable)
3660 {
3661 RegValue &= ~SW_PORT0_PTGSCR_TGE(1U); /* Disable time gating */
3662 }
3663 }
3664
3665 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
3666 {
3667 /* write it back. */
3668 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PTGSCR = RegValue;
3669 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_60();
3670
3671 /* if time gate scheduling is enabled, and entry data is configured, then adds the entry */
3672 if ((TRUE == Enable) && (TRUE == PortTimeAwareShaperEnabled[SwitchPortIdx]))
3673 {
3674 status = Netc_EthSwt_Ip_AddOrUpdateTimeGateSchedulingTableEntry(0U, &TimeGateSchedulingEntryData[SwitchPortIdx]);
3675 /* fail to add or update the time gate schedulling table entry */
3676 if (status != NETC_ETHSWT_CBDRSTATUS_SUCCES)
3677 {
3678 status = E_NOT_OK;
3679 }
3680 }
3681 }
3682 else
3683 {
3684 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_60();
3685 }
3686
3687 return status;
3688 }
3689
3690 static inline void Netc_EthSwt_Ip_FillInGateControlListData(const uint8 *OperationTimeIdx, const Netc_EthSwt_Ip_TimeGateSchedulingEntryDataType *TimeGateSchedulingTableEntry)
3691 {
3692 uint8 CFGEDataIdx;
3693 uint16 GateEntryIdx;
3694 uint8 HostRequest;
3695
3696 if (*OperationTimeIdx == 1U)
3697 {
3698 CFGEDataIdx = 0U;
3699 for (GateEntryIdx = 0U; GateEntryIdx < TimeGateSchedulingTableEntry->AdminControlListLength; GateEntryIdx++)
3700 {
3701 TableDataBuffer.TableDataField[(uint8)(NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA5) + CFGEDataIdx] = TimeGateSchedulingTableEntry->GateEntryAdminControlListData[GateEntryIdx].AdminTimeInterval;
3702 /* convert gate operation type */
3703 switch (TimeGateSchedulingTableEntry->GateEntryAdminControlListData[GateEntryIdx].AdminGateOperationType)
3704 {
3705 case ETHSWT_HOST_REQUEST_UNCHANGED:
3706 HostRequest = 0U;
3707 break;
3708 case ETHSWT_HOST_REQUEST_HOLD:
3709 HostRequest = 1U;
3710 break;
3711 case ETHSWT_HOST_REQUEST_RELEASE:
3712 HostRequest = 2U;
3713 break;
3714 default:
3715 HostRequest = 0U;
3716 break;
3717 }
3718 TableDataBuffer.TableDataField[(uint8)(NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA6) + CFGEDataIdx] = NETC_ETHSWT_IP_TGSTABLE_CFGE_ADMIN_TC_STATES(TimeGateSchedulingTableEntry->GateEntryAdminControlListData[GateEntryIdx].AdminTrafficClassGateStates) \
3719 | NETC_ETHSWT_IP_TGSTABLE_CFGE_ADMIN_HR_CB(HostRequest);
3720
3721 CFGEDataIdx += 2U; /* CFGE data field index increased by 2 */
3722 }
3723 }
3724 }
3725
3726 /*FUNCTION**********************************************************************
3727 *
3728 * Function Name : Netc_EthSwt_Ip_AddOrUpdateTimeGateSchedulingTableEntry
3729 * Description : Ethernet Switch adds or updates Time Gate Scheduling table entry function.
3730 * implements Netc_EthSwt_Ip_AddOrUpdateTimeGateSchedulingTableEntry_Activity
3731 *
3732 *END**************************************************************************/
3733 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateTimeGateSchedulingTableEntry( uint8 SwitchIdx,
3734 const Netc_EthSwt_Ip_TimeGateSchedulingEntryDataType *TimeGateSchedulingTableEntry
3735 )
3736 {
3737 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
3738 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
3739 uint8 OperationTimes;
3740 uint8 OperationTimeIdx;
3741 volatile uint64 CurrentTime = 0;
3742 uint32 CycleFactor;
3743 uint64 NewBaseTime;
3744 uint32 LookaheadTime;
3745
3746 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3747 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3748 DevAssert(TimeGateSchedulingTableEntry != NULL_PTR);
3749 #endif
3750
3751 /* AdminControlListLength = 0U means to reset the gate control list or add the time gate scheduling entry without gate control list */
3752 OperationTimes = (TimeGateSchedulingTableEntry->AdminControlListLength > 0U) ? 2U : 1U;
3753 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_43();
3754
3755 /* for adding or updating gate control list, we'll have to remove the gate control list firstly */
3756 for (OperationTimeIdx = 0U; OperationTimeIdx < OperationTimes; OperationTimeIdx++)
3757 {
3758
3759 /* ++++++ initialize the table request data buffer ++++++ */
3760 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U); /* fill in Actions field */
3761 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = TimeGateSchedulingTableEntry->TimeGateSchedulingTable_EID; /* fill in Entry ID */
3762 /* fill in CFGE_DATA */
3763 /* get the current time from 1588 timer */
3764 CurrentTime = IP_NETC__TMR0_BASE->TMR_CUR_TIME_L; /* should read the Lower register first */
3765 CurrentTime |= ((uint64)(IP_NETC__TMR0_BASE->TMR_CUR_TIME_H)) << NETC_ETHSWT_IP_32BIT_SHIFT;
3766 /* get lookaheadtime */
3767 LookaheadTime = IP_NETC__NETC_IERB->CFG_SW_INST[0U].STGSLR; /* [Ricky]TODO: this register is not available for now + Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->RESERVED_7; */
3768
3769 /* calculate the NewBaseTime */
3770 if (TimeGateSchedulingTableEntry->AdminBaseTime >= (CurrentTime + LookaheadTime))
3771 {
3772 NewBaseTime = TimeGateSchedulingTableEntry->AdminBaseTime;
3773 }
3774 else
3775 {
3776 CycleFactor = (uint32)(CurrentTime + LookaheadTime - TimeGateSchedulingTableEntry->AdminBaseTime) / (TimeGateSchedulingTableEntry->AdminCycleTime);
3777 NewBaseTime = TimeGateSchedulingTableEntry->AdminBaseTime + (((uint64)CycleFactor + 1UL) * (uint64)(TimeGateSchedulingTableEntry->AdminCycleTime));
3778 }
3779 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = (uint32)(NewBaseTime & (NETC_ETHSWT_IP_BD_NULL_ENTRY_ID));
3780 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = (uint32)(NewBaseTime >> NETC_ETHSWT_IP_32BIT_SHIFT);
3781 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = TimeGateSchedulingTableEntry->AdminCycleTime;
3782 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = TimeGateSchedulingTableEntry->AdminCycleTimeExt;
3783 /* set Administrative Control List Length to 0 for removing the admin gate control list or adding an entry with no administrative gate control list */
3784 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = (OperationTimeIdx == 0U) ? 0x0UL : (uint32)(TimeGateSchedulingTableEntry->AdminControlListLength);
3785
3786 Netc_EthSwt_Ip_FillInGateControlListData(&OperationTimeIdx, TimeGateSchedulingTableEntry);
3787 /* ------ initialize the table request data buffer ------ */
3788
3789 /* fill in operation data for config field of Request Header*/
3790 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3791 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3792 OperationData.TableId = NETC_ETHSWT_IP_TIME_GATE_SCHEDULING_TABLE_ID;
3793 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support NETC_ETHSWT_ENTRY_ID_MATCH method */
3794 OperationData.Cmd = NETC_ETHSWT_UPDATE_CMD; /* can only use "update" command to add or update an time gate scheduling table entry */
3795 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_REQBUFFER_LEN); /* [Ricky]TODO: follow-up work needs to do. */
3796 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TGSTABLE_RSPBUFFER_LEN);
3797
3798 /* send "update" command to add/remove gate control list */
3799 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
3800 #if defined(ERR_IPV_NETC_051243)
3801 #if (STD_ON == ERR_IPV_NETC_051243)
3802 /* Error code 0x8A is not a real error. check it on Errata. */
3803 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
3804 {
3805 #endif
3806 #else
3807 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
3808 {
3809 #endif
3810 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
3811 }
3812 }
3813 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_43();
3814
3815 return status;
3816 }
3817
3818 /*!
3819 * @brief : Function for accessing 64 bits counters.
3820 * @details : Function for extracting the counter value using base/offset
3821 *
3822 * @param[in] baseAddressValue base address in uint32
3823 * @param[in] offsetAddressValue offset from the base
3824 *
3825 * @return Register value
3826 */
3827 static inline uint64 Netc_EthSwt_Ip_Extract64bitsFrom32bitsReg(const uint32 baseAddressValue, const uint32 offsetAddressValue)
3828 {
3829 uint32 lessSignificantPtrValue;
3830 const volatile uint32 *ptrToLessSignificantData;
3831 uint64 lessSignificantAddressData, mostSignificantAddressData;
3832
3833 /* The 64bits counter are in two chunk of 32bits */
3834 /* We will need to make some arithmitic on the pointers */
3835
3836 /* The most significant is higher in memory, the next address to get the next 32 bits */
3837 lessSignificantPtrValue = baseAddressValue + offsetAddressValue;
3838
3839 /* Convert back the numbers in pointers */
3840 ptrToLessSignificantData = (volatile uint32 *) lessSignificantPtrValue;
3841 #if defined(ERR_IPV_NETC_050679)
3842 /*
3843 Workaround for ERR050679:
3844 Accesses to 64-bit stats registers must be performed atomically
3845 */
3846 #if (STD_ON == ERR_IPV_NETC_050679)
3847 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_00();
3848 #endif
3849 #endif
3850
3851 /* Extract the two 32 bits of data, lower address must be read first, this will lock the higher part */
3852 /* Note that there is only one higher value buffer, should be exclusive... semaphore, what about the other cores? High level problem to be aware of */
3853 lessSignificantAddressData = ptrToLessSignificantData[0U]; /* must be first */
3854 mostSignificantAddressData = ptrToLessSignificantData[1U];
3855
3856 #if defined(ERR_IPV_NETC_050679)
3857 #if (STD_ON == ERR_IPV_NETC_050679)
3858 /*
3859 Workaround for ERR050679:
3860 Accesses to 64-bit stats registers must be performed atomically
3861 */
3862 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_00();
3863 #endif
3864 #endif
3865
3866 /* putting it all together */
3867 return ((mostSignificantAddressData << NETC_ETHSWT_IP_32BIT_SHIFT) | lessSignificantAddressData);
3868 }
3869
3870 /*!
3871 * @brief : Function for accessing 64 bits counters in a table.
3872 * @details : Function for getting the 64 bits counters using two 32 bits accesses.
3873 *
3874 * @param[in] Reg 64bits register pointer
3875 *
3876 * @return Register value
3877 */
3878 static inline uint64 Netc_EthSwt_Ip_GetCounterLocal(const volatile uint64 *Reg)
3879 {
3880 return Netc_EthSwt_Ip_Extract64bitsFrom32bitsReg((uint32) Reg, 0U);
3881 }
3882
3883 /*!
3884 * @brief Ethernet Switch get port index counter values function.
3885 *
3886 * @param[in] SwitchIdx
3887 * @param[in] PortIndex
3888 * @param[in] Counter
3889 *
3890 * @return Std Error
3891 */
3892 static Std_ReturnType Netc_EthSwt_Ip_GetSwtPortCounters( uint8 SwitchIdx, uint8 PortIndex, Netc_EthSwt_Ip_CounterType *Counter )
3893 {
3894 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
3895 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3896 #endif
3897
3898 (void)SwitchIdx;
3899
3900 /* Receive */
3901 /* Port MAC index Receive Ethernet Octets Counter(etherStatsOctetsn) */
3902 Counter->rxEtherOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_REOCTN));
3903
3904
3905 /* Port MAC index Receive Octets Counter(iflnOctetsn) */
3906 Counter->rxOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_ROCTN));
3907
3908 /* Port MAC index Receive Alignment Error Counter Register(aAlignmentErrorsn) */
3909 /* Reserved */
3910
3911 /* Port MAC index Receive Valid Pause Frame Counter Register(aPAUSEMACCtrlFramesReceivedn) */
3912 Counter->rxValidPauseFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RXPFN);
3913
3914 /* Port MAC index Receive Frame Counter */
3915 Counter->rxFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RFRMN);
3916
3917 /* Port MAC index Receive Frame Check Sequence Error Counter */
3918 Counter->rxFrameCheckSequenceErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RFCSN);
3919
3920 /* Port MAC index Receive VLAN Frame Counter */
3921 Counter->rxVlanFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RVLANN);
3922
3923 /* Port MAC index Receive Frame Error Counter Register(ifInErrorsn) */
3924 Counter->rxFrameErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RERRN);
3925
3926 /* Port MAC index Receive Unicast Frame Counter */
3927 Counter->rxUnicastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RUCAN);
3928
3929 /* Port MAC index Receive Multicast Frame Counter */
3930 Counter->rxMulticastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RMCAN);
3931
3932 /* Port MAC index Receive Broadcast Frame Counter */
3933 Counter->rxBroadcastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RBCAN);
3934
3935 /* Port MAC index Receive Dropped Packets Counter Register(etherStatsDropEventsn) */
3936 Counter->rxDroppedPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RDRPN);
3937
3938 /* Port MAC index Receive Packets Counter Register(etherStatsPktsn) */
3939 Counter->rxPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RPKTN);
3940
3941 /* Port MAC index Receive Undersized Packet Counter */
3942 Counter->rxUndersizePacketCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RUNDN);
3943
3944 /* Port MAC index Receive 64-Octet Packet Counter Register(etherStatsPkts64OctetsN) */
3945 Counter->rx64OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R64N);
3946
3947 /* Port MAC index Receive 65 to 127-Octet Packet Counter Register(etherStatsPkts65to127OctetsN) */
3948 Counter->rx65to127OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R127N);
3949
3950 /* Port MAC index Receive 128 to 255-Octet Packet Counter Register(etherStatsPkts128to255OctetsN) */
3951 Counter->rx128to255OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R255N);
3952
3953 /* Port MAC index Receive 256 to 511-Octet Packet Counter Register(etherStatsPkts256to511OctetsN) */
3954 Counter->rx256to511OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R511N);
3955
3956 /* Port MAC index Receive 512 to 1023-Octet Packet Counter Register(etherStatsPkts512to1023OctetsN) */
3957 Counter->rx512to1023OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R1023N);
3958
3959 /* Port MAC index Receive 1024 to 1522-Octet Packet Counter Register(etherStatsPkts1024to1522OctetsN) */
3960 Counter->rx1024to1522OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R1522N);
3961
3962 /* Port MAC index Receive 1523 to Max-Octet Packet Counter Register(etherStatsPkts1523toMaxOctetsN) */
3963 Counter->rx1523toMaxOctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R1523XN);
3964
3965 /* Port MAC index Receive Oversized Packet Counter */
3966 Counter->rxOversizedPacketsCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_ROVRN);
3967
3968 /* Port MAC index Receive Jabber Packet Counter Register(etherStatsJabbersn) */
3969 Counter->rxJabberPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RJBRN);
3970
3971 /* Port MAC index Receive Fragment Packet Counter Register(etherStatsFragmentsn) */
3972 Counter->rxFragmentPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RFRGN);
3973
3974 /* Port MAC index Receive Control Packet Counter Register */
3975 Counter->rxControlPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RCNPN);
3976
3977 /* Port MAC index Receive Dropped Not Truncated Packets Counter Register(etherStatsDropEventsn) */
3978 Counter->rxDroppedNTruncatedPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RDRNTPN);
3979
3980 /* Port Rx discard count register */
3981 Counter->rxDiscardCounter = Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PRXDCR;
3982
3983 /* Transmit */
3984 /* Port MAC index Transmit Ethernet Octets Counter(etherStatsOctetsn) */
3985 Counter->txEtherOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TEOCTN);
3986
3987 /* Port MAC index Transmit Octets Counter Register(ifOutOctetsn) */
3988 Counter->txOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TOCTN);
3989
3990 /* Port MAC index Transmit Valid Pause Frame Counter Register(aPAUSEMACCtrlFramesReceivedn) */
3991 Counter->txValidPauseFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TXPFN);
3992
3993 /* Port MAC index Transmit Frame Counter */
3994 Counter->txFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TFRMN);
3995
3996 /* Port MAC index Transmit Frame Check Sequence Error Counter */
3997 Counter->txFrameCheckSequenceErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TFCSN);
3998
3999 /* Port MAC index Transmit VLAN Frame Counter */
4000 Counter->txVlanFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TVLANN);
4001
4002 /* Port MAC index Transmit Frame Error Counter Register(ifOutErrorsn) */
4003 Counter->txFrameErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TERRN);
4004
4005 /* Port MAC index Transmit Unicast Frame Counter */
4006 Counter->txUnicastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TUCAN);
4007
4008 /* Port MAC index Transmit Multicast Frame Counter */
4009 Counter->txMulticastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TMCAN);
4010
4011 /* Port MAC index Transmit Broadcast Frame Counter */
4012 Counter->txBroadcastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TBCAN);
4013
4014 /* Port MAC index Transmit Packets Counter Register(etherStatsPktsN; */
4015 Counter->txPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TPKTN);
4016
4017 /* Port MAC index Transmit Undersized Packet Counter */
4018 Counter->txUndersizePacketCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TUNDN);
4019
4020 /* Port MAC index Transmit 64-Octet Packet Counter Register (etherStatsPkts64OctetsN) */
4021 Counter->tx64OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T64N);
4022
4023 /* Port MAC index Transmit 65 to 127-Octet Packet Counter Register (etherStatsPkts65to127OctetsN) */
4024 Counter->tx65to127OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T127N);
4025
4026 /* Port MAC index Transmit 128 to 255-Octet Packet Counter Register (etherStatsPkts128to255OctetsN) */
4027 Counter->tx128to255OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T255N);
4028
4029 /* Port MAC index Transmit 256 to 511-Octet Packet Counter Register (etherStatsPkts256to511OctetsN) */
4030 Counter->tx256to511OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T511N);
4031
4032 /* Port MAC index Transmit 512 to 1023-Octet Packet Counter Register (etherStatsPkts512to1023OctetsN) */
4033 Counter->tx512to1023OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T1023N);
4034
4035 /* Port MAC index Transmit 1024 to 1522-Octet Packet Counter Register (etherStatsPkts1024to1522OctetsN) */
4036 Counter->tx1024to1522OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T1522N);
4037
4038 /* Port MAC index Transmit 1523 to TX_MTU-Octet Packet Counter Register (etherStatsPkts1523toMaxOctetsN) */
4039 Counter->tx1523toMaxOctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T1523XN);
4040
4041 /* Port MAC index Transmit Control Packet Counter Register */
4042 Counter->txControlPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TCNPN);
4043
4044 /* Port MAC index Transmit Deferred Packet Counter Register(aFramesWithDeferredXmissions) */
4045 Counter->txDeferredPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TDFRN);
4046
4047 /* Port MAC index Transmit Multiple Collisions Counter Register */
4048 Counter->txMultiCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TMCOLN);
4049
4050 /* Port MAC index Transmit Single Collision Counter Register */
4051 Counter->txSingleCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TSCOLN);
4052
4053 /* Port MAC index Transmit Late Collision Counter(aLateCollisions) Register */
4054 Counter->txLateCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TLCOLN);
4055
4056 /* Port MAC index Transmit Excessive Collisions Counter Register */
4057 Counter->txExcessiveCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TECOLN);
4058
4059 #if defined(ERR_IPV_NETC_E051023)
4060 #if (STD_ON == ERR_IPV_NETC_E051023)
4061 /* ERR051023: NETC: Excessive collisions are counted as late collisions */
4062 Counter->txLateCollisionCounter -= Counter->txExcessiveCollisionCounter;
4063 #endif
4064 #endif
4065
4066 /* Port Tx discard count register */
4067 Counter->txDiscardCounter = Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PTXDCR;
4068
4069 #if defined(ERR_IPV_NETC_E051129)
4070 #if (STD_ON == ERR_IPV_NETC_E051129)
4071 /* Errata ERR051129: Uncorrectable non-fatal integrity error count register */
4072 Counter->unIntegrityErrorCounter = IP_NETC__SW0_COMMON->UNIECTR;
4073 Counter->unIntegrityErrorCounter &= ((uint32)NETC_F2_COMMON_UNIECTR_COUNT_MASK);
4074 #endif
4075 #endif
4076
4077 return E_OK;
4078 }
4079
4080 /*!
4081 * @brief Ethernet Switch get pseudo port counter values function.
4082 *
4083 * @param[in]
4084 * @param[out]
4085 * @return
4086 */
4087 static Std_ReturnType Netc_EthSwt_Ip_GetSwtPseudoPortCounters( uint8 SwitchIdx, uint8 SwitchPortIdx, Netc_EthSwt_Ip_CounterType *Counter )
4088 {
4089 uint32 xCR0Value;
4090 uint8 PseudoPortIdx;
4091
4092 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
4093 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4094 #endif
4095
4096 (void)SwitchIdx;
4097
4098 /* pseudo port indexes are starting after the mac ports. */
4099 PseudoPortIdx = SwitchPortIdx - NETC_ETHSWT_NUMBER_OF_MAC_PORTS;
4100
4101 /* Receive */
4102 /* Port pseudo MAC receive octets counter */
4103 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMROCR[0];
4104 Counter->rxOctetCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMROCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
4105 /* Port pseudo MAC receive unicast frame counter register */
4106 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRUFCR[0];
4107 Counter->rxUnicastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRUFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
4108 /* Port pseudo MAC receive multicast frame counter register */
4109 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRMFCR[0];
4110 Counter->rxMulticastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRMFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
4111 /* Port pseudo MAC receive broadcast frame counter register */
4112 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRBFCR[0];
4113 Counter->rxBroadcastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRBFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
4114
4115 /* unsupported rx counters */
4116 Counter->rxPktCounter = 0xFFFFFFFFFFFFFFFFU;
4117 Counter->rxFrmCounter = 0xFFFFFFFFFFFFFFFFU;
4118 Counter->rxVlanFrmCounter = 0xFFFFFFFFFFFFFFFFU;
4119 Counter->rxFrameErrorCounter = 0xFFFFFFFFFFFFFFFFU;
4120 Counter->rxUndersizePacketCounter = 0xFFFFFFFFFFFFFFFFU;
4121 Counter->rxOversizedPacketsCounter = 0xFFFFFFFFFFFFFFFFU;
4122 Counter->rxFrameCheckSequenceErrorCounter = 0xFFFFFFFFFFFFFFFFU;
4123 Counter->rxEtherOctetCounter = 0xFFFFFFFFFFFFFFFFU;
4124 Counter->rxValidPauseFrmCounter = 0xFFFFFFFFFFFFFFFFU;
4125 Counter->rxDroppedPktCounter = 0xFFFFFFFFFFFFFFFFU;
4126 Counter->rx64OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4127 Counter->rx65to127OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4128 Counter->rx128to255OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4129 Counter->rx256to511OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4130 Counter->rx512to1023OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4131 Counter->rx1024to1522OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4132 Counter->rx1523toMaxOctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4133 Counter->rxJabberPktCounter = 0xFFFFFFFFFFFFFFFFU;
4134 Counter->rxFragmentPktCounter = 0xFFFFFFFFFFFFFFFFU;
4135 Counter->rxControlPktCounter = 0xFFFFFFFFFFFFFFFFU;
4136 Counter->rxDroppedNTruncatedPktCounter = 0xFFFFFFFFFFFFFFFFU;
4137
4138 /* Port Rx discard count register */
4139 Counter->rxDiscardCounter = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PRXDCR;
4140
4141 /* Transmit */
4142 /* Port pseudo MAC transmit octets counter */
4143 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTOCR[0];
4144 Counter->txOctetCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTOCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
4145 /* Port pseudo MAC transmit unicast frame counter register */
4146 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTUFCR[0];
4147 Counter->txUnicastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTUFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
4148 /* Port pseudo MAC transmit multicast frame counter register */
4149 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTMFCR[0];
4150 Counter->txMulticastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTMFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
4151 /* Port pseudo MAC transmit broadcast frame counter register */
4152 xCR0Value = IP_NETC__SW0_PSEUDO_MAC_PORT2->PPMTBFCR[0];
4153 Counter->txBroadcastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTBFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
4154
4155 /* Port Tx discard count register */
4156 Counter->txDiscardCounter = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PTXDCR;
4157
4158 /* unsupported tx counters */
4159 Counter->txPktCounter = 0xFFFFFFFFFFFFFFFFU;
4160 Counter->txFrmCounter = 0xFFFFFFFFFFFFFFFFU;
4161 Counter->txVlanFrmCounter = 0xFFFFFFFFFFFFFFFFU;
4162 Counter->txFrameErrorCounter = 0xFFFFFFFFFFFFFFFFU;
4163 Counter->txUndersizePacketCounter = 0xFFFFFFFFFFFFFFFFU;
4164 Counter->txSingleCollisionCounter = 0xFFFFFFFFFFFFFFFFU;
4165 Counter->txMultiCollisionCounter = 0xFFFFFFFFFFFFFFFFU;
4166 Counter->txFrameCheckSequenceErrorCounter = 0xFFFFFFFFFFFFFFFFU;
4167
4168 Counter->txEtherOctetCounter = 0xFFFFFFFFFFFFFFFFU;
4169 Counter->txValidPauseFrmCounter = 0xFFFFFFFFFFFFFFFFU;
4170 Counter->tx64OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4171 Counter->tx65to127OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4172 Counter->tx128to255OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4173 Counter->tx256to511OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4174 Counter->tx512to1023OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4175 Counter->tx1024to1522OctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4176 Counter->tx1523toMaxOctetPktCounter = 0xFFFFFFFFFFFFFFFFU;
4177 Counter->txControlPktCounter = 0xFFFFFFFFFFFFFFFFU;
4178 Counter->txDeferredPktCounter = 0xFFFFFFFFFFFFFFFFU;
4179 Counter->txLateCollisionCounter = 0xFFFFFFFFFFFFFFFFU;
4180 Counter->txExcessiveCollisionCounter = 0xFFFFFFFFFFFFFFFFU;
4181
4182 #if defined(ERR_IPV_NETC_E051129)
4183 #if (STD_ON == ERR_IPV_NETC_E051129)
4184 /* Errata ERR051129: Uncorrectable non-fatal integrity error count register */
4185 Counter->unIntegrityErrorCounter = IP_NETC__SW0_COMMON->UNIECTR & NETC_F2_COMMON_UNIECTR_COUNT_MASK;
4186 #endif
4187 #endif
4188 return E_OK;
4189 }
4190
4191 /*FUNCTION**********************************************************************
4192 *
4193 * Function Name : Netc_EthSwt_Ip_EnableVlan
4194 * Description : Ethernet switch enable VLAN function.
4195 * implements Netc_EthSwt_Ip_EnableVlan_Activity
4196 *END**************************************************************************/
4197 Std_ReturnType Netc_EthSwt_Ip_EnableVlan( uint8 SwitchIdx, uint8 SwitchPortIdx, uint16 VlanId, boolean Enable )
4198 {
4199 Std_ReturnType Status = E_OK;
4200 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_CBDRSTATUS_SUCCES;
4201 Netc_EthSwt_Ip_VlanFilterEntryDataType VlanFilterTableEntry;
4202 uint32 MatchedEntries = 0U;
4203
4204 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
4205 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4206 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
4207 #endif
4208
4209 /* Query the entry with VlanId */
4210 VlanFilterTableEntry.VlanID = VlanId;
4211 CBDRStatus = Netc_EthSwt_Ip_QueryVlanFilterTableEntry(SwitchIdx, &MatchedEntries, &VlanFilterTableEntry);
4212 if ((CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES) || (MatchedEntries == 0U))
4213 {
4214 Status = E_NOT_OK; /* Query command error or no mached Vlan ID entry found */
4215 }
4216 else
4217 {
4218 /* Get the CFGE data of a mached entry */
4219 VlanFilterTableEntry.SpanningTreeGroupMemberId = (uint8)((TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA0] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_STG_ID_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_STG_ID_SHIFT);
4220 VlanFilterTableEntry.PortMembershipBitmap = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA0] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_PORT_MEMBERSHIP_MASK;
4221 VlanFilterTableEntry.IpMulticastFloodingEnable = (((TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFLE_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFLE_SHIFT) != 0x0UL) ? TRUE : FALSE;
4222 VlanFilterTableEntry.IpMulticastFilteringEnable = (((TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFE_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFE_SHIFT) != 0x0UL) ? TRUE : FALSE;
4223 VlanFilterTableEntry.MacForwardingOptions = (uint8)((TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MFO_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MFO_SHIFT);
4224 VlanFilterTableEntry.MacLearningOptions = (uint8)((TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MLO_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MLO_SHIFT);
4225 VlanFilterTableEntry.FID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_FID_MASK);
4226 VlanFilterTableEntry.EgressTreatmentApplicabilityPortBitmap = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA2] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_ETA_PORT_BITMAP_MASK;
4227 VlanFilterTableEntry.BaseEgressTreatmentEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA3] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_BASE_ET_EID_MASK;
4228
4229 /* Modify port membership bitmap data */
4230 if (TRUE == Enable)
4231 {
4232 VlanFilterTableEntry.PortMembershipBitmap |= (uint32)(0x1UL << SwitchPortIdx); /* add the port to the portmembershipbitmap */
4233 }
4234 else
4235 {
4236 VlanFilterTableEntry.PortMembershipBitmap &= ~((uint32)(0x1UL << SwitchPortIdx)); /* remove the port from the portmembershipbitmap */
4237 }
4238
4239 /* Update the entry */
4240 VlanFilterTableEntry.VlanID = VlanId;
4241 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry(SwitchIdx, NETC_ETHSWT_UPDATE_CMD, &MatchedEntries, &VlanFilterTableEntry);
4242 if (CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES)
4243 {
4244 Status = E_NOT_OK; /* Update command error */
4245 }
4246
4247 }
4248
4249 return Status;
4250 }
4251 /*FUNCTION**********************************************************************
4252 *
4253 * Function Name : Netc_EthSwt_Ip_ResetConfiguration
4254 * Description : Ethernet switch reset configuration function.
4255 * implements Netc_EthSwt_Ip_ResetConfiguration_Activity
4256 *END**************************************************************************/
4257 Std_ReturnType Netc_EthSwt_Ip_ResetConfiguration(uint8 SwitchIdx)
4258 {
4259 /*
4260 * [notes]: implemented this function with singel delete command and Search Method.
4261 */
4262 Std_ReturnType status = E_OK;
4263 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
4264 uint32 ActionsData;
4265 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData;
4266
4267 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
4268 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4269 #endif
4270
4271 /* set the query options with ENTRY_ID only query */
4272 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(1U) \
4273 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U) \
4274 | NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(0U) \
4275 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U);
4276 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_45();
4277
4278 /*+++ fill in FdbTabeDataBuffer for Request Data Buffer +++ */
4279 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in the Actions field */
4280 /* fill in Access Key data field with search criteria data format */
4281 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_RESUMEENTRYID] = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID; /* resume entry id */
4282 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MACADDRESS_L] = 0U; /* clear other unuse data field */
4283 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MACADDRESS_H] = 0U; /* clear other unuse data field */
4284 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_FID] = 0U; /* clear other unuse data field */
4285 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_PORTBITMAP] = 0U; /* clear other unuse data field */
4286 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_CFGECONFIG] = NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC(1U); /* set CFGE_DATA[DYNAMIC] to 0x1 meaning it will match dynamic entries */
4287 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ETEID] = 0U; /* clear other unuse data field */
4288 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_CFGEMC(1U); /* 0x1: Match CFGE_DATA[DYNAMIC] field */
4289 /*--- fill in FdbTabeDataBuffer for Request Data Buffer --- */
4290 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_45();
4291
4292 /* fill in operation data for config field of Request Header*/
4293 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
4294 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
4295 OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
4296 OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD; /* delete all matched entries with Search Method */
4297 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
4298 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN);
4299 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
4300
4301 /* send the "Delete" command */
4302 CBDRStatus = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
4303 if (CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES)
4304 {
4305 status = E_NOT_OK;
4306 }
4307
4308 return status;
4309 }
4310
4311 static inline Std_ReturnType Netc_EthSwt_Ip_SearchAndFIllInVlanFilterTableEntry(uint32 * ResumeId,
4312 uint16 * NumOfExistingEntry,
4313 Netc_EthSwt_Ip_VlanFilterEntryDataType * VlanFilterTableEntry)
4314 {
4315 Std_ReturnType status = E_OK;
4316 uint32 ActionsData;
4317 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
4318 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
4319 uint32 NumOfElement = 0U;
4320 uint32 CfgeData;
4321
4322 /* set the query options with full query */
4323 ActionsData = (NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
4324 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U));
4325
4326 /* fill in TabeDataBuffer for request */
4327 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData;
4328 /* fill in Access Key data with search criteria data format */
4329 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_REQFMT_RESUMEENTRYID_FIELD] = *ResumeId; /* resume entry id */
4330
4331 /* do the full query with Search Method */
4332 /* fill in operation data for config field of Request Header*/
4333 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
4334 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
4335 OperationData.TableId = NETC_ETHSWT_IP_VLAN_FILTER_TABLE_ID;
4336 OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
4337 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
4338 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
4339 OperationData.RspBuffLength = (NETC_ETHSWT_IP_VLANFILTERTABLE_RESBUFFER_LEN); /* full query needs more space for response data */
4340
4341 /* send the "Query" command */
4342 /* [notes]: there is an error "0x8A" in NTMP response header during this query operation but it is not a real error. there should be another errata for "0x8A" later. */
4343 CBDRStatus = Netc_EthSwt_Ip_SendCommand(0U, NETC_ETHSWT_IP_CBDR_0, &OperationData);
4344
4345 #if defined(ERR_IPV_NETC_051243)
4346 #if (STD_ON == ERR_IPV_NETC_051243)
4347 /* check the status of query command */
4348 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES))
4349 {
4350 #endif
4351 #else
4352 if (CBDRStatus == NETC_ETHSWT_CBDRSTATUS_SUCCES)
4353 {
4354 #endif
4355 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
4356
4357 /* get the resume_entry_id and be ready for the next query operation */
4358 *ResumeId = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABLE_RSPDATA_STATUS];
4359 /* ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED */
4360 /* found a matched entry */
4361 if ((1U == NumOfElement) && (*ResumeId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
4362 {
4363 /* fill in "Netc_EthSwt_Ip_VlanFilterEntryDataType" structure with data in response data buffer */
4364 VlanFilterTableEntry->VlanID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_VID] & NETC_ETHSWT_VLANFILTERTABLE_KEYEDATA_VID_MASK);
4365
4366 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA0];
4367 VlanFilterTableEntry->SpanningTreeGroupMemberId = (uint8)((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_STG_ID_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_STG_ID_SHIFT);
4368 VlanFilterTableEntry->PortMembershipBitmap = (CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_PORT_MEMBERSHIP_MASK);
4369
4370 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1];
4371 VlanFilterTableEntry->FID = (uint16)(CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_FID_MASK);
4372 VlanFilterTableEntry->MacLearningOptions = (uint8)((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MLO_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MLO_SHIFT);
4373 VlanFilterTableEntry->MacForwardingOptions = (uint8)((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MFO_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_MFO_SHIFT);
4374 VlanFilterTableEntry->IpMulticastFilteringEnable = (((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFE_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFE_SHIFT) == 0x0UL) ? FALSE : TRUE;
4375 VlanFilterTableEntry->IpMulticastFloodingEnable = (((CfgeData & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFLE_MASK) >> NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_IPMFLE_SHIFT) == 0x0UL) ? FALSE : TRUE;
4376
4377 VlanFilterTableEntry->EgressTreatmentApplicabilityPortBitmap = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA2] & NETC_ETHSWT_VLANFILTERTABLE_CFGEDATA_ETA_PORT_BITMAP_MASK;
4378 VlanFilterTableEntry->BaseEgressTreatmentEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA3];
4379 /* increase the NumOfExistingEntry */
4380 (*NumOfExistingEntry) += 1U;
4381 }
4382 }
4383 else
4384 {
4385 status = E_NOT_OK;
4386 }
4387
4388 return status;
4389 }
4390
4391 static inline Std_ReturnType Netc_EthSwt_Ip_SyncVlanFilterTableMLO( uint8 SwitchIdx,
4392 Netc_EthSwt_Ip_MacLearningOptionType MacLearningMode
4393 )
4394 {
4395 Std_ReturnType status = E_OK;
4396 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_CBDRSTATUS_SUCCES;
4397
4398 uint16 NumOfExistingEntry = 0U;
4399 static uint16 NumOfInUseEntry;
4400 uint32 ResumeId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
4401 Netc_EthSwt_Ip_VlanFilterEntryDataType VlanFilterTableEntry;
4402 Netc_EthSwt_Ip_CommandsType Cmd = NETC_ETHSWT_UPDATE_CMD;
4403 uint32 MatchedEntries;
4404
4405 /* [notes]: we will have to read entries one by one because of the errata ERR051048.
4406 - ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED
4407 - Description: The NUM_MATCHED field in the command NTMP response header may be incorrect when
4408 the search access method is used for the following tables: FDB table 15, L2 IPv4 Multicast
4409 Filter table 16, VLAN Filter table 18, Ingress Stream Identification table 30, or Ingress Stream
4410 Filter table 32.
4411 - Workaround: For the query command, limit the message response buffer size (RESPONSE_LENGTH field in the request header)
4412 so that NETC returns no more than one entry at a time. Under this condition, the NUM_MATCHED field value is correct
4413 */
4414
4415 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
4416 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4417 #endif
4418
4419 (void)SwitchIdx;
4420 /* Number of entries in-use by the VLAN Filter table is indicated in VFHTOR[NUM_ENTRIES]. */
4421 NumOfInUseEntry = (uint16)(IP_NETC__SW0_BASE->VFHTOR & NETC_ETHSWT_IP_0XFFFF_MASK); /* get how many entries exist in module */
4422
4423 /* if NumOfInUseEntry == 0U, return the NumOfInUseEntry directly and will not do the query and fill in the structure */
4424 if (NumOfInUseEntry == 0U)
4425 {
4426 NumOfExistingEntry = NumOfInUseEntry;
4427 }
4428 else /* if *NumberOfElements > 0, do the query and fill in the structure */
4429 {
4430 do {
4431 /* check if the VlanFilterTableList is full or we get all existing entries */
4432 if ((NumOfExistingEntry >= NumOfInUseEntry) || (status == (uint8)(E_NOT_OK)))
4433 {
4434 break;
4435 }
4436
4437 status = Netc_EthSwt_Ip_SearchAndFIllInVlanFilterTableEntry((uint32 *) &ResumeId, (uint16 *) &NumOfExistingEntry, &VlanFilterTableEntry);
4438
4439 if(E_OK == status)
4440 {
4441 /*Update MLO, for the current entry, if necessary*/
4442 if(VlanFilterTableEntry.MacLearningOptions != (uint8)MacLearningMode)
4443 {
4444 VlanFilterTableEntry.MacLearningOptions = (uint8)MacLearningMode;
4445 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry( SwitchIdx, Cmd, (uint32 *) &MatchedEntries, (const Netc_EthSwt_Ip_VlanFilterEntryDataType *) &VlanFilterTableEntry );
4446 if (NETC_ETHSWT_CBDRSTATUS_SUCCES != CBDRStatus)
4447 {
4448 status = E_NOT_OK;
4449 }
4450 }
4451 }
4452
4453
4454 } while (TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABLE_RSPDATA_STATUS] != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID); /* Status == MAX_32BIT means the query operation is completed */
4455 }
4456
4457 return status;
4458 }
4459
4460 /*FUNCTION**********************************************************************
4461 *
4462 * Function Name : Netc_EthSwt_Ip_SetMacLearningMode
4463 * Description : Ethernet switch set MAC learning mode function.
4464 * implements Netc_EthSwt_Ip_SetMacLearningMode_Activity
4465 *END**************************************************************************/
4466 Std_ReturnType Netc_EthSwt_Ip_SetMacLearningMode( uint8 SwitchIdx,
4467 Netc_EthSwt_Ip_MacLearningOptionType MacLearningMode
4468 )
4469 {
4470 Std_ReturnType status;
4471 uint32 MacLearningOption;
4472
4473 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
4474 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4475 #endif
4476
4477 (void)SwitchIdx;
4478
4479 MacLearningOption = IP_NETC__SW0_BASE->VFHTDECR2;
4480 MacLearningOption &= ~NETC_F2_VFHTDECR2_MLO_MASK;
4481
4482 status = Netc_EthSwt_Ip_SyncVlanFilterTableMLO(SwitchIdx, MacLearningMode);
4483
4484 if (E_OK == status)
4485 {
4486 switch (MacLearningMode)
4487 {
4488 case ETHSWT_MACLEARNINGOPTION_HWDISABLED:
4489 MacLearningOption |= NETC_F2_VFHTDECR2_MLO(ETHSWT_MACLEARNINGOPTION_HWDISABLED);
4490 break;
4491 case ETHSWT_MACLEARNINGOPTION_HWENABLED:
4492 MacLearningOption |= NETC_F2_VFHTDECR2_MLO(ETHSWT_MACLEARNINGOPTION_HWENABLED);
4493 break;
4494 case ETHSWT_MACLEARNINGOPTION_SWSECUREENABLED:
4495 MacLearningOption |= NETC_F2_VFHTDECR2_MLO(ETHSWT_MACLEARNINGOPTION_SWSECUREENABLED);
4496 break;
4497 case ETHSWT_MACLEARNINGOPTION_SWUNSECUREENABLED:
4498 MacLearningOption |= NETC_F2_VFHTDECR2_MLO(ETHSWT_MACLEARNINGOPTION_SWUNSECUREENABLED);
4499 break;
4500 case ETHSWT_MACLEARNINGOPTION_DISABLEDWITHSWVALIDATION:
4501 MacLearningOption |= NETC_F2_VFHTDECR2_MLO(ETHSWT_MACLEARNINGOPTION_DISABLEDWITHSWVALIDATION);
4502 break;
4503 default:
4504 /* log error */
4505 status = E_NOT_OK;
4506 break;
4507 }
4508 }
4509
4510 IP_NETC__SW0_BASE->VFHTDECR2 = MacLearningOption;
4511
4512 return status;
4513 }
4514
4515 /*FUNCTION**********************************************************************
4516 *
4517 * Function Name : Netc_EthSwt_Ip_GetMacLearningMode
4518 * Description : Ethernet switch get MAC learning mode function.
4519 * implements Netc_EthSwt_Ip_GetMacLearningMode_Activity
4520 *END**************************************************************************/
4521 Std_ReturnType Netc_EthSwt_Ip_GetMacLearningMode( uint8 SwitchIdx,
4522 Netc_EthSwt_Ip_MacLearningOptionType * MacLearningMode
4523 )
4524 {
4525 Std_ReturnType status = E_OK;
4526 uint32 MacLearningOption;
4527
4528 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
4529 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4530 DevAssert(MacLearningMode != NULL_PTR);
4531 #endif
4532
4533 (void)SwitchIdx;
4534
4535 MacLearningOption = IP_NETC__SW0_BASE->VFHTDECR2;
4536 MacLearningOption = ((MacLearningOption & NETC_F2_VFHTDECR2_MLO_MASK) >> NETC_F2_VFHTDECR2_MLO_SHIFT);
4537 switch (MacLearningOption)
4538 {
4539 case 0x1UL:
4540 *MacLearningMode = ETHSWT_MACLEARNINGOPTION_HWDISABLED;
4541 break;
4542 case 0x2UL:
4543 *MacLearningMode = ETHSWT_MACLEARNINGOPTION_HWENABLED;
4544 break;
4545 case 0x3UL:
4546 *MacLearningMode = ETHSWT_MACLEARNINGOPTION_SWSECUREENABLED;
4547 break;
4548 case 0x4UL:
4549 *MacLearningMode = ETHSWT_MACLEARNINGOPTION_SWUNSECUREENABLED;
4550 break;
4551 case 0x5UL:
4552 *MacLearningMode = ETHSWT_MACLEARNINGOPTION_DISABLEDWITHSWVALIDATION;
4553 break;
4554 default:
4555 /* log error */
4556 status = E_NOT_OK;
4557 break;
4558 }
4559
4560 return status;
4561 }
4562
4563 /*FUNCTION**********************************************************************
4564 *
4565 * Function Name : Netc_EthSwt_Ip_GetSwitchIdentifier
4566 * Description : Ethernet switch hardware version function.
4567 * implements Netc_EthSwt_Ip_GetSwitchIdentifier_Activity
4568 *END**************************************************************************/
4569 Std_ReturnType Netc_EthSwt_Ip_GetSwitchIdentifier(uint8 SwitchIdx, uint32 *HwVersion)
4570 {
4571 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
4572 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4573 #endif
4574
4575 /* This dummy cast is done to support scalability in futures platforms. */
4576 (void)SwitchIdx;
4577 /* Hardware revision. */
4578 *HwVersion = IP_NETC__SW0_GLOBAL->IPBRR0;
4579
4580 return E_OK;
4581 }
4582
4583 /*FUNCTION**********************************************************************
4584 * Function Name : Netc_EthSwt_Ip_InitCommandBDR
4585 * Description : Internal function for initializing the command ring.
4586 *
4587 *END**************************************************************************/
4588 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_InitCommandBDR(uint8 SwitchIdx, uint8 cbdrIndex)
4589 {
4590 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
4591
4592 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
4593 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4594 #endif
4595
4596 (void)SwitchIdx;
4597
4598 /* check the index of command ring */
4599 if (cbdrIndex >= NETC_ETHSWT_IP_CBDR_NUM)
4600 {
4601 status = NETC_ETHSWT_CBDRSTATUS_INDEX_ERROR;
4602 }
4603 else
4604 {
4605 /* configure the CBDR base address register where the address of a switch table is stored*/
4606 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRBAR0 = (uint32)(CmdBDRConfig[cbdrIndex].CmdBDAddr);
4607
4608 /* set the index of producer and consumer register to 0. The ring is empty now. */
4609 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRPIR = NETC_F2_CBDRPIR_BDR_INDEX(0U);
4610 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRCIR = NETC_F2_CBDRCIR_BDR_INDEX(0U);
4611
4612 /* set the size of command ring. Size of ring in sets of 8 BDs. Maximum ring size is 1K. */
4613 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRLENR = NETC_F2_CBDRLENR_LENGTH(CmdBDRConfig[cbdrIndex].lengthCBDR);
4614
4615 /* enable CBDR. When the ring is non-empty, command buffer descriptors will be processed */
4616 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRMR = NETC_F2_CBDRMR_EN(1U);
4617 }
4618
4619 return status;
4620 }
4621
4622 /*FUNCTION**********************************************************************
4623 *
4624 * Function Name : Netc_EthSwt_Ip_FillInFdbTableReqDataBuff
4625 * Description : Internal function for initializing the FDB Table Request Data Buffer.
4626 *
4627 *END**************************************************************************/
4628 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_FillInFdbTableReqDataBuff(uint32 ActionsData, const uint32 *pAccessKey, const Netc_EthSwt_Ip_FDBTableCFGEDataType *pCfgeData, Netc_EthSwt_Ip_AccessMethodType accessMethod)
4629 {
4630 uint8 ItemIdx;
4631 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
4632 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_47();
4633
4634 /* ------initialize the table request data buffer------ */
4635 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
4636
4637 /* initialize ACCESS_KEY */
4638 switch (accessMethod)
4639 {
4640 case NETC_ETHSWT_ENTRY_ID_MATCH:
4641 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = pAccessKey[0U]; /* fill in Entry_ID field */
4642 break;
4643 case NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH:
4644 for (ItemIdx = 1U; ItemIdx <= NETC_ETHSWT_IP_FDB_KEYE_DATA_ITEMS; ItemIdx++)
4645 {
4646 TableDataBuffer.TableDataField[ItemIdx] = pAccessKey[ItemIdx - 1U]; /* fill in keye data field */
4647 }
4648 break;
4649 case NETC_ETHSWT_SEARCH_METHOD:
4650 for (ItemIdx = 1U; ItemIdx <= NETC_ETHSWT_IP_FDB_SEARCH_CRITERIA_DATA_ITEMS; ItemIdx++)
4651 {
4652 TableDataBuffer.TableDataField[ItemIdx] = pAccessKey[ItemIdx - 1U]; /* fill in search criteria data field */
4653 }
4654 break;
4655 default:
4656 /* Not Applicable for FDB table*/
4657 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
4658 break;
4659 }
4660
4661 /* initialize CFGE_DATA. This portion is present only for commands which perform an update or add. */
4662 if (pCfgeData != NULL_PTR)
4663 {
4664 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_CFGE_PORT_BITMAP_FIELD] = pCfgeData->Cfge_PortBitmap;
4665 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD] = pCfgeData->Cfge_ConfigField;
4666 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_CFGE_ETEID_FIELD] = pCfgeData->Cfge_EtEid;
4667 }
4668 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_47();
4669
4670 return status;
4671 }
4672
4673 /*FUNCTION**********************************************************************
4674 *
4675 * Function Name : Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff
4676 * Description : Internal function for initializing the Vlan Filter Table Request Data Buffer.
4677 *
4678 *END**************************************************************************/
4679 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff(uint32 ActionsData, uint32 AccessKeyData, const Netc_EthSwt_Ip_VlanFilterTableCFGEDataType *pCfgeData, Netc_EthSwt_Ip_AccessMethodType accessMethod)
4680 {
4681 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
4682 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_12();
4683
4684 /* ------initialize the table request data buffer------ */
4685 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
4686
4687 /* initialize ACCESS_KEY Data */
4688 switch (accessMethod)
4689 {
4690 case NETC_ETHSWT_ENTRY_ID_MATCH:
4691 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = AccessKeyData; /* fill in Entry_ID field */
4692 break;
4693 case NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH:
4694 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_REQFMT_VID_FIELD] = AccessKeyData; /* fill in VID field of KEYE Data */
4695 break;
4696 case NETC_ETHSWT_SEARCH_METHOD:
4697 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_REQFMT_RESUMEENTRYID_FIELD] = AccessKeyData; /* fill in RESUME_ENTRY_ID of search criteria data */
4698 break;
4699 default:
4700 /* Not Applicable for Vlan Filter table*/
4701 status = NETC_ETHSWT_CBDRSTATUS_ACCESSMETHOD_ERROR;
4702 break;
4703 }
4704
4705 /* initialize CFGE_DATA. This portion is present only for commands which perform an update or add. */
4706 if (pCfgeData != NULL_PTR)
4707 {
4708 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = pCfgeData->Cfge_Data[0U];
4709 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = pCfgeData->Cfge_Data[1U];
4710 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = pCfgeData->Cfge_Data[2U];
4711 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = pCfgeData->Cfge_Data[3U];
4712
4713 }
4714 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_12();
4715
4716 return status;
4717 }
4718
4719 /*FUNCTION**********************************************************************
4720 *
4721 * Function Name : Netc_EthSwt_Ip_SendCommand
4722 * Description : Internal function for table operations with different commands like add, query, delete etc..
4723 *
4724 *END**************************************************************************/
4725 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_SendCommand(uint8 SwitchIdx, uint8 cbdrIndex, const NetcEthSwt_Ip_ReqHeaderTableOperationDataType *OperationData)
4726 {
4727 uint32 producerIdx;
4728 uint32 consumerIdx;
4729 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
4730 uint32 PreviousProducerIdx;
4731 uint32 statusField;
4732 uint32 rrBit;
4733 uint32 errorField;
4734 uint32 StartTime;
4735 uint32 ElapsedTime;
4736 uint32 TimeoutTicks;
4737 boolean TimeExpired;
4738
4739 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
4740 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4741 #endif
4742
4743 (void)SwitchIdx;
4744
4745 /* read the producer and consumer index register */
4746 producerIdx = IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRPIR;
4747 consumerIdx = IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRCIR;
4748
4749 /* check if the ring is full */
4750 if (((producerIdx + 0x1UL) % ((uint32)(CmdBDRConfig[cbdrIndex].lengthCBDR) * NETC_ETHSWT_IP_SET_OF_BD)) == consumerIdx)
4751 {
4752 status = NETC_ETHSWT_CBDRSTATUS_RINGFULL; /* the ring is full */
4753 }
4754 else
4755 {
4756 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_04();
4757 /* +++ fill in the NTMP request message header +++ */
4758 /* set the table address */
4759 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_ADDR_L] = (uint32)(&TableDataBuffer);
4760
4761 /* set the length of request and response data buffer */
4762 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_LENGTHFIELD] = (NETC_ETHSWT_IP_CMDBD_REQFMT_REQUEST_LENGTH(OperationData->ReqBuffLength) | NETC_ETHSWT_IP_CMDBD_REQFMT_RESPONSE_LENGTH(OperationData->RspBuffLength));
4763
4764 /* set RR = 0, CCI = 0, protocol version = 2, table id, access method and cmd */
4765 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] = 0x0; /* clear this field first */
4766 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] |= NETC_ETHSWT_IP_CMDBD_REQFMT_CONFIG_FIELD_CMD(OperationData->Cmd);
4767 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] |= NETC_ETHSWT_IP_CMDBD_REQFMT_CONFIG_FIELD_ACCESS_METHOD(OperationData->AccessMethod);
4768 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] |= NETC_ETHSWT_IP_CMDBD_REQFMT_CONFIG_FIELD_TABLE_ID(OperationData->TableId);
4769 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] |= NETC_ETHSWT_IP_CMDBD_REQFMT_CONFIG_FIELD_VERSION(OperationData->Version);
4770 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] |= NETC_ETHSWT_IP_CMDBD_REQFMT_CONFIG_FIELD_CCI(OperationData->CmdCompletionInt);
4771 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] |= NETC_ETHSWT_IP_CMDBD_REQFMT_CONFIG_FIELD_RR(0U); /* RR bit has to be set to 0 */
4772
4773 /* set NTMP version to 2.0*/
4774 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_NPFFIELD] = NETC_ETHSWT_IP_CMDBD_REQFMT_NPF_FIELD(NETC_ETHSWT_IP_CMDBD_REQFMT_NTMP_PROTOCOL_VERSION);
4775 /* --- fill in the NTMP request message header --- */
4776 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_04();
4777
4778 /* +++ write the produce index register and enable hardware to consume the command +++ */
4779 PreviousProducerIdx = producerIdx; /* save the produce index before incrementing it manually */
4780 if ((producerIdx + 0x1UL) == ((uint32)(CmdBDRConfig[cbdrIndex].lengthCBDR) * NETC_ETHSWT_IP_SET_OF_BD)) /* adjust producer index */
4781 {
4782 producerIdx = 0x0UL; /* when producerIdx equals ACTUAL_CBDR_LENGTH minus 1, then it would start from 0 again */
4783 }
4784 else
4785 {
4786 producerIdx += 0x1UL; /* increase the producer index manually */
4787 }
4788
4789 /* This is needed to make sure the descriptor gets updated with the latest values, before
4790 incrementing the producer index to start the actual operation */
4791 MCAL_DATA_SYNC_BARRIER();
4792
4793 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRPIR = NETC_F2_CBDRPIR_BDR_INDEX(producerIdx);
4794 /* --- write the produce index register and enable hardware to consume the command --- */
4795
4796 /* +++ to make sure the hardware consumes and processes the command completely +++ */
4797 /* Setup timeout timer */
4798 Netc_EthSwt_Ip_StartTimeOut(&StartTime, &ElapsedTime, &TimeoutTicks, NETC_ETHSWT_IP_TIMEOUT_VALUE_US);
4799 do {
4800 statusField = CmdBDRConfig[cbdrIndex].CmdBDAddr[PreviousProducerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_RSPHEADER_STATUS_FIELD_INDEX]; /* get status field in the response data buffer */
4801 rrBit = ((statusField & (NETC_ETHSWT_IP_CMDBD_RSPFMT_STATUS_FIELD_RR_MASK)) >> (NETC_ETHSWT_IP_CMDBD_RSPFMT_STATUS_FIELD_RR_SHIFT)); /* get the value of RR bit in the response data buffer */
4802 TimeExpired = Netc_EthSwt_Ip_TimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks);
4803 } while ((rrBit != 0x1U) && (FALSE == TimeExpired)); /* wait the hardware consume the command and check RR bit to see if the processing is completed (rrBit = 1). */
4804 /* --- to make sure the hardware consumes and processes the command completely --- */
4805
4806 /* the command sent was executed successfully and timely by hardware. */
4807 if (FALSE == TimeExpired)
4808 {
4809 /* return the value of ERROR field in response data buffer indicating if there is an error for processing the command */
4810 errorField = ((statusField & (NETC_ETHSWT_IP_CMDBD_RSPFMT_STATUS_FIELD_ERROR_MASK)) >> (NETC_ETHSWT_IP_CMDBD_RSPFMT_STATUS_FIELD_ERROR_SHIFT));
4811 if (errorField != 0U)
4812 {
4813 status = errorField; /* ERROR field should be 0. */
4814 }
4815 }
4816 else /* table operation timeout. */
4817 {
4818 status = NETC_ETHSWT_CBDRSTATUS_TABLE_OPERATION_TIMEOUT; /* either NETC_ETHSWT_IP_TIMEOUT_VALUE_US is not big enough or something wrong with the entry configuration. */
4819 }
4820 }
4821 return status;
4822 }
4823
4824 /*FUNCTION**********************************************************************
4825 *
4826 * Function Name : Netc_EthSwt_Ip_GetMatchedEntries
4827 * Description : Function for getting matched table entries. Num_Matched field indicates if it matches an entry.
4828 *
4829 *END**************************************************************************/
4830 static void Netc_EthSwt_Ip_GetMatchedEntries(uint8 cbdrIndex, uint32 *NumOfEntry)
4831 {
4832 uint32 producerIdx;
4833 uint32 statusField;
4834 uint32 lengthOfCmDB;
4835
4836 producerIdx = IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRPIR;
4837
4838 /* the value stored in producer index register indicates the index of next entry */
4839 if (producerIdx > 0UL)
4840 {
4841 producerIdx -= 1UL;
4842 }
4843 else /* producerIdx increased from 15 to 0, will set it to 15, or length minus 1 */
4844 {
4845 lengthOfCmDB = ((uint32)(CmdBDRConfig[cbdrIndex].lengthCBDR) * NETC_ETHSWT_IP_SET_OF_BD);
4846 producerIdx = lengthOfCmDB - 0x1UL;
4847 }
4848
4849 /* get status field in the response data buffer for the matched fdb entry */
4850 statusField = CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_RSPHEADER_STATUS_FIELD_INDEX];
4851
4852 /* NUM_MATCHED should equal or greater than 1 if the entry exists for any commands. */
4853 *NumOfEntry = (statusField & (NETC_ETHSWT_IP_CMDBD_RSPFMT_STATUS_FIELD_NUMMATCHED_MASK));
4854
4855 }
4856
4857 /*FUNCTION**********************************************************************
4858 *
4859 * Function Name : Netc_EthSwt_Ip_GetCounters
4860 * Description : Function for getting the counters of a port
4861 * For MAC counters that are 64bits, the access must be atomic.
4862 * implements Netc_EthSwt_Ip_GetCounters_Activity
4863 *END**************************************************************************/
4864 Std_ReturnType Netc_EthSwt_Ip_GetCounters( uint8 SwitchIdx,
4865 uint8 SwitchPortIdx,
4866 Netc_EthSwt_Ip_CounterType *Counter
4867 )
4868 {
4869 Std_ReturnType status = E_OK;
4870
4871 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
4872 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4873 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
4874 DevAssert(Counter != NULL_PTR);
4875 #endif
4876
4877 (void)SwitchIdx;
4878
4879 if(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
4880 {
4881 status = Netc_EthSwt_Ip_GetSwtPortCounters(SwitchIdx, SwitchPortIdx, Counter);
4882 }
4883 else
4884 {
4885 status = Netc_EthSwt_Ip_GetSwtPseudoPortCounters(SwitchIdx, SwitchPortIdx, Counter);
4886 }
4887
4888 return status;
4889 }
4890
4891 /*FUNCTION**********************************************************************
4892 *
4893 * Function Name : Netc_EthSwt_Ip_ComputedRegisterValueExtractionSingleCounter
4894 * Description : Function for extracting the counter value using base/offset
4895 *END**************************************************************************/
4896 static inline uint64 Netc_EthSwt_Ip_ComputedRegisterValueExtractionSingleCounter(const Netc_EthSwt_Ip_PortBaseType* base, const Netc_EthSwt_Ip_SingleCounterType offset)
4897 {
4898 return Netc_EthSwt_Ip_Extract64bitsFrom32bitsReg((uint32) base, (uint32) offset);
4899 }
4900
4901 /*FUNCTION**********************************************************************
4902 *
4903 * Function Name : Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter
4904 * Description : Function for extracting the counter value using base/offset
4905 *END**************************************************************************/
4906 static inline uint64 Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(const Netc_EthSwt_Ip_PseudoPortBaseType* base, const Netc_EthSwt_Ip_PseudoPortCounterType offset)
4907 {
4908 return Netc_EthSwt_Ip_Extract64bitsFrom32bitsReg((uint32) base, (uint32) offset);
4909 }
4910
4911 /*FUNCTION**********************************************************************
4912 *
4913 * Function Name : Netc_EthSwt_Ip_GetCounter
4914 * Description : Function for getting the counters of a port.
4915 * For MAC counters that are 64bits, the access must be atomic.
4916 * implements Netc_EthSwt_Ip_GetCounter_Activity
4917 *END**************************************************************************/
4918 Netc_EthSwt_Ip_CounterValueType Netc_EthSwt_Ip_GetCounter(uint8 SwitchIdx, uint8 SwitchPortIdx, Netc_EthSwt_Ip_SingleCounterType Counter)
4919 {
4920 uint8 PseudoPortIdx;
4921 uint64 CounterValue = 0UL;
4922
4923 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
4924 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4925 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
4926 #endif
4927
4928 (void)SwitchIdx;
4929
4930 if(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
4931 {
4932 /* Compute address of the counter. for port 0 and port 1*/
4933 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionSingleCounter(Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx], Counter);
4934 }
4935 else
4936 {
4937 /* pseudo port indexes are starting after the mac ports. */
4938 PseudoPortIdx = SwitchPortIdx - NETC_ETHSWT_NUMBER_OF_MAC_PORTS;
4939 switch (Counter)
4940 {
4941 case NETC_ETHSWT_IP_RX_OCTETS_COUNT:
4942 /* Compute addres of the counter. */
4943 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMROCR0);
4944 break;
4945 case NETC_ETHSWT_IP_RX_UNICAST_FRM_COUNT:
4946 /* Compute addres of the counter. */
4947 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMRUFCR0);
4948 break;
4949 case NETC_ETHSWT_IP_RX_MULTICAST_FRM_COUNT:
4950 /* Compute addres of the counter. */
4951 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMRMFCR0);
4952 break;
4953 case NETC_ETHSWT_IP_RX_BROADCAST_FRM_COUNT:
4954 /* Compute addres of the counter. */
4955 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMRBFCR0);
4956 break;
4957 case NETC_ETHSWT_IP_TX_OCTETS_COUNT:
4958 /* Compute addres of the counter. */
4959 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMTOCR0);
4960 break;
4961 case NETC_ETHSWT_IP_TX_UNICAST_FRM_COUNT:
4962 /* Compute addres of the counter. */
4963 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMTUFCR0);
4964 break;
4965 case NETC_ETHSWT_IP_TX_MULTICAST_FRM_COUNT:
4966 /* Compute addres of the counter. */
4967 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMTMFCR0);
4968 break;
4969 case NETC_ETHSWT_IP_TX_BROADCAST_FRM_COUNT:
4970 /* Compute addres of the counter. */
4971 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMTBFCR0);
4972 break;
4973 default:
4974 CounterValue = 0xFFFFFFFFFFFFFFFFU;
4975 break;
4976 }
4977
4978 }
4979
4980 return CounterValue;
4981 }
4982
4983 /*FUNCTION**********************************************************************
4984 *
4985 * Function Name : Netc_EthSwt_Ip_PortGetLoopbackMode
4986 * Description : Function for getting the loopback mode of a port
4987 * implements Netc_EthSwt_Ip_PortGetLoopbackMode_Activity
4988 *END**************************************************************************/
4989 Std_ReturnType Netc_EthSwt_Ip_PortGetLoopbackMode( uint8 SwitchIdx,
4990 uint8 SwitchPortIdx,
4991 boolean *LoopbackEnable
4992 )
4993 {
4994 Std_ReturnType status = E_OK;
4995 uint32 portCommandConfig = 0UL;
4996
4997 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
4998 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4999 #endif
5000
5001 (void)SwitchIdx;
5002
5003 /* Read the register */
5004 portCommandConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG;
5005
5006 /* Get the loop back mode value */
5007 if (SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
5008 {
5009 *LoopbackEnable = ((SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_LOOP_ENA_MASK & portCommandConfig) == 0U) ? FALSE : TRUE;
5010 }
5011 else
5012 {
5013 *LoopbackEnable = FALSE; /* pseudo port does not have loop back mode */
5014 }
5015 return status;
5016 }
5017
5018 /*FUNCTION**********************************************************************
5019 *
5020 * Function Name : Netc_EthSwt_Ip_PortSetLoopbackMode
5021 * Description : Function for setting the loopback mode of a port
5022 * implements Netc_EthSwt_Ip_PortSetLoopbackMode_Activity
5023 *END**************************************************************************/
5024 Std_ReturnType Netc_EthSwt_Ip_PortSetLoopbackMode( uint8 SwitchIdx,
5025 uint8 SwitchPortIdx,
5026 boolean LoopbackEnable
5027 )
5028 {
5029 Std_ReturnType status = E_OK;
5030 uint32 portCommandConfig = 0UL;
5031
5032 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5033 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5034 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS);
5035 #endif
5036
5037 (void)SwitchIdx;
5038 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_57();
5039 portCommandConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG
5040 & ~SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_LOOP_ENA_MASK;
5041
5042 /* Configure the loopback mode in the PM0_COMMAND_CONFIG */
5043 if (TRUE == LoopbackEnable)
5044 {
5045 portCommandConfig |= SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_LOOP_ENA_MASK;
5046 }
5047
5048 /* Write the PM0_COMMAND_CONFIG with the computed value */
5049 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG = portCommandConfig;
5050 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_57();
5051
5052 return status;
5053 }
5054
5055 /*FUNCTION**********************************************************************
5056 *
5057 * Function Name : Netc_EthSwt_Ip_SetPortMacLayerDuplexMode
5058 * Description : Function for enabling or disabling Time Gate Scheduling on a switch port.
5059 * implements Netc_EthSwt_Ip_SetPortMacLayerDuplexMode_Activity
5060 *END**************************************************************************/
5061 Std_ReturnType Netc_EthSwt_Ip_SetPortMacLayerDuplexMode( uint8 SwitchIdx, uint8 SwitchPortIdx,
5062 Netc_EthSwt_Ip_PortDuplexType EthSwtPortMacLayerDuplexMode
5063 )
5064 {
5065 Std_ReturnType status = E_OK;
5066 uint32 interfaceModeConfig = 0UL;
5067
5068 (void) SwitchIdx;
5069 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5070 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5071 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
5072 #endif
5073
5074 if(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
5075 {
5076 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_58();
5077
5078 interfaceModeConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE;
5079
5080 /* Full duplex is 0 in HD field */
5081 if(EthSwtPortMacLayerDuplexMode == NETC_ETHSWT_PORT_FULL_DUPLEX)
5082 {
5083 interfaceModeConfig &= ~SW_ETH_MAC_PORT0_PM0_IF_MODE_HD_MASK;
5084 }
5085 else /* ETHTRCV_DUPLEX_MODE_HALF */
5086 {
5087 interfaceModeConfig |= SW_ETH_MAC_PORT0_PM0_IF_MODE_HD_MASK;
5088 }
5089
5090 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE = interfaceModeConfig;
5091 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_58();
5092
5093 }
5094
5095 return status;
5096 }
5097
5098 static inline Std_ReturnType Netc_EthSwt_Ip_RGMIIModeConfig(uint32 *interfaceModeConfig, uint32 *shapingPSpeedConfig, EthTrcv_BaudRateType EthSwtPortMacLayerSpeed, Netc_EthSwt_Ip_PortDuplexType EthSwtPortMacLayerDuplexMode)
5099 {
5100 Std_ReturnType status = E_OK;
5101
5102 /* Full duplex is 0 in HD field for RGMII mode*/
5103 if (EthSwtPortMacLayerDuplexMode == NETC_ETHSWT_PORT_FULL_DUPLEX)
5104 {
5105 (*interfaceModeConfig) &= ~SW_ETH_MAC_PORT1_PM0_IF_MODE_HD_MASK;
5106 }
5107
5108 switch(EthSwtPortMacLayerSpeed)
5109 {
5110 case ETHTRCV_BAUD_RATE_10MBIT: /* 10Mbps */
5111 {
5112 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT));
5113 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
5114 break;
5115 }
5116 case ETHTRCV_BAUD_RATE_100MBIT: /* 100Mbps */
5117 {
5118 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT));
5119 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
5120 break;
5121 }
5122 case ETHTRCV_BAUD_RATE_1000MBIT: /* 1000Mbps */
5123 {
5124 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT));
5125 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_1000MBITS;
5126 break;
5127 }
5128 default:
5129 {
5130 status = E_NOT_OK;
5131 break;
5132 }
5133 }
5134
5135 return status;
5136 }
5137 static inline Std_ReturnType Netc_EthSwt_Ip_SGMIIModeConfig(uint32 *interfaceModeConfig, uint32 *shapingPSpeedConfig, EthTrcv_BaudRateType EthSwtPortMacLayerSpeed)
5138
5139 {
5140 Std_ReturnType status = E_OK;
5141
5142 switch(EthSwtPortMacLayerSpeed)
5143 {
5144 case ETHTRCV_BAUD_RATE_10MBIT: /* 10Mbps */
5145 {
5146 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT));
5147 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
5148 break;
5149 }
5150 case ETHTRCV_BAUD_RATE_100MBIT: /* 100Mbps */
5151 {
5152 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT));
5153 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
5154 break;
5155 }
5156 case ETHTRCV_BAUD_RATE_1000MBIT: /* 1000Mbps */
5157 {
5158 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT));
5159 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_1000MBITS;
5160 break;
5161 }
5162 case ETHTRCV_BAUD_RATE_2500MBIT: /* 2500Mbps */
5163 {
5164 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_2500MBIT));
5165 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_2500MBITS;
5166 break;
5167 }
5168 default:
5169 {
5170 status = E_NOT_OK;
5171 break;
5172 }
5173 }
5174
5175 return status;
5176 }
5177
5178 static Std_ReturnType Netc_EthSwt_Ip_MacPortConfig( uint8 SwitchIdx, uint8 SwitchPortIdx,
5179 Netc_EthSwt_Ip_XmiiModeType EthSwtPortPhysicalLayerType,
5180 EthTrcv_BaudRateType EthSwtPortMacLayerSpeed,
5181 Netc_EthSwt_Ip_PortDuplexType EthSwtPortMacLayerDuplexMode
5182 )
5183 {
5184 Std_ReturnType status = E_OK;
5185 uint32 interfaceModeConfig = 0UL;
5186 uint32 shapingPSpeedConfig = 0UL; /* used for shaping of the port */
5187
5188 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5189 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5190 #endif
5191
5192 (void) SwitchIdx;
5193
5194 if(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
5195 {
5196 /* Set the interface type */
5197 if (NETC_ETHSWT_RGMII_MODE == EthSwtPortPhysicalLayerType)
5198 {
5199 interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE(4U));
5200 status = Netc_EthSwt_Ip_RGMIIModeConfig(&interfaceModeConfig, &shapingPSpeedConfig, EthSwtPortMacLayerSpeed, EthSwtPortMacLayerDuplexMode);
5201 }
5202 else if (NETC_ETHSWT_RMII_MODE == EthSwtPortPhysicalLayerType)
5203 {
5204 interfaceModeConfig = (SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE(3U));
5205 /* Full duplex is 0 in HD field */
5206 if (EthSwtPortMacLayerDuplexMode == NETC_ETHSWT_PORT_FULL_DUPLEX)
5207 {
5208 interfaceModeConfig |= SW_ETH_MAC_PORT1_PM0_IF_MODE_HD_MASK;
5209 }
5210 if(ETHTRCV_BAUD_RATE_10MBIT == EthSwtPortMacLayerSpeed)
5211 {
5212 interfaceModeConfig |= SW_ETH_MAC_PORT1_PM0_IF_MODE_M10_MASK;
5213 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
5214 }
5215 }
5216 else if (NETC_ETHSWT_MII_MODE == EthSwtPortPhysicalLayerType)
5217 {
5218 interfaceModeConfig = (SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE(1U));
5219 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
5220 }
5221 else if (NETC_ETHSWT_SGMII_MODE == EthSwtPortPhysicalLayerType)
5222 {
5223 /* The MAC register IF_MODE[IFMODE] must be set to 0b101 for SGMII mode. */
5224 interfaceModeConfig = (SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE(5U));
5225 status = Netc_EthSwt_Ip_SGMIIModeConfig(&interfaceModeConfig, &shapingPSpeedConfig, EthSwtPortMacLayerSpeed);
5226 }
5227 else
5228 {
5229 /* type error */
5230 status = E_NOT_OK;
5231 }
5232
5233 /* Write the interface mode configuration in the register */
5234 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE = interfaceModeConfig;
5235 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR &= ~SW_PORT0_PCR_PSPEED_MASK;
5236 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR |= SW_PORT0_PCR_PSPEED(shapingPSpeedConfig);
5237 }
5238 else
5239 {
5240 /* pseudo port */
5241 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR &= ~SW_PORT0_PCR_PSPEED_MASK;
5242 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR |= SW_PORT0_PCR_PSPEED(NETC_ETHSWT_IP_SHAPING_PSPEED_2000MBITS);
5243 }
5244
5245 return status;
5246 }
5247
5248 /* inline function for configuring BPDVR */
5249 static inline void ConfigBridgePortDefaultVlanReg(uint8 SwitchPortIdx, const Netc_EthSwt_Ip_PortType *port)
5250 {
5251 uint32 bridgePortDefaultVlan = 0UL;
5252
5253 /* Bridge VLAN port defaults, bits in this section use reverse logic, TRUE==0 */
5254 if(TRUE != port->iPort->EthSwtDropDoubleTagged)
5255 {
5256 bridgePortDefaultVlan |= SW_PORT0_BPDVR_RXTAGA(NETC_ETHSWT_IP_RXTAGA_ACCEPT_DOUBLE_TAGGED);
5257 }
5258 if(TRUE != port->iPort->EthSwtPortIngressDropUntagged)
5259 {
5260 bridgePortDefaultVlan |= SW_PORT0_BPDVR_RXTAGA(NETC_ETHSWT_IP_RXTAGA_ACCEPT_UNTAGGED);
5261 }
5262 if(TRUE != port->iPort->EthSwtPortIngressDropSingleTagged)
5263 {
5264 bridgePortDefaultVlan |= SW_PORT0_BPDVR_RXTAGA(NETC_ETHSWT_IP_RXTAGA_ACCEPT_SINGLE_TAGGED);
5265 }
5266 if(TRUE != port->iPort->EthSwtPortIngressDropPriorityTagged)
5267 {
5268 bridgePortDefaultVlan |= SW_PORT0_BPDVR_RXTAGA(NETC_ETHSWT_IP_RXTAGA_ACCEPT_PRIO_TAGGED);
5269 }
5270 if(TRUE != port->iPort->vlanEnable)
5271 {
5272 bridgePortDefaultVlan |= SW_PORT0_BPDVR_RXVAM(1);
5273 }
5274
5275 if(TRUE == port->iPort->SentUntaggedFrames)
5276 {
5277 bridgePortDefaultVlan |= SW_PORT0_BPDVR_TXTAGA(1); /* Delete outer VLAN tag */
5278 }
5279 /* default vlan id */
5280 bridgePortDefaultVlan |= SW_PORT0_BPDVR_VID(port->iPort->EthSwtPortIngressDefaultVlan);
5281 /* default priority */
5282 bridgePortDefaultVlan |= SW_PORT0_BPDVR_PCP(port->iPort->EthSwtPortIngressDefaultPriority);
5283 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->BPDVR = bridgePortDefaultVlan;
5284 }
5285
5286 /* inline function for configuring credit base shaper registers */
5287 static inline void ConfigCreditBaseShaperReg(uint8 SwitchPortIdx, const Netc_EthSwt_Ip_PortType *port)
5288 {
5289 uint8 shapingClass;
5290 uint32 localPtcTmSDUR;
5291
5292 if(port->ePort->portShaper != NULL_PTR)
5293 {
5294 for(shapingClass = 0U; shapingClass < NETC_ETHSWT_IP_NUM_SHAPING_CLASS; shapingClass++)
5295 {
5296 /* Coonfigure the maximum frame size per shaping class, Max 2000 */
5297 localPtcTmSDUR = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[shapingClass].PTCTMSDUR;
5298 localPtcTmSDUR &= ~SW_PORT0_PTCTMSDUR_MAXSDU_MASK;
5299 localPtcTmSDUR |= SW_PORT0_PTCTMSDUR_MAXSDU(port->ePort->portShaper[shapingClass]->EthSwtPortMaxSizedFrame);
5300 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[shapingClass].PTCTMSDUR = localPtcTmSDUR;
5301
5302 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[shapingClass].PTCCBSR0 = SW_PORT0_PTCCBSR0_CBSE(port->ePort->portShaper[shapingClass]->EthSwtPortEgressCBShaperEnable ? 1U : 0U)
5303 | SW_PORT0_PTCCBSR0_BW(port->ePort->portShaper[shapingClass]->EthSwtPortEgressCBShaperBandwidth);
5304 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[shapingClass].PTCCBSR1 = SW_PORT0_PTCCBSR1_HI_CREDIT(port->ePort->portShaper[shapingClass]->EthSwtPortEgressHiCredit);
5305 }
5306 }
5307 }
5308
5309 /* inline function for configuring PM0_COMMAND register */
5310 static inline Std_ReturnType ConfigPM0CommandReg(uint8 SwitchIdx, uint8 SwitchPortIdx, const Netc_EthSwt_Ip_PortType *port)
5311 {
5312 Std_ReturnType status = E_OK;
5313 uint32 portCommandConfig = 0UL;
5314
5315 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5316 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5317 #endif
5318
5319 /* Start the PM0_COMMAND_CONFIG value with the TX padding option */
5320 portCommandConfig = SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_TXP_MASK;
5321
5322 /* Construct several values to be used later based on whether the port is enabled or not */
5323 if (TRUE == port->EthSwtPortMacLayerPortEnable)
5324 {
5325 /* The pseudoport does not have the PM0_COMMAND_CONFIG register */
5326 if (SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
5327 {
5328 portCommandConfig |= SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_TX_EN_MASK | SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_RX_EN_MASK;
5329 }
5330
5331 /* Enable Rx and Tx Path for port */
5332 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->POR &= ~(SW_PORT0_POR_TXDIS_MASK | SW_PORT0_POR_RXDIS_MASK);
5333 }
5334 else
5335 {
5336 /* Disable the port in POR register */
5337 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->POR |= SW_PORT0_POR_TXDIS_MASK | SW_PORT0_POR_RXDIS_MASK;
5338 }
5339
5340 /* The pseudoport does not have the following options */
5341 if (SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
5342 {
5343 if(TRUE == port->EthSwtPortEnableMagicPacketDetection)
5344 {
5345 portCommandConfig |= SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_MG(1U);
5346 }
5347
5348 /* Configure the loopback mode in the PM0_COMMAND_CONFIG */
5349 if (TRUE == port->EthSwtPortLoopbackEnable)
5350 {
5351 portCommandConfig |= SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_LOOP_ENA_MASK;
5352 }
5353
5354 /* Write the PM0_COMMAND_CONFIG with the computed value */
5355 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG = portCommandConfig;
5356
5357 #if(NETC_ETHSWT_IP_CONFIG_LINK_PROTOCOL == STD_ON)
5358 /* Config link protocol for mac ports */
5359 Netc_EthSwt_Ip_ConfigLinkProtocol(SwitchIdx, SwitchPortIdx, port->EthSwtPortPhysicalLayerType);
5360 #endif
5361
5362 /* Configure the interface mode, the speed and the duplex mode */
5363 status |= Netc_EthSwt_Ip_MacPortConfig( SwitchIdx, SwitchPortIdx, port->EthSwtPortPhysicalLayerType,
5364 port->EthSwtPortMacLayerSpeed, port->EthSwtPortMacLayerDuplexMode
5365 );
5366 }
5367
5368 return status;
5369 }
5370
5371 static Std_ReturnType Netc_EthSwt_Ip_InitPort(uint8 SwitchIdx, uint8 SwitchPortIdx, const Netc_EthSwt_Ip_PortType *port)
5372 {
5373 Std_ReturnType status = E_OK;
5374 uint32 bridgePortConfig = 0UL;
5375
5376 (void) SwitchIdx;
5377 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5378 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5379 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
5380 #endif
5381
5382 /* Port QOS mode */
5383 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PQOSMR = SW_PORT0_PQOSMR_VS(1U)
5384 | SW_PORT0_PQOSMR_VE(port->iPort->vlanEnable?1U:0U)
5385 | SW_PORT0_PQOSMR_DIPV(port->iPort->vlanDefaultIpv)
5386 | SW_PORT0_PQOSMR_DDR(port->iPort->vlanDefaultDr)
5387 | SW_PORT0_PQOSMR_VQMP(port->iPort->vlanMappingProfile)
5388 | SW_PORT0_PQOSMR_QVMP(port->ePort->vlanMappingProfile);
5389
5390 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PPCPDEIMR = SW_PORT0_PPCPDEIMR_IPCPMPV(port->iPort->vlanEnableIngressPcpToPcpMapping?1U:0U)
5391 | SW_PORT0_PPCPDEIMR_IPCPMP(port->iPort->vlanIngressPcpToPcpProfile)
5392 | SW_PORT0_PPCPDEIMR_EPCPMPV(port->ePort->vlanEnableEgressPcpToPcpMapping?1U:0U)
5393 | SW_PORT0_PPCPDEIMR_EPCPMP(port->ePort->vlanEgressPcpToPcpProfile)
5394 | SW_PORT0_PPCPDEIMR_DRME(port->ePort->updateEgressDr?1U:0U)
5395 | SW_PORT0_PPCPDEIMR_DR0DEI(*(port->ePort->vlanDrToDei)[0U])
5396 | SW_PORT0_PPCPDEIMR_DR1DEI(*(port->ePort->vlanDrToDei)[1U])
5397 | SW_PORT0_PPCPDEIMR_DR2DEI(*(port->ePort->vlanDrToDei)[2U])
5398 | SW_PORT0_PPCPDEIMR_DR3DEI(*(port->ePort->vlanDrToDei)[3U]);
5399
5400 /* Bridge Port Default Vlan register configuration */
5401 ConfigBridgePortDefaultVlanReg(SwitchPortIdx, port);
5402
5403 /* PM0_COMMAND_CONFIG configuration */
5404 status = ConfigPM0CommandReg(SwitchIdx, SwitchPortIdx, port);
5405
5406 /* Bridge port configuration */
5407 if(port->EthSwtPortDisallowMacStationMove)
5408 {
5409 bridgePortConfig = SW_PORT1_BPCR_STAMVD(1U);
5410 }
5411
5412 bridgePortConfig |= SW_PORT0_BPCR_DYN_LIMIT(port->EthSwtPortMaxDynamicEntries);
5413
5414 /* Configure the pruning setting for each port */
5415 if (FALSE == port->EthSwtPortPruningEnable)
5416 {
5417 bridgePortConfig |= SW_PORT0_BPCR_SRCPRND_MASK;
5418 }
5419
5420 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->BPCR = bridgePortConfig;
5421
5422 /* configure the credit base shaper */
5423 ConfigCreditBaseShaperReg(SwitchPortIdx, port);
5424
5425 return status;
5426 }
5427
5428 /*FUNCTION**********************************************************************
5429 *
5430 * Function Name : Netc_EthSwt_Ip_ConfigureCreditBasedShaper
5431 * Description : function for configuring the CBS
5432 * implements Netc_EthSwt_Ip_ConfigureCreditBasedShaper_Activity
5433 *END**************************************************************************/
5434 Std_ReturnType Netc_EthSwt_Ip_ConfigureCreditBasedShaper(uint8 SwitchIdx, const uint8 SwitchPortIdx, const uint8 TrafficClass, const uint64 idleSlope)
5435 {
5436 Std_ReturnType status = E_OK;
5437 uint64 portTxRate;
5438 EthTrcv_BaudRateType baudRate = ETHTRCV_BAUD_RATE_10MBIT;
5439 uint64 largeBandwidth;
5440 uint32 bandwidth;
5441 uint64 largeEgressHiCredit;
5442 uint32 egressHiCredit;
5443 uint32 Netc_EthSwt_Ip_MaxFrameSize;
5444
5445 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5446 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5447 /* A Slope of zero would cause a bandwidth of zero and this would cause a buffer leak */
5448 DevAssert(idleSlope > 0U);
5449 DevAssert(TrafficClass < NETC_ETHSWT_IP_NUM_SHAPING_CLASS);
5450 #endif
5451
5452 if(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
5453 {
5454 status = Netc_EthSwt_Ip_GetPortSpeed( SwitchIdx, SwitchPortIdx, &baudRate);
5455 status |= Netc_EthSwt_Ip_PortRateEnumToRate(baudRate, &portTxRate);
5456 }
5457 else
5458 {
5459 portTxRate = 2000000UL;
5460 };
5461
5462 largeBandwidth = idleSlope / (portTxRate / 10000UL); /* bandwidth is in % and 100th precision, so need to divide by 10000 */
5463 if( largeBandwidth < 100UL )
5464 {
5465 largeBandwidth = 100UL; /* Min of 1% bandwidth, otherwise frames would get stuck in the switch */
5466 }
5467 /* Round and convert to uint32 */
5468 bandwidth = (uint32)(largeBandwidth/100UL);
5469 bandwidth = ((uint64)((((uint64)bandwidth)*100UL)+50UL)>largeBandwidth)?bandwidth:(bandwidth+1UL);
5470
5471 /* High Credit in credits
5472 hiCredit (bits) = maxSizedFrame * (idleSlope/portTxRate)
5473 bandwidth = idleSlope / portTxRate
5474 Then:
5475 hiCredit (bits) = maxSizedFrame * bandwidth
5476
5477 hiCredit (credits) = hiCredit (bits) * (ClockFrequency/portRate)
5478 Then:
5479 hiCredit (credits) = maxSizedFrame * bandwidth * (ClockFrequency / portRate)
5480 */
5481 Netc_EthSwt_Ip_MaxFrameSize = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCTMSDUR;
5482 largeEgressHiCredit = largeBandwidth * Netc_EthSwt_Ip_MaxFrameSize * (Netc_EthSwt_Ip_NetcClockFrequency / (portTxRate)) / 100UL; /* Bandwidth is in %, need to div by 100 */
5483 /* Round and convert to uint32 */
5484 egressHiCredit = (uint32)(largeEgressHiCredit/100UL);
5485 egressHiCredit = (((egressHiCredit*100UL)+50UL)>egressHiCredit)?egressHiCredit:(egressHiCredit+1UL);
5486
5487 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_05();
5488 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCCBSR0 &= ~SW_PORT0_PTCCBSR0_BW_MASK;
5489 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCCBSR0 |= SW_PORT0_PTCCBSR0_BW(bandwidth);
5490 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCCBSR1 = SW_PORT0_PTCCBSR1_HI_CREDIT(egressHiCredit);
5491 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_05();
5492
5493 return status;
5494 }
5495
5496 /*FUNCTION**********************************************************************
5497 *
5498 * Function Name : Netc_EthSwt_Ip_EnableCreditBasedShaper
5499 * Description : function for enabling a CBS
5500 * implements Netc_EthSwt_Ip_EnableCreditBasedShaper_Activity
5501 *END**************************************************************************/
5502 Std_ReturnType Netc_EthSwt_Ip_EnableCreditBasedShaper(uint8 SwitchIdx, const uint8 SwitchPortIdx, const uint8 TrafficClass, const boolean Enable)
5503 {
5504 Std_ReturnType status = E_OK;
5505
5506 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5507 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5508 DevAssert(TrafficClass < NETC_ETHSWT_IP_NUM_SHAPING_CLASS);
5509 #endif
5510
5511 (void)SwitchIdx;
5512 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_10();
5513 /* clear the bit first */
5514 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCCBSR0 &= ~SW_PORT0_PTCCBSR0_CBSE_MASK;
5515 /* write the bit */
5516 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCCBSR0 |= SW_PORT0_PTCCBSR0_CBSE((TRUE==Enable)?1U:0U);
5517 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_10();
5518
5519 return status;
5520 }
5521
5522 /* inline function for configuring VlanIpvDr2PcpProfile */
5523 static inline void ConfigVlanIpvDr2PcpProfile(const uint8 *IndexProfile, const Netc_EthSwt_Ip_ConfigType * Config)
5524 {
5525 uint8 IndexIpv;
5526 uint8 IndexDr;
5527
5528 if(NULL_PTR != Config->vlanIpvDr2PcpProfile)
5529 {
5530 for (IndexDr=0U; IndexDr<NETC_ETHSWT_NUMBER_OF_DR; IndexDr++)
5531 { /* Shifted by NETC_ETHSWT_IP_FIELD_REP_IN_4BITS for each DR index */
5532 for (IndexIpv=0; IndexIpv<NETC_ETHSWT_NUMBER_OF_IPV; IndexIpv++)
5533 {
5534 /* Settings are divied in 4 registers by groups of 2 */
5535 if((IndexIpv % 2U) == 0U)
5536 { /* even IPV in lower bits */
5537 IP_NETC__SW0_BASE->MAP_PCP[(*IndexProfile)].QOSVLANMPR[IndexIpv/2U] |= (uint32)((uint32)((*(Config->vlanIpvDr2PcpProfile))[(*IndexProfile)][IndexIpv][IndexDr])
5538 & NETC_F2_QOSVLANMPR_IPV0_DR0_MASK)<<(IndexDr*NETC_ETHSWT_IP_FIELD_REP_IN_4BITS);
5539 }
5540 else
5541 {
5542 IP_NETC__SW0_BASE->MAP_PCP[(*IndexProfile)].QOSVLANMPR[IndexIpv/2U] |= (uint32)((uint32)((*(Config->vlanIpvDr2PcpProfile))[(*IndexProfile)][IndexIpv][IndexDr])
5543 & NETC_F2_QOSVLANMPR_IPV0_DR0_MASK)<<((IndexDr*NETC_ETHSWT_IP_FIELD_REP_IN_4BITS)+NETC_ETHSWT_IP_FIELD_REP_IN_TOP_OF_32BITS);
5544 }
5545 }
5546 }
5547 }
5548 }
5549
5550 /* inline function for initializing Mapping profile */
5551 static inline void InitMappingProfile(const Netc_EthSwt_Ip_ConfigType * Config)
5552 {
5553 uint8 IndexProfile;
5554 uint8 IndexPcpDei;
5555 uint8 IndexPcp;
5556
5557 /* Initialize the clasification mapping */
5558 for (IndexProfile=0U; IndexProfile<NETC_ETHSWT_NUMBER_OF_PROFILES; IndexProfile++)
5559 {
5560 /* Initializing the different arrays */
5561 IP_NETC__SW0_COMMON->NUM_PROFILE[IndexProfile].VLANIPVMPR0 = 0U;
5562 IP_NETC__SW0_COMMON->NUM_PROFILE[IndexProfile].VLANIPVMPR1 = 0U;
5563 IP_NETC__SW0_COMMON->NUM_PROFILE[IndexProfile].VLANDRMPR = 0U;
5564 IP_NETC__SW0_BASE->PCP2PCPMPR[IndexProfile] = 0U;
5565 IP_NETC__SW0_BASE->MAP_PCP[IndexProfile].QOSVLANMPR[0] = 0U;
5566 IP_NETC__SW0_BASE->MAP_PCP[IndexProfile].QOSVLANMPR[1] = 0U;
5567 IP_NETC__SW0_BASE->MAP_PCP[IndexProfile].QOSVLANMPR[2] = 0U;
5568 IP_NETC__SW0_BASE->MAP_PCP[IndexProfile].QOSVLANMPR[3] = 0U;
5569
5570 if(NULL_PTR != Config->vlanPcpDei2IpvProfile )
5571 {
5572 for (IndexPcpDei=0U; IndexPcpDei<NETC_ETHSWT_NUMBER_OF_PCP_DEI; IndexPcpDei++)
5573 {
5574 if(IndexPcpDei < (NETC_ETHSWT_NUMBER_OF_PCP_DEI/2U)) /* Setting are divided in 2 registers */
5575 {
5576 IP_NETC__SW0_COMMON->NUM_PROFILE[IndexProfile].VLANIPVMPR0 |= (((uint32)((*(Config->vlanPcpDei2IpvProfile))[IndexProfile][IndexPcpDei]) & NETC_F2_COMMON_VLANIPVMPR0_PCP_DEI_0_MASK)<<(IndexPcpDei*NETC_ETHSWT_IP_FIELD_REP_IN_4BITS));
5577 }
5578 else
5579 {
5580 IP_NETC__SW0_COMMON->NUM_PROFILE[IndexProfile].VLANIPVMPR1 |= (((uint32)((*(Config->vlanPcpDei2IpvProfile))[IndexProfile][IndexPcpDei]) & NETC_F2_COMMON_VLANIPVMPR0_PCP_DEI_0_MASK)<<(IndexPcpDei/2U*NETC_ETHSWT_IP_FIELD_REP_IN_4BITS));
5581 }
5582 }
5583 }
5584 if(Config->vlanPcpDei2DrProfile != NULL_PTR)
5585 {
5586 for (IndexPcpDei=0U; IndexPcpDei<NETC_ETHSWT_NUMBER_OF_PCP_DEI; IndexPcpDei++)
5587 {
5588 IP_NETC__SW0_COMMON->NUM_PROFILE[IndexProfile].VLANDRMPR |= (((uint32)((*(Config->vlanPcpDei2DrProfile))[IndexProfile][IndexPcpDei]) & NETC_F2_COMMON_VLANDRMPR_PCP_DEI_0_MASK)<<(IndexPcpDei*NETC_F2_COMMON_VLANDRMPR_PCP_DEI_0_WIDTH));
5589 }
5590 }
5591 if(NULL_PTR != Config->vlanPcp2PcpProfile)
5592 {
5593 for (IndexPcp=0U; IndexPcp<NETC_ETHSWT_NUMBER_OF_PCP; IndexPcp++)
5594 {
5595 IP_NETC__SW0_BASE->PCP2PCPMPR[IndexProfile] |= (((uint32)((*(Config->vlanPcp2PcpProfile))[IndexProfile][IndexPcp]) & NETC_F2_PCP2PCPMPR_PCP0_MASK)<<(IndexPcp*NETC_ETHSWT_IP_FIELD_REP_IN_4BITS));
5596 }
5597 }
5598
5599 ConfigVlanIpvDr2PcpProfile(&IndexProfile, Config);
5600 }
5601 }
5602
5603 /* inline function for initializing 1588 timer */
5604 static inline void InitTimer1588(const Netc_EthSwt_Ip_ConfigType * Config)
5605 {
5606 uint16 TimerClkPeriod;
5607 uint32 ClkAddendData;
5608 uint32 TimerClkAddend;
5609
5610 if (Config->Timer1588ClkSrc == ETHSWT_EXTERNAL_REFERENCE_CLOCK)
5611 {
5612 TimerOriginalRefClk = Config->netcExternalClockFrequency;
5613 TimerRefClk = Config->netcExternalClockFrequency;
5614 IP_NETC__TMR0_BASE->TMR_CTRL &= ~TMR0_BASE_TMR_CTRL_CK_SEL(1U); /* select the external 200MHz clock for 1588 timer */
5615 }
5616 else if (Config->Timer1588ClkSrc == ETHSWT_MODULE_REFERENCE_CLOCK)
5617 {
5618 TimerOriginalRefClk = Config->netcClockFrequency;
5619 TimerRefClk = Config->netcClockFrequency;
5620 IP_NETC__TMR0_BASE->TMR_CTRL |= TMR0_BASE_TMR_CTRL_CK_SEL(1U); /* select NETC system clock (default setting) for 1588 timer */
5621 }
5622 else /* reference clock is disabled, will not use 1588 timer */
5623 {
5624 TimerOriginalRefClk = 0x0UL;
5625 TimerRefClk = 0x0UL;
5626 }
5627
5628 /* config and eanble the 1588 timer */
5629 if (TimerOriginalRefClk != 0x0UL)
5630 {
5631 TimerClkPeriod = (uint16)(1000U/(TimerOriginalRefClk/1000000U)); /* clock period = 1/200000000 = 5ns */
5632 ClkAddendData = (1000000U/(TimerOriginalRefClk/1000000U)) - (1000U * TimerClkPeriod);
5633 TimerClkAddend = (uint32)((((uint64)0x1U << NETC_ETHSWT_IP_32BIT_SHIFT) * ClkAddendData) / 1000U);
5634
5635 /* Timer addend register holds the fractional part of the timer clock period */
5636 IP_NETC__TMR0_BASE->TMR_ADD = TMR0_BASE_TMR_ADD_ADDEND(TimerClkAddend);
5637 /* clear CLK_PERIOD data field first */
5638 IP_NETC__TMR0_BASE->TMR_CTRL &= ~TMR0_BASE_TMR_CTRL_TCLK_PERIOD(0x3FFF);
5639 IP_NETC__TMR0_BASE->TMR_CTRL |= TMR0_BASE_TMR_CTRL_TCLK_PERIOD(TimerClkPeriod);
5640 /* Enable timer */
5641 IP_NETC__TMR0_BASE->TMR_CTRL |= TMR0_BASE_TMR_CTRL_TE(1U);
5642 }
5643
5644 }
5645
5646 /* inline function for initializing time gate scheduling table entries data during switch init */
5647 static inline void InitTimeGateSchedulingTableEntryData(const Netc_EthSwt_Ip_ConfigType * Config)
5648 {
5649 uint8 PortIndex;
5650 uint8 GateControlListIdx;
5651
5652 for (PortIndex = 0U; PortIndex < NETC_ETHSWT_NUMBER_OF_PORTS; PortIndex++)
5653 {
5654 if ((*((*(Config)).port))[PortIndex].ePort->portTimeAwareShaperEnable == TRUE)
5655 {
5656 /* set the flag for ports */
5657 PortTimeAwareShaperEnabled[PortIndex] = TRUE;
5658
5659 /* write register PTGSATOR. [Ricky}: not supported for now. follow up ticket needed. */
5660 /* TODO: Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->RESERVED_7 should be equal to (*((*(Config)).port))[PortIndex].ePort->portTimeGateSchedulingAdvanceTimeOffsetReg; */
5661
5662 /* Fill in the data structure for time gate scheduling */
5663 TimeGateSchedulingEntryData[PortIndex].TimeGateSchedulingTable_EID = PortIndex;
5664 TimeGateSchedulingEntryData[PortIndex].AdminBaseTime = (*((*(Config)).port))[PortIndex].ePort->portEgressAdminBaseTime;
5665 TimeGateSchedulingEntryData[PortIndex].AdminCycleTime = (*((*(Config)).port))[PortIndex].ePort->portEgressAdminCycleTime;
5666 TimeGateSchedulingEntryData[PortIndex].AdminCycleTimeExt = (*((*(Config)).port))[PortIndex].ePort->portEgressAdminCycleTimeExt;
5667 TimeGateSchedulingEntryData[PortIndex].AdminControlListLength = (*((*(Config)).port))[PortIndex].ePort->numberOfGateControlListEntries;
5668 for (GateControlListIdx = 0U; GateControlListIdx < TimeGateSchedulingEntryData[PortIndex].AdminControlListLength; GateControlListIdx++)
5669 {
5670 TimeGateSchedulingEntryData[PortIndex].GateEntryAdminControlListData[GateControlListIdx].AdminTimeInterval = (*((*((*(Config)).port))[PortIndex].ePort->TimeGateControlListEntries))[GateControlListIdx].AdminTimeInterval;
5671 TimeGateSchedulingEntryData[PortIndex].GateEntryAdminControlListData[GateControlListIdx].AdminTrafficClassGateStates = (*((*((*(Config)).port))[PortIndex].ePort->TimeGateControlListEntries))[GateControlListIdx].AdminTrafficClassGateStates;
5672 TimeGateSchedulingEntryData[PortIndex].GateEntryAdminControlListData[GateControlListIdx].AdminGateOperationType = (*((*((*(Config)).port))[PortIndex].ePort->TimeGateControlListEntries))[GateControlListIdx].AdminGateOperationType;
5673 }
5674 }
5675 }
5676 }
5677
5678 #if defined(ERR_IPV_NETC_E051130)
5679 #if (STD_ON == ERR_IPV_NETC_E051130)
5680 /* Workaround for ERR051130:
5681 Egress time gate scheduling can get corrupted when functional level reset is applied or when time gating is disabled
5682 */
5683 /* Added 2 fake time gate control list entries for clearing the internal context for time gate scheduling feature */
5684 static Netc_EthSwt_Ip_CBDRStatusType InitTimeGateSchedulingFeature(uint8 SwitchIdx, uint8 SwitchPortIdx)
5685 {
5686 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_CBDRSTATUS_SUCCES;
5687 volatile uint64 CurrentTime = 0;
5688 uint8 EntryIdx;
5689
5690 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5691 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5692 #endif
5693
5694 /* fill in struct Netc_EthSwt_Ip_TimeGateSchedulingEntryDataType */
5695 TimeGateSchedulingEntryData[0U].TimeGateSchedulingTable_EID = SwitchPortIdx;
5696 TimeGateSchedulingEntryData[0U].AdminCycleTime = 4000000U; /* it should be greater than the sum of time interval */
5697 TimeGateSchedulingEntryData[0U].AdminCycleTimeExt = 100000U;
5698 TimeGateSchedulingEntryData[0U].AdminControlListLength = 2U; /* 2 entries */
5699
5700 /* get the current time from 1588 timer */
5701 CurrentTime = IP_NETC__TMR0_BASE->TMR_CUR_TIME_L; /* should read the Lower register first */
5702 CurrentTime |= ((uint64)(IP_NETC__TMR0_BASE->TMR_CUR_TIME_H)) << NETC_ETHSWT_IP_32BIT_SHIFT;
5703 TimeGateSchedulingEntryData[0U].AdminBaseTime = CurrentTime; /* set base time to current time */
5704
5705 /* fill in gate control list entries data */
5706 for (EntryIdx = 0U; EntryIdx < TimeGateSchedulingEntryData[0U].AdminControlListLength; EntryIdx++)
5707 {
5708 TimeGateSchedulingEntryData[0U].GateEntryAdminControlListData[EntryIdx].AdminTimeInterval = 2000000U; /* the value is equal to transmit 128bytes + 20 bytes (header) frame with port speed 10M */
5709 TimeGateSchedulingEntryData[0U].GateEntryAdminControlListData[EntryIdx].AdminTrafficClassGateStates = 0xFFU; /* all open */
5710 TimeGateSchedulingEntryData[0U].GateEntryAdminControlListData[EntryIdx].AdminGateOperationType = ETHSWT_HOST_REQUEST_UNCHANGED;
5711 }
5712
5713 /* add these 2 gate control list entries */
5714 CBDRStatus = Netc_EthSwt_Ip_ConfigPortTimeGateScheduling(SwitchIdx, SwitchPortIdx, TRUE);
5715
5716 return CBDRStatus;
5717 }
5718 #endif
5719 #endif
5720
5721 /* inline function for enabling PCIE for the timer, MDIO, switch, and ENETC */
5722 static inline void Netc_EthSwt_Ip_EnablePCIE(void)
5723 {
5724 /* Enable PCIE for the TIMER */
5725 IP_NETC__NETC_F0_PCI_HDR_TYPE0->PCI_CFH_CMD = NETC_F0_PCI_HDR_TYPE0_PCI_CFH_CMD_BUS_MASTER_EN(1U) | NETC_F0_PCI_HDR_TYPE0_PCI_CFH_CMD_MEM_ACCESS(1U);
5726 /* Enable PCIE for the MDIO */
5727 IP_NETC__NETC_F1_PCI_HDR_TYPE0->PCI_CFH_CMD = NETC_F1_PCI_HDR_TYPE0_PCI_CFH_CMD_BUS_MASTER_EN(1U) | NETC_F1_PCI_HDR_TYPE0_PCI_CFH_CMD_MEM_ACCESS(1U);
5728 /* Enable PCIE for the Switch */
5729 IP_NETC__NETC_F2_PCI_HDR_TYPE0->PCI_CFH_CMD = NETC_F2_PCI_HDR_TYPE0_PCI_CFH_CMD_BUS_MASTER_EN(1U) | NETC_F2_PCI_HDR_TYPE0_PCI_CFH_CMD_MEM_ACCESS(1U);
5730 /* Enable PCIE for the ENETC */
5731 IP_NETC__NETC_F3_PCI_HDR_TYPE0->PCI_CFH_CMD = NETC_F3_PCI_HDR_TYPE0_PCI_CFH_CMD_BUS_MASTER_EN(1U) | NETC_F3_PCI_HDR_TYPE0_PCI_CFH_CMD_MEM_ACCESS(1U);
5732 }
5733
5734 /*FUNCTION**********************************************************************
5735 *
5736 * Function Name : Netc_EthSwt_Ip_ConfigSwt
5737 * Description : function for configuring the switch registers and ports
5738 *
5739 *END**************************************************************************/
5740 static Std_ReturnType Netc_EthSwt_Ip_ConfigSwt(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
5741 {
5742 Std_ReturnType status = E_OK;
5743 uint8 PortIndex;
5744 uint8 enabledPortMask = 0U;
5745
5746 Netc_EthSwt_Ip_NetcClockFrequency = Config->netcClockFrequency;
5747
5748 if(Config->EthSwtEnableSharedLearning)
5749 {
5750 IP_NETC__SW0_BASE->VFHTDECR1 = NETC_F2_VFHTDECR1_VL_MODE(1U) | NETC_F2_VFHTDECR1_FID(0U);
5751 }
5752 else
5753 {
5754 IP_NETC__SW0_BASE->VFHTDECR1 = NETC_F2_VFHTDECR1_VL_MODE(0U);
5755 }
5756
5757 IP_NETC__SW0_BASE->FDBHTMCR = NETC_F2_FDBHTMCR_DYN_LIMIT(Config->EthSwtMaxDynamicEntries);
5758 IP_NETC__SW0_COMMON->CVLANR1 = NETC_F2_COMMON_CVLANR1_V(Config->EthSwtCustomVlanEtherType1);
5759 IP_NETC__SW0_COMMON->CVLANR2 = NETC_F2_COMMON_CVLANR2_ETYPE(Config->EthSwtCustomVlanEtherType2);
5760
5761 /* Mapping profile initialization */
5762 InitMappingProfile(Config);
5763
5764 /* Initialize the ports of the switch */
5765 for (PortIndex = 0U; PortIndex < NETC_ETHSWT_NUMBER_OF_PORTS; PortIndex++)
5766 {
5767 status = Netc_EthSwt_Ip_InitPort(SwitchIdx, PortIndex, &(*((*(Config)).port))[PortIndex]);
5768
5769 if ( (TRUE == (*((*(Config)).port))[PortIndex].EthSwtPortMacLayerPortEnable) && (FALSE == (*((*(Config)).port))[PortIndex].iPort->vlanEnable ))
5770 {
5771 enabledPortMask |= (1U << PortIndex);
5772 }
5773 }
5774
5775 status |= Netc_EthSwt_Ip_EMDIOConfiguration(0U); /* init EMDIO configuration register */
5776
5777 /* Configure the VLAN filter hash default settings */
5778 IP_NETC__SW0_BASE->VFHTDECR0 = enabledPortMask; /* Add enabled ports to the default VLAN */
5779 /* To add Shared learning setting in EBT */
5780 /* set configured learning and forwarding options */
5781 IP_NETC__SW0_BASE->VFHTDECR2 = NETC_F2_VFHTDECR2_MLO(Config->MacLearningOption) | NETC_F2_VFHTDECR2_MFO(Config->MacForwardingOption);
5782
5783 /* used for port aging, value in sec */
5784 Netc_EthSwt_Ip_FdbTableEntryTimeout[SwitchIdx] = Config->EthSwtArlTableEntryTimeout;
5785
5786 /* +++ initialize 1588 timer for time gate scheduling +++ */
5787 InitTimer1588(Config);
5788 /* --- initialize 1588 timer for time gate scheduling --- */
5789
5790 /* initialize memory and length for command ring 0 and 1 */
5791 CmdBDRConfig[NETC_ETHSWT_IP_CBDR_0].CmdBDAddr = &SwtcommandRingDescriptor0[0U];
5792 CmdBDRConfig[NETC_ETHSWT_IP_CBDR_0].lengthCBDR = (NETC_ETHSWT_IP_CBDR0_LENGTH);
5793
5794 return status;
5795 }
5796
5797 /*FUNCTION**********************************************************************
5798 *
5799 * Function Name : Netc_EthSwt_Ip_ConfigTAS
5800 * Description : function for configuring the Time Aware Shaper for the switch
5801 *
5802 *END**************************************************************************/
5803 static Std_ReturnType Netc_EthSwt_Ip_ConfigTAS(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
5804 {
5805 Std_ReturnType status = E_OK;
5806 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
5807
5808 /* check if TAS is enabled or not */
5809 PortTimeAwareShaperEnabled[0U] = ((*((*(Config)).port))[0U].ePort->portTimeAwareShaperEnable ||
5810 (*((*(Config)).port))[1U].ePort->portTimeAwareShaperEnable ||
5811 (*((*(Config)).port))[2U].ePort->portTimeAwareShaperEnable) ? TRUE : FALSE;
5812
5813 if (TRUE == PortTimeAwareShaperEnabled[0U])
5814 {
5815 #if defined(ERR_IPV_NETC_E051130)
5816 #if (STD_ON == ERR_IPV_NETC_E051130)
5817 /* Default time gate scheduling conditions on the port 0 */
5818 CBDRStatus = InitTimeGateSchedulingFeature(SwitchIdx, 0U);
5819 if (CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES)
5820 {
5821 status = E_NOT_OK;
5822 }
5823 else
5824 {
5825 #endif
5826 #endif
5827 /* Add time gate scheduling table entries data */
5828 InitTimeGateSchedulingTableEntryData(Config);
5829 #if defined(ERR_IPV_NETC_E051130)
5830 #if (STD_ON == ERR_IPV_NETC_E051130)
5831 }
5832 #endif
5833 #endif
5834 }
5835 return status;
5836 }
5837
5838 #if (NETC_ETHSWT_NUMBER_OF_FDB_ENTRIES > 0U)
5839 /*FUNCTION**********************************************************************
5840 *
5841 * Function Name : Netc_EthSwt_Ip_ConfigFDBTable
5842 * Description : function for configuring the FDB Table for the switch
5843 *
5844 *END**************************************************************************/
5845 static Std_ReturnType Netc_EthSwt_Ip_ConfigFDBTable(const Netc_EthSwt_Ip_ConfigType * Config)
5846 {
5847 uint32 MatchedEntries = 0U;
5848 uint8 MacAddrByteIdx;
5849 uint8 FdbEntryIdx;
5850 Netc_EthSwt_Ip_FdbEntryDataType FdbTableEntry = {0};
5851
5852 Std_ReturnType status = E_OK;
5853 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
5854
5855 /* Add static FDB entries */
5856 for (FdbEntryIdx = 0U; FdbEntryIdx < Config->NumberOfFdbEntries; FdbEntryIdx++)
5857 {
5858 /* fill in data of Mac Address */
5859 for (MacAddrByteIdx = 0U; MacAddrByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacAddrByteIdx++)
5860 {
5861 FdbTableEntry.MacAddr[MacAddrByteIdx] = (*(Config->FdbEntries))[FdbEntryIdx].macAddr[MacAddrByteIdx];
5862 }
5863
5864 FdbTableEntry.FID = 0U; /* fill in data of FID */
5865 FdbTableEntry.SwitchPortEgressBitMask = (*(Config->FdbEntries))[FdbEntryIdx].ePortMask; /* fill in data of port bitmask */
5866 FdbTableEntry.DynamicEntry = FALSE; /* static entry */
5867
5868 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateFdbTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &FdbTableEntry);
5869 /* fail to add the static FDB entry */
5870 if ((CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES) || (MatchedEntries != 0U))
5871 {
5872 status = E_NOT_OK;
5873 break;
5874 }
5875
5876 }
5877 return status;
5878 }
5879 #endif
5880
5881 #if (NETC_ETHSWT_NUMBER_OF_STREAMIDENTIFICATION_ENTRIES > 0U)
5882 /*FUNCTION**********************************************************************
5883 *
5884 * Function Name : Netc_EthSwt_Ip_ConfigISITable
5885 * Description : function for configuring the IngressStreamIdentification Table for the switch
5886 *
5887 *END**************************************************************************/
5888 static Std_ReturnType Netc_EthSwt_Ip_ConfigISITable(const Netc_EthSwt_Ip_ConfigType * Config)
5889 {
5890 uint32 MatchedEntries = 0U;
5891 uint8 FrmKeyWordIdx;
5892 uint8 IsiEntryIdx;
5893 Netc_EthSwt_Ip_IngrStremIdentificationTableDataType IsiTableEntry = {0};
5894
5895 Std_ReturnType status = E_OK;
5896 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
5897
5898 /* Add key construction rules */
5899 IP_NETC__SW0_COMMON->ISIDKC0CR0 = (*(Config->EthSwtKeyConstruction))[0U].EthSwtKeyConstructionRegValue;
5900 IP_NETC__SW0_COMMON->ISIDKC1CR0 = (*(Config->EthSwtKeyConstruction))[1U].EthSwtKeyConstructionRegValue;
5901 IP_NETC__SW0_COMMON->ISIDKC2CR0 = (*(Config->EthSwtKeyConstruction))[2U].EthSwtKeyConstructionRegValue;
5902 IP_NETC__SW0_COMMON->ISIDKC3CR0 = (*(Config->EthSwtKeyConstruction))[3U].EthSwtKeyConstructionRegValue;
5903
5904 /* Add payload field values */
5905 IP_NETC__SW0_COMMON->ISIDKC0PF0CR = (*(Config->EthSwtKeyConstruction))[0U].EthSwtPayloadField0RegValue;
5906 IP_NETC__SW0_COMMON->ISIDKC0PF1CR = (*(Config->EthSwtKeyConstruction))[0U].EthSwtPayloadField1RegValue;
5907 IP_NETC__SW0_COMMON->ISIDKC1PF0CR = (*(Config->EthSwtKeyConstruction))[1U].EthSwtPayloadField0RegValue;
5908 IP_NETC__SW0_COMMON->ISIDKC1PF1CR = (*(Config->EthSwtKeyConstruction))[1U].EthSwtPayloadField1RegValue;
5909 IP_NETC__SW0_COMMON->ISIDKC2PF0CR = (*(Config->EthSwtKeyConstruction))[2U].EthSwtPayloadField0RegValue;
5910 IP_NETC__SW0_COMMON->ISIDKC2PF1CR = (*(Config->EthSwtKeyConstruction))[2U].EthSwtPayloadField1RegValue;
5911 IP_NETC__SW0_COMMON->ISIDKC3PF0CR = (*(Config->EthSwtKeyConstruction))[3U].EthSwtPayloadField0RegValue;
5912 IP_NETC__SW0_COMMON->ISIDKC3PF1CR = (*(Config->EthSwtKeyConstruction))[3U].EthSwtPayloadField1RegValue;
5913
5914 /* Add static IngressStreamIdentification entries */
5915 for (IsiEntryIdx = 0U; IsiEntryIdx < Config->NumberOfIsiEntries; IsiEntryIdx++)
5916 {
5917 IsiTableEntry.IngrStreamIdenResumeEntryId = (*(Config->IsiEntries))[IsiEntryIdx].IngrStreamIdenResumeEntryId;
5918 IsiTableEntry.IngrStreamIdenEntryId = (*(Config->IsiEntries))[IsiEntryIdx].IngrStreamIdenEntryId;
5919 IsiTableEntry.IngrStreamEntryId = (*(Config->IsiEntries))[IsiEntryIdx].IngrStreamEntryId;
5920 IsiTableEntry.Keye_Keytype = (*(Config->IsiEntries))[IsiEntryIdx].Keye_Keytype;
5921 IsiTableEntry.Keye_SrcPortId = (*(Config->IsiEntries))[IsiEntryIdx].Keye_SrcPortId;
5922 IsiTableEntry.Keye_Spm = (*(Config->IsiEntries))[IsiEntryIdx].Keye_Spm;
5923 for(FrmKeyWordIdx = 0; FrmKeyWordIdx < 4; FrmKeyWordIdx++)
5924 {
5925 IsiTableEntry.Keye_FrmKey[FrmKeyWordIdx] = (*(Config->IsiEntries))[IsiEntryIdx].Keye_FrmKey[FrmKeyWordIdx];
5926 }
5927 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateIngrStreamIdentificationTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &IsiTableEntry);
5928 /* fail to add the static IngressStreamIdentification entry */
5929 if ((CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES) || (MatchedEntries != 0U))
5930 {
5931 status = E_NOT_OK;
5932 break;
5933 }
5934
5935 }
5936 return status;
5937 }
5938 #endif
5939
5940 #if (NETC_ETHSWT_NUMBER_OF_SEQTAG_ENTRIES > 0U)
5941 /*FUNCTION**********************************************************************
5942 *
5943 * Function Name : Netc_EthSwt_Ip_ConfigISITable
5944 * Description : function for configuring the IngressStreamIdentification Table for the switch
5945 *
5946 *END**************************************************************************/
5947 static Std_ReturnType Netc_EthSwt_Ip_ConfigSeqGenTable(const Netc_EthSwt_Ip_ConfigType * Config)
5948 {
5949 uint32 MatchedEntries = 0U;
5950 uint8 SeqTagEntryIdx;
5951 Netc_EthSwt_Ip_ISQGTableDataType SeqTagTableEntry = {0};
5952
5953 Std_ReturnType status = E_OK;
5954 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
5955
5956 /* Add static SequenceTag entries */
5957 for (SeqTagEntryIdx = 0U; SeqTagEntryIdx < Config->NumberOfSeqTagEntries; SeqTagEntryIdx++)
5958 {
5959 SeqTagTableEntry.ISQGEntryId = (*(Config->SeqTagEntries))[SeqTagEntryIdx].ISQGEntryId;
5960 SeqTagTableEntry.Cfge_SQTagType = (*(Config->SeqTagEntries))[SeqTagEntryIdx].Cfge_SQTagType;
5961 SeqTagTableEntry.Sgse_SQGNum = (*(Config->SeqTagEntries))[SeqTagEntryIdx].Sgse_SQGNum;
5962 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateIngressSeqGenerationTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &SeqTagTableEntry);
5963 /* fail to add the static SequenceGeneration entry */
5964 if ((CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES) || (MatchedEntries != 0U))
5965 {
5966 status = E_NOT_OK;
5967 break;
5968 }
5969
5970 }
5971 return status;
5972 }
5973 #endif
5974
5975 #if (NETC_ETHSWT_NUMBER_OF_SEQRECOVERY_ENTRIES > 0U)
5976 /*FUNCTION**********************************************************************
5977 *
5978 * Function Name : Netc_EthSwt_Ip_ConfigISITable
5979 * Description : function for configuring the IngressStreamIdentification Table for the switch
5980 *
5981 *END**************************************************************************/
5982 static Std_ReturnType Netc_EthSwt_Ip_ConfigSeqRecTable(const Netc_EthSwt_Ip_ConfigType * Config)
5983 {
5984 uint32 MatchedEntries = 0U;
5985 uint8 SeqRecEntryIdx;
5986 Netc_EthSwt_Ip_EgrSeqRecoveryTableDataType SeqRecTableEntry = {0};
5987
5988 Std_ReturnType status = E_OK;
5989 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
5990
5991 /* Add static SequenceRecovery entries */
5992 for (SeqRecEntryIdx = 0U; SeqRecEntryIdx < Config->NumberOfSeqRecoveryEntries; SeqRecEntryIdx++)
5993 {
5994 SeqRecTableEntry.EgrSeqRecEntryId = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].EgrSeqRecEntryId;
5995 SeqRecTableEntry.Cfge_SQTag = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SQTag;
5996 SeqRecTableEntry.Cfge_SQRHisLen = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SQRHisLen;
5997 SeqRecTableEntry.Cfge_SQRFutureWinLen = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SQRFutureWinLen;
5998 SeqRecTableEntry.Cfge_SQRTimeOutPeriod = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SQRTimeOutPeriod;
5999 SeqRecTableEntry.Cfge_SqrTnsq = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SqrTnsq;
6000 SeqRecTableEntry.Cfge_SqrAlg = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SqrAlg;
6001 SeqRecTableEntry.Cfge_SqrType = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SqrType;
6002 CBDRStatus = Netc_EthSwt_Ip_UpdateEgressSeqRecoveryTableEntry(0U, &MatchedEntries, &SeqRecTableEntry);
6003 /* fail to add the static SequenceRecovery entry */
6004 if ((CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES) || (MatchedEntries != 1U))
6005 {
6006 status = E_NOT_OK;
6007 break;
6008 }
6009
6010 }
6011 return status;
6012 }
6013 #endif
6014
6015 #if (NETC_ETHSWT_NUMBER_OF_FRAMEMODIFICATION_ENTRIES > 0U)
6016 /*FUNCTION**********************************************************************
6017 *
6018 * Function Name : Netc_EthSwt_Ip_ConfigFrmModificationTable
6019 * Description : function for configuring the FrameModification Table for the switch
6020 *
6021 *END**************************************************************************/
6022 static Std_ReturnType Netc_EthSwt_Ip_ConfigFrmModificationTable(const Netc_EthSwt_Ip_ConfigType * Config)
6023 {
6024 uint32 MatchedEntries = 0U;
6025 uint8 FrmModifEntryIdx = 0U;
6026
6027 Std_ReturnType status = E_OK;
6028 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
6029 Netc_EthSwt_Ip_FrmModificationEntryDataType FrmModifTableEntry = {0};
6030
6031 for (FrmModifEntryIdx = 0U; FrmModifEntryIdx < Config->NumberOfFrmModifEntries; FrmModifEntryIdx++)
6032 {
6033 FrmModifTableEntry = (*(Config->FrameModificationEntries))[FrmModifEntryIdx];
6034 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateFrmModificationTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &FrmModifTableEntry);
6035
6036 if (CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES)
6037 {
6038 status = E_NOT_OK;
6039 break;
6040 }
6041 }
6042
6043 return status;
6044 }
6045 #endif
6046
6047 #if (NETC_ETHSWT_NUMBER_OF_EGRESSTREATMENT_ENTRIES > 0U)
6048 /*FUNCTION**********************************************************************
6049 *
6050 * Function Name : Netc_EthSwt_Ip_ConfigEgressTreatmentTable
6051 * Description : function for configuring the EgressTreatment Table for the switch
6052 *
6053 *END**************************************************************************/
6054 static Std_ReturnType Netc_EthSwt_Ip_ConfigEgressTreatmentTable(const Netc_EthSwt_Ip_ConfigType * Config)
6055 {
6056 uint32 MatchedEntries = 0U;
6057 uint8 EgrTrtEntryIdx = 0U;
6058
6059 Std_ReturnType status = E_OK;
6060 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
6061 Netc_EthSwt_Ip_EgressTreatmentEntryDataType EgrTrtTableEntry = {0};
6062
6063 for (EgrTrtEntryIdx = 0U; EgrTrtEntryIdx < Config->NumberOfEgrTreatmentEntries; EgrTrtEntryIdx++)
6064 {
6065 EgrTrtTableEntry = (*(Config->EgressTreatmentEntries))[EgrTrtEntryIdx];
6066 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateEgressTreatmentTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &EgrTrtTableEntry);
6067
6068 if (CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES)
6069 {
6070 status = E_NOT_OK;
6071 break;
6072 }
6073 }
6074
6075 return status;
6076 }
6077 #endif
6078
6079 #if (NETC_ETHSWT_NUMBER_OF_INGRESSSTREAM_ENTRIES > 0U)
6080 /*FUNCTION**********************************************************************
6081 *
6082 * Function Name : Netc_EthSwt_Ip_ConfigIngressStreamTable
6083 * Description : function for configuring the IngressStream Table for the switch
6084 *
6085 *END**************************************************************************/
6086 static Std_ReturnType Netc_EthSwt_Ip_ConfigIngressStreamTable(const Netc_EthSwt_Ip_ConfigType * Config)
6087 {
6088 uint32 MatchedEntries = 0U;
6089 uint8 IngrStrEntryIdx = 0U;
6090
6091 Std_ReturnType status = E_OK;
6092 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
6093 Netc_EthSwt_Ip_IngressStreamEntryDataType IngrStrTableEntry = {0};
6094
6095 for (IngrStrEntryIdx = 0U; IngrStrEntryIdx < Config->NumberOfIngrStreamEntries; IngrStrEntryIdx++)
6096 {
6097 IngrStrTableEntry = (*(Config->IngressStreamEntries))[IngrStrEntryIdx];
6098 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateIngressStreamTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &IngrStrTableEntry);
6099
6100 if (CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES)
6101 {
6102 status = E_NOT_OK;
6103 break;
6104 }
6105 }
6106
6107 return status;
6108 }
6109 #endif
6110
6111 #if (NETC_ETHSWT_NUMBER_OF_VLANFILTER_ENTRIES > 0U)
6112 /*FUNCTION**********************************************************************
6113 *
6114 * Function Name : Netc_EthSwt_Ip_ConfigVLANFilterTable
6115 * Description : function for configuring the VLAN Filter Table for the switch
6116 *
6117 *END**************************************************************************/
6118 static Std_ReturnType Netc_EthSwt_Ip_ConfigVLANFilterTable(const Netc_EthSwt_Ip_ConfigType * Config)
6119 {
6120
6121 uint32 VlanMatchedEntries = 0U;
6122 uint8 VlanEntryIdx;
6123 Netc_EthSwt_Ip_VlanFilterEntryDataType VlanFilterEntryData = {0};
6124
6125 Std_ReturnType status = E_OK;
6126 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
6127
6128 /* Add Vlan Filter entries */
6129 for (VlanEntryIdx = 0U; VlanEntryIdx < Config->NumberOfVlanFilterEntries; VlanEntryIdx++)
6130 {
6131 /* fill in VlanFilterEntryData structure */
6132 VlanFilterEntryData.VlanID = (*(Config->VlanFilterEntries))[VlanEntryIdx].vlanId;
6133 VlanFilterEntryData.PortMembershipBitmap = (*(Config->VlanFilterEntries))[VlanEntryIdx].iPortMask;
6134
6135 if (Config->EthSwtEnableSharedLearning == FALSE)
6136 {
6137 VlanFilterEntryData.FID = VlanFilterEntryData.VlanID; /* for independent vlan learning, the FID should be equal to TCI */
6138 }
6139 else
6140 {
6141 VlanFilterEntryData.FID = (0U); /* for shared vlan learning, the FID should be always equal to 0 */
6142 }
6143
6144 VlanFilterEntryData.MacLearningOptions = Config->MacLearningOption; /* enable mac learning */
6145 VlanFilterEntryData.MacForwardingOptions = Config->MacForwardingOption; /* FDB lookup, if there is no match, then frame is flooded */
6146 VlanFilterEntryData.IpMulticastFloodingEnable = FALSE; /* IP multicast flooding disable */
6147 VlanFilterEntryData.IpMulticastFilteringEnable = FALSE; /* IP multicast filtering disable */
6148 VlanFilterEntryData.BaseEgressTreatmentEntryID = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID; /* egress treatment processing is by-passed */
6149
6150 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry(0U, NETC_ETHSWT_ADD_CMD, &VlanMatchedEntries, &VlanFilterEntryData);
6151 /* fail to add the Vlan Filter entry */
6152 if ((CBDRStatus != NETC_ETHSWT_CBDRSTATUS_SUCCES) || (VlanMatchedEntries != 0U))
6153 {
6154 status = E_NOT_OK;
6155 break;
6156 }
6157 }
6158 return status;
6159 }
6160 #endif
6161
6162
6163 /*FUNCTION**********************************************************************
6164 *
6165 * Function Name : Netc_EthSwt_Ip_Init
6166 * Description : function for initializing a switch
6167 * implements Netc_EthSwt_Ip_Init_Activity
6168 *END**************************************************************************/
6169 Std_ReturnType Netc_EthSwt_Ip_Init(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
6170 {
6171 Std_ReturnType status = E_OK;
6172 uint8 portIdx = 0U;
6173 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
6174
6175 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6176 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6177 DevAssert(Config != NULL_PTR);
6178 #endif
6179
6180 /* enable PCIE for the timer, MDIO, switch, and ENETC */
6181 Netc_EthSwt_Ip_EnablePCIE();
6182
6183 status = Netc_EthSwt_Ip_IerbReady();
6184
6185 if(status == (uint8)(E_OK))
6186 {
6187 /* configure switch registers and ports */
6188 status = Netc_EthSwt_Ip_ConfigSwt(SwitchIdx,Config);
6189
6190 /* intialize command ring 0 */
6191 CBDRStatus = Netc_EthSwt_Ip_InitCommandBDR(0U, NETC_ETHSWT_IP_CBDR_0);
6192 if (NETC_ETHSWT_CBDRSTATUS_SUCCES == CBDRStatus)
6193 {
6194 #if (NETC_ETHSWT_NUMBER_OF_FDB_ENTRIES > 0U)
6195 /* Configure FDB table */
6196 status |= Netc_EthSwt_Ip_ConfigFDBTable(Config);
6197 #endif
6198
6199 #if (NETC_ETHSWT_NUMBER_OF_RP_ENTRIES > 0U)
6200 status |= Netc_EthSwt_Ip_ConfigRP(SwitchIdx,Config);
6201 #endif
6202
6203 #if (NETC_ETHSWT_NUMBER_OF_SGCL_ENTRIES > 0U)
6204 status |= Netc_EthSwt_Ip_ConfigSGCL(SwitchIdx,Config);
6205 #endif
6206
6207 #if (NETC_ETHSWT_NUMBER_OF_SGI_ENTRIES > 0U)
6208 status |= Netc_EthSwt_Ip_ConfigSGI(SwitchIdx,Config);
6209 #endif
6210
6211 #if (NETC_ETHSWT_NUMBER_OF_VLANFILTER_ENTRIES > 0U)
6212 /* Configure VLAN Filter table */
6213 status |= Netc_EthSwt_Ip_ConfigVLANFilterTable(Config);
6214 #endif
6215 /* Configure Time Aware Shaper */
6216 status |= Netc_EthSwt_Ip_ConfigTAS(SwitchIdx, Config);
6217
6218 #if (NETC_ETHSWT_NUMBER_OF_STREAMIDENTIFICATION_ENTRIES > 0U)
6219 /* Configure IngressStreamIdentification table */
6220 status |= Netc_EthSwt_Ip_ConfigISITable(Config);
6221 #endif
6222
6223 #if (NETC_ETHSWT_NUMBER_OF_SEQTAG_ENTRIES > 0U)
6224 /* Configure IngressSequenceGeneration table */
6225 status |= Netc_EthSwt_Ip_ConfigSeqGenTable(Config);
6226 #endif
6227
6228 #if (NETC_ETHSWT_NUMBER_OF_SEQRECOVERY_ENTRIES > 0U)
6229 /* Configure EgressSequenceRecovery table */
6230 status |= Netc_EthSwt_Ip_ConfigSeqRecTable(Config);
6231 #endif
6232 #if (NETC_ETHSWT_NUMBER_OF_EGRESSTREATMENT_ENTRIES > 0U)
6233 /* Configure EgressTreatment table */
6234 status |= Netc_EthSwt_Ip_ConfigEgressTreatmentTable(Config);
6235 #endif
6236 #if (NETC_ETHSWT_NUMBER_OF_FRAMEMODIFICATION_ENTRIES > 0U)
6237 /* Configure FrameModification table */
6238 status |= Netc_EthSwt_Ip_ConfigFrmModificationTable(Config);
6239 #endif
6240 #if (NETC_ETHSWT_NUMBER_OF_INGRESSSTREAM_ENTRIES > 0U)
6241 /* Configure IngressStream table */
6242 status |= Netc_EthSwt_Ip_ConfigIngressStreamTable(Config);
6243 #endif
6244 /* Enable Ingress Port Filtering for ports
6245 (for PTP and Mirroring)
6246 PTP traffic from PSI is injected as Tx management on desired external port and therefore not passing as Rx through pseudo-ports.
6247 PTP frames sent to external devices from PSI will not be filtered when filtering on pseudo-ports is enabled.
6248 Only PTP frames from VSIs will be redirected to Ingress on PSI when filtering is enabled on pseudo-ports. */
6249 for (portIdx = 0U; portIdx < NETC_ETHSWT_NUMBER_OF_PORTS; portIdx++)
6250 {
6251 status |= Netc_EthSwt_Ip_EnableIngressPortFiltering(SwitchIdx, portIdx, TRUE);
6252 }
6253 }
6254 else
6255 {
6256 status = E_NOT_OK;
6257 }
6258 }
6259
6260 return status;
6261 }
6262
6263 /*FUNCTION**********************************************************************
6264 *
6265 * Function Name : Netc_EthSwt_Ip_EMDIOConfiguration
6266 * Description : function for configuring the EMDIO
6267 *
6268 *END**************************************************************************/
6269 static Std_ReturnType Netc_EthSwt_Ip_EMDIOConfiguration( uint8 SwitchIdx )
6270 {
6271 Std_ReturnType Status = E_OK;
6272 uint32 CfgData;
6273
6274 (void)SwitchIdx;
6275 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6276 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6277 #endif
6278
6279 CfgData = NETC_F1_EMDIO_CFG_CMP(0U) | NETC_F1_EMDIO_CFG_CIM(0U) | NETC_F1_EMDIO_CFG_NEG(1U) \
6280 | NETC_F1_EMDIO_CFG_EHOLD(0U) | NETC_F1_EMDIO_CFG_MDIO_CLK_DIV(NETC_ETHSWT_IP_MDIO_CLK_DIV) \
6281 | NETC_F1_EMDIO_CFG_ENC45(0U) | NETC_F1_EMDIO_CFG_PRE_DIS(0U) | NETC_F1_EMDIO_CFG_MDIO_HOLD(4U);
6282
6283 /* config EMDIO_CFG register */
6284 IP_NETC__EMDIO_BASE->EMDIO_CFG = CfgData;
6285
6286 return Status;
6287 }
6288
6289 /*FUNCTION**********************************************************************
6290 *
6291 * Function Name : Netc_EthSwt_Ip_ReadTrcvRegister
6292 * Description : External function for reading the content of a transceiver register
6293 * implements Netc_EthSwt_Ip_ReadTrcvRegister_Activity
6294 *END**************************************************************************/
6295 Std_ReturnType Netc_EthSwt_Ip_ReadTrcvRegister( uint8 SwitchIdx, uint8 TrcvIdx, uint8 RegIdx, uint16 * RegVal )
6296 {
6297 Std_ReturnType Status = E_NOT_OK;
6298 uint32 CtrlData;
6299 uint32 StartTime;
6300 uint32 ElapsedTime;
6301 uint32 TimeoutTicks;
6302
6303 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6304 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6305 #endif
6306
6307 (void)SwitchIdx;
6308
6309 CtrlData = NETC_F1_EMDIO_CTL_PORT_ADDR(TrcvIdx) | NETC_F1_EMDIO_CTL_DEV_ADDR(RegIdx) \
6310 | NETC_F1_EMDIO_CTL_READ(1U);
6311
6312 /* config EMDIO_CTL register */
6313 IP_NETC__EMDIO_BASE->EMDIO_CTL = CtrlData;
6314
6315 /* Wait till MDIO transaction is occuring and no read error is detected */
6316 Netc_EthSwt_Ip_StartTimeOut(&StartTime, &ElapsedTime, &TimeoutTicks, NETC_ETHSWT_IP_TIMEOUT_VALUE_US);
6317 do
6318 {
6319 if ((IP_NETC__EMDIO_BASE->EMDIO_CFG & NETC_ETHSWT_IP_MDIO_REG_READ_FLAG) == 0x0U)
6320 {
6321 Status = E_OK;
6322 break;
6323 }
6324 } while (!Netc_EthSwt_Ip_TimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks));
6325
6326 /* Read the Data */
6327 if ((uint8)(E_OK) == Status)
6328 {
6329 *RegVal = (uint16)(IP_NETC__EMDIO_BASE->EMDIO_DATA & NETC_F1_EMDIO_DATA_MDIO_DATA_MASK);
6330 }
6331
6332 return Status;
6333 }
6334
6335 /*FUNCTION**********************************************************************
6336 *
6337 * Function Name : Netc_EthSwt_Ip_WriteTrcvRegister
6338 * Description : External function for writing the content of a transceiver register
6339 * implements Netc_EthSwt_Ip_WriteTrcvRegister_Activity
6340 *END**************************************************************************/
6341 Std_ReturnType Netc_EthSwt_Ip_WriteTrcvRegister( uint8 SwitchIdx, uint8 TrcvIdx, uint8 RegIdx, uint16 RegVal )
6342 {
6343 Std_ReturnType Status = E_NOT_OK;
6344 uint32 CtrlData;
6345 uint32 StartTime;
6346 uint32 ElapsedTime;
6347 uint32 TimeoutTicks;
6348
6349 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6350 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6351 #endif
6352
6353 (void)SwitchIdx;
6354
6355 CtrlData = NETC_F1_EMDIO_CTL_PORT_ADDR(TrcvIdx) | NETC_F1_EMDIO_CTL_DEV_ADDR(RegIdx);
6356
6357 /* config EMDIO_CTL register */
6358 IP_NETC__EMDIO_BASE->EMDIO_CTL = CtrlData;
6359
6360 /* Write MDIO_DATA for initiating write transaction to PHY */
6361 IP_NETC__EMDIO_BASE->EMDIO_DATA = RegVal;
6362
6363 /* Wait till MDIO transaction is occuring */
6364 Netc_EthSwt_Ip_StartTimeOut(&StartTime, &ElapsedTime, &TimeoutTicks, NETC_ETHSWT_IP_TIMEOUT_VALUE_US);
6365 do
6366 {
6367 if ((IP_NETC__EMDIO_BASE->EMDIO_CFG & NETC_ETHSWT_IP_MDIO_REG_WRITE_FLAG) == 0x0U)
6368 {
6369 Status = E_OK;
6370 break;
6371 }
6372 } while (!Netc_EthSwt_Ip_TimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks));
6373
6374 return Status;
6375 }
6376
6377 /*FUNCTION**********************************************************************
6378 *
6379 * Function Name : Netc_EthSwt_Ip_GetPortMirrorState
6380 * Description : External function for obtaining the current status of mirroring for the indexed Ethernet switch
6381 * implements Netc_EthSwt_Ip_GetMirrorState_Activity
6382 *END**************************************************************************/
6383 Std_ReturnType Netc_EthSwt_Ip_GetMirrorState( uint8 SwitchIdx, Netc_EthSwt_Ip_SwitchMirrorStateType *MirrorStatePtr )
6384 {
6385 Std_ReturnType Status = E_OK;
6386 uint32 MirrorState;
6387
6388 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6389 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6390 DevAssert(MirrorStatePtr != NULL_PTR);
6391 #endif
6392
6393 (void)SwitchIdx;
6394
6395 MirrorState = (IP_NETC__SW0_BASE->IMDCR0) & NETC_F2_IMDCR0_MIREN_MASK;
6396 *MirrorStatePtr = (MirrorState == 0U) ? (NETC_ETHSWT_MIRROR_DISABLED) : (NETC_ETHSWT_MIRROR_ENABLED);
6397
6398 return Status;
6399 }
6400
6401 /*FUNCTION**********************************************************************
6402 *
6403 * Function Name : Netc_EthSwt_Ip_SetMirrorState
6404 * Description : External function for requesting to set the mirroring state of the given Ethernet switch.
6405 * implements Netc_EthSwt_Ip_SetMirrorState_Activity
6406 *END**************************************************************************/
6407 Std_ReturnType Netc_EthSwt_Ip_SetMirrorState( uint8 SwitchIdx, Netc_EthSwt_Ip_SwitchMirrorStateType MirrorState )
6408 {
6409 Std_ReturnType Status = E_OK;
6410 uint32 RegIMDCR0 = 0x0UL;
6411
6412 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6413 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6414 #endif
6415
6416 (void)SwitchIdx;
6417 RegIMDCR0 = IP_NETC__SW0_BASE->IMDCR0;
6418 if (NETC_ETHSWT_MIRROR_ENABLED == MirrorState)
6419 {
6420 RegIMDCR0 |= NETC_F2_IMDCR0_MIREN(NETC_ETHSWT_MIRROR_ENABLED);
6421 }
6422 else
6423 {
6424 RegIMDCR0 &= ~NETC_F2_IMDCR0_MIREN(NETC_ETHSWT_MIRROR_ENABLED);
6425 }
6426
6427 IP_NETC__SW0_BASE->IMDCR0 = RegIMDCR0;
6428
6429 return Status;
6430 }
6431
6432 /*FUNCTION**********************************************************************
6433 *
6434 * Function Name : Netc_EthSwt_Ip_DeleteMirrorConfiguration
6435 * Description : External function for deleting the mirror configuration of the given Ethernet switch..
6436 * implements Netc_EthSwt_Ip_DeleteMirrorConfiguration_Activity
6437 *END**************************************************************************/
6438 Std_ReturnType Netc_EthSwt_Ip_DeleteMirrorConfiguration( uint8 MirroredSwitchIdx )
6439 {
6440 Std_ReturnType Status = E_OK;
6441 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
6442 uint16 EFMEntryId;
6443 uint8 MIRDestBit;
6444 uint32 MatchedEntries = 0U;
6445 uint32 LocalImdCr1 = 0U;
6446
6447 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6448 DevAssert(MirroredSwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6449 #endif
6450 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_06();
6451 if (TRUE == MirrorConfigurationDone)
6452 {
6453 if (MirroringIngressPortFilterEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID)
6454 {
6455 /* Delete ingress port filter entry */
6456 CBDRStatus = Netc_EthSwt_Ip_DeleteIngressPortFilterTableEntry(MirroredSwitchIdx, &MatchedEntries, MirroringIngressPortFilterEntryId);
6457 if ((NETC_ETHSWT_CBDRSTATUS_SUCCES != CBDRStatus) || (0UL == MatchedEntries))
6458 {
6459 Status = E_NOT_OK;
6460 }
6461 else
6462 {
6463 /* Set ingress port filter entry to NULL again */
6464 MirroringIngressPortFilterEntryId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
6465 Status = E_OK;
6466 }
6467 }
6468
6469 /* Delete Frame modificatin entry */
6470 MIRDestBit = (uint8)((IP_NETC__SW0_BASE->IMDCR0 & NETC_F2_IMDCR0_MIRDEST_MASK) >> NETC_F2_IMDCR0_MIRDEST_SHIFT);
6471 /* Read the register value in a local variable since it should have been read more than once. */
6472 LocalImdCr1 = IP_NETC__SW0_BASE->IMDCR1;
6473 EFMEntryId = (uint16)(LocalImdCr1 & NETC_F2_IMDCR1_EFMEID_MASK);
6474 if ((EFMEntryId != NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID) && (MIRDestBit == (uint8)0U))
6475 {
6476 CBDRStatus = Netc_EthSwt_Ip_DeleteFrmModificationTableEntry(MirroredSwitchIdx, EFMEntryId, &MatchedEntries);
6477 if ((NETC_ETHSWT_CBDRSTATUS_SUCCES != CBDRStatus) || (0U == MatchedEntries))
6478 {
6479 Status = E_NOT_OK;
6480 }
6481 else
6482 {
6483 EFMEntryId = (uint16)(NETC_F2_IMDCR1_EFMEID(NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID)); /* set frame modification table entry ID to NULL */
6484 LocalImdCr1 |= EFMEntryId;
6485 IP_NETC__SW0_BASE->IMDCR1 = LocalImdCr1;
6486 Status = E_OK;
6487 }
6488 }
6489 if ((uint8)(E_OK) == Status)
6490 {
6491 Status = Netc_EthSwt_Ip_SetMirrorState(MirroredSwitchIdx, NETC_ETHSWT_MIRROR_DISABLED);
6492
6493 /* Disable ingress mirroring on all ports */
6494 Netc_EthSwt_Ip_SW0_PortxBaseAddr[0U]->PMCR = 0x0U;
6495 Netc_EthSwt_Ip_SW0_PortxBaseAddr[1U]->PMCR = 0x0U;
6496 Netc_EthSwt_Ip_SW0_PortxBaseAddr[2U]->PMCR = 0x0U;
6497
6498 MirrorConfigurationDone = FALSE;
6499 }
6500 }
6501
6502 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_06();
6503
6504 return Status;
6505 }
6506
6507 /* inline function for checking if mac address filter enabled or not */
6508 static inline void CheckMacAddressFilterEnableFlag(boolean *SrcMacAddrFilterEnabled, boolean *DstMacAddrFilterEnabled, const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr)
6509 {
6510 uint8 MacByteIdx;
6511
6512 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
6513 {
6514 if (MirrorConfigurationPtr->SrcMacAddrFilter[MacByteIdx] != 0x0U)
6515 {
6516 *SrcMacAddrFilterEnabled = TRUE;
6517 break;
6518 }
6519 }
6520 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
6521 {
6522 if (MirrorConfigurationPtr->DstMacAddrFilter[MacByteIdx] != 0x0U)
6523 {
6524 *DstMacAddrFilterEnabled = TRUE;
6525 break;
6526 }
6527 }
6528 }
6529
6530
6531 /*FUNCTION**********************************************************************
6532 *
6533 * Function Name : Netc_EthSwt_Ip_ConfigIngressPortFilterForTimestamping
6534 * implements Netc_EthSwt_Ip_ConfigIngressPortFilterForTimestamping_Activity
6535 *END**************************************************************************/
6536 Std_ReturnType Netc_EthSwt_Ip_ConfigIngressPortFilterForTimestamping(uint8 SwitchIdx)
6537 {
6538
6539 Netc_EthSwt_Ip_IngressPortFilterEntryDataType IngressPortFilterTableEntry = {0};
6540 uint8 Index;
6541 uint32 MatchedEntries;
6542 Std_ReturnType Status;
6543
6544 /* CFGE Data */
6545 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeOverrideIpv = FALSE; /* Leave IPV as-is */
6546 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeOverrideDr = FALSE; /* Leave DR as-is */
6547 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeFilterForwardingAction = NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_REDIRECTFRAMES; /* Redirect frame to management port*/
6548 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeIngressMirroringEnable = FALSE; /* Ingress Mirroring disabled */
6549 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeWakeOnLanTriggerEnable = FALSE; /* Wake-On-LAN triggering disabled */
6550 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeFilterAction = NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_NOACTION; /* Not routing to any RP/Ingress Stream */
6551 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeHostReason = (uint8)NETC_ETHSWT_IP_HOSTREASON_SW_PTP; /* Software-defined hostreason to mark frame as PTP-specific */
6552 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeTargetForSelectedFilterAction = 0xFFFFFFFFUL; /* RP/Ingress Stream by-passed */
6553
6554 /* KEYE Data */
6555 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyePrecedence = 0xFFFFU; /* Set highest priority for filter */
6556 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeFrmAttributeFlagsMask = 0x0U; /* Mask all frame attribute flags (Do not filter based on them) */
6557 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePointMask = 0x0U; /* Do not filter based on Differentiated Services Code Point */
6558 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeSourcePortIDMask = 0x0U; /* Do not filter based on Source Port */
6559 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformationMask = 0x0U; /* Do not filter based on Outer VLAN Tag Control Information */
6560 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformationMask = 0x0U; /* Do not filter based on Inner VLAN Tag Control Information */
6561 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeEtherTypeMask = 0x0U; /* Do not filter based on EtherType */
6562 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeIPProtocolMask = 0x0U; /* Do not filter based on IP Protocol field */
6563 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeL4SourcePortMask = 0x0U; /* Do not filter based on L4 Source Port */
6564 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeL4DestinationPortMask = 0x0U; /* Do not filter based on L4 Destination Port */
6565
6566 for (Index = 0; Index < 6U; Index++)
6567 {
6568 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddrMask[Index] = 0xFU; /* Filter based on Destination MAC Address */
6569 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeSrcMacAddrMask[Index] = 0x0U; /* Do not filter based on Source MAC Address */
6570 }
6571 for (Index = 0; Index < 4U; Index++)
6572 {
6573 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeIPSourceAddressMask[Index] = 0x0U; /* Do not filter based on IP Source Address */
6574 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeIPDestinationAddressMask[Index] = 0x0U; /* Do not filter based on IP Destination Address */
6575 }
6576 for (Index = 0; Index < 24U; Index++)
6577 {
6578 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyePayloadBytesMask[Index] = 0x0U; /* Do not filter based on Payload Bytes */
6579 }
6580
6581 /* Generic PTP messages DMAC: 01-1B-19-00-00-00 */
6582 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[0U] = 0x01U;
6583 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[1U] = 0x1BU;
6584 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[2U] = 0x19U;
6585 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[3U] = 0x00U;
6586 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[4U] = 0x00U;
6587 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[5U] = 0x00U;
6588 Status = (Netc_EthSwt_Ip_AddIngressPortFilterTableEntry(SwitchIdx, &MatchedEntries, &IngressPortFilterTableEntry) == NETC_ETHSWT_CBDRSTATUS_SUCCES) ? E_OK : E_NOT_OK;
6589
6590 if (Status == E_OK)
6591 {
6592 /* Peer delay message DMAC: 01-80-C2-00-00-0E */
6593 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[1U] = 0x80U;
6594 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[2U] = 0xC2U;
6595 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[5U] = 0x0EU;
6596 Status = (Netc_EthSwt_Ip_AddIngressPortFilterTableEntry(SwitchIdx, &MatchedEntries, &IngressPortFilterTableEntry) == NETC_ETHSWT_CBDRSTATUS_SUCCES) ? E_OK : E_NOT_OK;
6597 }
6598
6599 return Status;
6600 }
6601
6602 /* inline function for enabling mac address filtering for port mirroring*/
6603 static inline Std_ReturnType Netc_EthSwt_Ip_ConfigIngressPortFilterForPortMirroring(uint8 MirroredSwitchIdx, const boolean *SrcMacAddrFilterEnabled,
6604 const boolean *DstMacAddrFilterEnabled,
6605 const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr,
6606 Netc_EthSwt_Ip_IngressPortFilterEntryDataType *IngressPortFilterTableEntry
6607 )
6608 {
6609 Std_ReturnType Status = E_OK;
6610 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
6611 uint8 MacByteIdx;
6612 uint8 PayloadByteIdx;
6613 uint32 MatchedEntries;
6614
6615 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6616 DevAssert(MirroredSwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6617 #endif
6618
6619 /* config and add one ingress port filter table entry */
6620 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeOverrideIpv = FALSE;
6621 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeOverrideDr = FALSE;
6622 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeIngressMirroringEnable = TRUE; /* enable mirroring */
6623 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeWakeOnLanTriggerEnable = FALSE;
6624 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeCutThroughDisable = TRUE; /* shoudl disable CTD */
6625 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeTimestampCaptureEable = FALSE;
6626 /* permit frames */
6627 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeFilterForwardingAction = NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_PERMITFRAMES;
6628 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeFilterAction = NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_NOACTION;
6629
6630 /* enable mac address filtering */
6631 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
6632 {
6633 if (*DstMacAddrFilterEnabled == TRUE)
6634 {
6635 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[MacByteIdx] = 0xFFU;
6636 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[MacByteIdx] = MirrorConfigurationPtr->DstMacAddrFilter[MacByteIdx];
6637 MirrorCfgBackup.DstMacAddrFilter[MacByteIdx] = MirrorConfigurationPtr->DstMacAddrFilter[MacByteIdx];
6638 }
6639 else
6640 {
6641 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[MacByteIdx] = 0x0U;
6642 MirrorCfgBackup.DstMacAddrFilter[MacByteIdx] = 0x0U;
6643 }
6644
6645 if (*SrcMacAddrFilterEnabled == TRUE)
6646 {
6647 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[MacByteIdx] = 0xFFU;
6648 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[MacByteIdx] = MirrorConfigurationPtr->SrcMacAddrFilter[MacByteIdx];
6649 MirrorCfgBackup.SrcMacAddrFilter[MacByteIdx] = MirrorConfigurationPtr->SrcMacAddrFilter[MacByteIdx];
6650 }
6651 else
6652 {
6653 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[MacByteIdx] = 0x0U;
6654 MirrorCfgBackup.SrcMacAddrFilter[MacByteIdx] = 0x0U;
6655 }
6656 }
6657
6658 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeFrmAttributeFlagsMask = 0U;
6659 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSourcePortIDMask = 0U;
6660 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePointMask = 0U;
6661 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformationMask = 0U;
6662 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeEtherTypeMask = 0U;
6663 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPProtocolMask = 0U;
6664 for (MacByteIdx = 0U; MacByteIdx < 4U; MacByteIdx++)
6665 {
6666 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPSourceAddressMask[MacByteIdx] = 0x0U;
6667 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPDestinationAddressMask[MacByteIdx] = 0x0U;
6668 }
6669 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4SourcePortMask = 0U;
6670 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4DestinationPortMask = 0U;
6671 for (PayloadByteIdx = 0U; PayloadByteIdx < 24U; PayloadByteIdx++)
6672 {
6673 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytesMask[PayloadByteIdx] = 0x0U;
6674 }
6675 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePrecedence = NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID; /* precedence, maximum priority */
6676
6677 if (MirrorConfigurationPtr->VlanIdFilter != NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID)
6678 {
6679 MirrorCfgBackup.VlanIdFilter = MirrorConfigurationPtr->VlanIdFilter;
6680
6681 /* vlan id filter */
6682 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformationMask = 0xFFF0U;
6683 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformation = (MirrorConfigurationPtr->VlanIdFilter);
6684 }
6685 else
6686 {
6687 MirrorCfgBackup.VlanIdFilter = NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID;
6688 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformationMask = 0x0U;
6689 }
6690
6691 CBDRStatus = Netc_EthSwt_Ip_AddIngressPortFilterTableEntry(MirroredSwitchIdx, &MatchedEntries, IngressPortFilterTableEntry);
6692 if ((NETC_ETHSWT_CBDRSTATUS_SUCCES != CBDRStatus) || (1U == MatchedEntries))
6693 {
6694 Status = E_NOT_OK;
6695 }
6696 else
6697 {
6698 /* Store the ingress port filter entry id */
6699 MirroringIngressPortFilterEntryId = IngressPortFilterTableEntry->IngressPortFilterEntryID;
6700 }
6701
6702 return Status;
6703 }
6704
6705 /* inline function for retagging /double tagging egress frames with frame modification table entry */
6706 static inline Std_ReturnType Netc_EthSwt_Ip_ConfigEgressFrameModificationForPortMirroring(uint8 MirroredSwitchIdx, const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr)
6707 {
6708 Std_ReturnType Status = E_OK;
6709 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
6710 uint32 RegIMDCR1 = 0x0UL;
6711 uint32 MatchedEntries = 0x0UL;
6712 Netc_EthSwt_Ip_FrmModificationEntryDataType FrmModificationEntry = {0};
6713
6714 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6715 DevAssert(MirroredSwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6716 #endif
6717
6718 if (MirrorConfigurationPtr->MirroringMode != NETC_ETHSWT_NO_VLAN_RETAGGING)
6719 {
6720 /* config and add one frame modification table entry for modifying the dest mac address */
6721 FrmModificationEntry.FrmModificationEntryID = NETC_ETHSWT_EFMEID_FOR_MIRRORING; /* default frame modification table entry ID for mirroring */
6722 FrmModificationEntry.L2Actions = 0U;
6723 FrmModificationEntry.L2HeaderMacActions = 0U; /* no actions for Header Mac */
6724 FrmModificationEntry.L2HeaderVlanActions = (MirrorConfigurationPtr->MirroringMode > NETC_ETHSWT_VLAN_RETAGGING) ? (2U) : (3U);
6725 FrmModificationEntry.OuterVidActions = 1U; /* Use the VID specified in the OUTER_VLAN_VID field of this entry */
6726 FrmModificationEntry.OuterVlanVID = MirrorConfigurationPtr->VlanId;
6727 FrmModificationEntry.OuterTpidAction = 0U; /* Use TPID, PCP and DEI from outer VLAN header */
6728 FrmModificationEntry.OuterDeiAction = 0U; /* Use TPID, PCP and DEI from outer VLAN header */
6729 FrmModificationEntry.OuterPcpAction = 0U; /* Use TPID, PCP and DEI from outer VLAN header */
6730 FrmModificationEntry.SequenceTagAction = 0U;
6731 FrmModificationEntry.PayloadActions = 0U;
6732 FrmModificationEntry.FrmModificationDataEntryID = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID; /* frame modification data table entry id */
6733
6734 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateFrmModificationTableEntry(MirroredSwitchIdx, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &FrmModificationEntry);
6735 if (NETC_ETHSWT_CBDRSTATUS_SUCCES == CBDRStatus)
6736 {
6737 /* [IMDCR0]: keep IPV and DR default in IMDCR0 register */
6738 /* [IMDCR1] */
6739 RegIMDCR1 = NETC_F2_IMDCR1_EFM_LEN_CHANGE(NETC_ETHSWT_EFM_LEN_CHANGE_FOR_MIRRORING);
6740 RegIMDCR1 |= NETC_F2_IMDCR1_EFMEID(NETC_ETHSWT_EFMEID_FOR_MIRRORING); /* default frame modification table entry ID for mirroring */
6741 IP_NETC__SW0_BASE->IMDCR1 = RegIMDCR1;
6742 }
6743 else
6744 {
6745 Status = E_NOT_OK;
6746 }
6747 }
6748
6749 return Status;
6750 }
6751
6752 /*FUNCTION**********************************************************************
6753 *
6754 * Function Name : Netc_EthSwt_Ip_WriteMirrorConfiguration
6755 * Description : Function used for writing a mirroring configuration
6756 * implements Netc_EthSwt_Ip_WriteMirrorConfiguration_Activity
6757 *END**************************************************************************/
6758 Std_ReturnType Netc_EthSwt_Ip_WriteMirrorConfiguration( uint8 MirroredSwitchIdx, const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr )
6759 {
6760 Std_ReturnType Status = E_OK;
6761 uint32 RegIMDCR0 = 0x0UL;
6762 uint32 RegIMDCR1 = 0x0UL;
6763 uint8 PortIdx;
6764 uint32 IngressBitMask;
6765 boolean DstMacAddrFilterEnabled = FALSE;
6766 boolean SrcMacAddrFilterEnabled = FALSE;
6767 Netc_EthSwt_Ip_IngressPortFilterEntryDataType IngressPortFilterTableEntry = {0};
6768
6769
6770 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6771 DevAssert(MirroredSwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6772 DevAssert(MirrorConfigurationPtr != NULL_PTR);
6773 DevAssert(MirrorConfigurationPtr->CapturePortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
6774 DevAssert(MirrorConfigurationPtr->MirroringMode <= NETC_ETHSWT_VLAN_DOUBLE_TAGGING);
6775 #endif
6776
6777 /* If a mirroring configuration is already in place, delete it */
6778 Status = Netc_EthSwt_Ip_DeleteMirrorConfiguration(MirroredSwitchIdx);
6779 if ((uint8)(E_OK) == Status)
6780 {
6781 /* Indicates the mirror destination */
6782 RegIMDCR0 = IP_NETC__SW0_BASE->IMDCR0;
6783 RegIMDCR0 &= ~(NETC_F2_IMDCR0_MIRDEST_MASK);
6784 RegIMDCR0 |= NETC_F2_IMDCR0_MIRDEST(0U); /* 0: Port as specified by PORT field; 1: Switch management port */
6785 RegIMDCR0 &= ~(NETC_F2_IMDCR0_PORT_MASK);
6786 RegIMDCR0 |= NETC_F2_IMDCR0_PORT(MirrorConfigurationPtr->CapturePortIdx);
6787 /* Write IMDCR0 register */
6788 IP_NETC__SW0_BASE->IMDCR0 = RegIMDCR0;
6789
6790 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_11();
6791 RegIMDCR1 = IP_NETC__SW0_BASE->IMDCR1;
6792 RegIMDCR1 |= NETC_F2_IMDCR1_EFMEID(NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID); /* set frame modification table entry ID to NULL */
6793 IP_NETC__SW0_BASE->IMDCR1 = RegIMDCR1;
6794
6795 /* check if Mac Address Filter enabled */
6796 CheckMacAddressFilterEnableFlag(&SrcMacAddrFilterEnabled, &DstMacAddrFilterEnabled, MirrorConfigurationPtr);
6797
6798 /* Start writing mirroring configuration */
6799 /* #1 */
6800 if ((MirrorConfigurationPtr->VlanIdFilter == NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID) && (DstMacAddrFilterEnabled == FALSE) && (SrcMacAddrFilterEnabled == FALSE))
6801 {
6802 /* Enable port mirroring according to TrafficDirectionIngressBitMask */
6803 IngressBitMask = MirrorConfigurationPtr->TrafficDirectionIngressBitMask;
6804 for(PortIdx = 0U; PortIdx < NETC_ETHSWT_NUMBER_OF_PORTS; PortIdx++)
6805 {
6806 if((IngressBitMask & 0x1U) == 0x1U)
6807 {
6808 Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIdx]->PMCR = (uint32)0x1U;
6809 }
6810 IngressBitMask >>= 1U;
6811 }
6812 }
6813 else /* #2 ingress port filtering */
6814 {
6815 /* Config and add the ingress port filter table entry for ingress frames filtering */
6816 Status |= Netc_EthSwt_Ip_ConfigIngressPortFilterForPortMirroring(MirroredSwitchIdx, &SrcMacAddrFilterEnabled, &DstMacAddrFilterEnabled, MirrorConfigurationPtr, &IngressPortFilterTableEntry);
6817 }
6818
6819 /* #3 egress frame modification */
6820 Status |= Netc_EthSwt_Ip_ConfigEgressFrameModificationForPortMirroring(MirroredSwitchIdx, MirrorConfigurationPtr);
6821
6822 if ((uint8)(E_OK) == Status)
6823 {
6824 /* Set the mirror configuration done flag */
6825 MirrorConfigurationDone = TRUE;
6826
6827 /* store the mirror configuration data */
6828 MirrorCfgBackup.MirroringMode = MirrorConfigurationPtr->MirroringMode;
6829 MirrorCfgBackup.VlanId = MirrorConfigurationPtr->VlanId;
6830 MirrorCfgBackup.CapturePortIdx = MirrorConfigurationPtr->CapturePortIdx;
6831 MirrorCfgBackup.TrafficDirectionIngressBitMask = MirrorConfigurationPtr->TrafficDirectionIngressBitMask;
6832 }
6833 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_11();
6834
6835 }
6836
6837 return Status;
6838 }
6839
6840 /*FUNCTION**********************************************************************
6841 *
6842 * Function Name : Netc_EthSwt_Ip_ReadMirrorConfiguration
6843 * Description : External function for obtaining the mirror configuration of the given Ethernet switch..
6844 * implements Netc_EthSwt_Ip_ReadMirrorConfiguration_Activity
6845 *END**************************************************************************/
6846 Std_ReturnType Netc_EthSwt_Ip_ReadMirrorConfiguration( uint8 MirroredSwitchIdx, Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr )
6847 {
6848 Std_ReturnType Status = E_OK;
6849 uint8 MacByteIdx;
6850
6851 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6852 DevAssert(MirroredSwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6853 DevAssert(MirrorConfigurationPtr != NULL_PTR);
6854 #endif
6855
6856 (void)MirroredSwitchIdx;
6857 if (TRUE == MirrorConfigurationDone) /* The mirror configuration is in place */
6858 {
6859 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
6860 {
6861 MirrorConfigurationPtr->SrcMacAddrFilter[MacByteIdx] = MirrorCfgBackup.SrcMacAddrFilter[MacByteIdx];
6862 MirrorConfigurationPtr->DstMacAddrFilter[MacByteIdx] = MirrorCfgBackup.DstMacAddrFilter[MacByteIdx];
6863 }
6864 MirrorConfigurationPtr->VlanIdFilter = MirrorCfgBackup.VlanIdFilter;
6865 MirrorConfigurationPtr->MirroringMode = MirrorCfgBackup.MirroringMode;
6866 MirrorConfigurationPtr->VlanId = MirrorCfgBackup.VlanId;
6867 MirrorConfigurationPtr->CapturePortIdx = MirrorCfgBackup.CapturePortIdx;
6868 MirrorConfigurationPtr->TrafficDirectionIngressBitMask = MirrorCfgBackup.TrafficDirectionIngressBitMask;
6869 }
6870 else /* no mirror configuration exists */
6871 {
6872 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
6873 {
6874 MirrorConfigurationPtr->SrcMacAddrFilter[MacByteIdx] = 0x0U;
6875 MirrorConfigurationPtr->DstMacAddrFilter[MacByteIdx] = 0x0U;
6876 }
6877 MirrorConfigurationPtr->VlanIdFilter = NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID;
6878 MirrorConfigurationPtr->MirroringMode = NETC_ETHSWT_NO_VLAN_RETAGGING;
6879 MirrorConfigurationPtr->VlanId = NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID;
6880 MirrorConfigurationPtr->CapturePortIdx = 0U;
6881 MirrorConfigurationPtr->TrafficDirectionIngressBitMask = 0x0UL;
6882 }
6883
6884 return Status;
6885 }
6886
6887 /*FUNCTION**********************************************************************
6888 *
6889 * Function Name : Netc_EthSwt_Ip_MainFunction
6890 * Description : Periodically called function to age FDB entries
6891 * implements Netc_EthSwt_Ip_MainFunction_Activity
6892 *END**************************************************************************/
6893 void Netc_EthSwt_Ip_MainFunction( uint8 SwitchIdx )
6894 {
6895 Std_ReturnType Status = E_OK;
6896 Netc_EthSwt_Ip_CBDRStatusType DeleteStatus;
6897 uint32 ResumeEntryId;
6898 uint32 EntryId;
6899 boolean FoundEntry;
6900 uint32 HwAgingCount;
6901 float32 MainFunctionCycleSteps;
6902 float32 CalNumAgingCycle;
6903 float32 AgingTimeout;
6904 float32 mainPeriod;
6905
6906 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6907 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6908 #endif
6909
6910 mainPeriod = (float32)NETC_ETHSWT_IP_MAIN_FUNCTION_PERIOD;
6911
6912 /* Calculating the number of MAIN_FUNCTION_PERIOD we needed to skip to fit in the limited number of hardware steps the hardware aging counter can accommodate. */
6913 CalNumAgingCycle = (float32)Netc_EthSwt_Ip_FdbTableEntryTimeout[SwitchIdx];
6914 CalNumAgingCycle /= mainPeriod;
6915 if (CalNumAgingCycle < NETC_ETHSWT_IP_NUM_AGING_CYCLE_FLOAT)
6916 {
6917 /* The number of steps is 1 if we number of Netc_EthSwt_Ip_FdbTableEntryTimeout/NETC_ETHSWT_IP_MAIN_FUNCTION_PERIOD give us a Number of steps less than the number of steps the hardware can accommodate. */
6918 MainFunctionCycleSteps = NETC_ETHSWT_IP_ONE_FLOAT;
6919 }
6920 else
6921 {
6922 /* In the case there is not a sufficient number of steps in hardware, we skip a number of MAIN_FUNCTION_PERIOD before we increment the hardware aging counter.
6923 The number of skip cycle is deternimned by a round up of the number of steps we would like to have (Netc_EthSwt_Ip_FdbTableEntryTimeout/NETC_ETHSWT_IP_MAIN_FUNCTION_PERIOD)
6924 divided by the number of steps supported by hardware. Note that (Netc_EthSwt_Ip_FdbTableEntryTimeout/NETC_ETHSWT_IP_MAIN_FUNCTION_PERIOD) is padded to give a rounded up result. */
6925 /* Extract the number of funtion period */
6926 MainFunctionCycleSteps = (float32)(Netc_EthSwt_Ip_FdbTableEntryTimeout[SwitchIdx]);
6927 MainFunctionCycleSteps /= mainPeriod;
6928 /* Rounding up the number of aging cycles steps */
6929 MainFunctionCycleSteps += NETC_ETHSWT_IP_NUM_AGING_CYCLE_FLOAT - NETC_ETHSWT_IP_ONE_FLOAT;
6930 /* Extract the number of steps */
6931 MainFunctionCycleSteps /= NETC_ETHSWT_IP_NUM_AGING_CYCLE_FLOAT;
6932 /* Convert float32 to uint32, missing lroundf from C99 */
6933 if(MainFunctionCycleSteps <= NETC_ETHSWT_IP_ONE_FLOAT)
6934 {
6935 MainFunctionCycleSteps = (float32)NETC_ETHSWT_IP_ONE_FLOAT;
6936 }
6937 }
6938 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_61();
6939 Netc_EthSwt_Ip_MainFunctionCycle[SwitchIdx]++;
6940
6941 if(((float32)Netc_EthSwt_Ip_MainFunctionCycle[SwitchIdx]) >= MainFunctionCycleSteps)
6942 {
6943 /* Aging action */
6944 /* Activity update, ACT_CNT++ if no ACT_FLAG otherwise 0 */
6945 ResumeEntryId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
6946 do
6947 {
6948 Status |= Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable(SwitchIdx, &ResumeEntryId, &EntryId, &HwAgingCount, &FoundEntry);
6949 if(((Std_ReturnType)E_OK == Status) && (TRUE == FoundEntry))
6950 {
6951 AgingTimeout = (float32)HwAgingCount;
6952 AgingTimeout *= MainFunctionCycleSteps;
6953 AgingTimeout *= mainPeriod;
6954 if(AgingTimeout >= (float32) (Netc_EthSwt_Ip_FdbTableEntryTimeout[SwitchIdx]))
6955 {
6956 DeleteStatus = Netc_EthSwt_Ip_DeleteFdbTableEntryById(SwitchIdx, EntryId);
6957 if(NETC_ETHSWT_CBDRSTATUS_SUCCES != DeleteStatus)
6958 {
6959 Status = E_NOT_OK;
6960 }
6961 }
6962 }
6963 } while (((Std_ReturnType)E_OK == Status)
6964 && ((uint32)NETC_ETHSWT_IP_BD_NULL_ENTRY_ID != ResumeEntryId) );
6965 Netc_EthSwt_Ip_MainFunctionCycle[SwitchIdx] = 0UL;
6966 }
6967 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_61();
6968
6969 }
6970
6971 /*FUNCTION**********************************************************************
6972 *
6973 * Function Name : Netc_EthSwt_Ip_SetPruningMode
6974 * Description : External function for setting the pruning mode for ports.
6975 * implements Netc_EthSwt_Ip_SetPruningMode_Activity
6976 *END**************************************************************************/
6977 Std_ReturnType Netc_EthSwt_Ip_SetPruningMode(uint8 SwitchIdx, uint8 SwitchPortIdx, boolean PruningEnable)
6978 {
6979 Std_ReturnType Status = E_OK;
6980 uint32 bridgePortConfig = 0UL;
6981
6982 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6983 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6984 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
6985 #endif
6986
6987 (void)SwitchIdx;
6988 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_59();
6989
6990 /* read the BPCR configurate data first */
6991 bridgePortConfig = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->BPCR;
6992
6993 /* Configure the pruning setting for the port */
6994 if (FALSE == PruningEnable)
6995 {
6996 bridgePortConfig |= SW_PORT0_BPCR_SRCPRND_MASK;
6997 }
6998 else
6999 {
7000 bridgePortConfig &= ~SW_PORT0_BPCR_SRCPRND_MASK;
7001 }
7002
7003 /* write the BPCR configuration back */
7004 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->BPCR = bridgePortConfig;
7005 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_59();
7006
7007 return Status;
7008 }
7009
7010 /*FUNCTION**********************************************************************
7011 *
7012 * Function Name : Netc_EthSwt_Ip_GetPruningMode
7013 * Description : External function for getting the pruning mode of ports.
7014 * implements Netc_EthSwt_Ip_GetPruningMode_Activity
7015 *END**************************************************************************/
7016 Std_ReturnType Netc_EthSwt_Ip_GetPruningMode(uint8 SwitchIdx, uint8 SwitchPortIdx, boolean *PruningEnablePtr)
7017 {
7018 Std_ReturnType Status = E_OK;
7019 uint32 bridgePortConfig = 0UL;
7020
7021 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
7022 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7023 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
7024 DevAssert(PruningEnablePtr != NULL_PTR);
7025 #endif
7026
7027 (void)SwitchIdx;
7028
7029 /* read the BPCR configurate data first */
7030 bridgePortConfig = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->BPCR;
7031
7032 /* get the pruning mode data for the port */
7033 *PruningEnablePtr = ((bridgePortConfig & SW_PORT0_BPCR_SRCPRND_MASK) == 0x0UL) ? TRUE : FALSE;
7034
7035 return Status;
7036 }
7037
7038 #if(NETC_ETHSWT_IP_CONFIG_LINK_PROTOCOL == STD_ON)
7039 /*FUNCTION**********************************************************************
7040 *
7041 * Function Name : Netc_EthSwt_Ip_ConfigLinkProtocol
7042 * Description : External function for configuring the MII protocol for ethernet ports.
7043 *
7044 *END**************************************************************************/
7045 static void Netc_EthSwt_Ip_ConfigLinkProtocol(uint8 SwitchIdx, uint8 SwitchPortIdx, Netc_EthSwt_Ip_XmiiModeType EthSwtPortPhysicalLayerType)
7046 {
7047 uint32 Netcc1Reg;
7048
7049 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
7050 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7051 DevAssert(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_PORTS);
7052 #endif
7053
7054 (void)SwitchIdx;
7055
7056 if(SwitchPortIdx < NETC_ETHSWT_NUMBER_OF_MAC_PORTS)
7057 {
7058 /* read NETCC1 register first */
7059 Netcc1Reg = IP_GPR1->NETCC1;
7060
7061 /* modify the value for NETCC1 */
7062 if ((uint8)NETC_ETHSWT_PORT0 == SwitchPortIdx) /* link 0 */
7063 {
7064 Netcc1Reg |= GPR1_NETCC1_LINK0MIIP(EthSwtPortPhysicalLayerType);
7065 }
7066 else if ((uint8)NETC_ETHSWT_PORT1 == SwitchPortIdx) /* link 1 */
7067 {
7068 Netcc1Reg |= GPR1_NETCC1_LINK1MIIP(EthSwtPortPhysicalLayerType);
7069 }
7070 else
7071 {
7072 /* avoid MISRA violation */
7073 }
7074
7075 /* write it back */
7076 IP_GPR1->NETCC1 = Netcc1Reg;
7077 }
7078
7079 }
7080 #endif
7081
7082 /*FUNCTION**********************************************************************
7083 *
7084 * Function Name : Netc_EthSwt_Ip_ConvertToPtpTime
7085 * Description : Convert 64-bit clock value (ns) to PTP ptpTime (secondsHi,seconds, nanoseconds)
7086 *END**************************************************************************/
7087 static void Netc_EthSwt_Ip_ConvertToPtpTime(const uint64 clk, Netc_EthSwt_Ip_PtpTimeType *ptpTime)
7088 {
7089 uint64 seconds64;
7090
7091 /* convert the ns to seconds */
7092 seconds64 = clk / 1000000000UL;
7093 ptpTime->seconds = (uint32) seconds64;
7094 ptpTime->secondsHi = (uint16) (seconds64 >> 32U);
7095
7096 /* convert the portion that is less than 1s to ns */
7097 ptpTime->nanoseconds = (uint32) (clk - (uint64) (seconds64 * 1000000000UL));
7098
7099 return;
7100 }
7101
7102 /*FUNCTION**********************************************************************
7103 *
7104 * Function Name : Netc_EthSwt_Ip_GetPtpTSClk
7105 * Description : External function for getting current ptpTime of free running (ptpTime stamp) clock.
7106 * implements Netc_EthSwt_Ip_GetPtpTSClk_Activity
7107 *END**************************************************************************/
7108 Std_ReturnType Netc_EthSwt_Ip_GetPtpTSClk( uint8 SwitchIdx, Netc_EthSwt_Ip_PtpTimeType *PtpTime)
7109 {
7110 Std_ReturnType Status = E_OK;
7111 volatile uint64 FreeRunningTicks;
7112 uint64 clk;
7113
7114 (void)SwitchIdx;
7115
7116 if (TimerOriginalRefClk != 0x0UL)
7117 {
7118 /* Read free running time registers */
7119 FreeRunningTicks = IP_NETC__TMR0_BASE->TMR_FRT_L; /* should read the Lower register first */
7120 FreeRunningTicks |= ((uint64)(IP_NETC__TMR0_BASE->TMR_FRT_H)) << NETC_ETHSWT_IP_32BIT_SHIFT;
7121
7122 /* Convert free running ticks to nano seconds */
7123 clk = FreeRunningTicks * (uint64)((uint32)((1000U) / (TimerOriginalRefClk/1000000U)));
7124
7125 /* Convert ns time to PTP time */
7126 Netc_EthSwt_Ip_ConvertToPtpTime(clk, PtpTime);
7127 }
7128 else
7129 {
7130 Status = E_NOT_OK; /* 1588 timer is not enabled. */
7131 }
7132
7133 return Status;
7134 }
7135
7136 /*FUNCTION**********************************************************************
7137 *
7138 * Function Name : Netc_EthSwt_Ip_GetPtpClk
7139 * Description : External function for getting current ptpTime of corrected clock (PTP_CLK).
7140 * implements Netc_EthSwt_Ip_GetPtpClk_Activity
7141 *END**************************************************************************/
7142 Std_ReturnType Netc_EthSwt_Ip_GetPtpClk( uint8 SwitchIdx, Netc_EthSwt_Ip_PtpTimeType *PtpTime)
7143 {
7144 Std_ReturnType Status = E_OK;
7145 volatile uint64 FreeRunningTicks;
7146 volatile uint64 CorrectedTime;
7147
7148 (void)SwitchIdx;
7149
7150 if (TimerRefClk != 0x0UL)
7151 {
7152 /* Read Timer synchronous time registers */
7153 FreeRunningTicks = IP_NETC__TMR0_BASE->TMR_FRT_L; /* A read to TMR_FRT_L captures all 64b of FRT_H/L and 64b of SRT_H/L, for an atomic read of all 4 registers. */
7154 (void)FreeRunningTicks; /* The cast is necessary to avoid the compiler warning. The register read is needed in order to trigger an atomic read of all 4 timer registers. */
7155 CorrectedTime = IP_NETC__TMR0_BASE->TMR_SRT_L;
7156 CorrectedTime |= (((uint64)(IP_NETC__TMR0_BASE->TMR_SRT_H)) << NETC_ETHSWT_IP_32BIT_SHIFT);
7157
7158 /* Convert ns time to PTP time */
7159 Netc_EthSwt_Ip_ConvertToPtpTime(CorrectedTime, PtpTime);
7160 }
7161 else
7162 {
7163 Status = E_NOT_OK; /* 1588 timer is not enabled. */
7164 }
7165
7166 return Status;
7167 }
7168
7169 /*FUNCTION**********************************************************************
7170 *
7171 * Function Name : Netc_EthSwt_Ip_GetPtpTimes
7172 * Description : External function for retrieving an atomic snapshot of both clocks in the switch.
7173 * implements Netc_EthSwt_Ip_GetPtpTimes_Activity
7174 *END**************************************************************************/
7175 Std_ReturnType Netc_EthSwt_Ip_GetPtpTimes( uint8 SwitchIdx, Netc_EthSwt_Ip_PtpTimeType *FreeRunTime, Netc_EthSwt_Ip_PtpTimeType *CorrTime)
7176 {
7177 Std_ReturnType Status = E_OK;
7178 volatile uint64 FreeRunningTicks;
7179 volatile uint64 CorrectedTime;
7180 uint64 clk;
7181
7182 (void)SwitchIdx;
7183
7184 if (TimerRefClk != 0x0UL)
7185 {
7186 /* A read to TMR_FRT_L captures all 64b of FRT_H/L and 64b of SRT_H/L, for an atomic read of all 4 registers. */
7187 FreeRunningTicks = IP_NETC__TMR0_BASE->TMR_FRT_L;
7188 FreeRunningTicks |= ((uint64)(IP_NETC__TMR0_BASE->TMR_FRT_H)) << NETC_ETHSWT_IP_32BIT_SHIFT;
7189 CorrectedTime = IP_NETC__TMR0_BASE->TMR_SRT_L;
7190 CorrectedTime |= ((uint64)(IP_NETC__TMR0_BASE->TMR_SRT_H)) << NETC_ETHSWT_IP_32BIT_SHIFT;
7191
7192 /* Convert free running ticks to nano seconds */
7193 clk = FreeRunningTicks * (uint64)((uint32)((1000U) / (TimerOriginalRefClk/1000000U)));
7194
7195 /* Convert free running ns time to PTP time */
7196 Netc_EthSwt_Ip_ConvertToPtpTime(clk, FreeRunTime);
7197
7198 /* Convert synced ns time to PTP time */
7199 Netc_EthSwt_Ip_ConvertToPtpTime(CorrectedTime, CorrTime);
7200 }
7201 else
7202 {
7203 Status = E_NOT_OK; /* 1588 timer is not enabled. */
7204 }
7205
7206 return Status;
7207 }
7208
7209 /*FUNCTION**********************************************************************
7210 *
7211 * Function Name : Netc_EthSwt_Ip_SetPtpClkRatio
7212 * Description : External function for adjusting the clock rate of the PTP clock.
7213 * implements Netc_EthSwt_Ip_SetPtpClkRatio_Activity
7214 *END**************************************************************************/
7215 Std_ReturnType Netc_EthSwt_Ip_SetPtpClkRatio( uint8 SwitchIdx, uint32 ClkRatio )
7216 {
7217 Std_ReturnType Status = E_OK;
7218 float32 ConvertedClkRatio;
7219 uint16 TimerClkPeriod;
7220 uint32 ClkAddendData;
7221 uint32 TimerClkAddend;
7222 uint32 IntegerPortion;
7223 float32 FractionalPortion;
7224 uint32 ClkRatioTemp;
7225
7226 (void)SwitchIdx;
7227 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_02();
7228 if (TimerRefClk != 0x0UL)
7229 {
7230 /* convert uint32 ClkRatio to a float */
7231 IntegerPortion = (uint32)((ClkRatio & 0x80000000U) >> 31U);
7232 ClkRatioTemp = ClkRatio & 0x7FFFFFFFUL;
7233 FractionalPortion = (float32)ClkRatioTemp/(float32)0x80000000UL;
7234 ConvertedClkRatio = (float32)((float32)IntegerPortion + FractionalPortion);
7235
7236 /* modify the clock frequency */
7237 TimerRefClk = (uint32)((float32)TimerRefClk * ConvertedClkRatio);
7238
7239 TimerClkPeriod = (uint16)(1000U/(TimerRefClk/1000000U)); /* the integer portion of timer clock period (1/f) */
7240 ClkAddendData = (1000000U/(TimerRefClk/1000000U)) - (1000U * TimerClkPeriod);
7241 TimerClkAddend = (uint32)((((uint64)0x1U << NETC_ETHSWT_IP_32BIT_SHIFT) * ClkAddendData) / 1000U); /* the fractional part of the timer clock period. */
7242
7243 /* Timer addend register holds the fractional part of the timer clock period */
7244 IP_NETC__TMR0_BASE->TMR_ADD = TMR0_BASE_TMR_ADD_ADDEND(TimerClkAddend);
7245 /* clear CLK_PERIOD data field first */
7246 IP_NETC__TMR0_BASE->TMR_CTRL &= ~TMR0_BASE_TMR_CTRL_TCLK_PERIOD(0x3FFF);
7247 IP_NETC__TMR0_BASE->TMR_CTRL |= TMR0_BASE_TMR_CTRL_TCLK_PERIOD(TimerClkPeriod);
7248 }
7249 else
7250 {
7251 Status = E_NOT_OK; /* 1588 timer is not enabled. */
7252 }
7253 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_02();
7254
7255 return Status;
7256 }
7257
7258
7259 /*FUNCTION**********************************************************************
7260 *
7261 * Function Name : Netc_EthSwt_Ip_CorrectPtpClk
7262 * Description : External function for adding/subtracting an offset to/from the corrected clock (PTP_CLK).
7263 * implements Netc_EthSwt_Ip_CorrectPtpClk_Activity
7264 *END**************************************************************************/
7265 Std_ReturnType Netc_EthSwt_Ip_CorrectPtpClk( uint8 SwitchIdx, sint64 Offset )
7266 {
7267 Std_ReturnType Status = E_OK;
7268 uint64 OriginOffset;
7269 uint64 NewOffset;
7270
7271 (void)SwitchIdx;
7272
7273 /* get the existing offset first */
7274 OriginOffset = IP_NETC__TMR0_BASE->TMROFF_L;
7275 OriginOffset |= (uint64)(IP_NETC__TMR0_BASE->TMROFF_H) << NETC_ETHSWT_IP_32BIT_SHIFT;
7276
7277 /* modify the offset */
7278 NewOffset = OriginOffset + ((uint64) (Offset)); /* the offset could be positive or negative */
7279
7280 /* write the new offset back */
7281 IP_NETC__TMR0_BASE->TMROFF_L = (uint32)NewOffset;
7282 IP_NETC__TMR0_BASE->TMROFF_H = (uint32)(NewOffset >> NETC_ETHSWT_IP_32BIT_SHIFT);
7283
7284 return Status;
7285 }
7286
7287
7288 /*FUNCTION**********************************************************************
7289 *
7290 * Function Name : Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntry
7291 * Description : Ethernet Switch Add or Update rate policer table entry function.Netc_EthSwt_Ip_ConvertToPtpTime
7292 *END**************************************************************************/
7293 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntry( uint8 SwitchIdx,
7294 Netc_EthSwt_Ip_CommandsType Cmd,
7295 uint32 *MatchedEntries,
7296 const Netc_EthSwt_Ip_RatePolicerEntryDataType * RatePolicerTableEntry
7297 )
7298 {
7299 Netc_EthSwt_Ip_CBDRStatusType status;
7300 uint32 ActionsData;
7301 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
7302
7303 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
7304 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7305 DevAssert(RatePolicerTableEntry != NULL_PTR);
7306 DevAssert(MatchedEntries != NULL_PTR);
7307 #endif
7308
7309 /* clear the variable MatchedEntries first */
7310 *MatchedEntries = 0U;
7311
7312 /* only support Add and Update commands */
7313 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
7314 {
7315 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
7316 }
7317 else
7318 {
7319 /* set table version and CFGEU, FEEU, ... flag */
7320 ActionsData = (NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(RatePolicerTableEntry->ConfigurationElementUpdate ? 1U : 0U) \
7321 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_FEEU(RatePolicerTableEntry->FunctionalEnableElementUpdate ? 1U : 0U)) \
7322 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_PSEU(RatePolicerTableEntry->PolicerStateElementUpdate ? 1U : 0U) \
7323 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_STSEU(RatePolicerTableEntry->StatisticsElementUpdate ? 1U : 0U) \
7324 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
7325
7326 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_03();
7327 /* ------initialize the table request data buffer------ */
7328 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
7329 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = RatePolicerTableEntry->RatePolicerEntryId; /* fill in Entry_ID field (Access Key) */
7330 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cir; /* CFGE CIR field */
7331 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cbs; /* CFGE CBS field */
7332 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Eir; /* CFGE EIR field */
7333 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Ebs; /* CFGE EBS field */
7334 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_MREN((RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Mren) ? 1U : 0U) \
7335 | NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_DOY((RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Doy) ? 1U : 0U) \
7336 | NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_CM((RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cm) ? 1U : 0U) \
7337 | NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_CF((RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cf) ? 1U : 0U) \
7338 | NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_NDOR((RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Ndor) ? 1U : 0U) \
7339 | NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_SDU_TYPE(RatePolicerTableEntry->RatePolicerCfgeData.Cfge_SduType);
7340 /* fill in Functional Enable Element Data */
7341 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] |= (NETC_ETHSWT_IP_RATEPOLICERTABLE_FEE_DATA_FEN(RatePolicerTableEntry->RatePolicerFunctionEnable ? 1U : 0U) << NETC_ETHSWT_IP_16BIT_SHIFT);
7342 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_03();
7343
7344 /* fill in operation data for config field of Request Header*/
7345 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
7346 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
7347 OperationData.TableId = NETC_ETHSWT_IP_RATE_POLICER_TABLE_ID;
7348 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
7349 OperationData.Cmd = Cmd;
7350 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_RATEPOLICERTABLE_REQBUFFER_LEN);
7351 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
7352
7353 /* send command */
7354 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
7355 #if defined(ERR_IPV_NETC_051243)
7356 #if (STD_ON == ERR_IPV_NETC_051243)
7357 /* Error code 0x8A is not a real error. check it on Errata. */
7358 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
7359 {
7360 #endif
7361 #else
7362 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
7363 {
7364 #endif
7365 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
7366 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
7367 }
7368 }
7369
7370 return status;
7371 }
7372
7373 /*FUNCTION**********************************************************************
7374 *
7375 * Function Name : Netc_EthSwt_Ip_QueryRatePolicerTableEntry
7376 * Description : Ethernet Switch query Rate policer table entry function.
7377 *END**************************************************************************/
7378 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryRatePolicerTableEntry( uint8 SwitchIdx,
7379 uint32 *MatchedEntries,
7380 uint32 RatePolicerEntryId,
7381 Netc_EthSwt_Ip_RatePolicerEntryRspDataType * RatePolicerTableEntry
7382 )
7383 {
7384 Netc_EthSwt_Ip_CBDRStatusType status;
7385 uint32 ActionsData;
7386 uint32 CfgeConfigBits;
7387 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
7388 uint8 SduType;
7389
7390 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
7391 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7392 DevAssert(MatchedEntries != NULL_PTR);
7393 DevAssert(RatePolicerTableEntry != NULL_PTR);
7394 #endif
7395
7396 /* clear the variable MatchedEntries first */
7397 *MatchedEntries = 0U;
7398
7399 /* always do the full query. 0x0 = Full query. */
7400 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
7401 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
7402
7403 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_13();
7404 /* ------initialize the table request data buffer------ */
7405 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
7406 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = RatePolicerEntryId; /* fill in Entry_ID field (Access Key) */
7407 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_13();
7408
7409 /* fill in operation data for config field of Request Header*/
7410 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
7411 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
7412 OperationData.TableId = NETC_ETHSWT_IP_RATE_POLICER_TABLE_ID;
7413 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for query command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
7414 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
7415 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
7416 OperationData.RspBuffLength = (NETC_ETHSWT_IP_RATEPOLICERTABLE_RSPBUFFER_LEN); /* set response data buffer length */
7417
7418 /* send command */
7419 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
7420 #if defined(ERR_IPV_NETC_051243)
7421 #if (STD_ON == ERR_IPV_NETC_051243)
7422 /* Error code 0x8A is not a real error. check it on Errata. */
7423 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
7424 {
7425 #endif
7426 #else
7427 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
7428 {
7429 #endif
7430 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
7431 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
7432
7433 /* found a matched entry */
7434 if (1U == *MatchedEntries)
7435 {
7436 /* fill in "Netc_EthSwt_Ip_RatePolicerEntryDataType" structure with data in response data buffer */
7437 RatePolicerTableEntry->RatePolicerEntryId = TableDataBuffer.TableDataField[0U];
7438 /* fill in STSE data */
7439 RatePolicerTableEntry->RatePolicerStseData.Stse_ByteCount = (((uint64)TableDataBuffer.TableDataField[2U]) << NETC_ETHSWT_IP_32BIT_SHIFT);
7440 RatePolicerTableEntry->RatePolicerStseData.Stse_ByteCount |= (uint64)(TableDataBuffer.TableDataField[1U]);
7441 RatePolicerTableEntry->RatePolicerStseData.Stse_DropFrames = TableDataBuffer.TableDataField[3U];
7442 RatePolicerTableEntry->RatePolicerStseData.Stse_Dr0GrnFrames = TableDataBuffer.TableDataField[5U];
7443 RatePolicerTableEntry->RatePolicerStseData.Stse_Dr1GrnFrames = TableDataBuffer.TableDataField[7U];
7444 RatePolicerTableEntry->RatePolicerStseData.Stse_Dr2YlwFrames = TableDataBuffer.TableDataField[9U];
7445 RatePolicerTableEntry->RatePolicerStseData.Stse_RemarkYlwFrames = TableDataBuffer.TableDataField[11U];
7446 RatePolicerTableEntry->RatePolicerStseData.Stse_Dr3RedFrames = TableDataBuffer.TableDataField[13U];
7447 RatePolicerTableEntry->RatePolicerStseData.Stse_RemarkRedFrames = TableDataBuffer.TableDataField[15U];
7448 RatePolicerTableEntry->RatePolicerStseData.Stse_Lts = TableDataBuffer.TableDataField[17U];
7449 RatePolicerTableEntry->RatePolicerStseData.Stse_CommittedTokenBucketInteger = TableDataBuffer.TableDataField[18U];
7450 RatePolicerTableEntry->RatePolicerStseData.Stse_CommittedTokenBucketFractional = TableDataBuffer.TableDataField[19U]; /* 1 sign bit + 31 bits fractional */
7451 RatePolicerTableEntry->RatePolicerStseData.Stse_ExcessTokenBucketInteger = TableDataBuffer.TableDataField[20U];
7452 RatePolicerTableEntry->RatePolicerStseData.Stse_ExcessTokenBucketFractional = TableDataBuffer.TableDataField[21U]; /* 1 sign bit + 31 bits fractional */
7453 /* fill in CFGE data */
7454 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cir = TableDataBuffer.TableDataField[22U];
7455 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cbs = TableDataBuffer.TableDataField[23U];
7456 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Eir = TableDataBuffer.TableDataField[24U];
7457 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Ebs = TableDataBuffer.TableDataField[25U];
7458 CfgeConfigBits = TableDataBuffer.TableDataField[26U];
7459 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Mren = ((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_MREN_MASK) == 0U) ? FALSE : TRUE;
7460 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Doy = ((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_DOY_MASK) == 0U) ? FALSE : TRUE;
7461 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cm = ((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_CM_MASK) == 0U) ? FALSE : TRUE;
7462 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cf = ((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_CF_MASK) == 0U) ? FALSE : TRUE;
7463 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Ndor = ((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_NDOR_MASK) == 0U) ? FALSE : TRUE;
7464 SduType = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_SDU_TYPE_MASK) >> NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_SDU_TYPE_SHIFT);
7465 switch (SduType)
7466 {
7467 case 0U:
7468 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_SduType = NETC_ETHSWT_IP_PPDU;
7469 break;
7470 case 1U:
7471 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_SduType = NETC_ETHSWT_IP_MPDU;
7472 break;
7473 case 2U:
7474 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_SduType = NETC_ETHSWT_IP_MSDU;
7475 break;
7476 default:
7477 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_SduType = NETC_ETHSWT_IP_RSDTYPE;
7478 break;
7479 }
7480 /* fill FEE data */
7481 RatePolicerTableEntry->RatePolicerFunctionEnable = (((CfgeConfigBits >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_RATEPOLICERTABLE_FEE_DATA_FEN_MASK) == 0U) ? FALSE : TRUE;
7482 /* fill PSE data */
7483 RatePolicerTableEntry->MarkRedFlag = (((CfgeConfigBits >> NETC_ETHSWT_IP_24BIT_SHIFT) & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_MREN_MASK) == 0U) ? FALSE : TRUE;
7484 }
7485 }
7486
7487 return status;
7488 }
7489
7490 /*FUNCTION**********************************************************************
7491 *
7492 * Function Name : Netc_EthSwt_Ip_DeleteRatePolicerTableEntry
7493 * Description : Ethernet Switch delete Rate policer table entry function.
7494 *END**************************************************************************/
7495 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteRatePolicerTableEntry( uint8 SwitchIdx,
7496 uint32 *MatchedEntries,
7497 uint32 RatePolicerEntryId
7498 )
7499 {
7500 Netc_EthSwt_Ip_CBDRStatusType status;
7501 uint32 ActionsData = 0U;
7502 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
7503
7504 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
7505 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7506 DevAssert(MatchedEntries != NULL_PTR);
7507 #endif
7508
7509 /* clear the variable MatchedEntries first */
7510 *MatchedEntries = 0U;
7511 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_14();
7512 /* ------initialize the table request data buffer------ */
7513 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
7514 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = RatePolicerEntryId; /* fill in Entry_ID field (Access Key) */
7515 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_14();
7516
7517 /* fill in operation data for config field of Request Header*/
7518 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
7519 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
7520 OperationData.TableId = NETC_ETHSWT_IP_RATE_POLICER_TABLE_ID;
7521 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
7522 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
7523 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
7524 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN); /* set response data buffer with normal length */
7525
7526 /* send the "Delete" command */
7527 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
7528 #if defined(ERR_IPV_NETC_051243)
7529 #if (STD_ON == ERR_IPV_NETC_051243)
7530 /* Error code 0x8A is not a real error. check it on Errata. */
7531 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
7532 {
7533 #endif
7534 #else
7535 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
7536 {
7537 #endif
7538 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
7539 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
7540 }
7541
7542 return status;
7543 }
7544
7545 /*FUNCTION**********************************************************************
7546 *
7547 * Function Name : Netc_EthSwt_Ip_AddOrUpdateIngressStreamTableEntry
7548 * Description : Ethernet Switch Add or Update ingress stream table entry function.
7549 * implements Netc_EthSwt_Ip_AddOrUpdateIngressStreamTableEntry_Activity
7550 *END**************************************************************************/
7551 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateIngressStreamTableEntry( uint8 SwitchIdx,
7552 Netc_EthSwt_Ip_CommandsType Cmd,
7553 uint32 *MatchedEntries,
7554 const Netc_EthSwt_Ip_IngressStreamEntryDataType * IngressStreamTableEntry
7555 )
7556 {
7557 Netc_EthSwt_Ip_CBDRStatusType status;
7558 uint32 ActionsData;
7559 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
7560
7561 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
7562 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7563 DevAssert(IngressStreamTableEntry != NULL_PTR);
7564 DevAssert(MatchedEntries != NULL_PTR);
7565 #endif
7566
7567 /* clear the variable MatchedEntries first */
7568 *MatchedEntries = 0U;
7569
7570 /* only support Add and Update commands */
7571 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
7572 {
7573 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
7574 }
7575 else
7576 {
7577 /* set table version and CFGEU flag */
7578 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U) \
7579 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
7580
7581 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_15();
7582 /* ------initialize the table request data buffer------ */
7583 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
7584 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamTableEntry->IngressStreamEntryId; /* fill in Entry_ID field (Access Key) */
7585 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SFE((IngressStreamTableEntry->IngressStreamCfgeData.StreamFilteringEnable) ? 1U : 0U) \
7586 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IPV(IngressStreamTableEntry->IngressStreamCfgeData.InternalPriorityValue) \
7587 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OIPV((IngressStreamTableEntry->IngressStreamCfgeData.OverrideIPV) ? 1U : 0U) \
7588 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_DR(IngressStreamTableEntry->IngressStreamCfgeData.DropResilience) \
7589 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ODR((IngressStreamTableEntry->IngressStreamCfgeData.OverrideDR) ? 1U : 0U) \
7590 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IMIRE((IngressStreamTableEntry->IngressStreamCfgeData.IngressMirroringEnable) ? 1U : 0U) \
7591 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_TIMECAPE((IngressStreamTableEntry->IngressStreamCfgeData.TimeStampCaptureEnable) ? 1U : 0U) \
7592 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SPPD((IngressStreamTableEntry->IngressStreamCfgeData.SrcPortPruningDisable) ? 1U : 0U) \
7593 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ISQA(IngressStreamTableEntry->IngressStreamCfgeData.IngressSeqAction) \
7594 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ORP((IngressStreamTableEntry->IngressStreamCfgeData.OverrideRatePolicerInstanceEID) ? 1U : 0U) \
7595 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OSGI((IngressStreamTableEntry->IngressStreamCfgeData.OverrideStreamGateInstanceEID) ? 1U : 0U) \
7596 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_HR(IngressStreamTableEntry->IngressStreamCfgeData.HostReason) \
7597 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_FA(IngressStreamTableEntry->IngressStreamCfgeData.ForwardingActions) \
7598 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SDUTYPE(IngressStreamTableEntry->IngressStreamCfgeData.SduType);
7599 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_MSDU(IngressStreamTableEntry->IngressStreamCfgeData.MaximumServiceDataUnit) \
7600 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IFMELENCHG(IngressStreamTableEntry->IngressStreamCfgeData.IngressFrmModiEntryFrmLenChange) \
7601 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_EPORT(IngressStreamTableEntry->IngressStreamCfgeData.EgressPort) \
7602 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OETEID(IngressStreamTableEntry->IngressStreamCfgeData.OverrideET_EID) \
7603 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_CTD(IngressStreamTableEntry->IngressStreamCfgeData.CutThrDisable);
7604 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = IngressStreamTableEntry->IngressStreamCfgeData.IngressSeqGeneration_EID;
7605 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = IngressStreamTableEntry->IngressStreamCfgeData.RatePolicer_EID;
7606 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = IngressStreamTableEntry->IngressStreamCfgeData.StreamGateInstance_EID;
7607 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA5] = IngressStreamTableEntry->IngressStreamCfgeData.IngressFrmModification_EID;
7608 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA6] = IngressStreamTableEntry->IngressStreamCfgeData.EgressTreatment_EID;
7609 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA7] = IngressStreamTableEntry->IngressStreamCfgeData.IngressStreamCounter_EID;
7610 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA8] = NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_EGRESSPORTMAP(IngressStreamTableEntry->IngressStreamCfgeData.EgressPortBitMap);
7611 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA9] = NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SIMAP(IngressStreamTableEntry->IngressStreamCfgeData.StationInterfaceMap);
7612 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_15();
7613
7614 /* fill in operation data for config field of Request Header*/
7615 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
7616 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
7617 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_TABLE_ID;
7618 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
7619 OperationData.Cmd = Cmd;
7620 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_INGRESSSTREAMTABLE_REQBUFFER_LEN);
7621 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
7622
7623 /* send command */
7624 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
7625 #if defined(ERR_IPV_NETC_051243)
7626 #if (STD_ON == ERR_IPV_NETC_051243)
7627 /* Error code 0x8A is not a real error. check it on Errata. */
7628 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
7629 {
7630 #endif
7631 #else
7632 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
7633 {
7634 #endif
7635 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
7636 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
7637 }
7638 }
7639
7640 return status;
7641 }
7642
7643 /*FUNCTION**********************************************************************
7644 *
7645 * Function Name : Netc_EthSwt_Ip_QueryIngressStreamTableEntry
7646 * Description : Ethernet Switch query Ingress Stream table entry function.
7647 * implements Netc_EthSwt_Ip_QueryIngressStreamTableEntry_Activity
7648 *END**************************************************************************/
7649 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngressStreamTableEntry( uint8 SwitchIdx,
7650 uint32 *MatchedEntries,
7651 uint32 IngressStreamEntryId,
7652 Netc_EthSwt_Ip_IngressStreamEntryDataType * IngressStreamTableEntry
7653 )
7654 {
7655 Netc_EthSwt_Ip_CBDRStatusType status;
7656 uint32 ActionsData;
7657 uint32 CfgeConfigBits;
7658 uint32 CfgeConfigBits2;
7659 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
7660 uint8 SduType;
7661
7662 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
7663 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7664 DevAssert(MatchedEntries != NULL_PTR);
7665 DevAssert(IngressStreamTableEntry != NULL_PTR);
7666 #endif
7667
7668 /* clear the variable MatchedEntries first */
7669 *MatchedEntries = 0U;
7670
7671 /* always do the full query. 0x0 = Full query. */
7672 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
7673 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
7674
7675 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_16();
7676 /* ------initialize the table request data buffer------ */
7677 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
7678 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamEntryId; /* fill in Entry_ID field (Access Key) */
7679 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_16();
7680
7681 /* fill in operation data for config field of Request Header*/
7682 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
7683 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
7684 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_TABLE_ID;
7685 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for query command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
7686 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
7687 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
7688 OperationData.RspBuffLength = (NETC_ETHSWT_IP_INGRESSSTREAMTABLE_RSPBUFFER_LEN); /* set response data buffer length */
7689
7690 /* send command */
7691 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
7692 #if defined(ERR_IPV_NETC_051243)
7693 #if (STD_ON == ERR_IPV_NETC_051243)
7694 /* Error code 0x8A is not a real error. check it on Errata. */
7695 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
7696 {
7697 #endif
7698 #else
7699 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
7700 {
7701 #endif
7702 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
7703 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
7704
7705 /* found a matched entry */
7706 if (1U == *MatchedEntries)
7707 {
7708 /* fill in "Netc_EthSwt_Ip_IngressStreamEntryDataType" structure with data in response data buffer */
7709 IngressStreamTableEntry->IngressStreamEntryId = TableDataBuffer.TableDataField[0U];
7710 /* fill in CFGE data */
7711 CfgeConfigBits = TableDataBuffer.TableDataField[1U];
7712 IngressStreamTableEntry->IngressStreamCfgeData.StreamFilteringEnable = ((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SFE_MASK) > 0U) ? TRUE : FALSE;
7713 IngressStreamTableEntry->IngressStreamCfgeData.InternalPriorityValue = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IPV_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IPV_SHIFT);
7714 IngressStreamTableEntry->IngressStreamCfgeData.OverrideIPV = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OIPV_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OIPV_SHIFT) > 0U) ? TRUE : FALSE;
7715 IngressStreamTableEntry->IngressStreamCfgeData.DropResilience = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_DR_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_DR_SHIFT);
7716 IngressStreamTableEntry->IngressStreamCfgeData.OverrideDR = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ODR_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ODR_SHIFT) > 0U) ? TRUE : FALSE;
7717 IngressStreamTableEntry->IngressStreamCfgeData.IngressMirroringEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IMIRE_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IMIRE_SHIFT) > 0U) ? TRUE : FALSE;
7718 IngressStreamTableEntry->IngressStreamCfgeData.TimeStampCaptureEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_TIMECAPE_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_TIMECAPE_SHIFT) > 0U) ? TRUE : FALSE;
7719 IngressStreamTableEntry->IngressStreamCfgeData.SrcPortPruningDisable = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SPPD_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SPPD_SHIFT) > 0U) ? TRUE : FALSE;
7720 IngressStreamTableEntry->IngressStreamCfgeData.IngressSeqAction = ((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ISQA_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ISQA_SHIFT);
7721 IngressStreamTableEntry->IngressStreamCfgeData.OverrideRatePolicerInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ORP_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ORP_SHIFT) > 0U) ? TRUE : FALSE;
7722 IngressStreamTableEntry->IngressStreamCfgeData.OverrideStreamGateInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OSGI_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OSGI_SHIFT) > 0U) ? TRUE : FALSE;
7723 IngressStreamTableEntry->IngressStreamCfgeData.HostReason = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_HR_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_HR_SHIFT);
7724 IngressStreamTableEntry->IngressStreamCfgeData.ForwardingActions = ((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_FA_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_FA_SHIFT);
7725 SduType = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SDUTYPE_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SDUTYPE_SHIFT);
7726 switch (SduType)
7727 {
7728 case 0U:
7729 IngressStreamTableEntry->IngressStreamCfgeData.SduType = NETC_ETHSWT_IP_PPDU;
7730 break;
7731 case 1U:
7732 IngressStreamTableEntry->IngressStreamCfgeData.SduType = NETC_ETHSWT_IP_MPDU;
7733 break;
7734 case 2U:
7735 IngressStreamTableEntry->IngressStreamCfgeData.SduType = NETC_ETHSWT_IP_MSDU;
7736 break;
7737 default:
7738 IngressStreamTableEntry->IngressStreamCfgeData.SduType = NETC_ETHSWT_IP_RSDTYPE;
7739 break;
7740 }
7741
7742 CfgeConfigBits2 = TableDataBuffer.TableDataField[2U];
7743 IngressStreamTableEntry->IngressStreamCfgeData.MaximumServiceDataUnit = (uint16)((CfgeConfigBits2 & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_MSDU_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_MSDU_SHIFT);
7744 IngressStreamTableEntry->IngressStreamCfgeData.IngressFrmModiEntryFrmLenChange = (uint8)((CfgeConfigBits2 & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IFMELENCHG_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IFMELENCHG_SHIFT);
7745 IngressStreamTableEntry->IngressStreamCfgeData.EgressPort = (uint8)((CfgeConfigBits2 & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_EPORT_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_EPORT_SHIFT);
7746 IngressStreamTableEntry->IngressStreamCfgeData.OverrideET_EID = ((CfgeConfigBits2 & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OETEID_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OETEID_SHIFT);
7747 IngressStreamTableEntry->IngressStreamCfgeData.CutThrDisable = ((CfgeConfigBits2 & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_CTD_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_CTD_SHIFT);
7748
7749 IngressStreamTableEntry->IngressStreamCfgeData.IngressSeqGeneration_EID = TableDataBuffer.TableDataField[3U];
7750 IngressStreamTableEntry->IngressStreamCfgeData.RatePolicer_EID = TableDataBuffer.TableDataField[4U];
7751 IngressStreamTableEntry->IngressStreamCfgeData.StreamGateInstance_EID = TableDataBuffer.TableDataField[5U];
7752 IngressStreamTableEntry->IngressStreamCfgeData.IngressFrmModification_EID = TableDataBuffer.TableDataField[6U];
7753 IngressStreamTableEntry->IngressStreamCfgeData.EgressTreatment_EID = TableDataBuffer.TableDataField[7U];
7754 IngressStreamTableEntry->IngressStreamCfgeData.IngressStreamCounter_EID = TableDataBuffer.TableDataField[8U];
7755 IngressStreamTableEntry->IngressStreamCfgeData.EgressPortBitMap = TableDataBuffer.TableDataField[9U] & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_EGRESSPORTMAP_MASK;
7756 IngressStreamTableEntry->IngressStreamCfgeData.StationInterfaceMap = (uint16)(TableDataBuffer.TableDataField[10U] & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SIMAP_MASK);
7757 }
7758 }
7759
7760 return status;
7761 }
7762
7763 /*FUNCTION**********************************************************************
7764 *
7765 * Function Name : Netc_EthSwt_Ip_DeleteIngressStreamTableEntry
7766 * Description : Ethernet Switch delete Ingress Stream table entry function.
7767 * implements Netc_EthSwt_Ip_DeleteIngressStreamTableEntry_Activity
7768 *END**************************************************************************/
7769 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngressStreamTableEntry( uint8 SwitchIdx,
7770 uint32 *MatchedEntries,
7771 uint32 IngressStreamEntryId
7772 )
7773 {
7774 Netc_EthSwt_Ip_CBDRStatusType status;
7775 uint32 ActionsData = 0U;
7776 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
7777
7778 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
7779 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7780 DevAssert(MatchedEntries != NULL_PTR);
7781 #endif
7782
7783 /* clear the variable MatchedEntries first */
7784 *MatchedEntries = 0U;
7785 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_17();
7786 /* ------initialize the table request data buffer------ */
7787 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
7788 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamEntryId; /* fill in Entry_ID field (Access Key) */
7789 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_17();
7790
7791 /* fill in operation data for config field of Request Header*/
7792 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
7793 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
7794 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_TABLE_ID;
7795 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
7796 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
7797 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
7798 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN); /* set response data buffer with normal length */
7799
7800 /* send the "Delete" command */
7801 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
7802 #if defined(ERR_IPV_NETC_051243)
7803 #if (STD_ON == ERR_IPV_NETC_051243)
7804 /* Error code 0x8A is not a real error. check it on Errata. */
7805 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
7806 {
7807 #endif
7808 #else
7809 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
7810 {
7811 #endif
7812 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
7813 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
7814 }
7815
7816 return status;
7817 }
7818
7819 /*FUNCTION**********************************************************************
7820 *
7821 * Function Name : Netc_EthSwt_Ip_AddOrUpdateIngressStreamCountTableEntry
7822 * Description : Ethernet Switch Add or Update ingress stream count table entry function.
7823 * implements Netc_EthSwt_Ip_AddOrUpdateIngressStreamCountTableEntry_Activity
7824 *END**************************************************************************/
7825 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateIngressStreamCountTableEntry( uint8 SwitchIdx,
7826 Netc_EthSwt_Ip_CommandsType Cmd,
7827 uint32 *MatchedEntries,
7828 uint32 IngressStreamCountId
7829 )
7830 {
7831 Netc_EthSwt_Ip_CBDRStatusType status;
7832 uint32 ActionsData;
7833 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
7834
7835 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
7836 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7837 DevAssert(MatchedEntries != NULL_PTR);
7838 #endif
7839
7840 /* clear the variable MatchedEntries first */
7841 *MatchedEntries = 0U;
7842
7843 /* only support Add and Update commands */
7844 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
7845 {
7846 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
7847 }
7848 else
7849 {
7850 /* set table version and CFGEU flag */
7851 ActionsData = NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD_STSEU(1U) \
7852 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
7853
7854 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_18();
7855 /* ------initialize the table request data buffer------ */
7856 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
7857 /* fill in KEYE_DATA */
7858 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACCESSKEY_FIELD] = IngressStreamCountId; /* fill in ISC_ID field */
7859 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_18();
7860
7861 /* fill in operation data for config field of Request Header*/
7862 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
7863 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
7864 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_COUNT_TABLE_ID;
7865 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
7866 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
7867 OperationData.Cmd = Cmd;
7868 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
7869 OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISCTABLE_RSPBUFFER_LEN);
7870
7871 /* send command */
7872 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
7873 #if defined(ERR_IPV_NETC_051243)
7874 #if (STD_ON == ERR_IPV_NETC_051243)
7875 /* Error code 0x8A is not a real error. check it on Errata. */
7876 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
7877 {
7878 #endif
7879 #else
7880 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
7881 {
7882 #endif
7883 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
7884 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
7885 }
7886 }
7887
7888 return status;
7889 }
7890
7891 /*FUNCTION**********************************************************************
7892 *
7893 * Function Name : Netc_EthSwt_Ip_QueryIngressStreamCountTableEntry
7894 * Description : Ethernet Switch query Ingress Stream Count table entry function.
7895 * implements Netc_EthSwt_Ip_QueryIngressStreamCountTableEntry_Activity
7896 *END**************************************************************************/
7897 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngressStreamCountTableEntry( uint8 SwitchIdx,
7898 uint32 *MatchedEntries,
7899 uint32 IngressStreamCountEntryId,
7900 Netc_EthSwt_Ip_IngressStreamCountTableRspDataType * IngressStreamCountTableEntry
7901 )
7902 {
7903 Netc_EthSwt_Ip_CBDRStatusType status;
7904 uint32 ActionsData;
7905 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
7906
7907 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
7908 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7909 DevAssert(MatchedEntries != NULL_PTR);
7910 DevAssert(IngressStreamCountTableEntry != NULL_PTR);
7911 #endif
7912
7913 /* clear the variable MatchedEntries first */
7914 *MatchedEntries = 0U;
7915
7916 /* always do the full query. 0x0 = Full query. */
7917 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
7918 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
7919
7920 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_19();
7921 /* ------initialize the table request data buffer------ */
7922 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
7923 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACCESSKEY_FIELD] = IngressStreamCountEntryId; /* fill in Entry_ID field (Access Key) */
7924 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_19();
7925
7926 /* fill in operation data for config field of Request Header*/
7927 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
7928 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
7929 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_COUNT_TABLE_ID;
7930 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for query command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
7931 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
7932 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
7933 OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISCTABLE_RSPBUFFER_LEN); /* set response data buffer length */
7934
7935 /* send command */
7936 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
7937 #if defined(ERR_IPV_NETC_051243)
7938 #if (STD_ON == ERR_IPV_NETC_051243)
7939 /* Error code 0x8A is not a real error. check it on Errata. */
7940 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
7941 {
7942 #endif
7943 #else
7944 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
7945 {
7946 #endif
7947 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
7948 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
7949
7950 /* found a matched entry */
7951 if (1U == *MatchedEntries)
7952 {
7953 /* fill in "Netc_EthSwt_Ip_RatePolicerEntryDataType" structure with data in response data buffer */
7954 IngressStreamCountTableEntry->IngressStreamCountId = TableDataBuffer.TableDataField[0U];
7955 /* fill in STSE data */
7956 IngressStreamCountTableEntry->IngressStreamCountStseData.RxCount = TableDataBuffer.TableDataField[1U];
7957 IngressStreamCountTableEntry->IngressStreamCountStseData.MSduDropCount = TableDataBuffer.TableDataField[3U];
7958 IngressStreamCountTableEntry->IngressStreamCountStseData.PolicerDropCount = TableDataBuffer.TableDataField[5U];
7959 IngressStreamCountTableEntry->IngressStreamCountStseData.StreamGateDropCount = TableDataBuffer.TableDataField[7U];
7960 }
7961 }
7962
7963 return status;
7964 }
7965
7966 /*FUNCTION**********************************************************************
7967 *
7968 * Function Name : Netc_EthSwt_Ip_DeleteIngressStreamCountTableEntry
7969 * Description : Ethernet Switch delete Ingress Stream table entry function.
7970 * implements Netc_EthSwt_Ip_DeleteIngressStreamCountTableEntry_Activity
7971 *END**************************************************************************/
7972 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngressStreamCountTableEntry( uint8 SwitchIdx,
7973 uint32 *MatchedEntries,
7974 uint32 IngressStreamCountId
7975 )
7976 {
7977 Netc_EthSwt_Ip_CBDRStatusType status;
7978 uint32 ActionsData = 0U;
7979 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
7980
7981 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
7982 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7983 DevAssert(MatchedEntries != NULL_PTR);
7984 #endif
7985
7986 /* clear the variable MatchedEntries first */
7987 *MatchedEntries = 0U;
7988 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_20();
7989 /* ------initialize the table request data buffer------ */
7990 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
7991 /* fill in KEYE_DATA field */
7992 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACCESSKEY_FIELD] = IngressStreamCountId;
7993 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_20();
7994 /* fill in operation data for config field of Request Header*/
7995 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
7996 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
7997 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_COUNT_TABLE_ID;
7998 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
7999 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
8000 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
8001 OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISCTABLE_RSPBUFFER_LEN); /* set response data buffer with normal length */
8002
8003 /* send the "Delete" command */
8004 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
8005 #if defined(ERR_IPV_NETC_051243)
8006 #if (STD_ON == ERR_IPV_NETC_051243)
8007 /* Error code 0x8A is not a real error. check it on Errata. */
8008 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
8009 {
8010 #endif
8011 #else
8012 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
8013 {
8014 #endif
8015 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
8016 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8017 }
8018
8019 return status;
8020 }
8021
8022 /*FUNCTION**********************************************************************
8023 *
8024 * Function Name : Netc_EthSwt_Ip_AddOrUpdateIngressStreamFilterTableEntry
8025 * Description : Ethernet Switch Add or Update ingress stream filter table entry function.
8026 * implements Netc_EthSwt_Ip_AddOrUpdateIngressStreamFilterTableEntry_Activity
8027 *END**************************************************************************/
8028 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateIngressStreamFilterTableEntry( uint8 SwitchIdx,
8029 Netc_EthSwt_Ip_CommandsType Cmd,
8030 uint32 *MatchedEntries,
8031 const Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry
8032 )
8033 {
8034 Netc_EthSwt_Ip_CBDRStatusType status;
8035 uint32 ActionsData;
8036 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
8037
8038 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8039 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8040 DevAssert(IngressStreamFilterTableEntry != NULL_PTR);
8041 DevAssert(MatchedEntries != NULL_PTR);
8042 #endif
8043
8044 /* clear the variable MatchedEntries first */
8045 *MatchedEntries = 0U;
8046
8047 /* only support Add and Update commands */
8048 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
8049 {
8050 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
8051 }
8052 else
8053 {
8054 /* set table version and CFGEU flag */
8055 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U) \
8056 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
8057 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_21();
8058 /* ------initialize the table request data buffer------ */
8059 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
8060 /* fill in KEYE_DATA */
8061 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.IngressStream_EID; /* fill in IS_EID field */
8062 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.Pcp; /* fill in PCP field */
8063 /* fill in CFGE_DATA */
8064 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV(IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.InternalPriorityValue) \
8065 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideIPV) ? 1U : 0U) \
8066 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR(IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.DropResilience) \
8067 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideDR) ? 1U : 0U) \
8068 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressMirroringEnable) ? 1U : 0U) \
8069 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.TimeStampCaptureEnable) ? 1U : 0U) \
8070 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideRatePolicerInstanceEID) ? 1U : 0U) \
8071 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideStreamGateInstanceEID) ? 1U : 0U) \
8072 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE(IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType) \
8073 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD(IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.CutThrDisable) \
8074 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU(IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.MaximumServiceDataUnit);
8075 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.RatePolicer_EID;
8076 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.StreamGateInstance_EID;
8077 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressStreamCounter_EID;
8078 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_21();
8079
8080 /* fill in operation data for config field of Request Header*/
8081 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8082 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8083 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_FILTER_TABLE_ID;
8084 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH */
8085 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
8086 OperationData.Cmd = Cmd;
8087 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_REQBUFFER_LEN);
8088 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
8089
8090 /* send command */
8091 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
8092 #if defined(ERR_IPV_NETC_051243)
8093 #if (STD_ON == ERR_IPV_NETC_051243)
8094 /* Error code 0x8A is not a real error. check it on Errata. */
8095 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
8096 {
8097 #endif
8098 #else
8099 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
8100 {
8101 #endif
8102 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
8103 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8104 }
8105 }
8106
8107 return status;
8108 }
8109
8110 /*FUNCTION**********************************************************************
8111 *
8112 * Function Name : Netc_EthSwt_Ip_QueryIngressStreamFilterTableEntry
8113 * Description : Ethernet Switch query Ingress Stream Filter table entry function.
8114 * implements Netc_EthSwt_Ip_QueryIngressStreamFilterTableEntry_Activity
8115 *END**************************************************************************/
8116 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngressStreamFilterTableEntry( uint8 SwitchIdx,
8117 uint32 *MatchedEntries,
8118 Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry
8119 )
8120 {
8121 Netc_EthSwt_Ip_CBDRStatusType status;
8122 uint32 ActionsData;
8123 uint32 CfgeConfigBits;
8124 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
8125 uint8 SduType;
8126
8127 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8128 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8129 DevAssert(MatchedEntries != NULL_PTR);
8130 DevAssert(IngressStreamFilterTableEntry != NULL_PTR);
8131 #endif
8132 /* clear the variable MatchedEntries first */
8133 *MatchedEntries = 0U;
8134
8135 /* always do the full query. 0x0 = Full query. */
8136 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
8137 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
8138
8139 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_22();
8140 /* ------initialize the table request data buffer------ */
8141 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
8142 /* fill in KEYE_DATA field */
8143 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.IngressStream_EID;
8144 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.Pcp;
8145 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_22();
8146
8147 /* fill in operation data for config field of Request Header*/
8148 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8149 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8150 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_FILTER_TABLE_ID;
8151 /* for query function, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
8152 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
8153 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
8154 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_OTHER_REQBUFFER_LEN); /* set request data buffer length */
8155 OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_RSPBUFFER_LEN); /* set response data buffer length */
8156
8157 /* send command */
8158 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
8159 #if defined(ERR_IPV_NETC_051243)
8160 #if (STD_ON == ERR_IPV_NETC_051243)
8161 /* Error code 0x8A is not a real error. check it on Errata. */
8162 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
8163 {
8164 #endif
8165 #else
8166 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
8167 {
8168 #endif
8169 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
8170 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8171
8172 /* found a matched entry */
8173 if (1U == *MatchedEntries)
8174 {
8175 /* fill in "Netc_EthSwt_Ip_IngressStreamFilterEntryDataType" structure with data in response data buffer */
8176 IngressStreamFilterTableEntry->IngressStreamFilterEntryId = TableDataBuffer.TableDataField[1U];
8177 /* fill in KEYE_DATA */
8178 IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.IngressStream_EID = TableDataBuffer.TableDataField[2U];
8179 IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.Pcp = (uint8)(TableDataBuffer.TableDataField[3U] & NETC_ETHSWT_IP_ISFILTERTABLE_KEYE_PCP_MASK);
8180 /* fill in CFGE data */
8181 CfgeConfigBits = TableDataBuffer.TableDataField[4U];
8182 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.InternalPriorityValue = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_SHIFT);
8183 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideIPV = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_SHIFT) > 0U) ? TRUE : FALSE;
8184 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.DropResilience = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_SHIFT);
8185 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideDR = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_SHIFT) > 0U) ? TRUE : FALSE;
8186 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressMirroringEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_SHIFT) > 0U) ? TRUE : FALSE;
8187 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.TimeStampCaptureEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_SHIFT) > 0U) ? TRUE : FALSE;
8188 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideRatePolicerInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_SHIFT) > 0U) ? TRUE : FALSE;
8189 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideStreamGateInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_SHIFT) > 0U) ? TRUE : FALSE;
8190 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.CutThrDisable = (CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_SHIFT;
8191 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.MaximumServiceDataUnit = (uint16)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_SHIFT);
8192
8193 SduType = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_SHIFT);
8194 switch (SduType)
8195 {
8196 case 0U:
8197 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_PPDU;
8198 break;
8199 case 1U:
8200 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MPDU;
8201 break;
8202 case 2U:
8203 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MSDU;
8204 break;
8205 default:
8206 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_RSDTYPE;
8207 break;
8208 }
8209
8210 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.RatePolicer_EID = TableDataBuffer.TableDataField[5U];
8211 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.StreamGateInstance_EID = TableDataBuffer.TableDataField[6U];
8212 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressStreamCounter_EID = TableDataBuffer.TableDataField[7U];
8213 }
8214 }
8215
8216 return status;
8217 }
8218
8219 /*FUNCTION**********************************************************************
8220 *
8221 * Function Name : Netc_EthSwt_Ip_DeleteIngressStreamFilterTableEntry
8222 * Description : Ethernet Switch delete Ingress Stream table entry function.
8223 * implements Netc_EthSwt_Ip_DeleteIngressStreamFilterTableEntry_Activity
8224 *END**************************************************************************/
8225 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngressStreamFilterTableEntry( uint8 SwitchIdx,
8226 uint32 *MatchedEntries,
8227 const Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry
8228 )
8229 {
8230 Netc_EthSwt_Ip_CBDRStatusType status;
8231 uint32 ActionsData = 0U;
8232 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
8233
8234 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8235 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8236 DevAssert(MatchedEntries != NULL_PTR);
8237 DevAssert(IngressStreamFilterTableEntry != NULL_PTR);
8238 #endif
8239
8240 /* clear the variable MatchedEntries first */
8241 *MatchedEntries = 0U;
8242 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_23();
8243 /* ------initialize the table request data buffer------ */
8244 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
8245 /* fill in KEYE_DATA field */
8246 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.IngressStream_EID;
8247 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.Pcp;
8248 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_23();
8249
8250 /* fill in operation data for config field of Request Header*/
8251 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8252 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8253 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_FILTER_TABLE_ID;
8254 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH; /* for delete command, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
8255 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
8256 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_OTHER_REQBUFFER_LEN); /* set request data buffer length */
8257 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN); /* set response data buffer with normal length */
8258
8259 /* send the "Delete" command */
8260 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
8261 #if defined(ERR_IPV_NETC_051243)
8262 #if (STD_ON == ERR_IPV_NETC_051243)
8263 /* Error code 0x8A is not a real error. check it on Errata. */
8264 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
8265 {
8266 #endif
8267 #else
8268 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
8269 {
8270 #endif
8271 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
8272 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8273 }
8274
8275 return status;
8276 }
8277
8278 /*FUNCTION**********************************************************************
8279 *
8280 * Function Name : Netc_EthSwt_Ip_SearchIngressStreamFilterTableEntry
8281 * Description : Ethernet Switch search Ingress Stream Filter table entry one by one.
8282 * implements Netc_EthSwt_Ip_SearchIngressStreamFilterTableEntry_Activity
8283 *END**************************************************************************/
8284 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_SearchIngressStreamFilterTableEntry( uint8 SwitchIdx,
8285 uint32 * ResumeEntryId,
8286 uint32 * MatchedEntry,
8287 Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry
8288 )
8289 {
8290 Netc_EthSwt_Ip_CBDRStatusType status;
8291 uint32 ActionsData;
8292 uint32 CfgeConfigBits;
8293 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
8294 uint8 SduType;
8295
8296 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8297 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8298 DevAssert(ResumeEntryId != NULL_PTR);
8299 DevAssert(MatchedEntry != NULL_PTR);
8300 DevAssert(IngressStreamFilterTableEntry != NULL_PTR);
8301 #endif
8302
8303 /* clear the variable MatchedEntry first */
8304 *MatchedEntry = 0U;
8305
8306 /* always do the full query. 0x0 = Full query. */
8307 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
8308 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
8309
8310 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_24();
8311 /* ------initialize the table request data buffer------ */
8312 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
8313 /* fill in KEYE_DATA field */
8314 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = *ResumeEntryId;
8315 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_24();
8316
8317 /* fill in operation data for config field of Request Header*/
8318 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8319 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8320 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_FILTER_TABLE_ID;
8321 /* query function with NETC_ETHSWT_SEARCH_METHOD method */
8322 OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
8323 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
8324 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_OTHER_REQBUFFER_LEN); /* set request data buffer length */
8325 OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_RSPBUFFER_LEN); /* set response data buffer length */
8326
8327 /* send command */
8328 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
8329 #if defined(ERR_IPV_NETC_051243)
8330 #if (STD_ON == ERR_IPV_NETC_051243)
8331 /* Error code 0x8A is not a real error. check it on Errata. */
8332 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
8333 {
8334 #endif
8335 #else
8336 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
8337 {
8338 #endif
8339 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
8340 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntry);
8341
8342 /* found a matched entry */
8343 if (1U == *MatchedEntry)
8344 {
8345 /* fill in "Netc_EthSwt_Ip_IngressStreamFilterEntryDataType" structure with data in response data buffer */
8346 *ResumeEntryId = TableDataBuffer.TableDataField[0U]; /* update the resume entry id for next search */
8347 IngressStreamFilterTableEntry->IngressStreamFilterEntryId = TableDataBuffer.TableDataField[1U];
8348 /* fill in KEYE_DATA */
8349 IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.IngressStream_EID = TableDataBuffer.TableDataField[2U];
8350 IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.Pcp = (uint8)(TableDataBuffer.TableDataField[3U] & NETC_ETHSWT_IP_ISFILTERTABLE_KEYE_PCP_MASK);
8351 /* fill in CFGE data */
8352 CfgeConfigBits = TableDataBuffer.TableDataField[4U];
8353 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.InternalPriorityValue = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_SHIFT);
8354 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideIPV = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_SHIFT) > 0U) ? TRUE : FALSE;
8355 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.DropResilience = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_SHIFT);
8356 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideDR = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_SHIFT) > 0U) ? TRUE : FALSE;
8357 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressMirroringEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_SHIFT) > 0U) ? TRUE : FALSE;
8358 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.TimeStampCaptureEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_SHIFT) > 0U) ? TRUE : FALSE;
8359 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideRatePolicerInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_SHIFT) > 0U) ? TRUE : FALSE;
8360 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideStreamGateInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_SHIFT) > 0U) ? TRUE : FALSE;
8361 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.CutThrDisable = (CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_SHIFT;
8362 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.MaximumServiceDataUnit = (uint16)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_SHIFT);
8363
8364 SduType = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_SHIFT);
8365 switch (SduType)
8366 {
8367 case 0U:
8368 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_PPDU;
8369 break;
8370 case 1U:
8371 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MPDU;
8372 break;
8373 case 2U:
8374 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MSDU;
8375 break;
8376 default:
8377 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_RSDTYPE;
8378 break;
8379 }
8380
8381 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.RatePolicer_EID = TableDataBuffer.TableDataField[5U];
8382 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.StreamGateInstance_EID = TableDataBuffer.TableDataField[6U];
8383 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressStreamCounter_EID = TableDataBuffer.TableDataField[7U];
8384 }
8385 }
8386
8387 return status;
8388 }
8389
8390 /*FUNCTION**********************************************************************
8391 *
8392 * Function Name : Netc_EthSwt_Ip_SearchAndFillIngressStreamFilterTable
8393 * Description : inline function for searching and filling Ingress Stream Filter table entries.
8394 *END**************************************************************************/
8395 static inline Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_SearchAndFillIngressStreamFilterTable( uint8 SwitchIdx,
8396 uint32 * ResumeEntryId,
8397 uint16 * NumOfExistingEntry,
8398 Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry
8399 )
8400 {
8401 Netc_EthSwt_Ip_CBDRStatusType status;
8402 uint32 ActionsData;
8403 uint32 CfgeConfigBits;
8404 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
8405 uint8 SduType;
8406 uint32 MatchedEntries = 0x0UL;
8407
8408 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8409 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8410 DevAssert(ResumeEntryId != NULL_PTR);
8411 DevAssert(IngressStreamFilterTableEntry != NULL_PTR);
8412 #endif
8413
8414 /* always do the full query. 0x0 = Full query. */
8415 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
8416 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
8417
8418 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_25();
8419
8420 /* ------initialize the table request data buffer------ */
8421 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
8422 /* fill in KEYE_DATA field */
8423 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = *ResumeEntryId;
8424 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_25();
8425
8426 /* fill in operation data for config field of Request Header*/
8427 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8428 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8429 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_FILTER_TABLE_ID;
8430 /* query function with NETC_ETHSWT_SEARCH_METHOD method */
8431 OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
8432 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
8433 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_OTHER_REQBUFFER_LEN); /* set request data buffer length */
8434 OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_RSPBUFFER_LEN); /* set response data buffer length */
8435
8436 /* send command */
8437 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
8438 #if defined(ERR_IPV_NETC_051243)
8439 #if (STD_ON == ERR_IPV_NETC_051243)
8440 /* Error code 0x8A is not a real error. check it on Errata. */
8441 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
8442 {
8443 #endif
8444 #else
8445 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
8446 {
8447 #endif
8448 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
8449 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &MatchedEntries);
8450
8451 /* get the resume_entry_id and be ready for the next query operation */
8452 *ResumeEntryId = TableDataBuffer.TableDataField[0U];
8453
8454 /* ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED */
8455 /* found a matched entry */
8456 if ((1U == MatchedEntries) && (*ResumeEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
8457 {
8458 /* fill in "Netc_EthSwt_Ip_IngressStreamFilterEntryDataType" structure with data in response data buffer */
8459 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterEntryId = TableDataBuffer.TableDataField[1U];
8460 /* fill in KEYE_DATA */
8461 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterKeyeData.IngressStream_EID = TableDataBuffer.TableDataField[2U];
8462 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterKeyeData.Pcp = (uint8)(TableDataBuffer.TableDataField[3U] & NETC_ETHSWT_IP_ISFILTERTABLE_KEYE_PCP_MASK);
8463 /* fill in CFGE data */
8464 CfgeConfigBits = TableDataBuffer.TableDataField[4U];
8465 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.InternalPriorityValue = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_SHIFT);
8466 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.OverrideIPV = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_SHIFT) > 0U) ? TRUE : FALSE;
8467 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.DropResilience = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_SHIFT);
8468 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.OverrideDR = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_SHIFT) > 0U) ? TRUE : FALSE;
8469 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.IngressMirroringEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_SHIFT) > 0U) ? TRUE : FALSE;
8470 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.TimeStampCaptureEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_SHIFT) > 0U) ? TRUE : FALSE;
8471 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.OverrideRatePolicerInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_SHIFT) > 0U) ? TRUE : FALSE;
8472 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.OverrideStreamGateInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_SHIFT) > 0U) ? TRUE : FALSE;
8473 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.CutThrDisable = (CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_SHIFT;
8474 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.MaximumServiceDataUnit = (uint16)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_SHIFT);
8475
8476 SduType = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_SHIFT);
8477 switch (SduType)
8478 {
8479 case 0U:
8480 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_PPDU;
8481 break;
8482 case 1U:
8483 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MPDU;
8484 break;
8485 case 2U:
8486 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MSDU;
8487 break;
8488 default:
8489 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_RSDTYPE;
8490 break;
8491 }
8492
8493 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.RatePolicer_EID = TableDataBuffer.TableDataField[5U];
8494 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.StreamGateInstance_EID = TableDataBuffer.TableDataField[6U];
8495 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.IngressStreamCounter_EID = TableDataBuffer.TableDataField[7U];
8496
8497 /* increase the NumOfExistingEntry */
8498 (*NumOfExistingEntry) += 1U;
8499 }
8500 }
8501
8502 return status;
8503 }
8504
8505 /*FUNCTION**********************************************************************
8506 *
8507 * Function Name : Netc_EthSwt_Ip_GetIngressStreamFilterTable
8508 * Description : Ethernet Switch get ingress stream filter table function.
8509 * implements Netc_EthSwt_Ip_GetIngressStreamFilterTable_Activity
8510 *END**************************************************************************/
8511 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_GetIngressStreamFilterTable( uint8 SwitchIdx,
8512 uint16 * NumberOfElements,
8513 Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableList
8514 )
8515 {
8516 Netc_EthSwt_Ip_CBDRStatusType status = E_OK;
8517 uint16 NumOfExistingEntry = 0U;
8518 uint32 ResumeId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
8519
8520 /* [notes]: we will have to read entries one by one because of the errata ERR051048.
8521 - ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED
8522 - Description: The NUM_MATCHED field in the command NTMP response header may be incorrect when
8523 the search access method is used for the following tables: FDB table 15, L2 IPv4 Multicast
8524 Filter table 16, VLAN Filter table 18, Ingress Stream Identification table 30, or Ingress Stream
8525 Filter table 32.
8526 - Workaround: For the query command, limit the message response buffer size (RESPONSE_LENGTH field in the request header)
8527 so that NETC returns no more than one entry at a time. Under this condition, the NUM_MATCHED field value is correct
8528 */
8529
8530 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8531 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8532 DevAssert(NumberOfElements != NULL_PTR);
8533 DevAssert(*NumberOfElements != 0U);
8534 DevAssert(IngressStreamFilterTableList != NULL_PTR);
8535 #endif
8536
8537 do
8538 {
8539 /* check if the IngressStreamFilterTableList is full or we get all existing entries */
8540 if ((NumOfExistingEntry >= *NumberOfElements) || (status == (uint8)(E_NOT_OK)))
8541 {
8542 break;
8543 }
8544
8545 status = Netc_EthSwt_Ip_SearchAndFillIngressStreamFilterTable(SwitchIdx, &ResumeId, &NumOfExistingEntry, IngressStreamFilterTableList);
8546
8547 } while (ResumeId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID); /* ResumeId == NETC_ETHSWT_IP_BD_NULL_ENTRY_ID means the query operation is completed */
8548
8549 /* return the Number of elements which are currently available in the EthSwitch module or number of elements copied to IngressStreamFilterTableList*/
8550 *NumberOfElements = NumOfExistingEntry;
8551
8552 return status;
8553 }
8554
8555 /*FUNCTION**********************************************************************
8556 *
8557 * Function Name : Netc_EthSwt_Ip_AddOrUpdateStreamGateInstanceTableEntry
8558 * Description : Ethernet Switch Add or Update Stream Gate Instance table entry function.
8559 * implements Netc_EthSwt_Ip_AddOrUpdateStreamGateInstanceTableEntry_Activity
8560 *END**************************************************************************/
8561 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateStreamGateInstanceTableEntry( uint8 SwitchIdx,
8562 Netc_EthSwt_Ip_CommandsType Cmd,
8563 uint32 *MatchedEntries,
8564 const Netc_EthSwt_Ip_StreamGateInstanceEntryDataType * StreamGateInstanceTableEntry
8565 )
8566 {
8567 Netc_EthSwt_Ip_CBDRStatusType status;
8568 uint32 ActionsData;
8569 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
8570
8571 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8572 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8573 DevAssert(StreamGateInstanceTableEntry != NULL_PTR);
8574 DevAssert(MatchedEntries != NULL_PTR);
8575 #endif
8576
8577 /* clear the variable MatchedEntries first */
8578 *MatchedEntries = 0U;
8579
8580 /* only support Add and Update commands */
8581 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
8582 {
8583 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
8584 }
8585 else
8586 {
8587 /* set table version and update actions*/
8588 ActionsData = NETC_ETHSWT_IP_SGITABLE_REQFMT_ACFGEU(1U) \
8589 | NETC_ETHSWT_IP_SGITABLE_REQFMT_CFGEU(1U) \
8590 | NETC_ETHSWT_IP_SGITABLE_REQFMT_SGISEU(1U) \
8591 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
8592
8593 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_26();
8594 /* ------initialize the table request data buffer------ */
8595 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
8596 /* fill in KEYE_DATA */
8597 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = StreamGateInstanceTableEntry->SGIEntryId; /* fill in Entry_ID */
8598 /* fill in ACFGE_DATA */
8599 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = StreamGateInstanceTableEntry->AdminSGCLEntryId;
8600 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = (uint32)(StreamGateInstanceTableEntry->AdminBaseTime & 0xFFFFFFFFUL);
8601 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = (uint32)(StreamGateInstanceTableEntry->AdminBaseTime >> NETC_ETHSWT_IP_32BIT_SHIFT);
8602 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = StreamGateInstanceTableEntry->AdminCycleTimeExt;
8603 /* fill in CFGE_DATA and ICFGE_DATA */
8604 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = (NETC_ETHSWT_IP_SGITABLE_CFGE_OEXEN(StreamGateInstanceTableEntry->Cfge_Oexen ? 1U : 0U) \
8605 | NETC_ETHSWT_IP_SGITABLE_CFGE_IRXEN(StreamGateInstanceTableEntry->Cfge_Irxen ? 1U : 0U) \
8606 | NETC_ETHSWT_IP_SGITABLE_CFGE_SDUTYPE(StreamGateInstanceTableEntry->SduType) \
8607 | (NETC_ETHSWT_IP_SGITABLE_ICFGE_IPV(StreamGateInstanceTableEntry->Icfge_Ipv) << NETC_ETHSWT_IP_8BIT_SHIFT) \
8608 | (NETC_ETHSWT_IP_SGITABLE_ICFGE_OIPV(StreamGateInstanceTableEntry->Icfge_Oipv ? 1U : 0U) << NETC_ETHSWT_IP_8BIT_SHIFT) \
8609 | (NETC_ETHSWT_IP_SGITABLE_ICFGE_GST(StreamGateInstanceTableEntry->Icfge_Gst) << NETC_ETHSWT_IP_8BIT_SHIFT) \
8610 | (NETC_ETHSWT_IP_SGITABLE_ICFGE_CTD(StreamGateInstanceTableEntry->Icfge_Ctd ? 1U : 0U) << NETC_ETHSWT_IP_8BIT_SHIFT)) & 0xFFFFU;
8611 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_26();
8612
8613 /* fill in operation data for config field of Request Header*/
8614 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8615 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8616 OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_INSTANCE_TABLE_ID;
8617 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
8618 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
8619 OperationData.Cmd = Cmd;
8620 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_SGITABLE_REQBUFFER_LEN);
8621 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
8622
8623 /* send command */
8624 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
8625 #if defined(ERR_IPV_NETC_051243)
8626 #if (STD_ON == ERR_IPV_NETC_051243)
8627 /* Error code 0x8A is not a real error. check it on Errata. */
8628 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
8629 {
8630 #endif
8631 #else
8632 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
8633 {
8634 #endif
8635 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
8636 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8637 }
8638 }
8639
8640 return status;
8641 }
8642
8643 /*FUNCTION**********************************************************************
8644 *
8645 * Function Name : Netc_EthSwt_Ip_QueryStreamGateInstanceTableEntry
8646 * Description : Ethernet Switch query Ingress Stream Filter table entry function.
8647 * implements Netc_EthSwt_Ip_QueryStreamGateInstanceTableEntry_Activity
8648 *END**************************************************************************/
8649 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryStreamGateInstanceTableEntry( uint8 SwitchIdx,
8650 uint32 *MatchedEntries,
8651 uint32 SGIEntryId,
8652 Netc_EthSwt_Ip_StreamGateInstanceEntryRspDataType * SGITableEntryRspData
8653 )
8654 {
8655 Netc_EthSwt_Ip_CBDRStatusType status;
8656 uint32 ActionsData;
8657 uint32 ConfigBits;
8658 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
8659 uint8 SduType;
8660
8661 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8662 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8663 DevAssert(MatchedEntries != NULL_PTR);
8664 DevAssert(SGITableEntryRspData != NULL_PTR);
8665 #endif
8666
8667 /* clear the variable MatchedEntries first */
8668 *MatchedEntries = 0U;
8669
8670 /* always do the full query. 0x0 = Full query. */
8671 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
8672 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
8673
8674 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_27();
8675 /* ------initialize the table request data buffer------ */
8676 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
8677 /* fill in ACCESS_KEY field */
8678 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = SGIEntryId;
8679 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_27();
8680
8681 /* fill in operation data for config field of Request Header*/
8682 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8683 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8684 OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_INSTANCE_TABLE_ID;
8685 /* for query function, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
8686 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
8687 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
8688 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
8689 OperationData.RspBuffLength = (NETC_ETHSWT_IP_SGITABLE_RSPBUFFER_LEN); /* set response data buffer length */
8690
8691 /* send command */
8692 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
8693 #if defined(ERR_IPV_NETC_051243)
8694 #if (STD_ON == ERR_IPV_NETC_051243)
8695 /* Error code 0x8A is not a real error. check it on Errata. */
8696 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
8697 {
8698 #endif
8699 #else
8700 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
8701 {
8702 #endif
8703 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
8704 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8705
8706 /* found a matched entry */
8707 if (1U == *MatchedEntries)
8708 {
8709 /* fill in "Netc_EthSwt_Ip_StreamGateInstanceEntryRspDataType" structure with data in response data buffer */
8710 SGITableEntryRspData->SGIEntryId = TableDataBuffer.TableDataField[0U];
8711 /* fill in SGISE_DATA */
8712 SGITableEntryRspData->OperationalSGCLEntryID = TableDataBuffer.TableDataField[1U];
8713 SGITableEntryRspData->ConfigChangeTime = ((uint64)(TableDataBuffer.TableDataField[3U]) << NETC_ETHSWT_IP_32BIT_SHIFT);
8714 SGITableEntryRspData->ConfigChangeTime |= (uint64)(TableDataBuffer.TableDataField[2U]);
8715 SGITableEntryRspData->OperationalBaseTime = ((uint64)(TableDataBuffer.TableDataField[5U]) << NETC_ETHSWT_IP_32BIT_SHIFT);
8716 SGITableEntryRspData->OperationalBaseTime |= (uint64)(TableDataBuffer.TableDataField[4U]);
8717 SGITableEntryRspData->OperationalCycleTimeExt = TableDataBuffer.TableDataField[6U];
8718 ConfigBits = TableDataBuffer.TableDataField[7U];
8719 SGITableEntryRspData->SGISEOex = (uint8)(ConfigBits & NETC_ETHSWT_IP_SGITABLE_SGISE_OEX_MASK);
8720 SGITableEntryRspData->SGISEIrx = (uint8)((ConfigBits & NETC_ETHSWT_IP_SGITABLE_SGISE_IRX_MASK) >> NETC_ETHSWT_IP_SGITABLE_SGISE_IRX_SHIFT);
8721 SGITableEntryRspData->SGISEState = (uint8)((ConfigBits & NETC_ETHSWT_IP_SGITABLE_SGISE_STATE_MASK) >> NETC_ETHSWT_IP_SGITABLE_SGISE_STATE_SHIFT);
8722
8723 /* fill in CFGE data */
8724 ConfigBits = TableDataBuffer.TableDataField[7U] >> NETC_ETHSWT_IP_8BIT_SHIFT;
8725 SGITableEntryRspData->Cfge_Oexen = ((ConfigBits & NETC_ETHSWT_IP_SGITABLE_CFGE_OEXEN_MASK) == 0U) ? FALSE : TRUE;
8726 SGITableEntryRspData->Cfge_Irxen = ((ConfigBits & NETC_ETHSWT_IP_SGITABLE_CFGE_IRXEN_MASK) == 0U) ? FALSE : TRUE;
8727 SduType = (uint8)((ConfigBits & NETC_ETHSWT_IP_SGITABLE_CFGE_SDUTYPE_MASK) >> NETC_ETHSWT_IP_SGITABLE_CFGE_SDUTYPE_SHIFT);
8728 switch (SduType)
8729 {
8730 case 0U:
8731 SGITableEntryRspData->SduType = NETC_ETHSWT_IP_PPDU;
8732 break;
8733 case 1U:
8734 SGITableEntryRspData->SduType = NETC_ETHSWT_IP_MPDU;
8735 break;
8736 case 2U:
8737 SGITableEntryRspData->SduType = NETC_ETHSWT_IP_MSDU;
8738 break;
8739 default:
8740 SGITableEntryRspData->SduType = NETC_ETHSWT_IP_RSDTYPE;
8741 break;
8742 }
8743
8744 /* fill in ICFGE data */
8745 ConfigBits = TableDataBuffer.TableDataField[7U] >> NETC_ETHSWT_IP_16BIT_SHIFT;
8746 SGITableEntryRspData->Icfge_Ipv = (uint8)(ConfigBits & NETC_ETHSWT_IP_SGITABLE_ICFGE_IPV_MASK);
8747 SGITableEntryRspData->Icfge_Oipv = ((ConfigBits & NETC_ETHSWT_IP_SGITABLE_ICFGE_OIPV_MASK) == 0U) ? FALSE : TRUE;
8748 SGITableEntryRspData->Icfge_Gst = (ConfigBits & NETC_ETHSWT_IP_SGITABLE_ICFGE_GST_MASK) >> NETC_ETHSWT_IP_SGITABLE_ICFGE_GST_SHIFT;
8749 SGITableEntryRspData->Icfge_Ctd = ((ConfigBits & NETC_ETHSWT_IP_SGITABLE_ICFGE_CTD_MASK) >> NETC_ETHSWT_IP_SGITABLE_ICFGE_CTD_SHIFT)!=0U;
8750
8751 /* fill in ACFGE data */
8752 SGITableEntryRspData->AdminSGCLEntryId = TableDataBuffer.TableDataField[8U];
8753 SGITableEntryRspData->AdminBaseTime = (((uint64)(TableDataBuffer.TableDataField[10U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
8754 SGITableEntryRspData->AdminBaseTime |= (uint64)(TableDataBuffer.TableDataField[9U]);
8755 SGITableEntryRspData->AdminCycleTimeExt = TableDataBuffer.TableDataField[11U];
8756 }
8757 }
8758
8759 return status;
8760 }
8761
8762 /*FUNCTION**********************************************************************
8763 *
8764 * Function Name : Netc_EthSwt_Ip_DeleteStreamGateInstanceTableEntry
8765 * Description : Ethernet Switch delete Stream Gate Instance table entry function.
8766 * implements Netc_EthSwt_Ip_DeleteStreamGateInstanceTableEntry_Activity
8767 *END**************************************************************************/
8768 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteStreamGateInstanceTableEntry( uint8 SwitchIdx,
8769 uint32 *MatchedEntries,
8770 uint32 SGIEntryId
8771 )
8772 {
8773 Netc_EthSwt_Ip_CBDRStatusType status;
8774 uint32 ActionsData = 0U;
8775 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
8776
8777 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8778 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8779 DevAssert(MatchedEntries != NULL_PTR);
8780 #endif
8781
8782 /* clear the variable MatchedEntries first */
8783 *MatchedEntries = 0U;
8784 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_28();
8785 /* ------initialize the table request data buffer------ */
8786 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
8787 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = SGIEntryId; /* fill in Entry_ID field (Access Key) */
8788 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_28();
8789
8790 /* fill in operation data for config field of Request Header*/
8791 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8792 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8793 OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_INSTANCE_TABLE_ID;
8794 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
8795 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
8796 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
8797 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN); /* set response data buffer with normal length */
8798
8799 /* send the "Delete" command */
8800 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
8801 #if defined(ERR_IPV_NETC_051243)
8802 #if (STD_ON == ERR_IPV_NETC_051243)
8803 /* Error code 0x8A is not a real error. check it on Errata. */
8804 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
8805 {
8806 #endif
8807 #else
8808 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
8809 {
8810 #endif
8811 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
8812 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8813 }
8814
8815 return status;
8816 }
8817
8818 /*FUNCTION**********************************************************************
8819 *
8820 * Function Name : Netc_EthSwt_Ip_AddStreamGateControlListTableEntry
8821 * Description : Ethernet Switch Add Stream Gate Control List table entry function.
8822 * implements Netc_EthSwt_Ip_AddStreamGateControlListTableEntry_Activity
8823 *END**************************************************************************/
8824 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddStreamGateControlListTableEntry( uint8 SwitchIdx,
8825 Netc_EthSwt_Ip_CommandsType Cmd,
8826 uint32 *MatchedEntries,
8827 const Netc_EthSwt_Ip_SGCLTableDataType * SGCLTableEntry
8828 )
8829 {
8830 Netc_EthSwt_Ip_CBDRStatusType status;
8831 uint32 ActionsData;
8832 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
8833 uint8 ListIdx;
8834
8835 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8836 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8837 DevAssert(SGCLTableEntry != NULL_PTR);
8838 DevAssert(MatchedEntries != NULL_PTR);
8839 if (SGCLTableEntry->Cfge_ListLength > 0U)
8840 {
8841 DevAssert(SGCLTableEntry->ListEntries != NULL_PTR);
8842 }
8843 #endif
8844
8845 /* clear the variable MatchedEntries first */
8846 *MatchedEntries = 0U;
8847
8848 /* only support Add commands */
8849 if (NETC_ETHSWT_ADD_CMD != Cmd)
8850 {
8851 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
8852 }
8853 else
8854 {
8855 /* set table version*/
8856 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
8857
8858 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_29();
8859 /* ------initialize the table request data buffer------ */
8860 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
8861 /* fill in ACCESS_KEY */
8862 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = SGCLTableEntry->SGCLEntryId; /* fill in Entry_ID */
8863 /* fill in CFGE_DATA */
8864 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = SGCLTableEntry->Cfge_CycleTime;
8865 /* Software must set LIST_LENGTH to N-1, where N is the size of the list being configured LIST_LENGTH=(N-1). will do it reversely when querying */
8866 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = NETC_ETHSWT_IP_SGCLTABLE_CFGE_LISTLEN((uint8)(SGCLTableEntry->Cfge_ListLength - 1U)) \
8867 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTOIPV((SGCLTableEntry->Cfge_ExtOIPV) ? 1U : 0U) \
8868 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTIPV(SGCLTableEntry->Cfge_ExtIpv) \
8869 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTCTD((SGCLTableEntry->Cfge_ExtCtd) ? 1U : 0U) \
8870 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTGTST(SGCLTableEntry->Cfge_ExtGtst);
8871
8872 /* fill in list entries data */
8873 if (SGCLTableEntry->Cfge_ListLength > 0U)
8874 {
8875 for (ListIdx = 0U; ListIdx < SGCLTableEntry->Cfge_ListLength; ListIdx++)
8876 {
8877 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2 + (2U * ListIdx)] = SGCLTableEntry->ListEntries[ListIdx].SGCL_TimeInterval;
8878 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3 + (2U * ListIdx)] = NETC_ETHSWT_IP_SGCLTABLE_CFGE_IOM(SGCLTableEntry->ListEntries[ListIdx].SGCL_IntervalOctetsMax) \
8879 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_IPV(SGCLTableEntry->ListEntries[ListIdx].SGCL_Ipv) \
8880 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_OIPV((SGCLTableEntry->ListEntries[ListIdx].SGCL_Oipv) ? 1U : 0U) \
8881 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_CTD((SGCLTableEntry->ListEntries[ListIdx].SGCL_Ctd) ? 1U : 0U) \
8882 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_IOMEN((SGCLTableEntry->ListEntries[ListIdx].SGCL_IntervalOctetMaxEnable) ? 1U : 0U) \
8883 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_GTST(SGCLTableEntry->ListEntries[ListIdx].SGCL_GateState);
8884 }
8885 }
8886 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_29();
8887
8888 /* fill in operation data for config field of Request Header*/
8889 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8890 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8891 OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_CTRL_LIST_TABLE_ID;
8892 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
8893 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
8894 OperationData.Cmd = Cmd;
8895 /* the request and response data buffer length are variable based on the length of control list*/
8896 OperationData.ReqBuffLength = (uint16)((uint8)(16U + (8U * SGCLTableEntry->Cfge_ListLength)));
8897 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
8898
8899 /* send command */
8900 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
8901 #if defined(ERR_IPV_NETC_051243)
8902 #if (STD_ON == ERR_IPV_NETC_051243)
8903 /* Error code 0x8A is not a real error. check it on Errata. */
8904 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
8905 {
8906 #endif
8907 #else
8908 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
8909 {
8910 #endif
8911 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
8912 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8913 }
8914 }
8915
8916 return status;
8917 }
8918
8919 /*FUNCTION**********************************************************************
8920 *
8921 * Function Name : Netc_EthSwt_Ip_QueryStreamGateControlListTableEntry
8922 * Description : Ethernet Switch query Ingress Stream Control List table entry function.
8923 * implements Netc_EthSwt_Ip_QueryStreamGateControlListTableEntry_Activity
8924 *END**************************************************************************/
8925 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryStreamGateControlListTableEntry( uint8 SwitchIdx,
8926 uint32 *MatchedEntries,
8927 uint32 SGCLEntryId,
8928 uint8 ListLen,
8929 Netc_EthSwt_Ip_SGCLTableDataType * SGCLTableEntryRspData
8930 )
8931 {
8932 Netc_EthSwt_Ip_CBDRStatusType status;
8933 uint32 ActionsData;
8934 uint32 ConfigBits;
8935 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
8936 uint8 ListIdx;
8937
8938 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8939 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8940 DevAssert(MatchedEntries != NULL_PTR);
8941 DevAssert(SGCLTableEntryRspData != NULL_PTR);
8942 if (ListLen > 0U)
8943 {
8944 DevAssert(SGCLTableEntryRspData->ListEntries != NULL_PTR);
8945 }
8946 #endif
8947
8948 /* clear the variable MatchedEntries first */
8949 *MatchedEntries = 0U;
8950
8951 /* always do the full query. 0x0 = Full query. */
8952 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
8953 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
8954
8955 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_30();
8956 /* ------initialize the table request data buffer------ */
8957 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
8958 /* fill in ACCESS_KEY field */
8959 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = SGCLEntryId;
8960 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_30();
8961
8962 /* fill in operation data for config field of Request Header*/
8963 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8964 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8965 OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_CTRL_LIST_TABLE_ID;
8966 /* for query function, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
8967 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
8968 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
8969 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
8970 OperationData.RspBuffLength = (uint16)((uint8)(16U + (8U * ListLen))); /* set response data buffer length */
8971
8972 /* send command */
8973 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
8974 #if defined(ERR_IPV_NETC_051243)
8975 #if (STD_ON == ERR_IPV_NETC_051243)
8976 /* Error code 0x8A is not a real error. check it on Errata. */
8977 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
8978 {
8979 #endif
8980 #else
8981 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
8982 {
8983 #endif
8984 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
8985 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8986
8987 /* found a matched entry */
8988 if (1U == *MatchedEntries)
8989 {
8990 /* fill in "Netc_EthSwt_Ip_SGCLTableDataType" structure with data in response data buffer */
8991 SGCLTableEntryRspData->SGCLEntryId = TableDataBuffer.TableDataField[0U];
8992
8993 /* fill in SGCLSE_DATA */
8994 SGCLTableEntryRspData->Sgclse_RefCount = (TableDataBuffer.TableDataField[1U] & NETC_ETHSWT_IP_SGCLTABLE_SGCLSE_REFCOUNT_MASK);
8995
8996 /* fill in CFGE data */
8997 SGCLTableEntryRspData->Cfge_CycleTime = TableDataBuffer.TableDataField[2U];
8998 ConfigBits = TableDataBuffer.TableDataField[3U];
8999 SGCLTableEntryRspData->Cfge_ListLength = (uint8)(ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_LISTLEN_MASK) + 1U;
9000 SGCLTableEntryRspData->Cfge_ExtIpv = (uint8)((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTIPV_MASK) >> NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTIPV_SHIFT);
9001 SGCLTableEntryRspData->Cfge_ExtOIPV = ((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTOIPV_MASK) == 0x0UL) ? FALSE : TRUE;
9002 SGCLTableEntryRspData->Cfge_ExtCtd = ((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTCTD_MASK) == 0x0UL) ? FALSE : TRUE;
9003 SGCLTableEntryRspData->Cfge_ExtGtst = (ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTGTST_MASK) >> NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTGTST_SHIFT;
9004
9005 if (SGCLTableEntryRspData->Cfge_ListLength > 0U)
9006 {
9007 for (ListIdx = 0U; ListIdx < SGCLTableEntryRspData->Cfge_ListLength; ListIdx++)
9008 {
9009 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_TimeInterval = TableDataBuffer.TableDataField[4U + (2U * ListIdx)];
9010 ConfigBits = TableDataBuffer.TableDataField[5U + (2U * ListIdx)];
9011 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_IntervalOctetsMax = ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_IOM_MASK;
9012 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_Ipv = (uint8)((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_IPV_MASK) >> NETC_ETHSWT_IP_SGCLTABLE_CFGE_IPV_SHIFT);
9013 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_Oipv = ((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_OIPV_MASK) == 0x0UL) ? FALSE : TRUE;
9014 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_Ctd = ((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_CTD_MASK) == 0x0UL) ? FALSE : TRUE;
9015 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_IntervalOctetMaxEnable = ((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_IOMEN_MASK) == 0x0UL) ? FALSE : TRUE;
9016 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_GateState = (ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_GTST_MASK) >> NETC_ETHSWT_IP_SGCLTABLE_CFGE_GTST_SHIFT;
9017 }
9018 }
9019 }
9020 }
9021
9022 return status;
9023 }
9024
9025 /*FUNCTION**********************************************************************
9026 *
9027 * Function Name : Netc_EthSwt_Ip_DeleteStreamGateControlListTableEntry
9028 * Description : Ethernet Switch delete Stream Gate Instance table entry function.
9029 * implements Netc_EthSwt_Ip_DeleteStreamGateControlListTableEntry_Activity
9030 *END**************************************************************************/
9031 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteStreamGateControlListTableEntry( uint8 SwitchIdx,
9032 uint32 *MatchedEntries,
9033 uint32 SGCLEntryId
9034 )
9035 {
9036 Netc_EthSwt_Ip_CBDRStatusType status;
9037 uint32 ActionsData = 0U;
9038 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
9039
9040 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9041 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9042 DevAssert(MatchedEntries != NULL_PTR);
9043 #endif
9044
9045 /* clear the variable MatchedEntries first */
9046 *MatchedEntries = 0U;
9047 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_31();
9048 /* ------initialize the table request data buffer------ */
9049 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
9050 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = SGCLEntryId; /* fill in Entry_ID field (Access Key) */
9051 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_31();
9052
9053 /* fill in operation data for config field of Request Header*/
9054 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9055 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9056 OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_CTRL_LIST_TABLE_ID;
9057 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
9058 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
9059 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
9060 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN); /* set response data buffer with normal length */
9061
9062 /* send the "Delete" command */
9063 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
9064 #if defined(ERR_IPV_NETC_051243)
9065 #if (STD_ON == ERR_IPV_NETC_051243)
9066 /* Error code 0x8A is not a real error. check it on Errata. */
9067 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
9068 {
9069 #endif
9070 #else
9071 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
9072 {
9073 #endif
9074 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
9075 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9076 }
9077
9078 return status;
9079 }
9080
9081 /*FUNCTION**********************************************************************
9082 *
9083 * Function Name : Netc_EthSwt_Ip_AddOrUpdateIngressSeqGenerationTableEntry
9084 * Description : Ethernet Switch Add or Update Ingress Sequence Generation table entry function.
9085 * implements Netc_EthSwt_Ip_AddOrUpdateIngressSeqGenerationTableEntry_Activity
9086 *END**************************************************************************/
9087 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateIngressSeqGenerationTableEntry( uint8 SwitchIdx,
9088 Netc_EthSwt_Ip_CommandsType Cmd,
9089 uint32 *MatchedEntries,
9090 const Netc_EthSwt_Ip_ISQGTableDataType * ISQGTableEntry
9091 )
9092 {
9093 Netc_EthSwt_Ip_CBDRStatusType status;
9094 uint32 ActionsData;
9095 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
9096
9097 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9098 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9099 DevAssert(ISQGTableEntry != NULL_PTR);
9100 DevAssert(MatchedEntries != NULL_PTR);
9101 #endif
9102
9103 /* clear the variable MatchedEntries first */
9104 *MatchedEntries = 0U;
9105
9106 /* only support Add and Update commands */
9107 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
9108 {
9109 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
9110 }
9111 else
9112 {
9113 /* set table version and update actions*/
9114 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U) \
9115 | NETC_ETHSWT_IP_ISQGTABLE_REQFMT_ACTIONS_FIELD_SGSEU(1U) \
9116 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9117
9118 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_32();
9119 /* ------initialize the table request data buffer------ */
9120 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9121 /* fill in KEYE_DATA */
9122 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = ISQGTableEntry->ISQGEntryId; /* fill in Entry_ID */
9123 /* fill in ACFGE_DATA */
9124 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = ISQGTableEntry->Cfge_SQTagType;
9125 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_32();
9126
9127 /* fill in operation data for config field of Request Header*/
9128 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9129 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9130 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_SEQ_GENERATION_TABLE_ID;
9131 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
9132 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
9133 OperationData.Cmd = Cmd;
9134 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISQGTABLE_REQBUFFER_LEN);
9135 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
9136
9137 /* send command */
9138 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
9139 #if defined(ERR_IPV_NETC_051243)
9140 #if (STD_ON == ERR_IPV_NETC_051243)
9141 /* Error code 0x8A is not a real error. check it on Errata. */
9142 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
9143 {
9144 #endif
9145 #else
9146 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
9147 {
9148 #endif
9149 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
9150 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9151 }
9152 }
9153
9154 return status;
9155 }
9156
9157 /*FUNCTION**********************************************************************
9158 *
9159 * Function Name : Netc_EthSwt_Ip_QueryIngressSeqGenerationTableEntry
9160 * Description : Ethernet Switch query Ingress Sequence Generation table entry function.
9161 * implements Netc_EthSwt_Ip_QueryIngressSeqGenerationTableEntry_Activity
9162 *END**************************************************************************/
9163 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngressSeqGenerationTableEntry( uint8 SwitchIdx,
9164 uint32 *MatchedEntries,
9165 uint32 ISQGEntryId,
9166 Netc_EthSwt_Ip_ISQGTableDataType * ISQGRspData
9167 )
9168 {
9169 Netc_EthSwt_Ip_CBDRStatusType status;
9170 uint32 ActionsData;
9171 uint32 ConfigBits;
9172 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
9173
9174 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9175 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9176 DevAssert(MatchedEntries != NULL_PTR);
9177 DevAssert(ISQGRspData != NULL_PTR);
9178 #endif
9179
9180 /* clear the variable MatchedEntries first */
9181 *MatchedEntries = 0U;
9182
9183 /* always do the full query. 0x0 = Full query. */
9184 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
9185 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9186
9187 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_33();
9188 /* ------initialize the table request data buffer------ */
9189 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9190 /* fill in ACCESS_KEY field */
9191 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = ISQGEntryId;
9192 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_33();
9193
9194 /* fill in operation data for config field of Request Header*/
9195 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9196 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9197 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_SEQ_GENERATION_TABLE_ID;
9198 /* for query function, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
9199 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
9200 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
9201 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
9202 OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISQGTABLE_RSPBUFFER_LEN); /* set response data buffer length */
9203
9204 /* send command */
9205 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
9206 #if defined(ERR_IPV_NETC_051243)
9207 #if (STD_ON == ERR_IPV_NETC_051243)
9208 /* Error code 0x8A is not a real error. check it on Errata. */
9209 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
9210 {
9211 #endif
9212 #else
9213 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
9214 {
9215 #endif
9216 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
9217 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9218
9219 /* found a matched entry */
9220 if (1U == *MatchedEntries)
9221 {
9222 /* fill in "Netc_EthSwt_Ip_ISQGTableDataType" structure with data in response data buffer */
9223 ISQGRspData->ISQGEntryId = TableDataBuffer.TableDataField[0U];
9224
9225 /* fill in CFGE data */
9226 ConfigBits = TableDataBuffer.TableDataField[1U];
9227 ISQGRspData->Cfge_SQTagType = (ConfigBits & NETC_ETHSWT_IP_ISQGTABLE_CFGE_SQTAG_MASK);
9228 ISQGRspData->Sgse_SQGNum = (uint16)((ConfigBits >> NETC_ETHSWT_IP_16BIT_SHIFT) & 0xFFFFU);
9229 }
9230 }
9231
9232 return status;
9233 }
9234
9235 /*FUNCTION**********************************************************************
9236 *
9237 * Function Name : Netc_EthSwt_Ip_DeleteIngressSeqGenerationTableEntry
9238 * implements Netc_EthSwt_Ip_DeleteIngressSeqGenerationTableEntry_Activity
9239 *END**************************************************************************/
9240 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngressSeqGenerationTableEntry( uint8 SwitchIdx,
9241 uint32 *MatchedEntries,
9242 uint32 ISQGEntryId
9243 )
9244 {
9245 Netc_EthSwt_Ip_CBDRStatusType status;
9246 uint32 ActionsData = 0U;
9247 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
9248
9249 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9250 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9251 DevAssert(MatchedEntries != NULL_PTR);
9252 #endif
9253
9254 /* clear the variable MatchedEntries first */
9255 *MatchedEntries = 0U;
9256 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_34();
9257 /* ------initialize the table request data buffer------ */
9258 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
9259 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = ISQGEntryId; /* fill in Entry_ID field (Access Key) */
9260 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_34();
9261
9262 /* fill in operation data for config field of Request Header*/
9263 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9264 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9265 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_SEQ_GENERATION_TABLE_ID;
9266 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
9267 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
9268 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
9269 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN); /* set response data buffer with normal length */
9270
9271 /* send the "Delete" command */
9272 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
9273 #if defined(ERR_IPV_NETC_051243)
9274 #if (STD_ON == ERR_IPV_NETC_051243)
9275 /* Error code 0x8A is not a real error. check it on Errata. */
9276 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
9277 {
9278 #endif
9279 #else
9280 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
9281 {
9282 #endif
9283 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
9284 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9285 }
9286
9287 return status;
9288 }
9289
9290 /*FUNCTION**********************************************************************
9291 *
9292 * Function Name : Netc_EthSwt_Ip_UpdateEgressSeqRecoveryTableEntry
9293 * Description : Ethernet Switch Add or Update Ingress Sequence Generation table entry function.
9294 * implements Netc_EthSwt_Ip_UpdateEgressSeqRecoveryTableEntry_Activity
9295 *END**************************************************************************/
9296 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_UpdateEgressSeqRecoveryTableEntry( uint8 SwitchIdx,
9297 uint32 *MatchedEntries,
9298 const Netc_EthSwt_Ip_EgrSeqRecoveryTableDataType * EgrSQRTableEntry
9299 )
9300 {
9301 Netc_EthSwt_Ip_CBDRStatusType status;
9302 uint32 ActionsData;
9303 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
9304
9305 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9306 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9307 DevAssert(EgrSQRTableEntry != NULL_PTR);
9308 DevAssert(MatchedEntries != NULL_PTR);
9309 #endif
9310
9311 /* clear the variable MatchedEntries first */
9312 *MatchedEntries = 0U;
9313
9314 /* set table version and update actions*/
9315 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U) \
9316 | NETC_ETHSWT_IP_ESQRTABLE_REQFMT_ACTIONS_FIELD_STSEU(1U) \
9317 | NETC_ETHSWT_IP_ESQRTABLE_REQFMT_ACTIONS_FIELD_SRSEU(1U) \
9318 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9319 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_35();
9320 /* ------initialize the table request data buffer------ */
9321 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9322 /* fill in ACCESS_KEY */
9323 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EgrSQRTableEntry->EgrSeqRecEntryId; /* fill in Entry_ID */
9324 /* fill in CFGE_DATA */
9325 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQTAG(EgrSQRTableEntry->Cfge_SQTag) \
9326 | NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTNSQ(EgrSQRTableEntry->Cfge_SqrTnsq) \
9327 | NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRALG(EgrSQRTableEntry->Cfge_SqrAlg) \
9328 | NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTYPE(EgrSQRTableEntry->Cfge_SqrType) \
9329 | NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRHL(EgrSQRTableEntry->Cfge_SQRHisLen) \
9330 | NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRFWL(EgrSQRTableEntry->Cfge_SQRFutureWinLen);
9331 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTP(EgrSQRTableEntry->Cfge_SQRTimeOutPeriod);
9332 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_35();
9333
9334 /* fill in operation data for config field of Request Header*/
9335 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9336 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9337 OperationData.TableId = NETC_ETHSWT_IP_EGRESS_SEQ_RECOVERY_TABLE_ID;
9338 /* for Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
9339 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
9340 OperationData.Cmd = NETC_ETHSWT_UPDATE_CMD;
9341 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_EGRSQRTABLE_REQBUFFER_LEN);
9342 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
9343
9344 /* send command */
9345 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
9346 #if defined(ERR_IPV_NETC_051243)
9347 #if (STD_ON == ERR_IPV_NETC_051243)
9348 /* Error code 0x8A is not a real error. check it on Errata. */
9349 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
9350 {
9351 #endif
9352 #else
9353 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
9354 {
9355 #endif
9356 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
9357 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9358 }
9359
9360 return status;
9361 }
9362
9363 /*FUNCTION**********************************************************************
9364 *
9365 * Function Name : Netc_EthSwt_Ip_QueryEgressSeqRecoveryTableEntry
9366 * Description : Ethernet Switch query Ingress Sequence Generation table entry function.
9367 * implements Netc_EthSwt_Ip_QueryEgressSeqRecoveryTableEntry_Activity
9368 *END**************************************************************************/
9369 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryEgressSeqRecoveryTableEntry( uint8 SwitchIdx,
9370 uint32 *MatchedEntries,
9371 uint32 ESQREntryId,
9372 Netc_EthSwt_Ip_EgrSeqRecoveryTableRspDataType * ESQRRspData
9373 )
9374 {
9375 Netc_EthSwt_Ip_CBDRStatusType status;
9376 uint32 ActionsData;
9377 uint32 ConfigBits;
9378 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
9379 uint8 HisIdx;
9380
9381 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9382 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9383 DevAssert(MatchedEntries != NULL_PTR);
9384 DevAssert(ESQRRspData != NULL_PTR);
9385 #endif
9386
9387 /* clear the variable MatchedEntries first */
9388 *MatchedEntries = 0U;
9389
9390 /* always do the full query. 0x0 = Full query. */
9391 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
9392 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9393
9394 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_36();
9395 /* ------initialize the table request data buffer------ */
9396 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9397 /* fill in ACCESS_KEY field */
9398 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = ESQREntryId;
9399 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_36();
9400
9401 /* fill in operation data for config field of Request Header*/
9402 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9403 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9404 OperationData.TableId = NETC_ETHSWT_IP_EGRESS_SEQ_RECOVERY_TABLE_ID;
9405 /* for query function, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
9406 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
9407 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
9408 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_EGRSQRTABLE_REQBUFFER_LEN); /* set request data buffer length */
9409 OperationData.RspBuffLength = (NETC_ETHSWT_IP_EGRSQRTABLE_RSPBUFFER_LEN); /* set response data buffer length */
9410
9411 /* send command */
9412 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
9413 #if defined(ERR_IPV_NETC_051243)
9414 #if (STD_ON == ERR_IPV_NETC_051243)
9415 /* Error code 0x8A is not a real error. check it on Errata. */
9416 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
9417 {
9418 #endif
9419 #else
9420 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
9421 {
9422 #endif
9423 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
9424 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9425
9426 /* found a matched entry */
9427 if (1U == *MatchedEntries)
9428 {
9429 /* fill in "Netc_EthSwt_Ip_EgrSeqRecoveryTableRspDataType" structure with data in response data buffer */
9430 ESQRRspData->EgrSeqRecEntryId = TableDataBuffer.TableDataField[0U];
9431
9432 /* fill in STSE_DATA */
9433 ESQRRspData->Stse_InOrderPkts = (((uint64)(TableDataBuffer.TableDataField[2U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
9434 ESQRRspData->Stse_InOrderPkts |= (uint64)(TableDataBuffer.TableDataField[1U]);
9435 ESQRRspData->Stse_OutOfOrderPkts = (((uint64)(TableDataBuffer.TableDataField[4U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
9436 ESQRRspData->Stse_OutOfOrderPkts |= (uint64)(TableDataBuffer.TableDataField[3U]);
9437 ESQRRspData->Stse_RoguePkts = (((uint64)(TableDataBuffer.TableDataField[6U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
9438 ESQRRspData->Stse_RoguePkts |= (uint64)(TableDataBuffer.TableDataField[5U]);
9439 ESQRRspData->Stse_DuplicatePkts = (((uint64)(TableDataBuffer.TableDataField[8U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
9440 ESQRRspData->Stse_DuplicatePkts |= (uint64)(TableDataBuffer.TableDataField[7U]);
9441 ESQRRspData->Stse_LostPkts = (((uint64)(TableDataBuffer.TableDataField[10U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
9442 ESQRRspData->Stse_LostPkts |= (uint64)(TableDataBuffer.TableDataField[9U]);
9443 ESQRRspData->Stse_TaglessPkts = (((uint64)(TableDataBuffer.TableDataField[12U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
9444 ESQRRspData->Stse_TaglessPkts |= (uint64)(TableDataBuffer.TableDataField[11U]);
9445 ESQRRspData->Stse_SeqRecResets = TableDataBuffer.TableDataField[13U];
9446
9447 /* fill in CFGE data */
9448 ConfigBits = TableDataBuffer.TableDataField[14U];
9449 ESQRRspData->Cfge_SQTag = (uint8)(ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQTAG_MASK);
9450 ESQRRspData->Cfge_SqrTnsq = (ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTNSQ_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTNSQ_SHIFT;
9451 ESQRRspData->Cfge_SqrAlg = (ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRALG_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRALG_SHIFT;
9452 ESQRRspData->Cfge_SqrType = (ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTYPE_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTYPE_SHIFT;
9453 ESQRRspData->Cfge_SQRHisLen = (uint8)((ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRHL_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRHL_SHIFT);
9454 ESQRRspData->Cfge_SQRFutureWinLen = (uint16)((ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRFWL_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRFWL_SHIFT);
9455 ESQRRspData->Cfge_SQRTimeOutPeriod = (uint16)(TableDataBuffer.TableDataField[15U] & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTP_MASK);
9456
9457 /* fill in SRSE data */
9458 ConfigBits = TableDataBuffer.TableDataField[16U];
9459 ESQRRspData->Srse_SqrNum = (uint16)(ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_SQRNUM_MASK);
9460 ESQRRspData->Srse_TakeAny = (uint8)((ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_TAKEANY_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_TAKEANY_SHIFT);
9461 ESQRRspData->Srse_LostCntEnable = ((ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_LCE_MASK) == 0U) ? FALSE : TRUE;
9462 ESQRRspData->Srse_SqrTimeStamp = (uint16)((ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_SQRTS_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_SQRTS_SHIFT);
9463
9464 for (HisIdx = 0U; HisIdx < 4U; HisIdx++)
9465 {
9466 ESQRRspData->Srse_SqrHistory[HisIdx] = TableDataBuffer.TableDataField[17U + HisIdx];
9467 }
9468 }
9469 }
9470
9471 return status;
9472 }
9473
9474 /*FUNCTION**********************************************************************
9475 *
9476 * Function Name : Netc_EthSwt_Ip_AddOrUpdateIngrStreamIdentificationTableEntry
9477 * Description : Ethernet Switch Add or Update Ingress Stream Identification table entry function.
9478 * implements Netc_EthSwt_Ip_AddOrUpdateIngrStreamIdentificationTableEntry_Activity
9479 *END**************************************************************************/
9480 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateIngrStreamIdentificationTableEntry( uint8 SwitchIdx,
9481 Netc_EthSwt_Ip_CommandsType Cmd,
9482 uint32 *MatchedEntries,
9483 const Netc_EthSwt_Ip_IngrStremIdentificationTableDataType * ISITableEntry
9484 )
9485 {
9486 Netc_EthSwt_Ip_CBDRStatusType status;
9487 uint32 ActionsData;
9488 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
9489 uint8 FrmKeyIdx;
9490
9491 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9492 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9493 DevAssert(ISITableEntry != NULL_PTR);
9494 DevAssert(MatchedEntries != NULL_PTR);
9495 #endif
9496
9497 /* clear the variable MatchedEntries first */
9498 *MatchedEntries = 0U;
9499
9500 /* only support Add and Update commands */
9501 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
9502 {
9503 status = NETC_ETHSWT_CBDRSTATUS_INVALID_CMD; /* not supported command */
9504 }
9505 else
9506 {
9507 /* set table version and update actions*/
9508 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U) \
9509 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9510
9511 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_37();
9512 /* ------initialize the table request data buffer------ */
9513 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9514 /* fill in KEYE_DATA */
9515 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = NETC_ETHSWT_IP_ISITABLE_KEYE_KEYTYPE(ISITableEntry->Keye_Keytype) \
9516 | NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID(ISITableEntry->Keye_SrcPortId) \
9517 | NETC_ETHSWT_IP_ISITABLE_KEYE_SPM(ISITableEntry->Keye_Spm);
9518 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_37();
9519
9520 for (FrmKeyIdx = 0U; FrmKeyIdx < 4U; FrmKeyIdx++)
9521 {
9522 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0 + FrmKeyIdx] = ISITableEntry->Keye_FrmKey[FrmKeyIdx]; /* [Ricky]TODO: need to check the data format, big endian */
9523 }
9524 /* fill in CFGE_DATA */
9525 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = ISITableEntry->IngrStreamEntryId; /* IS_EID */
9526
9527 /* fill in operation data for config field of Request Header*/
9528 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9529 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9530 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_IDEN_TABLE_ID;
9531 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH */
9532 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
9533 OperationData.Cmd = Cmd;
9534 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISITABLE_ADD_REQBUFFER_LEN);
9535 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
9536
9537 /* send command */
9538 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
9539 #if defined(ERR_IPV_NETC_051243)
9540 #if (STD_ON == ERR_IPV_NETC_051243)
9541 /* Error code 0x8A is not a real error. check it on Errata. */
9542 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
9543 {
9544 #endif
9545 #else
9546 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
9547 {
9548 #endif
9549 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
9550 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9551 }
9552 }
9553
9554 return status;
9555 }
9556
9557 /*FUNCTION**********************************************************************
9558 *
9559 * Function Name : Netc_EthSwt_Ip_QueryIngrStreamIdentificationTableEntry
9560 * Description : Ethernet Switch query Ingress Stream Identification table entry function.
9561 * implements Netc_EthSwt_Ip_QueryIngrStreamIdentificationTableEntry_Activity
9562 *END**************************************************************************/
9563 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngrStreamIdentificationTableEntry( uint8 SwitchIdx,
9564 uint32 *MatchedEntries,
9565 Netc_EthSwt_Ip_IngrStremIdentificationTableDataType * ISITableEntry
9566 )
9567 {
9568 Netc_EthSwt_Ip_CBDRStatusType status;
9569 uint32 ActionsData;
9570 uint32 ConfigBits;
9571 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
9572 uint8 FrmKeyIdx;
9573
9574 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9575 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9576 DevAssert(MatchedEntries != NULL_PTR);
9577 DevAssert(ISITableEntry != NULL_PTR);
9578 #endif
9579
9580 /* clear the variable MatchedEntries first */
9581 *MatchedEntries = 0U;
9582
9583 /* always do the full query. 0x0 = Full query. */
9584 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
9585 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9586
9587 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_38();
9588 /* ------initialize the table request data buffer------ */
9589 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9590 /* fill in KEYE_DATA */
9591 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = NETC_ETHSWT_IP_ISITABLE_KEYE_KEYTYPE(ISITableEntry->Keye_Keytype) \
9592 | NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID(ISITableEntry->Keye_SrcPortId) \
9593 | NETC_ETHSWT_IP_ISITABLE_KEYE_SPM(ISITableEntry->Keye_Spm);
9594 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_38();
9595
9596 for (FrmKeyIdx = 0U; FrmKeyIdx < 4U; FrmKeyIdx++)
9597 {
9598 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0 + FrmKeyIdx] = ISITableEntry->Keye_FrmKey[FrmKeyIdx]; /* [Ricky]TODO: need to check the data format, big endian */
9599 }
9600
9601 /* fill in operation data for config field of Request Header*/
9602 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9603 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9604 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_IDEN_TABLE_ID;
9605 /* for query function, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
9606 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
9607 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
9608 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISITABLE_QUERY_REQBUFFER_LEN); /* set request data buffer length */
9609 OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISITABLE_RSQBUFFER_LEN); /* set response data buffer length */
9610
9611 /* send command */
9612 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
9613 #if defined(ERR_IPV_NETC_051243)
9614 #if (STD_ON == ERR_IPV_NETC_051243)
9615 /* Error code 0x8A is not a real error. check it on Errata. */
9616 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
9617 {
9618 #endif
9619 #else
9620 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
9621 {
9622 #endif
9623 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
9624 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9625
9626 /* found a matched entry */
9627 if (1U == *MatchedEntries)
9628 {
9629 /* fill in "Netc_EthSwt_Ip_IngrStremIdentificationTableDataType" structure with data in response data buffer */
9630 ISITableEntry->IngrStreamIdenEntryId = TableDataBuffer.TableDataField[1U];
9631
9632 /* fill in KEYE data */
9633 ConfigBits = TableDataBuffer.TableDataField[2U];
9634 ISITableEntry->Keye_Keytype = (ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_KEYTYPE_MASK);
9635 ISITableEntry->Keye_SrcPortId = (uint8)((ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID_MASK) >> NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID_SHIFT);
9636 ISITableEntry->Keye_Spm = (ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_SPM_MASK) >> NETC_ETHSWT_IP_ISITABLE_KEYE_SPM_SHIFT;
9637
9638 for (FrmKeyIdx = 0U; FrmKeyIdx < 4U; FrmKeyIdx++)
9639 {
9640 ISITableEntry->Keye_FrmKey[FrmKeyIdx] = TableDataBuffer.TableDataField[3U + FrmKeyIdx];
9641 }
9642
9643 /* fill in CFGE data */
9644 ISITableEntry->IngrStreamEntryId = TableDataBuffer.TableDataField[7U];
9645 }
9646 }
9647
9648 return status;
9649 }
9650
9651 /*FUNCTION**********************************************************************
9652 *
9653 * Function Name : Netc_EthSwt_Ip_DeleteIngrStreamIdentificationTableEntry
9654 * Description : Ethernet Switch delete Ingress Stream Identification table entry function.
9655 * implements Netc_EthSwt_Ip_DeleteIngrStreamIdentificationTableEntry_Activity
9656 *END**************************************************************************/
9657 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngrStreamIdentificationTableEntry( uint8 SwitchIdx,
9658 uint32 *MatchedEntries,
9659 const Netc_EthSwt_Ip_IngrStremIdentificationTableDataType * ISITableEntry
9660 )
9661 {
9662 Netc_EthSwt_Ip_CBDRStatusType status;
9663 uint32 ActionsData = 0U;
9664 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
9665 uint8 FrmKeyIdx;
9666
9667 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9668 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9669 DevAssert(MatchedEntries != NULL_PTR);
9670 DevAssert(ISITableEntry != NULL_PTR);
9671 #endif
9672
9673 /* clear the variable MatchedEntries first */
9674 *MatchedEntries = 0U;
9675
9676 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_39();
9677 /* ------initialize the table request data buffer------ */
9678 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9679 /* fill in KEYE_DATA */
9680 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = NETC_ETHSWT_IP_ISITABLE_KEYE_KEYTYPE(ISITableEntry->Keye_Keytype) \
9681 | NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID(ISITableEntry->Keye_SrcPortId) \
9682 | NETC_ETHSWT_IP_ISITABLE_KEYE_SPM(ISITableEntry->Keye_Spm);
9683 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_39();
9684
9685 for (FrmKeyIdx = 0U; FrmKeyIdx < 4U; FrmKeyIdx++)
9686 {
9687 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0 + FrmKeyIdx] = ISITableEntry->Keye_FrmKey[FrmKeyIdx]; /* [Ricky]TODO: need to check the data format, big endian */
9688 }
9689
9690 /* fill in operation data for config field of Request Header*/
9691 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9692 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9693 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_IDEN_TABLE_ID;
9694 /* for query function, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
9695 OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
9696 OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
9697 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISITABLE_QUERY_REQBUFFER_LEN); /* set request data buffer length */
9698 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN); /* set response data buffer length */
9699
9700 /* send command */
9701 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
9702 #if defined(ERR_IPV_NETC_051243)
9703 #if (STD_ON == ERR_IPV_NETC_051243)
9704 /* Error code 0x8A is not a real error. check it on Errata. */
9705 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
9706 {
9707 #endif
9708 #else
9709 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
9710 {
9711 #endif
9712 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
9713 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9714 }
9715
9716 return status;
9717 }
9718
9719 /*FUNCTION**********************************************************************
9720 *
9721 * Function Name : Netc_EthSwt_Ip_SearchAndFillIngrStreamIdentificationTable
9722 * Description : inline function for searching and filling Ingress Stream Filter table entries.
9723 *END**************************************************************************/
9724 static inline Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_SearchAndFillIngrStreamIdentificationTable( uint8 SwitchIdx,
9725 uint32 * ResumeEntryId,
9726 uint16 * NumOfExistingEntry,
9727 Netc_EthSwt_Ip_IngrStremIdentificationTableDataType * ISITableEntry
9728 )
9729 {
9730 Netc_EthSwt_Ip_CBDRStatusType status;
9731 uint32 ActionsData;
9732 uint32 ConfigBits;
9733 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
9734 uint32 MatchedEntries = 0x0UL;
9735 uint8 FrmKeyIdx;
9736 uint8 TableMemIdx;
9737
9738 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9739 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9740 DevAssert(ResumeEntryId != NULL_PTR);
9741 DevAssert(ISITableEntry != NULL_PTR);
9742 #endif
9743
9744 /* always do the full query. 0x0 = Full query. */
9745 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
9746 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9747
9748 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_40();
9749 /* ------initialize the table request data buffer------ */
9750 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9751 /* fill in KEYE_DATA field */
9752 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = *ResumeEntryId;
9753 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_40();
9754
9755 /* clear the memory for searching, otherwise will get 0x89 error code */
9756 for (TableMemIdx = 0U; TableMemIdx < 6U; TableMemIdx++)
9757 {
9758 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0 + TableMemIdx] = 0U;
9759 }
9760
9761 /* fill in operation data for config field of Request Header*/
9762 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9763 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9764 OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_IDEN_TABLE_ID;
9765 /* query function with NETC_ETHSWT_SEARCH_METHOD method */
9766 OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
9767 OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
9768 OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISITABLE_QUERY_REQBUFFER_LEN); /* set request data buffer length */
9769 OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISITABLE_RSQBUFFER_LEN); /* set response data buffer length */
9770
9771 /* send command */
9772 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
9773 #if defined(ERR_IPV_NETC_051243)
9774 #if (STD_ON == ERR_IPV_NETC_051243)
9775 /* Error code 0x8A is not a real error. check it on Errata. */
9776 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
9777 {
9778 #endif
9779 #else
9780 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
9781 {
9782 #endif
9783 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
9784 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &MatchedEntries);
9785
9786 /* get the resume_entry_id and be ready for the next query operation */
9787 *ResumeEntryId = TableDataBuffer.TableDataField[0U];
9788
9789 /* ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED */
9790 /* found a matched entry */
9791 if ((1U == MatchedEntries) && (*ResumeEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
9792 {
9793 /* fill in "Netc_EthSwt_Ip_IngrStremIdentificationTableDataType" structure with data in response data buffer */
9794 ISITableEntry[*NumOfExistingEntry].IngrStreamIdenEntryId = TableDataBuffer.TableDataField[1U];
9795
9796 /* fill in KEYE data */
9797 ConfigBits = TableDataBuffer.TableDataField[2U];
9798 ISITableEntry[*NumOfExistingEntry].Keye_Keytype = (ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_KEYTYPE_MASK);
9799 ISITableEntry[*NumOfExistingEntry].Keye_SrcPortId = (uint8)((ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID_MASK) >> NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID_SHIFT);
9800 ISITableEntry[*NumOfExistingEntry].Keye_Spm = (ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_SPM_MASK) >> NETC_ETHSWT_IP_ISITABLE_KEYE_SPM_SHIFT;
9801
9802 for (FrmKeyIdx = 0U; FrmKeyIdx < 4U; FrmKeyIdx++)
9803 {
9804 ISITableEntry[*NumOfExistingEntry].Keye_FrmKey[FrmKeyIdx] = TableDataBuffer.TableDataField[3U + FrmKeyIdx];
9805 }
9806
9807 /* fill in CFGE data */
9808 ISITableEntry[*NumOfExistingEntry].IngrStreamEntryId = TableDataBuffer.TableDataField[7U];
9809
9810 /* increase the NumOfExistingEntry */
9811 (*NumOfExistingEntry) += 1U;
9812 }
9813 }
9814
9815 return status;
9816 }
9817
9818 /*FUNCTION**********************************************************************
9819 *
9820 * Function Name : Netc_EthSwt_Ip_GetIngrStreamIdentificationTable
9821 * Description : Ethernet Switch get ingress stream filter table function.
9822 * implements Netc_EthSwt_Ip_GetIngrStreamIdentificationTable_Activity
9823 *END**************************************************************************/
9824 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_GetIngrStreamIdentificationTable( uint8 SwitchIdx,
9825 uint16 * NumberOfElements,
9826 Netc_EthSwt_Ip_IngrStremIdentificationTableDataType * ISITableList
9827 )
9828 {
9829 Netc_EthSwt_Ip_CBDRStatusType status = E_OK;
9830 uint16 NumOfExistingEntry = 0U;
9831 uint32 ResumeId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
9832
9833 /* [notes]: we will have to read entries one by one because of the errata ERR051048.
9834 - ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED
9835 - Description: The NUM_MATCHED field in the command NTMP response header may be incorrect when
9836 the search access method is used for the following tables: FDB table 15, L2 IPv4 Multicast
9837 Filter table 16, VLAN Filter table 18, Ingress Stream Identification table 30, or Ingress Stream
9838 Filter table 32.
9839 - Workaround: For the query command, limit the message response buffer size (RESPONSE_LENGTH field in the request header)
9840 so that NETC returns no more than one entry at a time. Under this condition, the NUM_MATCHED field value is correct
9841 */
9842
9843 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9844 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9845 DevAssert(NumberOfElements != NULL_PTR);
9846 DevAssert(*NumberOfElements != 0U);
9847 DevAssert(ISITableList != NULL_PTR);
9848 #endif
9849
9850 do
9851 {
9852 /* check if the ISITableList is full or we get all existing entries */
9853 if ((NumOfExistingEntry >= *NumberOfElements) || (status == (uint8)(E_NOT_OK)))
9854 {
9855 break;
9856 }
9857
9858 status = Netc_EthSwt_Ip_SearchAndFillIngrStreamIdentificationTable(SwitchIdx, &ResumeId, &NumOfExistingEntry, ISITableList);
9859
9860 } while (ResumeId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID); /* ResumeId == NETC_ETHSWT_IP_BD_NULL_ENTRY_ID means the query operation is completed */
9861
9862 /* return the Number of elements which are currently available in the EthSwitch module or number of elements copied to ISITableList*/
9863 *NumberOfElements = NumOfExistingEntry;
9864
9865 return status;
9866 }
9867
9868 /*FUNCTION**********************************************************************
9869 *
9870 * Function Name : Netc_EthSwt_Ip_UpdateEgressSchedulerTableEntry
9871 * Description : Ethernet Switch Update Egress Class Scheduler table entry function.
9872 * implements Netc_EthSwt_Ip_UpdateEgressSchedulerTableEntry_Activity
9873 *END**************************************************************************/
9874 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_UpdateEgressSchedulerTableEntry( uint8 SwitchIdx,
9875 uint32 EntryId,
9876 uint32 *MatchedEntries,
9877 const Netc_EthSwt_Ip_PortSchedulerType * SchedulerTableEntry
9878 )
9879 {
9880 Netc_EthSwt_Ip_CBDRStatusType status;
9881 uint32 ActionsData;
9882 NetcEthSwt_Ip_ReqHeaderTableOperationDataType OperationData = {0U};
9883
9884 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9885 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9886 DevAssert(SchedulerTableEntry != NULL_PTR);
9887 DevAssert(MatchedEntries != NULL_PTR);
9888 DevAssert((EntryId > 0U) && (EntryId < NETC_ETHSWT_NUMBER_OF_PORTS));
9889 #endif
9890
9891 /* clear the variable MatchedEntries first */
9892 *MatchedEntries = 0U;
9893
9894 /* set table version*/
9895 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9896 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_41();
9897
9898 /* ------initialize the table request data buffer------ */
9899 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9900
9901 /* fill in Access Key field, only support Entry ID Match method */
9902 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EntryId;
9903
9904 /* fill in CFGE_DATA */
9905 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = NETC_ETHSWT_IP_SCHTABLE_CFGE_DATA_CQ_ASSG(SchedulerTableEntry->numberOfWBFSQueues) \
9906 | NETC_ETHSWT_IP_SCHTABLE_CFGE_DATA_OAL(SchedulerTableEntry->overheadAccountingLength);
9907
9908 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_0(SchedulerTableEntry->portEgressSchedulerWeightList[0U]) \
9909 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_1(SchedulerTableEntry->portEgressSchedulerWeightList[1U]) \
9910 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_2(SchedulerTableEntry->portEgressSchedulerWeightList[2U]) \
9911 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_3(SchedulerTableEntry->portEgressSchedulerWeightList[3U]);
9912
9913 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_4(SchedulerTableEntry->portEgressSchedulerWeightList[4U]) \
9914 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_5(SchedulerTableEntry->portEgressSchedulerWeightList[5U]) \
9915 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_6(SchedulerTableEntry->portEgressSchedulerWeightList[6U]) \
9916 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_7(SchedulerTableEntry->portEgressSchedulerWeightList[7U]);
9917 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_41();
9918
9919 /* fill in operation data for config field of Request Header*/
9920 OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9921 OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9922 OperationData.TableId = NETC_ETHSWT_IP_CLASS_SCHEDULER_TABLE_ID;
9923 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
9924 OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
9925 OperationData.Cmd = NETC_ETHSWT_UPDATE_CMD;
9926
9927 /* the request and response data buffer length are variable based on the length of control list*/
9928 OperationData.ReqBuffLength = NETC_ETHSWT_IP_EGRSCHTABLE_REQBUFFER_LEN ;
9929 OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
9930
9931 /* send command */
9932 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &OperationData);
9933 #if defined(ERR_IPV_NETC_051243)
9934 #if (STD_ON == ERR_IPV_NETC_051243)
9935 /* Error code 0x8A is not a real error. check it on Errata. */
9936 if ((status == 0x8AU) || (status == NETC_ETHSWT_CBDRSTATUS_SUCCES))
9937 {
9938 #endif
9939 #else
9940 if (status == NETC_ETHSWT_CBDRSTATUS_SUCCES)
9941 {
9942 #endif
9943 status = NETC_ETHSWT_CBDRSTATUS_SUCCES;
9944 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9945 }
9946
9947 return status;
9948 }
9949
9950 /*FUNCTION**********************************************************************
9951 *
9952 * Function Name : Netc_EthSwt_Ip_SetSyncState
9953 * Description : Function to set the Timers Synchronization state
9954 * implements Netc_EthSwt_Ip_SetSyncState_Activity
9955 *END**************************************************************************/
9956 Std_ReturnType Netc_EthSwt_Ip_SetSyncState(uint8 SwitchIdx, boolean SyncState)
9957 {
9958 Std_ReturnType status = E_OK;
9959
9960 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9961 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9962 #else
9963 (void)SwitchIdx; /*Cast to void because there might be cases when NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_OFF and SwitchIdx will be unused */
9964 #endif
9965 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_09();
9966 IP_NETC__TMR0_BASE->TMR_PARAM |= SyncState ? 1U : 0U;
9967 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_09();
9968
9969 return status;
9970 }
9971 #define ETHSWT_43_NETC_STOP_SEC_CODE
9972 #include "EthSwt_43_NETC_MemMap.h"
9973
9974 #ifdef __cplusplus
9975 }
9976 #endif
9977
9978 /** @} */
9979