1 /*
2 * Copyright 2021-2024 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 2
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 typedef enum
97 {
98 NETC_ETHSWT_IP_FDB_STATIC_ENTRY_QUERY_SEARCH,
99 NETC_ETHSWT_IP_FDB_DYNAMIC_ENTRY_QUERY_SEARCH,
100 NETC_ETHSWT_IP_FDB_DONE_ENTRY_QUERY_SEARCH
101 }Netc_EthSwt_Ip_FdbEntryQuerying;
102
103
104 typedef struct
105 {
106 boolean SrcMacAddrFilterEnabled;
107 boolean DstMacAddrFilterEnabled;
108 }Netc_EthSwt_Ip_IngressPortFilterSrcDestAddrFilter;
109
110 typedef struct
111 {
112 boolean MatchedEntryFound;
113 uint32 PortBitMap;
114 const uint8 * MacAddr;
115 }Netc_EthSwt_Ip_PortMacAddrEntry;
116
117 typedef struct
118 {
119 uint32 ResumeEntryId;
120 uint32 EntryId;
121 }Netc_EthSwt_Ip_ResumeEntryEntryId;
122
123
124 typedef struct
125 {
126 uint8 SwitchIdx;
127 uint8 SwitchPortIdx;
128 }Netc_EthSwt_Ip_SwitchIdxSwitchPort;
129
130
131 /*==================================================================================================
132 * LOCAL MACROS
133 ==================================================================================================*/
134 #define SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_MII_MODE (1U)
135 #define SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RMII_MODE (3U)
136 #define SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RGMII_MODE (4U)
137 #define SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_SGMII_MODE (5U)
138 #define SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT (0U)
139 #define SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT (1U)
140 #define SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT (2U)
141 #define SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_2500MBIT (3U)
142
143 /*==================================================================================================
144 * LOCAL CONSTANTS
145 ==================================================================================================*/
146 #define NETC_ETHSWT_IP_FIELD_REP_IN_4BITS (4U)
147 #define NETC_ETHSWT_IP_FIELD_REP_IN_TOP_OF_32BITS (16U)
148
149 #define NETC_ETHSWT_IP_RXTAGA_ACCEPT_UNTAGGED (1U)
150 #define NETC_ETHSWT_IP_RXTAGA_ACCEPT_PRIO_TAGGED (2U)
151 #define NETC_ETHSWT_IP_RXTAGA_ACCEPT_SINGLE_TAGGED (4U)
152 #define NETC_ETHSWT_IP_RXTAGA_ACCEPT_DOUBLE_TAGGED (8U)
153
154 /* Formula for speed: 10Mbps * (PSPEED+1) */
155 #define NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS (0U)
156 #define NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS (9U)
157 #define NETC_ETHSWT_IP_SHAPING_PSPEED_1000MBITS (99U)
158 #define NETC_ETHSWT_IP_SHAPING_PSPEED_2000MBITS (199U)
159 #define NETC_ETHSWT_IP_SHAPING_PSPEED_2500MBITS (249U)
160
161 #define NETC_ETHSWT_IP_NUM_SHAPING_CLASS (8U)
162
163 #define NETC_ETHSWT_IP_NUM_AGING_CYCLE (127U)
164 #define NETC_ETHSWT_IP_NUM_AGING_CYCLE_FLOAT (127.0F)
165
166 #define NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID (0xFFFFU)
167
168 #define NETC_ETHSWT_IP_ONE_FLOAT (1.0F)
169
170 #define MAX_32BIT ((uint32)0xFFFFFFFFUL)
171
172 /*==================================================================================================
173 * LOCAL VARIABLES
174 ==================================================================================================*/
175
176 /*==================================================================================================
177 * GLOBAL CONSTANTS
178 ==================================================================================================*/
179
180 /*==================================================================================================
181 * GLOBAL VARIABLES
182 ==================================================================================================*/
183 #define ETHSWT_43_NETC_START_SEC_VAR_INIT_BOOLEAN
184 #include "EthSwt_43_NETC_MemMap.h"
185
186 /* Flag to determine if mirroring is active or not */
187 static boolean MirrorConfigurationDone = FALSE;
188 /* Flag to determine if there is any VLAN configuration or the default entry will be used */
189 static boolean Netc_EthSwt_Ip_PortVlanEnable[NETC_ETHSWT_IP_NUMBER_OF_PORTS] = {(boolean)FALSE, (boolean)FALSE, (boolean)FALSE};
190
191 #if defined(ERR_IPV_NETC_051587)
192 #if (STD_ON == ERR_IPV_NETC_051587)
193 static boolean Netc_EthSwt_Ip_TGSAdminListRegistered[NETC_ETHSWT_IP_NUMBER_OF_PORTS];
194 #endif
195 #endif
196
197 #define ETHSWT_43_NETC_STOP_SEC_VAR_INIT_BOOLEAN
198 #include "EthSwt_43_NETC_MemMap.h"
199
200 #define ETHSWT_43_NETC_START_SEC_VAR_CLEARED_BOOLEAN
201 #include "EthSwt_43_NETC_MemMap.h"
202
203 /* Enabled status for Time Aware Shaper of each port */
204 static boolean PortTimeAwareShaperEnabled[NETC_ETHSWT_IP_NUMBER_OF_PORTS];
205
206 #define ETHSWT_43_NETC_STOP_SEC_VAR_CLEARED_BOOLEAN
207 #include "EthSwt_43_NETC_MemMap.h"
208
209 #define ETHSWT_43_NETC_START_SEC_VAR_INIT_UNSPECIFIED
210 #include "EthSwt_43_NETC_MemMap.h"
211
212 /* Base address of the registers for the MAC Ports */
213 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 };
214
215 /* Base address of the registers for the pseudo Port */
216 Netc_EthSwt_Ip_PseudoPortBaseType* Netc_EthSwt_Ip_PseudoPortBaseTable[] = { IP_NETC__SW0_PSEUDO_MAC_PORT2 };
217 SW_PORT0_Type *Netc_EthSwt_Ip_SW0_PortxBaseAddr[NETC_ETHSWT_IP_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};
218 #define ETHSWT_43_NETC_STOP_SEC_VAR_INIT_UNSPECIFIED
219 #include "EthSwt_43_NETC_MemMap.h"
220
221 #define ETHSWT_43_NETC_START_SEC_VAR_CLEARED_UNSPECIFIED
222 #include "EthSwt_43_NETC_MemMap.h"
223
224 /* Table entries for Time Aware Shaping configuration of each Port */
225 static Netc_EthSwt_Ip_TimeGateSchedulingEntryDataType TimeGateSchedulingEntryData[NETC_ETHSWT_IP_NUMBER_OF_PORTS];
226
227 #define ETHSWT_43_NETC_STOP_SEC_VAR_CLEARED_UNSPECIFIED
228 #include "EthSwt_43_NETC_MemMap.h"
229
230 #define ETHSWT_43_NETC_START_SEC_VAR_INIT_32
231 #include "EthSwt_43_NETC_MemMap.h"
232
233 /* reference clock for 1588 timer. 0x0UL means the 1588 timer is not enabled. */
234 static uint32 TimerOriginalRefClk = 0x0UL;
235 /* reference clcok for clock correction and set ratio */
236 static uint32 TimerRefClk = 0x0UL;
237
238 /* Ingress Port Filter Entry ID for mirroing */
239 uint32 MirroringIngressPortFilterEntryId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
240
241 /* Steps used to skip cycles that will not incress the FDB aging counters. */
242 static uint32 Netc_EthSwt_Ip_MainFunctionCycle[FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS] = {0UL};
243
244 #define ETHSWT_43_NETC_STOP_SEC_VAR_INIT_32
245 #include "EthSwt_43_NETC_MemMap.h"
246
247 #define ETHSWT_43_NETC_START_SEC_VAR_CLEARED_32
248 #include "EthSwt_43_NETC_MemMap.h"
249
250 /* The frequency of the NETC module for computing CBS parameters */
251 static uint32 Netc_EthSwt_Ip_NetcClockFrequency;
252
253 #define ETHSWT_43_NETC_STOP_SEC_VAR_CLEARED_32
254 #include "EthSwt_43_NETC_MemMap.h"
255
256 #define ETHSWT_43_NETC_START_SEC_VAR_CLEARED_16
257 #include "EthSwt_43_NETC_MemMap.h"
258
259 /* The timeout set for FDB aging */
260 static uint16 Netc_EthSwt_Ip_FdbTableEntryTimeout[FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS];
261
262 #define ETHSWT_43_NETC_STOP_SEC_VAR_CLEARED_16
263 #include "EthSwt_43_NETC_MemMap.h"
264
265 #define ETHSWT_43_NETC_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
266 #include "EthSwt_43_NETC_MemMap.h"
267
268 /* A shadow buffer for the mirroring configuration to be used when the application is reading the active configuration */
269 VAR_SEC_NOCACHE(MirrorCfgBackup) static Netc_EthSwt_Ip_SwitchMirrorCfgType MirrorCfgBackup;
270
271 /* Structure used for filling in the actual command buffer descriptor used in table operations */
272 VAR_SEC_NOCACHE(CmdBDRConfig) static volatile Netc_EthSwt_Ip_CmdBDType CmdBDRConfig[NETC_ETHSWT_IP_CBDR_NUM];
273
274 /* Key element data for ingress port filter table */
275 VAR_SEC_NOCACHE(Netc_EthSwt_Ip_IPFKeyeData) static volatile uint32 Netc_EthSwt_Ip_IPFKeyeData[NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_KEYE_DATA_LEN];
276
277 /* a 128 bytes aligned command ring descriptor buffer */
278 VAR_SEC_NOCACHE(SwtcommandRingDescriptor0) VAR_ALIGN(static Netc_EthSwt_Ip_NTMPMessageHeaderFormatType SwtcommandRingDescriptor0[NETC_ETHSWT_IP_ACTUAL_CBDR0_LENGTH], NETC_ETHSWT_IP_CBD_ALIGNED_SIZE)
279
280 /* a 16 bytes aligned FDB table request data buffer */
281 VAR_SEC_NOCACHE(TableDataBuffer) VAR_ALIGN(static volatile Netc_EthSwt_Ip_SwitchTableDataType TableDataBuffer, NETC_ETHSWT_IP_TABLE_ALIGNED_SIZE)
282
283 /* a 16 bytes aligned request header table data buffer */
284 VAR_SEC_NOCACHE(Netc_EthSwt_Ip_OperationData) VAR_ALIGN(static Netc_EthSwt_Ip_ReqHeaderTableOperationDataType Netc_EthSwt_Ip_OperationData, NETC_ETHSWT_IP_TABLE_ALIGNED_SIZE)
285
286 /* Local copy of the pointer to the configuration data. */
287 VAR_SEC_NOCACHE(Netc_EthSwt_Ip_ConfigPtr) static const Netc_EthSwt_Ip_ConfigType * Netc_EthSwt_Ip_ConfigPtr[FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS];
288
289 #define ETHSWT_43_NETC_STOP_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE
290 #include "EthSwt_43_NETC_MemMap.h"
291
292
293 /*==================================================================================================
294 * LOCAL FUNCTION PROTOTYPES
295 ==================================================================================================*/
296 #define ETHSWT_43_NETC_START_SEC_CODE
297 #include "EthSwt_43_NETC_MemMap.h"
298
299 /*!
300 * @brief : Function for accessing 64 bits counters.
301 * @details : Function for extracting the counter value using base/offset
302 *
303 * @param[in] baseAddressValue base address in uint32
304 * @param[in] offsetAddressValue offset from the base
305 *
306 * @return Register value
307 */
308 static inline uint64 Netc_EthSwt_Ip_Extract64bitsFrom32bitsReg(const uint32 baseAddressValue, const uint32 offsetAddressValue);
309
310 /**
311 * @brief : Function for accessing counter in a table.
312 * @details : Function for getting the counters using an offset
313 *
314 * @param[in] base: Base address of the table.
315 * @param[in] offset: Offset the table.
316 *
317 * @return Result the counter value
318 */
319 static inline uint64 Netc_EthSwt_Ip_ComputedRegisterValueExtractionSingleCounter(const Netc_EthSwt_Ip_PortBaseType* base, const Netc_EthSwt_Ip_SingleCounterType offset);
320
321 /**
322 * @brief : Function for accessing counter in a table.
323 * @details : Function for getting the counters using an offset
324 *
325 * @param[in] base: Base address of the table.
326 * @param[in] offset: Offset the table.
327 *
328 * @return Result the counter value
329 */
330 static inline uint64 Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(const Netc_EthSwt_Ip_PseudoPortBaseType* base, const Netc_EthSwt_Ip_PseudoPortCounterType offset);
331
332 /**
333 * @brief : Function for accessing 64 bits counters in a table.
334 * @details : Function for getting the 64 bits counters using two 32 bits accesses.
335 *
336 * @param[in] reg: 64bits register pointer.
337 *
338 * @return Result the counter value
339 */
340 static inline uint64 Netc_EthSwt_Ip_GetCounterLocal(const volatile uint64 *Reg);
341
342 /**
343 * @brief Command BD Rings initialization function
344 * @details Initialize command ring for switch
345 *
346 * @param[in] cbdrIndex: Index of switch command BD rings. There are only two switch command BD rings.
347 *
348 * @return Result of the operation
349 * @retval 0 : NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS, success
350 * @retval 1 : NETC_ETHSWT_IP_CBDRSTATUS_INDEX_ERROR, fail
351 */
352 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_InitCommandBDR(uint8 SwitchIdx, uint8 cbdrIndex);
353
354 /**
355 * @brief Command request function
356 * @details Add one entry with different commands to command ring
357 *
358 * @param[in] cbdrIndex: Index of switch command BD rings
359 * OperationData: a pointer points to a structure with elements table id, access method, and cmd
360 *
361 * @return Result of the operation
362 * @retval 0 : NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS, success
363 * @retval 2 : NETC_ETHSWT_IP_CBDRSTATUS_RINGFULL, fail
364 */
365 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_SendCommand(uint8 SwitchIdx, uint8 cbdrIndex, const Netc_EthSwt_Ip_ReqHeaderTableOperationDataType *OperationData);
366
367 /**
368 * @brief Get Matched table entries function
369 * @details Check how many table entry exist
370 *
371 * @param[in] cbdrIndex: Index of switch command BD rings
372 *
373 * @param[out] NumOfEntry: Number of matched entry found
374 *
375 * @return Result of the operation
376 * @retval 0 : NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS, success
377 * @retval others: fail
378 */
379 static void Netc_EthSwt_Ip_GetMatchedEntries(uint8 cbdrIndex, uint32 *NumOfEntry);
380
381 /**
382 * @brief FDB table initialization function
383 * @details Fill in the FDB table request data buffer
384 *
385 * @param[in] ActionsData: The data of Action Field of FDB table request data buffer
386 * pAccessKey: A pointer points the data of Access Key field of FDB table request data buffer
387 * pCfgeData: A pointer points the data of Cfge field of FDB table request data buffer
388 * accessMethod: The value of ACCESS_METHOD. it determins the content of the Access Key field
389 *
390 * @return Result of the operation
391 * @retval 0 : NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS, success
392 * @retval 6 : NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR, fail
393 */
394 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);
395
396 /**
397 * @brief Vlan Filter table initialization function
398 * @details Fill in the Vlan Filter table request data buffer
399 *
400 * @param[in] ActionsData: The data of Action Field of Vlan Filter table request data buffer
401 * 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.
402 * pCfgeData: A pointer points the data of Cfge field of Vlan Filter table request data buffer
403 * accessMethod: The value of ACCESS_METHOD. it determins the content of the Access Key field
404 *
405 * @return Result of the operation
406 * @retval 0 : NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS, success
407 * @retval 6 : NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR, fail
408 */
409 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff(uint32 ActionsData, uint32 AccessKeyData, const Netc_EthSwt_Ip_VlanFilterTableCFGEDataType *pCfgeData, Netc_EthSwt_Ip_AccessMethodType accessMethod);
410
411 static inline void Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable_FoundAMatchedEntry(uint32 * const EntryId, uint32 * const agingCount, boolean * const FoundEntry, const uint32 NumOfElement);
412
413 static inline void Netc_EthSwt_Ip_QueryFdbTableEntry_FoundAMatchedEntry(const uint32 MatchedEntries, Netc_EthSwt_Ip_FdbEntryDataType * FdbTableEntry);
414
415 static inline void Netc_EthSwt_Ip_WriteMirrorConfiguration_EnablePortMirror(const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr);
416
417 static Std_ReturnType Netc_EthSwt_Ip_MacPortConfig( Netc_EthSwt_Ip_SwitchIdxSwitchPort SwitchIdxSwitchPort,
418 Netc_EthSwt_Ip_XmiiModeType EthSwtPortPhysicalLayerType,
419 EthTrcv_BaudRateType EthSwtPortMacLayerSpeed,
420 Netc_EthSwt_Ip_PortDuplexType EthSwtPortMacLayerDuplexMode
421 );
422
423 static inline Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_GetPortMacAddr_SecondPart(uint8 SwitchIdx,
424 uint32* const NumOfMatchedElement,
425 Netc_EthSwt_Ip_FdbEntryDataType* const FdbTableEntry,
426 Netc_EthSwt_Ip_PortMacAddrEntry* const PortMacAddrEntry);
427
428
429
430 static inline Std_ReturnType Netc_EthSwt_Ip_ConfigIngressPortFilterForPortMirroring(const uint8 MirroredSwitchIdx, const Netc_EthSwt_Ip_IngressPortFilterSrcDestAddrFilter IngressPortFilterSrcDestAddrFilter,
431 const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr,
432 Netc_EthSwt_Ip_IngressPortFilterEntryDataType *IngressPortFilterTableEntry
433 );
434
435 static inline Std_ReturnType Netc_EthSwt_Ip_ConfigEgressFrameModificationForPortMirroring(uint8 MirroredSwitchIdx, const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr);
436
437
438 static inline void Netc_EthSwt_Ip_CheckMacAddressFilterEnableFlag(Netc_EthSwt_Ip_IngressPortFilterSrcDestAddrFilter* const IngressPortFilterSrcDestAddrFilter, const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr);
439 /**
440 * @brief Prepare to use a timeout.
441 *
442 * @param StartTimeOut Current value of selected counter.
443 * @param ElapsedTimeOut Reset elapsed time to 0.
444 * @param TimeoutTicksOut TimeoutUs converted from microsecond units to ticks units.
445 * @param TimeoutUs Timeout value in microsecond.
446 */
447 static inline void Netc_EthSwt_Ip_StartTimeOut( uint32 *StartTimeOut,
448 uint32 *ElapsedTimeOut,
449 uint32 *TimeoutTicksOut,
450 uint32 TimeoutUs
451 );
452
453 /**
454 * @brief Checks for timeout expiration condition.
455 *
456 * @param StartTimeInOut Initial value of the counter.
457 * @param ElapsedTimeInOut Current ticks passed.
458 * @param TimeoutTicks Number of ticks after timout will be activated.
459 *
460 * @return boolean TRUE - timout activated.
461 * FALSE - timeout is not yet reached.
462 */
463 static inline boolean Netc_EthSwt_Ip_TimeoutExpired( uint32 *StartTimeInOut,
464 uint32 *ElapsedTimeInOut,
465 uint32 TimeoutTicks
466 );
467
468 #if (NETC_ETHSWT_NUMBER_OF_FDB_ENTRIES > 0U)
469 /**
470 * @brief FDB table configuration function
471 *
472 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
473 *
474 * @return Result of the operation
475 * @retval 0 : E_OK, success
476 * @retval 1 : E_NOT_OK, fail
477 */
478 static Std_ReturnType Netc_EthSwt_Ip_ConfigFDBTable(const Netc_EthSwt_Ip_ConfigType * Config);
479 #endif
480
481 #if (NETC_ETHSWT_NUMBER_OF_IPFT_ENTRIES > 0U)
482 /**
483 * @brief IPF table configuration function
484 *
485 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
486 *
487 * @return Result of the operation
488 * @retval 0 : E_OK, success
489 * @retval 1 : E_NOT_OK, fail
490 */
491 static Std_ReturnType Netc_EthSwt_Ip_ConfigIPFTable(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config);
492 #endif
493
494 #if (NETC_ETHSWT_NUMBER_OF_STREAMIDENTIFICATION_ENTRIES > 0U)
495 /**
496 * @brief IngressStreamIdentification table configuration function
497 *
498 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
499 *
500 * @return Result of the operation
501 * @retval 0 : E_OK, success
502 * @retval 1 : E_NOT_OK, fail
503 */
504 static Std_ReturnType Netc_EthSwt_Ip_ConfigISITable(const Netc_EthSwt_Ip_ConfigType * Config);
505 #endif
506
507 #if (NETC_ETHSWT_NUMBER_OF_SEQTAG_ENTRIES > 0U)
508 /**
509 * @brief IngressSequenceGeneration table configuration function
510 *
511 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
512 *
513 * @return Result of the operation
514 * @retval 0 : E_OK, success
515 * @retval 1 : E_NOT_OK, fail
516 */
517 static Std_ReturnType Netc_EthSwt_Ip_ConfigSeqGenTable(const Netc_EthSwt_Ip_ConfigType * Config);
518 #endif
519
520 #if (NETC_ETHSWT_NUMBER_OF_SEQRECOVERY_ENTRIES > 0U)
521 /**
522 * @brief EgressSequenceRecovery table configuration function
523 *
524 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
525 *
526 * @return Result of the operation
527 * @retval 0 : E_OK, success
528 * @retval 1 : E_NOT_OK, fail
529 */
530 static Std_ReturnType Netc_EthSwt_Ip_ConfigSeqRecTable(const Netc_EthSwt_Ip_ConfigType * Config);
531 #endif
532
533 #if (NETC_ETHSWT_NUMBER_OF_FRAMEMODIFICATION_ENTRIES > 0U)
534 /**
535 * @brief FrameModification table configuration function
536 *
537 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
538 *
539 * @return Result of the operation
540 * @retval 0 : E_OK, success
541 * @retval 1 : E_NOT_OK, fail
542 */
543 static Std_ReturnType Netc_EthSwt_Ip_ConfigFrmModificationTable(const Netc_EthSwt_Ip_ConfigType * Config);
544 #endif
545
546 #if (NETC_ETHSWT_NUMBER_OF_EGRESSTREATMENT_ENTRIES > 0U)
547 /**
548 * @brief EgressTreatment table configuration function
549 *
550 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
551 *
552 * @return Result of the operation
553 * @retval 0 : E_OK, success
554 * @retval 1 : E_NOT_OK, fail
555 */
556 static Std_ReturnType Netc_EthSwt_Ip_ConfigEgressTreatmentTable(const Netc_EthSwt_Ip_ConfigType * Config);
557 #endif
558
559 #if (NETC_ETHSWT_NUMBER_OF_INGRESSSTREAM_ENTRIES > 0U)
560 /**
561 * @brief IngressStream table configuration function
562 *
563 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
564 *
565 * @return Result of the operation
566 * @retval 0 : E_OK, success
567 * @retval 1 : E_NOT_OK, fail
568 */
569 static Std_ReturnType Netc_EthSwt_Ip_ConfigIngressStreamTable(const Netc_EthSwt_Ip_ConfigType * Config);
570 #endif
571
572 #if (NETC_ETHSWT_NUMBER_OF_STREAMFILTER_ENTRIES > 0U)
573 /**
574 * @brief Ingress Stream Filter table configuration function
575 *
576 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
577 *
578 * @return Result of the operation
579 * @retval 0 : E_OK, success
580 * @retval 1 : E_NOT_OK, fail
581 */
582 static Std_ReturnType Netc_EthSwt_Ip_ConfigIngressStreamFilterTable(const Netc_EthSwt_Ip_ConfigType * Config);
583 #endif
584
585 #if (NETC_ETHSWT_NUMBER_OF_STREAMCOUNT_ENTRIES > 0U)
586 /**
587 * @brief IngressStreamCount table configuration function
588 *
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_ConfigIngressStreamCountTable(const Netc_EthSwt_Ip_ConfigType * Config);
596 #endif
597
598 #if (NETC_ETHSWT_NUMBER_OF_VLANFILTER_ENTRIES > 0U)
599 /**
600 * @brief VLAN filter table configuration function
601 *
602 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
603 *
604 * @return Result of the operation
605 * @retval 0 : E_OK, success
606 * @retval 1 : E_NOT_OK, fail
607 */
608 static Std_ReturnType Netc_EthSwt_Ip_ConfigVLANFilterTable(const Netc_EthSwt_Ip_ConfigType * Config);
609 #endif
610
611 /**
612 * @brief Time aware shaper configuration function
613 *
614 * @param[in] SwitchIdx: Switch ID
615 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
616 *
617 * @return Result of the operation
618 * @retval 0 : E_OK, success
619 * @retval 1 : E_NOT_OK, fail
620 */
621 static Std_ReturnType Netc_EthSwt_Ip_ConfigTAS(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config);
622
623 /**
624 * @brief Switch registers and ports configuration function
625 *
626 * @param[in] SwitchIdx: Switch ID
627 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
628 *
629 * @return Result of the operation
630 * @retval 0 : E_OK, success
631 * @retval 1 : E_NOT_OK, fail
632 */
633 static Std_ReturnType Netc_EthSwt_Ip_ConfigSwt(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config);
634
635 /**
636 * @brief inline function for enabling PCIE access for the timer, MDIO, switch and ENETC
637 *
638 * @return Std_ReturnType
639 * @retval E_OK: success
640 * @retval E_NOT_OK: timeout has occured
641 */
642 static inline Std_ReturnType Netc_EthSwt_Ip_EnablePCIE(void);
643
644 static inline Std_ReturnType Netc_EthSwt_Ip_PortRateEnumToRate(EthTrcv_BaudRateType baudRate, uint64 *portTxRate);
645
646 static Std_ReturnType Netc_EthSwt_Ip_IerbReady(void);
647
648 static inline void Netc_EthSwt_Ip_FillInTableDataBuffForSearchingFDBTable(const uint32 * ActionsData, const uint32 * ResumeEntryId, const Netc_EthSwt_Ip_FDBTableSearchCriteriaDataType * SearchCriteriaData);
649
650 static inline Std_ReturnType Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable( uint8 SwitchIdx,
651 Netc_EthSwt_Ip_ResumeEntryEntryId * ResumeEntryEntryId, uint32 * agingCount, boolean * FoundEntry
652 );
653
654 static inline Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteFdbTableEntryById( uint8 SwitchIdx,
655 uint32 EntryId
656 );
657
658 #if(NETC_ETHSWT_IP_CONFIG_LINK_PROTOCOL == STD_ON)
659 /**
660 * @brief Config link protocol for switch mac ports.
661 * @details
662 *
663 * @param[in] SwitchIdx Index of the switch within the context of the Ethernet Switch Driver
664 * @param[in] SwitchPortIdx Index of the port at the addressed switch
665 * @param[in] EthSwtPortPhysicalLayerType Supported MII protocol: 0 MII, 1 RMII, 2 RGMII
666 *
667 */
668 static void Netc_EthSwt_Ip_ConfigLinkProtocol(uint8 SwitchIdx, uint8 SwitchPortIdx, Netc_EthSwt_Ip_XmiiModeType EthSwtPortPhysicalLayerType);
669 #endif
670
671 #if (NETC_ETHSWT_NUMBER_OF_RP_ENTRIES > 0U)
672 /**
673 * @brief Rate policer configuration function
674 *
675 * @param[in] SwitchIdx: Switch ID
676 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
677 *
678 * @return Result of the operation
679 * @retval 0 : E_OK, success
680 * @retval 1 : E_NOT_OK, fail
681 */
682 static Std_ReturnType Netc_EthSwt_Ip_ConfigRP(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config);
683 #endif
684
685 #if (NETC_ETHSWT_NUMBER_OF_SGCL_ENTRIES > 0U)
686 /**
687 * @brief Stream Gate Control List configuration function
688 *
689 * @param[in] SwitchIdx: Switch ID
690 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
691 *
692 * @return Result of the operation
693 * @retval 0 : E_OK, success
694 * @retval 1 : E_NOT_OK, fail
695 */
696 static Std_ReturnType Netc_EthSwt_Ip_ConfigSGCL(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config);
697 #endif
698
699 #if (NETC_ETHSWT_NUMBER_OF_SGI_ENTRIES > 0U)
700 /**
701 * @brief Stream Gate Instance configuration function
702 *
703 * @param[in] SwitchIdx: Switch ID
704 * @param[in] Config: Pointer to the configuration of one Ethernet Switch for initalisation
705 *
706 * @return Result of the operation
707 * @retval 0 : E_OK, success
708 * @retval 1 : E_NOT_OK, fail
709 */
710 static Std_ReturnType Netc_EthSwt_Ip_ConfigSGI(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config);
711 #endif
712
713 /*==================================================================================================
714 * LOCAL FUNCTIONS
715 ==================================================================================================*/
Netc_EthSwt_Ip_StartTimeOut(uint32 * StartTimeOut,uint32 * ElapsedTimeOut,uint32 * TimeoutTicksOut,uint32 TimeoutUs)716 static inline void Netc_EthSwt_Ip_StartTimeOut( uint32 *StartTimeOut,
717 uint32 *ElapsedTimeOut,
718 uint32 *TimeoutTicksOut,
719 uint32 TimeoutUs
720 )
721 {
722 *StartTimeOut = OsIf_GetCounter(NETC_ETHSWT_IP_TIMEOUT_TYPE);
723 *ElapsedTimeOut = 0U;
724 *TimeoutTicksOut = OsIf_MicrosToTicks(TimeoutUs, NETC_ETHSWT_IP_TIMEOUT_TYPE);
725 }
726
Netc_EthSwt_Ip_TimeoutExpired(uint32 * StartTimeInOut,uint32 * ElapsedTimeInOut,uint32 TimeoutTicks)727 static inline boolean Netc_EthSwt_Ip_TimeoutExpired( uint32 *StartTimeInOut,
728 uint32 *ElapsedTimeInOut,
729 uint32 TimeoutTicks
730 )
731 {
732 uint32 elapsedTime;
733
734 /* get elapsed ticks */
735 elapsedTime = OsIf_GetElapsed(StartTimeInOut, NETC_ETHSWT_IP_TIMEOUT_TYPE);
736
737 /* Need to verify overflow of addition */
738 if(((uint64)elapsedTime + *ElapsedTimeInOut) < ((uint32)MAX_32BIT))
739 {
740 *ElapsedTimeInOut += elapsedTime;
741 }
742 else
743 {
744 *ElapsedTimeInOut = ((uint32)MAX_32BIT);
745 }
746
747 return ((*ElapsedTimeInOut >= TimeoutTicks) ? TRUE : FALSE);
748 }
749
750 /**
751 * @brief Internal function used by Netc_EthSwt_Ip_AddStreamGateControlListTableEntry function
752 *
753 * @param SGCLTableEntry Pointer points to a Stream Gate Control List entry structure Netc_EthSwt_Ip_SGCLTableDataType
754 */
Netc_EthSwt_Ip_AddStreamGateControlListTableEntry_FillListEntriesData(const Netc_EthSwt_Ip_SGCLTableDataType * SGCLTableEntry)755 static inline void Netc_EthSwt_Ip_AddStreamGateControlListTableEntry_FillListEntriesData(const Netc_EthSwt_Ip_SGCLTableDataType* SGCLTableEntry)
756 {
757 uint8 ListIdx;
758 if (SGCLTableEntry->Cfge_ListLength > 0U)
759 {
760 for (ListIdx = 0U; ListIdx < SGCLTableEntry->Cfge_ListLength; ListIdx++)
761 {
762 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2 + (2U * ListIdx)] = SGCLTableEntry->ListEntries[ListIdx].SGCL_TimeInterval;
763 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3 + (2U * ListIdx)] = NETC_ETHSWT_IP_SGCLTABLE_CFGE_IOM(SGCLTableEntry->ListEntries[ListIdx].SGCL_IntervalOctetsMax) \
764 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_IPV(SGCLTableEntry->ListEntries[ListIdx].SGCL_Ipv) \
765 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_OIPV((SGCLTableEntry->ListEntries[ListIdx].SGCL_Oipv) ? 1U : 0U) \
766 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_CTD((SGCLTableEntry->ListEntries[ListIdx].SGCL_Ctd) ? 1U : 0U) \
767 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_IOMEN((SGCLTableEntry->ListEntries[ListIdx].SGCL_IntervalOctetMaxEnable) ? 1U : 0U) \
768 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_GTST(SGCLTableEntry->ListEntries[ListIdx].SGCL_GateState);
769 }
770 }
771 }
772 /**
773 * @brief Internal function used by Netc_EthSwt_Ip_SearchIngressStreamFilterTableEntry function
774 *
775 * @param[in] ResumeEntryId resume entry id for searching
776 * @param[inout] IngressStreamFilterTableEntry A pointer that returns the data of a matched entry by "search" operation
777 * The data is valid only when MatchedEntry equals 1.
778 */
Netc_EthSwt_Ip_SearchIngressStreamFilterTableEntry_FoundAMatchedEntry(uint32 * ResumeEntryId,Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry)779 static inline void Netc_EthSwt_Ip_SearchIngressStreamFilterTableEntry_FoundAMatchedEntry(uint32 * ResumeEntryId,
780 Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry
781 )
782 {
783 uint8 SduType;
784 uint32 CfgeConfigBits;
785
786 /* fill in "Netc_EthSwt_Ip_IngressStreamFilterEntryDataType" structure with data in response data buffer */
787 *ResumeEntryId = TableDataBuffer.TableDataField[0U]; /* update the resume entry id for next search */
788 IngressStreamFilterTableEntry->IngressStreamFilterEntryId = TableDataBuffer.TableDataField[1U];
789 /* fill in KEYE_DATA */
790 IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.IngressStream_EID = TableDataBuffer.TableDataField[2U];
791 IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.Pcp = (uint8)(TableDataBuffer.TableDataField[3U] & NETC_ETHSWT_IP_ISFILTERTABLE_KEYE_PCP_MASK);
792 /* fill in CFGE data */
793 CfgeConfigBits = TableDataBuffer.TableDataField[4U];
794 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.InternalPriorityValue = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_SHIFT);
795 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideIPV = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_SHIFT) > 0U) ? TRUE : FALSE;
796 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.DropResilience = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_SHIFT);
797 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideDR = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_SHIFT) > 0U) ? TRUE : FALSE;
798 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressMirroringEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_SHIFT) > 0U) ? TRUE : FALSE;
799 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.TimeStampCaptureEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_SHIFT) > 0U) ? TRUE : FALSE;
800 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideRatePolicerInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_SHIFT) > 0U) ? TRUE : FALSE;
801 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideStreamGateInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_SHIFT) > 0U) ? TRUE : FALSE;
802 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.CutThrDisable = (CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_SHIFT;
803 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.MaximumServiceDataUnit = (uint16)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_SHIFT);
804
805 SduType = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_SHIFT);
806 switch (SduType)
807 {
808 case 0U:
809 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_PPDU;
810 break;
811 case 1U:
812 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MPDU;
813 break;
814 case 2U:
815 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MSDU;
816 break;
817 default:
818 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_RSDTYPE;
819 break;
820 }
821
822 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.RatePolicer_EID = TableDataBuffer.TableDataField[5U];
823 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.StreamGateInstance_EID = TableDataBuffer.TableDataField[6U];
824 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressStreamCounter_EID = TableDataBuffer.TableDataField[7U];
825 }
826
827 /**
828 * @brief Internal function used by Netc_EthSwt_Ip_QueryStreamGateControlListTableEntry function
829 *
830 * @param[inout] SGCLTableEntryRspData A pointer that returns the data of a matched entry by "query" operation
831 * The data is valid only when MatchedEntries equals 1.
832 */
Netc_EthSwt_Ip_QueryStreamGateControlListTableEntry_FoundAMatchedEntry(Netc_EthSwt_Ip_SGCLTableDataType * SGCLTableEntryRspData)833 static inline void Netc_EthSwt_Ip_QueryStreamGateControlListTableEntry_FoundAMatchedEntry(Netc_EthSwt_Ip_SGCLTableDataType* SGCLTableEntryRspData)
834 {
835 uint32 ConfigBits;
836 uint8 ListIdx;
837 /* fill in "Netc_EthSwt_Ip_SGCLTableDataType" structure with data in response data buffer */
838 SGCLTableEntryRspData->SGCLEntryId = TableDataBuffer.TableDataField[0U];
839 /* fill in SGCLSE_DATA */
840 SGCLTableEntryRspData->Sgclse_RefCount = (TableDataBuffer.TableDataField[1U] & NETC_ETHSWT_IP_SGCLTABLE_SGCLSE_REFCOUNT_MASK);
841 /* fill in CFGE data */
842 SGCLTableEntryRspData->Cfge_CycleTime = TableDataBuffer.TableDataField[2U];
843 ConfigBits = TableDataBuffer.TableDataField[3U];
844 SGCLTableEntryRspData->Cfge_ListLength = (uint8)(ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_LISTLEN_MASK) + 1U;
845 SGCLTableEntryRspData->Cfge_ExtIpv = (uint8)((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTIPV_MASK) >> NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTIPV_SHIFT);
846 SGCLTableEntryRspData->Cfge_ExtOIPV = ((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTOIPV_MASK) == 0x0UL) ? FALSE : TRUE;
847 SGCLTableEntryRspData->Cfge_ExtCtd = ((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTCTD_MASK) == 0x0UL) ? FALSE : TRUE;
848 SGCLTableEntryRspData->Cfge_ExtGtst = (ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTGTST_MASK) >> NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTGTST_SHIFT;
849
850 if (SGCLTableEntryRspData->Cfge_ListLength > 0U)
851 {
852 for (ListIdx = 0U; ListIdx < SGCLTableEntryRspData->Cfge_ListLength; ListIdx++)
853 {
854 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_TimeInterval = TableDataBuffer.TableDataField[4U + (2U * ListIdx)];
855 ConfigBits = TableDataBuffer.TableDataField[5U + (2U * ListIdx)];
856 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_IntervalOctetsMax = ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_IOM_MASK;
857 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_Ipv = (uint8)((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_IPV_MASK) >> NETC_ETHSWT_IP_SGCLTABLE_CFGE_IPV_SHIFT);
858 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_Oipv = ((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_OIPV_MASK) == 0x0UL) ? FALSE : TRUE;
859 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_Ctd = ((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_CTD_MASK) == 0x0UL) ? FALSE : TRUE;
860 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_IntervalOctetMaxEnable = ((ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_IOMEN_MASK) == 0x0UL) ? FALSE : TRUE;
861 SGCLTableEntryRspData->ListEntries[ListIdx].SGCL_GateState = (ConfigBits & NETC_ETHSWT_IP_SGCLTABLE_CFGE_GTST_MASK) >> NETC_ETHSWT_IP_SGCLTABLE_CFGE_GTST_SHIFT;
862 }
863 }
864 }
865
866 /**
867 * @brief Internal function used by Netc_EthSwt_Ip_QueryRatePolicerTableEntry function
868 *
869 * @param[inout] RatePolicerTableEntry A pointer that returns the data of a matched entry by "query" operation
870 * The data is valid only when MatchedEntries equals 1.
871 */
Netc_EthSwt_Ip_QueryRatePolicerTableEntry_FoundAMatchedEntry(Netc_EthSwt_Ip_RatePolicerEntryRspDataType * RatePolicerTableEntry)872 static inline void Netc_EthSwt_Ip_QueryRatePolicerTableEntry_FoundAMatchedEntry(Netc_EthSwt_Ip_RatePolicerEntryRspDataType * RatePolicerTableEntry)
873 {
874 uint32 CfgeConfigBits;
875 uint8 SduType;
876
877 /* fill in "Netc_EthSwt_Ip_RatePolicerEntryDataType" structure with data in response data buffer */
878 RatePolicerTableEntry->RatePolicerEntryId = TableDataBuffer.TableDataField[0U];
879 /* fill in STSE data */
880 RatePolicerTableEntry->RatePolicerStseData.Stse_ByteCount = (((uint64)TableDataBuffer.TableDataField[2U]) << NETC_ETHSWT_IP_32BIT_SHIFT);
881 RatePolicerTableEntry->RatePolicerStseData.Stse_ByteCount |= (uint64)(TableDataBuffer.TableDataField[1U]);
882 RatePolicerTableEntry->RatePolicerStseData.Stse_DropFrames = TableDataBuffer.TableDataField[3U];
883 RatePolicerTableEntry->RatePolicerStseData.Stse_Dr0GrnFrames = TableDataBuffer.TableDataField[5U];
884 RatePolicerTableEntry->RatePolicerStseData.Stse_Dr1GrnFrames = TableDataBuffer.TableDataField[7U];
885 RatePolicerTableEntry->RatePolicerStseData.Stse_Dr2YlwFrames = TableDataBuffer.TableDataField[9U];
886 RatePolicerTableEntry->RatePolicerStseData.Stse_RemarkYlwFrames = TableDataBuffer.TableDataField[11U];
887 RatePolicerTableEntry->RatePolicerStseData.Stse_Dr3RedFrames = TableDataBuffer.TableDataField[13U];
888 RatePolicerTableEntry->RatePolicerStseData.Stse_RemarkRedFrames = TableDataBuffer.TableDataField[15U];
889 RatePolicerTableEntry->RatePolicerStseData.Stse_Lts = TableDataBuffer.TableDataField[17U];
890 RatePolicerTableEntry->RatePolicerStseData.Stse_CommittedTokenBucketInteger = TableDataBuffer.TableDataField[18U];
891 RatePolicerTableEntry->RatePolicerStseData.Stse_CommittedTokenBucketFractional = TableDataBuffer.TableDataField[19U]; /* 1 sign bit + 31 bits fractional */
892 RatePolicerTableEntry->RatePolicerStseData.Stse_ExcessTokenBucketInteger = TableDataBuffer.TableDataField[20U];
893 RatePolicerTableEntry->RatePolicerStseData.Stse_ExcessTokenBucketFractional = TableDataBuffer.TableDataField[21U]; /* 1 sign bit + 31 bits fractional */
894 /* fill in CFGE data */
895 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cir = TableDataBuffer.TableDataField[22U];
896 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cbs = TableDataBuffer.TableDataField[23U];
897 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Eir = TableDataBuffer.TableDataField[24U];
898 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Ebs = TableDataBuffer.TableDataField[25U];
899 CfgeConfigBits = TableDataBuffer.TableDataField[26U];
900 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Mren = ((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_MREN_MASK) == 0U) ? FALSE : TRUE;
901 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Doy = ((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_DOY_MASK) == 0U) ? FALSE : TRUE;
902 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cm = ((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_CM_MASK) == 0U) ? FALSE : TRUE;
903 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cf = ((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_CF_MASK) == 0U) ? FALSE : TRUE;
904 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Ndor = ((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_NDOR_MASK) == 0U) ? FALSE : TRUE;
905 SduType = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_SDU_TYPE_MASK) >> NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_SDU_TYPE_SHIFT);
906 switch (SduType)
907 {
908 case 0U:
909 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_SduType = NETC_ETHSWT_IP_PPDU;
910 break;
911 case 1U:
912 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_SduType = NETC_ETHSWT_IP_MPDU;
913 break;
914 case 2U:
915 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_SduType = NETC_ETHSWT_IP_MSDU;
916 break;
917 default:
918 RatePolicerTableEntry->RatePolicerCfgeData.Cfge_SduType = NETC_ETHSWT_IP_RSDTYPE;
919 break;
920 }
921 /* fill FEE data */
922 RatePolicerTableEntry->RatePolicerFunctionEnable = (((CfgeConfigBits >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_RATEPOLICERTABLE_FEE_DATA_FEN_MASK) == 0U) ? FALSE : TRUE;
923 /* fill PSE data */
924 RatePolicerTableEntry->MarkRedFlag = (((CfgeConfigBits >> NETC_ETHSWT_IP_24BIT_SHIFT) & NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_MREN_MASK) == 0U) ? FALSE : TRUE;
925 }
926
927 /**
928 * @brief Internal function used by Netc_EthSwt_Ip_QueryIngressStreamTableEntry function
929 *
930 * @param[inout] IngressStreamTableEntry A pointer that returns the data of a matched entry by "search" operation
931 * The data is valid only when MatchedEntry equals 1.
932 */
Netc_EthSwt_Ip_QueryIngressStreamTableEntry_FoundAMatchedEntry(Netc_EthSwt_Ip_IngressStreamEntryDataType * IngressStreamTableEntry)933 static inline void Netc_EthSwt_Ip_QueryIngressStreamTableEntry_FoundAMatchedEntry(Netc_EthSwt_Ip_IngressStreamEntryDataType* IngressStreamTableEntry)
934 {
935 uint32 CfgeConfigBits;
936 uint8 SduType;
937 /* fill in "Netc_EthSwt_Ip_IngressStreamEntryDataType" structure with data in response data buffer */
938 IngressStreamTableEntry->IngressStreamEntryId = TableDataBuffer.TableDataField[0U];
939 /* fill in CFGE data */
940 CfgeConfigBits = TableDataBuffer.TableDataField[1U];
941 IngressStreamTableEntry->IngressStreamCfgeData.StreamFilteringEnable = ((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SFE_MASK) > 0U) ? TRUE : FALSE;
942 IngressStreamTableEntry->IngressStreamCfgeData.InternalPriorityValue = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IPV_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IPV_SHIFT);
943 IngressStreamTableEntry->IngressStreamCfgeData.OverrideIPV = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OIPV_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OIPV_SHIFT) > 0U) ? TRUE : FALSE;
944 IngressStreamTableEntry->IngressStreamCfgeData.DropResilience = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_DR_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_DR_SHIFT);
945 IngressStreamTableEntry->IngressStreamCfgeData.OverrideDR = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ODR_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ODR_SHIFT) > 0U) ? TRUE : FALSE;
946 IngressStreamTableEntry->IngressStreamCfgeData.IngressMirroringEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IMIRE_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IMIRE_SHIFT) > 0U) ? TRUE : FALSE;
947 IngressStreamTableEntry->IngressStreamCfgeData.TimeStampCaptureEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_TIMECAPE_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_TIMECAPE_SHIFT) > 0U) ? TRUE : FALSE;
948 IngressStreamTableEntry->IngressStreamCfgeData.SrcPortPruningDisable = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SPPD_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SPPD_SHIFT) > 0U) ? TRUE : FALSE;
949 IngressStreamTableEntry->IngressStreamCfgeData.IngressSeqAction = ((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ISQA_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ISQA_SHIFT);
950 IngressStreamTableEntry->IngressStreamCfgeData.OverrideRatePolicerInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ORP_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ORP_SHIFT) > 0U) ? TRUE : FALSE;
951 IngressStreamTableEntry->IngressStreamCfgeData.OverrideStreamGateInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OSGI_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OSGI_SHIFT) > 0U) ? TRUE : FALSE;
952 IngressStreamTableEntry->IngressStreamCfgeData.HostReason = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_HR_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_HR_SHIFT);
953 IngressStreamTableEntry->IngressStreamCfgeData.ForwardingActions = ((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_FA_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_FA_SHIFT);
954 SduType = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SDUTYPE_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SDUTYPE_SHIFT);
955 switch (SduType)
956 {
957 case 0U:
958 IngressStreamTableEntry->IngressStreamCfgeData.SduType = NETC_ETHSWT_IP_PPDU;
959 break;
960 case 1U:
961 IngressStreamTableEntry->IngressStreamCfgeData.SduType = NETC_ETHSWT_IP_MPDU;
962 break;
963 case 2U:
964 IngressStreamTableEntry->IngressStreamCfgeData.SduType = NETC_ETHSWT_IP_MSDU;
965 break;
966 default:
967 IngressStreamTableEntry->IngressStreamCfgeData.SduType = NETC_ETHSWT_IP_RSDTYPE;
968 break;
969 }
970
971 CfgeConfigBits = TableDataBuffer.TableDataField[2U];
972 IngressStreamTableEntry->IngressStreamCfgeData.MaximumServiceDataUnit = (uint16)((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_MSDU_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_MSDU_SHIFT);
973 IngressStreamTableEntry->IngressStreamCfgeData.IngressFrmModiEntryFrmLenChange = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IFMELENCHG_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IFMELENCHG_SHIFT);
974 IngressStreamTableEntry->IngressStreamCfgeData.EgressPort = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_EPORT_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_EPORT_SHIFT);
975 IngressStreamTableEntry->IngressStreamCfgeData.OverrideET_EID = ((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OETEID_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OETEID_SHIFT);
976 IngressStreamTableEntry->IngressStreamCfgeData.CutThrDisable = ((CfgeConfigBits & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_CTD_MASK) >> NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_CTD_SHIFT);
977
978 IngressStreamTableEntry->IngressStreamCfgeData.IngressSeqGeneration_EID = TableDataBuffer.TableDataField[3U];
979 IngressStreamTableEntry->IngressStreamCfgeData.RatePolicer_EID = TableDataBuffer.TableDataField[4U];
980 IngressStreamTableEntry->IngressStreamCfgeData.StreamGateInstance_EID = TableDataBuffer.TableDataField[5U];
981 IngressStreamTableEntry->IngressStreamCfgeData.IngressFrmModification_EID = TableDataBuffer.TableDataField[6U];
982 IngressStreamTableEntry->IngressStreamCfgeData.EgressTreatment_EID = TableDataBuffer.TableDataField[7U];
983 IngressStreamTableEntry->IngressStreamCfgeData.IngressStreamCounter_EID = TableDataBuffer.TableDataField[8U];
984 IngressStreamTableEntry->IngressStreamCfgeData.EgressPortBitMap = TableDataBuffer.TableDataField[9U] & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_EGRESSPORTMAP_MASK;
985 IngressStreamTableEntry->IngressStreamCfgeData.StationInterfaceMap = (uint16)(TableDataBuffer.TableDataField[10U] & NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SIMAP_MASK);
986 }
987
988 /**
989 * @brief Internal function used by Netc_EthSwt_Ip_QueryIngressStreamTableEntry function
990 *
991 * @param[inout] IngressStreamFilterTableEntry A pointer that returns the data of a matched entry by "search" operation
992 * The data is valid only when MatchedEntry equals 1.
993 */
Netc_EthSwt_Ip_QueryIngressStreamFilterTableEntry_FoundAMatchedEntry(Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry)994 static inline void Netc_EthSwt_Ip_QueryIngressStreamFilterTableEntry_FoundAMatchedEntry(Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry)
995 {
996 uint32 CfgeConfigBits;
997 uint8 SduType;
998 /* fill in "Netc_EthSwt_Ip_IngressStreamFilterEntryDataType" structure with data in response data buffer */
999 IngressStreamFilterTableEntry->IngressStreamFilterEntryId = TableDataBuffer.TableDataField[1U];
1000 /* fill in KEYE_DATA */
1001 IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.IngressStream_EID = TableDataBuffer.TableDataField[2U];
1002 IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.Pcp = (uint8)(TableDataBuffer.TableDataField[3U] & NETC_ETHSWT_IP_ISFILTERTABLE_KEYE_PCP_MASK);
1003 /* fill in CFGE data */
1004 CfgeConfigBits = TableDataBuffer.TableDataField[4U];
1005 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.InternalPriorityValue = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_SHIFT);
1006 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideIPV = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_SHIFT) > 0U) ? TRUE : FALSE;
1007 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.DropResilience = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_SHIFT);
1008 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideDR = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_SHIFT) > 0U) ? TRUE : FALSE;
1009 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressMirroringEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_SHIFT) > 0U) ? TRUE : FALSE;
1010 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.TimeStampCaptureEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_SHIFT) > 0U) ? TRUE : FALSE;
1011 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideRatePolicerInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_SHIFT) > 0U) ? TRUE : FALSE;
1012 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideStreamGateInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_SHIFT) > 0U) ? TRUE : FALSE;
1013 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.CutThrDisable = (CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_SHIFT;
1014 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.MaximumServiceDataUnit = (uint16)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_SHIFT);
1015
1016 SduType = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_SHIFT);
1017 switch (SduType)
1018 {
1019 case 0U:
1020 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_PPDU;
1021 break;
1022 case 1U:
1023 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MPDU;
1024 break;
1025 case 2U:
1026 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MSDU;
1027 break;
1028 default:
1029 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_RSDTYPE;
1030 break;
1031 }
1032
1033 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.RatePolicer_EID = TableDataBuffer.TableDataField[5U];
1034 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.StreamGateInstance_EID = TableDataBuffer.TableDataField[6U];
1035 IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressStreamCounter_EID = TableDataBuffer.TableDataField[7U];
1036 }
1037
1038 /**
1039 * @brief Internal function used by Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntry function
1040 *
1041 * @param[in] RatePolicerTableEntry Pointer points to a Rate policer entry structure Netc_EthSwt_Ip_RatePolicerEntryDataType
1042 * @return uint32 action data
1043 *
1044 */
Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntryGetActionsData(const Netc_EthSwt_Ip_RatePolicerEntryDataType * RatePolicerTableEntry)1045 static inline uint32 Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntryGetActionsData(const Netc_EthSwt_Ip_RatePolicerEntryDataType * RatePolicerTableEntry)
1046 {
1047 uint32 ActionsData;
1048 ActionsData = (NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(RatePolicerTableEntry->ConfigurationElementUpdate ? 1U : 0U) \
1049 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_FEEU(RatePolicerTableEntry->FunctionalEnableElementUpdate ? 1U : 0U)) \
1050 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_PSEU(RatePolicerTableEntry->PolicerStateElementUpdate ? 1U : 0U) \
1051 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_STSEU(RatePolicerTableEntry->StatisticsElementUpdate ? 1U : 0U) \
1052 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
1053 return ActionsData;
1054 }
1055
1056
1057 /**
1058 * @brief Internal function used by Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntryInitTableRequest function
1059 *
1060 * @param[in] RatePolicerTableEntry Pointer points to a Rate policer entry structure Netc_EthSwt_Ip_RatePolicerEntryDataType
1061 * @param[in] ActionsData
1062 *
1063 */
Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntryInitTableRequest(const Netc_EthSwt_Ip_RatePolicerEntryDataType * RatePolicerTableEntry,uint32 ActionsData)1064 static inline void Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntryInitTableRequest(const Netc_EthSwt_Ip_RatePolicerEntryDataType * RatePolicerTableEntry, uint32 ActionsData)
1065 {
1066 /* ------initialize the table request data buffer------ */
1067 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
1068 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = RatePolicerTableEntry->RatePolicerEntryId; /* fill in Entry_ID field (Access Key) */
1069 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cir; /* CFGE CIR field */
1070 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cbs; /* CFGE CBS field */
1071 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Eir; /* CFGE EIR field */
1072 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Ebs; /* CFGE EBS field */
1073 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_MREN((RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Mren) ? 1U : 0U) \
1074 | NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_DOY((RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Doy) ? 1U : 0U) \
1075 | NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_CM((RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cm) ? 1U : 0U) \
1076 | NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_CF((RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Cf) ? 1U : 0U) \
1077 | NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_NDOR((RatePolicerTableEntry->RatePolicerCfgeData.Cfge_Ndor) ? 1U : 0U) \
1078 | NETC_ETHSWT_IP_RATEPOLICERTABLE_CFGE_DATA_SDU_TYPE(RatePolicerTableEntry->RatePolicerCfgeData.Cfge_SduType);
1079 /* fill in Functional Enable Element Data */
1080 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] |= (NETC_ETHSWT_IP_RATEPOLICERTABLE_FEE_DATA_FEN(RatePolicerTableEntry->RatePolicerFunctionEnable ? 1U : 0U) << NETC_ETHSWT_IP_16BIT_SHIFT);
1081 }
1082
1083 /**
1084 * @brief Internal function used by Netc_EthSwt_Ip_SetPortSpeed function
1085 *
1086 * @param[in] BaudRate ETHTRCV_BAUD_RATE_10MBIT: 10MBit connection
1087 * ETHTRCV_BAUD_RATE_100MBIT: 100MBit connection
1088 * ETHTRCV_BAUD_RATE_1000MBIT: 1000MBit connection
1089 * @param[inout] interfaceModeConfig used for shaping of the port
1090 * @param[inout] shapingPSpeedConfig used for shaping of the port
1091 * @retval E_OK success
1092 * @retval E_NOT_OK Baud rate of the indexed switch port could not be changed
1093 *
1094 */
Netc_EthSwt_Ip_SetPortSpeed_MII_RMII_Mode(EthTrcv_BaudRateType BaudRate,uint32 * const interfaceModeConfig,uint32 * const shapingPSpeedConfig)1095 static inline Std_ReturnType Netc_EthSwt_Ip_SetPortSpeed_MII_RMII_Mode(EthTrcv_BaudRateType BaudRate, uint32* const interfaceModeConfig, uint32* const shapingPSpeedConfig)
1096 {
1097 Std_ReturnType status = E_OK;
1098 if(BaudRate == ETHTRCV_BAUD_RATE_10MBIT)
1099 {
1100 *interfaceModeConfig |= SW_ETH_MAC_PORT1_PM0_IF_MODE_M10_MASK;
1101 *shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
1102 }
1103 else if(BaudRate == ETHTRCV_BAUD_RATE_100MBIT)
1104 {
1105 *interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_M10_MASK);
1106 *shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
1107 }
1108 else
1109 {
1110 status = E_NOT_OK;
1111 }
1112 return status;
1113 }
1114
1115 /**
1116 * @brief Internal function used by Netc_EthSwt_Ip_SetPortSpeed function
1117 *
1118 * @param[in] BaudRate ETHTRCV_BAUD_RATE_10MBIT: 10MBit connection
1119 * ETHTRCV_BAUD_RATE_100MBIT: 100MBit connection
1120 * ETHTRCV_BAUD_RATE_1000MBIT: 1000MBit connection
1121 * @param[inout] interfaceModeConfig used for shaping of the port
1122 * @param[inout] shapingPSpeedConfig used for shaping of the port
1123 * @retval E_OK success
1124 * @retval E_NOT_OK Baud rate of the indexed switch port could not be changed
1125 *
1126 */
Netc_EthSwt_Ip_SetPortSpeed_RGMII_Mode(EthTrcv_BaudRateType BaudRate,uint32 * const interfaceModeConfig,uint32 * const shapingPSpeedConfig)1127 static inline Std_ReturnType Netc_EthSwt_Ip_SetPortSpeed_RGMII_Mode(EthTrcv_BaudRateType BaudRate, uint32* const interfaceModeConfig, uint32* const shapingPSpeedConfig)
1128 {
1129 Std_ReturnType status = E_OK;
1130 switch(BaudRate)
1131 {
1132 case ETHTRCV_BAUD_RATE_10MBIT: /* 10Mbps */
1133 {
1134 *interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1135 *interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT));
1136 *shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
1137 break;
1138 }
1139 case ETHTRCV_BAUD_RATE_100MBIT: /* 100Mbps */
1140 {
1141 *interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1142 *interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT));
1143 *shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
1144 break;
1145 }
1146 case ETHTRCV_BAUD_RATE_1000MBIT: /* 1000Mbps */
1147 {
1148 *interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1149 *interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT));
1150 *shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_1000MBITS;
1151 break;
1152 }
1153 default:
1154 {
1155 status = E_NOT_OK;
1156 break;
1157 }
1158 }
1159 return status;
1160 }
1161
1162
1163 /**
1164 * @brief Internal function used by Netc_EthSwt_Ip_SetPortSpeed function
1165 *
1166 * @param[in] BaudRate ETHTRCV_BAUD_RATE_10MBIT: 10MBit connection
1167 * ETHTRCV_BAUD_RATE_100MBIT: 100MBit connection
1168 * ETHTRCV_BAUD_RATE_1000MBIT: 1000MBit connection
1169 * @param[inout] interfaceModeConfig used for shaping of the port
1170 * @param[inout] shapingPSpeedConfig used for shaping of the port
1171 * @retval E_OK success
1172 * @retval E_NOT_OK Baud rate of the indexed switch port could not be changed
1173 *
1174 */
Netc_EthSwt_Ip_SetPortSpeed_SGMII_Mode(EthTrcv_BaudRateType BaudRate,uint32 * const interfaceModeConfig,uint32 * const shapingPSpeedConfig)1175 static inline Std_ReturnType Netc_EthSwt_Ip_SetPortSpeed_SGMII_Mode(EthTrcv_BaudRateType BaudRate, uint32* const interfaceModeConfig, uint32* const shapingPSpeedConfig)
1176 {
1177 Std_ReturnType status = E_OK;
1178 switch(BaudRate)
1179 {
1180 case ETHTRCV_BAUD_RATE_10MBIT: /* 10Mbps */
1181 {
1182 *interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1183 *interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT));
1184 *shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
1185 break;
1186 }
1187 case ETHTRCV_BAUD_RATE_100MBIT: /* 100Mbps */
1188 {
1189 *interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1190 *interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT));
1191 *shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
1192 break;
1193 }
1194 case ETHTRCV_BAUD_RATE_1000MBIT: /* 1000Mbps */
1195 {
1196 *interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1197 *interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT));
1198 *shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_1000MBITS;
1199 break;
1200 }
1201 case ETHTRCV_BAUD_RATE_2500MBIT: /* 2500Mbps */
1202 {
1203 *interfaceModeConfig &= ~(SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK);
1204 *interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_2500MBIT));
1205 *shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_2500MBITS;
1206 break;
1207 }
1208 default:
1209 {
1210 status = E_NOT_OK;
1211 break;
1212 }
1213 }
1214 return status;
1215 }
1216
Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable_FoundAMatchedEntry(uint32 * const EntryId,uint32 * const agingCount,boolean * const FoundEntry,const uint32 NumOfElement)1217 static inline void Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable_FoundAMatchedEntry(uint32 * const EntryId, uint32 * const agingCount, boolean * const FoundEntry, const uint32 NumOfElement)
1218 {
1219 uint32 TableEntryId;
1220 uint32 ActionsDataResponse;
1221
1222 /* found a matched entry */
1223 TableEntryId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
1224 if ((1U == NumOfElement) && (TableEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
1225 {
1226 *EntryId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_ENTRYID];
1227 ActionsDataResponse = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_ACTEDATA];
1228 *agingCount = (ActionsDataResponse & NETC_ETHSWT_IP_FDBTABLE_REPFMT_ACTE_DATA_FIELD_ACT_CNT_MASK);
1229 /* Predicting the update action effect after the search */
1230 if(NETC_ETHSWT_IP_FDBTABLE_REPFMT_ACTE_DATA_FIELD_ACT_FLAG_INACTIVE_FIELD ==
1231 (ActionsDataResponse & NETC_ETHSWT_IP_FDBTABLE_REPFMT_ACTE_DATA_FIELD_ACT_FLAG_MASK))
1232 {
1233 if(*agingCount<=NETC_ETHSWT_IP_NUM_AGING_CYCLE)
1234 {
1235 *agingCount += 1U;
1236 }
1237 }
1238 else
1239 {
1240 *agingCount = 0U;
1241 }
1242 *FoundEntry = TRUE;
1243 }
1244 }
1245
Netc_EthSwt_Ip_QueryFdbTableEntry_FoundAMatchedEntry(const uint32 MatchedEntries,Netc_EthSwt_Ip_FdbEntryDataType * FdbTableEntry)1246 static inline void Netc_EthSwt_Ip_QueryFdbTableEntry_FoundAMatchedEntry(const uint32 MatchedEntries, Netc_EthSwt_Ip_FdbEntryDataType * FdbTableEntry)
1247 {
1248 uint32 MacAddrL;
1249 uint32 MacAddrH;
1250 uint32 CfgeData;
1251 uint8 MacByteIdx;
1252
1253 /* found a matched entry */
1254 if (1U == MatchedEntries)
1255 {
1256 /* fill in "Netc_EthSwt_Ip_FdbEntryDataType" structure with data in response data buffer */
1257 MacAddrL = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_L];
1258 MacAddrH = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_H];
1259 for (MacByteIdx = 0U; MacByteIdx < 4U; MacByteIdx++ )
1260 {
1261 FdbTableEntry->MacAddr[MacByteIdx] = (uint8)(MacAddrL & NETC_ETHSWT_IP_0XFF_MASK);
1262 MacAddrL >>= 8U;
1263 }
1264 FdbTableEntry->MacAddr[4U] = (uint8)(MacAddrH & NETC_ETHSWT_IP_0XFF_MASK);
1265 FdbTableEntry->MacAddr[5U] = (uint8)((MacAddrH >> 8U) & NETC_ETHSWT_IP_0XFF_MASK);
1266
1267 FdbTableEntry->FID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_FID] & NETC_ETHSWT_IP_FDBTABLE_KEYE_DATA_FID_MASK);
1268 FdbTableEntry->SwitchPortEgressBitMask = (TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_PORTBITMAP] & NETC_ETHSWT_IP_FDBTABLE_CFGE_PORT_BITMAP_MASK);
1269
1270 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_CFGECONFIG];
1271 FdbTableEntry->TimeStampCapture = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE_SHIFT) != 0x0UL) ? TRUE : FALSE;
1272 FdbTableEntry->DynamicEntry = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC_SHIFT) != 0x0UL) ? TRUE : FALSE;
1273 FdbTableEntry->CutThroughDisable = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_SHIFT);
1274 FdbTableEntry->IngressMirroringEnable = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE_SHIFT) != 0x0UL) ? TRUE : FALSE;
1275 FdbTableEntry->EgressPort = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_SHIFT);
1276 FdbTableEntry->OverridETEID = (uint8)(CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_OETEID_MASK);
1277
1278 FdbTableEntry->ET_EID = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_ETEID];
1279 }
1280 }
1281
Netc_EthSwt_Ip_WriteMirrorConfiguration_EnablePortMirror(const Netc_EthSwt_Ip_SwitchMirrorCfgType * MirrorConfigurationPtr)1282 static inline void Netc_EthSwt_Ip_WriteMirrorConfiguration_EnablePortMirror(const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr)
1283 {
1284 uint32 IngressBitMask;
1285 uint8 PortIdx;
1286 /* Enable port mirroring according to TrafficDirectionIngressBitMask */
1287 IngressBitMask = MirrorConfigurationPtr->TrafficDirectionIngressBitMask;
1288 for(PortIdx = 0U; PortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS; PortIdx++)
1289 {
1290 if((IngressBitMask & 0x1U) == 0x1U)
1291 {
1292 Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIdx]->PMCR = (uint32)0x1U;
1293 }
1294 IngressBitMask >>= 1U;
1295 }
1296 }
1297
1298
Netc_EthSwt_Ip_WriteMirrorConfiguration_SecondPart(uint8 MirroredSwitchIdx,const Netc_EthSwt_Ip_SwitchMirrorCfgType * MirrorConfigurationPtr,Std_ReturnType * Status)1299 static inline void Netc_EthSwt_Ip_WriteMirrorConfiguration_SecondPart(uint8 MirroredSwitchIdx, const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr, Std_ReturnType* Status)
1300 {
1301 Netc_EthSwt_Ip_IngressPortFilterSrcDestAddrFilter IngressPortFilterSrcDestAddrFilter = {FALSE, FALSE};
1302 Netc_EthSwt_Ip_IngressPortFilterEntryDataType IngressPortFilterTableEntry = {0};
1303 /* check if Mac Address Filter enabled */
1304 Netc_EthSwt_Ip_CheckMacAddressFilterEnableFlag(&IngressPortFilterSrcDestAddrFilter, MirrorConfigurationPtr);
1305
1306 /* Start writing mirroring configuration */
1307 /* #1 */
1308 if ((MirrorConfigurationPtr->VlanIdFilter == NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID) && (IngressPortFilterSrcDestAddrFilter.DstMacAddrFilterEnabled == FALSE) && (IngressPortFilterSrcDestAddrFilter.SrcMacAddrFilterEnabled == FALSE))
1309 {
1310 /* Enable port mirroring according to TrafficDirectionIngressBitMask */
1311 Netc_EthSwt_Ip_WriteMirrorConfiguration_EnablePortMirror(MirrorConfigurationPtr);
1312 }
1313 else /* #2 ingress port filtering */
1314 {
1315 /* Config and add the ingress port filter table entry for ingress frames filtering */
1316 *Status |= Netc_EthSwt_Ip_ConfigIngressPortFilterForPortMirroring(MirroredSwitchIdx, IngressPortFilterSrcDestAddrFilter, MirrorConfigurationPtr, &IngressPortFilterTableEntry);
1317 }
1318
1319 /* #3 egress frame modification */
1320 *Status |= Netc_EthSwt_Ip_ConfigEgressFrameModificationForPortMirroring(MirroredSwitchIdx, MirrorConfigurationPtr);
1321 }
1322
1323
Netc_EthSwt_Ip_IerbReady(void)1324 static Std_ReturnType Netc_EthSwt_Ip_IerbReady(void)
1325 {
1326 Std_ReturnType Status = E_NOT_OK;
1327 uint32 StartTime;
1328 uint32 ElapsedTime;
1329 uint32 TimeoutTicks;
1330
1331 /* Verify ready and IERB is valid */
1332 /* Setup timeout timer */
1333 Netc_EthSwt_Ip_StartTimeOut(&StartTime, &ElapsedTime, &TimeoutTicks, NETC_ETHSWT_IP_TIMEOUT_VALUE_US);
1334 do
1335 {
1336 #ifdef MCAL_ENABLE_FAULT_INJECTION
1337 MCAL_FAULT_INJECTION_POINT(ETHSWT_CHECK_OSR_STATE_TIMEOUT);
1338 #endif
1339 if (
1340 (0UL == (IP_NETC__SW0_COMMON->OSR & NETC_F2_COMMON_OSR_STATE_MASK)) &&
1341 (0UL == (IP_NETC__SW0_COMMON->OSR & NETC_F2_COMMON_OSR_ITM_STATE_MASK))
1342 )
1343 {
1344 Status = E_OK;
1345 break;
1346 }
1347 }while(!Netc_EthSwt_Ip_TimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks));
1348
1349 return Status;
1350 }
1351
Netc_EthSwt_Ip_PortRateEnumToRate(EthTrcv_BaudRateType baudRate,uint64 * portTxRate)1352 static inline Std_ReturnType Netc_EthSwt_Ip_PortRateEnumToRate(EthTrcv_BaudRateType baudRate, uint64 *portTxRate)
1353 {
1354 Std_ReturnType status = E_OK;
1355 /* Translate enum in uint32 for calculations and PSPEED config */
1356 switch(baudRate) {
1357 case ETHTRCV_BAUD_RATE_10MBIT:
1358 *portTxRate = 10000000UL;
1359 break;
1360 case ETHTRCV_BAUD_RATE_100MBIT:
1361 *portTxRate = 100000000UL;
1362 break;
1363 case ETHTRCV_BAUD_RATE_1000MBIT:
1364 *portTxRate = 1000000000UL;
1365 break;
1366 default:
1367 *portTxRate = 1000000000UL;
1368 status = E_NOT_OK;
1369 break;
1370 };
1371 return status;
1372 }
1373
Netc_EthSwt_Ip_GetPortMacAddr_SecondPart(uint8 SwitchIdx,uint32 * const NumOfMatchedElement,Netc_EthSwt_Ip_FdbEntryDataType * const FdbTableEntry,Netc_EthSwt_Ip_PortMacAddrEntry * const PortMacAddrEntry)1374 static inline Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_GetPortMacAddr_SecondPart(uint8 SwitchIdx,
1375 uint32* const NumOfMatchedElement,
1376 Netc_EthSwt_Ip_FdbEntryDataType* const FdbTableEntry,
1377 Netc_EthSwt_Ip_PortMacAddrEntry* const PortMacAddrEntry)
1378 {
1379 Netc_EthSwt_Ip_CBDRStatusType QueryStatus;
1380 Netc_EthSwt_Ip_FDBTableSearchCriteriaDataType SearchCriteriaData = {0U};
1381 uint32 ResumeEntryId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
1382 uint8 MacByteIdx;
1383
1384 do
1385 {
1386 *NumOfMatchedElement = 1; /* set the flag for finding a matched entry */
1387 SearchCriteriaData.SearchMatchCriteria = NETC_ETHSWT_IP_FDBTABLE_MATCH_ANY_CRITERIA;
1388 QueryStatus = Netc_EthSwt_Ip_SearchFdbTable(SwitchIdx, &ResumeEntryId, &SearchCriteriaData, FdbTableEntry);
1389
1390 /* check if we found a matched entry */
1391 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
1392 {
1393 if (FdbTableEntry->MacAddr[MacByteIdx] != PortMacAddrEntry->MacAddr[MacByteIdx])
1394 {
1395 *NumOfMatchedElement = 0U;
1396 break;
1397 }
1398 }
1399
1400 /* find a matched entry */
1401 if (1U == *NumOfMatchedElement)
1402 {
1403 PortMacAddrEntry->MatchedEntryFound = TRUE;
1404 /* get the port bitmap value from Fdb table response data buffer. */
1405 PortMacAddrEntry->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 */
1406 }
1407 } while (ResumeEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID);
1408 return QueryStatus;
1409 }
1410
1411 /*FUNCTION**********************************************************************
1412 *
1413 * Function Name : Netc_EthSwt_Ip_EMDIOConfiguration
1414 * Description : function for configuring the EMDIO
1415 *
1416 *END**************************************************************************/
1417 static Std_ReturnType Netc_EthSwt_Ip_EMDIOConfiguration( uint8 SwitchIdx );
1418
1419 /*FUNCTION**********************************************************************
1420 *
1421 * Function Name : Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable
1422 * Description : Ethernet Switch search entry ID in FDB table and increment aging count.
1423 *END**************************************************************************/
Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable(uint8 SwitchIdx,Netc_EthSwt_Ip_ResumeEntryEntryId * ResumeEntryEntryId,uint32 * agingCount,boolean * FoundEntry)1424 static inline Std_ReturnType Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable( uint8 SwitchIdx,
1425 Netc_EthSwt_Ip_ResumeEntryEntryId * ResumeEntryEntryId, uint32 * agingCount, boolean * FoundEntry
1426 )
1427 {
1428 Std_ReturnType status = E_OK;
1429 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
1430 uint32 NumOfElement = 0U;
1431 uint32 ActionsData;
1432
1433 Netc_EthSwt_Ip_FDBTableSearchCriteriaDataType SearchCriteriaData;
1434
1435 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
1436 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1437 #endif
1438 *FoundEntry = FALSE;
1439 SearchCriteriaData.SearchResumeEntryId=0U;
1440 SearchCriteriaData.SearchActeData.ActivityCounter=0U;
1441 SearchCriteriaData.SearchActeData.ActivityFlag=FALSE;
1442 SearchCriteriaData.SearchCfgeData.SearchPortBitMap=0U;
1443 SearchCriteriaData.SearchKeyeData.SearchFid=0U;
1444 SearchCriteriaData.SearchKeyeData.SearchMulticastMacAddr=FALSE;
1445
1446 SearchCriteriaData.SearchMatchCriteria = (NETC_ETHSWT_IP_FDBTABLE_MATCH_CFGE_DYNAMIC_FIELD); /* Match DYNAMIC field */
1447 SearchCriteriaData.SearchCfgeData.SearchDynamicEntry = TRUE; /* Search DYNAMIC entry */
1448
1449 /* +++ fill in FdbTabeDataBuffer for request +++ */
1450 /* set the query options with full query */
1451 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
1452 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U) \
1453 | NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(1U) \
1454 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(0U);
1455 Netc_EthSwt_Ip_FillInTableDataBuffForSearchingFDBTable(&ActionsData, &(ResumeEntryEntryId->ResumeEntryId), &SearchCriteriaData);
1456 /* --- fill in FdbTabeDataBuffer for request --- */
1457
1458 /* do the full query with Search Method */
1459 /* fill in operation data for config field of Request Header*/
1460 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
1461 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
1462 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
1463 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
1464 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_FOLLOWEDBY_UPDATE_CMD;
1465 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_REQBUFFER_LEN);
1466 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_FDBTABLE_RESBUFFER_LEN); /* full query needs more space for response data */
1467
1468 /* send the "Query" command */
1469 /* [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. */
1470 CBDRStatus = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
1471
1472 #if defined(ERR_IPV_NETC_051243)
1473 #if (STD_ON == ERR_IPV_NETC_051243)
1474 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
1475 {
1476 #endif
1477 #else
1478 if (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
1479 {
1480 #endif
1481 /* check if found a matched entry */
1482 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
1483
1484 /* found a matched entry */
1485 Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable_FoundAMatchedEntry(&(ResumeEntryEntryId->EntryId), agingCount, FoundEntry, NumOfElement);
1486
1487 /* get the resume_entry_id and be ready for the next query operation */
1488 /* [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 */
1489 ResumeEntryEntryId->ResumeEntryId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
1490 }
1491 else
1492 {
1493 status = E_NOT_OK;
1494 }
1495
1496 return status;
1497 }
1498
1499 /*FUNCTION**********************************************************************
1500 *
1501 * Function Name : Netc_EthSwt_Ip_DeleteFdbTableEntryById
1502 * Description : Ethernet Switch use the entry ID in FDB table and delete it.
1503 *END**************************************************************************/
1504 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteFdbTableEntryById( uint8 SwitchIdx,
1505 uint32 EntryId
1506 )
1507 {
1508 Std_ReturnType status = E_OK;
1509 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
1510 uint32 NumOfElement = 0U;
1511 uint32 EntryStatus;
1512
1513 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
1514 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1515 #endif
1516 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_42();
1517 /* +++ fill in FdbTabeDataBuffer for request +++ */
1518 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = \
1519 NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
1520 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U) \
1521 | NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(0U) \
1522 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(0U);
1523
1524 /* fill in Access Key data with search criteria data format */
1525 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EntryId;
1526 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_42();
1527
1528 /* fill in operation data for config field of Request Header*/
1529 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
1530 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
1531 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
1532 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
1533 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
1534 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN);
1535 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
1536
1537 /* send the "Delete" command */
1538 /* [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. */
1539 CBDRStatus = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
1540
1541 #if defined(ERR_IPV_NETC_051243)
1542 #if (STD_ON == ERR_IPV_NETC_051243)
1543 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
1544 {
1545 #endif
1546 #else
1547 if (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
1548 {
1549 #endif
1550 /* check if found a matched entry */
1551 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
1552
1553 /* found a matched entry */
1554 EntryStatus = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
1555 if (!((1U == NumOfElement) && (EntryStatus != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID)))
1556 {
1557 status = E_NOT_OK;
1558 }
1559 }
1560 else
1561 {
1562 status = E_NOT_OK;
1563 }
1564
1565 return status;
1566 }
1567
1568 #if (NETC_ETHSWT_NUMBER_OF_RP_ENTRIES > 0U)
1569 /*FUNCTION**********************************************************************
1570 *
1571 * Function Name : Netc_EthSwt_Ip_ConfigRP
1572 * Description : function for configuring the Rate Policer for the switch
1573 *
1574 *END**************************************************************************/
1575 static Std_ReturnType Netc_EthSwt_Ip_ConfigRP(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
1576 {
1577 Std_ReturnType status = E_OK;
1578 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
1579 uint32 RPIndex = 0U;
1580 uint32 MatchedEntries = 0UL;
1581 Netc_EthSwt_Ip_RatePolicerEntryDataType RPTableEntry = {0};
1582
1583 for (RPIndex = 0U; RPIndex < Config->NumberOfRPEntries; RPIndex++)
1584 {
1585 RPTableEntry = (*(Config->EthSwtRatePolicerEntries))[RPIndex];
1586 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntry(SwitchIdx, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &RPTableEntry);
1587
1588 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
1589 {
1590 status = E_NOT_OK;
1591 break;
1592 }
1593 }
1594
1595 return status;
1596 }
1597 #endif
1598
1599 #if (NETC_ETHSWT_NUMBER_OF_SGCL_ENTRIES > 0U)
1600 /*FUNCTION**********************************************************************
1601 *
1602 * Function Name : Netc_EthSwt_Ip_ConfigSGCL
1603 * Description : function for configuring the Stream Gate Control Lists for the switch
1604 *
1605 *END**************************************************************************/
1606 static Std_ReturnType Netc_EthSwt_Ip_ConfigSGCL(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
1607 {
1608 Std_ReturnType status = E_OK;
1609 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
1610 uint32 SGCLIndex = 0U;
1611 uint32 MatchedEntries = 0UL;
1612 Netc_EthSwt_Ip_SGCLTableDataType SGCLTableEntry = {0};
1613
1614 for (SGCLIndex = 0U; SGCLIndex < Config->NumberOfSGCLEntries; SGCLIndex++)
1615 {
1616 SGCLTableEntry = (*(Config->StreamGateControlListEntries))[SGCLIndex];
1617 CBDRStatus = Netc_EthSwt_Ip_AddStreamGateControlListTableEntry(SwitchIdx, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &SGCLTableEntry);
1618
1619 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
1620 {
1621 status = E_NOT_OK;
1622 break;
1623 }
1624 }
1625
1626 return status;
1627 }
1628 #endif
1629
1630 #if (NETC_ETHSWT_NUMBER_OF_SGI_ENTRIES > 0U)
1631 /*FUNCTION**********************************************************************
1632 *
1633 * Function Name : Netc_EthSwt_Ip_ConfigSGI
1634 * Description : function for configuring the Stream Gate Instance Table for the switch
1635 *
1636 *END**************************************************************************/
1637 static Std_ReturnType Netc_EthSwt_Ip_ConfigSGI(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
1638 {
1639 Std_ReturnType status = E_OK;
1640 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
1641 uint32 SGIIndex = 0U;
1642 uint32 MatchedEntries = 0UL;
1643 Netc_EthSwt_Ip_StreamGateInstanceEntryDataType SGITableEntry = {0};
1644
1645 for (SGIIndex = 0U; SGIIndex < Config->NumberOfSGIEntries; SGIIndex++)
1646 {
1647 SGITableEntry = (*(Config->StreamGateInstanceEntries))[SGIIndex];
1648 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateStreamGateInstanceTableEntry(SwitchIdx, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &SGITableEntry);
1649
1650 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
1651 {
1652 status = E_NOT_OK;
1653 break;
1654 }
1655 }
1656
1657 return status;
1658 }
1659 #endif
1660
1661 /*==================================================================================================
1662 * GLOBAL FUNCTIONS
1663 ==================================================================================================*/
1664
1665 /*FUNCTION**********************************************************************
1666 *
1667 * Function Name : Netc_EthSwt_Ip_SetPortMode
1668 * Description : function for setting the port mode
1669 * implements Netc_EthSwt_Ip_SetPortMode_Activity
1670 *END**************************************************************************/
1671 Std_ReturnType Netc_EthSwt_Ip_SetPortMode(uint8 SwitchIdx,
1672 uint8 SwitchPortIdx,
1673 boolean PortEnable)
1674 {
1675 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
1676 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1677 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
1678 #endif
1679
1680 (void) SwitchIdx;
1681
1682 if(TRUE == PortEnable)
1683 {
1684 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_07();
1685 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->POR &= ~(SW_PORT0_POR_TXDIS_MASK | SW_PORT0_POR_RXDIS_MASK);
1686
1687 /* Write the PM0_COMMAND_CONFIG only for the MAC ports */
1688 if (SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
1689 {
1690 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG |= (SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_RX_EN_MASK | \
1691 SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_TX_EN_MASK);
1692 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM1_COMMAND_CONFIG |= (SW_ETH_MAC_PORT0_PM1_COMMAND_CONFIG_RX_EN_MASK | \
1693 SW_ETH_MAC_PORT0_PM1_COMMAND_CONFIG_TX_EN_MASK);
1694 }
1695 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_07();
1696
1697 if (FALSE == Netc_EthSwt_Ip_PortVlanEnable[SwitchPortIdx])
1698 {
1699 /* Configure the VLAN filter hash default settings */
1700 IP_NETC__SW0_BASE->VFHTDECR0 |= (uint32)(1LU << ((uint32)SwitchPortIdx)); /* Add enabled ports to the default VLAN */
1701 }
1702 }
1703 else
1704 {
1705 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_07();
1706 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->POR |= (SW_PORT0_POR_TXDIS_MASK | SW_PORT0_POR_RXDIS_MASK);
1707
1708 /* Write the PM0_COMMAND_CONFIG only for the MAC ports */
1709 if (SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
1710 {
1711 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG &= ~(SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_RX_EN_MASK | \
1712 SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_TX_EN_MASK);
1713 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM1_COMMAND_CONFIG &= ~(SW_ETH_MAC_PORT0_PM1_COMMAND_CONFIG_RX_EN_MASK | \
1714 SW_ETH_MAC_PORT0_PM1_COMMAND_CONFIG_TX_EN_MASK);
1715 }
1716 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_07();
1717 }
1718
1719 return E_OK;
1720 }
1721
1722
1723 /*FUNCTION**********************************************************************
1724 *
1725 * Function Name : Netc_EthSwt_Ip_GetPortMode
1726 * Description : function for getting the port mode
1727 * implements Netc_EthSwt_Ip_GetPortMode_Activity
1728 *END**************************************************************************/
1729 Std_ReturnType Netc_EthSwt_Ip_GetPortMode(uint8 SwitchIdx,
1730 uint8 SwitchPortIdx,
1731 boolean *PortEnable)
1732 {
1733 uint32 macPortConfig;
1734 Std_ReturnType status = E_OK;
1735
1736 (void) SwitchIdx;
1737 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
1738 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1739 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
1740 #endif
1741
1742 if (SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
1743 {
1744 macPortConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG;
1745
1746 if ( (((SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_TX_EN_MASK & macPortConfig) >> SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_TX_EN_SHIFT) ^ \
1747 ((SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_RX_EN_MASK & macPortConfig) >> SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_RX_EN_SHIFT)) == 1UL
1748 ) /* Test for different mode for RX and TX with XOR */
1749 {
1750 *PortEnable = FALSE;
1751 status = E_NOT_OK;
1752 }
1753 else
1754 {
1755 if((macPortConfig & SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_TX_EN_MASK) == SW_ETH_MAC_PORT1_PM0_COMMAND_CONFIG_TX_EN_MASK)
1756 {
1757 *PortEnable = TRUE;
1758 }
1759 else
1760 {
1761 *PortEnable = FALSE;
1762 }
1763 }
1764 }
1765 else
1766 {
1767 if (0UL == (Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->POR & (SW_PORT0_POR_TXDIS_MASK | SW_PORT0_POR_RXDIS_MASK)))
1768 {
1769 *PortEnable = TRUE;
1770 }
1771 else
1772 {
1773 *PortEnable = FALSE;
1774 }
1775 }
1776
1777 return status;
1778 }
1779
1780 /*FUNCTION**********************************************************************
1781 *
1782 * Function Name : Netc_EthSwt_Ip_GetPortSpeed
1783 * Description : Ethernet Switch get baud rate function.
1784 * implements Netc_EthSwt_Ip_GetPortSpeed_Activity
1785 *END**************************************************************************/
1786 Std_ReturnType Netc_EthSwt_Ip_GetPortSpeed( uint8 SwitchIdx,
1787 uint8 SwitchPortIdx,
1788 EthTrcv_BaudRateType * BaudRate
1789 )
1790 {
1791 Std_ReturnType status = E_OK;
1792 uint32 interfaceModeConfig;
1793
1794 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
1795 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1796 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
1797 #endif
1798
1799 (void) SwitchIdx;
1800 if(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
1801 {
1802 interfaceModeConfig = (Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE);
1803
1804 switch((interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE_MASK) >> SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE_SHIFT)
1805 {
1806 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_MII_MODE: /* MII mode */
1807 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RMII_MODE: /* RMII mode */
1808 if((interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_M10_MASK) == SW_ETH_MAC_PORT1_PM0_IF_MODE_M10_MASK)
1809 {
1810 *BaudRate = ETHTRCV_BAUD_RATE_10MBIT;
1811 }
1812 else
1813 {
1814 *BaudRate = ETHTRCV_BAUD_RATE_100MBIT;
1815 }
1816 break;
1817 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RGMII_MODE: /* RGMII mode */
1818 switch((interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK) >> SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_SHIFT)
1819 {
1820 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT: /* 1000Mbps */
1821 *BaudRate = ETHTRCV_BAUD_RATE_1000MBIT;
1822 break;
1823 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT: /* 100Mbps */
1824 *BaudRate = ETHTRCV_BAUD_RATE_100MBIT;
1825 break;
1826 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT: /* 10Mbps */
1827 *BaudRate = ETHTRCV_BAUD_RATE_10MBIT;
1828 break;
1829 default:
1830 status = E_NOT_OK;
1831 break;
1832 }
1833 break;
1834 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_SGMII_MODE: /* RGMII mode */
1835 switch((interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_MASK) >> SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP_SHIFT)
1836 {
1837 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_2500MBIT: /* 2500Mbps */
1838 *BaudRate = ETHTRCV_BAUD_RATE_2500MBIT;
1839 break;
1840 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT: /* 1000Mbps */
1841 *BaudRate = ETHTRCV_BAUD_RATE_1000MBIT;
1842 break;
1843 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT: /* 100Mbps */
1844 *BaudRate = ETHTRCV_BAUD_RATE_100MBIT;
1845 break;
1846 case SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT: /* 10Mbps */
1847 *BaudRate = ETHTRCV_BAUD_RATE_10MBIT;
1848 break;
1849 default:
1850 status = E_NOT_OK;
1851 break;
1852 }
1853 break;
1854 default:
1855 status = E_NOT_OK;
1856 break;
1857 }
1858 }
1859 else
1860 {
1861 *BaudRate = ETHTRCV_BAUD_RATE_1000MBIT;
1862 }
1863
1864 return status;
1865 }
1866
1867 /*FUNCTION**********************************************************************
1868 *
1869 * Function Name : Netc_EthSwt_Ip_SetPortSpeed
1870 * Description : Ethernet Switch set baud rate function.
1871 * implements Netc_EthSwt_Ip_SetPortSpeed_Activity
1872 *END**************************************************************************/
1873 Std_ReturnType Netc_EthSwt_Ip_SetPortSpeed( uint8 SwitchIdx,
1874 uint8 SwitchPortIdx,
1875 EthTrcv_BaudRateType BaudRate
1876 )
1877 {
1878 Std_ReturnType status = E_OK;
1879 uint32 interfaceType;
1880 uint32 interfaceModeConfig = 0UL;
1881 uint32 shapingPSpeedConfig = 0UL; /* used for shaping of the port */
1882
1883 (void) SwitchIdx;
1884 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
1885 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1886 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
1887 #endif
1888
1889 if(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
1890 {
1891 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_01();
1892 interfaceModeConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE;
1893
1894 interfaceType = ((interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE_MASK) >> SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE_SHIFT) ;
1895 switch(interfaceType)
1896 {
1897 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_MII_MODE: /* MII mode */
1898 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RMII_MODE: /* RMII mode */
1899 {
1900 status = Netc_EthSwt_Ip_SetPortSpeed_MII_RMII_Mode(BaudRate, &interfaceModeConfig, &shapingPSpeedConfig);
1901 break;
1902 }
1903 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_RGMII_MODE: /* RGMII mode */
1904 {
1905 status = Netc_EthSwt_Ip_SetPortSpeed_RGMII_Mode(BaudRate, &interfaceModeConfig, &shapingPSpeedConfig);
1906 break;
1907 }
1908 case SW_ETH_MAC_PORT_PM0_IF_MODE_IFMODE_SGMII_MODE: /* SGMII mode */
1909 {
1910 status = Netc_EthSwt_Ip_SetPortSpeed_SGMII_Mode(BaudRate, &interfaceModeConfig, &shapingPSpeedConfig);
1911 break;
1912 }
1913 default:
1914 {
1915 status = E_NOT_OK;
1916 break;
1917 }
1918 }
1919 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE = interfaceModeConfig;
1920 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM1_IF_MODE = interfaceModeConfig;
1921
1922 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR &= ~SW_PORT0_PCR_PSPEED_MASK;
1923 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR |= SW_PORT0_PCR_PSPEED(shapingPSpeedConfig);
1924 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_01();
1925 }
1926 else
1927 {
1928 /* pseudo port */
1929 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_01();
1930 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR &= ~SW_PORT0_PCR_PSPEED_MASK;
1931 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCR |= SW_PORT0_PCR_PSPEED(NETC_ETHSWT_IP_SHAPING_PSPEED_2000MBITS);
1932 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_01();
1933 }
1934
1935 return status;
1936 }
1937
1938 /*FUNCTION**********************************************************************
1939 *
1940 * Function Name : Netc_EthSwt_Ip_GetDuplexMode
1941 * Description : Ethernet Switch get duplex mode function.
1942 * implements Netc_EthSwt_Ip_GetDuplexMode_Activity
1943 *END**************************************************************************/
1944 Std_ReturnType Netc_EthSwt_Ip_GetDuplexMode( uint8 SwitchIdx,
1945 uint8 SwitchPortIdx,
1946 EthTrcv_DuplexModeType * DuplexMode
1947 )
1948 {
1949 Std_ReturnType status = E_OK;
1950 uint32 interfaceModeConfig;
1951
1952 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
1953 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1954 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
1955 #endif
1956
1957 (void) SwitchIdx;
1958 if(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
1959 {
1960 interfaceModeConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE;
1961
1962 /* Full duplex is 0 in HD field */
1963 if (SW_ETH_MAC_PORT1_PM0_IF_MODE_HD_MASK == (interfaceModeConfig & SW_ETH_MAC_PORT1_PM0_IF_MODE_HD_MASK))
1964 {
1965 *DuplexMode = ETHTRCV_DUPLEX_MODE_HALF;
1966 }
1967 else /* ETHTRCV_DUPLEX_MODE_HALF */
1968 {
1969 *DuplexMode = ETHTRCV_DUPLEX_MODE_FULL;
1970 }
1971 }
1972 else
1973 {
1974 *DuplexMode = ETHTRCV_DUPLEX_MODE_FULL;
1975 }
1976
1977 return status;
1978 }
1979
1980 /*FUNCTION**********************************************************************
1981 *
1982 * Function Name : Netc_EthSwt_Ip_SetMacAddr
1983 * Description : This function sets the MAC address of a certain port of switch
1984 * implements Netc_EthSwt_Ip_SetMacAddr_Activity
1985 *END**************************************************************************/
1986 Std_ReturnType Netc_EthSwt_Ip_SetMacAddr(uint8 SwitchIdx, uint8 PortIndex, const uint8 *MacAddr)
1987 {
1988 Std_ReturnType status = E_OK;
1989
1990 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
1991 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
1992 DevAssert(PortIndex < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
1993 DevAssert(MacAddr != NULL_PTR);
1994 #endif
1995
1996 (void)SwitchIdx;
1997
1998 Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PMAR0 = (uint32)(MacAddr[0U]) | ((uint32)(MacAddr[1U]) << 8U) | ((uint32)(MacAddr[2U]) << 16U) | ((uint32)(MacAddr[3U]) << 24U);
1999 Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PMAR1 = (uint32)(MacAddr[4U]) | ((uint32)(MacAddr[5U]) << 8U);
2000
2001 return status;
2002 }
2003
2004 /*FUNCTION**********************************************************************
2005 *
2006 * Function Name : Netc_EthSwt_Ip_GetMacAddr
2007 * Description : This function reads the MAC address of a certain port
2008 * implements Netc_EthSwt_Ip_GetMacAddr_Activity
2009 *END**************************************************************************/
2010 void Netc_EthSwt_Ip_GetMacAddr(uint8 SwitchIdx, uint8 PortIndex, uint8 *MacAddr)
2011 {
2012 uint32 msbMacAddr;
2013 uint32 lsbMacAddr;
2014 uint8 macAddrIdx;
2015
2016 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2017 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2018 DevAssert(PortIndex < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
2019 DevAssert(MacAddr != NULL_PTR);
2020 #endif
2021
2022 (void)SwitchIdx;
2023
2024 /* read data from registers */
2025 msbMacAddr = Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PMAR0;
2026 lsbMacAddr = Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PMAR1;
2027
2028 /* copy mac address in the correct order */
2029 for (macAddrIdx = 0U; macAddrIdx < 4U; macAddrIdx++)
2030 {
2031 MacAddr[macAddrIdx] = (uint8)(msbMacAddr & NETC_ETHSWT_IP_0XFF_MASK);
2032 msbMacAddr >>= 8U;
2033 }
2034
2035 MacAddr[4U] = (uint8)(lsbMacAddr & NETC_ETHSWT_IP_0XFF_MASK);
2036 lsbMacAddr >>= 8U;
2037 MacAddr[5U] = (uint8)(lsbMacAddr & NETC_ETHSWT_IP_0XFF_MASK);
2038
2039 }
2040
2041 /*FUNCTION**********************************************************************
2042 *
2043 * Function Name : Netc_EthSwt_Ip_GetPortMacAddr
2044 * Description : Ethernet Switch get port MAC address function.
2045 * implements Netc_EthSwt_Ip_GetPortMacAddr_Activity
2046 *END**************************************************************************/
2047 Std_ReturnType Netc_EthSwt_Ip_GetPortMacAddr( uint8 SwitchIdx, uint16 Fid, const uint8 * MacAddr, uint8 * PortIdx )
2048 {
2049 Std_ReturnType status = E_OK;
2050 Netc_EthSwt_Ip_CBDRStatusType QueryStatus;
2051 uint8 PortIndex;
2052 uint8 NumOfMatchedPorts = 0U;
2053 uint8 MacByteIdx;
2054 uint32 NumOfMatchedElement = 0x0UL;
2055 Netc_EthSwt_Ip_FdbEntryDataType FdbTableEntry = {0U};
2056 Netc_EthSwt_Ip_PortMacAddrEntry PortMacAddrEntry = {FALSE, 0x00UL, MacAddr};
2057
2058 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2059 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2060 DevAssert(MacAddr != NULL_PTR);
2061 DevAssert(PortIdx != NULL_PTR);
2062 #endif
2063
2064 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
2065 {
2066 FdbTableEntry.MacAddr[MacByteIdx] = MacAddr[MacByteIdx];
2067 }
2068 FdbTableEntry.FID = Fid;
2069
2070 if (FdbTableEntry.FID == NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID)
2071 {
2072 QueryStatus = Netc_EthSwt_Ip_GetPortMacAddr_SecondPart(SwitchIdx, &NumOfMatchedElement, &FdbTableEntry, &PortMacAddrEntry);;
2073 }
2074 else
2075 {
2076 QueryStatus = Netc_EthSwt_Ip_QueryFdbTableEntry(SwitchIdx, &NumOfMatchedElement, &FdbTableEntry);
2077
2078 /* find a matched entry */
2079 if (1U == NumOfMatchedElement)
2080 {
2081 PortMacAddrEntry.MatchedEntryFound = TRUE;
2082 /* get the port bitmap value from Fdb table response data buffer */
2083 PortMacAddrEntry.PortBitMap = FdbTableEntry.SwitchPortEgressBitMask;
2084 }
2085 }
2086
2087 if (QueryStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
2088 {
2089 /* find a matched entry */
2090 if (TRUE == PortMacAddrEntry.MatchedEntryFound)
2091 {
2092 /* check matched port number */
2093 for (PortIndex = 0U; PortIndex < NETC_ETHSWT_IP_BITMAPLEN; PortIndex++)
2094 {
2095 if (1U == (PortMacAddrEntry.PortBitMap & (0x1U)))
2096 {
2097 NumOfMatchedPorts += 1U;
2098 *PortIdx = PortIndex;
2099 }
2100 PortMacAddrEntry.PortBitMap >>= 1U;
2101 }
2102
2103 /* no matched ports found */
2104 if (0U == NumOfMatchedPorts)
2105 {
2106 *PortIdx = NETC_ETHSWT_IP_NOMATCHEDPORTMACADDR;
2107 }
2108
2109 /* multiple matched ports found */
2110 if (NumOfMatchedPorts > 1U)
2111 {
2112 status = E_NOT_OK;
2113 *PortIdx = NETC_ETHSWT_IP_NOMATCHEDPORTMACADDR;
2114 }
2115 }
2116 else
2117 {
2118 /* no entry found */
2119 *PortIdx = NETC_ETHSWT_IP_NOMATCHEDPORTMACADDR;
2120 }
2121 }
2122 else
2123 {
2124 status = E_NOT_OK;
2125 }
2126
2127 return status;
2128 }
2129
2130 /*FUNCTION**********************************************************************
2131 *
2132 * Function Name : Netc_EthSwt_Ip_QueryFdbTableEntry
2133 * Description : Ethernet Switch query FDB table entry function.
2134 * implements Netc_EthSwt_Ip_QueryFdbTableEntry_Activity
2135 *END**************************************************************************/
2136 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryFdbTableEntry( uint8 SwitchIdx,
2137 uint32 *MatchedEntries,
2138 Netc_EthSwt_Ip_FdbEntryDataType * FdbTableEntry
2139 )
2140 {
2141 Netc_EthSwt_Ip_CBDRStatusType status;
2142 uint32 KeyeData[3U];
2143 uint32 ActionsData;
2144
2145 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2146 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2147 DevAssert(MatchedEntries != NULL_PTR);
2148 DevAssert(FdbTableEntry != NULL_PTR);
2149 #endif
2150
2151 /* clear the variable MatchedEntries first */
2152 *MatchedEntries = 0U;
2153
2154 /* always do the full query. 0x0 = Full query. */
2155 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY);
2156
2157 KeyeData[0U] = ((uint32)(FdbTableEntry->MacAddr[0U]) | ((uint32)(FdbTableEntry->MacAddr[1U]) << 8U) | ((uint32)(FdbTableEntry->MacAddr[2U]) << 16U) | ((uint32)(FdbTableEntry->MacAddr[3U]) << 24U));
2158 KeyeData[1U] = ((uint32)(FdbTableEntry->MacAddr[4U]) | ((uint32)(FdbTableEntry->MacAddr[5U]) << 8U));
2159 KeyeData[2U] = FdbTableEntry->FID;
2160
2161 /* no need CFGE_DATA and only use "NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH" as the access method */
2162 status = Netc_EthSwt_Ip_FillInFdbTableReqDataBuff(ActionsData, &KeyeData[0U], NULL_PTR, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
2163 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS == status)
2164 {
2165 /* fill in operation data for config field of Request Header*/
2166 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2167 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2168 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
2169 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH; /* for query command, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
2170 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
2171 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN); /* set request data buffer length */
2172 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_FDBTABLE_RESBUFFER_LEN); /* set response data buffer with normal length */
2173
2174 /* send command */
2175 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
2176 #if defined(ERR_IPV_NETC_051243)
2177 #if (STD_ON == ERR_IPV_NETC_051243)
2178 /* Error code 0x8A is not a real error. check it on Errata. */
2179 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
2180 {
2181 #endif
2182 #else
2183 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
2184 {
2185 #endif
2186 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
2187 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2188
2189 /* found a matched entry */
2190 Netc_EthSwt_Ip_QueryFdbTableEntry_FoundAMatchedEntry(*MatchedEntries, FdbTableEntry);
2191 }
2192 }
2193 else
2194 {
2195 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
2196 }
2197
2198
2199 return status;
2200 }
2201
2202
2203
2204 /*FUNCTION**********************************************************************
2205 *
2206 * Function Name : Netc_EthSwt_Ip_DeleteFdbTableEntry
2207 * Description : Ethernet Switch delete FDB table entry function.
2208 * implements Netc_EthSwt_Ip_DeleteFdbTableEntry_Activity
2209 *END**************************************************************************/
2210 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteFdbTableEntry( uint8 SwitchIdx,
2211 uint32 *MatchedEntries,
2212 const Netc_EthSwt_Ip_FdbEntryDataType * FdbTableEntry
2213 )
2214 {
2215 Netc_EthSwt_Ip_CBDRStatusType status;
2216 uint32 KeyeData[3U];
2217 uint32 ActionsData = 0U;
2218
2219 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2220 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2221 DevAssert(MatchedEntries != NULL_PTR);
2222 DevAssert(FdbTableEntry != NULL_PTR);
2223 #endif
2224
2225 /* clear the variable MatchedEntries first */
2226 *MatchedEntries = 0U;
2227
2228 /* Delete command will ignore ActionsData data field */
2229 KeyeData[0U] = ((uint32)(FdbTableEntry->MacAddr[0U]) | ((uint32)(FdbTableEntry->MacAddr[1U]) << 8U) | ((uint32)(FdbTableEntry->MacAddr[2U]) << 16U) | ((uint32)(FdbTableEntry->MacAddr[3U]) << 24U));
2230 KeyeData[1U] = ((uint32)(FdbTableEntry->MacAddr[4U]) | ((uint32)(FdbTableEntry->MacAddr[5U]) << 8U));
2231 KeyeData[2U] = FdbTableEntry->FID;
2232
2233 /* no need CFGE_DATA and only use "NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH" as the access method */
2234 status = Netc_EthSwt_Ip_FillInFdbTableReqDataBuff(ActionsData, &KeyeData[0U], NULL_PTR, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
2235 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS == status)
2236 {
2237 /* fill in operation data for config field of Request Header*/
2238 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2239 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2240 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
2241 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH; /* for delete command, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
2242 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
2243 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN); /* set request data buffer length */
2244 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
2245
2246 /* send the "Delete" command */
2247 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
2248 #if defined(ERR_IPV_NETC_051243)
2249 #if (STD_ON == ERR_IPV_NETC_051243)
2250 /* Error code 0x8A is not a real error. check it on Errata. */
2251 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
2252 {
2253 #endif
2254 #else
2255 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
2256 {
2257 #endif
2258 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
2259 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2260 }
2261 }
2262 else
2263 {
2264 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
2265 }
2266
2267
2268 return status;
2269 }
2270
2271 /*FUNCTION**********************************************************************
2272 *
2273 * Function Name : Netc_EthSwt_Ip_AddOrUpdateFdbTableEntry
2274 * Description : Ethernet Switch Add or Update FDB table entry function.
2275 * implements Netc_EthSwt_Ip_AddOrUpdateFdbTableEntry_Activity
2276 *END**************************************************************************/
2277 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateFdbTableEntry( uint8 SwitchIdx,
2278 Netc_EthSwt_Ip_CommandsType Cmd,
2279 uint32 *MatchedEntries,
2280 const Netc_EthSwt_Ip_FdbEntryDataType * FdbTableEntry
2281 )
2282 {
2283 Netc_EthSwt_Ip_CBDRStatusType status;
2284 uint32 KeyeData[3U];
2285 uint32 ActionsData;
2286 Netc_EthSwt_Ip_FDBTableCFGEDataType CfgeData;
2287
2288 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2289 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2290 DevAssert(FdbTableEntry != NULL_PTR);
2291 DevAssert(MatchedEntries != NULL_PTR);
2292 #endif
2293
2294 /* clear the variable MatchedEntries first */
2295 *MatchedEntries = 0U;
2296
2297 /* only support Add, Update and AddOrUpdate commands */
2298 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd) && (NETC_ETHSWT_ADD_OR_UPDATE_CMD != Cmd))
2299 {
2300 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
2301 }
2302 else
2303 {
2304 /* set ACTEU and CFGEU flag */
2305 ActionsData = (NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(1U) \
2306 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U));
2307
2308 KeyeData[0U] = ((uint32)(FdbTableEntry->MacAddr[0U]) | ((uint32)(FdbTableEntry->MacAddr[1U]) << 8U) | ((uint32)(FdbTableEntry->MacAddr[2U]) << 16U) | ((uint32)(FdbTableEntry->MacAddr[3U]) << 24U));
2309 KeyeData[1U] = ((uint32)(FdbTableEntry->MacAddr[4U]) | ((uint32)(FdbTableEntry->MacAddr[5U]) << 8U));
2310 KeyeData[2U] = FdbTableEntry->FID;
2311
2312 CfgeData.Cfge_PortBitmap = NETC_ETHSWT_IP_FDBTABLE_CFGE_PORT_BITMAP(FdbTableEntry->SwitchPortEgressBitMask);
2313 CfgeData.Cfge_ConfigField = (NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE(FdbTableEntry->TimeStampCapture ? 1U : 0U) \
2314 | NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC(FdbTableEntry->DynamicEntry ? 1U : 0U) \
2315 | NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD(FdbTableEntry->CutThroughDisable) \
2316 | NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE(FdbTableEntry->IngressMirroringEnable ? 1U : 0U) \
2317 | NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT(FdbTableEntry->EgressPort) \
2318 | NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_OETEID(FdbTableEntry->OverridETEID));
2319
2320 CfgeData.Cfge_EtEid = FdbTableEntry->ET_EID;
2321
2322 /* only supports "NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH" access method */
2323 status = Netc_EthSwt_Ip_FillInFdbTableReqDataBuff(ActionsData, &KeyeData[0U], &CfgeData, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
2324 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS == status)
2325 {
2326 /* fill in operation data for config field of Request Header*/
2327 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2328 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2329 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
2330 Netc_EthSwt_Ip_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 */
2331 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
2332 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_REQBUFFER_LEN);
2333 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
2334
2335 /* send command */
2336 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
2337 #if defined(ERR_IPV_NETC_051243)
2338 #if (STD_ON == ERR_IPV_NETC_051243)
2339 /* Error code 0x8A is not a real error. check it on Errata. */
2340 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
2341 {
2342 #endif
2343 #else
2344 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
2345 {
2346 #endif
2347 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
2348 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2349 }
2350 }
2351 else
2352 {
2353 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
2354 }
2355 }
2356
2357 return status;
2358 }
2359
2360 /* inline function for verifying conditions in function Netc_EthSwt_Ip_FillInFdbTableListData() */
2361 static inline void Netc_EthSwt_Ip_VerifyFillInFdbTableListDataFuncCond(const uint32 *ResumeId, Netc_EthSwt_Ip_FdbEntryQuerying* const FdbEntryQuerying)
2362 {
2363 if ((NETC_ETHSWT_IP_BD_NULL_ENTRY_ID == *ResumeId) && (NULL_PTR != FdbEntryQuerying))
2364 {
2365 switch (*FdbEntryQuerying)
2366 {
2367 case NETC_ETHSWT_IP_FDB_STATIC_ENTRY_QUERY_SEARCH:
2368 {
2369 *FdbEntryQuerying = NETC_ETHSWT_IP_FDB_DYNAMIC_ENTRY_QUERY_SEARCH;
2370 break;
2371 }
2372 case NETC_ETHSWT_IP_FDB_DYNAMIC_ENTRY_QUERY_SEARCH:
2373 {
2374 *FdbEntryQuerying = NETC_ETHSWT_IP_FDB_DONE_ENTRY_QUERY_SEARCH;
2375 break;
2376 }
2377 default:
2378 {
2379 *FdbEntryQuerying = NETC_ETHSWT_IP_FDB_DONE_ENTRY_QUERY_SEARCH;
2380 break;
2381 }
2382 }
2383 }
2384 }
2385
2386 /*FUNCTION**********************************************************************
2387 *
2388 * Function Name : Netc_EthSwt_Ip_SearchAndFillInFdbTableList
2389 * Description : inline function for searching and filling in FdbTableList data in function Netc_EthSwt_Ip_GetFdbTable().
2390 *
2391 *END**************************************************************************/
2392 static inline Std_ReturnType Netc_EthSwt_Ip_SearchAndFillInFdbTableList(uint32 *ResumeId, uint16 *NumOfExistingEntry, Netc_EthSwt_Ip_FdbEntryDataType *FdbTableList,
2393 Netc_EthSwt_Ip_FdbEntryQuerying* const FdbEntryQuerying)
2394 {
2395 Std_ReturnType status = E_OK;
2396 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
2397 uint32 NumOfElement = 0U;
2398 uint32 MacAddrL;
2399 uint32 MacAddrH;
2400 uint32 CfgeData;
2401 uint8 MacAddrByteIdx;
2402 uint32 ActionsData;
2403
2404 /* set the query options with full query */
2405 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
2406 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U) \
2407 | NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(0U) \
2408 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(0U);
2409
2410 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_46();
2411 /* fill in FdbTabeDataBuffer for request */
2412 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData;
2413 /* fill in Access Key data with search criteria data format */
2414 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_RESUMEENTRYID] = *ResumeId; /* resume entry id */
2415 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MACADDRESS_L] = 0U;
2416 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MACADDRESS_H] = 0U;
2417 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_FID] = 0U;
2418 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_PORTBITMAP] = 0U;
2419 /* 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 */
2420 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_CFGECONFIG] = (NETC_ETHSWT_IP_FDB_STATIC_ENTRY_QUERY_SEARCH == *FdbEntryQuerying) ? NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC(0U) : NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC(1U);
2421
2422 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ETEID] = 0U;
2423 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_CFGEMC(1U); /* 0x1: Match CFGE_DATA[DYNAMIC] field */
2424
2425 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_46();
2426 /* do the full query with Search Method */
2427 /* fill in operation data for config field of Request Header*/
2428 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2429 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2430 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
2431 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
2432 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
2433 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN);
2434 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_FDBTABLE_RESBUFFER_LEN); /* full query needs more space for response data */
2435
2436 /* send the "Query" command */
2437 /* [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. */
2438 CBDRStatus = Netc_EthSwt_Ip_SendCommand(0U, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
2439
2440 #if defined(ERR_IPV_NETC_051243)
2441 #if (STD_ON == ERR_IPV_NETC_051243)
2442 /* check the status of query command */
2443 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
2444 {
2445 #endif
2446 #else
2447 if (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
2448 {
2449 #endif
2450 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
2451
2452 /* get the resume_entry_id and be ready for the next query operation */
2453 *ResumeId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
2454 /* ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED */
2455 /* found a matched entry */
2456 if ((1U == NumOfElement) && (*ResumeId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
2457 {
2458 /* fill in "Netc_EthSwt_Ip_FdbEntryDataType" structure with data in response data buffer */
2459 MacAddrL = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_L];
2460 MacAddrH = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_H];
2461 for (MacAddrByteIdx = 0U; MacAddrByteIdx < 4U; MacAddrByteIdx++ )
2462 {
2463 FdbTableList[(*NumOfExistingEntry)].MacAddr[MacAddrByteIdx] = (uint8)(MacAddrL & NETC_ETHSWT_IP_0XFF_MASK);
2464 MacAddrL >>= 8U;
2465 }
2466 FdbTableList[(*NumOfExistingEntry)].MacAddr[4U] = (uint8)(MacAddrH & NETC_ETHSWT_IP_0XFF_MASK);
2467 FdbTableList[(*NumOfExistingEntry)].MacAddr[5U] = (uint8)((MacAddrH >> 8U) & NETC_ETHSWT_IP_0XFF_MASK);
2468
2469 FdbTableList[(*NumOfExistingEntry)].FID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_FID] & NETC_ETHSWT_IP_FDBTABLE_KEYE_DATA_FID_MASK);
2470 FdbTableList[(*NumOfExistingEntry)].SwitchPortEgressBitMask = (TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_PORTBITMAP] & NETC_ETHSWT_IP_FDBTABLE_CFGE_PORT_BITMAP_MASK);
2471
2472 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_CFGECONFIG];
2473 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;
2474 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;
2475 FdbTableList[(*NumOfExistingEntry)].CutThroughDisable = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_SHIFT);
2476 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;
2477 FdbTableList[(*NumOfExistingEntry)].EgressPort = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_SHIFT);
2478 FdbTableList[(*NumOfExistingEntry)].OverridETEID = (uint8)(CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_OETEID_MASK);
2479
2480 FdbTableList[(*NumOfExistingEntry)].ET_EID = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_ETEID];
2481
2482 /* increase the NumOfExistingEntry */
2483 (*NumOfExistingEntry) += 1U;
2484 }
2485
2486 Netc_EthSwt_Ip_VerifyFillInFdbTableListDataFuncCond(ResumeId, FdbEntryQuerying);
2487 }
2488 else
2489 {
2490 status = E_NOT_OK;
2491 }
2492
2493 return status;
2494 }
2495
2496 /*FUNCTION**********************************************************************
2497 *
2498 * Function Name : Netc_EthSwt_Ip_GetFdbTable
2499 * Description : Ethernet Switch get FDB table function.
2500 * implements Netc_EthSwt_Ip_GetFdbTable_Activity
2501 *END**************************************************************************/
2502 Std_ReturnType Netc_EthSwt_Ip_GetFdbTable( uint8 SwitchIdx,
2503 uint16 * NumberOfElements,
2504 Netc_EthSwt_Ip_FdbEntryDataType * FdbTableList
2505 )
2506 {
2507 Std_ReturnType status = E_OK;
2508 uint16 NumOfExistingEntry = 0U;
2509 uint16 NumOfInUseEntry;
2510 uint32 ResumeId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
2511
2512 Netc_EthSwt_Ip_FdbEntryQuerying FdbEntryQuerying = NETC_ETHSWT_IP_FDB_STATIC_ENTRY_QUERY_SEARCH;
2513
2514 /* [notes]: we will have to read entries one by one because of the errata ERR051048.
2515 - ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED
2516 - Description: The NUM_MATCHED field in the command NTMP response header may be incorrect when
2517 the search access method is used for the following tables: FDB table 15, L2 IPv4 Multicast
2518 Filter table 16, VLAN Filter table 18, Ingress Stream Identification table 30, or Ingress Stream
2519 Filter table 32.
2520 - Workaround: For the query command, limit the message response buffer size (RESPONSE_LENGTH field in the request header)
2521 so that NETC returns no more than one entry at a time. Under this condition, the NUM_MATCHED field value is correct
2522 */
2523
2524 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2525 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2526 DevAssert(NumberOfElements != NULL_PTR);
2527 if (*NumberOfElements > 0U)
2528 {
2529 DevAssert(FdbTableList != NULL_PTR);
2530 }
2531 #endif
2532
2533 (void)SwitchIdx;
2534 /*
2535 * Number of static FDB entries in-use (hash-based and CAM-based entries) is indicated in FDBHTOR0[STATIC_ENTRIES].
2536 * Number of dynamic FDB entries in-use (hash-based and CAMbased entries) is indicated in FDBHTOR1[DYN_ENTRIES].
2537 */
2538 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 */
2539
2540 /* if *NumberOfElements == 0U or NumOfInUseEntry == 0U, return the NumOfInUseEntry directly and will not do the query and fill in the structure */
2541 if ((*NumberOfElements == 0U) || (NumOfInUseEntry == 0U))
2542 {
2543 NumOfExistingEntry = NumOfInUseEntry;
2544 }
2545 else /* if *NumberOfElements > 0, do the query and fill in the structure */
2546 {
2547 do
2548 {
2549 /* check if the FdbTableList is full or we get all existing entries */
2550 if ((NumOfExistingEntry >= *NumberOfElements) || (NumOfExistingEntry >= NumOfInUseEntry) || (status == (uint8)(E_NOT_OK)))
2551 {
2552 break;
2553 }
2554
2555 status = Netc_EthSwt_Ip_SearchAndFillInFdbTableList(&ResumeId, &NumOfExistingEntry, FdbTableList, &FdbEntryQuerying);
2556
2557 } while ((TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS] != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID) || (NETC_ETHSWT_IP_FDB_DONE_ENTRY_QUERY_SEARCH != FdbEntryQuerying)); /* Status == MAX_32BIT means the query operation is completed */
2558 }
2559
2560 /* return the Number of elements which are currently available in the EthSwitch module or number of elements copied to FdbTableList*/
2561 *NumberOfElements = NumOfExistingEntry;
2562
2563 return status;
2564 }
2565
2566 /* inline function for filling in TableDataBuff in Netc_EthSwt_Ip_SearchFdbTable() function. */
2567 static inline void Netc_EthSwt_Ip_FillInTableDataBuffForSearchingFDBTable(const uint32 * ActionsData, const uint32 * ResumeEntryId, const Netc_EthSwt_Ip_FDBTableSearchCriteriaDataType * SearchCriteriaData)
2568 {
2569 uint8 MatchCriteriaData;
2570
2571 /* +++ fill in FdbTabeDataBuffer for request +++ */
2572 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = *ActionsData;
2573
2574 /* fill in Access Key data with search criteria data format */
2575 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_RESUMEENTRYID] = *ResumeEntryId; /* ResumeEntryId should start from MAX_32BIT */
2576 /* no need to fill in ETEID data for searching purpose */
2577 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ETEID] = 0U;
2578
2579 /* remap and fill in Match Criteria flag */
2580 if (SearchCriteriaData->SearchMatchCriteria >= NETC_ETHSWT_IP_FDBTABLE_MATCH_KEYE_FID_FIELD)
2581 {
2582 MatchCriteriaData = ((uint8)(SearchCriteriaData->SearchMatchCriteria) - NETC_ETHSWT_IP_FDBTABLE_KEYE_MATCH_CRITERIA_ADJUSTING_FACTOR);
2583 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_KEYEMC(MatchCriteriaData);
2584
2585 /* fill in Key Element Match Criteria data */
2586 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MACADDRESS_L] = NETC_ETHSWT_IP_MULTICASTBIT_OF_MAC_ADDRESS(SearchCriteriaData->SearchKeyeData.SearchMulticastMacAddr ? 1U : 0U);
2587 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_FID] = SearchCriteriaData->SearchKeyeData.SearchFid;
2588 }
2589 else if (SearchCriteriaData->SearchMatchCriteria >= NETC_ETHSWT_IP_FDBTABLE_MATCH_CFGE_DYNAMIC_FIELD)
2590 {
2591 MatchCriteriaData = ((uint8)(SearchCriteriaData->SearchMatchCriteria) - NETC_ETHSWT_IP_FDBTABLE_CFGE_MATCH_CRITERIA_ADJUSTING_FACTOR);
2592 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_CFGEMC(MatchCriteriaData);
2593
2594 /* fill in CFGE Match Criteria data*/
2595 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_PORTBITMAP] = SearchCriteriaData->SearchCfgeData.SearchPortBitMap;
2596 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_CFGECONFIG] = NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC(SearchCriteriaData->SearchCfgeData.SearchDynamicEntry ? 1U : 0U);
2597 }
2598 else if (SearchCriteriaData->SearchMatchCriteria == NETC_ETHSWT_IP_FDBTABLE_MATCH_ACTE_DATA_FIELD)
2599 {
2600 MatchCriteriaData = (uint8)(SearchCriteriaData->SearchMatchCriteria);
2601 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ACTEMC(MatchCriteriaData);
2602 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_08();
2603 /* fill in ACTE Match Criteria data*/
2604 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] |= (NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ACTCNT(SearchCriteriaData->SearchActeData.ActivityCounter) \
2605 | NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ACTFLAG(SearchCriteriaData->SearchActeData.ActivityFlag ? 1U : 0U));
2606 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_08();
2607 }
2608 else
2609 {
2610 /* MATCH_ANY_CRITERIA */
2611 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = 0x0UL;
2612 }
2613
2614 /* --- fill in FdbTabeDataBuffer for request --- */
2615 }
2616 /*FUNCTION**********************************************************************
2617 *
2618 * Function Name : Netc_EthSwt_Ip_SearchFdbTable
2619 * Description : Ethernet Switch search FDB table one by one.
2620 * implements Netc_EthSwt_Ip_SearchFdbTable_Activity
2621 *END**************************************************************************/
2622 Std_ReturnType Netc_EthSwt_Ip_SearchFdbTable( uint8 SwitchIdx,
2623 uint32 * ResumeEntryId,
2624 const Netc_EthSwt_Ip_FDBTableSearchCriteriaDataType * SearchCriteriaData,
2625 Netc_EthSwt_Ip_FdbEntryDataType * FdbTableEntry
2626 )
2627 {
2628 Std_ReturnType status = E_OK;
2629 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
2630 uint8 MacBeyteIdx;
2631 uint32 MacAddrL;
2632 uint32 MacAddrH;
2633 uint32 CfgeData;
2634 uint32 NumOfElement = 0U;
2635 uint32 TableEntryId;
2636 uint32 ActionsData;
2637
2638 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2639 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2640 DevAssert(SearchCriteriaData != NULL_PTR);
2641 DevAssert(SearchCriteriaData->SearchMatchCriteria <= (NETC_ETHSWT_IP_FDBTABLE_MATCH_KEYE_FID_AND_MULTICAST_BIT_OF_MACADDR));
2642 DevAssert(FdbTableEntry != NULL_PTR);
2643 #endif
2644
2645 /* +++ fill in FdbTabeDataBuffer for request +++ */
2646 /* set the query options with full query */
2647 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
2648 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U) \
2649 | NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(0U) \
2650 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(0U);
2651 Netc_EthSwt_Ip_FillInTableDataBuffForSearchingFDBTable(&ActionsData, ResumeEntryId, SearchCriteriaData);
2652 /* --- fill in FdbTabeDataBuffer for request --- */
2653
2654 /* do the full query with Search Method */
2655 /* fill in operation data for config field of Request Header*/
2656 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2657 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2658 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
2659 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
2660 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
2661 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN);
2662 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_FDBTABLE_RESBUFFER_LEN); /* full query needs more space for response data */
2663
2664 /* send the "Query" command */
2665 /* [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. */
2666 CBDRStatus = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
2667
2668 #if defined(ERR_IPV_NETC_051243)
2669 #if (STD_ON == ERR_IPV_NETC_051243)
2670 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
2671 {
2672 #endif
2673 #else
2674 if (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
2675 {
2676 #endif
2677 /* check if found a matched entry */
2678 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
2679
2680 /* found a matched entry */
2681 TableEntryId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
2682 if ((1U == NumOfElement) && (TableEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
2683 {
2684 /* fill in "Netc_EthSwt_Ip_FdbEntryDataType" structure with data in response data buffer */
2685 MacAddrL = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_L];
2686 MacAddrH = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_MACADDRESS_H];
2687 for (MacBeyteIdx = 0U; MacBeyteIdx < 4U; MacBeyteIdx++ )
2688 {
2689 FdbTableEntry->MacAddr[MacBeyteIdx] = (uint8)(MacAddrL & NETC_ETHSWT_IP_0XFF_MASK);
2690 MacAddrL >>= 8U;
2691 }
2692 FdbTableEntry->MacAddr[4U] = (uint8)(MacAddrH & NETC_ETHSWT_IP_0XFF_MASK);
2693 FdbTableEntry->MacAddr[5U] = (uint8)((MacAddrH >> 8U) & NETC_ETHSWT_IP_0XFF_MASK);
2694
2695 FdbTableEntry->FID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_FID] & NETC_ETHSWT_IP_FDBTABLE_KEYE_DATA_FID_MASK);
2696 FdbTableEntry->SwitchPortEgressBitMask = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_PORTBITMAP] & NETC_ETHSWT_IP_FDBTABLE_CFGE_PORT_BITMAP_MASK;
2697
2698 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_CFGECONFIG];
2699 FdbTableEntry->TimeStampCapture = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_TIMECAPE_SHIFT) == 0x0UL) ? FALSE : TRUE;
2700 FdbTableEntry->DynamicEntry = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_DYNAMIC_SHIFT) == 0x0UL) ? FALSE : TRUE;
2701 FdbTableEntry->CutThroughDisable = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_CTD_SHIFT);
2702 FdbTableEntry->IngressMirroringEnable = (((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_IMIRE_SHIFT) == 0x0UL) ? FALSE : TRUE;
2703 FdbTableEntry->EgressPort = (uint8)((CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_MASK) >> NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_EPORT_SHIFT);
2704 FdbTableEntry->OverridETEID = (uint8)(CfgeData & NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD_OETEID_MASK);
2705
2706 FdbTableEntry->ET_EID = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_ETEID];
2707 }
2708
2709 /* get the resume_entry_id and be ready for the next query operation */
2710 /* [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 */
2711 *ResumeEntryId = TableDataBuffer.TableDataField[NETC_ETHSWT_FDBTABLE_RSPDATA_STATUS];
2712 }
2713 else
2714 {
2715 status = E_NOT_OK;
2716 }
2717
2718 return status;
2719 }
2720
2721 /* inline function for searching and filling in VlanFilterTableList in function Netc_EthSwt_Ip_GetVlanFilterTable() */
2722 static inline Std_ReturnType Netc_EthSwt_Ip_SearchAndFIllInVlanFilterTableList(uint32 *ResumeId, uint16 *NumOfExistingEntry, Netc_EthSwt_Ip_VlanFilterEntryDataType * VlanFilterTableList)
2723 {
2724 Std_ReturnType status = E_OK;
2725 uint32 ActionsData;
2726 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
2727 uint32 NumOfElement = 0U;
2728 uint32 CfgeData;
2729
2730 /* set the query options with full query */
2731 ActionsData = (NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
2732 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U));
2733 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_48();
2734
2735 /* fill in TabeDataBuffer for request */
2736 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData;
2737 /* fill in Access Key data with search criteria data format */
2738 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_REQFMT_RESUMEENTRYID_FIELD] = *ResumeId; /* resume entry id */
2739 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_48();
2740
2741 /* do the full query with Search Method */
2742 /* fill in operation data for config field of Request Header*/
2743 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2744 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2745 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_VLAN_FILTER_TABLE_ID;
2746 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
2747 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
2748 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
2749 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_VLANFILTERTABLE_RESBUFFER_LEN); /* full query needs more space for response data */
2750
2751 /* send the "Query" command */
2752 /* [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. */
2753 CBDRStatus = Netc_EthSwt_Ip_SendCommand(0U, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
2754
2755 #if defined(ERR_IPV_NETC_051243)
2756 #if (STD_ON == ERR_IPV_NETC_051243)
2757 /* check the status of query command */
2758 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
2759 {
2760 #endif
2761 #else
2762 if (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
2763 {
2764 #endif
2765 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
2766
2767 /* get the resume_entry_id and be ready for the next query operation */
2768 *ResumeId = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_RSPDATA_STATUS];
2769
2770 /* ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED */
2771 /* found a matched entry */
2772 if ((1U == NumOfElement) && (*ResumeId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
2773 {
2774 /* fill in "Netc_EthSwt_Ip_VlanFilterEntryDataType" structure with data in response data buffer */
2775 VlanFilterTableList[(*NumOfExistingEntry)].VlanID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_VID] & NETC_ETHSWT_IP_VLANFILTERTABLE_KEYEDATA_VID_MASK);
2776
2777 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA0];
2778 VlanFilterTableList[(*NumOfExistingEntry)].SpanningTreeGroupMemberId = (uint8)((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_STG_ID_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_STG_ID_SHIFT);
2779 VlanFilterTableList[(*NumOfExistingEntry)].PortMembershipBitmap = (CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_PORT_MEMBERSHIP_MASK);
2780
2781 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1];
2782 VlanFilterTableList[(*NumOfExistingEntry)].FID = (uint16)(CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_FID_MASK);
2783 VlanFilterTableList[(*NumOfExistingEntry)].MacLearningOptions = (uint8)((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MLO_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MLO_SHIFT);
2784 VlanFilterTableList[(*NumOfExistingEntry)].MacForwardingOptions = (uint8)((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MFO_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MFO_SHIFT);
2785 VlanFilterTableList[(*NumOfExistingEntry)].IpMulticastFilteringEnable = (((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFE_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFE_SHIFT) == 0x0UL) ? FALSE : TRUE;
2786 VlanFilterTableList[(*NumOfExistingEntry)].IpMulticastFloodingEnable = (((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFLE_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFLE_SHIFT) == 0x0UL) ? FALSE : TRUE;
2787
2788 VlanFilterTableList[(*NumOfExistingEntry)].EgressTreatmentApplicabilityPortBitmap = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA2] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_ETA_PORT_BITMAP_MASK;
2789 VlanFilterTableList[(*NumOfExistingEntry)].BaseEgressTreatmentEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA3];
2790
2791 /* increase the NumOfExistingEntry */
2792 (*NumOfExistingEntry) += 1U;
2793 }
2794 }
2795 else
2796 {
2797 status = E_NOT_OK;
2798 }
2799
2800 return status;
2801 }
2802
2803 /*FUNCTION**********************************************************************
2804 *
2805 * Function Name : Netc_EthSwt_Ip_GetVlanFilterTable
2806 * Description : Ethernet Switch get Vlan Filter table function.
2807 * implements Netc_EthSwt_Ip_GetVlanFilterTable_Activity
2808 *END**************************************************************************/
2809 Std_ReturnType Netc_EthSwt_Ip_GetVlanFilterTable( uint8 SwitchIdx,
2810 uint16 * NumberOfElements,
2811 Netc_EthSwt_Ip_VlanFilterEntryDataType * VlanFilterTableList
2812 )
2813 {
2814 Std_ReturnType status = E_OK;
2815 uint16 NumOfExistingEntry = 0U;
2816 uint16 NumOfInUseEntry;
2817 uint32 ResumeId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
2818
2819 /* [notes]: we will have to read entries one by one because of the errata ERR051048.
2820 - ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED
2821 - Description: The NUM_MATCHED field in the command NTMP response header may be incorrect when
2822 the search access method is used for the following tables: FDB table 15, L2 IPv4 Multicast
2823 Filter table 16, VLAN Filter table 18, Ingress Stream Identification table 30, or Ingress Stream
2824 Filter table 32.
2825 - Workaround: For the query command, limit the message response buffer size (RESPONSE_LENGTH field in the request header)
2826 so that NETC returns no more than one entry at a time. Under this condition, the NUM_MATCHED field value is correct
2827 */
2828
2829 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2830 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2831 DevAssert(NumberOfElements != NULL_PTR);
2832 if (*NumberOfElements > 0U)
2833 {
2834 DevAssert(VlanFilterTableList != NULL_PTR);
2835 }
2836 #endif
2837
2838 (void)SwitchIdx;
2839 /* Number of entries in-use by the VLAN Filter table is indicated in VFHTOR[NUM_ENTRIES]. */
2840 NumOfInUseEntry = (uint16)(IP_NETC__SW0_BASE->VFHTOR & NETC_ETHSWT_IP_0XFFFF_MASK); /* get how many entries exist in module */
2841
2842 /* if *NumberOfElements == 0U or NumOfInUseEntry == 0U, return the NumOfInUseEntry directly and will not do the query and fill in the structure */
2843 if ((*NumberOfElements == 0U) || (NumOfInUseEntry == 0U))
2844 {
2845 NumOfExistingEntry = NumOfInUseEntry;
2846 }
2847 else /* if *NumberOfElements > 0, do the query and fill in the structure */
2848 {
2849 do {
2850 /* check if the VlanFilterTableList is full or we get all existing entries */
2851 if ((NumOfExistingEntry >= *NumberOfElements) || (NumOfExistingEntry >= NumOfInUseEntry) || (status == (uint8)(E_NOT_OK)))
2852 {
2853 break;
2854 }
2855
2856 status = Netc_EthSwt_Ip_SearchAndFIllInVlanFilterTableList(&ResumeId, &NumOfExistingEntry, VlanFilterTableList);
2857 } while (TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_RSPDATA_STATUS] != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID); /* Status == MAX_32BIT means the query operation is completed */
2858 }
2859
2860 /* return the Number of elements which are currently available in the EthSwitch module or number of elements copied to VlanFilterTableList*/
2861 *NumberOfElements = NumOfExistingEntry;
2862
2863 return status;
2864 }
2865
2866 /*FUNCTION**********************************************************************
2867 *
2868 * Function Name : Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry
2869 * Description : Ethernet Switch add, update or addorupdate Vlan Filter table entry function.
2870 * implements Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry_Activity
2871 *END**************************************************************************/
2872 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry( uint8 SwitchIdx,
2873 Netc_EthSwt_Ip_CommandsType Cmd,
2874 uint32 *MatchedEntries,
2875 const Netc_EthSwt_Ip_VlanFilterEntryDataType * VlanFilterTableEntry
2876 )
2877 {
2878 Netc_EthSwt_Ip_CBDRStatusType status;
2879 uint32 AccessKeyData;
2880 uint32 ActionsData;
2881 Netc_EthSwt_Ip_VlanFilterTableCFGEDataType VlanFilterCfgeData;
2882
2883 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2884 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2885 DevAssert(MatchedEntries != NULL_PTR);
2886 DevAssert(VlanFilterTableEntry != NULL_PTR);
2887 #endif
2888
2889 /* clear the variable MatchedEntries first */
2890 *MatchedEntries = 0U;
2891
2892 /* only support Add, Update and AddOrUpdate commands */
2893 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd) && (NETC_ETHSWT_ADD_OR_UPDATE_CMD != Cmd))
2894 {
2895 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
2896 }
2897 else
2898 {
2899 /* fill in Vlan Filter Table Request Data Buffer */
2900 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U);
2901
2902 AccessKeyData = VlanFilterTableEntry->VlanID;
2903
2904 VlanFilterCfgeData.Cfge_Data[0U] = (NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_STG_ID(VlanFilterTableEntry->SpanningTreeGroupMemberId) \
2905 | NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_PORT_MEMBERSHIP(VlanFilterTableEntry->PortMembershipBitmap));
2906 VlanFilterCfgeData.Cfge_Data[1U] = (NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFLE(VlanFilterTableEntry->IpMulticastFloodingEnable ? 1U :0U) \
2907 | NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFE(VlanFilterTableEntry->IpMulticastFilteringEnable ? 1U : 0U) \
2908 | NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MFO(VlanFilterTableEntry->MacForwardingOptions) \
2909 | NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MLO(VlanFilterTableEntry->MacLearningOptions) \
2910 | NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_FID(VlanFilterTableEntry->FID));
2911 VlanFilterCfgeData.Cfge_Data[2U] = NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_ETA_PORT_BITMAP(VlanFilterTableEntry->EgressTreatmentApplicabilityPortBitmap);
2912 VlanFilterCfgeData.Cfge_Data[3U] = NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_BASE_ET_EID(VlanFilterTableEntry->BaseEgressTreatmentEntryID);
2913
2914 /* For Add, Update and AddOrUpdate commands, we only provide NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method for users */
2915 status = Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff(ActionsData, AccessKeyData, &VlanFilterCfgeData, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
2916 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS == status)
2917 {
2918 /* fill in operation data for config field of Request Header*/
2919 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2920 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2921 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_VLAN_FILTER_TABLE_ID;
2922 Netc_EthSwt_Ip_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 */
2923 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
2924 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_VLANFILTERTABLE_REQBUFFER_LEN);
2925 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
2926
2927 /* send the command */
2928 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
2929 #if defined(ERR_IPV_NETC_051243)
2930 #if (STD_ON == ERR_IPV_NETC_051243)
2931 /* Error code 0x8A is not a real error. check it on Errata. */
2932 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
2933 {
2934 #endif
2935 #else
2936 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
2937 {
2938 #endif
2939 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
2940 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
2941 }
2942 }
2943 else
2944 {
2945 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
2946 }
2947 }
2948
2949 return status;
2950 }
2951
2952 /*FUNCTION**********************************************************************
2953 *
2954 * Function Name : Netc_EthSwt_Ip_QueryVlanFilterTableEntry
2955 * Description : Ethernet Switch query Vlan Filter table entry function.
2956 * implements Netc_EthSwt_Ip_QueryVlanFilterTableEntry_Activity
2957 *END**************************************************************************/
2958 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryVlanFilterTableEntry( uint8 SwitchIdx,
2959 uint32 *MatchedEntries,
2960 Netc_EthSwt_Ip_VlanFilterEntryDataType * VlanFilterTableEntry
2961 )
2962 {
2963 Netc_EthSwt_Ip_CBDRStatusType status;
2964 uint32 AccessKeyData;
2965 uint32 ActionsData;
2966 uint32 CfgeData;
2967
2968 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
2969 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
2970 DevAssert(MatchedEntries != NULL_PTR);
2971 #endif
2972
2973 /* clear the variable MatchedEntries first */
2974 *MatchedEntries = 0U;
2975
2976 /* fill in Vlan Filter Table Request Data Buffer */
2977 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 */
2978
2979 AccessKeyData = VlanFilterTableEntry->VlanID;
2980
2981 /* for query command, we don't need the CFGE_DATA field */
2982 status = Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff(ActionsData, AccessKeyData, NULL_PTR, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
2983 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS == status)
2984 {
2985 /* fill in operation data for config field of NTMP Request Header*/
2986 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
2987 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
2988 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_VLAN_FILTER_TABLE_ID;
2989 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
2990 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
2991 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
2992 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_VLANFILTERTABLE_RESBUFFER_LEN); /* set response data buffer length */
2993
2994 /* send the "Query" command */
2995 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
2996 #if defined(ERR_IPV_NETC_051243)
2997 #if (STD_ON == ERR_IPV_NETC_051243)
2998 /* Error code 0x8A is not a real error. check it on Errata. */
2999 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
3000 {
3001 #endif
3002 #else
3003 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3004 {
3005 #endif
3006 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3007 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3008
3009 /* found a matched entry */
3010 if (1U == *MatchedEntries)
3011 {
3012 /* fill in "Netc_EthSwt_Ip_VlanFilterEntryDataType" structure with data in response data buffer */
3013 VlanFilterTableEntry->VlanID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_VID] & NETC_ETHSWT_IP_VLANFILTERTABLE_KEYEDATA_VID_MASK);
3014
3015 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA0];
3016 VlanFilterTableEntry->SpanningTreeGroupMemberId = (uint8)((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_STG_ID_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_STG_ID_SHIFT);
3017 VlanFilterTableEntry->PortMembershipBitmap = (CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_PORT_MEMBERSHIP_MASK);
3018
3019 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1];
3020 VlanFilterTableEntry->FID = (uint16)(CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_FID_MASK);
3021 VlanFilterTableEntry->MacLearningOptions = (uint8)((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MLO_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MLO_SHIFT);
3022 VlanFilterTableEntry->MacForwardingOptions = (uint8)((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MFO_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MFO_SHIFT);
3023 VlanFilterTableEntry->IpMulticastFilteringEnable = (((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFE_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFE_SHIFT) != 0x0UL) ? TRUE : FALSE;
3024 VlanFilterTableEntry->IpMulticastFloodingEnable = (((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFLE_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFLE_SHIFT) != 0x0UL) ? TRUE : FALSE;
3025
3026 VlanFilterTableEntry->EgressTreatmentApplicabilityPortBitmap = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA2] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_ETA_PORT_BITMAP_MASK;
3027 VlanFilterTableEntry->BaseEgressTreatmentEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA3];
3028 }
3029 }
3030 }
3031 else
3032 {
3033 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
3034 }
3035
3036 return status;
3037 }
3038
3039 /*FUNCTION**********************************************************************
3040 *
3041 * Function Name : Netc_EthSwt_Ip_DeleteVlanFilterTableEntry
3042 * Description : Ethernet Switch delete Vlan Filter table entry function.
3043 * implements Netc_EthSwt_Ip_DeleteVlanFilterTableEntry_Activity
3044 *END**************************************************************************/
3045 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteVlanFilterTableEntry( uint8 SwitchIdx,
3046 uint32 *MatchedEntries,
3047 uint32 VlanFilterTableEntryId
3048 )
3049 {
3050 Netc_EthSwt_Ip_CBDRStatusType status;
3051 uint32 AccessKeyData;
3052 uint32 ActionsData = 0U;
3053
3054 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3055 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3056 DevAssert(MatchedEntries != NULL_PTR);
3057 #endif
3058
3059 /* clear the variable MatchedEntries first */
3060 *MatchedEntries = 0U;
3061
3062 /* fill in Vlan Filter Table Request Data Buffer */
3063 AccessKeyData = VlanFilterTableEntryId;
3064
3065 /* for delete command, we don't need the CFGE_DATA field */
3066 status = Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff(ActionsData, AccessKeyData, NULL_PTR, NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH);
3067 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS == status)
3068 {
3069 /* fill in operation data for config field of NTMP Request Header*/
3070 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3071 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3072 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_VLAN_FILTER_TABLE_ID;
3073 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
3074 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
3075 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
3076 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
3077
3078 /* send the "Delete" command */
3079 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
3080 #if defined(ERR_IPV_NETC_051243)
3081 #if (STD_ON == ERR_IPV_NETC_051243)
3082 /* Error code 0x8A is not a real error. check it on Errata. */
3083 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
3084 {
3085 #endif
3086 #else
3087 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3088 {
3089 #endif
3090 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3091 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3092 }
3093 }
3094 else
3095 {
3096 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
3097 }
3098
3099 return status;
3100 }
3101
3102 /*FUNCTION**********************************************************************
3103 *
3104 * Function Name : Netc_EthSwt_Ip_QueryEgressCountTableEntry
3105 * Description : Ethernet Switch query Egress count table entry function.
3106 * implements Netc_EthSwt_Ip_QueryEgressCountTableEntry_Activity
3107 *END**************************************************************************/
3108 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryEgressCountTableEntry( uint8 SwitchIdx,
3109 uint32 EntryId,
3110 uint32 *MatchedEntries,
3111 Netc_EthSwt_Ip_ECTableStatisticsDataType *StatisticsData
3112 )
3113 {
3114 Netc_EthSwt_Ip_CBDRStatusType status;
3115
3116 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3117 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3118 DevAssert(StatisticsData != NULL_PTR);
3119 DevAssert(MatchedEntries != NULL_PTR);
3120 DevAssert((EntryId > 0U) && (EntryId <= (IP_NETC__SW0_COMMON->ECTCAPR & NETC_F2_COMMON_ECTCAPR_NUM_ENTRIES_MASK)));
3121 #endif
3122
3123 /* clear the variable MatchedEntries first */
3124 *MatchedEntries = 0U;
3125 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_44();
3126
3127 /* fill in Egress Count Table Request Data Buffer */
3128 /* fill in Actions field. only support "full query" action and no need to update Statistics Element */
3129 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = (NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
3130 | NETC_ETHSWT_IP_EGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD_STSEU(NETC_ETHSWT_EGRESSCOUNTTABLE_NO_UPDATE_STATISTICS_ELEMENT));
3131 /* fill in Access Key field, only support Entry ID Match method */
3132 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EntryId;
3133 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_44();
3134
3135 /* fill in operation data for config field of NTMP Request Header*/
3136 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3137 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3138 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_EGRESS_COUNT_TABLE_ID;
3139 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support Entry ID Match method */
3140 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
3141 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
3142 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_EGRESSCOUNTTABLE_RSPBUFFER_LEN); /* set response data buffer length */
3143
3144 /* send the "Query" command */
3145 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
3146 #if defined(ERR_IPV_NETC_051243)
3147 #if (STD_ON == ERR_IPV_NETC_051243)
3148 /* Error code 0x8A is not a real error. check it on Errata. */
3149 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
3150 {
3151 #endif
3152 #else
3153 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3154 {
3155 #endif
3156 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3157 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3158 /* found a matched entry */
3159 if (*MatchedEntries == 1U)
3160 {
3161 /* get the Enqueued Frame Count data */
3162 StatisticsData->EnqueuedFrmCnt = ((uint64)(TableDataBuffer.TableDataField[NETC_ETHSWT_ECTABLE_RSPDATA_ENQFRMCNT_H]) << NETC_ETHSWT_IP_32BIT_SHIFT);
3163 StatisticsData->EnqueuedFrmCnt |= (uint64)(TableDataBuffer.TableDataField[NETC_ETHSWT_ECTABLE_RSPDATA_ENQFRMCNT_L]);
3164
3165 /* get the Rejected Frame Count */
3166 StatisticsData->RejectedFrmCnt = ((uint64)(TableDataBuffer.TableDataField[NETC_ETHSWT_ECTABLE_RSPDATA_REJFRMCNT_H]) << NETC_ETHSWT_IP_32BIT_SHIFT);
3167 StatisticsData->RejectedFrmCnt |= (uint64)(TableDataBuffer.TableDataField[NETC_ETHSWT_ECTABLE_RSPDATA_REJFRMCNT_L]);
3168 }
3169 }
3170
3171 return status;
3172 }
3173
3174 /*FUNCTION**********************************************************************
3175 *
3176 * Function Name : Netc_EthSwt_Ip_ResetEgressCountTableEntry
3177 * Description : Ethernet Switch reset Egress count table entry function.
3178 * implements Netc_EthSwt_Ip_ResetEgressCountTableEntry_Activity
3179 *END**************************************************************************/
3180 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_ResetEgressCountTableEntry( uint8 SwitchIdx,
3181 uint32 EntryId,
3182 uint32 *MatchedEntries
3183 )
3184 {
3185 Netc_EthSwt_Ip_CBDRStatusType status;
3186
3187 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3188 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3189 DevAssert(MatchedEntries != NULL_PTR);
3190 DevAssert((EntryId > 0U) && (EntryId <= (IP_NETC__SW0_COMMON->ECTCAPR & NETC_F2_COMMON_ECTCAPR_NUM_ENTRIES_MASK)));
3191 #endif
3192
3193 /* clear the variable MatchedEntries first */
3194 *MatchedEntries = 0U;
3195
3196 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_49();
3197 /* fill in Egress Count Table Request Data Buffer */
3198 /* fill in Actions field. only support "full query" action and set STSEU to reset Statistics Element */
3199 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD] = (NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
3200 | NETC_ETHSWT_IP_EGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD_STSEU(NETC_ETHSWT_EGRESSCOUNTTABLE_RESET_STATISTICS_ELEMENT));
3201 /* fill in Access Key field, only support Entry ID Match method */
3202 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSCOUNTTABLE_REQFMT_ACCESSKEY_FIELD] = EntryId;
3203 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_49();
3204
3205 /* fill in operation data for config field of NTMP Request Header*/
3206 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3207 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3208 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_EGRESS_COUNT_TABLE_ID;
3209 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support Entry ID Match method */
3210 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_UPDATE_CMD;
3211 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
3212 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
3213
3214 /* send the "Update" command */
3215 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
3216 #if defined(ERR_IPV_NETC_051243)
3217 #if (STD_ON == ERR_IPV_NETC_051243)
3218 /* Error code 0x8A is not a real error. check it on Errata. */
3219 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
3220 #else
3221 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3222 #endif
3223 #else
3224 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3225 #endif
3226 {
3227 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3228 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3229 }
3230
3231 return status;
3232 }
3233
3234 /*FUNCTION**********************************************************************
3235 *
3236 * Function Name : Netc_EthSwt_Ip_AddOrUpdateEgressTreatmentTableEntry
3237 * Description : Ethernet Switch add, update or addorupdate Egress Treatment table entry function.
3238 * implements Netc_EthSwt_Ip_AddOrUpdateEgressTreatmentTableEntry_Activity
3239 *END**************************************************************************/
3240 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateEgressTreatmentTableEntry( uint8 SwitchIdx,
3241 Netc_EthSwt_Ip_CommandsType Cmd,
3242 uint32 *MatchedEntries,
3243 const Netc_EthSwt_Ip_EgressTreatmentEntryDataType * EgressTreatmentTableEntry
3244 )
3245 {
3246 Netc_EthSwt_Ip_CBDRStatusType status;
3247
3248 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3249 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3250 DevAssert(MatchedEntries != NULL_PTR);
3251 DevAssert(EgressTreatmentTableEntry != NULL_PTR);
3252 #endif
3253
3254 /* clear the variable MatchedEntries first */
3255 *MatchedEntries = 0U;
3256
3257 /* only support Add, Update and AddOrUpdate commands */
3258 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd) && (NETC_ETHSWT_ADD_OR_UPDATE_CMD != Cmd))
3259 {
3260 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
3261 }
3262 else
3263 {
3264 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_50();
3265 /* fill in Egress Treatment Table Request Data Buffer */
3266 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U);
3267 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EgressTreatmentTableEntry->EgressTreatmentEntryID;
3268
3269 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = (NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_DATA_LEN(EgressTreatmentTableEntry->EgressFrmModificationDataLength) \
3270 | NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_LEN_CHANGE(EgressTreatmentTableEntry->EgressFrmModificationLengthChange) \
3271 | NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_COUNTER_ACTION(EgressTreatmentTableEntry->EgressCounterAction) \
3272 | NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_SEQUENCE_ACTION(EgressTreatmentTableEntry->EgressSequenceAction) \
3273 | NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_MODE(EgressTreatmentTableEntry->EgressFrmModificationMode));
3274 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = EgressTreatmentTableEntry->EgressFrmModificationEID;
3275 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = EgressTreatmentTableEntry->EgressCountTableEID;
3276 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = EgressTreatmentTableEntry->EgressSeqActionsTargetEID;
3277 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_50();
3278
3279 /* fill in operation data for config field of Request Header*/
3280 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3281 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3282 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_EGRESS_TREATMENT_TABLE_ID;
3283 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
3284 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
3285 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ETMTABLE_REQBUFFER_LEN);
3286 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
3287
3288 /* send the command */
3289 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
3290 #if defined(ERR_IPV_NETC_051243)
3291 #if (STD_ON == ERR_IPV_NETC_051243)
3292 /* Error code 0x8A is not a real error. check it on Errata. */
3293 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
3294 {
3295 #endif
3296 #else
3297 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3298 {
3299 #endif
3300 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3301 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3302 }
3303
3304 }
3305
3306 return status;
3307 }
3308
3309 /*FUNCTION**********************************************************************
3310 *
3311 * Function Name : Netc_EthSwt_Ip_QueryEgressTreatmentTableEntry
3312 * Description : Ethernet Switch query Egress Treatment table entry function.
3313 * implements Netc_EthSwt_Ip_QueryEgressTreatmentTableEntry_Activity
3314 *END**************************************************************************/
3315 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryEgressTreatmentTableEntry( uint8 SwitchIdx,
3316 uint32 *MatchedEntries,
3317 Netc_EthSwt_Ip_EgressTreatmentEntryDataType * EgressTreatmentTableEntry
3318 )
3319 {
3320 Netc_EthSwt_Ip_CBDRStatusType status;
3321 uint32 CfgeData;
3322
3323 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3324 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3325 DevAssert(MatchedEntries != NULL_PTR);
3326 #endif
3327
3328 /* clear the variable MatchedEntries first */
3329 *MatchedEntries = 0U;
3330 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_51();
3331 /* fill in Egress Treatment Table Request Data Buffer */
3332 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 */
3333 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EgressTreatmentTableEntry->EgressTreatmentEntryID;
3334 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_51();
3335
3336 /* fill in operation data for config field of Request Header*/
3337 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3338 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3339 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_EGRESS_TREATMENT_TABLE_ID;
3340 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
3341 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
3342 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
3343 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_EGRESSTREAMENTTABLE_RESBUFFER_LEN);
3344
3345 /* send the command */
3346 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
3347 #if defined(ERR_IPV_NETC_051243)
3348 #if (STD_ON == ERR_IPV_NETC_051243)
3349 /* Error code 0x8A is not a real error. check it on Errata. */
3350 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
3351 {
3352 #endif
3353 #else
3354 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3355 {
3356 #endif
3357 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3358 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3359
3360 /* found a matched entry */
3361 if (1U == *MatchedEntries)
3362 {
3363 /* fill in "Netc_EthSwt_Ip_EgressTreatmentEntryDataType" structure with data in response data buffer */
3364 EgressTreatmentTableEntry->EgressTreatmentEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSTREATMENTTABLE_RSPFMT_ENTRYID_FIELD];
3365
3366 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSTREATMENTTABLE_RSPFMT_CFGEDATA0];
3367 EgressTreatmentTableEntry->EgressFrmModificationDataLength = (uint16)((CfgeData & NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_DATA_LEN_MASK) >> NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_DATA_LEN_SHIFT);
3368 EgressTreatmentTableEntry->EgressFrmModificationLengthChange = (uint8)((CfgeData & NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_LEN_CHANGE_MASK) >> NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_LEN_CHANGE_SHIFT);
3369 EgressTreatmentTableEntry->EgressCounterAction = ((CfgeData & NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_COUNTER_ACTION_MASK) >> NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_COUNTER_ACTION_SHIFT);
3370 EgressTreatmentTableEntry->EgressSequenceAction = ((CfgeData & NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_SEQUENCE_ACTION_MASK) >> NETC_ETHSWT_IP_ETTABLE_CFGE_EGRESS_SEQUENCE_ACTION_SHIFT);
3371 EgressTreatmentTableEntry->EgressFrmModificationMode = (CfgeData & NETC_ETHSWT_IP_ETTABLE_CFGE_FRM_MODIFICATION_MODE_MASK);
3372
3373 EgressTreatmentTableEntry->EgressFrmModificationEID = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSTREATMENTTABLE_RSPFMT_CFGEDATA1]; /* fill in EFM_EID field */
3374 EgressTreatmentTableEntry->EgressCountTableEID = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSTREATMENTTABLE_RSPFMT_CFGEDATA2]; /* fill in EC_EID field */
3375 EgressTreatmentTableEntry->EgressSeqActionsTargetEID = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_EGRESSTREATMENTTABLE_RSPFMT_CFGEDATA3]; /* fill in ESQA_TGT_EID field */
3376 }
3377 }
3378
3379 return status;
3380 }
3381
3382 /*FUNCTION**********************************************************************
3383 *
3384 * Function Name : Netc_EthSwt_Ip_DeleteEgressTreatmentTableEntry
3385 * Description : Ethernet Switch delete Egress Treatment table entry function.
3386 * implements Netc_EthSwt_Ip_DeleteEgressTreatmentTableEntry_Activity
3387 *END**************************************************************************/
3388 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteEgressTreatmentTableEntry( uint8 SwitchIdx,
3389 uint32 EgressTreatmentTableEntryId,
3390 uint32 *MatchedEntries
3391 )
3392 {
3393 Netc_EthSwt_Ip_CBDRStatusType status;
3394
3395 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3396 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3397 DevAssert(MatchedEntries != NULL_PTR);
3398 #endif
3399
3400 /* clear the variable MatchedEntries first */
3401 *MatchedEntries = 0U;
3402 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_52();
3403
3404 /* fill in Egress Treatment Table Request Data Buffer */
3405 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = 0U; /* no need to fill in Actions field */
3406 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EgressTreatmentTableEntryId;
3407 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_52();
3408
3409 /* fill in operation data for config field of Request Header*/
3410 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3411 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3412 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_EGRESS_TREATMENT_TABLE_ID;
3413 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
3414 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
3415 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
3416 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
3417
3418 /* send the command */
3419 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
3420 #if defined(ERR_IPV_NETC_051243)
3421 #if (STD_ON == ERR_IPV_NETC_051243)
3422 /* Error code 0x8A is not a real error. check it on Errata. */
3423 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
3424 #else
3425 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3426 #endif
3427 #else
3428 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3429 #endif
3430 {
3431 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3432 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3433 }
3434
3435 return status;
3436 }
3437
3438 /*FUNCTION**********************************************************************
3439 *
3440 * Function Name : Netc_EthSwt_Ip_AddOrUpdateFrmModificationTableEntry
3441 * Description : Ethernet Switch add, update or addorupdate Frame Modification table entry function.
3442 * implements Netc_EthSwt_Ip_AddOrUpdateFrmModificationTableEntry_Activity
3443 *END**************************************************************************/
3444 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateFrmModificationTableEntry( uint8 SwitchIdx,
3445 Netc_EthSwt_Ip_CommandsType Cmd,
3446 uint32 *MatchedEntries,
3447 const Netc_EthSwt_Ip_FrmModificationEntryDataType * FrmModificationTableEntry
3448 )
3449 {
3450 Netc_EthSwt_Ip_CBDRStatusType status;
3451 uint16 MacAddrH;
3452 uint32 MacAddrL = 0x0UL;
3453 uint8 MacByteIdx;
3454
3455 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3456 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3457 DevAssert(MatchedEntries != NULL_PTR);
3458 DevAssert(FrmModificationTableEntry != NULL_PTR);
3459 #endif
3460
3461 /* clear the variable MatchedEntries first */
3462 *MatchedEntries = 0U;
3463
3464 /* only support Add, Update and AddOrUpdate commands */
3465 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd) && (NETC_ETHSWT_ADD_OR_UPDATE_CMD != Cmd))
3466 {
3467 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
3468 }
3469 else
3470 {
3471 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_53();
3472 /* fill in Frame Modification Table Request Data Buffer */
3473 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U); /* Configuration Element Update */
3474 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = FrmModificationTableEntry->FrmModificationEntryID; /* Entry ID */
3475
3476 /* be careful to the order of dest mac address, it is in big endian */
3477 for (MacByteIdx = 5U; MacByteIdx > 2U; MacByteIdx-- ) /* Get the Dest Mac Address */
3478 {
3479 MacAddrL |= FrmModificationTableEntry->DestMacAddr[MacByteIdx];
3480 MacAddrL <<= 8U;
3481 }
3482 MacAddrL |= FrmModificationTableEntry->DestMacAddr[2U];
3483 MacAddrH = ((uint16)(FrmModificationTableEntry->DestMacAddr[1U]) << 8U) | FrmModificationTableEntry->DestMacAddr[0U];
3484
3485 /* fill in CFGE Data */
3486 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = (NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_DEST_MAC_ADDR_H(MacAddrH) \
3487 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SRC_MAC_ADDR_PORT(FrmModificationTableEntry->SrcMacAddrRegisterPort) \
3488 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SEQUENCE_TAG_ACTION(FrmModificationTableEntry->SequenceTagAction) \
3489 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VID_ACTION(FrmModificationTableEntry->OuterVidActions) \
3490 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_VLAN_HEADER_ACTION(FrmModificationTableEntry->L2HeaderVlanActions) \
3491 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_MAC_HEADER_ACTION(FrmModificationTableEntry->L2HeaderMacActions) \
3492 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_LAYER2_ACTION(FrmModificationTableEntry->L2Actions));
3493 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = MacAddrL;
3494 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = (NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_PAYLOAD_ACTION(FrmModificationTableEntry->PayloadActions) \
3495 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_DEI_ACTION(FrmModificationTableEntry->OuterDeiAction) \
3496 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_PCP_ACTION(FrmModificationTableEntry->OuterPcpAction) \
3497 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_TPID_ACTION(FrmModificationTableEntry->OuterTpidAction) \
3498 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_DEI(FrmModificationTableEntry->OuterVlanDei) \
3499 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_PCP(FrmModificationTableEntry->OuterVlanPcp) \
3500 | NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_VID(FrmModificationTableEntry->OuterVlanVID));
3501 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_PAYLOAD_OFFSET(FrmModificationTableEntry->PayloadOffset);
3502 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_FRM_MODI_BYTES(FrmModificationTableEntry->FrmModificationDataBytes);
3503 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA5] = FrmModificationTableEntry->FrmModificationDataEntryID; /* Frame Modification Data Tabel Entry ID */
3504 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_53();
3505
3506 /* fill in operation data for config field of Request Header*/
3507 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3508 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3509 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_FRM_MODIFICATION_TABLE_ID;
3510 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support "Entry ID" match method */
3511 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
3512 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FRMTABLE_REQBUFFER_LEN);
3513 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
3514
3515 /* send the command */
3516 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
3517 #if defined(ERR_IPV_NETC_051243)
3518 #if (STD_ON == ERR_IPV_NETC_051243)
3519 /* Error code 0x8A is not a real error. check it on Errata. */
3520 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
3521 {
3522 #endif
3523 #else
3524 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3525 {
3526 #endif
3527 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3528 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3529 }
3530 }
3531
3532 return status;
3533 }
3534
3535 /*FUNCTION**********************************************************************
3536 *
3537 * Function Name : Netc_EthSwt_Ip_QueryFrmModificationTableEntry
3538 * Description : Ethernet Switch query Frame Modification table entry function.
3539 * implements Netc_EthSwt_Ip_QueryFrmModificationTableEntry_Activity
3540 *END**************************************************************************/
3541 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryFrmModificationTableEntry( uint8 SwitchIdx,
3542 uint32 *MatchedEntries,
3543 Netc_EthSwt_Ip_FrmModificationEntryDataType * FrmModificationTableEntry
3544 )
3545 {
3546 Netc_EthSwt_Ip_CBDRStatusType status;
3547 uint16 MacAddrH;
3548 uint32 MacAddrL;
3549 uint8 MacByteIdx;
3550 uint32 CfgeData;
3551
3552 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3553 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3554 DevAssert(MatchedEntries != NULL_PTR);
3555 DevAssert(FrmModificationTableEntry != NULL_PTR);
3556 #endif
3557
3558 /* clear the variable MatchedEntries first */
3559 *MatchedEntries = 0U;
3560 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_54();
3561
3562 /* fill in Frame Modification Table Request Data Buffer */
3563 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" */
3564 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = FrmModificationTableEntry->FrmModificationEntryID; /* Entry ID */
3565 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_54();
3566
3567 /* fill in operation data for config field of Request Header*/
3568 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3569 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3570 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_FRM_MODIFICATION_TABLE_ID;
3571 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support "Entry ID" match method */
3572 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
3573 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
3574 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_FRMTABLE_RSPBUFFER_LEN);
3575
3576 /* send the command */
3577 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
3578 #if defined(ERR_IPV_NETC_051243)
3579 #if (STD_ON == ERR_IPV_NETC_051243)
3580 /* Error code 0x8A is not a real error. check it on Errata. */
3581 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
3582 {
3583 #endif
3584 #else
3585 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3586 {
3587 #endif
3588 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3589 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3590 /* found a matched entry */
3591 if (1U == *MatchedEntries)
3592 {
3593 /* fill in structure Netc_EthSwt_Ip_FrmModificationEntryDataType with data in response data buffer */
3594 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA0];
3595 MacAddrH = (uint16)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_DEST_MAC_ADDR_H_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_DEST_MAC_ADDR_H_SHIFT);
3596 MacAddrL = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA1];
3597 for (MacByteIdx = 0U; MacByteIdx < 4U; MacByteIdx++)
3598 {
3599 FrmModificationTableEntry->DestMacAddr[MacByteIdx] = (uint8)(MacAddrL & NETC_ETHSWT_IP_0XFF_MASK);
3600 MacAddrL >>= 8U;
3601 }
3602 FrmModificationTableEntry->DestMacAddr[4U] = (uint8)(MacAddrH & NETC_ETHSWT_IP_0XFF_MASK);
3603 FrmModificationTableEntry->DestMacAddr[5U] = (uint8)(MacAddrH >> 8U);
3604
3605 FrmModificationTableEntry->SrcMacAddrRegisterPort = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SRC_MAC_ADDR_PORT_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SRC_MAC_ADDR_PORT_SHIFT);
3606 FrmModificationTableEntry->SequenceTagAction = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SEQUENCE_TAG_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_SEQUENCE_TAG_ACTION_SHIFT);
3607 FrmModificationTableEntry->OuterVidActions = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VID_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VID_ACTION_SHIFT);
3608 FrmModificationTableEntry->L2HeaderVlanActions = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_VLAN_HEADER_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_VLAN_HEADER_ACTION_SHIFT);
3609 FrmModificationTableEntry->L2HeaderMacActions = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_MAC_HEADER_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_MAC_HEADER_ACTION_SHIFT);
3610 FrmModificationTableEntry->L2Actions = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_LAYER2_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_LAYER2_ACTION_SHIFT);
3611
3612 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA2];
3613 FrmModificationTableEntry->PayloadActions = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_PAYLOAD_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_PAYLOAD_ACTION_SHIFT);
3614 FrmModificationTableEntry->OuterDeiAction = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_DEI_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_DEI_ACTION_SHIFT);
3615 FrmModificationTableEntry->OuterPcpAction = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_PCP_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_PCP_ACTION_SHIFT);
3616 FrmModificationTableEntry->OuterTpidAction = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_TPID_ACTION_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_TPID_ACTION_SHIFT);
3617 FrmModificationTableEntry->OuterVlanDei = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_DEI_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_DEI_SHIFT);
3618 FrmModificationTableEntry->OuterVlanPcp = (uint8)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_PCP_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_PCP_SHIFT);
3619 FrmModificationTableEntry->OuterVlanVID = (uint16)((CfgeData & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_VID_MASK) >> NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_OUTER_VLAN_VID_SHIFT);
3620
3621 FrmModificationTableEntry->PayloadOffset = (uint8)(TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA3] & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_PAYLOAD_OFFSET_MASK);
3622 FrmModificationTableEntry->FrmModificationDataBytes = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA4] & NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_CFGE_FRM_MODI_BYTES_MASK);
3623 FrmModificationTableEntry->FrmModificationDataEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FRMMODIFICATIONTABLE_RSPFMT_CFGEDATA5];
3624 }
3625 }
3626
3627
3628 return status;
3629 }
3630
3631 /*FUNCTION**********************************************************************
3632 *
3633 * Function Name : Netc_EthSwt_Ip_DeleteFrmModificationTableEntry
3634 * Description : Ethernet Switch delete Frame Modification table entry function.
3635 * implements Netc_EthSwt_Ip_DeleteFrmModificationTableEntry_Activity
3636 *END**************************************************************************/
3637 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteFrmModificationTableEntry( uint8 SwitchIdx,
3638 uint32 FrmModificationEntryID,
3639 uint32 *MatchedEntries
3640 )
3641 {
3642 Netc_EthSwt_Ip_CBDRStatusType status;
3643
3644 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3645 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3646 DevAssert(MatchedEntries != NULL_PTR);
3647 #endif
3648
3649 /* clear the variable MatchedEntries first */
3650 *MatchedEntries = 0U;
3651 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_55();
3652
3653 /* fill in Frame Modification Table Request Data Buffer */
3654 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = 0U; /* no need to fill in Actions field */
3655 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = FrmModificationEntryID; /* Entry ID */
3656 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_55();
3657
3658 /* fill in operation data for config field of Request Header*/
3659 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3660 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3661 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_FRM_MODIFICATION_TABLE_ID;
3662 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support "Entry ID" match method */
3663 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
3664 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
3665 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
3666
3667 /* send the command */
3668 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
3669 #if defined(ERR_IPV_NETC_051243)
3670 #if (STD_ON == ERR_IPV_NETC_051243)
3671 /* Error code 0x8A is not a real error. check it on Errata. */
3672 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
3673 #else
3674 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3675 #endif
3676 #else
3677 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3678 #endif
3679 {
3680 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3681 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3682 }
3683
3684 return status;
3685 }
3686
3687 /*FUNCTION**********************************************************************
3688 *
3689 * Function Name : Netc_EthSwt_Ip_EnableIngressPortFiltering
3690 * Description : Ethernet switch enables the ingress port filtering lookup function.
3691 * implements Netc_EthSwt_Ip_EnableIngressPortFiltering_Activity
3692 *END**************************************************************************/
3693 Std_ReturnType Netc_EthSwt_Ip_EnableIngressPortFiltering( uint8 SwitchIdx, uint8 SwitchPortIdx, boolean Enable )
3694 {
3695 Std_ReturnType Status = E_OK;
3696 uint32 RegVal;
3697
3698 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3699 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3700 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
3701 #endif
3702
3703 (void)SwitchIdx;
3704
3705 /* Convert the value */
3706 RegVal = (Enable) ? (0x1UL) : (0x0UL);
3707
3708 /* write the PIPFCR[EN] bit */
3709 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PIPFCR = RegVal;
3710
3711 return Status;
3712 }
3713
3714 /* inline function for filling in Access Keye data in function Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff() */
3715 static inline Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_FillInAccessKeyeData(const Netc_EthSwt_Ip_AccessMethodType accessMethod, const volatile uint32 *pAccessKey)
3716 {
3717 uint8 ItemIdx;
3718 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3719
3720 switch (accessMethod)
3721 {
3722 case NETC_ETHSWT_ENTRY_ID_MATCH:
3723 /* fill in Entry_ID field */
3724 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = pAccessKey[0U];
3725 break;
3726 case NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH:
3727 /* Not Applicable for Ingress Port Filter table*/
3728 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
3729 break;
3730 case NETC_ETHSWT_SEARCH_METHOD:
3731 /* fill in Resume_Entry_ID field */
3732 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = pAccessKey[0U];
3733 break;
3734 case NETC_ETHSWT_TERNARY_MATCH_KEY_ELEMENT_MATCH:
3735 /* fill in keye_data field */
3736 for (ItemIdx = 1U; ItemIdx <= NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_KEYE_DATA_LEN; ItemIdx++)
3737 {
3738 TableDataBuffer.TableDataField[ItemIdx] = pAccessKey[ItemIdx - 1U];
3739 }
3740 break;
3741 default:
3742 /* Not Applicable for Ingress Port Filter table*/
3743 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
3744 break;
3745 }
3746
3747 return status;
3748 }
3749
3750 /*FUNCTION**********************************************************************
3751 *
3752 * Function Name : Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff
3753 * Description : Internal function for initializing the Ingress Port Filter Table Request Data Buffer.
3754 *
3755 *END**************************************************************************/
3756 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff( uint32 ActionsData,
3757 const volatile uint32 *pAccessKey,
3758 const Netc_EthSwt_Ip_IngressPortFilterCfgeDataType *pCfgeData,
3759 Netc_EthSwt_Ip_AccessMethodType accessMethod
3760 )
3761 {
3762 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3763
3764 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_56();
3765 /* ------initialize the table request data buffer------ */
3766 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
3767
3768 /* initialize ACCESS_KEY */
3769 status = Netc_EthSwt_Ip_FillInAccessKeyeData(accessMethod, pAccessKey);
3770
3771 /* initialize CFGE_DATA. This portion is present only for commands which perform an update or add. */
3772 if (pCfgeData != NULL_PTR)
3773 {
3774 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSPORTFILTER_CFGE_CONFIG_FIELD] = (NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_IPV(pCfgeData->CfgeIpv) \
3775 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_OIPV(pCfgeData->CfgeOverrideIpv ? 1U : 0U) \
3776 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_DR(pCfgeData->CfgeDr) \
3777 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_ODR(pCfgeData->CfgeOverrideDr ? 1U : 0U) \
3778 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTFA(pCfgeData->CfgeFilterForwardingAction) \
3779 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_IMIRE(pCfgeData->CfgeIngressMirroringEnable ? 1U : 0U) \
3780 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_WOLTE(pCfgeData->CfgeWakeOnLanTriggerEnable ? 1U : 0U) \
3781 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTA(pCfgeData->CfgeFilterAction) \
3782 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_RPR(pCfgeData->CfgeRelativePrecedentResolution) \
3783 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_CTD(pCfgeData->CfgeCutThroughDisable? 1U : 0U) \
3784 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_HR(pCfgeData->CfgeHostReason) \
3785 | NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_TIMECAP(pCfgeData->CfgeTimestampCaptureEable ? 1U : 0U));
3786 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSPORTFILTER_CFGE_FLTATGT_FIELD] = pCfgeData->CfgeTargetForSelectedFilterAction;
3787 }
3788 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_56();
3789
3790 return status;
3791 }
3792
3793 /*FUNCTION**********************************************************************
3794 *
3795 * Function Name : Netc_EthSwt_Ip_AddIngressPortFilterTableEntry
3796 * Description : Ethernet Switch adds Ingress Port Filter table entry function.
3797 * implements Netc_EthSwt_Ip_AddIngressPortFilterTableEntry_Activity
3798 *END**************************************************************************/
3799 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddIngressPortFilterTableEntry( uint8 SwitchIdx,
3800 uint32 *MatchedEntries,
3801 Netc_EthSwt_Ip_IngressPortFilterEntryDataType * IngressPortFilterTableEntry
3802 )
3803 {
3804 Netc_EthSwt_Ip_CBDRStatusType status;
3805 uint32 ActionsData;
3806 uint8 ByteIdx;
3807 uint8 CfgeDataIdx;
3808 uint8 PayloadIdx;
3809 uint16 AuxWord[2U];
3810
3811 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
3812 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
3813 DevAssert(MatchedEntries != NULL_PTR);
3814 DevAssert(IngressPortFilterTableEntry != NULL_PTR);
3815 #endif
3816
3817 /* clear the variable MatchedEntries first */
3818 *MatchedEntries = 0U;
3819
3820 /* set STSEU and CFGEU flag */
3821 ActionsData = (NETC_ETHSWT_IP_IPFTABLE_REQFMT_ACTIONS_FIELD_STSEU(1U) | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U));
3822
3823 /* inialize KEYE_DATA */
3824 Netc_EthSwt_Ip_IPFKeyeData[0U] = IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePrecedence;
3825 Netc_EthSwt_Ip_IPFKeyeData[2U] = ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeFrmAttributeFlagsMask) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3826 | IngressPortFilterTableEntry->IngressPortFilterkeyeData.keyeFrmAttributeFlags;
3827 Netc_EthSwt_Ip_IPFKeyeData[3U] = NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPORTMASK(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSourcePortIDMask) \
3828 | NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPRTID(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSourcePortID) \
3829 | NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_DSCPMASK(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePointMask) \
3830 | NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_DIFFSCP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePoint);
3831 AuxWord[0U] = NETC_ETHSWT_IP_16BIT_BYTE_SWAP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformationMask);
3832 AuxWord[1U] = NETC_ETHSWT_IP_16BIT_BYTE_SWAP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformation);
3833 Netc_EthSwt_Ip_IPFKeyeData[4U] = ((uint32)AuxWord[0U] << NETC_ETHSWT_IP_16BIT_SHIFT) | (uint32)AuxWord[1U]; /* big endian for TCI */
3834 Netc_EthSwt_Ip_IPFKeyeData[5U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[0U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[1U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3835 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[2U]) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3836 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[3U]) << NETC_ETHSWT_IP_24BIT_SHIFT);
3837 Netc_EthSwt_Ip_IPFKeyeData[6U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[4U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[5U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3838 | (((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[0U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[1U]) << NETC_ETHSWT_IP_8BIT_SHIFT)) << NETC_ETHSWT_IP_16BIT_SHIFT);
3839 Netc_EthSwt_Ip_IPFKeyeData[7U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[2U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[3U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3840 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[4U]) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3841 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[5U]) << NETC_ETHSWT_IP_24BIT_SHIFT);
3842 Netc_EthSwt_Ip_IPFKeyeData[8U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[0U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[1U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3843 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[2U]) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3844 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[3U]) << NETC_ETHSWT_IP_24BIT_SHIFT);
3845 Netc_EthSwt_Ip_IPFKeyeData[9U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[4U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[5U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3846 | (((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[0U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[1U]) << NETC_ETHSWT_IP_8BIT_SHIFT)) << NETC_ETHSWT_IP_16BIT_SHIFT);
3847 Netc_EthSwt_Ip_IPFKeyeData[10U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[2U]) | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[3U]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3848 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[4U]) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3849 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[5U]) << NETC_ETHSWT_IP_24BIT_SHIFT);
3850 AuxWord[0U] = NETC_ETHSWT_IP_16BIT_BYTE_SWAP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformationMask);
3851 AuxWord[1U] = NETC_ETHSWT_IP_16BIT_BYTE_SWAP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformation);
3852 Netc_EthSwt_Ip_IPFKeyeData[11U] = ((uint32)AuxWord[0U] << NETC_ETHSWT_IP_16BIT_SHIFT) | (uint32)AuxWord[1U];
3853 AuxWord[0U] = NETC_ETHSWT_IP_16BIT_BYTE_SWAP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeEtherTypeMask);
3854 AuxWord[1U] = NETC_ETHSWT_IP_16BIT_BYTE_SWAP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeEtherType);
3855 Netc_EthSwt_Ip_IPFKeyeData[12U] = ((uint32)AuxWord[0U] << NETC_ETHSWT_IP_16BIT_SHIFT) | (uint32)AuxWord[1U];
3856 Netc_EthSwt_Ip_IPFKeyeData[13U] = ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPProtocolMask) << NETC_ETHSWT_IP_8BIT_SHIFT) | (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPProtocol);
3857 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3858 {
3859 Netc_EthSwt_Ip_IPFKeyeData[ByteIdx + 17U] = IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPSourceAddress[ByteIdx];
3860 }
3861 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3862 {
3863 Netc_EthSwt_Ip_IPFKeyeData[ByteIdx + 23U] = IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPSourceAddressMask[ByteIdx];
3864 }
3865 AuxWord[0U] = NETC_ETHSWT_IP_16BIT_BYTE_SWAP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4SourcePortMask);
3866 AuxWord[1U] = NETC_ETHSWT_IP_16BIT_BYTE_SWAP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4SourcePort);
3867 Netc_EthSwt_Ip_IPFKeyeData[27U] = ((uint32)AuxWord[0U] << NETC_ETHSWT_IP_16BIT_SHIFT) | (uint32)AuxWord[1U];
3868 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3869 {
3870 Netc_EthSwt_Ip_IPFKeyeData[ByteIdx + 29U] = IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPDestinationAddress[ByteIdx];
3871 }
3872 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3873 {
3874 Netc_EthSwt_Ip_IPFKeyeData[ByteIdx + 35U] = IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPDestinationAddressMask[ByteIdx];
3875 }
3876 AuxWord[0U] = NETC_ETHSWT_IP_16BIT_BYTE_SWAP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4DestinationPortMask);
3877 AuxWord[1U] = NETC_ETHSWT_IP_16BIT_BYTE_SWAP(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4DestinationPort);
3878 Netc_EthSwt_Ip_IPFKeyeData[39U] = ((uint32)AuxWord[0U] << NETC_ETHSWT_IP_16BIT_SHIFT) | (uint32)AuxWord[1U];
3879
3880 CfgeDataIdx = 0U;
3881 PayloadIdx = 0U;
3882 for (ByteIdx = 0U; ByteIdx < 12U; ByteIdx++)
3883 {
3884 Netc_EthSwt_Ip_IPFKeyeData[CfgeDataIdx + 41U] = (uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytes[ByteIdx + PayloadIdx]) \
3885 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytesMask[ByteIdx + PayloadIdx]) << NETC_ETHSWT_IP_8BIT_SHIFT) \
3886 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytes[ByteIdx + PayloadIdx + 1U]) << NETC_ETHSWT_IP_16BIT_SHIFT) \
3887 | ((uint32)(IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytesMask[ByteIdx + PayloadIdx + 1U]) << NETC_ETHSWT_IP_24BIT_SHIFT);
3888 PayloadIdx++;
3889 CfgeDataIdx++;
3890 }
3891
3892 /* only supports "NETC_ETHSWT_TERNARY_MATCH_KEY_ELEMENT_MATCH" access method */
3893 status = Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff(ActionsData, &Netc_EthSwt_Ip_IPFKeyeData[0U], &(IngressPortFilterTableEntry->IngressPortFilterCfgeData), NETC_ETHSWT_TERNARY_MATCH_KEY_ELEMENT_MATCH);
3894 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS == status)
3895 {
3896 /* fill in operation data for config field of Request Header*/
3897 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
3898 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
3899 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_PORT_FILTER_TABLE_ID;
3900 Netc_EthSwt_Ip_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 */
3901 Netc_EthSwt_Ip_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 */
3902 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_REQBUFFER_LEN);
3903 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_RSPBUFFER_LEN);
3904
3905 /* send command */
3906 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
3907 #if defined(ERR_IPV_NETC_051243)
3908 #if (STD_ON == ERR_IPV_NETC_051243)
3909 /* Error code 0x8A is not a real error. check it on Errata. */
3910 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
3911 {
3912 #endif
3913 #else
3914 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
3915 {
3916 #endif
3917 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
3918 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
3919 /* 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. */
3920 IngressPortFilterTableEntry->IngressPortFilterEntryID = TableDataBuffer.TableDataField[1U]; /* Get the Entry_ID from response data buffer */
3921 }
3922 }
3923 else
3924 {
3925 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
3926 }
3927
3928 return status;
3929 }
3930
3931 /* inline function for filling in part of keye data in function Netc_EthSwt_Ip_FillInIPFTableEntryData() */
3932 static inline void Netc_EthSwt_Ip_FillInKeyeDataForIPF(Netc_EthSwt_Ip_IngressPortFilterEntryDataType * IngressPortFilterTableEntry)
3933 {
3934 uint8 ByteIdx;
3935 uint8 PayloadIdx;
3936 uint8 CfgeDataIdx;
3937 uint32 AuxWord;
3938
3939 for (ByteIdx = 2U; ByteIdx < 6U; ByteIdx++)
3940 {
3941 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[ByteIdx] = (uint8)(TableDataBuffer.TableDataField[12U] & NETC_ETHSWT_IP_0XFF_MASK);
3942 TableDataBuffer.TableDataField[12U] >>= NETC_ETHSWT_IP_8BIT_SHIFT;
3943 }
3944 AuxWord = TableDataBuffer.TableDataField[13U] & NETC_ETHSWT_IP_0XFFFF_MASK;
3945 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformation = (uint16)NETC_ETHSWT_IP_16BIT_BYTE_SWAP(AuxWord);
3946 AuxWord = (TableDataBuffer.TableDataField[13U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFFFF_MASK;
3947 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformationMask = (uint16)NETC_ETHSWT_IP_16BIT_BYTE_SWAP(AuxWord);
3948 AuxWord = TableDataBuffer.TableDataField[14U] & NETC_ETHSWT_IP_0XFFFF_MASK;
3949 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeEtherType = (uint16)NETC_ETHSWT_IP_16BIT_BYTE_SWAP(AuxWord);
3950 AuxWord = (TableDataBuffer.TableDataField[14U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFFFF_MASK;
3951 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeEtherTypeMask = (uint16)NETC_ETHSWT_IP_16BIT_BYTE_SWAP(AuxWord);
3952 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPProtocol = (uint8)(TableDataBuffer.TableDataField[15U] & NETC_ETHSWT_IP_0XFF_MASK);
3953 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPProtocolMask = (uint8)((TableDataBuffer.TableDataField[15U] >> NETC_ETHSWT_IP_8BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3954 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3955 {
3956 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPSourceAddress[ByteIdx] = TableDataBuffer.TableDataField[ByteIdx + 19U];
3957 }
3958 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3959 {
3960 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPSourceAddressMask[ByteIdx] = TableDataBuffer.TableDataField[ByteIdx + 25U];
3961 }
3962 AuxWord = TableDataBuffer.TableDataField[29U] & NETC_ETHSWT_IP_0XFFFF_MASK;
3963 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4SourcePort = (uint16)NETC_ETHSWT_IP_16BIT_BYTE_SWAP(AuxWord);
3964 AuxWord = (TableDataBuffer.TableDataField[29U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFFFF_MASK;
3965 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4SourcePortMask = (uint16)NETC_ETHSWT_IP_16BIT_BYTE_SWAP(AuxWord);
3966 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3967 {
3968 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPDestinationAddress[ByteIdx] = TableDataBuffer.TableDataField[ByteIdx + 31U];
3969 }
3970 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
3971 {
3972 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPDestinationAddressMask[ByteIdx] = TableDataBuffer.TableDataField[ByteIdx + 37U];
3973 }
3974 AuxWord = TableDataBuffer.TableDataField[41U] & NETC_ETHSWT_IP_0XFFFF_MASK;
3975 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4DestinationPort = (uint16)NETC_ETHSWT_IP_16BIT_BYTE_SWAP(AuxWord);
3976 AuxWord = (TableDataBuffer.TableDataField[41U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFFFF_MASK;
3977 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4DestinationPortMask = (uint16)NETC_ETHSWT_IP_16BIT_BYTE_SWAP(AuxWord);
3978
3979 CfgeDataIdx = 0U;
3980 PayloadIdx = 0U;
3981 for (ByteIdx = 0U; ByteIdx < 12U; ByteIdx++)
3982 {
3983 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytes[ByteIdx + PayloadIdx] = (uint8)(TableDataBuffer.TableDataField[CfgeDataIdx + 43U] & NETC_ETHSWT_IP_0XFF_MASK);
3984 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytes[ByteIdx + PayloadIdx + 1U] = (uint8)((TableDataBuffer.TableDataField[CfgeDataIdx + 43U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3985 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytesMask[ByteIdx + PayloadIdx] = (uint8)((TableDataBuffer.TableDataField[CfgeDataIdx + 43U] >> NETC_ETHSWT_IP_8BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3986 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytesMask[ByteIdx + PayloadIdx + 1U] = (uint8)((TableDataBuffer.TableDataField[CfgeDataIdx + 43U] >> NETC_ETHSWT_IP_24BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
3987 PayloadIdx++;
3988 CfgeDataIdx++;
3989 }
3990 }
3991
3992 /* inline function for filling in IngressPortFilterTableEntry data in function Netc_EthSwt_Ip_QueryIngressPortFilterTableEntry() */
3993 static inline void Netc_EthSwt_Ip_FillInIPFTableEntryData(Netc_EthSwt_Ip_IngressPortFilterEntryDataType * IngressPortFilterTableEntry)
3994 {
3995 uint8 ByteIdx;
3996 uint32 CfgeData;
3997 uint32 AuxWord;
3998
3999 /* fill in structure Netc_EthSwt_Ip_IngressPortFilterEntryDataType with data from response data buffer */
4000 IngressPortFilterTableEntry->IngressPortFilterEntryID = TableDataBuffer.TableDataField[1U]; /* Entry_ID */
4001
4002 /* KEYE_DATA */
4003 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePrecedence = (uint16)(TableDataBuffer.TableDataField[2U] & NETC_ETHSWT_IP_0XFFFF_MASK);
4004 IngressPortFilterTableEntry->IngressPortFilterkeyeData.keyeFrmAttributeFlags = (uint16)(TableDataBuffer.TableDataField[4U] & NETC_ETHSWT_IP_0XFFFF_MASK);
4005 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeFrmAttributeFlagsMask = (uint16)((TableDataBuffer.TableDataField[4U] & NETC_ETHSWT_IP_0XFFFF0000_MASK) >> NETC_ETHSWT_IP_16BIT_SHIFT);
4006 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePoint = (uint8)(TableDataBuffer.TableDataField[5U] & NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_DIFFSCP_MASK);
4007 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePointMask = (uint8)((TableDataBuffer.TableDataField[5U] & NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_DSCPMASK_MASK) \
4008 >> NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_DSCPMASK_SHIFT);
4009 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSourcePortID = (uint8)((TableDataBuffer.TableDataField[5U] & NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPRTID_MASK) \
4010 >> NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPRTID_SHIFT);
4011 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSourcePortIDMask = (uint8)((TableDataBuffer.TableDataField[5U] & NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPORTMASK_MASK) \
4012 >> NETC_ETHSWT_IP_IPFTABLE_KEYE_DATA_SRCPORTMASK_SHIFT);
4013 AuxWord = TableDataBuffer.TableDataField[6U] & NETC_ETHSWT_IP_0XFFFF_MASK;
4014 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformation = (uint16)NETC_ETHSWT_IP_16BIT_BYTE_SWAP(AuxWord);
4015 AuxWord = (TableDataBuffer.TableDataField[6U] & NETC_ETHSWT_IP_0XFFFF0000_MASK) >> NETC_ETHSWT_IP_16BIT_SHIFT;
4016 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformationMask = (uint16)NETC_ETHSWT_IP_16BIT_BYTE_SWAP(AuxWord);
4017 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
4018 {
4019 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[ByteIdx] = (uint8)(TableDataBuffer.TableDataField[7U] & NETC_ETHSWT_IP_0XFF_MASK);
4020 TableDataBuffer.TableDataField[7U] >>= NETC_ETHSWT_IP_8BIT_SHIFT;
4021 }
4022 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[4U] = (uint8)(TableDataBuffer.TableDataField[8U] & NETC_ETHSWT_IP_0XFF_MASK);
4023 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[5U] = (uint8)((TableDataBuffer.TableDataField[8U] >> NETC_ETHSWT_IP_8BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
4024 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[0U] = (uint8)((TableDataBuffer.TableDataField[8U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
4025 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[1U] = (uint8)((TableDataBuffer.TableDataField[8U] >> NETC_ETHSWT_IP_24BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
4026 for (ByteIdx = 2U; ByteIdx < 6U; ByteIdx++)
4027 {
4028 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[ByteIdx] = (uint8)(TableDataBuffer.TableDataField[9U] & NETC_ETHSWT_IP_0XFF_MASK);
4029 TableDataBuffer.TableDataField[9U] >>= NETC_ETHSWT_IP_8BIT_SHIFT;
4030 }
4031 for (ByteIdx = 0U; ByteIdx < 4U; ByteIdx++)
4032 {
4033 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[ByteIdx] = (uint8)(TableDataBuffer.TableDataField[10U] & NETC_ETHSWT_IP_0XFF_MASK);
4034 TableDataBuffer.TableDataField[10U] >>= NETC_ETHSWT_IP_8BIT_SHIFT;
4035 }
4036 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[4U] = (uint8)(TableDataBuffer.TableDataField[11U] & NETC_ETHSWT_IP_0XFF_MASK);
4037 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[5U] = (uint8)((TableDataBuffer.TableDataField[11U] >> NETC_ETHSWT_IP_8BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
4038 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[0U] = (uint8)((TableDataBuffer.TableDataField[11U] >> NETC_ETHSWT_IP_16BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
4039 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[1U] = ((uint8)(TableDataBuffer.TableDataField[11U] >> NETC_ETHSWT_IP_24BIT_SHIFT) & NETC_ETHSWT_IP_0XFF_MASK);
4040
4041 Netc_EthSwt_Ip_FillInKeyeDataForIPF(IngressPortFilterTableEntry); /* fill in the rest part of the KEYE_DATA */
4042
4043 /* Match Count data */
4044 IngressPortFilterTableEntry->IngressPortFilterMatchCount = (uint64)(TableDataBuffer.TableDataField[55U]);
4045 IngressPortFilterTableEntry->IngressPortFilterMatchCount |= ((uint64)(TableDataBuffer.TableDataField[56U]) << NETC_ETHSWT_IP_32BIT_SHIFT);
4046
4047 /* CFGE_DATA */
4048 CfgeData = TableDataBuffer.TableDataField[57U]; /* config field in CFGE_DATA */
4049 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeIpv = (uint8)(CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_IPV_MASK);
4050 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeOverrideIpv = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_OIPV_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_OIPV_SHIFT) != 0x0UL) ? TRUE : FALSE;
4051 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeDr = (uint8)((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_DR_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_DR_SHIFT);
4052 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeOverrideDr = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_ODR_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_ODR_SHIFT) != 0x0UL) ? TRUE : FALSE;
4053 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeFilterForwardingAction = ((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTFA_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTFA_SHIFT);
4054 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeIngressMirroringEnable = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_IMIRE_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_IMIRE_SHIFT) != 0x0UL) ? TRUE : FALSE;
4055 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeWakeOnLanTriggerEnable = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_WOLTE_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_WOLTE_SHIFT) != 0x0UL) ? TRUE : FALSE;
4056 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeFilterAction = ((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTA_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_FLTA_SHIFT);
4057 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeRelativePrecedentResolution = (uint8)((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_RPR_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_RPR_SHIFT);
4058 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeCutThroughDisable = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_CTD_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_CTD_SHIFT) != 0x0UL) ? TRUE : FALSE;
4059 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeHostReason = (uint8)((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_HR_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_HR_SHIFT);
4060 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeTimestampCaptureEable = (((CfgeData & NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_TIMECAP_MASK) >> NETC_ETHSWT_IP_IPFTABLE_CFGE_CONFIG_TIMECAP_SHIFT) != 0x0UL) ? TRUE : FALSE;
4061 }
4062
4063 /*FUNCTION**********************************************************************
4064 *
4065 * Function Name : Netc_EthSwt_Ip_QueryIngressPortFilterTableEntry
4066 * Description : Ethernet Switch querys Ingress Port Filter table entry function.
4067 * implements Netc_EthSwt_Ip_QueryIngressPortFilterTableEntry_Activity
4068 *END**************************************************************************/
4069 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngressPortFilterTableEntry( uint8 SwitchIdx,
4070 uint32 *MatchedEntries,
4071 Netc_EthSwt_Ip_IngressPortFilterEntryDataType * IngressPortFilterTableEntry
4072 )
4073 {
4074 Netc_EthSwt_Ip_CBDRStatusType status;
4075 uint32 KeyeData[NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_KEYE_DATA_LEN];
4076 uint32 ActionsData;
4077
4078
4079 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
4080 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4081 DevAssert(MatchedEntries != NULL_PTR);
4082 DevAssert(IngressPortFilterTableEntry != NULL_PTR);
4083 #endif
4084
4085 /* clear the variable MatchedEntries first */
4086 *MatchedEntries = 0U;
4087
4088 /* only support "full query" */
4089 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY);
4090
4091 /* inialize KEYE_DATA with Entry_ID */
4092 KeyeData[0U] = IngressPortFilterTableEntry->IngressPortFilterEntryID;
4093
4094 status = Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff(ActionsData, &KeyeData[0U], NULL_PTR, NETC_ETHSWT_ENTRY_ID_MATCH);
4095 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS == status)
4096 {
4097 /* fill in operation data for config field of Request Header*/
4098 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
4099 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
4100 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_PORT_FILTER_TABLE_ID;
4101 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
4102 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
4103 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_REQBUFFER_LEN);
4104 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_RSPBUFFER_LEN);
4105
4106 /* send command */
4107 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
4108 #if defined(ERR_IPV_NETC_051243)
4109 #if (STD_ON == ERR_IPV_NETC_051243)
4110 /* Error code 0x8A is not a real error. check it on Errata. */
4111 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
4112 {
4113 #endif
4114 #else
4115 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
4116 {
4117 #endif
4118 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
4119 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
4120 /* if found a matched entry, then fill in the structure */
4121 if (1U == *MatchedEntries)
4122 {
4123 Netc_EthSwt_Ip_FillInIPFTableEntryData(IngressPortFilterTableEntry);
4124 }
4125 }
4126 }
4127 else
4128 {
4129 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
4130 }
4131
4132 return status;
4133 }
4134
4135 /*FUNCTION**********************************************************************
4136 *
4137 * Function Name : Netc_EthSwt_Ip_DeleteIngressPortFilterTableEntry
4138 * Description : Ethernet Switch deletes Ingress Port Filter table entry function.
4139 * implements Netc_EthSwt_Ip_DeleteIngressPortFilterTableEntry_Activity
4140 *END**************************************************************************/
4141 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngressPortFilterTableEntry( uint8 SwitchIdx,
4142 uint32 *MatchedEntries,
4143 uint32 IngressPortFilterEntry
4144 )
4145 {
4146 Netc_EthSwt_Ip_CBDRStatusType status;
4147 uint32 KeyeData[1U];
4148 uint32 ActionsData = 0x0UL;
4149
4150 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
4151 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4152 DevAssert(MatchedEntries != NULL_PTR);
4153 #endif
4154
4155 /* clear the variable MatchedEntries first */
4156 *MatchedEntries = 0U;
4157
4158 /* inialize KEYE_DATA with Entry_ID */
4159 KeyeData[0U] = IngressPortFilterEntry;
4160
4161 status = Netc_EthSwt_Ip_FillInIngressPortFilterTableReqDataBuff(ActionsData, &KeyeData[0U], NULL_PTR, NETC_ETHSWT_ENTRY_ID_MATCH);
4162 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS == status)
4163 {
4164 /* fill in operation data for config field of Request Header*/
4165 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
4166 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
4167 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_PORT_FILTER_TABLE_ID;
4168 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
4169 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
4170 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_REQBUFFER_LEN);
4171 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
4172
4173 /* send command */
4174 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
4175 #if defined(ERR_IPV_NETC_051243)
4176 #if (STD_ON == ERR_IPV_NETC_051243)
4177 /* Error code 0x8A is not a real error. check it on Errata. */
4178 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
4179 {
4180 #endif
4181 #else
4182 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
4183 {
4184 #endif
4185 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
4186 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
4187 }
4188 }
4189 else
4190 {
4191 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
4192 }
4193
4194 return status;
4195 }
4196
4197 /*FUNCTION**********************************************************************
4198 *
4199 * Function Name : Netc_EthSwt_Ip_ConfigPortTimeGateScheduling
4200 * Description : Ethernet Switch enables or disables Time Gate Scheduling function on a port.
4201 * implements Netc_EthSwt_Ip_ConfigPortTimeGateScheduling_Activity
4202 *
4203 *END**************************************************************************/
4204 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_ConfigPortTimeGateScheduling( uint8 SwitchIdx,
4205 uint8 SwitchPortIdx,
4206 boolean Enable
4207 )
4208 {
4209 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
4210 uint32 RegValue;
4211 uint32 GateControlListState;
4212 uint32 StartTime;
4213 uint32 ElapsedTime;
4214 uint32 TimeoutTicks;
4215 boolean TimeExpired;
4216
4217 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
4218 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4219 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
4220 #endif
4221
4222 (void)SwitchIdx;
4223 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_60();
4224 /* read the reg value first */
4225 RegValue = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PTGSCR;
4226 if ((RegValue & SW_PORT0_PTGSCR_TGE_MASK) != SW_PORT0_PTGSCR_TGE_MASK) /* time gating is disabled */
4227 {
4228 if (TRUE == Enable)
4229 {
4230 /* Software must also wait until PTGAGLSR[TG] is deasserted before re-enabling. */
4231 Netc_EthSwt_Ip_StartTimeOut(&StartTime, &ElapsedTime, &TimeoutTicks, NETC_ETHSWT_IP_TIMEOUT_VALUE_US);
4232 do {
4233 /* get the state of gate control list */
4234 GateControlListState = (Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PTGAGLSR & SW_PORT0_PTGAGLSR_TG_MASK);
4235 TimeExpired = Netc_EthSwt_Ip_TimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks);
4236 #ifdef MCAL_ENABLE_FAULT_INJECTION
4237 MCAL_FAULT_INJECTION_POINT(ETHSWT_CHECK_TG_TIMEOUT);
4238 #endif
4239 } while ((GateControlListState != 0x0U) && (FALSE == TimeExpired));
4240
4241 if (GateControlListState == 0x0U)
4242 {
4243 RegValue |= SW_PORT0_PTGSCR_TGE(1U); /* Enable time gating */
4244 }
4245 else
4246 {
4247 status = E_NOT_OK; /* fail to enable time gating because Operational gate control list is active */
4248 }
4249 }
4250 }
4251 else /* time gating is enabled */
4252 {
4253 if (FALSE == Enable)
4254 {
4255 RegValue &= ~SW_PORT0_PTGSCR_TGE(1U); /* Disable time gating */
4256 }
4257 }
4258
4259 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
4260 {
4261 /* write it back. */
4262 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PTGSCR = RegValue;
4263 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_60();
4264
4265 /* if time gate scheduling is enabled, and entry data is configured, then adds the entry */
4266 if ((TRUE == Enable) && (TRUE == PortTimeAwareShaperEnabled[SwitchPortIdx]))
4267 {
4268 status = Netc_EthSwt_Ip_AddOrUpdateTimeGateSchedulingTableEntry(0U, &TimeGateSchedulingEntryData[SwitchPortIdx]);
4269 /* fail to add or update the time gate schedulling table entry */
4270 if (status != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
4271 {
4272 status = E_NOT_OK;
4273 }
4274 }
4275 }
4276 else
4277 {
4278 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_60();
4279 }
4280
4281 return status;
4282 }
4283
4284 static inline void Netc_EthSwt_Ip_FillInGateControlListData(const uint8 *OperationTimeIdx, const Netc_EthSwt_Ip_TimeGateSchedulingEntryDataType *TimeGateSchedulingTableEntry)
4285 {
4286 uint8 CFGEDataIdx;
4287 uint16 GateEntryIdx;
4288 uint8 HostRequest;
4289
4290 if (*OperationTimeIdx == 1U)
4291 {
4292 CFGEDataIdx = 0U;
4293 #if (NETC_ETHSWT_MAX_NUMBER_OF_GATECONTROLLIST_ENTRIES > 0U)
4294 for (GateEntryIdx = 0U; GateEntryIdx < TimeGateSchedulingTableEntry->AdminControlListLength; GateEntryIdx++)
4295 {
4296 TableDataBuffer.TableDataField[(uint8)(NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA5) + CFGEDataIdx] = TimeGateSchedulingTableEntry->GateEntryAdminControlListData[GateEntryIdx].AdminTimeInterval;
4297 /* convert gate operation type */
4298 switch (TimeGateSchedulingTableEntry->GateEntryAdminControlListData[GateEntryIdx].AdminGateOperationType)
4299 {
4300 case ETHSWT_HOST_REQUEST_UNCHANGED:
4301 HostRequest = 0U;
4302 break;
4303 case ETHSWT_HOST_REQUEST_HOLD:
4304 HostRequest = 1U;
4305 break;
4306 case ETHSWT_HOST_REQUEST_RELEASE:
4307 HostRequest = 2U;
4308 break;
4309 default:
4310 HostRequest = 0U;
4311 break;
4312 }
4313 TableDataBuffer.TableDataField[(uint8)(NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA6) + CFGEDataIdx] = NETC_ETHSWT_IP_TGSTABLE_CFGE_ADMIN_TC_STATES(TimeGateSchedulingTableEntry->GateEntryAdminControlListData[GateEntryIdx].AdminTrafficClassGateStates) \
4314 | NETC_ETHSWT_IP_TGSTABLE_CFGE_ADMIN_HR_CB(HostRequest);
4315
4316 CFGEDataIdx += 2U; /* CFGE data field index increased by 2 */
4317 }
4318 #endif
4319 }
4320 }
4321
4322 /*FUNCTION**********************************************************************
4323 *
4324 * Function Name : Netc_EthSwt_Ip_AddOrUpdateTimeGateSchedulingTableEntry
4325 * Description : Ethernet Switch adds or updates Time Gate Scheduling table entry function.
4326 * implements Netc_EthSwt_Ip_AddOrUpdateTimeGateSchedulingTableEntry_Activity
4327 *
4328 *END**************************************************************************/
4329 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateTimeGateSchedulingTableEntry( uint8 SwitchIdx,
4330 const Netc_EthSwt_Ip_TimeGateSchedulingEntryDataType *TimeGateSchedulingTableEntry
4331 )
4332 {
4333 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
4334 uint8 OperationTimes;
4335 uint8 OperationTimeIdx;
4336 volatile uint64 CurrentTime = 0;
4337 uint64 CycleFactor;
4338 uint64 NewBaseTime;
4339 uint64 LookaheadTime;
4340 uint64 ComparisonValue;
4341 #if defined(ERR_IPV_NETC_051587)
4342 #if (STD_ON == ERR_IPV_NETC_051587)
4343 uint64 AdminCtrlListLength;
4344 uint64 CmdProccesingTime;
4345 uint32 NetcClkPeriod;
4346 #endif
4347 #endif
4348
4349 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
4350 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4351 DevAssert(TimeGateSchedulingTableEntry != NULL_PTR);
4352 #endif
4353
4354 /* AdminControlListLength = 0U means to reset the gate control list or add the time gate scheduling entry without gate control list */
4355 OperationTimes = (TimeGateSchedulingTableEntry->AdminControlListLength > 0U) ? 2U : 1U;
4356 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_43();
4357
4358 /* for adding or updating gate control list, we'll have to remove the gate control list firstly */
4359 for (OperationTimeIdx = 0U; OperationTimeIdx < OperationTimes; OperationTimeIdx++)
4360 {
4361
4362 /* ++++++ initialize the table request data buffer ++++++ */
4363 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U); /* fill in Actions field */
4364 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = TimeGateSchedulingTableEntry->TimeGateSchedulingTable_EID; /* fill in Entry ID */
4365 /* fill in CFGE_DATA */
4366 /* get the current time from 1588 timer */
4367 CurrentTime = Netc_EthSwt_Ip_TimerBase->TMR_CUR_TIME_L; /* should read the Lower register first */
4368 CurrentTime |= ((uint64)(Netc_EthSwt_Ip_TimerBase->TMR_CUR_TIME_H)) << NETC_ETHSWT_IP_32BIT_SHIFT;
4369 /* get lookaheadtime */
4370 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; */
4371
4372 /* calculate the NewBaseTime */
4373 #if defined(ERR_IPV_NETC_051587)
4374 #if (STD_ON == ERR_IPV_NETC_051587)
4375 NetcClkPeriod = (Netc_EthSwt_Ip_TimerBase->TMR_CTRL & TMR0_BASE_TMR_CTRL_TCLK_PERIOD_MASK) >> TMR0_BASE_TMR_CTRL_TCLK_PERIOD_SHIFT;
4376 AdminCtrlListLength = (uint64)(TimeGateSchedulingTableEntry->AdminControlListLength);
4377 CmdProccesingTime = (300UL + (AdminCtrlListLength*7UL) + (AdminCtrlListLength*AdminCtrlListLength*5UL)) * ((uint64)NetcClkPeriod);
4378
4379 ComparisonValue = CurrentTime + LookaheadTime + CmdProccesingTime + ((uint64)2U * (uint64)TimeGateSchedulingTableEntry->AdminCycleTime);
4380 if ((Netc_EthSwt_Ip_TGSAdminListRegistered[TimeGateSchedulingTableEntry->TimeGateSchedulingTable_EID] == (boolean)FALSE) || \
4381 (TimeGateSchedulingTableEntry->AdminBaseTime >= ComparisonValue))
4382 #else
4383 ComparisonValue = CurrentTime + LookaheadTime;
4384 if (TimeGateSchedulingTableEntry->AdminBaseTime >= ComparisonValue)
4385 #endif
4386 #else
4387 ComparisonValue = CurrentTime + LookaheadTime;
4388 if (TimeGateSchedulingTableEntry->AdminBaseTime >= ComparisonValue)
4389 #endif
4390 {
4391 NewBaseTime = TimeGateSchedulingTableEntry->AdminBaseTime;
4392 }
4393 else
4394 {
4395 #if defined(ERR_IPV_NETC_051587)
4396 #if (STD_ON == ERR_IPV_NETC_051587)
4397 CycleFactor = ((CurrentTime + LookaheadTime + CmdProccesingTime - TimeGateSchedulingTableEntry->AdminBaseTime) / ((uint64)TimeGateSchedulingTableEntry->AdminCycleTime)) + 2U;
4398 #else
4399 CycleFactor = (CurrentTime + LookaheadTime - TimeGateSchedulingTableEntry->AdminBaseTime) / ((uint64)TimeGateSchedulingTableEntry->AdminCycleTime);
4400 #endif
4401 #else
4402 CycleFactor = (CurrentTime + LookaheadTime - TimeGateSchedulingTableEntry->AdminBaseTime) / (TimeGateSchedulingTableEntry->AdminCycleTime);
4403 #endif
4404 NewBaseTime = TimeGateSchedulingTableEntry->AdminBaseTime + ((CycleFactor + 1UL) * (uint64)(TimeGateSchedulingTableEntry->AdminCycleTime));
4405 }
4406 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = (uint32)(NewBaseTime & (NETC_ETHSWT_IP_BD_NULL_ENTRY_ID));
4407 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = (uint32)(NewBaseTime >> NETC_ETHSWT_IP_32BIT_SHIFT);
4408 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = TimeGateSchedulingTableEntry->AdminCycleTime;
4409 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = TimeGateSchedulingTableEntry->AdminCycleTimeExt;
4410 /* set Administrative Control List Length to 0 for removing the admin gate control list or adding an entry with no administrative gate control list */
4411 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = (OperationTimeIdx == 0U) ? 0x0UL : (uint32)(TimeGateSchedulingTableEntry->AdminControlListLength);
4412
4413 Netc_EthSwt_Ip_FillInGateControlListData(&OperationTimeIdx, TimeGateSchedulingTableEntry);
4414 /* ------ initialize the table request data buffer ------ */
4415
4416 /* fill in operation data for config field of Request Header*/
4417 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
4418 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
4419 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_TIME_GATE_SCHEDULING_TABLE_ID;
4420 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* only support NETC_ETHSWT_ENTRY_ID_MATCH method */
4421 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_UPDATE_CMD; /* can only use "update" command to add or update an time gate scheduling table entry */
4422 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TGSTABLE_ADD_REQBUFFER_LEN);
4423 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TGSTABLE_RSPBUFFER_LEN);
4424
4425 /* send "update" command to add/remove gate control list */
4426 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
4427
4428 #if defined(ERR_IPV_NETC_051254)
4429 #if (STD_ON == ERR_IPV_NETC_051254)
4430 if (NETC_ETHSWT_IP_CBDRSTATUS_ADMIN_BASE_TIME_IS_MORE_THAN_1S == status)
4431 {
4432 /* set Administrative Control List Length to 0 for removing the admin gate control list */
4433 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = 0x0UL;
4434
4435 Netc_EthSwt_Ip_FillInGateControlListData(&OperationTimeIdx, TimeGateSchedulingTableEntry);
4436 /* send "update" command to remove gate control list */
4437 (void)Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
4438 }
4439 #endif
4440 #endif
4441
4442 #if defined(ERR_IPV_NETC_051243)
4443 #if (STD_ON == ERR_IPV_NETC_051243)
4444 /* Error code 0x8A is not a real error. check it on Errata. */
4445 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
4446 {
4447 #endif
4448 #else
4449 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
4450 {
4451 #endif
4452 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
4453 }
4454 }
4455
4456 #if defined(ERR_IPV_NETC_051587)
4457 #if (STD_ON == ERR_IPV_NETC_051587)
4458 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
4459 {
4460 Netc_EthSwt_Ip_TGSAdminListRegistered[TimeGateSchedulingTableEntry->TimeGateSchedulingTable_EID] = (boolean)TRUE;
4461 }
4462 #endif
4463 #endif
4464
4465 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_43();
4466
4467 return status;
4468 }
4469
4470 /*!
4471 * @brief : Function for accessing 64 bits counters.
4472 * @details : Function for extracting the counter value using base/offset
4473 *
4474 * @param[in] baseAddressValue base address in uint32
4475 * @param[in] offsetAddressValue offset from the base
4476 *
4477 * @return Register value
4478 */
4479 static inline uint64 Netc_EthSwt_Ip_Extract64bitsFrom32bitsReg(const uint32 baseAddressValue, const uint32 offsetAddressValue)
4480 {
4481 uint32 lessSignificantPtrValue;
4482 const volatile uint32 *ptrToLessSignificantData;
4483 uint64 lessSignificantAddressData, mostSignificantAddressData;
4484
4485 /* The 64bits counter are in two chunk of 32bits */
4486 /* We will need to make some arithmitic on the pointers */
4487
4488 /* The most significant is higher in memory, the next address to get the next 32 bits */
4489 lessSignificantPtrValue = baseAddressValue + offsetAddressValue;
4490
4491 /* Convert back the numbers in pointers */
4492 ptrToLessSignificantData = (volatile uint32 *) lessSignificantPtrValue;
4493 #if defined(ERR_IPV_NETC_050679)
4494 /*
4495 Workaround for ERR050679:
4496 Accesses to 64-bit stats registers must be performed atomically
4497 */
4498 #if (STD_ON == ERR_IPV_NETC_050679)
4499 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_00();
4500 #endif
4501 #endif
4502
4503 /* Extract the two 32 bits of data, lower address must be read first, this will lock the higher part */
4504 /* 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 */
4505 lessSignificantAddressData = ptrToLessSignificantData[0U]; /* must be first */
4506 mostSignificantAddressData = ptrToLessSignificantData[1U];
4507
4508 #if defined(ERR_IPV_NETC_050679)
4509 #if (STD_ON == ERR_IPV_NETC_050679)
4510 /*
4511 Workaround for ERR050679:
4512 Accesses to 64-bit stats registers must be performed atomically
4513 */
4514 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_00();
4515 #endif
4516 #endif
4517
4518 /* putting it all together */
4519 return ((mostSignificantAddressData << NETC_ETHSWT_IP_32BIT_SHIFT) | lessSignificantAddressData);
4520 }
4521
4522 /*!
4523 * @brief : Function for accessing 64 bits counters in a table.
4524 * @details : Function for getting the 64 bits counters using two 32 bits accesses.
4525 *
4526 * @param[in] Reg 64bits register pointer
4527 *
4528 * @return Register value
4529 */
4530 static inline uint64 Netc_EthSwt_Ip_GetCounterLocal(const volatile uint64 *Reg)
4531 {
4532 return Netc_EthSwt_Ip_Extract64bitsFrom32bitsReg((uint32) Reg, 0U);
4533 }
4534
4535 /*!
4536 * @brief Ethernet Switch get port index counter values function.
4537 *
4538 * @param[in] SwitchIdx
4539 * @param[in] PortIndex
4540 * @param[in] Counter
4541 *
4542 * @return Std Error
4543 */
4544 static Std_ReturnType Netc_EthSwt_Ip_GetSwtPortCounters( uint8 SwitchIdx, uint8 PortIndex, Netc_EthSwt_Ip_CounterType *Counter )
4545 {
4546 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
4547 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4548 #endif
4549
4550 (void)SwitchIdx;
4551
4552 /* Receive */
4553 /* Port MAC index Receive Ethernet Octets Counter(etherStatsOctetsn) */
4554 Counter->rxEtherOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_REOCTN));
4555 Counter->rxEtherOctetCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_REOCTN));
4556
4557
4558 /* Port MAC index Receive Octets Counter(iflnOctetsn) */
4559 Counter->rxOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_ROCTN));
4560 Counter->rxOctetCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_ROCTN));
4561
4562 /* Port MAC index Receive Alignment Error Counter Register(aAlignmentErrorsn) */
4563 /* Reserved */
4564
4565 /* Port MAC index Receive Valid Pause Frame Counter Register(aPAUSEMACCtrlFramesReceivedn) */
4566 Counter->rxValidPauseFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RXPFN);
4567 Counter->rxValidPauseFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RXPFN));
4568
4569 /* Port MAC index Receive Frame Counter */
4570 Counter->rxFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RFRMN);
4571 Counter->rxFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RFRMN));
4572
4573 /* Port MAC index Receive Frame Check Sequence Error Counter */
4574 Counter->rxFrameCheckSequenceErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RFCSN);
4575 Counter->rxFrameCheckSequenceErrorCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RFCSN));
4576
4577 /* Port MAC index Receive VLAN Frame Counter */
4578 Counter->rxVlanFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RVLANN);
4579 Counter->rxVlanFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RVLANN));
4580
4581 /* Port MAC index Receive Frame Error Counter Register(ifInErrorsn) */
4582 Counter->rxFrameErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RERRN);
4583 Counter->rxFrameErrorCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RERRN));
4584
4585 /* Port MAC index Receive Unicast Frame Counter */
4586 Counter->rxUnicastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RUCAN);
4587 Counter->rxUnicastFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RUCAN));
4588
4589 /* Port MAC index Receive Multicast Frame Counter */
4590 Counter->rxMulticastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RMCAN);
4591 Counter->rxMulticastFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RMCAN));
4592
4593 /* Port MAC index Receive Broadcast Frame Counter */
4594 Counter->rxBroadcastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RBCAN);
4595 Counter->rxBroadcastFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RBCAN));
4596
4597 /* Port MAC index Receive Dropped Packets Counter Register(etherStatsDropEventsn) */
4598 Counter->rxDroppedPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RDRPN);
4599 Counter->rxDroppedPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RDRPN));
4600
4601 /* Port MAC index Receive Packets Counter Register(etherStatsPktsn) */
4602 Counter->rxPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RPKTN);
4603 Counter->rxPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RPKTN));
4604
4605 /* Port MAC index Receive Undersized Packet Counter */
4606 Counter->rxUndersizePacketCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RUNDN);
4607 Counter->rxUndersizePacketCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RUNDN));
4608
4609 /* Port MAC index Receive 64-Octet Packet Counter Register(etherStatsPkts64OctetsN) */
4610 Counter->rx64OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R64N);
4611 Counter->rx64OctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R64N));
4612
4613 /* Port MAC index Receive 65 to 127-Octet Packet Counter Register(etherStatsPkts65to127OctetsN) */
4614 Counter->rx65to127OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R127N);
4615 Counter->rx65to127OctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R127N));
4616
4617 /* Port MAC index Receive 128 to 255-Octet Packet Counter Register(etherStatsPkts128to255OctetsN) */
4618 Counter->rx128to255OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R255N);
4619 Counter->rxBroadcastFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R255N));
4620
4621 /* Port MAC index Receive 256 to 511-Octet Packet Counter Register(etherStatsPkts256to511OctetsN) */
4622 Counter->rx256to511OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R511N);
4623 Counter->rx256to511OctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R511N));
4624
4625 /* Port MAC index Receive 512 to 1023-Octet Packet Counter Register(etherStatsPkts512to1023OctetsN) */
4626 Counter->rx512to1023OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R1023N);
4627 Counter->rx512to1023OctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R1023N));
4628
4629 /* Port MAC index Receive 1024 to 1522-Octet Packet Counter Register(etherStatsPkts1024to1522OctetsN) */
4630 Counter->rx1024to1522OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R1522N);
4631 Counter->rx1024to1522OctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R1522N));
4632
4633 /* Port MAC index Receive 1523 to Max-Octet Packet Counter Register(etherStatsPkts1523toMaxOctetsN) */
4634 Counter->rx1523toMaxOctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R1523XN);
4635 Counter->rx1523toMaxOctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R1523XN));
4636
4637 /* Port MAC index Receive Oversized Packet Counter */
4638 Counter->rxOversizedPacketsCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_ROVRN);
4639 Counter->rxOversizedPacketsCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_ROVRN));
4640
4641 /* Port MAC index Receive Jabber Packet Counter Register(etherStatsJabbersn) */
4642 Counter->rxJabberPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RJBRN);
4643 Counter->rxJabberPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RJBRN));
4644
4645 /* Port MAC index Receive Fragment Packet Counter Register(etherStatsFragmentsn) */
4646 Counter->rxFragmentPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RFRGN);
4647 Counter->rxFragmentPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RFRGN));
4648
4649 /* Port MAC index Receive Control Packet Counter Register */
4650 Counter->rxControlPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RCNPN);
4651 Counter->rxControlPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RCNPN));
4652
4653 /* Port MAC index Receive Dropped Not Truncated Packets Counter Register(etherStatsDropEventsn) */
4654 Counter->rxDroppedNTruncatedPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RDRNTPN);
4655 Counter->rxDroppedNTruncatedPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RDRNTPN));
4656
4657 /* Port Rx discard count register */
4658 Counter->rxDiscardCounter = Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PRXDCR;
4659
4660 /* Transmit */
4661 /* Port MAC index Transmit Ethernet Octets Counter(etherStatsOctetsn) */
4662 Counter->txEtherOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TEOCTN);
4663 Counter->txEtherOctetCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TEOCTN));
4664
4665 /* Port MAC index Transmit Octets Counter Register(ifOutOctetsn) */
4666 Counter->txOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TOCTN);
4667 Counter->txOctetCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TOCTN));
4668
4669 /* Port MAC index Transmit Valid Pause Frame Counter Register(aPAUSEMACCtrlFramesReceivedn) */
4670 Counter->txValidPauseFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TXPFN);
4671 Counter->txValidPauseFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TXPFN));
4672
4673 /* Port MAC index Transmit Frame Counter */
4674 Counter->txFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TFRMN);
4675 Counter->txFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TFRMN));
4676
4677 /* Port MAC index Transmit Frame Check Sequence Error Counter */
4678 Counter->txFrameCheckSequenceErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TFCSN);
4679 Counter->txFrameCheckSequenceErrorCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TFCSN));
4680
4681 /* Port MAC index Transmit VLAN Frame Counter */
4682 Counter->txVlanFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TVLANN);
4683 Counter->txVlanFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TVLANN));
4684
4685 /* Port MAC index Transmit Frame Error Counter Register(ifOutErrorsn) */
4686 Counter->txFrameErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TERRN);
4687 Counter->txFrameErrorCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TERRN));
4688
4689 /* Port MAC index Transmit Unicast Frame Counter */
4690 Counter->txUnicastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TUCAN);
4691 Counter->txUnicastFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TUCAN));
4692
4693 /* Port MAC index Transmit Multicast Frame Counter */
4694 Counter->txMulticastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TMCAN);
4695 Counter->txMulticastFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TMCAN));
4696
4697 /* Port MAC index Transmit Broadcast Frame Counter */
4698 Counter->txBroadcastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TBCAN);
4699 Counter->txBroadcastFrmCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TBCAN));
4700
4701 /* Port MAC index Transmit Packets Counter Register(etherStatsPktsN; */
4702 Counter->txPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TPKTN);
4703 Counter->txPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TPKTN));
4704
4705 /* Port MAC index Transmit Undersized Packet Counter */
4706 Counter->txUndersizePacketCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TUNDN);
4707 Counter->txUndersizePacketCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TUNDN));
4708
4709 /* Port MAC index Transmit 64-Octet Packet Counter Register (etherStatsPkts64OctetsN) */
4710 Counter->tx64OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T64N);
4711 Counter->tx64OctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T64N));
4712
4713 /* Port MAC index Transmit 65 to 127-Octet Packet Counter Register (etherStatsPkts65to127OctetsN) */
4714 Counter->tx65to127OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T127N);
4715 Counter->tx65to127OctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T127N));
4716
4717 /* Port MAC index Transmit 128 to 255-Octet Packet Counter Register (etherStatsPkts128to255OctetsN) */
4718 Counter->tx128to255OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T255N);
4719 Counter->tx128to255OctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T255N));
4720
4721 /* Port MAC index Transmit 256 to 511-Octet Packet Counter Register (etherStatsPkts256to511OctetsN) */
4722 Counter->tx256to511OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T511N);
4723 Counter->tx256to511OctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T511N));
4724
4725 /* Port MAC index Transmit 512 to 1023-Octet Packet Counter Register (etherStatsPkts512to1023OctetsN) */
4726 Counter->tx512to1023OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T1023N);
4727 Counter->tx512to1023OctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T1023N));
4728
4729 /* Port MAC index Transmit 1024 to 1522-Octet Packet Counter Register (etherStatsPkts1024to1522OctetsN) */
4730 Counter->tx1024to1522OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T1522N);
4731 Counter->tx1024to1522OctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T1522N));
4732
4733 /* Port MAC index Transmit 1523 to TX_MTU-Octet Packet Counter Register (etherStatsPkts1523toMaxOctetsN) */
4734 Counter->tx1523toMaxOctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T1523XN);
4735 Counter->tx1523toMaxOctetPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T1523XN));
4736
4737 /* Port MAC index Transmit Control Packet Counter Register */
4738 Counter->txControlPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TCNPN);
4739 Counter->txControlPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TCNPN));
4740
4741 /* Port MAC index Transmit Deferred Packet Counter Register(aFramesWithDeferredXmissions) */
4742 Counter->txDeferredPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TDFRN);
4743 Counter->txDeferredPktCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TDFRN));
4744
4745 /* Port MAC index Transmit Multiple Collisions Counter Register */
4746 Counter->txMultiCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TMCOLN);
4747 Counter->txMultiCollisionCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TMCOLN));
4748
4749 /* Port MAC index Transmit Single Collision Counter Register */
4750 Counter->txSingleCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TSCOLN);
4751 Counter->txSingleCollisionCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TSCOLN));
4752
4753 /* Port MAC index Transmit Late Collision Counter(aLateCollisions) Register */
4754 Counter->txLateCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TLCOLN);
4755 Counter->txLateCollisionCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TLCOLN));
4756
4757 /* Port MAC index Transmit Excessive Collisions Counter Register */
4758 Counter->txExcessiveCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TECOLN);
4759 Counter->txExcessiveCollisionCounter += Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TECOLN));
4760
4761 #if defined(ERR_IPV_NETC_E051023)
4762 #if (STD_ON == ERR_IPV_NETC_E051023)
4763 /* ERR051023: NETC: Excessive collisions are counted as late collisions */
4764 Counter->txLateCollisionCounter -= Counter->txExcessiveCollisionCounter;
4765 #endif
4766 #endif
4767
4768 /* Port Tx discard count register */
4769 Counter->txDiscardCounter = Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PTXDCR;
4770
4771 #if defined(ERR_IPV_NETC_E051129)
4772 #if (STD_ON == ERR_IPV_NETC_E051129)
4773 /* Errata ERR051129: Uncorrectable non-fatal integrity error count register */
4774 Counter->unIntegrityErrorCounter = IP_NETC__SW0_COMMON->UNIECTR;
4775 Counter->unIntegrityErrorCounter &= ((uint32)NETC_F2_COMMON_UNIECTR_COUNT_MASK);
4776 #endif
4777 #endif
4778
4779 return E_OK;
4780 }
4781
4782
4783 /*!
4784 * @brief Ethernet Switch function to get counter values for individual MAC (MAC0 - EMAC / MAC1 - PMAC) on a port.
4785 *
4786 * @param[in] SwitchIdx
4787 * @param[in] PortIndex
4788 * @param[in] MacIndex
4789 * @param[in] Counter
4790 *
4791 * @return Std Error
4792 */
4793 static Std_ReturnType Netc_EthSwt_Ip_GetSwtPortIndividualMacCounters( uint8 SwitchIdx, uint8 PortIndex, boolean MacIndex, Netc_EthSwt_Ip_CounterType *Counter )
4794 {
4795 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
4796 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
4797 #endif
4798
4799 (void)SwitchIdx;
4800
4801 if (MacIndex == (boolean)0U)
4802 {
4803 /* Receive */
4804 /* Port MAC index Receive Ethernet Octets Counter(etherStatsOctetsn) */
4805 Counter->rxEtherOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_REOCTN));
4806
4807
4808 /* Port MAC index Receive Octets Counter(iflnOctetsn) */
4809 Counter->rxOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_ROCTN));
4810
4811 /* Port MAC index Receive Alignment Error Counter Register(aAlignmentErrorsn) */
4812 /* Reserved */
4813
4814 /* Port MAC index Receive Valid Pause Frame Counter Register(aPAUSEMACCtrlFramesReceivedn) */
4815 Counter->rxValidPauseFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RXPFN);
4816
4817 /* Port MAC index Receive Frame Counter */
4818 Counter->rxFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RFRMN);
4819
4820 /* Port MAC index Receive Frame Check Sequence Error Counter */
4821 Counter->rxFrameCheckSequenceErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RFCSN);
4822
4823 /* Port MAC index Receive VLAN Frame Counter */
4824 Counter->rxVlanFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RVLANN);
4825
4826 /* Port MAC index Receive Frame Error Counter Register(ifInErrorsn) */
4827 Counter->rxFrameErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RERRN);
4828
4829 /* Port MAC index Receive Unicast Frame Counter */
4830 Counter->rxUnicastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RUCAN);
4831
4832 /* Port MAC index Receive Multicast Frame Counter */
4833 Counter->rxMulticastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RMCAN);
4834
4835 /* Port MAC index Receive Broadcast Frame Counter */
4836 Counter->rxBroadcastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RBCAN);
4837
4838 /* Port MAC index Receive Dropped Packets Counter Register(etherStatsDropEventsn) */
4839 Counter->rxDroppedPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RDRPN);
4840
4841 /* Port MAC index Receive Packets Counter Register(etherStatsPktsn) */
4842 Counter->rxPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RPKTN);
4843
4844 /* Port MAC index Receive Undersized Packet Counter */
4845 Counter->rxUndersizePacketCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RUNDN);
4846
4847 /* Port MAC index Receive 64-Octet Packet Counter Register(etherStatsPkts64OctetsN) */
4848 Counter->rx64OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R64N);
4849
4850 /* Port MAC index Receive 65 to 127-Octet Packet Counter Register(etherStatsPkts65to127OctetsN) */
4851 Counter->rx65to127OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R127N);
4852
4853 /* Port MAC index Receive 128 to 255-Octet Packet Counter Register(etherStatsPkts128to255OctetsN) */
4854 Counter->rx128to255OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R255N);
4855
4856 /* Port MAC index Receive 256 to 511-Octet Packet Counter Register(etherStatsPkts256to511OctetsN) */
4857 Counter->rx256to511OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R511N);
4858
4859 /* Port MAC index Receive 512 to 1023-Octet Packet Counter Register(etherStatsPkts512to1023OctetsN) */
4860 Counter->rx512to1023OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R1023N);
4861
4862 /* Port MAC index Receive 1024 to 1522-Octet Packet Counter Register(etherStatsPkts1024to1522OctetsN) */
4863 Counter->rx1024to1522OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R1522N);
4864
4865 /* Port MAC index Receive 1523 to Max-Octet Packet Counter Register(etherStatsPkts1523toMaxOctetsN) */
4866 Counter->rx1523toMaxOctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_R1523XN);
4867
4868 /* Port MAC index Receive Oversized Packet Counter */
4869 Counter->rxOversizedPacketsCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_ROVRN);
4870
4871 /* Port MAC index Receive Jabber Packet Counter Register(etherStatsJabbersn) */
4872 Counter->rxJabberPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RJBRN);
4873
4874 /* Port MAC index Receive Fragment Packet Counter Register(etherStatsFragmentsn) */
4875 Counter->rxFragmentPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RFRGN);
4876
4877 /* Port MAC index Receive Control Packet Counter Register */
4878 Counter->rxControlPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RCNPN);
4879
4880 /* Port MAC index Receive Dropped Not Truncated Packets Counter Register(etherStatsDropEventsn) */
4881 Counter->rxDroppedNTruncatedPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_RDRNTPN);
4882
4883 /* Port Rx discard count register */
4884 Counter->rxDiscardCounter = Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PRXDCR;
4885
4886 /* Transmit */
4887 /* Port MAC index Transmit Ethernet Octets Counter(etherStatsOctetsn) */
4888 Counter->txEtherOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TEOCTN);
4889
4890 /* Port MAC index Transmit Octets Counter Register(ifOutOctetsn) */
4891 Counter->txOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TOCTN);
4892
4893 /* Port MAC index Transmit Valid Pause Frame Counter Register(aPAUSEMACCtrlFramesReceivedn) */
4894 Counter->txValidPauseFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TXPFN);
4895
4896 /* Port MAC index Transmit Frame Counter */
4897 Counter->txFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TFRMN);
4898
4899 /* Port MAC index Transmit Frame Check Sequence Error Counter */
4900 Counter->txFrameCheckSequenceErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TFCSN);
4901
4902 /* Port MAC index Transmit VLAN Frame Counter */
4903 Counter->txVlanFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TVLANN);
4904
4905 /* Port MAC index Transmit Frame Error Counter Register(ifOutErrorsn) */
4906 Counter->txFrameErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TERRN);
4907
4908 /* Port MAC index Transmit Unicast Frame Counter */
4909 Counter->txUnicastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TUCAN);
4910
4911 /* Port MAC index Transmit Multicast Frame Counter */
4912 Counter->txMulticastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TMCAN);
4913
4914 /* Port MAC index Transmit Broadcast Frame Counter */
4915 Counter->txBroadcastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TBCAN);
4916
4917 /* Port MAC index Transmit Packets Counter Register(etherStatsPktsN; */
4918 Counter->txPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TPKTN);
4919
4920 /* Port MAC index Transmit Undersized Packet Counter */
4921 Counter->txUndersizePacketCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TUNDN);
4922
4923 /* Port MAC index Transmit 64-Octet Packet Counter Register (etherStatsPkts64OctetsN) */
4924 Counter->tx64OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T64N);
4925
4926 /* Port MAC index Transmit 65 to 127-Octet Packet Counter Register (etherStatsPkts65to127OctetsN) */
4927 Counter->tx65to127OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T127N);
4928
4929 /* Port MAC index Transmit 128 to 255-Octet Packet Counter Register (etherStatsPkts128to255OctetsN) */
4930 Counter->tx128to255OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T255N);
4931
4932 /* Port MAC index Transmit 256 to 511-Octet Packet Counter Register (etherStatsPkts256to511OctetsN) */
4933 Counter->tx256to511OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T511N);
4934
4935 /* Port MAC index Transmit 512 to 1023-Octet Packet Counter Register (etherStatsPkts512to1023OctetsN) */
4936 Counter->tx512to1023OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T1023N);
4937
4938 /* Port MAC index Transmit 1024 to 1522-Octet Packet Counter Register (etherStatsPkts1024to1522OctetsN) */
4939 Counter->tx1024to1522OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T1522N);
4940
4941 /* Port MAC index Transmit 1523 to TX_MTU-Octet Packet Counter Register (etherStatsPkts1523toMaxOctetsN) */
4942 Counter->tx1523toMaxOctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_T1523XN);
4943
4944 /* Port MAC index Transmit Control Packet Counter Register */
4945 Counter->txControlPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TCNPN);
4946
4947 /* Port MAC index Transmit Deferred Packet Counter Register(aFramesWithDeferredXmissions) */
4948 Counter->txDeferredPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TDFRN);
4949
4950 /* Port MAC index Transmit Multiple Collisions Counter Register */
4951 Counter->txMultiCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TMCOLN);
4952
4953 /* Port MAC index Transmit Single Collision Counter Register */
4954 Counter->txSingleCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TSCOLN);
4955
4956 /* Port MAC index Transmit Late Collision Counter(aLateCollisions) Register */
4957 Counter->txLateCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TLCOLN);
4958
4959 /* Port MAC index Transmit Excessive Collisions Counter Register */
4960 Counter->txExcessiveCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM0_TECOLN);
4961 }
4962 else
4963 {
4964 /* Receive */
4965 /* Port MAC index Receive Ethernet Octets Counter(etherStatsOctetsn) */
4966 Counter->rxEtherOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_REOCTN));
4967
4968
4969 /* Port MAC index Receive Octets Counter(iflnOctetsn) */
4970 Counter->rxOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&(Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_ROCTN));
4971
4972 /* Port MAC index Receive Alignment Error Counter Register(aAlignmentErrorsn) */
4973 /* Reserved */
4974
4975 /* Port MAC index Receive Valid Pause Frame Counter Register(aPAUSEMACCtrlFramesReceivedn) */
4976 Counter->rxValidPauseFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RXPFN);
4977
4978 /* Port MAC index Receive Frame Counter */
4979 Counter->rxFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RFRMN);
4980
4981 /* Port MAC index Receive Frame Check Sequence Error Counter */
4982 Counter->rxFrameCheckSequenceErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RFCSN);
4983
4984 /* Port MAC index Receive VLAN Frame Counter */
4985 Counter->rxVlanFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RVLANN);
4986
4987 /* Port MAC index Receive Frame Error Counter Register(ifInErrorsn) */
4988 Counter->rxFrameErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RERRN);
4989
4990 /* Port MAC index Receive Unicast Frame Counter */
4991 Counter->rxUnicastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RUCAN);
4992
4993 /* Port MAC index Receive Multicast Frame Counter */
4994 Counter->rxMulticastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RMCAN);
4995
4996 /* Port MAC index Receive Broadcast Frame Counter */
4997 Counter->rxBroadcastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RBCAN);
4998
4999 /* Port MAC index Receive Dropped Packets Counter Register(etherStatsDropEventsn) */
5000 Counter->rxDroppedPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RDRPN);
5001
5002 /* Port MAC index Receive Packets Counter Register(etherStatsPktsn) */
5003 Counter->rxPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RPKTN);
5004
5005 /* Port MAC index Receive Undersized Packet Counter */
5006 Counter->rxUndersizePacketCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RUNDN);
5007
5008 /* Port MAC index Receive 64-Octet Packet Counter Register(etherStatsPkts64OctetsN) */
5009 Counter->rx64OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R64N);
5010
5011 /* Port MAC index Receive 65 to 127-Octet Packet Counter Register(etherStatsPkts65to127OctetsN) */
5012 Counter->rx65to127OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R127N);
5013
5014 /* Port MAC index Receive 128 to 255-Octet Packet Counter Register(etherStatsPkts128to255OctetsN) */
5015 Counter->rx128to255OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R255N);
5016
5017 /* Port MAC index Receive 256 to 511-Octet Packet Counter Register(etherStatsPkts256to511OctetsN) */
5018 Counter->rx256to511OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R511N);
5019
5020 /* Port MAC index Receive 512 to 1023-Octet Packet Counter Register(etherStatsPkts512to1023OctetsN) */
5021 Counter->rx512to1023OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R1023N);
5022
5023 /* Port MAC index Receive 1024 to 1522-Octet Packet Counter Register(etherStatsPkts1024to1522OctetsN) */
5024 Counter->rx1024to1522OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R1522N);
5025
5026 /* Port MAC index Receive 1523 to Max-Octet Packet Counter Register(etherStatsPkts1523toMaxOctetsN) */
5027 Counter->rx1523toMaxOctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_R1523XN);
5028
5029 /* Port MAC index Receive Oversized Packet Counter */
5030 Counter->rxOversizedPacketsCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_ROVRN);
5031
5032 /* Port MAC index Receive Jabber Packet Counter Register(etherStatsJabbersn) */
5033 Counter->rxJabberPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RJBRN);
5034
5035 /* Port MAC index Receive Fragment Packet Counter Register(etherStatsFragmentsn) */
5036 Counter->rxFragmentPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RFRGN);
5037
5038 /* Port MAC index Receive Control Packet Counter Register */
5039 Counter->rxControlPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RCNPN);
5040
5041 /* Port MAC index Receive Dropped Not Truncated Packets Counter Register(etherStatsDropEventsn) */
5042 Counter->rxDroppedNTruncatedPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_RDRNTPN);
5043
5044 /* Port Rx discard count register */
5045 Counter->rxDiscardCounter = Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PRXDCR;
5046
5047 /* Transmit */
5048 /* Port MAC index Transmit Ethernet Octets Counter(etherStatsOctetsn) */
5049 Counter->txEtherOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TEOCTN);
5050
5051 /* Port MAC index Transmit Octets Counter Register(ifOutOctetsn) */
5052 Counter->txOctetCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TOCTN);
5053
5054 /* Port MAC index Transmit Valid Pause Frame Counter Register(aPAUSEMACCtrlFramesReceivedn) */
5055 Counter->txValidPauseFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TXPFN);
5056
5057 /* Port MAC index Transmit Frame Counter */
5058 Counter->txFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TFRMN);
5059
5060 /* Port MAC index Transmit Frame Check Sequence Error Counter */
5061 Counter->txFrameCheckSequenceErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TFCSN);
5062
5063 /* Port MAC index Transmit VLAN Frame Counter */
5064 Counter->txVlanFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TVLANN);
5065
5066 /* Port MAC index Transmit Frame Error Counter Register(ifOutErrorsn) */
5067 Counter->txFrameErrorCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TERRN);
5068
5069 /* Port MAC index Transmit Unicast Frame Counter */
5070 Counter->txUnicastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TUCAN);
5071
5072 /* Port MAC index Transmit Multicast Frame Counter */
5073 Counter->txMulticastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TMCAN);
5074
5075 /* Port MAC index Transmit Broadcast Frame Counter */
5076 Counter->txBroadcastFrmCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TBCAN);
5077
5078 /* Port MAC index Transmit Packets Counter Register(etherStatsPktsN; */
5079 Counter->txPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TPKTN);
5080
5081 /* Port MAC index Transmit Undersized Packet Counter */
5082 Counter->txUndersizePacketCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TUNDN);
5083
5084 /* Port MAC index Transmit 64-Octet Packet Counter Register (etherStatsPkts64OctetsN) */
5085 Counter->tx64OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T64N);
5086
5087 /* Port MAC index Transmit 65 to 127-Octet Packet Counter Register (etherStatsPkts65to127OctetsN) */
5088 Counter->tx65to127OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T127N);
5089
5090 /* Port MAC index Transmit 128 to 255-Octet Packet Counter Register (etherStatsPkts128to255OctetsN) */
5091 Counter->tx128to255OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T255N);
5092
5093 /* Port MAC index Transmit 256 to 511-Octet Packet Counter Register (etherStatsPkts256to511OctetsN) */
5094 Counter->tx256to511OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T511N);
5095
5096 /* Port MAC index Transmit 512 to 1023-Octet Packet Counter Register (etherStatsPkts512to1023OctetsN) */
5097 Counter->tx512to1023OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T1023N);
5098
5099 /* Port MAC index Transmit 1024 to 1522-Octet Packet Counter Register (etherStatsPkts1024to1522OctetsN) */
5100 Counter->tx1024to1522OctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T1522N);
5101
5102 /* Port MAC index Transmit 1523 to TX_MTU-Octet Packet Counter Register (etherStatsPkts1523toMaxOctetsN) */
5103 Counter->tx1523toMaxOctetPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_T1523XN);
5104
5105 /* Port MAC index Transmit Control Packet Counter Register */
5106 Counter->txControlPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TCNPN);
5107
5108 /* Port MAC index Transmit Deferred Packet Counter Register(aFramesWithDeferredXmissions) */
5109 Counter->txDeferredPktCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TDFRN);
5110
5111 /* Port MAC index Transmit Multiple Collisions Counter Register */
5112 Counter->txMultiCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TMCOLN);
5113
5114 /* Port MAC index Transmit Single Collision Counter Register */
5115 Counter->txSingleCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TSCOLN);
5116
5117 /* Port MAC index Transmit Late Collision Counter(aLateCollisions) Register */
5118 Counter->txLateCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TLCOLN);
5119
5120 /* Port MAC index Transmit Excessive Collisions Counter Register */
5121 Counter->txExcessiveCollisionCounter = Netc_EthSwt_Ip_GetCounterLocal(&Netc_EthSwt_Ip_PortBaseTable[PortIndex]->PM1_TECOLN);
5122 }
5123
5124 #if defined(ERR_IPV_NETC_E051023)
5125 #if (STD_ON == ERR_IPV_NETC_E051023)
5126 /* ERR051023: NETC: Excessive collisions are counted as late collisions */
5127 Counter->txLateCollisionCounter -= Counter->txExcessiveCollisionCounter;
5128 #endif
5129 #endif
5130
5131 /* Port Tx discard count register */
5132 Counter->txDiscardCounter = Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->PTXDCR;
5133
5134 #if defined(ERR_IPV_NETC_E051129)
5135 #if (STD_ON == ERR_IPV_NETC_E051129)
5136 /* Errata ERR051129: Uncorrectable non-fatal integrity error count register */
5137 Counter->unIntegrityErrorCounter = IP_NETC__SW0_COMMON->UNIECTR;
5138 Counter->unIntegrityErrorCounter &= ((uint32)NETC_F2_COMMON_UNIECTR_COUNT_MASK);
5139 #endif
5140 #endif
5141
5142 return E_OK;
5143 }
5144
5145 /*!
5146 * @brief Ethernet Switch get pseudo port counter values function.
5147 *
5148 * @param[in]
5149 * @param[out]
5150 * @return
5151 */
5152 static Std_ReturnType Netc_EthSwt_Ip_GetSwtPseudoPortCounters( uint8 SwitchIdx, uint8 SwitchPortIdx, Netc_EthSwt_Ip_CounterType *Counter )
5153 {
5154 uint32 xCR0Value;
5155 uint8 PseudoPortIdx;
5156
5157 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5158 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5159 #endif
5160
5161 (void)SwitchIdx;
5162
5163 /* pseudo port indexes are starting after the mac ports. */
5164 PseudoPortIdx = 0U;
5165
5166 /* Receive */
5167 /* Port pseudo MAC receive octets counter */
5168 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMROCR[0];
5169 Counter->rxOctetCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMROCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
5170 /* Port pseudo MAC receive unicast frame counter register */
5171 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRUFCR[0];
5172 Counter->rxUnicastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRUFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
5173 /* Port pseudo MAC receive multicast frame counter register */
5174 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRMFCR[0];
5175 Counter->rxMulticastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRMFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
5176 /* Port pseudo MAC receive broadcast frame counter register */
5177 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRBFCR[0];
5178 Counter->rxBroadcastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMRBFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
5179
5180 /* unsupported rx counters */
5181 Counter->rxPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5182 Counter->rxFrmCounter = 0xFFFFFFFFFFFFFFFFULL;
5183 Counter->rxVlanFrmCounter = 0xFFFFFFFFFFFFFFFFULL;
5184 Counter->rxFrameErrorCounter = 0xFFFFFFFFFFFFFFFFULL;
5185 Counter->rxUndersizePacketCounter = 0xFFFFFFFFFFFFFFFFULL;
5186 Counter->rxOversizedPacketsCounter = 0xFFFFFFFFFFFFFFFFULL;
5187 Counter->rxFrameCheckSequenceErrorCounter = 0xFFFFFFFFFFFFFFFFULL;
5188 Counter->rxEtherOctetCounter = 0xFFFFFFFFFFFFFFFFULL;
5189 Counter->rxValidPauseFrmCounter = 0xFFFFFFFFFFFFFFFFULL;
5190 Counter->rxDroppedPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5191 Counter->rx64OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5192 Counter->rx65to127OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5193 Counter->rx128to255OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5194 Counter->rx256to511OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5195 Counter->rx512to1023OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5196 Counter->rx1024to1522OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5197 Counter->rx1523toMaxOctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5198 Counter->rxJabberPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5199 Counter->rxFragmentPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5200 Counter->rxControlPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5201 Counter->rxDroppedNTruncatedPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5202
5203 /* Port Rx discard count register */
5204 Counter->rxDiscardCounter = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PRXDCR;
5205
5206 /* Transmit */
5207 /* Port pseudo MAC transmit octets counter */
5208 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTOCR[0];
5209 Counter->txOctetCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTOCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
5210 /* Port pseudo MAC transmit unicast frame counter register */
5211 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTUFCR[0];
5212 Counter->txUnicastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTUFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
5213 /* Port pseudo MAC transmit multicast frame counter register */
5214 xCR0Value = Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTMFCR[0];
5215 Counter->txMulticastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTMFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
5216 /* Port pseudo MAC transmit broadcast frame counter register */
5217 xCR0Value = IP_NETC__SW0_PSEUDO_MAC_PORT2->PPMTBFCR[0];
5218 Counter->txBroadcastFrmCounter = xCR0Value | ((uint64)((uint32)(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx]->PPMTBFCR[1])) << NETC_ETHSWT_IP_32BIT_SHIFT);
5219
5220 /* Port Tx discard count register */
5221 Counter->txDiscardCounter = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PTXDCR;
5222
5223 /* unsupported tx counters */
5224 Counter->txPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5225 Counter->txFrmCounter = 0xFFFFFFFFFFFFFFFFULL;
5226 Counter->txVlanFrmCounter = 0xFFFFFFFFFFFFFFFFULL;
5227 Counter->txFrameErrorCounter = 0xFFFFFFFFFFFFFFFFULL;
5228 Counter->txUndersizePacketCounter = 0xFFFFFFFFFFFFFFFFULL;
5229 Counter->txSingleCollisionCounter = 0xFFFFFFFFFFFFFFFFULL;
5230 Counter->txMultiCollisionCounter = 0xFFFFFFFFFFFFFFFFULL;
5231 Counter->txFrameCheckSequenceErrorCounter = 0xFFFFFFFFFFFFFFFFULL;
5232
5233 Counter->txEtherOctetCounter = 0xFFFFFFFFFFFFFFFFULL;
5234 Counter->txValidPauseFrmCounter = 0xFFFFFFFFFFFFFFFFULL;
5235 Counter->tx64OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5236 Counter->tx65to127OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5237 Counter->tx128to255OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5238 Counter->tx256to511OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5239 Counter->tx512to1023OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5240 Counter->tx1024to1522OctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5241 Counter->tx1523toMaxOctetPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5242 Counter->txControlPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5243 Counter->txDeferredPktCounter = 0xFFFFFFFFFFFFFFFFULL;
5244 Counter->txLateCollisionCounter = 0xFFFFFFFFFFFFFFFFULL;
5245 Counter->txExcessiveCollisionCounter = 0xFFFFFFFFFFFFFFFFULL;
5246
5247 #if defined(ERR_IPV_NETC_E051129)
5248 #if (STD_ON == ERR_IPV_NETC_E051129)
5249 /* Errata ERR051129: Uncorrectable non-fatal integrity error count register */
5250 Counter->unIntegrityErrorCounter = IP_NETC__SW0_COMMON->UNIECTR & NETC_F2_COMMON_UNIECTR_COUNT_MASK;
5251 #endif
5252 #endif
5253 return E_OK;
5254 }
5255
5256 /*FUNCTION**********************************************************************
5257 *
5258 * Function Name : Netc_EthSwt_Ip_EnableVlan
5259 * Description : Ethernet switch enable VLAN function.
5260 * implements Netc_EthSwt_Ip_EnableVlan_Activity
5261 *END**************************************************************************/
5262 Std_ReturnType Netc_EthSwt_Ip_EnableVlan( uint8 SwitchIdx, uint8 SwitchPortIdx, uint16 VlanId, boolean Enable )
5263 {
5264 Std_ReturnType Status = E_OK;
5265 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
5266 Netc_EthSwt_Ip_VlanFilterEntryDataType VlanFilterTableEntry;
5267 uint32 MatchedEntries = 0U;
5268
5269 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
5270 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5271 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
5272 #endif
5273
5274 /* Query the entry with VlanId */
5275 VlanFilterTableEntry.VlanID = VlanId;
5276 CBDRStatus = Netc_EthSwt_Ip_QueryVlanFilterTableEntry(SwitchIdx, &MatchedEntries, &VlanFilterTableEntry);
5277 if ((CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS) || (MatchedEntries == 0U))
5278 {
5279 Status = E_NOT_OK; /* Query command error or no mached Vlan ID entry found */
5280 }
5281 else
5282 {
5283 /* Get the CFGE data of a mached entry */
5284 VlanFilterTableEntry.SpanningTreeGroupMemberId = (uint8)((TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA0] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_STG_ID_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_STG_ID_SHIFT);
5285 VlanFilterTableEntry.PortMembershipBitmap = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA0] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_PORT_MEMBERSHIP_MASK;
5286 VlanFilterTableEntry.IpMulticastFloodingEnable = (((TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFLE_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFLE_SHIFT) != 0x0UL) ? TRUE : FALSE;
5287 VlanFilterTableEntry.IpMulticastFilteringEnable = (((TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFE_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFE_SHIFT) != 0x0UL) ? TRUE : FALSE;
5288 VlanFilterTableEntry.MacForwardingOptions = (uint8)((TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MFO_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MFO_SHIFT);
5289 VlanFilterTableEntry.MacLearningOptions = (uint8)((TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MLO_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MLO_SHIFT);
5290 VlanFilterTableEntry.FID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_FID_MASK);
5291 VlanFilterTableEntry.EgressTreatmentApplicabilityPortBitmap = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA2] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_ETA_PORT_BITMAP_MASK;
5292 VlanFilterTableEntry.BaseEgressTreatmentEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA3] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_BASE_ET_EID_MASK;
5293
5294 /* Modify port membership bitmap data */
5295 if (TRUE == Enable)
5296 {
5297 VlanFilterTableEntry.PortMembershipBitmap |= (uint32)(0x1UL << SwitchPortIdx); /* add the port to the portmembershipbitmap */
5298 }
5299 else
5300 {
5301 VlanFilterTableEntry.PortMembershipBitmap &= ~((uint32)(0x1UL << SwitchPortIdx)); /* remove the port from the portmembershipbitmap */
5302 }
5303
5304 /* Update the entry */
5305 VlanFilterTableEntry.VlanID = VlanId;
5306 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry(SwitchIdx, NETC_ETHSWT_UPDATE_CMD, &MatchedEntries, &VlanFilterTableEntry);
5307 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
5308 {
5309 Status = E_NOT_OK; /* Update command error */
5310 }
5311
5312 }
5313
5314 return Status;
5315 }
5316 /*FUNCTION**********************************************************************
5317 *
5318 * Function Name : Netc_EthSwt_Ip_ResetConfiguration
5319 * Description : Ethernet switch reset configuration function.
5320 * implements Netc_EthSwt_Ip_ResetConfiguration_Activity
5321 *END**************************************************************************/
5322 Std_ReturnType Netc_EthSwt_Ip_ResetConfiguration(uint8 SwitchIdx)
5323 {
5324 /*
5325 * [notes]: implemented this function with singel delete command and Search Method.
5326 */
5327 Std_ReturnType status = E_OK;
5328 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
5329 uint32 ActionsData;
5330
5331 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
5332 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5333 #endif
5334
5335 /* set the query options with ENTRY_ID only query */
5336 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(1U) \
5337 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U) \
5338 | NETC_ETHSWT_IP_FDBTABLE_REQFMT_ACTIONS_FIELD_ACTEU(0U) \
5339 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U);
5340 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_45();
5341
5342 /*+++ fill in FdbTabeDataBuffer for Request Data Buffer +++ */
5343 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in the Actions field */
5344 /* fill in Access Key data field with search criteria data format */
5345 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_RESUMEENTRYID] = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID; /* resume entry id */
5346 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MACADDRESS_L] = 0U; /* clear other unuse data field */
5347 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MACADDRESS_H] = 0U; /* clear other unuse data field */
5348 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_FID] = 0U; /* clear other unuse data field */
5349 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_PORTBITMAP] = 0U; /* clear other unuse data field */
5350 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 */
5351 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_ETEID] = 0U; /* clear other unuse data field */
5352 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_MATCHCRITERIA] = NETC_ETHSWT_IP_FDBTABLE_SEARCH_CRITERIA_CFGEMC(1U); /* 0x1: Match CFGE_DATA[DYNAMIC] field */
5353 /*--- fill in FdbTabeDataBuffer for Request Data Buffer --- */
5354 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_45();
5355
5356 /* fill in operation data for config field of Request Header*/
5357 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
5358 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
5359 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_FDB_TABLE_ID;
5360 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD; /* delete all matched entries with Search Method */
5361 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
5362 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_FDBTABLE_QUERY_REQBUFFER_LEN);
5363 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
5364
5365 /* send the "Delete" command */
5366 CBDRStatus = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
5367 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
5368 {
5369 status = E_NOT_OK;
5370 }
5371
5372 return status;
5373 }
5374
5375 static inline Std_ReturnType Netc_EthSwt_Ip_SearchAndFIllInVlanFilterTableEntry(uint32 * ResumeId,
5376 uint16 * NumOfExistingEntry,
5377 Netc_EthSwt_Ip_VlanFilterEntryDataType * VlanFilterTableEntry)
5378 {
5379 Std_ReturnType status = E_OK;
5380 uint32 ActionsData;
5381 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
5382 uint32 NumOfElement = 0U;
5383 uint32 CfgeData;
5384
5385 /* set the query options with full query */
5386 ActionsData = (NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
5387 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_DEBUG_OPTIONS(0U));
5388
5389 /* fill in TabeDataBuffer for request */
5390 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData;
5391 /* fill in Access Key data with search criteria data format */
5392 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_REQFMT_RESUMEENTRYID_FIELD] = *ResumeId; /* resume entry id */
5393
5394 /* do the full query with Search Method */
5395 /* fill in operation data for config field of Request Header*/
5396 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
5397 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
5398 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_VLAN_FILTER_TABLE_ID;
5399 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
5400 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
5401 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
5402 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_VLANFILTERTABLE_RESBUFFER_LEN); /* full query needs more space for response data */
5403
5404 /* send the "Query" command */
5405 /* [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. */
5406 CBDRStatus = Netc_EthSwt_Ip_SendCommand(0U, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
5407
5408 #if defined(ERR_IPV_NETC_051243)
5409 #if (STD_ON == ERR_IPV_NETC_051243)
5410 /* check the status of query command */
5411 if ((CBDRStatus == 0x8AU) || (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
5412 {
5413 #endif
5414 #else
5415 if (CBDRStatus == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
5416 {
5417 #endif
5418 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &NumOfElement);
5419
5420 /* get the resume_entry_id and be ready for the next query operation */
5421 *ResumeId = TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_RSPDATA_STATUS];
5422 /* ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED */
5423 /* found a matched entry */
5424 if ((1U == NumOfElement) && (*ResumeId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
5425 {
5426 /* fill in "Netc_EthSwt_Ip_VlanFilterEntryDataType" structure with data in response data buffer */
5427 VlanFilterTableEntry->VlanID = (uint16)(TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_VID] & NETC_ETHSWT_IP_VLANFILTERTABLE_KEYEDATA_VID_MASK);
5428
5429 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA0];
5430 VlanFilterTableEntry->SpanningTreeGroupMemberId = (uint8)((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_STG_ID_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_STG_ID_SHIFT);
5431 VlanFilterTableEntry->PortMembershipBitmap = (CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_PORT_MEMBERSHIP_MASK);
5432
5433 CfgeData = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA1];
5434 VlanFilterTableEntry->FID = (uint16)(CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_FID_MASK);
5435 VlanFilterTableEntry->MacLearningOptions = (uint8)((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MLO_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MLO_SHIFT);
5436 VlanFilterTableEntry->MacForwardingOptions = (uint8)((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MFO_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_MFO_SHIFT);
5437 VlanFilterTableEntry->IpMulticastFilteringEnable = (((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFE_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFE_SHIFT) == 0x0UL) ? FALSE : TRUE;
5438 VlanFilterTableEntry->IpMulticastFloodingEnable = (((CfgeData & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFLE_MASK) >> NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_IPMFLE_SHIFT) == 0x0UL) ? FALSE : TRUE;
5439
5440 VlanFilterTableEntry->EgressTreatmentApplicabilityPortBitmap = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA2] & NETC_ETHSWT_IP_VLANFILTERTABLE_CFGEDATA_ETA_PORT_BITMAP_MASK;
5441 VlanFilterTableEntry->BaseEgressTreatmentEntryID = TableDataBuffer.TableDataField[NETC_ETHSWT_VLANFILTERTABL_RSPDATA_CFGEDATA3];
5442 /* increase the NumOfExistingEntry */
5443 (*NumOfExistingEntry) += 1U;
5444 }
5445 }
5446 else
5447 {
5448 status = E_NOT_OK;
5449 }
5450
5451 return status;
5452 }
5453
5454 static inline Std_ReturnType Netc_EthSwt_Ip_SyncVlanFilterTableMLO( uint8 SwitchIdx,
5455 Netc_EthSwt_Ip_MacLearningOptionType MacLearningMode
5456 )
5457 {
5458 Std_ReturnType status = E_OK;
5459 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
5460
5461 uint16 NumOfExistingEntry = 0U;
5462 static uint16 NumOfInUseEntry;
5463 uint32 ResumeId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
5464 Netc_EthSwt_Ip_VlanFilterEntryDataType VlanFilterTableEntry = {0U};
5465 Netc_EthSwt_Ip_CommandsType Cmd = NETC_ETHSWT_UPDATE_CMD;
5466 uint32 MatchedEntries;
5467
5468 /* [notes]: we will have to read entries one by one because of the errata ERR051048.
5469 - ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED
5470 - Description: The NUM_MATCHED field in the command NTMP response header may be incorrect when
5471 the search access method is used for the following tables: FDB table 15, L2 IPv4 Multicast
5472 Filter table 16, VLAN Filter table 18, Ingress Stream Identification table 30, or Ingress Stream
5473 Filter table 32.
5474 - Workaround: For the query command, limit the message response buffer size (RESPONSE_LENGTH field in the request header)
5475 so that NETC returns no more than one entry at a time. Under this condition, the NUM_MATCHED field value is correct
5476 */
5477
5478 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
5479 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5480 #endif
5481
5482 (void)SwitchIdx;
5483 /* Number of entries in-use by the VLAN Filter table is indicated in VFHTOR[NUM_ENTRIES]. */
5484 NumOfInUseEntry = (uint16)(IP_NETC__SW0_BASE->VFHTOR & NETC_ETHSWT_IP_0XFFFF_MASK); /* get how many entries exist in module */
5485
5486 /* if NumOfInUseEntry == 0U, return the NumOfInUseEntry directly and will not do the query and fill in the structure */
5487 if (NumOfInUseEntry > 0U) /* if *NumberOfElements > 0, do the query and fill in the structure */
5488 {
5489 do {
5490 status = Netc_EthSwt_Ip_SearchAndFIllInVlanFilterTableEntry((uint32 *) &ResumeId, (uint16 *) &NumOfExistingEntry, &VlanFilterTableEntry);
5491
5492 if (status == (uint8)(E_NOT_OK))
5493 {
5494 break;
5495 }
5496
5497 /*Update MLO, for the current entry, if necessary*/
5498 if ((VlanFilterTableEntry.MacLearningOptions != (uint8)MacLearningMode))
5499 {
5500 VlanFilterTableEntry.MacLearningOptions = (uint8)MacLearningMode;
5501 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry( SwitchIdx, Cmd, (uint32 *) &MatchedEntries, (const Netc_EthSwt_Ip_VlanFilterEntryDataType *) &VlanFilterTableEntry );
5502 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS != CBDRStatus)
5503 {
5504 status = E_NOT_OK;
5505 }
5506 }
5507
5508 } while ((TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_RSPDATA_STATUS] != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID) && (status == (uint8)(E_OK)) && (NumOfExistingEntry < NumOfInUseEntry));
5509
5510 }
5511
5512 return status;
5513 }
5514
5515 /*FUNCTION**********************************************************************
5516 *
5517 * Function Name : Netc_EthSwt_Ip_SetMacLearningMode
5518 * Description : Ethernet switch set MAC learning mode function.
5519 * implements Netc_EthSwt_Ip_SetMacLearningMode_Activity
5520 *END**************************************************************************/
5521 Std_ReturnType Netc_EthSwt_Ip_SetMacLearningMode( uint8 SwitchIdx,
5522 Netc_EthSwt_Ip_MacLearningOptionType MacLearningMode
5523 )
5524 {
5525 Std_ReturnType status;
5526 uint32 MacLearningOption;
5527
5528 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
5529 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5530 #endif
5531
5532 (void)SwitchIdx;
5533
5534 MacLearningOption = IP_NETC__SW0_BASE->VFHTDECR2;
5535 MacLearningOption &= ~NETC_F2_VFHTDECR2_MLO_MASK;
5536
5537 status = Netc_EthSwt_Ip_SyncVlanFilterTableMLO(SwitchIdx, MacLearningMode);
5538
5539 if (E_OK == status)
5540 {
5541 switch (MacLearningMode)
5542 {
5543 case ETHSWT_MACLEARNINGOPTION_HWDISABLED:
5544 MacLearningOption |= NETC_F2_VFHTDECR2_MLO(ETHSWT_MACLEARNINGOPTION_HWDISABLED);
5545 break;
5546 case ETHSWT_MACLEARNINGOPTION_HWENABLED:
5547 MacLearningOption |= NETC_F2_VFHTDECR2_MLO(ETHSWT_MACLEARNINGOPTION_HWENABLED);
5548 break;
5549 case ETHSWT_MACLEARNINGOPTION_SWSECUREENABLED:
5550 MacLearningOption |= NETC_F2_VFHTDECR2_MLO(ETHSWT_MACLEARNINGOPTION_SWSECUREENABLED);
5551 break;
5552 case ETHSWT_MACLEARNINGOPTION_SWUNSECUREENABLED:
5553 MacLearningOption |= NETC_F2_VFHTDECR2_MLO(ETHSWT_MACLEARNINGOPTION_SWUNSECUREENABLED);
5554 break;
5555 case ETHSWT_MACLEARNINGOPTION_DISABLEDWITHSWVALIDATION:
5556 MacLearningOption |= NETC_F2_VFHTDECR2_MLO(ETHSWT_MACLEARNINGOPTION_DISABLEDWITHSWVALIDATION);
5557 break;
5558 default:
5559 /* log error */
5560 status = E_NOT_OK;
5561 break;
5562 }
5563 }
5564
5565 IP_NETC__SW0_BASE->VFHTDECR2 = MacLearningOption;
5566
5567 return status;
5568 }
5569
5570 /*FUNCTION**********************************************************************
5571 *
5572 * Function Name : Netc_EthSwt_Ip_GetMacLearningMode
5573 * Description : Ethernet switch get MAC learning mode function.
5574 * implements Netc_EthSwt_Ip_GetMacLearningMode_Activity
5575 *END**************************************************************************/
5576 Std_ReturnType Netc_EthSwt_Ip_GetMacLearningMode( uint8 SwitchIdx,
5577 Netc_EthSwt_Ip_MacLearningOptionType * MacLearningMode
5578 )
5579 {
5580 Std_ReturnType status = E_OK;
5581 uint32 MacLearningOption;
5582
5583 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
5584 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5585 DevAssert(MacLearningMode != NULL_PTR);
5586 #endif
5587
5588 (void)SwitchIdx;
5589
5590 MacLearningOption = IP_NETC__SW0_BASE->VFHTDECR2;
5591 MacLearningOption = ((MacLearningOption & NETC_F2_VFHTDECR2_MLO_MASK) >> NETC_F2_VFHTDECR2_MLO_SHIFT);
5592 switch (MacLearningOption)
5593 {
5594 case 0x1UL:
5595 *MacLearningMode = ETHSWT_MACLEARNINGOPTION_HWDISABLED;
5596 break;
5597 case 0x2UL:
5598 *MacLearningMode = ETHSWT_MACLEARNINGOPTION_HWENABLED;
5599 break;
5600 case 0x3UL:
5601 *MacLearningMode = ETHSWT_MACLEARNINGOPTION_SWSECUREENABLED;
5602 break;
5603 case 0x4UL:
5604 *MacLearningMode = ETHSWT_MACLEARNINGOPTION_SWUNSECUREENABLED;
5605 break;
5606 case 0x5UL:
5607 *MacLearningMode = ETHSWT_MACLEARNINGOPTION_DISABLEDWITHSWVALIDATION;
5608 break;
5609 default:
5610 /* log error */
5611 status = E_NOT_OK;
5612 break;
5613 }
5614
5615 return status;
5616 }
5617
5618 /*FUNCTION**********************************************************************
5619 *
5620 * Function Name : Netc_EthSwt_Ip_GetSwitchIdentifier
5621 * Description : Ethernet switch hardware version function.
5622 * implements Netc_EthSwt_Ip_GetSwitchIdentifier_Activity
5623 *END**************************************************************************/
5624 Std_ReturnType Netc_EthSwt_Ip_GetSwitchIdentifier(uint8 SwitchIdx, uint32 *HwVersion)
5625 {
5626 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5627 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5628 #endif
5629
5630 /* This dummy cast is done to support scalability in futures platforms. */
5631 (void)SwitchIdx;
5632 /* Hardware revision. */
5633 *HwVersion = IP_NETC__SW0_GLOBAL->IPBRR0;
5634
5635 return E_OK;
5636 }
5637
5638 /*FUNCTION**********************************************************************
5639 * Function Name : Netc_EthSwt_Ip_InitCommandBDR
5640 * Description : Internal function for initializing the command ring.
5641 *
5642 *END**************************************************************************/
5643 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_InitCommandBDR(uint8 SwitchIdx, uint8 cbdrIndex)
5644 {
5645 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
5646
5647 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5648 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5649 #endif
5650
5651 (void)SwitchIdx;
5652
5653 /* check the index of command ring */
5654 if (cbdrIndex >= NETC_ETHSWT_IP_CBDR_NUM)
5655 {
5656 status = NETC_ETHSWT_IP_CBDRSTATUS_INDEX_ERROR;
5657 }
5658 else
5659 {
5660 /* configure the CBDR base address register where the address of a switch table is stored*/
5661 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRBAR0 = (uint32)(CmdBDRConfig[cbdrIndex].CmdBDAddr);
5662
5663 /* set the index of producer and consumer register to 0. The ring is empty now. */
5664 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRPIR = NETC_F2_CBDRPIR_BDR_INDEX(0U);
5665 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRCIR = NETC_F2_CBDRCIR_BDR_INDEX(0U);
5666
5667 /* set the size of command ring. Size of ring in sets of 8 BDs. Maximum ring size is 1K. */
5668 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRLENR = NETC_F2_CBDRLENR_LENGTH(CmdBDRConfig[cbdrIndex].lengthCBDR);
5669
5670 /* enable CBDR. When the ring is non-empty, command buffer descriptors will be processed */
5671 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRMR = NETC_F2_CBDRMR_EN(1U);
5672 }
5673
5674 return status;
5675 }
5676
5677 /*FUNCTION**********************************************************************
5678 *
5679 * Function Name : Netc_EthSwt_Ip_FillInFdbTableReqDataBuff
5680 * Description : Internal function for initializing the FDB Table Request Data Buffer.
5681 *
5682 *END**************************************************************************/
5683 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)
5684 {
5685 uint8 ItemIdx;
5686 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
5687 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_47();
5688
5689 /* ------initialize the table request data buffer------ */
5690 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
5691
5692 /* initialize ACCESS_KEY */
5693 switch (accessMethod)
5694 {
5695 case NETC_ETHSWT_ENTRY_ID_MATCH:
5696 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = pAccessKey[0U]; /* fill in Entry_ID field */
5697 break;
5698 case NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH:
5699 for (ItemIdx = 1U; ItemIdx <= NETC_ETHSWT_IP_FDB_KEYE_DATA_ITEMS; ItemIdx++)
5700 {
5701 TableDataBuffer.TableDataField[ItemIdx] = pAccessKey[ItemIdx - 1U]; /* fill in keye data field */
5702 }
5703 break;
5704 case NETC_ETHSWT_SEARCH_METHOD:
5705 for (ItemIdx = 1U; ItemIdx <= NETC_ETHSWT_IP_FDB_SEARCH_CRITERIA_DATA_ITEMS; ItemIdx++)
5706 {
5707 TableDataBuffer.TableDataField[ItemIdx] = pAccessKey[ItemIdx - 1U]; /* fill in search criteria data field */
5708 }
5709 break;
5710 default:
5711 /* Not Applicable for FDB table*/
5712 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
5713 break;
5714 }
5715
5716 /* initialize CFGE_DATA. This portion is present only for commands which perform an update or add. */
5717 if (pCfgeData != NULL_PTR)
5718 {
5719 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_CFGE_PORT_BITMAP_FIELD] = pCfgeData->Cfge_PortBitmap;
5720 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_CFGE_CONFIG_FIELD] = pCfgeData->Cfge_ConfigField;
5721 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_FDBTABLE_CFGE_ETEID_FIELD] = pCfgeData->Cfge_EtEid;
5722 }
5723 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_47();
5724
5725 return status;
5726 }
5727
5728 /*FUNCTION**********************************************************************
5729 *
5730 * Function Name : Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff
5731 * Description : Internal function for initializing the Vlan Filter Table Request Data Buffer.
5732 *
5733 *END**************************************************************************/
5734 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_FillInVlanFilterTableReqDataBuff(uint32 ActionsData, uint32 AccessKeyData, const Netc_EthSwt_Ip_VlanFilterTableCFGEDataType *pCfgeData, Netc_EthSwt_Ip_AccessMethodType accessMethod)
5735 {
5736 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
5737 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_12();
5738
5739 /* ------initialize the table request data buffer------ */
5740 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
5741
5742 /* initialize ACCESS_KEY Data */
5743 switch (accessMethod)
5744 {
5745 case NETC_ETHSWT_ENTRY_ID_MATCH:
5746 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = AccessKeyData; /* fill in Entry_ID field */
5747 break;
5748 case NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH:
5749 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_REQFMT_VID_FIELD] = AccessKeyData; /* fill in VID field of KEYE Data */
5750 break;
5751 case NETC_ETHSWT_SEARCH_METHOD:
5752 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_VLANFILTERTABLE_REQFMT_RESUMEENTRYID_FIELD] = AccessKeyData; /* fill in RESUME_ENTRY_ID of search criteria data */
5753 break;
5754 default:
5755 /* Not Applicable for Vlan Filter table*/
5756 status = NETC_ETHSWT_IP_CBDRSTATUS_ACCESSMETHOD_ERROR;
5757 break;
5758 }
5759
5760 /* initialize CFGE_DATA. This portion is present only for commands which perform an update or add. */
5761 if (pCfgeData != NULL_PTR)
5762 {
5763 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = pCfgeData->Cfge_Data[0U];
5764 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = pCfgeData->Cfge_Data[1U];
5765 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = pCfgeData->Cfge_Data[2U];
5766 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = pCfgeData->Cfge_Data[3U];
5767
5768 }
5769 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_12();
5770
5771 return status;
5772 }
5773
5774 /*FUNCTION**********************************************************************
5775 *
5776 * Function Name : Netc_EthSwt_Ip_SendCommand
5777 * Description : Internal function for table operations with different commands like add, query, delete etc..
5778 *
5779 *END**************************************************************************/
5780 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_SendCommand(uint8 SwitchIdx, uint8 cbdrIndex, const Netc_EthSwt_Ip_ReqHeaderTableOperationDataType *OperationData)
5781 {
5782 uint32 producerIdx;
5783 uint32 consumerIdx;
5784 Netc_EthSwt_Ip_CBDRStatusType status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
5785 uint32 PreviousProducerIdx;
5786 uint32 statusField;
5787 uint32 rrBit;
5788 uint32 errorField;
5789 uint32 StartTime;
5790 uint32 ElapsedTime;
5791 uint32 TimeoutTicks;
5792 boolean TimeExpired;
5793
5794 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
5795 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5796 #endif
5797
5798 (void)SwitchIdx;
5799
5800 /* read the producer and consumer index register */
5801 producerIdx = IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRPIR;
5802 consumerIdx = IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRCIR;
5803
5804 /* check if the ring is full */
5805 if (((producerIdx + 0x1UL) % ((uint32)(CmdBDRConfig[cbdrIndex].lengthCBDR) * NETC_ETHSWT_IP_SET_OF_BD)) == consumerIdx)
5806 {
5807 status = NETC_ETHSWT_IP_CBDRSTATUS_RINGFULL; /* the ring is full */
5808 }
5809 else
5810 {
5811 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_04();
5812 /* +++ fill in the NTMP request message header +++ */
5813 /* set the table address */
5814 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_ADDR_L] = (uint32)(&TableDataBuffer);
5815
5816 /* set the length of request and response data buffer */
5817 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));
5818
5819 /* set RR = 0, CCI = 0, protocol version = 2, table id, access method and cmd */
5820 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] = 0x0; /* clear this field first */
5821 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] |= NETC_ETHSWT_IP_CMDBD_REQFMT_CONFIG_FIELD_CMD(OperationData->Cmd);
5822 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] |= NETC_ETHSWT_IP_CMDBD_REQFMT_CONFIG_FIELD_ACCESS_METHOD(OperationData->AccessMethod);
5823 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] |= NETC_ETHSWT_IP_CMDBD_REQFMT_CONFIG_FIELD_TABLE_ID(OperationData->TableId);
5824 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] |= NETC_ETHSWT_IP_CMDBD_REQFMT_CONFIG_FIELD_VERSION(OperationData->Version);
5825 CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_REQHEADER_CONFIGFIELD] |= NETC_ETHSWT_IP_CMDBD_REQFMT_CONFIG_FIELD_CCI(OperationData->CmdCompletionInt);
5826 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 */
5827
5828 /* set NTMP version to 2.0*/
5829 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);
5830 /* --- fill in the NTMP request message header --- */
5831 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_04();
5832
5833 /* +++ write the produce index register and enable hardware to consume the command +++ */
5834 PreviousProducerIdx = producerIdx; /* save the produce index before incrementing it manually */
5835 if ((producerIdx + 0x1UL) == ((uint32)(CmdBDRConfig[cbdrIndex].lengthCBDR) * NETC_ETHSWT_IP_SET_OF_BD)) /* adjust producer index */
5836 {
5837 producerIdx = 0x0UL; /* when producerIdx equals ACTUAL_CBDR_LENGTH minus 1, then it would start from 0 again */
5838 }
5839 else
5840 {
5841 producerIdx += 0x1UL; /* increase the producer index manually */
5842 }
5843
5844 /* This is needed to make sure the descriptor gets updated with the latest values, before
5845 incrementing the producer index to start the actual operation */
5846 MCAL_DATA_SYNC_BARRIER();
5847
5848 IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRPIR = NETC_F2_CBDRPIR_BDR_INDEX(producerIdx);
5849 /* --- write the produce index register and enable hardware to consume the command --- */
5850
5851 /* +++ to make sure the hardware consumes and processes the command completely +++ */
5852 /* Setup timeout timer */
5853 Netc_EthSwt_Ip_StartTimeOut(&StartTime, &ElapsedTime, &TimeoutTicks, NETC_ETHSWT_IP_TIMEOUT_VALUE_US);
5854 do {
5855 statusField = CmdBDRConfig[cbdrIndex].CmdBDAddr[PreviousProducerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_RSPHEADER_STATUS_FIELD_INDEX]; /* get status field in the response data buffer */
5856 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 */
5857 TimeExpired = Netc_EthSwt_Ip_TimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks);
5858 #ifdef MCAL_ENABLE_FAULT_INJECTION
5859 MCAL_FAULT_INJECTION_POINT(ETHSWT_CHECK_RR_TIMEOUT);
5860 #endif
5861 } while ((rrBit != 0x1U) && (FALSE == TimeExpired)); /* wait the hardware consume the command and check RR bit to see if the processing is completed (rrBit = 1). */
5862 /* --- to make sure the hardware consumes and processes the command completely --- */
5863
5864 /* the command sent was executed successfully and timely by hardware. */
5865 if (FALSE == TimeExpired)
5866 {
5867 /* return the value of ERROR field in response data buffer indicating if there is an error for processing the command */
5868 errorField = ((statusField & (NETC_ETHSWT_IP_CMDBD_RSPFMT_STATUS_FIELD_ERROR_MASK)) >> (NETC_ETHSWT_IP_CMDBD_RSPFMT_STATUS_FIELD_ERROR_SHIFT));
5869 if (errorField != 0U)
5870 {
5871 status = errorField; /* ERROR field should be 0. */
5872 }
5873 }
5874 else /* table operation timeout. */
5875 {
5876 status = NETC_ETHSWT_IP_CBDRSTATUS_TABLE_OPERATION_TIMEOUT; /* either NETC_ETHSWT_IP_TIMEOUT_VALUE_US is not big enough or something wrong with the entry configuration. */
5877 }
5878 }
5879 return status;
5880 }
5881
5882 /*FUNCTION**********************************************************************
5883 *
5884 * Function Name : Netc_EthSwt_Ip_GetMatchedEntries
5885 * Description : Function for getting matched table entries. Num_Matched field indicates if it matches an entry.
5886 *
5887 *END**************************************************************************/
5888 static void Netc_EthSwt_Ip_GetMatchedEntries(uint8 cbdrIndex, uint32 *NumOfEntry)
5889 {
5890 uint32 producerIdx;
5891 uint32 statusField;
5892
5893 producerIdx = IP_NETC__SW0_BASE->NUM_CBDR[cbdrIndex].CBDRPIR;
5894
5895 /* the value stored in producer index register indicates the index of next entry */
5896 if (producerIdx == 0UL) /* producerIdx increased from 15 to 0, will set it to 15, or length minus 1 */
5897 {
5898 producerIdx = ((uint32)(CmdBDRConfig[cbdrIndex].lengthCBDR) * NETC_ETHSWT_IP_SET_OF_BD);
5899 }
5900
5901 producerIdx -= 1UL;
5902
5903 /* get status field in the response data buffer for the matched fdb entry */
5904 statusField = CmdBDRConfig[cbdrIndex].CmdBDAddr[producerIdx].MessageHeaderDataField[NETC_ETHSWT_IP_RSPHEADER_STATUS_FIELD_INDEX];
5905
5906 /* NUM_MATCHED should equal or greater than 1 if the entry exists for any commands. */
5907 *NumOfEntry = (statusField & (NETC_ETHSWT_IP_CMDBD_RSPFMT_STATUS_FIELD_NUMMATCHED_MASK));
5908
5909 }
5910
5911 /*FUNCTION**********************************************************************
5912 *
5913 * Function Name : Netc_EthSwt_Ip_GetCounters
5914 * Description : Function for getting the counters of a port
5915 * For MAC counters that are 64bits, the access must be atomic.
5916 * implements Netc_EthSwt_Ip_GetCounters_Activity
5917 *END**************************************************************************/
5918 Std_ReturnType Netc_EthSwt_Ip_GetCounters( uint8 SwitchIdx,
5919 uint8 SwitchPortIdx,
5920 Netc_EthSwt_Ip_CounterType *Counter
5921 )
5922 {
5923 Std_ReturnType status = E_OK;
5924
5925 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
5926 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5927 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
5928 DevAssert(Counter != NULL_PTR);
5929 #endif
5930
5931 (void)SwitchIdx;
5932
5933 if(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
5934 {
5935 status = Netc_EthSwt_Ip_GetSwtPortCounters(SwitchIdx, SwitchPortIdx, Counter);
5936 }
5937 else
5938 {
5939 status = Netc_EthSwt_Ip_GetSwtPseudoPortCounters(SwitchIdx, SwitchPortIdx, Counter);
5940 }
5941
5942 return status;
5943 }
5944
5945 /*FUNCTION**********************************************************************
5946 *
5947 * Function Name : Netc_EthSwt_Ip_GetAllCounters
5948 * Description : Function for getting the counters from every MAC of a port.
5949 * For MAC counters that are 64bits, the access must be atomic.
5950 * implements Netc_EthSwt_Ip_GetAllCounters_Activity
5951 *END**************************************************************************/
5952 Std_ReturnType Netc_EthSwt_Ip_GetAllCounters(uint8 SwitchIdx, uint8 SwitchPortIdx, Netc_EthSwt_Ip_CounterType Counters[2U])
5953 {
5954 Std_ReturnType status;
5955
5956 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
5957 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
5958 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
5959 DevAssert(Counters != NULL_PTR);
5960 #endif
5961
5962 if(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
5963 {
5964 /* Extract counters from MAC0 */
5965 status = Netc_EthSwt_Ip_GetSwtPortIndividualMacCounters(SwitchIdx, SwitchPortIdx, (boolean)0U, Counters);
5966 if (status == E_OK)
5967 {
5968 /* Extract counters from MAC1 */
5969 status = Netc_EthSwt_Ip_GetSwtPortIndividualMacCounters(SwitchIdx, SwitchPortIdx, (boolean)1U, &(Counters[1U]));
5970 }
5971 }
5972 else
5973 {
5974 status = Netc_EthSwt_Ip_GetSwtPseudoPortCounters(SwitchIdx, SwitchPortIdx, Counters);
5975 }
5976
5977 return status;
5978 }
5979
5980 /*FUNCTION**********************************************************************
5981 *
5982 * Function Name : Netc_EthSwt_Ip_ComputedRegisterValueExtractionSingleCounter
5983 * Description : Function for extracting the counter value using base/offset
5984 *END**************************************************************************/
5985 static inline uint64 Netc_EthSwt_Ip_ComputedRegisterValueExtractionSingleCounter(const Netc_EthSwt_Ip_PortBaseType* base, const Netc_EthSwt_Ip_SingleCounterType offset)
5986 {
5987 return Netc_EthSwt_Ip_Extract64bitsFrom32bitsReg((uint32) base, (uint32) offset);
5988 }
5989
5990 /*FUNCTION**********************************************************************
5991 *
5992 * Function Name : Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter
5993 * Description : Function for extracting the counter value using base/offset
5994 *END**************************************************************************/
5995 static inline uint64 Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(const Netc_EthSwt_Ip_PseudoPortBaseType* base, const Netc_EthSwt_Ip_PseudoPortCounterType offset)
5996 {
5997 return Netc_EthSwt_Ip_Extract64bitsFrom32bitsReg((uint32) base, (uint32) offset);
5998 }
5999
6000 /*FUNCTION**********************************************************************
6001 *
6002 * Function Name : Netc_EthSwt_Ip_GetCounter
6003 * Description : Function for getting a counter from the pseudo-MAC or from one of the MACs of a port.
6004 * For MAC counters that are 64bits, the access must be atomic.
6005 * implements Netc_EthSwt_Ip_GetCounter_Activity
6006 *END**************************************************************************/
6007 Netc_EthSwt_Ip_CounterValueType Netc_EthSwt_Ip_GetCounter(uint8 SwitchIdx, uint8 SwitchPortIdx, Netc_EthSwt_Ip_SingleCounterType Counter)
6008 {
6009 uint8 PseudoPortIdx;
6010 uint64 CounterValue = 0UL;
6011
6012 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
6013 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6014 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
6015 #endif
6016
6017 (void)SwitchIdx;
6018
6019 if(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
6020 {
6021 /* Compute address of the counter. for port 0 and port 1*/
6022 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionSingleCounter(Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx], Counter);
6023 }
6024 else
6025 {
6026 /* pseudo port indexes are starting after the mac ports. */
6027 PseudoPortIdx = (uint8)0U;
6028 switch (Counter)
6029 {
6030 case NETC_ETHSWT_IP_RX_OCTETS_COUNT:
6031 /* Compute addres of the counter. */
6032 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMROCR0);
6033 break;
6034 case NETC_ETHSWT_IP_RX_UNICAST_FRM_COUNT:
6035 /* Compute addres of the counter. */
6036 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMRUFCR0);
6037 break;
6038 case NETC_ETHSWT_IP_RX_MULTICAST_FRM_COUNT:
6039 /* Compute addres of the counter. */
6040 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMRMFCR0);
6041 break;
6042 case NETC_ETHSWT_IP_RX_BROADCAST_FRM_COUNT:
6043 /* Compute addres of the counter. */
6044 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMRBFCR0);
6045 break;
6046 case NETC_ETHSWT_IP_TX_OCTETS_COUNT:
6047 /* Compute addres of the counter. */
6048 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMTOCR0);
6049 break;
6050 case NETC_ETHSWT_IP_TX_UNICAST_FRM_COUNT:
6051 /* Compute addres of the counter. */
6052 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMTUFCR0);
6053 break;
6054 case NETC_ETHSWT_IP_TX_MULTICAST_FRM_COUNT:
6055 /* Compute addres of the counter. */
6056 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMTMFCR0);
6057 break;
6058 case NETC_ETHSWT_IP_TX_BROADCAST_FRM_COUNT:
6059 /* Compute addres of the counter. */
6060 CounterValue = Netc_EthSwt_Ip_ComputedRegisterValueExtractionPseudoCounter(Netc_EthSwt_Ip_PseudoPortBaseTable[PseudoPortIdx], NETC_ETHSWT_IP_PPMTBFCR0);
6061 break;
6062 default:
6063 CounterValue = 0xFFFFFFFFFFFFFFFFULL;
6064 break;
6065 }
6066
6067 }
6068
6069 return CounterValue;
6070 }
6071
6072 /*FUNCTION**********************************************************************
6073 *
6074 * Function Name : Netc_EthSwt_Ip_PortGetLoopbackMode
6075 * Description : Function for getting the loopback mode of a port
6076 * implements Netc_EthSwt_Ip_PortGetLoopbackMode_Activity
6077 *END**************************************************************************/
6078 Std_ReturnType Netc_EthSwt_Ip_PortGetLoopbackMode( uint8 SwitchIdx,
6079 uint8 SwitchPortIdx,
6080 boolean *LoopbackEnable
6081 )
6082 {
6083 Std_ReturnType status = E_NOT_OK;
6084 uint32 portCommandConfig = 0UL;
6085
6086 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6087 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6088 #endif
6089
6090 (void)SwitchIdx;
6091
6092
6093 /* Get the loop back mode value */
6094 if (SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
6095 {
6096 /* Read the register */
6097 portCommandConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG;
6098 *LoopbackEnable = ((SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_LOOP_ENA_MASK & portCommandConfig) == 0U) ? FALSE : TRUE;
6099 status = E_OK;
6100 }
6101 else
6102 {
6103 *LoopbackEnable = FALSE; /* pseudo port does not have loop back mode */
6104 }
6105 return status;
6106 }
6107
6108 /*FUNCTION**********************************************************************
6109 *
6110 * Function Name : Netc_EthSwt_Ip_PortSetLoopbackMode
6111 * Description : Function for setting the loopback mode of a port
6112 * implements Netc_EthSwt_Ip_PortSetLoopbackMode_Activity
6113 *END**************************************************************************/
6114 Std_ReturnType Netc_EthSwt_Ip_PortSetLoopbackMode( uint8 SwitchIdx,
6115 uint8 SwitchPortIdx,
6116 boolean LoopbackEnable
6117 )
6118 {
6119 Std_ReturnType status = E_NOT_OK;
6120 uint32 portCommandConfig = 0UL;
6121
6122 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6123 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6124 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS);
6125 #endif
6126
6127 (void)SwitchIdx;
6128 if (SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
6129 {
6130 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_57();
6131 portCommandConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG
6132 & ~SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_LOOP_ENA_MASK;
6133
6134 /* Configure the loopback mode in the PM0_COMMAND_CONFIG */
6135 if (TRUE == LoopbackEnable)
6136 {
6137 portCommandConfig |= SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_LOOP_ENA_MASK;
6138 }
6139
6140 /* Write the PM0_COMMAND_CONFIG with the computed value */
6141 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_COMMAND_CONFIG = portCommandConfig;
6142 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM1_COMMAND_CONFIG = portCommandConfig;
6143 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_57();
6144
6145 status = E_OK;
6146 }
6147
6148 return status;
6149 }
6150
6151 /*FUNCTION**********************************************************************
6152 *
6153 * Function Name : Netc_EthSwt_Ip_SetPortMacLayerDuplexMode
6154 * Description : Function for enabling or disabling Time Gate Scheduling on a switch port.
6155 * implements Netc_EthSwt_Ip_SetPortMacLayerDuplexMode_Activity
6156 *END**************************************************************************/
6157 Std_ReturnType Netc_EthSwt_Ip_SetPortMacLayerDuplexMode( uint8 SwitchIdx, uint8 SwitchPortIdx,
6158 Netc_EthSwt_Ip_PortDuplexType EthSwtPortMacLayerDuplexMode
6159 )
6160 {
6161 Std_ReturnType status = E_OK;
6162 uint32 interfaceModeConfig = 0UL;
6163
6164 (void) SwitchIdx;
6165 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6166 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6167 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
6168 #endif
6169
6170 if(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
6171 {
6172 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_58();
6173
6174 interfaceModeConfig = Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE;
6175
6176 /* Full duplex is 0 in HD field */
6177 if(EthSwtPortMacLayerDuplexMode == NETC_ETHSWT_PORT_FULL_DUPLEX)
6178 {
6179 interfaceModeConfig &= ~SW_ETH_MAC_PORT0_PM0_IF_MODE_HD_MASK;
6180 }
6181 else /* ETHTRCV_DUPLEX_MODE_HALF */
6182 {
6183 interfaceModeConfig |= SW_ETH_MAC_PORT0_PM0_IF_MODE_HD_MASK;
6184 }
6185
6186 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM0_IF_MODE = interfaceModeConfig;
6187 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->PM1_IF_MODE = interfaceModeConfig;
6188 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_58();
6189
6190 }
6191
6192 return status;
6193 }
6194
6195 static inline Std_ReturnType Netc_EthSwt_Ip_RGMIIModeConfig(uint32 *interfaceModeConfig, uint32 *shapingPSpeedConfig, EthTrcv_BaudRateType EthSwtPortMacLayerSpeed, Netc_EthSwt_Ip_PortDuplexType EthSwtPortMacLayerDuplexMode)
6196 {
6197 Std_ReturnType status = E_OK;
6198
6199 /* Full duplex is 0 in HD field for RGMII mode*/
6200 if (EthSwtPortMacLayerDuplexMode == NETC_ETHSWT_PORT_FULL_DUPLEX)
6201 {
6202 (*interfaceModeConfig) &= ~SW_ETH_MAC_PORT1_PM0_IF_MODE_HD_MASK;
6203 }
6204
6205 switch(EthSwtPortMacLayerSpeed)
6206 {
6207 case ETHTRCV_BAUD_RATE_10MBIT: /* 10Mbps */
6208 {
6209 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT));
6210 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
6211 break;
6212 }
6213 case ETHTRCV_BAUD_RATE_100MBIT: /* 100Mbps */
6214 {
6215 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT));
6216 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
6217 break;
6218 }
6219 case ETHTRCV_BAUD_RATE_1000MBIT: /* 1000Mbps */
6220 {
6221 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT));
6222 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_1000MBITS;
6223 break;
6224 }
6225 default:
6226 {
6227 status = E_NOT_OK;
6228 break;
6229 }
6230 }
6231
6232 return status;
6233 }
6234 static inline Std_ReturnType Netc_EthSwt_Ip_SGMIIModeConfig(uint32 *interfaceModeConfig, uint32 *shapingPSpeedConfig, EthTrcv_BaudRateType EthSwtPortMacLayerSpeed)
6235
6236 {
6237 Std_ReturnType status = E_OK;
6238
6239 switch(EthSwtPortMacLayerSpeed)
6240 {
6241 case ETHTRCV_BAUD_RATE_10MBIT: /* 10Mbps */
6242 {
6243 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_10MBIT));
6244 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
6245 break;
6246 }
6247 case ETHTRCV_BAUD_RATE_100MBIT: /* 100Mbps */
6248 {
6249 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_100MBIT));
6250 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
6251 break;
6252 }
6253 case ETHTRCV_BAUD_RATE_1000MBIT: /* 1000Mbps */
6254 {
6255 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_1000MBIT));
6256 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_1000MBITS;
6257 break;
6258 }
6259 case ETHTRCV_BAUD_RATE_2500MBIT: /* 2500Mbps */
6260 {
6261 (*interfaceModeConfig) |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_SSP(SW_ETH_MAC_PORT_PM0_IF_MODE_SSP_BAUD_RATE_2500MBIT));
6262 (*shapingPSpeedConfig) = NETC_ETHSWT_IP_SHAPING_PSPEED_2500MBITS;
6263 break;
6264 }
6265 default:
6266 {
6267 status = E_NOT_OK;
6268 break;
6269 }
6270 }
6271
6272 return status;
6273 }
6274
6275 static inline Std_ReturnType Netc_EthSwt_Ip_MacPortConfigSetInterface( Netc_EthSwt_Ip_SwitchIdxSwitchPort SwitchIdxSwitchPort,
6276 Netc_EthSwt_Ip_XmiiModeType EthSwtPortPhysicalLayerType,
6277 EthTrcv_BaudRateType EthSwtPortMacLayerSpeed,
6278 Netc_EthSwt_Ip_PortDuplexType EthSwtPortMacLayerDuplexMode
6279 )
6280 {
6281 Std_ReturnType status = E_OK;
6282 uint32 interfaceModeConfig = 0UL;
6283 uint32 shapingPSpeedConfig = 0UL; /* used for shaping of the port */
6284
6285 /* Set the interface type */
6286 if (NETC_ETHSWT_RGMII_MODE == EthSwtPortPhysicalLayerType)
6287 {
6288 interfaceModeConfig |= (SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE(4U));
6289 status = Netc_EthSwt_Ip_RGMIIModeConfig(&interfaceModeConfig, &shapingPSpeedConfig, EthSwtPortMacLayerSpeed, EthSwtPortMacLayerDuplexMode);
6290 }
6291 else if (NETC_ETHSWT_RMII_MODE == EthSwtPortPhysicalLayerType)
6292 {
6293 interfaceModeConfig = (SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE(3U));
6294 /* Full duplex is 0 in HD field */
6295 if (EthSwtPortMacLayerDuplexMode == NETC_ETHSWT_PORT_FULL_DUPLEX)
6296 {
6297 interfaceModeConfig |= SW_ETH_MAC_PORT1_PM0_IF_MODE_HD_MASK;
6298 }
6299 if(ETHTRCV_BAUD_RATE_10MBIT == EthSwtPortMacLayerSpeed)
6300 {
6301 interfaceModeConfig |= SW_ETH_MAC_PORT1_PM0_IF_MODE_M10_MASK;
6302 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_10MBITS;
6303 }
6304 }
6305 else if (NETC_ETHSWT_MII_MODE == EthSwtPortPhysicalLayerType)
6306 {
6307 interfaceModeConfig = (SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE(1U));
6308 shapingPSpeedConfig = NETC_ETHSWT_IP_SHAPING_PSPEED_100MBITS;
6309 }
6310 else if (NETC_ETHSWT_SGMII_MODE == EthSwtPortPhysicalLayerType)
6311 {
6312 /* The MAC register IF_MODE[IFMODE] must be set to 0b101 for SGMII mode. */
6313 interfaceModeConfig = (SW_ETH_MAC_PORT1_PM0_IF_MODE_IFMODE(5U));
6314 status = Netc_EthSwt_Ip_SGMIIModeConfig(&interfaceModeConfig, &shapingPSpeedConfig, EthSwtPortMacLayerSpeed);
6315 }
6316 else
6317 {
6318 /* type error */
6319 status = E_NOT_OK;
6320 }
6321
6322 /* Write the interface mode configuration in the register */
6323 Netc_EthSwt_Ip_PortBaseTable[SwitchIdxSwitchPort.SwitchPortIdx]->PM0_IF_MODE = interfaceModeConfig;
6324 Netc_EthSwt_Ip_PortBaseTable[SwitchIdxSwitchPort.SwitchPortIdx]->PM1_IF_MODE = interfaceModeConfig;
6325 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchIdxSwitchPort.SwitchPortIdx]->PCR &= ~SW_PORT0_PCR_PSPEED_MASK;
6326 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchIdxSwitchPort.SwitchPortIdx]->PCR |= SW_PORT0_PCR_PSPEED(shapingPSpeedConfig);
6327 return status;
6328 }
6329
6330 static Std_ReturnType Netc_EthSwt_Ip_MacPortConfig( Netc_EthSwt_Ip_SwitchIdxSwitchPort SwitchIdxSwitchPort,
6331 Netc_EthSwt_Ip_XmiiModeType EthSwtPortPhysicalLayerType,
6332 EthTrcv_BaudRateType EthSwtPortMacLayerSpeed,
6333 Netc_EthSwt_Ip_PortDuplexType EthSwtPortMacLayerDuplexMode
6334 )
6335 {
6336 Std_ReturnType status = E_OK;
6337
6338 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6339 DevAssert(SwitchIdxSwitchPort.SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6340 #endif
6341
6342
6343 if(SwitchIdxSwitchPort.SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
6344 {
6345 status = Netc_EthSwt_Ip_MacPortConfigSetInterface(SwitchIdxSwitchPort, EthSwtPortPhysicalLayerType, EthSwtPortMacLayerSpeed, EthSwtPortMacLayerDuplexMode);
6346 }
6347 else
6348 {
6349 /* pseudo port */
6350 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchIdxSwitchPort.SwitchPortIdx]->PCR &= ~SW_PORT0_PCR_PSPEED_MASK;
6351 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchIdxSwitchPort.SwitchPortIdx]->PCR |= SW_PORT0_PCR_PSPEED(NETC_ETHSWT_IP_SHAPING_PSPEED_2000MBITS);
6352 }
6353
6354 return status;
6355 }
6356
6357 /* inline function for configuring BPDVR */
6358 static inline void Netc_EthSwt_Ip_ConfigBridgePortDefaultVlanReg(uint8 SwitchPortIdx, const Netc_EthSwt_Ip_PortType *port)
6359 {
6360 uint32 bridgePortDefaultVlan = 0UL;
6361
6362 /* Bridge VLAN port defaults, bits in this section use reverse logic, TRUE==0 */
6363 if(TRUE != port->iPort->EthSwtDropDoubleTagged)
6364 {
6365 bridgePortDefaultVlan |= SW_PORT0_BPDVR_RXTAGA(NETC_ETHSWT_IP_RXTAGA_ACCEPT_DOUBLE_TAGGED);
6366 }
6367 if(TRUE != port->iPort->EthSwtPortIngressDropUntagged)
6368 {
6369 bridgePortDefaultVlan |= SW_PORT0_BPDVR_RXTAGA(NETC_ETHSWT_IP_RXTAGA_ACCEPT_UNTAGGED);
6370 }
6371 if(TRUE != port->iPort->EthSwtPortIngressDropSingleTagged)
6372 {
6373 bridgePortDefaultVlan |= SW_PORT0_BPDVR_RXTAGA(NETC_ETHSWT_IP_RXTAGA_ACCEPT_SINGLE_TAGGED);
6374 }
6375 if(TRUE != port->iPort->EthSwtPortIngressDropPriorityTagged)
6376 {
6377 bridgePortDefaultVlan |= SW_PORT0_BPDVR_RXTAGA(NETC_ETHSWT_IP_RXTAGA_ACCEPT_PRIO_TAGGED);
6378 }
6379 if(TRUE != port->iPort->vlanEnable)
6380 {
6381 bridgePortDefaultVlan |= SW_PORT0_BPDVR_RXVAM(1);
6382 }
6383
6384 if(TRUE == port->iPort->SentUntaggedFrames)
6385 {
6386 bridgePortDefaultVlan |= SW_PORT0_BPDVR_TXTAGA(1); /* Delete outer VLAN tag */
6387 }
6388 /* default vlan id */
6389 bridgePortDefaultVlan |= SW_PORT0_BPDVR_VID(port->iPort->EthSwtPortIngressDefaultVlan);
6390 /* default priority */
6391 bridgePortDefaultVlan |= SW_PORT0_BPDVR_PCP(port->iPort->EthSwtPortIngressDefaultPriority);
6392 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->BPDVR = bridgePortDefaultVlan;
6393 }
6394
6395 /* inline function for configuring credit base shaper registers */
6396 static inline void Netc_EthSwt_Ip_ConfigCreditBaseShaperReg(uint8 SwitchPortIdx, const Netc_EthSwt_Ip_PortType *port)
6397 {
6398 uint8 shapingClass;
6399 uint32 localPtcTmSDUR;
6400
6401 if(port->ePort->portShaper != NULL_PTR)
6402 {
6403 for(shapingClass = 0U; shapingClass < NETC_ETHSWT_IP_NUM_SHAPING_CLASS; shapingClass++)
6404 {
6405 /* Coonfigure the maximum frame size per shaping class, Max 2000 */
6406 localPtcTmSDUR = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[shapingClass].PTCTMSDUR;
6407 localPtcTmSDUR &= ~SW_PORT0_PTCTMSDUR_MAXSDU_MASK;
6408 localPtcTmSDUR |= SW_PORT0_PTCTMSDUR_MAXSDU(port->ePort->portShaper[shapingClass]->EthSwtPortMaxSizedFrame);
6409 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[shapingClass].PTCTMSDUR = localPtcTmSDUR;
6410
6411 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[shapingClass].PTCCBSR0 = SW_PORT0_PTCCBSR0_CBSE(port->ePort->portShaper[shapingClass]->EthSwtPortEgressCBShaperEnable ? 1U : 0U)
6412 | SW_PORT0_PTCCBSR0_BW(port->ePort->portShaper[shapingClass]->EthSwtPortEgressCBShaperBandwidth);
6413 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[shapingClass].PTCCBSR1 = SW_PORT0_PTCCBSR1_HI_CREDIT(port->ePort->portShaper[shapingClass]->EthSwtPortEgressHiCredit);
6414 }
6415 }
6416 }
6417
6418 /* inline function for configuring egress frame preemption registers */
6419 static inline void Netc_EthSwt_Ip_ConfigEgressPreemptionReg(uint8 SwitchPortIdx, const Netc_EthSwt_Ip_PortType *port)
6420 {
6421 /* The pseudoport does not have the following options */
6422 if (SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
6423 {
6424 if(port->ePort->enablePreemption == (boolean)TRUE)
6425 {
6426 #if defined(ERR_IPV_NETC_051025)
6427 #if (STD_ON == ERR_IPV_NETC_051025)
6428 /* Default is 10, for 10ms, for timer @400MHz. But if errata applies, timer is at @330MHz.
6429 To achieve 10ms, replace 10 with 330MHz/400MHz * 10 = 8.25, aproximated to 8 */
6430 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->MAC_MERGE_MMCSR |= SW_ETH_MAC_PORT0_MAC_MERGE_MMCSR_VT(8U);
6431 #endif
6432 #endif
6433 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->MAC_MERGE_MMCSR |= SW_ETH_MAC_PORT0_MAC_MERGE_MMCSR_ME(1U); /* Set ME bits to 1 to enable preemption on any byte boundary. */
6434 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PFPCR = port->ePort->preemptionTCprofiles;
6435 }
6436 else
6437 {
6438 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->MAC_MERGE_MMCSR &= ~SW_ETH_MAC_PORT0_MAC_MERGE_MMCSR_ME(1U); /* Set ME bits to 0 to disable preemption. */
6439 }
6440 }
6441 }
6442
6443 /* inline function for configuring PM0_COMMAND register */
6444 static inline Std_ReturnType Netc_EthSwt_Ip_ConfigPMCommandReg(Netc_EthSwt_Ip_SwitchIdxSwitchPort SwitchIdxSwitchPort, const Netc_EthSwt_Ip_PortType *port)
6445 {
6446 Std_ReturnType status = E_OK;
6447 uint32 portCommandConfig = 0UL;
6448
6449 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6450 DevAssert(SwitchIdxSwitchPort.SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6451 #endif
6452
6453 /* Start the PM0_COMMAND_CONFIG value with the TX padding option */
6454 portCommandConfig = SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_TXP_MASK;
6455
6456 /* Construct several values to be used later based on whether the port is enabled or not */
6457 if (TRUE == port->EthSwtPortMacLayerPortEnable)
6458 {
6459 /* The pseudoport does not have the PMa_COMMAND_CONFIG register */
6460 if (SwitchIdxSwitchPort.SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
6461 {
6462 portCommandConfig |= SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_TX_EN_MASK | SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_RX_EN_MASK;
6463 }
6464
6465 /* Enable Rx and Tx Path for port */
6466 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchIdxSwitchPort.SwitchPortIdx]->POR &= ~(SW_PORT0_POR_TXDIS_MASK | SW_PORT0_POR_RXDIS_MASK);
6467 }
6468 else
6469 {
6470 /* Disable the port in POR register */
6471 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchIdxSwitchPort.SwitchPortIdx]->POR |= SW_PORT0_POR_TXDIS_MASK | SW_PORT0_POR_RXDIS_MASK;
6472 }
6473
6474 /* The pseudoport does not have the following options */
6475 if (SwitchIdxSwitchPort.SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
6476 {
6477 if(TRUE == port->EthSwtPortEnableMagicPacketDetection)
6478 {
6479 portCommandConfig |= SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_MG(1U);
6480 }
6481
6482 /* Configure the loopback mode in the PM0_COMMAND_CONFIG */
6483 if (TRUE == port->EthSwtPortLoopbackEnable)
6484 {
6485 portCommandConfig |= SW_ETH_MAC_PORT0_PM0_COMMAND_CONFIG_LOOP_ENA_MASK;
6486 }
6487
6488 /* Write the PMa_COMMAND_CONFIG with the computed value */
6489 Netc_EthSwt_Ip_PortBaseTable[SwitchIdxSwitchPort.SwitchPortIdx]->PM0_COMMAND_CONFIG = portCommandConfig;
6490 Netc_EthSwt_Ip_PortBaseTable[SwitchIdxSwitchPort.SwitchPortIdx]->PM1_COMMAND_CONFIG = portCommandConfig;
6491
6492 #if(NETC_ETHSWT_IP_CONFIG_LINK_PROTOCOL == STD_ON)
6493 /* Config link protocol for mac ports */
6494 Netc_EthSwt_Ip_ConfigLinkProtocol(SwitchIdxSwitchPort.SwitchIdx, SwitchIdxSwitchPort.SwitchPortIdx, port->EthSwtPortPhysicalLayerType);
6495 #endif
6496
6497 /* Configure the interface mode, the speed and the duplex mode */
6498 status |= Netc_EthSwt_Ip_MacPortConfig(SwitchIdxSwitchPort, port->EthSwtPortPhysicalLayerType,
6499 port->EthSwtPortMacLayerSpeed, port->EthSwtPortMacLayerDuplexMode
6500 );
6501 }
6502
6503 return status;
6504 }
6505
6506 static inline void Netc_EthSwt_Ip_SetIngressCutThroughPortx(uint8 SwitchPortIdx)
6507 {
6508 if( (0U == SwitchPortIdx) || (1U == SwitchPortIdx) )
6509 {
6510 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCTFCR |= SW_PORT0_PCTFCR_ICTS(1U);
6511 }
6512 }
6513
6514 static inline void Netc_EthSwt_Ip_SetEgressCutThroughPortx(uint8 SwitchPortIdx)
6515 {
6516 if( (0U == SwitchPortIdx) || (1U == SwitchPortIdx) )
6517 {
6518 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PCTFCR |= SW_PORT0_PCTFCR_ECTS(1U);
6519 }
6520 }
6521
6522 static inline void Netc_EthSwt_Ip_InitPort_ConfigIngressEgressCutThroughSettings(Netc_EthSwt_Ip_SwitchIdxSwitchPort SwitchIdxSwitchPort, const Netc_EthSwt_Ip_PortType *port)
6523 {
6524 /* Configure the ingress/egress cut through settings */
6525 if (TRUE == (port->ePort->portEgressAllowCutThroughFrames) )
6526 {
6527 Netc_EthSwt_Ip_SetEgressCutThroughPortx(SwitchIdxSwitchPort.SwitchPortIdx);
6528 }
6529
6530 if (TRUE == (port->iPort->portIngressAllowCutThroughFrames) )
6531 {
6532 Netc_EthSwt_Ip_SetIngressCutThroughPortx(SwitchIdxSwitchPort.SwitchPortIdx);
6533 }
6534 }
6535
6536 static Std_ReturnType Netc_EthSwt_Ip_InitPort(Netc_EthSwt_Ip_SwitchIdxSwitchPort SwitchIdxSwitchPort, const Netc_EthSwt_Ip_PortType *port)
6537 {
6538 Std_ReturnType status = E_OK;
6539 uint32 bridgePortConfig = 0UL;
6540
6541 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6542 DevAssert(SwitchIdxSwitchPort.SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6543 DevAssert(SwitchIdxSwitchPort.SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
6544 #endif
6545
6546 /* Port QOS mode */
6547 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchIdxSwitchPort.SwitchPortIdx]->PQOSMR = SW_PORT0_PQOSMR_VS(1U)
6548 | SW_PORT0_PQOSMR_VE(port->iPort->vlanEnable?1U:0U)
6549 | SW_PORT0_PQOSMR_DIPV(port->iPort->vlanDefaultIpv)
6550 | SW_PORT0_PQOSMR_DDR(port->iPort->vlanDefaultDr)
6551 | SW_PORT0_PQOSMR_VQMP(port->iPort->vlanMappingProfile)
6552 | SW_PORT0_PQOSMR_QVMP(port->ePort->vlanMappingProfile);
6553
6554 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchIdxSwitchPort.SwitchPortIdx]->PPCPDEIMR = SW_PORT0_PPCPDEIMR_IPCPMPV(port->iPort->vlanEnableIngressPcpToPcpMapping?1U:0U)
6555 | SW_PORT0_PPCPDEIMR_IPCPMP(port->iPort->vlanIngressPcpToPcpProfile)
6556 | SW_PORT0_PPCPDEIMR_EPCPMPV(port->ePort->vlanEnableEgressPcpToPcpMapping?1U:0U)
6557 | SW_PORT0_PPCPDEIMR_EPCPMP(port->ePort->vlanEgressPcpToPcpProfile)
6558 | SW_PORT0_PPCPDEIMR_DRME(port->ePort->updateEgressDr?1U:0U)
6559 | SW_PORT0_PPCPDEIMR_DR0DEI(*(port->ePort->vlanDrToDei)[0U])
6560 | SW_PORT0_PPCPDEIMR_DR1DEI(*(port->ePort->vlanDrToDei)[1U])
6561 | SW_PORT0_PPCPDEIMR_DR2DEI(*(port->ePort->vlanDrToDei)[2U])
6562 | SW_PORT0_PPCPDEIMR_DR3DEI(*(port->ePort->vlanDrToDei)[3U]);
6563
6564 /* Bridge Port Default Vlan register configuration */
6565 Netc_EthSwt_Ip_ConfigBridgePortDefaultVlanReg(SwitchIdxSwitchPort.SwitchPortIdx, port);
6566
6567 /* PM0_COMMAND_CONFIG configuration */
6568 status = Netc_EthSwt_Ip_ConfigPMCommandReg(SwitchIdxSwitchPort, port);
6569
6570 Netc_EthSwt_Ip_InitPort_ConfigIngressEgressCutThroughSettings(SwitchIdxSwitchPort, port);
6571
6572 /* Bridge port configuration */
6573 if(port->EthSwtPortDisallowMacStationMove)
6574 {
6575 bridgePortConfig = SW_PORT1_BPCR_STAMVD(1U);
6576 }
6577
6578 bridgePortConfig |= SW_PORT0_BPCR_DYN_LIMIT(port->EthSwtPortMaxDynamicEntries);
6579
6580 /* Configure the pruning setting for each port */
6581 if (FALSE == port->EthSwtPortPruningEnable)
6582 {
6583 bridgePortConfig |= SW_PORT0_BPCR_SRCPRND_MASK;
6584 }
6585
6586 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchIdxSwitchPort.SwitchPortIdx]->BPCR = bridgePortConfig;
6587
6588 /* configure egress frame preemption */
6589 Netc_EthSwt_Ip_ConfigEgressPreemptionReg(SwitchIdxSwitchPort.SwitchPortIdx, port);
6590
6591 /* configure the credit base shaper */
6592 Netc_EthSwt_Ip_ConfigCreditBaseShaperReg(SwitchIdxSwitchPort.SwitchPortIdx, port);
6593
6594 return status;
6595 }
6596
6597 /*FUNCTION**********************************************************************
6598 *
6599 * Function Name : Netc_EthSwt_Ip_ConfigureEgressFramePreemption
6600 * Description : Function for configuring the frame preemption feature on egress
6601 * implements Netc_EthSwt_Ip_ConfigureEgressFramePreemption_Activity
6602 *END**************************************************************************/
6603 Std_ReturnType Netc_EthSwt_Ip_ConfigureEgressFramePreemption(uint8 SwitchIdx, const uint8 SwitchPortIdx, const boolean TrafficClass[8U])
6604 {
6605 uint8 tcIndex;
6606 uint32 localPFPCR = 0U;
6607 Std_ReturnType status = E_OK;
6608
6609 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6610 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6611 #endif
6612 (void) SwitchIdx;
6613 if(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
6614 {
6615 for(tcIndex = 0U; tcIndex < NETC_ETHSWT_IP_NUM_SHAPING_CLASS; tcIndex++)
6616 {
6617 localPFPCR |= ((uint32)(TrafficClass[tcIndex] ? 1U : 0U)) << tcIndex;
6618 }
6619 }
6620 else
6621 {
6622 status = E_NOT_OK; /* Unavailable feature for pseudo-port */
6623 };
6624
6625 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_62();
6626 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->PFPCR = localPFPCR;
6627 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_62();
6628
6629 return status;
6630 }
6631
6632 /*FUNCTION**********************************************************************
6633 *
6634 * Function Name : Netc_EthSwt_Ip_EnableEgressFramePreemption
6635 * Description : Function for enabling/disabling the frame preemption feature on egress
6636 * implements Netc_EthSwt_Ip_EnableEgressFramePreemption_Activity
6637 *END**************************************************************************/
6638 Std_ReturnType Netc_EthSwt_Ip_EnableEgressFramePreemption(uint8 SwitchIdx, const uint8 SwitchPortIdx, const boolean Enable)
6639 {
6640 Std_ReturnType status = E_OK;
6641
6642 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6643 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6644 #endif
6645
6646 (void)SwitchIdx;
6647
6648 if(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
6649 {
6650 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_63();
6651
6652 if(Enable == (boolean)TRUE)
6653 {
6654 #if defined(ERR_IPV_NETC_051025)
6655 #if (STD_ON == ERR_IPV_NETC_051025)
6656 /* Default is 10, for 10ms, for timer @400MHz. But if errata applies, timer is at @330MHz.
6657 To achieve 10ms, replace 10 with 330MHz/400MHz * 10 = 8.25, aproximated to 8 */
6658 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->MAC_MERGE_MMCSR |= SW_ETH_MAC_PORT0_MAC_MERGE_MMCSR_VT(8U);
6659 #endif
6660 #endif
6661 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->MAC_MERGE_MMCSR |= SW_ETH_MAC_PORT0_MAC_MERGE_MMCSR_ME(1U); /* Set ME bits to 1 to enable preemption on any byte boundary. */
6662 }
6663 else
6664 {
6665 Netc_EthSwt_Ip_PortBaseTable[SwitchPortIdx]->MAC_MERGE_MMCSR &= ~SW_ETH_MAC_PORT0_MAC_MERGE_MMCSR_ME(1U); /* Set ME bits to 0 to disable preemption. */
6666 }
6667 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_63();
6668 }
6669 else
6670 {
6671 status = E_NOT_OK;
6672 }
6673
6674 return status;
6675 }
6676
6677 /*FUNCTION**********************************************************************
6678 *
6679 * Function Name : Netc_EthSwt_Ip_ConfigureCreditBasedShaper
6680 * Description : function for configuring the CBS
6681 * implements Netc_EthSwt_Ip_ConfigureCreditBasedShaper_Activity
6682 *END**************************************************************************/
6683 Std_ReturnType Netc_EthSwt_Ip_ConfigureCreditBasedShaper(uint8 SwitchIdx, const uint8 SwitchPortIdx, const uint8 TrafficClass, const uint64 idleSlope)
6684 {
6685 Std_ReturnType status = E_OK;
6686 uint64 portTxRate;
6687 EthTrcv_BaudRateType baudRate = ETHTRCV_BAUD_RATE_10MBIT;
6688 uint64 largeBandwidth;
6689 uint32 bandwidth;
6690 uint64 largeEgressHiCredit;
6691 uint32 egressHiCredit;
6692 uint32 Netc_EthSwt_Ip_MaxFrameSize;
6693
6694 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6695 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6696 /* A Slope of zero would cause a bandwidth of zero and this would cause a buffer leak */
6697 DevAssert(idleSlope > 0U);
6698 DevAssert(TrafficClass < NETC_ETHSWT_IP_NUM_SHAPING_CLASS);
6699 #endif
6700
6701 if(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
6702 {
6703 status = Netc_EthSwt_Ip_GetPortSpeed( SwitchIdx, SwitchPortIdx, &baudRate);
6704 status |= Netc_EthSwt_Ip_PortRateEnumToRate(baudRate, &portTxRate);
6705 }
6706 else
6707 {
6708 portTxRate = 2000000UL;
6709 };
6710
6711 largeBandwidth = idleSlope / (portTxRate / 10000UL); /* bandwidth is in % and 100th precision, so need to divide by 10000 */
6712 if( largeBandwidth < 100UL )
6713 {
6714 largeBandwidth = 100UL; /* Min of 1% bandwidth, otherwise frames would get stuck in the switch */
6715 }
6716 /* Round and convert to uint32 */
6717 bandwidth = (uint32)(largeBandwidth/100UL);
6718 bandwidth = ((uint64)((((uint64)bandwidth)*100UL)+50UL)>largeBandwidth)?bandwidth:(bandwidth+1UL);
6719
6720 /* High Credit in credits
6721 hiCredit (bits) = maxSizedFrame * (idleSlope/portTxRate)
6722 bandwidth = idleSlope / portTxRate
6723 Then:
6724 hiCredit (bits) = maxSizedFrame * bandwidth
6725
6726 hiCredit (credits) = hiCredit (bits) * (ClockFrequency/portRate)
6727 Then:
6728 hiCredit (credits) = maxSizedFrame * bandwidth * (ClockFrequency / portRate)
6729 */
6730 Netc_EthSwt_Ip_MaxFrameSize = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCTMSDUR;
6731 largeEgressHiCredit = largeBandwidth * Netc_EthSwt_Ip_MaxFrameSize * (Netc_EthSwt_Ip_NetcClockFrequency / (portTxRate)) / 100UL; /* Bandwidth is in %, need to div by 100 */
6732 /* Round and convert to uint32 */
6733 egressHiCredit = (uint32)(largeEgressHiCredit/100UL);
6734 egressHiCredit = (((egressHiCredit*100UL)+50UL)>egressHiCredit)?egressHiCredit:(egressHiCredit+1UL);
6735
6736 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_05();
6737 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCCBSR0 &= ~SW_PORT0_PTCCBSR0_BW_MASK;
6738 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCCBSR0 |= SW_PORT0_PTCCBSR0_BW(bandwidth);
6739 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCCBSR1 = SW_PORT0_PTCCBSR1_HI_CREDIT(egressHiCredit);
6740 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_05();
6741
6742 return status;
6743 }
6744
6745 /*FUNCTION**********************************************************************
6746 *
6747 * Function Name : Netc_EthSwt_Ip_EnableCreditBasedShaper
6748 * Description : function for enabling a CBS
6749 * implements Netc_EthSwt_Ip_EnableCreditBasedShaper_Activity
6750 *END**************************************************************************/
6751 Std_ReturnType Netc_EthSwt_Ip_EnableCreditBasedShaper(uint8 SwitchIdx, const uint8 SwitchPortIdx, const uint8 TrafficClass, const boolean Enable)
6752 {
6753 Std_ReturnType status = E_OK;
6754
6755 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6756 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6757 DevAssert(TrafficClass < NETC_ETHSWT_IP_NUM_SHAPING_CLASS);
6758 #endif
6759
6760 (void)SwitchIdx;
6761 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_10();
6762 /* clear the bit first */
6763 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCCBSR0 &= ~SW_PORT0_PTCCBSR0_CBSE_MASK;
6764 /* write the bit */
6765 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->TCT_NUM[TrafficClass].PTCCBSR0 |= SW_PORT0_PTCCBSR0_CBSE((TRUE==Enable)?1U:0U);
6766 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_10();
6767
6768 return status;
6769 }
6770
6771
6772 /* inline function for configuring VlanIpvDr2PcpProfile */
6773 static inline void Netc_EthSwt_Ip_ConfigVlanIpvDr2PcpProfile(const uint8 *IndexProfile, const Netc_EthSwt_Ip_ConfigType * Config)
6774 {
6775 uint16 IndexIpv;
6776 uint16 IndexDr;
6777
6778 if(NULL_PTR != Config->vlanIpvDr2PcpProfile)
6779 {
6780 for (IndexDr=0U; IndexDr < NETC_ETHSWT_IP_NUMBER_OF_DR; IndexDr++)
6781 { /* Shifted by NETC_ETHSWT_IP_FIELD_REP_IN_4BITS for each DR index */
6782 for (IndexIpv=0; IndexIpv < NETC_ETHSWT_IP_NUMBER_OF_IPV; IndexIpv++)
6783 {
6784 /* Settings are divied in 4 registers by groups of 2 */
6785 /* even IPV in lower bits */
6786 IP_NETC__SW0_BASE->MAP_PCP[(*IndexProfile)].QOSVLANMPR[IndexIpv/2U] |= (uint32)((uint32)((*(Config->vlanIpvDr2PcpProfile))[(*IndexProfile)][IndexIpv][IndexDr])
6787 & NETC_F2_QOSVLANMPR_IPV0_DR0_MASK) << ((IndexDr*NETC_ETHSWT_IP_FIELD_REP_IN_4BITS) + (NETC_ETHSWT_IP_FIELD_REP_IN_TOP_OF_32BITS * (IndexIpv % 2U)));
6788 }
6789 }
6790 }
6791 }
6792
6793 static inline void Netc_EthSwt_Ip_InitMappingProfilePartTwo(uint8 IndexProfile, const Netc_EthSwt_Ip_ConfigType * Config)
6794 {
6795 uint8 IndexPcpDei;
6796 uint8 IndexPcp;
6797 if(NULL_PTR != Config->vlanPcpDei2IpvProfile )
6798 {
6799 for (IndexPcpDei=0U; IndexPcpDei < NETC_ETHSWT_IP_NUMBER_OF_PCP_DEI; IndexPcpDei++)
6800 {
6801 if(IndexPcpDei < (NETC_ETHSWT_IP_NUMBER_OF_PCP_DEI/2U)) /* Setting are divided in 2 registers */
6802 {
6803 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));
6804 }
6805 else
6806 {
6807 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));
6808 }
6809 }
6810 }
6811 if(Config->vlanPcpDei2DrProfile != NULL_PTR)
6812 {
6813 for (IndexPcpDei=0U; IndexPcpDei < NETC_ETHSWT_IP_NUMBER_OF_PCP_DEI; IndexPcpDei++)
6814 {
6815 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));
6816 }
6817 }
6818 if(NULL_PTR != Config->vlanPcp2PcpProfile)
6819 {
6820 for (IndexPcp=0U; IndexPcp < NETC_ETHSWT_IP_NUMBER_OF_PCP; IndexPcp++)
6821 {
6822 IP_NETC__SW0_BASE->PCP2PCPMPR[IndexProfile] |= (((uint32)((*(Config->vlanPcp2PcpProfile))[IndexProfile][IndexPcp]) & NETC_F2_PCP2PCPMPR_PCP0_MASK)<<(IndexPcp*NETC_ETHSWT_IP_FIELD_REP_IN_4BITS));
6823 }
6824 }
6825 }
6826
6827 /* inline function for initializing Mapping profile */
6828 static inline void Netc_EthSwt_Ip_InitMappingProfile(const Netc_EthSwt_Ip_ConfigType * Config)
6829 {
6830 uint8 IndexProfile;
6831 /* Initialize the clasification mapping */
6832 for (IndexProfile=0U; IndexProfile < NETC_ETHSWT_IP_NUMBER_OF_PROFILES; IndexProfile++)
6833 {
6834 /* Initializing the different arrays */
6835 IP_NETC__SW0_COMMON->NUM_PROFILE[IndexProfile].VLANIPVMPR0 = 0U;
6836 IP_NETC__SW0_COMMON->NUM_PROFILE[IndexProfile].VLANIPVMPR1 = 0U;
6837 IP_NETC__SW0_COMMON->NUM_PROFILE[IndexProfile].VLANDRMPR = 0U;
6838 IP_NETC__SW0_BASE->PCP2PCPMPR[IndexProfile] = 0U;
6839 IP_NETC__SW0_BASE->MAP_PCP[IndexProfile].QOSVLANMPR[0] = 0U;
6840 IP_NETC__SW0_BASE->MAP_PCP[IndexProfile].QOSVLANMPR[1] = 0U;
6841 IP_NETC__SW0_BASE->MAP_PCP[IndexProfile].QOSVLANMPR[2] = 0U;
6842 IP_NETC__SW0_BASE->MAP_PCP[IndexProfile].QOSVLANMPR[3] = 0U;
6843
6844 Netc_EthSwt_Ip_InitMappingProfilePartTwo(IndexProfile, Config);
6845
6846 Netc_EthSwt_Ip_ConfigVlanIpvDr2PcpProfile(&IndexProfile, Config);
6847 }
6848 }
6849
6850 /* inline function for initializing 1588 timer */
6851 static inline void Netc_EthSwt_Ip_InitTimer1588(const Netc_EthSwt_Ip_ConfigType * Config)
6852 {
6853 uint16 TimerClkPeriod;
6854 float64 ClkAddendData;
6855 uint32 TimerClkAddend;
6856 float64 TimerClkAddendRaw;
6857 uint32 TimerClkAddendRawInt;
6858
6859 if (Config->Timer1588ClkSrc == ETHSWT_EXTERNAL_REFERENCE_CLOCK)
6860 {
6861 TimerOriginalRefClk = Config->netcExternalClockFrequency;
6862 TimerRefClk = Config->netcExternalClockFrequency;
6863 Netc_EthSwt_Ip_TimerBase->TMR_CTRL &= ~TMR0_BASE_TMR_CTRL_CK_SEL(1U); /* select the external 200MHz clock for 1588 timer */
6864 }
6865 else if (Config->Timer1588ClkSrc == ETHSWT_MODULE_REFERENCE_CLOCK)
6866 {
6867 TimerOriginalRefClk = Config->netcClockFrequency;
6868 TimerRefClk = Config->netcClockFrequency;
6869 Netc_EthSwt_Ip_TimerBase->TMR_CTRL |= TMR0_BASE_TMR_CTRL_CK_SEL(1U); /* select NETC system clock (default setting) for 1588 timer */
6870 }
6871 else /* reference clock is disabled, will not use 1588 timer */
6872 {
6873 TimerOriginalRefClk = 0x0UL;
6874 TimerRefClk = 0x0UL;
6875 }
6876
6877 /* config and eanble the 1588 timer */
6878 if (TimerOriginalRefClk != 0x0UL)
6879 {
6880 TimerClkPeriod = (uint16)(1000000000UL / TimerRefClk); /* the integer portion of timer clock period (1/f) */
6881
6882 ClkAddendData = (((float64)1000000000UL) / ((float64)TimerRefClk)) - ((float64)TimerClkPeriod);
6883 TimerClkAddendRaw = ((float64)0x100000000UL) * ((float64)ClkAddendData);
6884 TimerClkAddendRawInt = (uint32)TimerClkAddendRaw;
6885 TimerClkAddend = TimerClkAddendRawInt + ((TimerClkAddendRaw > (float64)TimerClkAddendRawInt) ? 1U : 0U); /* the fractional part of the timer clock period. */
6886
6887 /* Timer addend register holds the fractional part of the timer clock period */
6888 Netc_EthSwt_Ip_TimerBase->TMR_ADD = TMR0_BASE_TMR_ADD_ADDEND(TimerClkAddend);
6889 /* clear CLK_PERIOD data field first */
6890 Netc_EthSwt_Ip_TimerBase->TMR_CTRL &= ~TMR0_BASE_TMR_CTRL_TCLK_PERIOD(0x3FF);
6891 Netc_EthSwt_Ip_TimerBase->TMR_CTRL |= TMR0_BASE_TMR_CTRL_TCLK_PERIOD(TimerClkPeriod);
6892 /* Enable timer */
6893 Netc_EthSwt_Ip_TimerBase->TMR_CTRL |= TMR0_BASE_TMR_CTRL_TE(1U);
6894 }
6895
6896 }
6897
6898 /* inline function for initializing time gate scheduling table entries data during switch init */
6899 static inline void Netc_EthSwt_Ip_InitTimeGateSchedulingTableEntryData(const Netc_EthSwt_Ip_ConfigType * Config)
6900 {
6901 uint8 PortIndex;
6902 uint8 GateControlListIdx;
6903
6904 for (PortIndex = 0U; PortIndex < NETC_ETHSWT_IP_NUMBER_OF_PORTS; PortIndex++)
6905 {
6906 if ((*((*(Config)).port))[PortIndex].ePort->portTimeAwareShaperEnable == TRUE)
6907 {
6908 /* set the flag for ports */
6909 PortTimeAwareShaperEnabled[PortIndex] = TRUE;
6910
6911 /* write register PTGSATOR. [Ricky}: not supported for now. follow up ticket needed. */
6912 /* TODO: Netc_EthSwt_Ip_SW0_PortxBaseAddr[PortIndex]->RESERVED_7 should be equal to (*((*(Config)).port))[PortIndex].ePort->portTimeGateSchedulingAdvanceTimeOffsetReg; */
6913
6914 /* Fill in the data structure for time gate scheduling */
6915 TimeGateSchedulingEntryData[PortIndex].TimeGateSchedulingTable_EID = PortIndex;
6916 TimeGateSchedulingEntryData[PortIndex].AdminBaseTime = (*((*(Config)).port))[PortIndex].ePort->portEgressAdminBaseTime;
6917 TimeGateSchedulingEntryData[PortIndex].AdminCycleTime = (*((*(Config)).port))[PortIndex].ePort->portEgressAdminCycleTime;
6918 TimeGateSchedulingEntryData[PortIndex].AdminCycleTimeExt = (*((*(Config)).port))[PortIndex].ePort->portEgressAdminCycleTimeExt;
6919 TimeGateSchedulingEntryData[PortIndex].AdminControlListLength = (*((*(Config)).port))[PortIndex].ePort->numberOfGateControlListEntries;
6920 #if (NETC_ETHSWT_MAX_NUMBER_OF_GATECONTROLLIST_ENTRIES > 0U)
6921 for (GateControlListIdx = 0U; GateControlListIdx < TimeGateSchedulingEntryData[PortIndex].AdminControlListLength; GateControlListIdx++)
6922 {
6923 TimeGateSchedulingEntryData[PortIndex].GateEntryAdminControlListData[GateControlListIdx].AdminTimeInterval = (*((*((*(Config)).port))[PortIndex].ePort->TimeGateControlListEntries))[GateControlListIdx].AdminTimeInterval;
6924 TimeGateSchedulingEntryData[PortIndex].GateEntryAdminControlListData[GateControlListIdx].AdminTrafficClassGateStates = (*((*((*(Config)).port))[PortIndex].ePort->TimeGateControlListEntries))[GateControlListIdx].AdminTrafficClassGateStates;
6925 TimeGateSchedulingEntryData[PortIndex].GateEntryAdminControlListData[GateControlListIdx].AdminGateOperationType = (*((*((*(Config)).port))[PortIndex].ePort->TimeGateControlListEntries))[GateControlListIdx].AdminGateOperationType;
6926 }
6927 #endif
6928 }
6929 }
6930 }
6931
6932 #if defined(ERR_IPV_NETC_E051130)
6933 #if (STD_ON == ERR_IPV_NETC_E051130)
6934 /* Workaround for ERR051130:
6935 Egress time gate scheduling can get corrupted when functional level reset is applied or when time gating is disabled
6936 */
6937 /* Added 2 fake time gate control list entries for clearing the internal context for time gate scheduling feature */
6938 static Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_InitTimeGateSchedulingFeature(uint8 SwitchIdx, uint8 SwitchPortIdx)
6939 {
6940 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
6941 volatile uint64 CurrentTime = 0;
6942 uint8 EntryIdx;
6943
6944 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
6945 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
6946 #endif
6947
6948 /* fill in struct Netc_EthSwt_Ip_TimeGateSchedulingEntryDataType */
6949 TimeGateSchedulingEntryData[0U].TimeGateSchedulingTable_EID = SwitchPortIdx;
6950 TimeGateSchedulingEntryData[0U].AdminCycleTime = 4000000U; /* it should be greater than the sum of time interval */
6951 TimeGateSchedulingEntryData[0U].AdminCycleTimeExt = 100000U;
6952 TimeGateSchedulingEntryData[0U].AdminControlListLength = 2U; /* 2 entries */
6953
6954 /* get the current time from 1588 timer */
6955 CurrentTime = Netc_EthSwt_Ip_TimerBase->TMR_CUR_TIME_L; /* should read the Lower register first */
6956 CurrentTime |= ((uint64)(Netc_EthSwt_Ip_TimerBase->TMR_CUR_TIME_H)) << NETC_ETHSWT_IP_32BIT_SHIFT;
6957 TimeGateSchedulingEntryData[0U].AdminBaseTime = CurrentTime; /* set base time to current time */
6958
6959 #if (NETC_ETHSWT_MAX_NUMBER_OF_GATECONTROLLIST_ENTRIES > 0U)
6960 /* fill in gate control list entries data */
6961 for (EntryIdx = 0U; EntryIdx < TimeGateSchedulingEntryData[0U].AdminControlListLength; EntryIdx++)
6962 {
6963 TimeGateSchedulingEntryData[0U].GateEntryAdminControlListData[EntryIdx].AdminTimeInterval = 2000000U; /* the value is equal to transmit 128bytes + 20 bytes (header) frame with port speed 10M */
6964 TimeGateSchedulingEntryData[0U].GateEntryAdminControlListData[EntryIdx].AdminTrafficClassGateStates = 0xFFU; /* all open */
6965 TimeGateSchedulingEntryData[0U].GateEntryAdminControlListData[EntryIdx].AdminGateOperationType = ETHSWT_HOST_REQUEST_UNCHANGED;
6966 }
6967 #endif
6968
6969 /* add these 2 gate control list entries */
6970 CBDRStatus = Netc_EthSwt_Ip_ConfigPortTimeGateScheduling(SwitchIdx, SwitchPortIdx, TRUE);
6971
6972 return CBDRStatus;
6973 }
6974 #endif
6975 #endif
6976
6977 static inline Std_ReturnType Netc_EthSwt_Ip_EnablePCIE(void)
6978 {
6979 uint32 StartTime;
6980 uint32 ElapsedTime;
6981 uint32 TimeoutTicks;
6982 Std_ReturnType Status = E_NOT_OK;
6983
6984 /* Perform warm reset to allow IERB writes. */
6985 IP_NETC__NETC_PRIV->NETCRR &= ~NETC_PRIV_NETCRR_LOCK_MASK;
6986
6987 /* Wait until NETCRR[LOCK] is cleared. */
6988 Netc_EthSwt_Ip_StartTimeOut(&StartTime, &ElapsedTime, &TimeoutTicks, NETC_ETHSWT_IP_TIMEOUT_VALUE_US);
6989 do
6990 {
6991 if ((IP_NETC__NETC_PRIV->NETCRR & NETC_PRIV_NETCRR_LOCK_MASK) == 0x0U)
6992 {
6993 Status = E_OK;
6994 break;
6995 }
6996 }while(!Netc_EthSwt_Ip_TimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks));
6997 /* This is a short procedure of warm reset because the functions were not intialized until now. */
6998
6999 if(E_OK == Status)
7000 {
7001 /* Allocate memory for stream gate instance index table memory. */
7002 IP_NETC__NETC_IERB->CFG_ENETC_INST[0U].ESGIITMAR = (uint32)0x00U;
7003 /* Allocate memory for stream gate control list index table memory */
7004 IP_NETC__NETC_IERB->CFG_ENETC_INST[0U].ESGCLITMAR = (uint32)0x02U;
7005 }
7006
7007 /* Explicit lock of memory. */
7008 IP_NETC__NETC_PRIV->NETCRR |= NETC_PRIV_NETCRR_LOCK_MASK;
7009
7010 /* Enable PCIE for the TIMER */
7011 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);
7012 /* Enable PCIE for the MDIO */
7013 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);
7014 /* Enable PCIE for the Switch */
7015 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);
7016 #if defined(ERR_IPV_NETC_051260)
7017 #if (STD_ON == ERR_IPV_NETC_051260)
7018 /* Enable PCIE for the ENETC */
7019 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);
7020 #endif
7021 #endif
7022
7023 return Status;
7024 }
7025
7026 /*FUNCTION**********************************************************************
7027 *
7028 * Function Name : Netc_EthSwt_Ip_ConfigSwt
7029 * Description : function for configuring the switch registers and ports
7030 *
7031 *END**************************************************************************/
7032 static Std_ReturnType Netc_EthSwt_Ip_ConfigSwt(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
7033 {
7034 Std_ReturnType status = E_OK;
7035 uint8 enabledPortMask = 0U;
7036 Netc_EthSwt_Ip_SwitchIdxSwitchPort SwitchIdxSwitchPort;
7037
7038 SwitchIdxSwitchPort.SwitchIdx = SwitchIdx;
7039
7040 Netc_EthSwt_Ip_NetcClockFrequency = Config->netcClockFrequency;
7041
7042 if(Config->EthSwtEnableSharedLearning)
7043 {
7044 IP_NETC__SW0_BASE->VFHTDECR1 = NETC_F2_VFHTDECR1_VL_MODE(1U) | NETC_F2_VFHTDECR1_FID(0U);
7045 }
7046 else
7047 {
7048 IP_NETC__SW0_BASE->VFHTDECR1 = NETC_F2_VFHTDECR1_VL_MODE(0U);
7049 }
7050
7051 IP_NETC__SW0_BASE->FDBHTMCR = NETC_F2_FDBHTMCR_DYN_LIMIT(Config->EthSwtMaxDynamicEntries);
7052 IP_NETC__SW0_COMMON->CVLANR1 = NETC_F2_COMMON_CVLANR1_V(Config->EthSwtCustomVlanEtherType1);
7053 IP_NETC__SW0_COMMON->CVLANR2 = NETC_F2_COMMON_CVLANR2_ETYPE(Config->EthSwtCustomVlanEtherType2);
7054
7055 /* Mapping profile initialization */
7056 Netc_EthSwt_Ip_InitMappingProfile(Config);
7057
7058 /* Initialize the ports of the switch */
7059 for (SwitchIdxSwitchPort.SwitchPortIdx = 0U; SwitchIdxSwitchPort.SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS; SwitchIdxSwitchPort.SwitchPortIdx++)
7060 {
7061 status = Netc_EthSwt_Ip_InitPort(SwitchIdxSwitchPort, &(*((*(Config)).port))[SwitchIdxSwitchPort.SwitchPortIdx]);
7062 /* Save the vlan configuration */
7063 Netc_EthSwt_Ip_PortVlanEnable[SwitchIdxSwitchPort.SwitchPortIdx] = (*((*(Config)).port))[SwitchIdxSwitchPort.SwitchPortIdx].iPort->vlanEnable;
7064
7065 if ( (TRUE == (*((*(Config)).port))[SwitchIdxSwitchPort.SwitchPortIdx].EthSwtPortMacLayerPortEnable) && (FALSE == (*((*(Config)).port))[SwitchIdxSwitchPort.SwitchPortIdx].iPort->vlanEnable ))
7066 {
7067 enabledPortMask |= (1U << SwitchIdxSwitchPort.SwitchPortIdx);
7068 }
7069 }
7070
7071 status |= Netc_EthSwt_Ip_EMDIOConfiguration(0U); /* init EMDIO configuration register */
7072
7073 /* Configure the VLAN filter hash default settings */
7074 IP_NETC__SW0_BASE->VFHTDECR0 = enabledPortMask; /* Add enabled ports to the default VLAN */
7075 /* To add Shared learning setting in EBT */
7076 /* set configured learning and forwarding options */
7077 IP_NETC__SW0_BASE->VFHTDECR2 = NETC_F2_VFHTDECR2_MLO(Config->MacLearningOption) | NETC_F2_VFHTDECR2_MFO(Config->MacForwardingOption);
7078
7079 /* used for port aging, value in sec */
7080 Netc_EthSwt_Ip_FdbTableEntryTimeout[SwitchIdxSwitchPort.SwitchIdx] = Config->EthSwtArlTableEntryTimeout;
7081
7082 /* +++ initialize 1588 timer for time gate scheduling +++ */
7083 Netc_EthSwt_Ip_InitTimer1588(Config);
7084 /* --- initialize 1588 timer for time gate scheduling --- */
7085
7086 /* initialize memory and length for command ring 0 and 1 */
7087 CmdBDRConfig[NETC_ETHSWT_IP_CBDR_0].CmdBDAddr = &SwtcommandRingDescriptor0[0U];
7088 CmdBDRConfig[NETC_ETHSWT_IP_CBDR_0].lengthCBDR = (NETC_ETHSWT_IP_CBDR0_LENGTH);
7089
7090 return status;
7091 }
7092
7093 /*FUNCTION**********************************************************************
7094 *
7095 * Function Name : Netc_EthSwt_Ip_ConfigTAS
7096 * Description : function for configuring the Time Aware Shaper for the switch
7097 *
7098 *END**************************************************************************/
7099 static Std_ReturnType Netc_EthSwt_Ip_ConfigTAS(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
7100 {
7101 Std_ReturnType status = E_OK;
7102 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
7103
7104 /* Avoid MISRA violation */
7105 (void)CBDRStatus;
7106 (void)SwitchIdx;
7107
7108 /* check if TAS is enabled or not */
7109 PortTimeAwareShaperEnabled[0U] = ((*((*(Config)).port))[0U].ePort->portTimeAwareShaperEnable ||
7110 (*((*(Config)).port))[1U].ePort->portTimeAwareShaperEnable ||
7111 (*((*(Config)).port))[2U].ePort->portTimeAwareShaperEnable) ? TRUE : FALSE;
7112
7113 if (TRUE == PortTimeAwareShaperEnabled[0U])
7114 {
7115 #if defined(ERR_IPV_NETC_E051130)
7116 #if (STD_ON == ERR_IPV_NETC_E051130)
7117 /* Default time gate scheduling conditions on the port 0 */
7118 CBDRStatus = Netc_EthSwt_Ip_InitTimeGateSchedulingFeature(SwitchIdx, 0U);
7119 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
7120 {
7121 status = E_NOT_OK;
7122 }
7123 else
7124 {
7125 #endif
7126 #endif
7127 /* Add time gate scheduling table entries data */
7128 Netc_EthSwt_Ip_InitTimeGateSchedulingTableEntryData(Config);
7129 #if defined(ERR_IPV_NETC_E051130)
7130 #if (STD_ON == ERR_IPV_NETC_E051130)
7131 }
7132 #endif
7133 #endif
7134 }
7135 return status;
7136 }
7137
7138 #if (NETC_ETHSWT_NUMBER_OF_FDB_ENTRIES > 0U)
7139 /*FUNCTION**********************************************************************
7140 *
7141 * Function Name : Netc_EthSwt_Ip_ConfigFDBTable
7142 * Description : function for configuring the FDB Table for the switch
7143 *
7144 *END**************************************************************************/
7145 static Std_ReturnType Netc_EthSwt_Ip_ConfigFDBTable(const Netc_EthSwt_Ip_ConfigType * Config)
7146 {
7147 uint32 MatchedEntries = 0U;
7148 uint8 MacAddrByteIdx;
7149 uint8 FdbEntryIdx;
7150 Netc_EthSwt_Ip_FdbEntryDataType FdbTableEntry = {0};
7151
7152 Std_ReturnType status = E_OK;
7153 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7154
7155 /* Add static FDB entries */
7156 for (FdbEntryIdx = 0U; FdbEntryIdx < Config->NumberOfFdbEntries; FdbEntryIdx++)
7157 {
7158 /* fill in data of Mac Address */
7159 for (MacAddrByteIdx = 0U; MacAddrByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacAddrByteIdx++)
7160 {
7161 FdbTableEntry.MacAddr[MacAddrByteIdx] = (*(Config->FdbEntries))[FdbEntryIdx].macAddr[MacAddrByteIdx];
7162 }
7163
7164 FdbTableEntry.FID = 0U; /* fill in data of FID */
7165 FdbTableEntry.SwitchPortEgressBitMask = (*(Config->FdbEntries))[FdbEntryIdx].ePortMask; /* fill in data of port bitmask */
7166 FdbTableEntry.DynamicEntry = FALSE; /* static entry */
7167
7168 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateFdbTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &FdbTableEntry);
7169 /* fail to add the static FDB entry */
7170 if ((CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS) || (MatchedEntries != 0U))
7171 {
7172 status = E_NOT_OK;
7173 break;
7174 }
7175
7176 }
7177 return status;
7178 }
7179 #endif
7180
7181 #if (NETC_ETHSWT_NUMBER_OF_IPFT_ENTRIES > 0U)
7182 /*FUNCTION**********************************************************************
7183 *
7184 * Function Name : Netc_EthSwt_Ip_ConfigIPFTable
7185 * Description : function for configuring the FDB Table for the switch
7186 *
7187 *END**************************************************************************/
7188 static Std_ReturnType Netc_EthSwt_Ip_ConfigIPFTable(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
7189 {
7190 uint32 MatchedEntries = 0U;
7191 uint8 IpftEntryIdx;
7192 Netc_EthSwt_Ip_IngressPortFilterEntryDataType IngrPortFilterTableEntry = {0};
7193
7194 Std_ReturnType status = E_OK;
7195 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7196
7197 for (IpftEntryIdx = 0U; IpftEntryIdx < Config->NumberOfIpftEntries; IpftEntryIdx++)
7198 {
7199 IngrPortFilterTableEntry = (*(Config->IngressPortFilterEntries))[IpftEntryIdx];
7200 CBDRStatus = Netc_EthSwt_Ip_AddIngressPortFilterTableEntry(SwitchIdx, &MatchedEntries, &IngrPortFilterTableEntry);
7201 /* fail to add the static FDB entry */
7202 if ((CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS) || (MatchedEntries != 0U))
7203 {
7204 status = E_NOT_OK;
7205 break;
7206 }
7207
7208 }
7209 return status;
7210 }
7211 #endif
7212
7213 #if (NETC_ETHSWT_NUMBER_OF_STREAMIDENTIFICATION_ENTRIES > 0U)
7214 /*FUNCTION**********************************************************************
7215 *
7216 * Function Name : Netc_EthSwt_Ip_ConfigISITable
7217 * Description : function for configuring the IngressStreamIdentification Table for the switch
7218 *
7219 *END**************************************************************************/
7220 static Std_ReturnType Netc_EthSwt_Ip_ConfigISITable(const Netc_EthSwt_Ip_ConfigType * Config)
7221 {
7222 uint32 MatchedEntries = 0U;
7223 uint8 FrmKeyWordIdx;
7224 uint8 IsiEntryIdx;
7225 Netc_EthSwt_Ip_IngrStremIdentificationTableDataType IsiTableEntry = {0};
7226
7227 Std_ReturnType status = E_OK;
7228 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7229
7230 /* Add key construction rules */
7231 IP_NETC__SW0_COMMON->ISIDKC0CR0 = (*(Config->EthSwtKeyConstruction))[0U].EthSwtKeyConstructionRegValue;
7232 IP_NETC__SW0_COMMON->ISIDKC1CR0 = (*(Config->EthSwtKeyConstruction))[1U].EthSwtKeyConstructionRegValue;
7233 IP_NETC__SW0_COMMON->ISIDKC2CR0 = (*(Config->EthSwtKeyConstruction))[2U].EthSwtKeyConstructionRegValue;
7234 IP_NETC__SW0_COMMON->ISIDKC3CR0 = (*(Config->EthSwtKeyConstruction))[3U].EthSwtKeyConstructionRegValue;
7235
7236 /* Add payload field values */
7237 IP_NETC__SW0_COMMON->ISIDKC0PF0CR = (*(Config->EthSwtKeyConstruction))[0U].EthSwtPayloadField0RegValue;
7238 IP_NETC__SW0_COMMON->ISIDKC0PF1CR = (*(Config->EthSwtKeyConstruction))[0U].EthSwtPayloadField1RegValue;
7239 IP_NETC__SW0_COMMON->ISIDKC1PF0CR = (*(Config->EthSwtKeyConstruction))[1U].EthSwtPayloadField0RegValue;
7240 IP_NETC__SW0_COMMON->ISIDKC1PF1CR = (*(Config->EthSwtKeyConstruction))[1U].EthSwtPayloadField1RegValue;
7241 IP_NETC__SW0_COMMON->ISIDKC2PF0CR = (*(Config->EthSwtKeyConstruction))[2U].EthSwtPayloadField0RegValue;
7242 IP_NETC__SW0_COMMON->ISIDKC2PF1CR = (*(Config->EthSwtKeyConstruction))[2U].EthSwtPayloadField1RegValue;
7243 IP_NETC__SW0_COMMON->ISIDKC3PF0CR = (*(Config->EthSwtKeyConstruction))[3U].EthSwtPayloadField0RegValue;
7244 IP_NETC__SW0_COMMON->ISIDKC3PF1CR = (*(Config->EthSwtKeyConstruction))[3U].EthSwtPayloadField1RegValue;
7245
7246 /* Add static IngressStreamIdentification entries */
7247 for (IsiEntryIdx = 0U; IsiEntryIdx < Config->NumberOfIsiEntries; IsiEntryIdx++)
7248 {
7249 IsiTableEntry.IngrStreamIdenResumeEntryId = (*(Config->IsiEntries))[IsiEntryIdx].IngrStreamIdenResumeEntryId;
7250 IsiTableEntry.IngrStreamIdenEntryId = (*(Config->IsiEntries))[IsiEntryIdx].IngrStreamIdenEntryId;
7251 IsiTableEntry.IngrStreamEntryId = (*(Config->IsiEntries))[IsiEntryIdx].IngrStreamEntryId;
7252 IsiTableEntry.Keye_Keytype = (*(Config->IsiEntries))[IsiEntryIdx].Keye_Keytype;
7253 IsiTableEntry.Keye_SrcPortId = (*(Config->IsiEntries))[IsiEntryIdx].Keye_SrcPortId;
7254 IsiTableEntry.Keye_Spm = (*(Config->IsiEntries))[IsiEntryIdx].Keye_Spm;
7255 for(FrmKeyWordIdx = 0; FrmKeyWordIdx < 4; FrmKeyWordIdx++)
7256 {
7257 IsiTableEntry.Keye_FrmKey[FrmKeyWordIdx] = (*(Config->IsiEntries))[IsiEntryIdx].Keye_FrmKey[FrmKeyWordIdx];
7258 }
7259 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateIngrStreamIdentificationTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &IsiTableEntry);
7260 /* fail to add the static IngressStreamIdentification entry */
7261 if ((CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS) || (MatchedEntries != 0U))
7262 {
7263 status = E_NOT_OK;
7264 break;
7265 }
7266
7267 }
7268 return status;
7269 }
7270 #endif
7271
7272 #if (NETC_ETHSWT_NUMBER_OF_SEQTAG_ENTRIES > 0U)
7273 /*FUNCTION**********************************************************************
7274 *
7275 * Function Name : Netc_EthSwt_Ip_ConfigISITable
7276 * Description : function for configuring the IngressStreamIdentification Table for the switch
7277 *
7278 *END**************************************************************************/
7279 static Std_ReturnType Netc_EthSwt_Ip_ConfigSeqGenTable(const Netc_EthSwt_Ip_ConfigType * Config)
7280 {
7281 uint32 MatchedEntries = 0U;
7282 uint8 SeqTagEntryIdx;
7283 Netc_EthSwt_Ip_ISQGTableDataType SeqTagTableEntry = {0};
7284
7285 Std_ReturnType status = E_OK;
7286 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7287
7288 /* Add static SequenceTag entries */
7289 for (SeqTagEntryIdx = 0U; SeqTagEntryIdx < Config->NumberOfSeqTagEntries; SeqTagEntryIdx++)
7290 {
7291 SeqTagTableEntry.ISQGEntryId = (*(Config->SeqTagEntries))[SeqTagEntryIdx].ISQGEntryId;
7292 SeqTagTableEntry.Cfge_SQTagType = (*(Config->SeqTagEntries))[SeqTagEntryIdx].Cfge_SQTagType;
7293 SeqTagTableEntry.Sgse_SQGNum = (*(Config->SeqTagEntries))[SeqTagEntryIdx].Sgse_SQGNum;
7294 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateIngressSeqGenerationTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &SeqTagTableEntry);
7295 /* fail to add the static SequenceGeneration entry */
7296 if ((CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS) || (MatchedEntries != 0U))
7297 {
7298 status = E_NOT_OK;
7299 break;
7300 }
7301
7302 }
7303 return status;
7304 }
7305 #endif
7306
7307 #if (NETC_ETHSWT_NUMBER_OF_SEQRECOVERY_ENTRIES > 0U)
7308 /*FUNCTION**********************************************************************
7309 *
7310 * Function Name : Netc_EthSwt_Ip_ConfigISITable
7311 * Description : function for configuring the IngressStreamIdentification Table for the switch
7312 *
7313 *END**************************************************************************/
7314 static Std_ReturnType Netc_EthSwt_Ip_ConfigSeqRecTable(const Netc_EthSwt_Ip_ConfigType * Config)
7315 {
7316 uint32 MatchedEntries = 0U;
7317 uint8 SeqRecEntryIdx;
7318 Netc_EthSwt_Ip_EgrSeqRecoveryTableDataType SeqRecTableEntry = {0};
7319
7320 Std_ReturnType status = E_OK;
7321 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7322
7323 /* Add static SequenceRecovery entries */
7324 for (SeqRecEntryIdx = 0U; SeqRecEntryIdx < Config->NumberOfSeqRecoveryEntries; SeqRecEntryIdx++)
7325 {
7326 SeqRecTableEntry.EgrSeqRecEntryId = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].EgrSeqRecEntryId;
7327 SeqRecTableEntry.Cfge_SQTag = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SQTag;
7328 SeqRecTableEntry.Cfge_SQRHisLen = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SQRHisLen;
7329 SeqRecTableEntry.Cfge_SQRFutureWinLen = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SQRFutureWinLen;
7330 SeqRecTableEntry.Cfge_SQRTimeOutPeriod = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SQRTimeOutPeriod;
7331 SeqRecTableEntry.Cfge_SqrTnsq = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SqrTnsq;
7332 SeqRecTableEntry.Cfge_SqrAlg = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SqrAlg;
7333 SeqRecTableEntry.Cfge_SqrType = (*(Config->SeqRecoveryEntries))[SeqRecEntryIdx].Cfge_SqrType;
7334 CBDRStatus = Netc_EthSwt_Ip_UpdateEgressSeqRecoveryTableEntry(0U, &MatchedEntries, &SeqRecTableEntry);
7335 /* fail to add the static SequenceRecovery entry */
7336 if ((CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS) || (MatchedEntries != 1U))
7337 {
7338 status = E_NOT_OK;
7339 break;
7340 }
7341
7342 }
7343 return status;
7344 }
7345 #endif
7346
7347 #if (NETC_ETHSWT_NUMBER_OF_FRAMEMODIFICATION_ENTRIES > 0U)
7348 /*FUNCTION**********************************************************************
7349 *
7350 * Function Name : Netc_EthSwt_Ip_ConfigFrmModificationTable
7351 * Description : function for configuring the FrameModification Table for the switch
7352 *
7353 *END**************************************************************************/
7354 static Std_ReturnType Netc_EthSwt_Ip_ConfigFrmModificationTable(const Netc_EthSwt_Ip_ConfigType * Config)
7355 {
7356 uint32 MatchedEntries = 0U;
7357 uint8 FrmModifEntryIdx = 0U;
7358
7359 Std_ReturnType status = E_OK;
7360 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7361 Netc_EthSwt_Ip_FrmModificationEntryDataType FrmModifTableEntry = {0};
7362
7363 for (FrmModifEntryIdx = 0U; FrmModifEntryIdx < Config->NumberOfFrmModifEntries; FrmModifEntryIdx++)
7364 {
7365 FrmModifTableEntry = (*(Config->FrameModificationEntries))[FrmModifEntryIdx];
7366 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateFrmModificationTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &FrmModifTableEntry);
7367
7368 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
7369 {
7370 status = E_NOT_OK;
7371 break;
7372 }
7373 }
7374
7375 return status;
7376 }
7377 #endif
7378
7379 #if (NETC_ETHSWT_NUMBER_OF_EGRESSTREATMENT_ENTRIES > 0U)
7380 /*FUNCTION**********************************************************************
7381 *
7382 * Function Name : Netc_EthSwt_Ip_ConfigEgressTreatmentTable
7383 * Description : function for configuring the EgressTreatment Table for the switch
7384 *
7385 *END**************************************************************************/
7386 static Std_ReturnType Netc_EthSwt_Ip_ConfigEgressTreatmentTable(const Netc_EthSwt_Ip_ConfigType * Config)
7387 {
7388 uint32 MatchedEntries = 0U;
7389 uint8 EgrTrtEntryIdx = 0U;
7390
7391 Std_ReturnType status = E_OK;
7392 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7393 Netc_EthSwt_Ip_EgressTreatmentEntryDataType EgrTrtTableEntry = {0};
7394
7395 for (EgrTrtEntryIdx = 0U; EgrTrtEntryIdx < Config->NumberOfEgrTreatmentEntries; EgrTrtEntryIdx++)
7396 {
7397 EgrTrtTableEntry = (*(Config->EgressTreatmentEntries))[EgrTrtEntryIdx];
7398 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateEgressTreatmentTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &EgrTrtTableEntry);
7399
7400 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
7401 {
7402 status = E_NOT_OK;
7403 break;
7404 }
7405 }
7406
7407 return status;
7408 }
7409
7410 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_GetEgressCountTable(uint8 SwitchIdx, uint32 * MatchedEntries, Netc_EthSwt_Ip_ECTableStatisticsDataType * EgressCountTable)
7411 {
7412 uint8 EgrTrtEntryIdx = 0U;
7413 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7414 uint8 EgressCountTableEntriesNb = IP_NETC__SW0_COMMON->ECTCAPR & NETC_F2_COMMON_ECTCAPR_NUM_ENTRIES_MASK;
7415
7416 for (EgrTrtEntryIdx = 0U; EgrTrtEntryIdx < EgressCountTableEntriesNb; EgrTrtEntryIdx++)
7417 {
7418 CBDRStatus = Netc_EthSwt_Ip_QueryEgressCountTableEntry(SwitchIdx, EgrTrtEntryIdx, MatchedEntries, &(EgressCountTable[EgrTrtEntryIdx]));
7419
7420 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
7421 {
7422 break;
7423 }
7424 }
7425
7426 return CBDRStatus;
7427 }
7428
7429
7430
7431 #endif
7432
7433 #if (NETC_ETHSWT_NUMBER_OF_INGRESSSTREAM_ENTRIES > 0U)
7434 /*FUNCTION**********************************************************************
7435 *
7436 * Function Name : Netc_EthSwt_Ip_ConfigIngressStreamTable
7437 * Description : function for configuring the IngressStream Table for the switch
7438 *
7439 *END**************************************************************************/
7440 static Std_ReturnType Netc_EthSwt_Ip_ConfigIngressStreamTable(const Netc_EthSwt_Ip_ConfigType * Config)
7441 {
7442 uint32 MatchedEntries = 0U;
7443 uint8 IngrStrEntryIdx = 0U;
7444
7445 Std_ReturnType status = E_OK;
7446 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7447 Netc_EthSwt_Ip_IngressStreamEntryDataType IngrStrTableEntry = {0};
7448
7449 for (IngrStrEntryIdx = 0U; IngrStrEntryIdx < Config->NumberOfIngrStreamEntries; IngrStrEntryIdx++)
7450 {
7451 IngrStrTableEntry = (*(Config->IngressStreamEntries))[IngrStrEntryIdx];
7452
7453 /*Add Ingress Stream Table entry*/
7454 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateIngressStreamTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &IngrStrTableEntry);
7455
7456 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
7457 {
7458 status = E_NOT_OK;
7459 break;
7460 }
7461
7462 }
7463
7464 return status;
7465 }
7466 #endif
7467
7468 #if (NETC_ETHSWT_NUMBER_OF_STREAMFILTER_ENTRIES > 0U)
7469 /*FUNCTION**********************************************************************
7470 *
7471 * Function Name : Netc_EthSwt_Ip_ConfigIngressStreamFilterTable
7472 * Description : function for configuring the Ingress Stream Filter Table for the switch
7473 *
7474 *END**************************************************************************/
7475 static Std_ReturnType Netc_EthSwt_Ip_ConfigIngressStreamFilterTable(const Netc_EthSwt_Ip_ConfigType * Config)
7476 {
7477 uint32 MatchedEntries = 0U;
7478 uint8 IngrStrFilterEntryIdx = 0U;
7479
7480 Std_ReturnType status = E_OK;
7481 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7482 Netc_EthSwt_Ip_IngressStreamFilterEntryDataType IngrStrFilterTableEntry = {0};
7483
7484 for (IngrStrFilterEntryIdx = 0U; IngrStrFilterEntryIdx < Config->NumberOfIngrStreamFilterEntries; IngrStrFilterEntryIdx++)
7485 {
7486 IngrStrFilterTableEntry = (*(Config->IngressStreamFilterEntries))[IngrStrFilterEntryIdx];
7487 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateIngressStreamFilterTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &IngrStrFilterTableEntry);
7488
7489 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
7490 {
7491 status = E_NOT_OK;
7492 break;
7493 }
7494 }
7495
7496 return status;
7497 }
7498 #endif
7499
7500 #if (NETC_ETHSWT_NUMBER_OF_STREAMCOUNT_ENTRIES > 0U)
7501 /*FUNCTION**********************************************************************
7502 *
7503 * Function Name : Netc_EthSwt_Ip_ConfigIngressStreamCountTable
7504 * Description : function for configuring the IngressStreamCount Table for the switch
7505 *
7506 *END**************************************************************************/
7507 static Std_ReturnType Netc_EthSwt_Ip_ConfigIngressStreamCountTable(const Netc_EthSwt_Ip_ConfigType * Config)
7508 {
7509 uint32 MatchedEntries = 0U;
7510 uint32 IngrStrCountIdx = 0U;
7511
7512 Std_ReturnType status = E_OK;
7513 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7514
7515 for (IngrStrCountIdx = 0U; IngrStrCountIdx < Config->NumberOfIngrStreamCountEntries; IngrStrCountIdx++)
7516 {
7517
7518 /*Add Ingress Stream Count Table entry*/
7519 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateIngressStreamCountTableEntry(0U, NETC_ETHSWT_ADD_CMD, &MatchedEntries, IngrStrCountIdx);
7520
7521 if (CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
7522 {
7523 status = E_NOT_OK;
7524 break;
7525 }
7526 }
7527
7528 return status;
7529 }
7530 #endif
7531
7532 #if (NETC_ETHSWT_NUMBER_OF_VLANFILTER_ENTRIES > 0U)
7533 /*FUNCTION**********************************************************************
7534 *
7535 * Function Name : Netc_EthSwt_Ip_ConfigVLANFilterTable
7536 * Description : function for configuring the VLAN Filter Table for the switch
7537 *
7538 *END**************************************************************************/
7539 static Std_ReturnType Netc_EthSwt_Ip_ConfigVLANFilterTable(const Netc_EthSwt_Ip_ConfigType * Config)
7540 {
7541
7542 uint32 VlanMatchedEntries = 0U;
7543 uint8 VlanEntryIdx;
7544 Netc_EthSwt_Ip_VlanFilterEntryDataType VlanFilterEntryData = {0};
7545
7546 Std_ReturnType status = E_OK;
7547 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7548
7549 /* Add Vlan Filter entries */
7550 for (VlanEntryIdx = 0U; VlanEntryIdx < Config->NumberOfVlanFilterEntries; VlanEntryIdx++)
7551 {
7552 /* fill in VlanFilterEntryData structure */
7553 VlanFilterEntryData.VlanID = (*(Config->VlanFilterEntries))[VlanEntryIdx].vlanId;
7554 VlanFilterEntryData.PortMembershipBitmap = (*(Config->VlanFilterEntries))[VlanEntryIdx].iPortMask;
7555
7556 if (Config->EthSwtEnableSharedLearning == FALSE)
7557 {
7558 VlanFilterEntryData.FID = VlanFilterEntryData.VlanID; /* for independent vlan learning, the FID should be equal to TCI */
7559 }
7560 else
7561 {
7562 VlanFilterEntryData.FID = (0U); /* for shared vlan learning, the FID should be always equal to 0 */
7563 }
7564
7565 VlanFilterEntryData.MacLearningOptions = Config->MacLearningOption; /* enable mac learning */
7566 VlanFilterEntryData.MacForwardingOptions = Config->MacForwardingOption; /* FDB lookup, if there is no match, then frame is flooded */
7567 VlanFilterEntryData.IpMulticastFloodingEnable = FALSE; /* IP multicast flooding disable */
7568 VlanFilterEntryData.IpMulticastFilteringEnable = FALSE; /* IP multicast filtering disable */
7569 VlanFilterEntryData.BaseEgressTreatmentEntryID = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID; /* egress treatment processing is by-passed */
7570
7571 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateVlanFilterTableEntry(0U, NETC_ETHSWT_ADD_CMD, &VlanMatchedEntries, &VlanFilterEntryData);
7572 /* fail to add the Vlan Filter entry */
7573 if ((CBDRStatus != NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS) || (VlanMatchedEntries != 0U))
7574 {
7575 status = E_NOT_OK;
7576 break;
7577 }
7578 }
7579 return status;
7580 }
7581 #endif
7582
7583
7584 /*FUNCTION**********************************************************************
7585 *
7586 * Function Name : Netc_EthSwt_Ip_Init
7587 * Description : function for initializing a switch
7588 * implements Netc_EthSwt_Ip_Init_Activity
7589 *END**************************************************************************/
7590 Std_ReturnType Netc_EthSwt_Ip_Init(uint8 SwitchIdx, const Netc_EthSwt_Ip_ConfigType * Config)
7591 {
7592 Std_ReturnType status;
7593 uint8 portIdx = 0U;
7594 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7595
7596 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
7597 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7598 DevAssert(Config != NULL_PTR);
7599 #endif
7600
7601 /* enable PCIE for the timer, MDIO, switch, and ENETC */
7602 status = Netc_EthSwt_Ip_EnablePCIE();
7603 status |= Netc_EthSwt_Ip_IerbReady();
7604
7605 if(status == (uint8)(E_OK))
7606 {
7607 /* configure switch registers and ports */
7608 status = Netc_EthSwt_Ip_ConfigSwt(SwitchIdx,Config);
7609
7610 /* intialize command ring 0 */
7611 CBDRStatus = Netc_EthSwt_Ip_InitCommandBDR(0U, NETC_ETHSWT_IP_CBDR_0);
7612 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS == CBDRStatus)
7613 {
7614 #if (NETC_ETHSWT_NUMBER_OF_FDB_ENTRIES > 0U)
7615 /* Configure FDB table */
7616 status |= Netc_EthSwt_Ip_ConfigFDBTable(Config);
7617 #endif
7618
7619 #if (NETC_ETHSWT_NUMBER_OF_VLANFILTER_ENTRIES > 0U)
7620 /* Configure VLAN Filter table */
7621 status |= Netc_EthSwt_Ip_ConfigVLANFilterTable(Config);
7622 #endif
7623 /* Enable Ingress Port Filtering for ports
7624 (for PTP and Mirroring)
7625 PTP traffic from PSI is injected as Tx management on desired external port and therefore not passing as Rx through pseudo-ports.
7626 PTP frames sent to external devices from PSI will not be filtered when filtering on pseudo-ports is enabled.
7627 Only PTP frames from VSIs will be redirected to Ingress on PSI when filtering is enabled on pseudo-ports. */
7628 for (portIdx = 0U; portIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS; portIdx++)
7629 {
7630 status |= Netc_EthSwt_Ip_EnableIngressPortFiltering(SwitchIdx, portIdx, TRUE);
7631 }
7632 Netc_EthSwt_Ip_ConfigPtr[SwitchIdx] = Config;
7633
7634 #if (NETC_ETHSWT_NUMBER_OF_IPFT_ENTRIES > 0U)
7635 status |= Netc_EthSwt_Ip_ConfigIPFTable(SwitchIdx, Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7636 #endif
7637 }
7638 else
7639 {
7640 status = E_NOT_OK;
7641 }
7642 }
7643
7644 return status;
7645 }
7646
7647 /*FUNCTION**********************************************************************
7648 *
7649 * Function Name : Netc_EthSwt_Ip_StartTSN
7650 * Description : function for starting the Time Sensitive Networking functionality
7651 * implements Netc_EthSwt_Ip_StartTSN_Activity
7652 *END**************************************************************************/
7653 Std_ReturnType Netc_EthSwt_Ip_StartTSN(uint8 SwitchIdx)
7654 {
7655 Std_ReturnType status = E_OK;
7656
7657 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
7658 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7659 DevAssert(Netc_EthSwt_Ip_ConfigPtr[SwitchIdx] != NULL_PTR);
7660 #endif
7661
7662 #if (NETC_ETHSWT_NUMBER_OF_RP_ENTRIES > 0U)
7663 status |= Netc_EthSwt_Ip_ConfigRP(SwitchIdx,Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7664 #endif
7665
7666 #if (NETC_ETHSWT_NUMBER_OF_SGCL_ENTRIES > 0U)
7667 status |= Netc_EthSwt_Ip_ConfigSGCL(SwitchIdx,Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7668 #endif
7669
7670 #if (NETC_ETHSWT_NUMBER_OF_SGI_ENTRIES > 0U)
7671 status |= Netc_EthSwt_Ip_ConfigSGI(SwitchIdx,Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7672 #endif
7673 /* Configure Time Aware Shaper */
7674 status |= Netc_EthSwt_Ip_ConfigTAS(SwitchIdx, Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7675
7676 #if (NETC_ETHSWT_NUMBER_OF_STREAMIDENTIFICATION_ENTRIES > 0U)
7677 /* Configure IngressStreamIdentification table */
7678 status |= Netc_EthSwt_Ip_ConfigISITable(Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7679 #endif
7680
7681 #if (NETC_ETHSWT_NUMBER_OF_SEQTAG_ENTRIES > 0U)
7682 /* Configure IngressSequenceGeneration table */
7683 status |= Netc_EthSwt_Ip_ConfigSeqGenTable(Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7684 #endif
7685
7686 #if (NETC_ETHSWT_NUMBER_OF_SEQRECOVERY_ENTRIES > 0U)
7687 /* Configure EgressSequenceRecovery table */
7688 status |= Netc_EthSwt_Ip_ConfigSeqRecTable(Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7689 #endif
7690 #if (NETC_ETHSWT_NUMBER_OF_EGRESSTREATMENT_ENTRIES > 0U)
7691 /* Configure EgressTreatment table */
7692 status |= Netc_EthSwt_Ip_ConfigEgressTreatmentTable(Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7693 #endif
7694 #if (NETC_ETHSWT_NUMBER_OF_FRAMEMODIFICATION_ENTRIES > 0U)
7695 /* Configure FrameModification table */
7696 status |= Netc_EthSwt_Ip_ConfigFrmModificationTable(Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7697 #endif
7698 #if (NETC_ETHSWT_NUMBER_OF_INGRESSSTREAM_ENTRIES > 0U)
7699 /* Configure IngressStream table */
7700 status |= Netc_EthSwt_Ip_ConfigIngressStreamTable(Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7701 #endif
7702 #if (NETC_ETHSWT_NUMBER_OF_STREAMFILTER_ENTRIES > 0U)
7703 /* Configure Ingress Stream Filter table */
7704 status |= Netc_EthSwt_Ip_ConfigIngressStreamFilterTable(Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7705 #endif
7706 #if (NETC_ETHSWT_NUMBER_OF_STREAMCOUNT_ENTRIES > 0U)
7707 /* Configure IngressStreamCount table */
7708 status |= Netc_EthSwt_Ip_ConfigIngressStreamCountTable(Netc_EthSwt_Ip_ConfigPtr[SwitchIdx]);
7709 #endif
7710
7711 return status;
7712 }
7713
7714 /*FUNCTION**********************************************************************
7715 *
7716 * Function Name : Netc_EthSwt_Ip_EMDIOConfiguration
7717 * Description : function for configuring the EMDIO
7718 *
7719 *END**************************************************************************/
7720 static Std_ReturnType Netc_EthSwt_Ip_EMDIOConfiguration( uint8 SwitchIdx )
7721 {
7722 Std_ReturnType Status = E_OK;
7723 uint32 CfgData;
7724
7725 (void)SwitchIdx;
7726 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
7727 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7728 #endif
7729
7730 CfgData = NETC_F1_EMDIO_CFG_CMP(0U) | NETC_F1_EMDIO_CFG_CIM(0U) | NETC_F1_EMDIO_CFG_NEG(1U) \
7731 | NETC_F1_EMDIO_CFG_EHOLD(0U) | NETC_F1_EMDIO_CFG_MDIO_CLK_DIV(NETC_ETHSWT_IP_MDIO_CLK_DIV) \
7732 | NETC_F1_EMDIO_CFG_ENC45(0U) | NETC_F1_EMDIO_CFG_PRE_DIS(0U) | NETC_F1_EMDIO_CFG_MDIO_HOLD(4U);
7733
7734 /* config EMDIO_CFG register */
7735 IP_NETC__EMDIO_BASE->EMDIO_CFG = CfgData;
7736
7737 return Status;
7738 }
7739
7740 /* implements Netc_EthSwt_Ip_ReadTrcvRegister_Activity */
7741 Std_ReturnType Netc_EthSwt_Ip_ReadTrcvRegister( uint8 SwitchIdx, uint8 TrcvIdx, uint8 RegIdx, uint16 * RegVal )
7742 {
7743 Std_ReturnType Status = E_NOT_OK;
7744 uint32 CtrlData;
7745 uint32 StartTime;
7746 uint32 ElapsedTime;
7747 uint32 TimeoutTicks;
7748
7749 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
7750 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7751 DevAssert(NULL_PTR != RegVal);
7752 #endif
7753
7754 (void)SwitchIdx;
7755
7756 CtrlData = NETC_F1_EMDIO_CTL_PORT_ADDR(TrcvIdx) | NETC_F1_EMDIO_CTL_DEV_ADDR(RegIdx) \
7757 | NETC_F1_EMDIO_CTL_READ(1U);
7758
7759 /* config EMDIO_CTL register */
7760 IP_NETC__EMDIO_BASE->EMDIO_CTL = CtrlData;
7761
7762 /* Wait till MDIO transaction is occuring and no read error is detected */
7763 Netc_EthSwt_Ip_StartTimeOut(&StartTime, &ElapsedTime, &TimeoutTicks, NETC_ETHSWT_IP_TIMEOUT_VALUE_US);
7764 do
7765 {
7766 #ifdef MCAL_ENABLE_FAULT_INJECTION
7767 MCAL_FAULT_INJECTION_POINT(ETHSWT_CHECK_EMDIO_READ_TIMEOUT);
7768 #endif
7769 if ((IP_NETC__EMDIO_BASE->EMDIO_CFG & NETC_ETHSWT_IP_MDIO_REG_READ_FLAG) == 0x0U)
7770 {
7771 Status = E_OK;
7772 break;
7773 }
7774 } while (!Netc_EthSwt_Ip_TimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks));
7775
7776 /* Read the Data */
7777 if ((uint8)(E_OK) == Status)
7778 {
7779 *RegVal = (uint16)(IP_NETC__EMDIO_BASE->EMDIO_DATA & NETC_F1_EMDIO_DATA_MDIO_DATA_MASK);
7780 }
7781
7782 return Status;
7783 }
7784
7785 /* implements Netc_EthSwt_Ip_WriteTrcvRegister_Activity */
7786 Std_ReturnType Netc_EthSwt_Ip_WriteTrcvRegister( uint8 SwitchIdx, uint8 TrcvIdx, uint8 RegIdx, uint16 RegVal )
7787 {
7788 Std_ReturnType Status = E_NOT_OK;
7789 uint32 CtrlData;
7790 uint32 StartTime;
7791 uint32 ElapsedTime;
7792 uint32 TimeoutTicks;
7793
7794 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
7795 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7796 #endif
7797
7798 (void)SwitchIdx;
7799
7800 CtrlData = NETC_F1_EMDIO_CTL_PORT_ADDR(TrcvIdx) | NETC_F1_EMDIO_CTL_DEV_ADDR(RegIdx);
7801
7802 /* config EMDIO_CTL register */
7803 IP_NETC__EMDIO_BASE->EMDIO_CTL = CtrlData;
7804
7805 /* Write MDIO_DATA for initiating write transaction to PHY */
7806 IP_NETC__EMDIO_BASE->EMDIO_DATA = RegVal;
7807
7808 /* Wait till MDIO transaction is occuring */
7809 Netc_EthSwt_Ip_StartTimeOut(&StartTime, &ElapsedTime, &TimeoutTicks, NETC_ETHSWT_IP_TIMEOUT_VALUE_US);
7810 do
7811 {
7812 #ifdef MCAL_ENABLE_FAULT_INJECTION
7813 MCAL_FAULT_INJECTION_POINT(ETHSWT_CHECK_EMDIO_WRITE_TIMEOUT);
7814 #endif
7815 if ((IP_NETC__EMDIO_BASE->EMDIO_CFG & NETC_ETHSWT_IP_MDIO_REG_WRITE_FLAG) == 0x0U)
7816 {
7817 Status = E_OK;
7818 break;
7819 }
7820 } while (!Netc_EthSwt_Ip_TimeoutExpired(&StartTime, &ElapsedTime, TimeoutTicks));
7821
7822 return Status;
7823 }
7824
7825 /*FUNCTION**********************************************************************
7826 *
7827 * Function Name : Netc_EthSwt_Ip_GetPortMirrorState
7828 * Description : External function for obtaining the current status of mirroring for the indexed Ethernet switch
7829 * implements Netc_EthSwt_Ip_GetMirrorState_Activity
7830 *END**************************************************************************/
7831 Std_ReturnType Netc_EthSwt_Ip_GetMirrorState( uint8 SwitchIdx, Netc_EthSwt_Ip_SwitchMirrorStateType *MirrorStatePtr )
7832 {
7833 Std_ReturnType Status = E_OK;
7834 uint32 MirrorState;
7835
7836 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
7837 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7838 DevAssert(MirrorStatePtr != NULL_PTR);
7839 #endif
7840
7841 (void)SwitchIdx;
7842
7843 MirrorState = (IP_NETC__SW0_BASE->IMDCR0) & NETC_F2_IMDCR0_MIREN_MASK;
7844 *MirrorStatePtr = (MirrorState == 0U) ? (NETC_ETHSWT_MIRROR_DISABLED) : (NETC_ETHSWT_MIRROR_ENABLED);
7845
7846 return Status;
7847 }
7848
7849 /*FUNCTION**********************************************************************
7850 *
7851 * Function Name : Netc_EthSwt_Ip_SetMirrorState
7852 * Description : External function for requesting to set the mirroring state of the given Ethernet switch.
7853 * implements Netc_EthSwt_Ip_SetMirrorState_Activity
7854 *END**************************************************************************/
7855 Std_ReturnType Netc_EthSwt_Ip_SetMirrorState( uint8 SwitchIdx, Netc_EthSwt_Ip_SwitchMirrorStateType MirrorState )
7856 {
7857 Std_ReturnType Status = E_OK;
7858 uint32 RegIMDCR0 = 0x0UL;
7859
7860 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
7861 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7862 #endif
7863
7864 (void)SwitchIdx;
7865 RegIMDCR0 = IP_NETC__SW0_BASE->IMDCR0;
7866 if (NETC_ETHSWT_MIRROR_ENABLED == MirrorState)
7867 {
7868 RegIMDCR0 |= NETC_F2_IMDCR0_MIREN(NETC_ETHSWT_MIRROR_ENABLED);
7869 }
7870 else
7871 {
7872 RegIMDCR0 &= ~NETC_F2_IMDCR0_MIREN(NETC_ETHSWT_MIRROR_ENABLED);
7873 }
7874
7875 IP_NETC__SW0_BASE->IMDCR0 = RegIMDCR0;
7876
7877 return Status;
7878 }
7879
7880 /*FUNCTION**********************************************************************
7881 *
7882 * Function Name : Netc_EthSwt_Ip_DeleteMirrorConfiguration
7883 * Description : External function for deleting the mirror configuration of the given Ethernet switch..
7884 * implements Netc_EthSwt_Ip_DeleteMirrorConfiguration_Activity
7885 *END**************************************************************************/
7886 Std_ReturnType Netc_EthSwt_Ip_DeleteMirrorConfiguration( uint8 MirroredSwitchIdx )
7887 {
7888 Std_ReturnType Status = E_OK;
7889 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
7890 uint16 EFMEntryId;
7891 uint8 MIRDestBit;
7892 uint32 MatchedEntries = 0U;
7893 uint32 LocalImdCr1 = 0U;
7894
7895 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
7896 DevAssert(MirroredSwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
7897 #endif
7898 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_06();
7899 if (TRUE == MirrorConfigurationDone)
7900 {
7901 if (MirroringIngressPortFilterEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID)
7902 {
7903 /* Delete ingress port filter entry */
7904 CBDRStatus = Netc_EthSwt_Ip_DeleteIngressPortFilterTableEntry(MirroredSwitchIdx, &MatchedEntries, MirroringIngressPortFilterEntryId);
7905 if ((NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS != CBDRStatus) || (0UL == MatchedEntries))
7906 {
7907 Status = E_NOT_OK;
7908 }
7909 else
7910 {
7911 /* Set ingress port filter entry to NULL again */
7912 MirroringIngressPortFilterEntryId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
7913 Status = E_OK;
7914 }
7915 }
7916
7917 /* Delete Frame modificatin entry */
7918 MIRDestBit = (uint8)((IP_NETC__SW0_BASE->IMDCR0 & NETC_F2_IMDCR0_MIRDEST_MASK) >> NETC_F2_IMDCR0_MIRDEST_SHIFT);
7919 /* Read the register value in a local variable since it should have been read more than once. */
7920 LocalImdCr1 = IP_NETC__SW0_BASE->IMDCR1;
7921 EFMEntryId = (uint16)(LocalImdCr1 & NETC_F2_IMDCR1_EFMEID_MASK);
7922 if ((EFMEntryId != NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID) && (MIRDestBit == (uint8)0U))
7923 {
7924 CBDRStatus = Netc_EthSwt_Ip_DeleteFrmModificationTableEntry(MirroredSwitchIdx, EFMEntryId, &MatchedEntries);
7925 if ((NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS != CBDRStatus) || (0U == MatchedEntries))
7926 {
7927 Status = E_NOT_OK;
7928 }
7929 else
7930 {
7931 EFMEntryId = (uint16)(NETC_F2_IMDCR1_EFMEID(NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID)); /* set frame modification table entry ID to NULL */
7932 LocalImdCr1 |= EFMEntryId;
7933 IP_NETC__SW0_BASE->IMDCR1 = LocalImdCr1;
7934 Status = E_OK;
7935 }
7936 }
7937 if ((uint8)(E_OK) == Status)
7938 {
7939 Status = Netc_EthSwt_Ip_SetMirrorState(MirroredSwitchIdx, NETC_ETHSWT_MIRROR_DISABLED);
7940
7941 /* Disable ingress mirroring on all ports */
7942 Netc_EthSwt_Ip_SW0_PortxBaseAddr[0U]->PMCR = 0x0U;
7943 Netc_EthSwt_Ip_SW0_PortxBaseAddr[1U]->PMCR = 0x0U;
7944 Netc_EthSwt_Ip_SW0_PortxBaseAddr[2U]->PMCR = 0x0U;
7945
7946 MirrorConfigurationDone = FALSE;
7947 }
7948 }
7949
7950 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_06();
7951
7952 return Status;
7953 }
7954
7955 /* inline function for checking if mac address filter enabled or not */
7956 static inline void Netc_EthSwt_Ip_CheckMacAddressFilterEnableFlag(Netc_EthSwt_Ip_IngressPortFilterSrcDestAddrFilter* const IngressPortFilterSrcDestAddrFilter, const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr)
7957 {
7958 uint8 MacByteIdx;
7959
7960 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
7961 {
7962 if (MirrorConfigurationPtr->SrcMacAddrFilter[MacByteIdx] != 0x0U)
7963 {
7964 IngressPortFilterSrcDestAddrFilter->SrcMacAddrFilterEnabled = TRUE;
7965 break;
7966 }
7967 }
7968 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
7969 {
7970 if (MirrorConfigurationPtr->DstMacAddrFilter[MacByteIdx] != 0x0U)
7971 {
7972 IngressPortFilterSrcDestAddrFilter->DstMacAddrFilterEnabled = TRUE;
7973 break;
7974 }
7975 }
7976 }
7977
7978
7979 /*FUNCTION**********************************************************************
7980 *
7981 * Function Name : Netc_EthSwt_Ip_ConfigIngressPortFilterForTimestamping
7982 * implements Netc_EthSwt_Ip_ConfigIngressPortFilterForTimestamping_Activity
7983 *END**************************************************************************/
7984 Std_ReturnType Netc_EthSwt_Ip_ConfigIngressPortFilterForTimestamping(uint8 SwitchIdx)
7985 {
7986
7987 Netc_EthSwt_Ip_IngressPortFilterEntryDataType IngressPortFilterTableEntry = {0};
7988 uint8 Index;
7989 uint32 MatchedEntries;
7990 Std_ReturnType Status;
7991
7992 /* CFGE Data */
7993 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeOverrideIpv = FALSE; /* Leave IPV as-is */
7994 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeOverrideDr = FALSE; /* Leave DR as-is */
7995 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeFilterForwardingAction = NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_REDIRECTFRAMES; /* Redirect frame to management port*/
7996 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeIngressMirroringEnable = FALSE; /* Ingress Mirroring disabled */
7997 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeWakeOnLanTriggerEnable = FALSE; /* Wake-On-LAN triggering disabled */
7998 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeFilterAction = NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_NOACTION; /* Not routing to any RP/Ingress Stream */
7999 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeHostReason = (uint8)NETC_ETHSWT_IP_HOSTREASON_SW_PTP; /* Software-defined hostreason to mark frame as PTP-specific */
8000 IngressPortFilterTableEntry.IngressPortFilterCfgeData.CfgeTargetForSelectedFilterAction = 0xFFFFFFFFUL; /* RP/Ingress Stream by-passed */
8001
8002 /* KEYE Data */
8003 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyePrecedence = 0xFFFFU; /* Set highest priority for filter */
8004 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeFrmAttributeFlagsMask = 0x0U; /* Mask all frame attribute flags (Do not filter based on them) */
8005 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePointMask = 0x0U; /* Do not filter based on Differentiated Services Code Point */
8006 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeSourcePortIDMask = 0x0U; /* Do not filter based on Source Port */
8007 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformationMask = 0x0U; /* Do not filter based on Outer VLAN Tag Control Information */
8008 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformationMask = 0x0U; /* Do not filter based on Inner VLAN Tag Control Information */
8009 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeEtherTypeMask = 0x0U; /* Do not filter based on EtherType */
8010 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeIPProtocolMask = 0x0U; /* Do not filter based on IP Protocol field */
8011 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeL4SourcePortMask = 0x0U; /* Do not filter based on L4 Source Port */
8012 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeL4DestinationPortMask = 0x0U; /* Do not filter based on L4 Destination Port */
8013
8014 for (Index = 0; Index < 6U; Index++)
8015 {
8016 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddrMask[Index] = 0xFFU; /* Filter based on Destination MAC Address */
8017 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeSrcMacAddrMask[Index] = 0x0U; /* Do not filter based on Source MAC Address */
8018 }
8019 for (Index = 0; Index < 4U; Index++)
8020 {
8021 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeIPSourceAddressMask[Index] = 0x0U; /* Do not filter based on IP Source Address */
8022 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeIPDestinationAddressMask[Index] = 0x0U; /* Do not filter based on IP Destination Address */
8023 }
8024 for (Index = 0; Index < 24U; Index++)
8025 {
8026 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyePayloadBytesMask[Index] = 0x0U; /* Do not filter based on Payload Bytes */
8027 }
8028
8029 /* Generic PTP messages DMAC: 01-1B-19-00-00-00 */
8030 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[0U] = 0x01U;
8031 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[1U] = 0x1BU;
8032 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[2U] = 0x19U;
8033 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[3U] = 0x00U;
8034 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[4U] = 0x00U;
8035 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[5U] = 0x00U;
8036 Status = (Netc_EthSwt_Ip_AddIngressPortFilterTableEntry(SwitchIdx, &MatchedEntries, &IngressPortFilterTableEntry) == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS) ? E_OK : E_NOT_OK;
8037
8038 if (Status == E_OK)
8039 {
8040 /* Peer delay message DMAC: 01-80-C2-00-00-0E */
8041 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[1U] = 0x80U;
8042 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[2U] = 0xC2U;
8043 IngressPortFilterTableEntry.IngressPortFilterkeyeData.KeyeDstMacAddr[5U] = 0x0EU;
8044 Status = (Netc_EthSwt_Ip_AddIngressPortFilterTableEntry(SwitchIdx, &MatchedEntries, &IngressPortFilterTableEntry) == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS) ? E_OK : E_NOT_OK;
8045 }
8046
8047 return Status;
8048 }
8049
8050 /* inline function for enabling mac address filtering for port mirroring*/
8051 static inline Std_ReturnType Netc_EthSwt_Ip_ConfigIngressPortFilterForPortMirroring(const uint8 MirroredSwitchIdx, const Netc_EthSwt_Ip_IngressPortFilterSrcDestAddrFilter IngressPortFilterSrcDestAddrFilter,
8052 const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr,
8053 Netc_EthSwt_Ip_IngressPortFilterEntryDataType *IngressPortFilterTableEntry
8054 )
8055 {
8056 Std_ReturnType Status = E_OK;
8057 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
8058 uint8 MacByteIdx;
8059 uint8 PayloadByteIdx;
8060 uint32 MatchedEntries;
8061
8062 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
8063 DevAssert(MirroredSwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8064 #endif
8065
8066 /* config and add one ingress port filter table entry */
8067 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeOverrideIpv = FALSE;
8068 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeOverrideDr = FALSE;
8069 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeIngressMirroringEnable = TRUE; /* enable mirroring */
8070 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeWakeOnLanTriggerEnable = FALSE;
8071 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeCutThroughDisable = TRUE; /* shoudl disable CTD */
8072 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeTimestampCaptureEable = FALSE;
8073 /* permit frames */
8074 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeFilterForwardingAction = NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_PERMITFRAMES;
8075 IngressPortFilterTableEntry->IngressPortFilterCfgeData.CfgeFilterAction = NETC_ETHSWT_IP_INGRESSPORTFILTERTABLE_NOACTION;
8076
8077 /* enable mac address filtering */
8078 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
8079 {
8080 if (IngressPortFilterSrcDestAddrFilter.DstMacAddrFilterEnabled == TRUE)
8081 {
8082 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[MacByteIdx] = 0xFFU;
8083 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddr[MacByteIdx] = MirrorConfigurationPtr->DstMacAddrFilter[MacByteIdx];
8084 MirrorCfgBackup.DstMacAddrFilter[MacByteIdx] = MirrorConfigurationPtr->DstMacAddrFilter[MacByteIdx];
8085 }
8086 else
8087 {
8088 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDstMacAddrMask[MacByteIdx] = 0x0U;
8089 MirrorCfgBackup.DstMacAddrFilter[MacByteIdx] = 0x0U;
8090 }
8091
8092 if (IngressPortFilterSrcDestAddrFilter.SrcMacAddrFilterEnabled == TRUE)
8093 {
8094 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[MacByteIdx] = 0xFFU;
8095 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddr[MacByteIdx] = MirrorConfigurationPtr->SrcMacAddrFilter[MacByteIdx];
8096 MirrorCfgBackup.SrcMacAddrFilter[MacByteIdx] = MirrorConfigurationPtr->SrcMacAddrFilter[MacByteIdx];
8097 }
8098 else
8099 {
8100 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSrcMacAddrMask[MacByteIdx] = 0x0U;
8101 MirrorCfgBackup.SrcMacAddrFilter[MacByteIdx] = 0x0U;
8102 }
8103 }
8104
8105 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeFrmAttributeFlagsMask = 0U;
8106 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeSourcePortIDMask = 0U;
8107 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeDifferentiatedServicesCodePointMask = 0U;
8108 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeInnerVLANTagControlInformationMask = 0U;
8109 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeEtherTypeMask = 0U;
8110 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPProtocolMask = 0U;
8111 for (MacByteIdx = 0U; MacByteIdx < 4U; MacByteIdx++)
8112 {
8113 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPSourceAddressMask[MacByteIdx] = 0x0U;
8114 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeIPDestinationAddressMask[MacByteIdx] = 0x0U;
8115 }
8116 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4SourcePortMask = 0U;
8117 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeL4DestinationPortMask = 0U;
8118 for (PayloadByteIdx = 0U; PayloadByteIdx < 24U; PayloadByteIdx++)
8119 {
8120 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePayloadBytesMask[PayloadByteIdx] = 0x0U;
8121 }
8122 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyePrecedence = NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID; /* precedence, maximum priority */
8123
8124 if (MirrorConfigurationPtr->VlanIdFilter != NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID)
8125 {
8126 MirrorCfgBackup.VlanIdFilter = MirrorConfigurationPtr->VlanIdFilter;
8127
8128 /* vlan id filter */
8129 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformationMask = 0xFFF0U;
8130 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformation = (MirrorConfigurationPtr->VlanIdFilter);
8131 }
8132 else
8133 {
8134 MirrorCfgBackup.VlanIdFilter = NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID;
8135 IngressPortFilterTableEntry->IngressPortFilterkeyeData.KeyeOuterVLANTagControlInformationMask = 0x0U;
8136 }
8137
8138 CBDRStatus = Netc_EthSwt_Ip_AddIngressPortFilterTableEntry(MirroredSwitchIdx, &MatchedEntries, IngressPortFilterTableEntry);
8139 if ((NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS != CBDRStatus) || (1U == MatchedEntries))
8140 {
8141 Status = E_NOT_OK;
8142 }
8143 else
8144 {
8145 /* Store the ingress port filter entry id */
8146 MirroringIngressPortFilterEntryId = IngressPortFilterTableEntry->IngressPortFilterEntryID;
8147 }
8148
8149 return Status;
8150 }
8151
8152 /* inline function for retagging /double tagging egress frames with frame modification table entry */
8153 static inline Std_ReturnType Netc_EthSwt_Ip_ConfigEgressFrameModificationForPortMirroring(uint8 MirroredSwitchIdx, const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr)
8154 {
8155 Std_ReturnType Status = E_OK;
8156 Netc_EthSwt_Ip_CBDRStatusType CBDRStatus;
8157 uint32 RegIMDCR1 = 0x0UL;
8158 uint32 MatchedEntries = 0x0UL;
8159 Netc_EthSwt_Ip_FrmModificationEntryDataType FrmModificationEntry = {0};
8160
8161 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
8162 DevAssert(MirroredSwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8163 #endif
8164
8165 if (MirrorConfigurationPtr->MirroringMode != NETC_ETHSWT_NO_VLAN_RETAGGING)
8166 {
8167 /* config and add one frame modification table entry for modifying the dest mac address */
8168 FrmModificationEntry.FrmModificationEntryID = NETC_ETHSWT_IP_EFMEID_FOR_MIRRORING; /* default frame modification table entry ID for mirroring */
8169 FrmModificationEntry.L2Actions = 0U;
8170 FrmModificationEntry.L2HeaderMacActions = 0U; /* no actions for Header Mac */
8171 FrmModificationEntry.L2HeaderVlanActions = (MirrorConfigurationPtr->MirroringMode > NETC_ETHSWT_VLAN_RETAGGING) ? (2U) : (3U);
8172 FrmModificationEntry.OuterVidActions = 1U; /* Use the VID specified in the OUTER_VLAN_VID field of this entry */
8173 FrmModificationEntry.OuterVlanVID = MirrorConfigurationPtr->VlanId;
8174 FrmModificationEntry.OuterTpidAction = 0U; /* Use TPID, PCP and DEI from outer VLAN header */
8175 FrmModificationEntry.OuterDeiAction = 0U; /* Use TPID, PCP and DEI from outer VLAN header */
8176 FrmModificationEntry.OuterPcpAction = 0U; /* Use TPID, PCP and DEI from outer VLAN header */
8177 FrmModificationEntry.SequenceTagAction = 0U;
8178 FrmModificationEntry.PayloadActions = 0U;
8179 FrmModificationEntry.FrmModificationDataEntryID = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID; /* frame modification data table entry id */
8180
8181 CBDRStatus = Netc_EthSwt_Ip_AddOrUpdateFrmModificationTableEntry(MirroredSwitchIdx, NETC_ETHSWT_ADD_CMD, &MatchedEntries, &FrmModificationEntry);
8182 if (NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS == CBDRStatus)
8183 {
8184 /* [IMDCR0]: keep IPV and DR default in IMDCR0 register */
8185 /* [IMDCR1] */
8186 RegIMDCR1 = NETC_F2_IMDCR1_EFM_LEN_CHANGE(NETC_ETHSWT_IP_EFM_LEN_CHANGE_FOR_MIRRORING);
8187 RegIMDCR1 |= NETC_F2_IMDCR1_EFMEID(NETC_ETHSWT_IP_EFMEID_FOR_MIRRORING); /* default frame modification table entry ID for mirroring */
8188 IP_NETC__SW0_BASE->IMDCR1 = RegIMDCR1;
8189 }
8190 else
8191 {
8192 Status = E_NOT_OK;
8193 }
8194 }
8195
8196 return Status;
8197 }
8198
8199 static inline void Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable_SecondPart(uint8 SwitchIdx, Netc_EthSwt_Ip_ResumeEntryEntryId ResumeEntryEntryId, float64 AgingTimeout, Std_ReturnType* Status)
8200 {
8201 Netc_EthSwt_Ip_CBDRStatusType DeleteStatus;
8202 if(AgingTimeout >= (float64) (Netc_EthSwt_Ip_FdbTableEntryTimeout[SwitchIdx])) /* Check if FDB entry is older than accepted */
8203 { /* Try and delete the aged FDB entry */
8204 DeleteStatus = Netc_EthSwt_Ip_DeleteFdbTableEntryById(SwitchIdx, ResumeEntryEntryId.EntryId);
8205 if(NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS != DeleteStatus)
8206 {
8207 *Status = E_NOT_OK;
8208 }
8209 }
8210 }
8211
8212 /*FUNCTION**********************************************************************
8213 *
8214 * Function Name : Netc_EthSwt_Ip_WriteMirrorConfiguration
8215 * Description : Function used for writing a mirroring configuration
8216 * implements Netc_EthSwt_Ip_WriteMirrorConfiguration_Activity
8217 *END**************************************************************************/
8218 Std_ReturnType Netc_EthSwt_Ip_WriteMirrorConfiguration( uint8 MirroredSwitchIdx, const Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr )
8219 {
8220 Std_ReturnType Status = E_OK;
8221 uint32 RegIMDCR0 = 0x0UL;
8222 uint32 RegIMDCR1 = 0x0UL;
8223
8224 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
8225 DevAssert(MirroredSwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8226 DevAssert(MirrorConfigurationPtr != NULL_PTR);
8227 DevAssert(MirrorConfigurationPtr->CapturePortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
8228 DevAssert(MirrorConfigurationPtr->MirroringMode <= NETC_ETHSWT_VLAN_DOUBLE_TAGGING);
8229 #endif
8230
8231 /* If a mirroring configuration is already in place, delete it */
8232 Status = Netc_EthSwt_Ip_DeleteMirrorConfiguration(MirroredSwitchIdx);
8233 if ((uint8)(E_OK) == Status)
8234 {
8235 /* Indicates the mirror destination */
8236 RegIMDCR0 = IP_NETC__SW0_BASE->IMDCR0;
8237 RegIMDCR0 &= ~(NETC_F2_IMDCR0_MIRDEST_MASK);
8238 RegIMDCR0 |= NETC_F2_IMDCR0_MIRDEST(0U); /* 0: Port as specified by PORT field; 1: Switch management port */
8239 RegIMDCR0 &= ~(NETC_F2_IMDCR0_PORT_MASK);
8240 RegIMDCR0 |= NETC_F2_IMDCR0_PORT(MirrorConfigurationPtr->CapturePortIdx);
8241 /* Write IMDCR0 register */
8242 IP_NETC__SW0_BASE->IMDCR0 = RegIMDCR0;
8243
8244 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_11();
8245 RegIMDCR1 = IP_NETC__SW0_BASE->IMDCR1;
8246 RegIMDCR1 |= NETC_F2_IMDCR1_EFMEID(NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID); /* set frame modification table entry ID to NULL */
8247 IP_NETC__SW0_BASE->IMDCR1 = RegIMDCR1;
8248
8249 Netc_EthSwt_Ip_WriteMirrorConfiguration_SecondPart(MirroredSwitchIdx, MirrorConfigurationPtr, &Status);
8250
8251 if ((uint8)(E_OK) == Status)
8252 {
8253 /* Set the mirror configuration done flag */
8254 MirrorConfigurationDone = TRUE;
8255
8256 /* store the mirror configuration data */
8257 MirrorCfgBackup.MirroringMode = MirrorConfigurationPtr->MirroringMode;
8258 MirrorCfgBackup.VlanId = MirrorConfigurationPtr->VlanId;
8259 MirrorCfgBackup.CapturePortIdx = MirrorConfigurationPtr->CapturePortIdx;
8260 MirrorCfgBackup.TrafficDirectionIngressBitMask = MirrorConfigurationPtr->TrafficDirectionIngressBitMask;
8261 }
8262 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_11();
8263
8264 }
8265
8266 return Status;
8267 }
8268
8269 /*FUNCTION**********************************************************************
8270 *
8271 * Function Name : Netc_EthSwt_Ip_ReadMirrorConfiguration
8272 * Description : External function for obtaining the mirror configuration of the given Ethernet switch..
8273 * implements Netc_EthSwt_Ip_ReadMirrorConfiguration_Activity
8274 *END**************************************************************************/
8275 Std_ReturnType Netc_EthSwt_Ip_ReadMirrorConfiguration( uint8 MirroredSwitchIdx, Netc_EthSwt_Ip_SwitchMirrorCfgType* MirrorConfigurationPtr )
8276 {
8277 Std_ReturnType Status = E_OK;
8278 uint8 MacByteIdx;
8279
8280 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
8281 DevAssert(MirroredSwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8282 DevAssert(MirrorConfigurationPtr != NULL_PTR);
8283 #endif
8284
8285 (void)MirroredSwitchIdx;
8286 if (TRUE == MirrorConfigurationDone) /* The mirror configuration is in place */
8287 {
8288 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
8289 {
8290 MirrorConfigurationPtr->SrcMacAddrFilter[MacByteIdx] = MirrorCfgBackup.SrcMacAddrFilter[MacByteIdx];
8291 MirrorConfigurationPtr->DstMacAddrFilter[MacByteIdx] = MirrorCfgBackup.DstMacAddrFilter[MacByteIdx];
8292 }
8293 MirrorConfigurationPtr->VlanIdFilter = MirrorCfgBackup.VlanIdFilter;
8294 MirrorConfigurationPtr->MirroringMode = MirrorCfgBackup.MirroringMode;
8295 MirrorConfigurationPtr->VlanId = MirrorCfgBackup.VlanId;
8296 MirrorConfigurationPtr->CapturePortIdx = MirrorCfgBackup.CapturePortIdx;
8297 MirrorConfigurationPtr->TrafficDirectionIngressBitMask = MirrorCfgBackup.TrafficDirectionIngressBitMask;
8298 }
8299 else /* no mirror configuration exists */
8300 {
8301 for (MacByteIdx = 0U; MacByteIdx < NETC_ETHSWT_IP_MACADDRLEN; MacByteIdx++)
8302 {
8303 MirrorConfigurationPtr->SrcMacAddrFilter[MacByteIdx] = 0x0U;
8304 MirrorConfigurationPtr->DstMacAddrFilter[MacByteIdx] = 0x0U;
8305 }
8306 MirrorConfigurationPtr->VlanIdFilter = NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID;
8307 MirrorConfigurationPtr->MirroringMode = NETC_ETHSWT_NO_VLAN_RETAGGING;
8308 MirrorConfigurationPtr->VlanId = NETC_ETHSWT_IP_UINT16_NULL_ENTRY_ID;
8309 MirrorConfigurationPtr->CapturePortIdx = 0U;
8310 MirrorConfigurationPtr->TrafficDirectionIngressBitMask = 0x0UL;
8311 }
8312
8313 return Status;
8314 }
8315
8316 /*FUNCTION**********************************************************************
8317 *
8318 * Function Name : Netc_EthSwt_Ip_MainFunction
8319 * Description : Periodically called function to age FDB entries
8320 * implements Netc_EthSwt_Ip_MainFunction_Activity
8321 *END**************************************************************************/
8322 void Netc_EthSwt_Ip_MainFunction( uint8 SwitchIdx )
8323 {
8324 Std_ReturnType Status = E_OK;
8325 Netc_EthSwt_Ip_ResumeEntryEntryId ResumeEntryEntryId;
8326 boolean FoundEntry;
8327 uint32 HwAgingCount;
8328 float32 MainFunctionCycleSteps;
8329 float32 CalNumAgingCycle;
8330 float64 AgingTimeout;
8331 float32 mainPeriod;
8332
8333 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
8334 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8335 #endif
8336
8337 mainPeriod = (float32)NETC_ETHSWT_IP_MAIN_FUNCTION_PERIOD;
8338
8339 /* 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. */
8340 CalNumAgingCycle = (float32)Netc_EthSwt_Ip_FdbTableEntryTimeout[SwitchIdx];
8341 CalNumAgingCycle /= mainPeriod;
8342 if (CalNumAgingCycle < NETC_ETHSWT_IP_NUM_AGING_CYCLE_FLOAT)
8343 {
8344 /* 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. */
8345 MainFunctionCycleSteps = NETC_ETHSWT_IP_ONE_FLOAT;
8346 }
8347 else
8348 {
8349 /* 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.
8350 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)
8351 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. */
8352 /* Extract the number of funtion period */
8353 MainFunctionCycleSteps = (float32)(Netc_EthSwt_Ip_FdbTableEntryTimeout[SwitchIdx]);
8354 MainFunctionCycleSteps /= mainPeriod;
8355 /* Rounding up the number of aging cycles steps */
8356 MainFunctionCycleSteps += NETC_ETHSWT_IP_NUM_AGING_CYCLE_FLOAT - NETC_ETHSWT_IP_ONE_FLOAT;
8357 /* Extract the number of steps */
8358 MainFunctionCycleSteps /= NETC_ETHSWT_IP_NUM_AGING_CYCLE_FLOAT;
8359 /* Convert float32 to uint32, missing lroundf from C99 */
8360 if(MainFunctionCycleSteps <= NETC_ETHSWT_IP_ONE_FLOAT)
8361 {
8362 MainFunctionCycleSteps = (float32)NETC_ETHSWT_IP_ONE_FLOAT;
8363 }
8364 }
8365 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_61();
8366 Netc_EthSwt_Ip_MainFunctionCycle[SwitchIdx]++;
8367
8368 if(((float64)Netc_EthSwt_Ip_MainFunctionCycle[SwitchIdx]) >= (float64)MainFunctionCycleSteps)
8369 {
8370 /* Aging action */
8371 /* Activity update, ACT_CNT++ if no ACT_FLAG otherwise 0 */
8372 ResumeEntryEntryId.ResumeEntryId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
8373 do
8374 {
8375 Status |= Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable(SwitchIdx, &ResumeEntryEntryId, &HwAgingCount, &FoundEntry);
8376 if(((Std_ReturnType)E_OK == Status) && (TRUE == FoundEntry))
8377 {
8378 AgingTimeout = (float64)HwAgingCount;
8379 AgingTimeout *= (float64)MainFunctionCycleSteps;
8380 AgingTimeout *= (float64)mainPeriod;
8381 Netc_EthSwt_Ip_SearchAndAgeEntryInFdbTable_SecondPart(SwitchIdx, ResumeEntryEntryId, AgingTimeout, &Status);
8382 }
8383 } while (((Std_ReturnType)E_OK == Status)
8384 && ((uint32)NETC_ETHSWT_IP_BD_NULL_ENTRY_ID != ResumeEntryEntryId.ResumeEntryId) );
8385 Netc_EthSwt_Ip_MainFunctionCycle[SwitchIdx] = 0UL;
8386 }
8387 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_61();
8388
8389 }
8390
8391 /*FUNCTION**********************************************************************
8392 *
8393 * Function Name : Netc_EthSwt_Ip_SetPruningMode
8394 * Description : External function for setting the pruning mode for ports.
8395 * implements Netc_EthSwt_Ip_SetPruningMode_Activity
8396 *END**************************************************************************/
8397 Std_ReturnType Netc_EthSwt_Ip_SetPruningMode(uint8 SwitchIdx, uint8 SwitchPortIdx, boolean PruningEnable)
8398 {
8399 Std_ReturnType Status = E_OK;
8400 uint32 bridgePortConfig = 0UL;
8401
8402 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
8403 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8404 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
8405 #endif
8406
8407 (void)SwitchIdx;
8408 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_59();
8409
8410 /* read the BPCR configurate data first */
8411 bridgePortConfig = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->BPCR;
8412
8413 /* Configure the pruning setting for the port */
8414 if (FALSE == PruningEnable)
8415 {
8416 bridgePortConfig |= SW_PORT0_BPCR_SRCPRND_MASK;
8417 }
8418 else
8419 {
8420 bridgePortConfig &= ~SW_PORT0_BPCR_SRCPRND_MASK;
8421 }
8422
8423 /* write the BPCR configuration back */
8424 Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->BPCR = bridgePortConfig;
8425 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_59();
8426
8427 return Status;
8428 }
8429
8430 /*FUNCTION**********************************************************************
8431 *
8432 * Function Name : Netc_EthSwt_Ip_GetPruningMode
8433 * Description : External function for getting the pruning mode of ports.
8434 * implements Netc_EthSwt_Ip_GetPruningMode_Activity
8435 *END**************************************************************************/
8436 Std_ReturnType Netc_EthSwt_Ip_GetPruningMode(uint8 SwitchIdx, uint8 SwitchPortIdx, boolean *PruningEnablePtr)
8437 {
8438 Std_ReturnType Status = E_OK;
8439 uint32 bridgePortConfig = 0UL;
8440
8441 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
8442 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8443 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
8444 DevAssert(PruningEnablePtr != NULL_PTR);
8445 #endif
8446
8447 (void)SwitchIdx;
8448
8449 /* read the BPCR configurate data first */
8450 bridgePortConfig = Netc_EthSwt_Ip_SW0_PortxBaseAddr[SwitchPortIdx]->BPCR;
8451
8452 /* get the pruning mode data for the port */
8453 *PruningEnablePtr = ((bridgePortConfig & SW_PORT0_BPCR_SRCPRND_MASK) == 0x0UL) ? TRUE : FALSE;
8454
8455 return Status;
8456 }
8457
8458 #if(NETC_ETHSWT_IP_CONFIG_LINK_PROTOCOL == STD_ON)
8459 /*FUNCTION**********************************************************************
8460 *
8461 * Function Name : Netc_EthSwt_Ip_ConfigLinkProtocol
8462 * Description : External function for configuring the MII protocol for ethernet ports.
8463 *
8464 *END**************************************************************************/
8465 static void Netc_EthSwt_Ip_ConfigLinkProtocol(uint8 SwitchIdx, uint8 SwitchPortIdx, Netc_EthSwt_Ip_XmiiModeType EthSwtPortPhysicalLayerType)
8466 {
8467 uint32 Netcc1Reg;
8468
8469 #if(NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_ON)
8470 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8471 DevAssert(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_PORTS);
8472 #endif
8473
8474 (void)SwitchIdx;
8475
8476 if(SwitchPortIdx < NETC_ETHSWT_IP_NUMBER_OF_MAC_PORTS)
8477 {
8478 /* read NETCC1 register first */
8479 Netcc1Reg = IP_GPR1->NETCC1;
8480
8481 /* modify the value for NETCC1 */
8482 if ((uint8)NETC_ETHSWT_PORT0 == SwitchPortIdx) /* link 0 */
8483 {
8484 Netcc1Reg |= GPR1_NETCC1_LINK0MIIP(EthSwtPortPhysicalLayerType);
8485 }
8486 else if ((uint8)NETC_ETHSWT_PORT1 == SwitchPortIdx) /* link 1 */
8487 {
8488 Netcc1Reg |= GPR1_NETCC1_LINK1MIIP(EthSwtPortPhysicalLayerType);
8489 }
8490 else
8491 {
8492 /* avoid MISRA violation */
8493 }
8494
8495 /* write it back */
8496 IP_GPR1->NETCC1 = Netcc1Reg;
8497 }
8498
8499 }
8500 #endif
8501
8502 /*FUNCTION**********************************************************************
8503 *
8504 * Function Name : Netc_EthSwt_Ip_ConvertToPtpTime
8505 * Description : Convert 64-bit clock value (ns) to PTP ptpTime (secondsHi,seconds, nanoseconds)
8506 *END**************************************************************************/
8507 static void Netc_EthSwt_Ip_ConvertToPtpTime(const uint64 clk, Netc_EthSwt_Ip_PtpTimeType *ptpTime)
8508 {
8509 uint64 seconds64;
8510
8511 /* convert the ns to seconds */
8512 seconds64 = clk / 1000000000UL;
8513 ptpTime->seconds = (uint32) seconds64;
8514 ptpTime->secondsHi = (uint16) (seconds64 >> 32U);
8515
8516 /* convert the portion that is less than 1s to ns */
8517 ptpTime->nanoseconds = (uint32) (clk - (uint64) (seconds64 * 1000000000UL));
8518
8519 return;
8520 }
8521
8522 /*FUNCTION**********************************************************************
8523 *
8524 * Function Name : Netc_EthSwt_Ip_GetPtpTSClk
8525 * Description : External function for getting current ptpTime of free running (ptpTime stamp) clock.
8526 * implements Netc_EthSwt_Ip_GetPtpTSClk_Activity
8527 *END**************************************************************************/
8528 Std_ReturnType Netc_EthSwt_Ip_GetPtpTSClk( uint8 SwitchIdx, Netc_EthSwt_Ip_PtpTimeType *PtpTime)
8529 {
8530 Std_ReturnType Status = E_OK;
8531 volatile uint64 FreeRunningTicks;
8532 float64 clkFloat;
8533 uint64 clk;
8534
8535 (void)SwitchIdx;
8536
8537 if (TimerOriginalRefClk != 0x0UL)
8538 {
8539 /* Read free running time registers */
8540 FreeRunningTicks = Netc_EthSwt_Ip_TimerBase->TMR_FRT_L; /* should read the Lower register first */
8541 FreeRunningTicks |= ((uint64)(Netc_EthSwt_Ip_TimerBase->TMR_FRT_H)) << NETC_ETHSWT_IP_32BIT_SHIFT;
8542
8543 /* Convert free running ticks to nano seconds */
8544 clkFloat = (float64)FreeRunningTicks * (((float64)1000000000U)/((float64)(TimerOriginalRefClk)));
8545 clk = (uint64)clkFloat;
8546
8547 /* Convert ns time to PTP time */
8548 Netc_EthSwt_Ip_ConvertToPtpTime(clk, PtpTime);
8549 }
8550 else
8551 {
8552 Status = E_NOT_OK; /* 1588 timer is not enabled. */
8553 }
8554
8555 return Status;
8556 }
8557
8558 /*FUNCTION**********************************************************************
8559 *
8560 * Function Name : Netc_EthSwt_Ip_GetPtpClk
8561 * Description : External function for getting current ptpTime of corrected clock (PTP_CLK).
8562 * implements Netc_EthSwt_Ip_GetPtpClk_Activity
8563 *END**************************************************************************/
8564 Std_ReturnType Netc_EthSwt_Ip_GetPtpClk( uint8 SwitchIdx, Netc_EthSwt_Ip_PtpTimeType *PtpTime)
8565 {
8566 Std_ReturnType Status = E_OK;
8567 volatile uint64 FreeRunningTicks;
8568 volatile uint64 CorrectedTime;
8569
8570 (void)SwitchIdx;
8571
8572 if (TimerRefClk != 0x0UL)
8573 {
8574 /* Read Timer synchronous time registers */
8575 FreeRunningTicks = Netc_EthSwt_Ip_TimerBase->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. */
8576 (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. */
8577 CorrectedTime = Netc_EthSwt_Ip_TimerBase->TMR_SRT_L;
8578 CorrectedTime |= (((uint64)(Netc_EthSwt_Ip_TimerBase->TMR_SRT_H)) << NETC_ETHSWT_IP_32BIT_SHIFT);
8579
8580 /* Convert ns time to PTP time */
8581 Netc_EthSwt_Ip_ConvertToPtpTime(CorrectedTime, PtpTime);
8582 }
8583 else
8584 {
8585 Status = E_NOT_OK; /* 1588 timer is not enabled. */
8586 }
8587
8588 return Status;
8589 }
8590
8591 /*FUNCTION**********************************************************************
8592 *
8593 * Function Name : Netc_EthSwt_Ip_GetPtpTimes
8594 * Description : External function for retrieving an atomic snapshot of both clocks in the switch.
8595 * implements Netc_EthSwt_Ip_GetPtpTimes_Activity
8596 *END**************************************************************************/
8597 Std_ReturnType Netc_EthSwt_Ip_GetPtpTimes( uint8 SwitchIdx, Netc_EthSwt_Ip_PtpTimeType *FreeRunTime, Netc_EthSwt_Ip_PtpTimeType *CorrTime)
8598 {
8599 Std_ReturnType Status = E_OK;
8600 volatile uint64 FreeRunningTicks;
8601 volatile uint64 CorrectedTime;
8602 float64 clkFloat;
8603 uint64 clk;
8604
8605 (void)SwitchIdx;
8606
8607 if (TimerRefClk != 0x0UL)
8608 {
8609 /* 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. */
8610 FreeRunningTicks = Netc_EthSwt_Ip_TimerBase->TMR_FRT_L;
8611 FreeRunningTicks |= ((uint64)(Netc_EthSwt_Ip_TimerBase->TMR_FRT_H)) << NETC_ETHSWT_IP_32BIT_SHIFT;
8612 CorrectedTime = Netc_EthSwt_Ip_TimerBase->TMR_SRT_L;
8613 CorrectedTime |= ((uint64)(Netc_EthSwt_Ip_TimerBase->TMR_SRT_H)) << NETC_ETHSWT_IP_32BIT_SHIFT;
8614
8615 /* Convert free running ticks to nano seconds */
8616 clkFloat = (float64)FreeRunningTicks * (((float64)1000000000U)/((float64)(TimerOriginalRefClk)));
8617 clk = (uint64)clkFloat;
8618
8619 /* Convert free running ns time to PTP time */
8620 Netc_EthSwt_Ip_ConvertToPtpTime(clk, FreeRunTime);
8621
8622 /* Convert synced ns time to PTP time */
8623 Netc_EthSwt_Ip_ConvertToPtpTime(CorrectedTime, CorrTime);
8624 }
8625 else
8626 {
8627 Status = E_NOT_OK; /* 1588 timer is not enabled. */
8628 }
8629
8630 return Status;
8631 }
8632
8633 /*FUNCTION**********************************************************************
8634 *
8635 * Function Name : Netc_EthSwt_Ip_SetPtpClkRatio
8636 * Description : External function for adjusting the clock rate of the PTP clock.
8637 * implements Netc_EthSwt_Ip_SetPtpClkRatio_Activity
8638 *END**************************************************************************/
8639 Std_ReturnType Netc_EthSwt_Ip_SetPtpClkRatio( uint8 SwitchIdx, uint32 ClkRatio )
8640 {
8641 Std_ReturnType Status = E_OK;
8642 float64 ConvertedClkRatio;
8643 uint16 TimerClkPeriod;
8644 float64 ClkAddendData;
8645 uint32 TimerClkAddend;
8646 float64 TimerClkAddendRaw;
8647 uint32 TimerClkAddendRawInt;
8648 uint32 IntegerPortion;
8649 float64 FractionalPortion;
8650 uint32 ClkRatioTemp;
8651 float64 TimerRefClkFloat;
8652
8653 (void)SwitchIdx;
8654 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_02();
8655 if (TimerRefClk != 0x0UL)
8656 {
8657 /* convert uint32 ClkRatio to a float */
8658 IntegerPortion = (uint32)((ClkRatio & 0x80000000U) >> 31U);
8659 ClkRatioTemp = ClkRatio & 0x7FFFFFFFUL;
8660 FractionalPortion = (float64)ClkRatioTemp/(float64)0x80000000UL;
8661 ConvertedClkRatio = (float64)((float64)IntegerPortion + FractionalPortion);
8662
8663 /* modify the clock frequency */
8664 TimerRefClkFloat = ((float64)TimerRefClk) * (ConvertedClkRatio * (((float64)TimerOriginalRefClk)/((float64)(TimerRefClk))));
8665 TimerRefClk = ((uint32)TimerRefClkFloat);
8666
8667 TimerClkPeriod = (uint16)(1000000000UL / TimerRefClk); /* the integer portion of timer clock period (1/f) */
8668 ClkAddendData = (((float64)1000000000UL) / ((float64)TimerRefClk)) - ((float64)TimerClkPeriod);
8669 TimerClkAddendRaw = (float64)(0x100000000UL) * ClkAddendData;
8670 TimerClkAddendRawInt = (uint32)TimerClkAddendRaw;
8671 TimerClkAddend = TimerClkAddendRawInt + ((TimerClkAddendRaw > (float64)TimerClkAddendRawInt) ? 1U : 0U); /* the fractional part of the timer clock period. */
8672
8673 /* Timer addend register holds the fractional part of the timer clock period */
8674 Netc_EthSwt_Ip_TimerBase->TMR_ADD = TMR0_BASE_TMR_ADD_ADDEND(TimerClkAddend);
8675
8676 uint32 TMR_CTRL_temp = Netc_EthSwt_Ip_TimerBase->TMR_CTRL;
8677 /* clear CLK_PERIOD data field first */
8678 TMR_CTRL_temp &= ~TMR0_BASE_TMR_CTRL_TCLK_PERIOD(0x3FF);
8679 /* set new period */
8680 TMR_CTRL_temp |= TMR0_BASE_TMR_CTRL_TCLK_PERIOD(TimerClkPeriod);
8681 Netc_EthSwt_Ip_TimerBase->TMR_CTRL = TMR_CTRL_temp;
8682 }
8683 else
8684 {
8685 Status = E_NOT_OK; /* 1588 timer is not enabled. */
8686 }
8687 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_02();
8688
8689 return Status;
8690 }
8691
8692
8693 /*FUNCTION**********************************************************************
8694 *
8695 * Function Name : Netc_EthSwt_Ip_CorrectPtpClk
8696 * Description : External function for adding/subtracting an offset to/from the corrected clock (PTP_CLK).
8697 * implements Netc_EthSwt_Ip_CorrectPtpClk_Activity
8698 *END**************************************************************************/
8699 Std_ReturnType Netc_EthSwt_Ip_CorrectPtpClk( uint8 SwitchIdx, sint64 Offset )
8700 {
8701 Std_ReturnType Status = E_OK;
8702 uint64 OriginOffset;
8703 uint64 NewOffset;
8704
8705 (void)SwitchIdx;
8706
8707 /* get the existing offset first */
8708 OriginOffset = Netc_EthSwt_Ip_TimerBase->TMROFF_L;
8709 OriginOffset |= (uint64)(Netc_EthSwt_Ip_TimerBase->TMROFF_H) << NETC_ETHSWT_IP_32BIT_SHIFT;
8710
8711 /* modify the offset */
8712 NewOffset = OriginOffset + ((uint64) (Offset)); /* the offset could be positive or negative */
8713
8714 /* write the new offset back */
8715 Netc_EthSwt_Ip_TimerBase->TMROFF_L = (uint32)NewOffset;
8716 Netc_EthSwt_Ip_TimerBase->TMROFF_H = (uint32)(NewOffset >> NETC_ETHSWT_IP_32BIT_SHIFT);
8717
8718 return Status;
8719 }
8720
8721
8722 /*FUNCTION**********************************************************************
8723 *
8724 * Function Name : Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntry
8725 * Description : Ethernet Switch Add or Update rate policer table entry function.Netc_EthSwt_Ip_ConvertToPtpTime
8726 *
8727 *END**************************************************************************/
8728 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntry( uint8 SwitchIdx,
8729 Netc_EthSwt_Ip_CommandsType Cmd,
8730 uint32 *MatchedEntries,
8731 const Netc_EthSwt_Ip_RatePolicerEntryDataType * RatePolicerTableEntry
8732 )
8733 {
8734 Netc_EthSwt_Ip_CBDRStatusType status;
8735 uint32 ActionsData;
8736
8737 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8738 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8739 DevAssert(RatePolicerTableEntry != NULL_PTR);
8740 DevAssert(MatchedEntries != NULL_PTR);
8741 #endif
8742
8743 /* clear the variable MatchedEntries first */
8744 *MatchedEntries = 0U;
8745
8746 /* only support Add and Update commands */
8747 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
8748 {
8749 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
8750 }
8751 else
8752 {
8753 /* set table version and CFGEU, FEEU, ... flag */
8754 ActionsData = Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntryGetActionsData(RatePolicerTableEntry);
8755
8756 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_03();
8757 Netc_EthSwt_Ip_AddOrUpdateRatePolicerTableEntryInitTableRequest(RatePolicerTableEntry, ActionsData);
8758 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_03();
8759
8760 /* fill in operation data for config field of Request Header*/
8761 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8762 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8763 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_RATE_POLICER_TABLE_ID;
8764 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
8765 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
8766 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_RATEPOLICERTABLE_REQBUFFER_LEN);
8767 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
8768
8769 /* send command */
8770 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
8771 #if defined(ERR_IPV_NETC_051243)
8772 #if (STD_ON == ERR_IPV_NETC_051243)
8773 /* Error code 0x8A is not a real error. check it on Errata. */
8774 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
8775 {
8776 #endif
8777 #else
8778 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
8779 {
8780 #endif
8781 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
8782 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8783 }
8784 }
8785
8786 return status;
8787 }
8788
8789 /*FUNCTION**********************************************************************
8790 *
8791 * Function Name : Netc_EthSwt_Ip_QueryRatePolicerTableEntry
8792 * Description : Ethernet Switch query Rate policer table entry function.
8793 *
8794 *END**************************************************************************/
8795 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryRatePolicerTableEntry( uint8 SwitchIdx,
8796 uint32 *MatchedEntries,
8797 uint32 RatePolicerEntryId,
8798 Netc_EthSwt_Ip_RatePolicerEntryRspDataType * RatePolicerTableEntry
8799 )
8800 {
8801 Netc_EthSwt_Ip_CBDRStatusType status;
8802 uint32 ActionsData;
8803
8804 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8805 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8806 DevAssert(MatchedEntries != NULL_PTR);
8807 DevAssert(RatePolicerTableEntry != NULL_PTR);
8808 #endif
8809
8810 /* clear the variable MatchedEntries first */
8811 *MatchedEntries = 0U;
8812
8813 /* always do the full query. 0x0 = Full query. */
8814 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
8815 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
8816
8817 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_13();
8818 /* ------initialize the table request data buffer------ */
8819 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
8820 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = RatePolicerEntryId; /* fill in Entry_ID field (Access Key) */
8821 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_13();
8822
8823 /* fill in operation data for config field of Request Header*/
8824 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8825 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8826 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_RATE_POLICER_TABLE_ID;
8827 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for query command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
8828 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
8829 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
8830 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_RATEPOLICERTABLE_RSPBUFFER_LEN); /* set response data buffer length */
8831
8832 /* send command */
8833 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
8834 #if defined(ERR_IPV_NETC_051243)
8835 #if (STD_ON == ERR_IPV_NETC_051243)
8836 /* Error code 0x8A is not a real error. check it on Errata. */
8837 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
8838 {
8839 #endif
8840 #else
8841 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
8842 {
8843 #endif
8844 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
8845 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8846
8847 /* found a matched entry */
8848 if (1U == *MatchedEntries)
8849 {
8850 Netc_EthSwt_Ip_QueryRatePolicerTableEntry_FoundAMatchedEntry(RatePolicerTableEntry);
8851 }
8852 }
8853
8854 return status;
8855 }
8856
8857 /*FUNCTION**********************************************************************
8858 *
8859 * Function Name : Netc_EthSwt_Ip_DeleteRatePolicerTableEntry
8860 * Description : Ethernet Switch delete Rate policer table entry function.
8861 *
8862 *END**************************************************************************/
8863 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteRatePolicerTableEntry( uint8 SwitchIdx,
8864 uint32 *MatchedEntries,
8865 uint32 RatePolicerEntryId
8866 )
8867 {
8868 Netc_EthSwt_Ip_CBDRStatusType status;
8869 uint32 ActionsData = 0U;
8870
8871 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8872 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8873 DevAssert(MatchedEntries != NULL_PTR);
8874 #endif
8875
8876 /* clear the variable MatchedEntries first */
8877 *MatchedEntries = 0U;
8878 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_14();
8879 /* ------initialize the table request data buffer------ */
8880 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
8881 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = RatePolicerEntryId; /* fill in Entry_ID field (Access Key) */
8882 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_14();
8883
8884 /* fill in operation data for config field of Request Header*/
8885 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8886 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8887 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_RATE_POLICER_TABLE_ID;
8888 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
8889 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
8890 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
8891 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN); /* set response data buffer with normal length */
8892
8893 /* send the "Delete" command */
8894 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
8895 #if defined(ERR_IPV_NETC_051243)
8896 #if (STD_ON == ERR_IPV_NETC_051243)
8897 /* Error code 0x8A is not a real error. check it on Errata. */
8898 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
8899 #else
8900 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
8901 #endif
8902 #else
8903 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
8904 #endif
8905 {
8906 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
8907 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
8908 }
8909
8910 return status;
8911 }
8912
8913 /*FUNCTION**********************************************************************
8914 *
8915 * Function Name : Netc_EthSwt_Ip_AddOrUpdateIngressStreamTableEntry
8916 * Description : Ethernet Switch Add or Update ingress stream table entry function.
8917 * implements Netc_EthSwt_Ip_AddOrUpdateIngressStreamTableEntry_Activity
8918 *END**************************************************************************/
8919 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateIngressStreamTableEntry( uint8 SwitchIdx,
8920 Netc_EthSwt_Ip_CommandsType Cmd,
8921 uint32 *MatchedEntries,
8922 const Netc_EthSwt_Ip_IngressStreamEntryDataType * IngressStreamTableEntry
8923 )
8924 {
8925 Netc_EthSwt_Ip_CBDRStatusType status;
8926 uint32 ActionsData;
8927
8928 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
8929 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
8930 DevAssert(IngressStreamTableEntry != NULL_PTR);
8931 DevAssert(MatchedEntries != NULL_PTR);
8932 #endif
8933
8934 /* clear the variable MatchedEntries first */
8935 *MatchedEntries = 0U;
8936
8937 /* only support Add and Update commands */
8938 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
8939 {
8940 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
8941 }
8942 else
8943 {
8944 /* set table version and CFGEU flag */
8945 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U) \
8946 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
8947
8948 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_15();
8949 /* ------initialize the table request data buffer------ */
8950 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
8951 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamTableEntry->IngressStreamEntryId; /* fill in Entry_ID field (Access Key) */
8952 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SFE((IngressStreamTableEntry->IngressStreamCfgeData.StreamFilteringEnable) ? 1U : 0U) \
8953 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IPV(IngressStreamTableEntry->IngressStreamCfgeData.InternalPriorityValue) \
8954 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OIPV((IngressStreamTableEntry->IngressStreamCfgeData.OverrideIPV) ? 1U : 0U) \
8955 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_DR(IngressStreamTableEntry->IngressStreamCfgeData.DropResilience) \
8956 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ODR((IngressStreamTableEntry->IngressStreamCfgeData.OverrideDR) ? 1U : 0U) \
8957 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IMIRE((IngressStreamTableEntry->IngressStreamCfgeData.IngressMirroringEnable) ? 1U : 0U) \
8958 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_TIMECAPE((IngressStreamTableEntry->IngressStreamCfgeData.TimeStampCaptureEnable) ? 1U : 0U) \
8959 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SPPD((IngressStreamTableEntry->IngressStreamCfgeData.SrcPortPruningDisable) ? 1U : 0U) \
8960 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ISQA(IngressStreamTableEntry->IngressStreamCfgeData.IngressSeqAction) \
8961 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_ORP((IngressStreamTableEntry->IngressStreamCfgeData.OverrideRatePolicerInstanceEID) ? 1U : 0U) \
8962 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OSGI((IngressStreamTableEntry->IngressStreamCfgeData.OverrideStreamGateInstanceEID) ? 1U : 0U) \
8963 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_HR(IngressStreamTableEntry->IngressStreamCfgeData.HostReason) \
8964 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_FA(IngressStreamTableEntry->IngressStreamCfgeData.ForwardingActions) \
8965 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SDUTYPE(IngressStreamTableEntry->IngressStreamCfgeData.SduType);
8966 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_MSDU(IngressStreamTableEntry->IngressStreamCfgeData.MaximumServiceDataUnit) \
8967 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_IFMELENCHG(IngressStreamTableEntry->IngressStreamCfgeData.IngressFrmModiEntryFrmLenChange) \
8968 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_EPORT(IngressStreamTableEntry->IngressStreamCfgeData.EgressPort) \
8969 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_OETEID(IngressStreamTableEntry->IngressStreamCfgeData.OverrideET_EID) \
8970 | NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_CTD(IngressStreamTableEntry->IngressStreamCfgeData.CutThrDisable);
8971 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = IngressStreamTableEntry->IngressStreamCfgeData.IngressSeqGeneration_EID;
8972 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = IngressStreamTableEntry->IngressStreamCfgeData.RatePolicer_EID;
8973 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = IngressStreamTableEntry->IngressStreamCfgeData.StreamGateInstance_EID;
8974 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA5] = IngressStreamTableEntry->IngressStreamCfgeData.IngressFrmModification_EID;
8975 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA6] = IngressStreamTableEntry->IngressStreamCfgeData.EgressTreatment_EID;
8976 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA7] = IngressStreamTableEntry->IngressStreamCfgeData.IngressStreamCounter_EID;
8977 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA8] = NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_EGRESSPORTMAP(IngressStreamTableEntry->IngressStreamCfgeData.EgressPortBitMap);
8978 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA9] = NETC_ETHSWT_IP_INGRESSSTREAMTABLE_CFGE_SIMAP(IngressStreamTableEntry->IngressStreamCfgeData.StationInterfaceMap);
8979 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_15();
8980
8981 /* fill in operation data for config field of Request Header*/
8982 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
8983 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
8984 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_TABLE_ID;
8985 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
8986 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
8987 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_INGRESSSTREAMTABLE_REQBUFFER_LEN);
8988 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
8989
8990 /* send command */
8991 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
8992 #if defined(ERR_IPV_NETC_051243)
8993 #if (STD_ON == ERR_IPV_NETC_051243)
8994 /* Error code 0x8A is not a real error. check it on Errata. */
8995 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
8996 {
8997 #endif
8998 #else
8999 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9000 {
9001 #endif
9002 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9003 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9004 }
9005 }
9006
9007 return status;
9008 }
9009
9010 /*FUNCTION**********************************************************************
9011 *
9012 * Function Name : Netc_EthSwt_Ip_QueryIngressStreamTableEntry
9013 * Description : Ethernet Switch query Ingress Stream table entry function.
9014 * implements Netc_EthSwt_Ip_QueryIngressStreamTableEntry_Activity
9015 *END**************************************************************************/
9016 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngressStreamTableEntry( uint8 SwitchIdx,
9017 uint32 *MatchedEntries,
9018 uint32 IngressStreamEntryId,
9019 Netc_EthSwt_Ip_IngressStreamEntryDataType * IngressStreamTableEntry
9020 )
9021 {
9022 Netc_EthSwt_Ip_CBDRStatusType status;
9023 uint32 ActionsData;
9024
9025 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9026 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9027 DevAssert(MatchedEntries != NULL_PTR);
9028 DevAssert(IngressStreamTableEntry != NULL_PTR);
9029 #endif
9030
9031 /* clear the variable MatchedEntries first */
9032 *MatchedEntries = 0U;
9033
9034 /* always do the full query. 0x0 = Full query. */
9035 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
9036 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9037
9038 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_16();
9039 /* ------initialize the table request data buffer------ */
9040 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9041 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamEntryId; /* fill in Entry_ID field (Access Key) */
9042 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_16();
9043
9044 /* fill in operation data for config field of Request Header*/
9045 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9046 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9047 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_TABLE_ID;
9048 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for query command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
9049 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
9050 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
9051 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_INGRESSSTREAMTABLE_RSPBUFFER_LEN); /* set response data buffer length */
9052
9053 /* send command */
9054 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9055 #if defined(ERR_IPV_NETC_051243)
9056 #if (STD_ON == ERR_IPV_NETC_051243)
9057 /* Error code 0x8A is not a real error. check it on Errata. */
9058 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9059 {
9060 #endif
9061 #else
9062 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9063 {
9064 #endif
9065 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9066 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9067
9068 /* found a matched entry */
9069 if (1U == *MatchedEntries)
9070 {
9071 Netc_EthSwt_Ip_QueryIngressStreamTableEntry_FoundAMatchedEntry(IngressStreamTableEntry);
9072 }
9073 }
9074
9075 return status;
9076 }
9077
9078 /*FUNCTION**********************************************************************
9079 *
9080 * Function Name : Netc_EthSwt_Ip_DeleteIngressStreamTableEntry
9081 * Description : Ethernet Switch delete Ingress Stream table entry function.
9082 * implements Netc_EthSwt_Ip_DeleteIngressStreamTableEntry_Activity
9083 *END**************************************************************************/
9084 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngressStreamTableEntry( uint8 SwitchIdx,
9085 uint32 *MatchedEntries,
9086 uint32 IngressStreamEntryId
9087 )
9088 {
9089 Netc_EthSwt_Ip_CBDRStatusType status;
9090 uint32 ActionsData = 0U;
9091
9092 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9093 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9094 DevAssert(MatchedEntries != NULL_PTR);
9095 #endif
9096
9097 /* clear the variable MatchedEntries first */
9098 *MatchedEntries = 0U;
9099 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_17();
9100 /* ------initialize the table request data buffer------ */
9101 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
9102 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamEntryId; /* fill in Entry_ID field (Access Key) */
9103 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_17();
9104
9105 /* fill in operation data for config field of Request Header*/
9106 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9107 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9108 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_TABLE_ID;
9109 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
9110 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
9111 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
9112 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN); /* set response data buffer with normal length */
9113
9114 /* send the "Delete" command */
9115 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9116 #if defined(ERR_IPV_NETC_051243)
9117 #if (STD_ON == ERR_IPV_NETC_051243)
9118 /* Error code 0x8A is not a real error. check it on Errata. */
9119 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9120 #else
9121 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9122 #endif
9123 #else
9124 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9125 #endif
9126 {
9127 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9128 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9129 }
9130
9131 return status;
9132 }
9133
9134 /*FUNCTION**********************************************************************
9135 *
9136 * Function Name : Netc_EthSwt_Ip_AddOrUpdateIngressStreamCountTableEntry
9137 * Description : Ethernet Switch Add or Update ingress stream count table entry function.
9138 * implements Netc_EthSwt_Ip_AddOrUpdateIngressStreamCountTableEntry_Activity
9139 *END**************************************************************************/
9140 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateIngressStreamCountTableEntry( uint8 SwitchIdx,
9141 Netc_EthSwt_Ip_CommandsType Cmd,
9142 uint32 *MatchedEntries,
9143 uint32 IngressStreamCountId
9144 )
9145 {
9146 Netc_EthSwt_Ip_CBDRStatusType status;
9147 uint32 ActionsData;
9148
9149 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9150 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9151 DevAssert(MatchedEntries != NULL_PTR);
9152 #endif
9153
9154 /* clear the variable MatchedEntries first */
9155 *MatchedEntries = 0U;
9156
9157 /* only support Add and Update commands */
9158 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
9159 {
9160 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
9161 }
9162 else
9163 {
9164 /* set table version and CFGEU flag */
9165 ActionsData = NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD_STSEU(1U) \
9166 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9167
9168 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_18();
9169 /* ------initialize the table request data buffer------ */
9170 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9171 /* fill in KEYE_DATA */
9172 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACCESSKEY_FIELD] = IngressStreamCountId; /* fill in ISC_ID field */
9173 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_18();
9174
9175 /* fill in operation data for config field of Request Header*/
9176 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9177 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9178 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_COUNT_TABLE_ID;
9179 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
9180 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
9181 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
9182 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN);
9183 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISCTABLE_RSPBUFFER_LEN);
9184
9185 /* send command */
9186 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9187 #if defined(ERR_IPV_NETC_051243)
9188 #if (STD_ON == ERR_IPV_NETC_051243)
9189 /* Error code 0x8A is not a real error. check it on Errata. */
9190 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9191 {
9192 #endif
9193 #else
9194 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9195 {
9196 #endif
9197 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9198 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9199 }
9200 }
9201
9202 return status;
9203 }
9204
9205 /*FUNCTION**********************************************************************
9206 *
9207 * Function Name : Netc_EthSwt_Ip_QueryIngressStreamCountTableEntry
9208 * Description : Ethernet Switch query Ingress Stream Count table entry function.
9209 * implements Netc_EthSwt_Ip_QueryIngressStreamCountTableEntry_Activity
9210 *END**************************************************************************/
9211 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngressStreamCountTableEntry( uint8 SwitchIdx,
9212 uint32 *MatchedEntries,
9213 uint32 IngressStreamCountEntryId,
9214 Netc_EthSwt_Ip_IngressStreamCountTableRspDataType * IngressStreamCountTableEntry
9215 )
9216 {
9217 Netc_EthSwt_Ip_CBDRStatusType status;
9218 uint32 ActionsData;
9219
9220 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9221 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9222 DevAssert(MatchedEntries != NULL_PTR);
9223 DevAssert(IngressStreamCountTableEntry != NULL_PTR);
9224 #endif
9225
9226 /* clear the variable MatchedEntries first */
9227 *MatchedEntries = 0U;
9228
9229 /* always do the full query. 0x0 = Full query. */
9230 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
9231 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9232
9233 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_19();
9234 /* ------initialize the table request data buffer------ */
9235 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9236 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACCESSKEY_FIELD] = IngressStreamCountEntryId; /* fill in Entry_ID field (Access Key) */
9237 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_19();
9238
9239 /* fill in operation data for config field of Request Header*/
9240 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9241 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9242 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_COUNT_TABLE_ID;
9243 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for query command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
9244 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
9245 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
9246 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISCTABLE_RSPBUFFER_LEN); /* set response data buffer length */
9247
9248 /* send command */
9249 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9250 #if defined(ERR_IPV_NETC_051243)
9251 #if (STD_ON == ERR_IPV_NETC_051243)
9252 /* Error code 0x8A is not a real error. check it on Errata. */
9253 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9254 {
9255 #endif
9256 #else
9257 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9258 {
9259 #endif
9260 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9261 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9262
9263 /* found a matched entry */
9264 if (1U == *MatchedEntries)
9265 {
9266 /* fill in "Netc_EthSwt_Ip_RatePolicerEntryDataType" structure with data in response data buffer */
9267 IngressStreamCountTableEntry->IngressStreamCountId = TableDataBuffer.TableDataField[0U];
9268 /* fill in STSE data */
9269 IngressStreamCountTableEntry->IngressStreamCountStseData.RxCount = TableDataBuffer.TableDataField[1U];
9270 IngressStreamCountTableEntry->IngressStreamCountStseData.MSduDropCount = TableDataBuffer.TableDataField[3U];
9271 IngressStreamCountTableEntry->IngressStreamCountStseData.PolicerDropCount = TableDataBuffer.TableDataField[5U];
9272 IngressStreamCountTableEntry->IngressStreamCountStseData.StreamGateDropCount = TableDataBuffer.TableDataField[7U];
9273 }
9274 }
9275
9276 return status;
9277 }
9278
9279 /*FUNCTION**********************************************************************
9280 *
9281 * Function Name : Netc_EthSwt_Ip_DeleteIngressStreamCountTableEntry
9282 * Description : Ethernet Switch delete Ingress Stream table entry function.
9283 * implements Netc_EthSwt_Ip_DeleteIngressStreamCountTableEntry_Activity
9284 *END**************************************************************************/
9285 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngressStreamCountTableEntry( uint8 SwitchIdx,
9286 uint32 *MatchedEntries,
9287 uint32 IngressStreamCountId
9288 )
9289 {
9290 Netc_EthSwt_Ip_CBDRStatusType status;
9291 uint32 ActionsData = 0U;
9292
9293 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9294 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9295 DevAssert(MatchedEntries != NULL_PTR);
9296 #endif
9297
9298 /* clear the variable MatchedEntries first */
9299 *MatchedEntries = 0U;
9300 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_20();
9301 /* ------initialize the table request data buffer------ */
9302 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
9303 /* fill in KEYE_DATA field */
9304 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_INGRESSCOUNTTABLE_REQFMT_ACCESSKEY_FIELD] = IngressStreamCountId;
9305 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_20();
9306 /* fill in operation data for config field of Request Header*/
9307 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9308 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9309 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_COUNT_TABLE_ID;
9310 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
9311 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
9312 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
9313 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISCTABLE_RSPBUFFER_LEN); /* set response data buffer with normal length */
9314
9315 /* send the "Delete" command */
9316 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9317 #if defined(ERR_IPV_NETC_051243)
9318 #if (STD_ON == ERR_IPV_NETC_051243)
9319 /* Error code 0x8A is not a real error. check it on Errata. */
9320 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9321 #else
9322 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9323 #endif
9324 #else
9325 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9326 #endif
9327 {
9328 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9329 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9330 }
9331
9332 return status;
9333 }
9334
9335 /*FUNCTION**********************************************************************
9336 *
9337 * Function Name : Netc_EthSwt_Ip_AddOrUpdateIngressStreamFilterTableEntry
9338 * Description : Ethernet Switch Add or Update ingress stream filter table entry function.
9339 * implements Netc_EthSwt_Ip_AddOrUpdateIngressStreamFilterTableEntry_Activity
9340 *END**************************************************************************/
9341 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateIngressStreamFilterTableEntry( uint8 SwitchIdx,
9342 Netc_EthSwt_Ip_CommandsType Cmd,
9343 uint32 *MatchedEntries,
9344 const Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry
9345 )
9346 {
9347 Netc_EthSwt_Ip_CBDRStatusType status;
9348 uint32 ActionsData;
9349
9350 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9351 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9352 DevAssert(IngressStreamFilterTableEntry != NULL_PTR);
9353 DevAssert(MatchedEntries != NULL_PTR);
9354 #endif
9355
9356 /* clear the variable MatchedEntries first */
9357 *MatchedEntries = 0U;
9358
9359 /* only support Add and Update commands */
9360 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
9361 {
9362 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
9363 }
9364 else
9365 {
9366 /* set table version and CFGEU flag */
9367 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U) \
9368 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9369 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_21();
9370 /* ------initialize the table request data buffer------ */
9371 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9372 /* fill in KEYE_DATA */
9373 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.IngressStream_EID; /* fill in IS_EID field */
9374 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.Pcp; /* fill in PCP field */
9375 /* fill in CFGE_DATA */
9376 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV(IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.InternalPriorityValue) \
9377 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideIPV) ? 1U : 0U) \
9378 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR(IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.DropResilience) \
9379 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideDR) ? 1U : 0U) \
9380 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressMirroringEnable) ? 1U : 0U) \
9381 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.TimeStampCaptureEnable) ? 1U : 0U) \
9382 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideRatePolicerInstanceEID) ? 1U : 0U) \
9383 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI((IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.OverrideStreamGateInstanceEID) ? 1U : 0U) \
9384 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE(IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.SduType) \
9385 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD(IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.CutThrDisable) \
9386 | NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU(IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.MaximumServiceDataUnit);
9387 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.RatePolicer_EID;
9388 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.StreamGateInstance_EID;
9389 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = IngressStreamFilterTableEntry->IngressStreamFilterCfgeData.IngressStreamCounter_EID;
9390 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_21();
9391
9392 /* fill in operation data for config field of Request Header*/
9393 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9394 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9395 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_FILTER_TABLE_ID;
9396 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH */
9397 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
9398 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
9399 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_REQBUFFER_LEN);
9400 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
9401
9402 /* send command */
9403 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9404 #if defined(ERR_IPV_NETC_051243)
9405 #if (STD_ON == ERR_IPV_NETC_051243)
9406 /* Error code 0x8A is not a real error. check it on Errata. */
9407 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9408 #else
9409 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9410 #endif
9411 #else
9412 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9413 #endif
9414 {
9415 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9416 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9417 }
9418
9419 }
9420
9421 return status;
9422 }
9423
9424 /*FUNCTION**********************************************************************
9425 *
9426 * Function Name : Netc_EthSwt_Ip_QueryIngressStreamFilterTableEntry
9427 * Description : Ethernet Switch query Ingress Stream Filter table entry function.
9428 * implements Netc_EthSwt_Ip_QueryIngressStreamFilterTableEntry_Activity
9429 *END**************************************************************************/
9430 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngressStreamFilterTableEntry( uint8 SwitchIdx,
9431 uint32 *MatchedEntries,
9432 Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry
9433 )
9434 {
9435 Netc_EthSwt_Ip_CBDRStatusType status;
9436 uint32 ActionsData;
9437
9438 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9439 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9440 DevAssert(MatchedEntries != NULL_PTR);
9441 DevAssert(IngressStreamFilterTableEntry != NULL_PTR);
9442 #endif
9443 /* clear the variable MatchedEntries first */
9444 *MatchedEntries = 0U;
9445
9446 /* always do the full query. 0x0 = Full query. */
9447 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
9448 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9449
9450 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_22();
9451 /* ------initialize the table request data buffer------ */
9452 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9453 /* fill in KEYE_DATA field */
9454 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.IngressStream_EID;
9455 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.Pcp;
9456 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_22();
9457
9458 /* fill in operation data for config field of Request Header*/
9459 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9460 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9461 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_FILTER_TABLE_ID;
9462 /* for query function, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
9463 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
9464 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
9465 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_OTHER_REQBUFFER_LEN); /* set request data buffer length */
9466 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_RSPBUFFER_LEN); /* set response data buffer length */
9467
9468 /* send command */
9469 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9470 #if defined(ERR_IPV_NETC_051243)
9471 #if (STD_ON == ERR_IPV_NETC_051243)
9472 /* Error code 0x8A is not a real error. check it on Errata. */
9473 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9474 {
9475 #endif
9476 #else
9477 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9478 {
9479 #endif
9480 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9481 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9482
9483 /* found a matched entry */
9484 if (1U == *MatchedEntries)
9485 {
9486 Netc_EthSwt_Ip_QueryIngressStreamFilterTableEntry_FoundAMatchedEntry(IngressStreamFilterTableEntry);
9487 }
9488 }
9489
9490 return status;
9491 }
9492
9493 /*FUNCTION**********************************************************************
9494 *
9495 * Function Name : Netc_EthSwt_Ip_DeleteIngressStreamFilterTableEntry
9496 * Description : Ethernet Switch delete Ingress Stream table entry function.
9497 * implements Netc_EthSwt_Ip_DeleteIngressStreamFilterTableEntry_Activity
9498 *END**************************************************************************/
9499 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngressStreamFilterTableEntry( uint8 SwitchIdx,
9500 uint32 *MatchedEntries,
9501 const Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry
9502 )
9503 {
9504 Netc_EthSwt_Ip_CBDRStatusType status;
9505 uint32 ActionsData = 0U;
9506
9507 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9508 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9509 DevAssert(MatchedEntries != NULL_PTR);
9510 DevAssert(IngressStreamFilterTableEntry != NULL_PTR);
9511 #endif
9512
9513 /* clear the variable MatchedEntries first */
9514 *MatchedEntries = 0U;
9515 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_23();
9516 /* ------initialize the table request data buffer------ */
9517 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
9518 /* fill in KEYE_DATA field */
9519 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.IngressStream_EID;
9520 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = IngressStreamFilterTableEntry->IngressStreamFilterKeyeData.Pcp;
9521 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_23();
9522
9523 /* fill in operation data for config field of Request Header*/
9524 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9525 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9526 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_FILTER_TABLE_ID;
9527 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH; /* for delete command, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
9528 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
9529 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_OTHER_REQBUFFER_LEN); /* set request data buffer length */
9530 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN); /* set response data buffer with normal length */
9531
9532 /* send the "Delete" command */
9533 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9534 #if defined(ERR_IPV_NETC_051243)
9535 #if (STD_ON == ERR_IPV_NETC_051243)
9536 /* Error code 0x8A is not a real error. check it on Errata. */
9537 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9538 #else
9539 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9540 #endif
9541 #else
9542 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9543 #endif
9544 {
9545 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9546 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9547 }
9548
9549 return status;
9550 }
9551
9552 /*FUNCTION**********************************************************************
9553 *
9554 * Function Name : Netc_EthSwt_Ip_SearchIngressStreamFilterTableEntry
9555 * Description : Ethernet Switch search Ingress Stream Filter table entry one by one.
9556 * implements Netc_EthSwt_Ip_SearchIngressStreamFilterTableEntry_Activity
9557 *END**************************************************************************/
9558 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_SearchIngressStreamFilterTableEntry( uint8 SwitchIdx,
9559 uint32 * ResumeEntryId,
9560 uint32 * MatchedEntry,
9561 Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry
9562 )
9563 {
9564 Netc_EthSwt_Ip_CBDRStatusType status;
9565 uint32 ActionsData;
9566
9567 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9568 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9569 DevAssert(ResumeEntryId != NULL_PTR);
9570 DevAssert(MatchedEntry != NULL_PTR);
9571 DevAssert(IngressStreamFilterTableEntry != NULL_PTR);
9572 #endif
9573
9574 /* clear the variable MatchedEntry first */
9575 *MatchedEntry = 0U;
9576
9577 /* always do the full query. 0x0 = Full query. */
9578 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
9579 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9580
9581 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_24();
9582 /* ------initialize the table request data buffer------ */
9583 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9584 /* fill in KEYE_DATA field */
9585 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = *ResumeEntryId;
9586 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_24();
9587
9588 /* fill in operation data for config field of Request Header*/
9589 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9590 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9591 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_FILTER_TABLE_ID;
9592 /* query function with NETC_ETHSWT_SEARCH_METHOD method */
9593 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
9594 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
9595 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_OTHER_REQBUFFER_LEN); /* set request data buffer length */
9596 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_RSPBUFFER_LEN); /* set response data buffer length */
9597
9598 /* send command */
9599 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9600 #if defined(ERR_IPV_NETC_051243)
9601 #if (STD_ON == ERR_IPV_NETC_051243)
9602 /* Error code 0x8A is not a real error. check it on Errata. */
9603 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9604 {
9605 #endif
9606 #else
9607 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9608 {
9609 #endif
9610 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9611 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntry);
9612
9613 /* found a matched entry */
9614 if (1U == *MatchedEntry)
9615 {
9616 Netc_EthSwt_Ip_SearchIngressStreamFilterTableEntry_FoundAMatchedEntry(ResumeEntryId, IngressStreamFilterTableEntry);
9617 }
9618 }
9619
9620 return status;
9621 }
9622
9623 /*FUNCTION**********************************************************************
9624 *
9625 * Function Name : Netc_EthSwt_Ip_SearchAndFillIngressStreamFilterTable
9626 * Description : inline function for searching and filling Ingress Stream Filter table entries.
9627 *END**************************************************************************/
9628 static inline Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_SearchAndFillIngressStreamFilterTable( uint8 SwitchIdx,
9629 uint32 * ResumeEntryId,
9630 uint16 * NumOfExistingEntry,
9631 Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableEntry
9632 )
9633 {
9634 Netc_EthSwt_Ip_CBDRStatusType status;
9635 uint32 ActionsData;
9636 uint32 CfgeConfigBits;
9637 uint8 SduType;
9638 uint32 MatchedEntries = 0x0UL;
9639
9640 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9641 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9642 DevAssert(ResumeEntryId != NULL_PTR);
9643 DevAssert(IngressStreamFilterTableEntry != NULL_PTR);
9644 #endif
9645
9646 /* always do the full query. 0x0 = Full query. */
9647 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
9648 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9649
9650 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_25();
9651
9652 /* ------initialize the table request data buffer------ */
9653 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9654 /* fill in KEYE_DATA field */
9655 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = *ResumeEntryId;
9656 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_25();
9657
9658 /* fill in operation data for config field of Request Header*/
9659 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9660 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9661 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_FILTER_TABLE_ID;
9662 /* query function with NETC_ETHSWT_SEARCH_METHOD method */
9663 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
9664 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
9665 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_OTHER_REQBUFFER_LEN); /* set request data buffer length */
9666 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISFILTERTABLE_RSPBUFFER_LEN); /* set response data buffer length */
9667
9668 /* send command */
9669 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9670 #if defined(ERR_IPV_NETC_051243)
9671 #if (STD_ON == ERR_IPV_NETC_051243)
9672 /* Error code 0x8A is not a real error. check it on Errata. */
9673 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9674 {
9675 #endif
9676 #else
9677 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9678 {
9679 #endif
9680 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9681 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &MatchedEntries);
9682
9683 /* get the resume_entry_id and be ready for the next query operation */
9684 *ResumeEntryId = TableDataBuffer.TableDataField[0U];
9685
9686 /* ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED */
9687 /* found a matched entry */
9688 if ((1U == MatchedEntries) && (*ResumeEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
9689 {
9690 /* fill in "Netc_EthSwt_Ip_IngressStreamFilterEntryDataType" structure with data in response data buffer */
9691 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterEntryId = TableDataBuffer.TableDataField[1U];
9692 /* fill in KEYE_DATA */
9693 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterKeyeData.IngressStream_EID = TableDataBuffer.TableDataField[2U];
9694 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterKeyeData.Pcp = (uint8)(TableDataBuffer.TableDataField[3U] & NETC_ETHSWT_IP_ISFILTERTABLE_KEYE_PCP_MASK);
9695 /* fill in CFGE data */
9696 CfgeConfigBits = TableDataBuffer.TableDataField[4U];
9697 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.InternalPriorityValue = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IPV_SHIFT);
9698 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.OverrideIPV = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OIPV_SHIFT) > 0U) ? TRUE : FALSE;
9699 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.DropResilience = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_DR_SHIFT);
9700 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.OverrideDR = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ODR_SHIFT) > 0U) ? TRUE : FALSE;
9701 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.IngressMirroringEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_IMIRE_SHIFT) > 0U) ? TRUE : FALSE;
9702 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.TimeStampCaptureEnable = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_TIMECAPE_SHIFT) > 0U) ? TRUE : FALSE;
9703 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.OverrideRatePolicerInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_ORP_SHIFT) > 0U) ? TRUE : FALSE;
9704 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.OverrideStreamGateInstanceEID = (((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_OSGI_SHIFT) > 0U) ? TRUE : FALSE;
9705 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.CutThrDisable = (CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_CTD_SHIFT;
9706 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.MaximumServiceDataUnit = (uint16)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_MSDU_SHIFT);
9707
9708 SduType = (uint8)((CfgeConfigBits & NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_MASK) >> NETC_ETHSWT_IP_ISFILTERTABLE_CFGE_SDUTYPE_SHIFT);
9709 switch (SduType)
9710 {
9711 case 0U:
9712 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_PPDU;
9713 break;
9714 case 1U:
9715 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MPDU;
9716 break;
9717 case 2U:
9718 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_MSDU;
9719 break;
9720 default:
9721 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.SduType = NETC_ETHSWT_IP_RSDTYPE;
9722 break;
9723 }
9724
9725 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.RatePolicer_EID = TableDataBuffer.TableDataField[5U];
9726 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.StreamGateInstance_EID = TableDataBuffer.TableDataField[6U];
9727 IngressStreamFilterTableEntry[*NumOfExistingEntry].IngressStreamFilterCfgeData.IngressStreamCounter_EID = TableDataBuffer.TableDataField[7U];
9728
9729 /* increase the NumOfExistingEntry */
9730 (*NumOfExistingEntry) += 1U;
9731 }
9732 }
9733
9734 return status;
9735 }
9736
9737 /*FUNCTION**********************************************************************
9738 *
9739 * Function Name : Netc_EthSwt_Ip_GetIngressStreamFilterTable
9740 * Description : Ethernet Switch get ingress stream filter table function.
9741 * implements Netc_EthSwt_Ip_GetIngressStreamFilterTable_Activity
9742 *END**************************************************************************/
9743 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_GetIngressStreamFilterTable( uint8 SwitchIdx,
9744 uint16 * NumberOfElements,
9745 Netc_EthSwt_Ip_IngressStreamFilterEntryDataType * IngressStreamFilterTableList
9746 )
9747 {
9748 Netc_EthSwt_Ip_CBDRStatusType status = E_OK;
9749 uint16 NumOfExistingEntry = 0U;
9750 uint32 ResumeId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
9751
9752 /* [notes]: we will have to read entries one by one because of the errata ERR051048.
9753 - ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED
9754 - Description: The NUM_MATCHED field in the command NTMP response header may be incorrect when
9755 the search access method is used for the following tables: FDB table 15, L2 IPv4 Multicast
9756 Filter table 16, VLAN Filter table 18, Ingress Stream Identification table 30, or Ingress Stream
9757 Filter table 32.
9758 - Workaround: For the query command, limit the message response buffer size (RESPONSE_LENGTH field in the request header)
9759 so that NETC returns no more than one entry at a time. Under this condition, the NUM_MATCHED field value is correct
9760 */
9761
9762 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9763 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9764 DevAssert(NumberOfElements != NULL_PTR);
9765 DevAssert(*NumberOfElements != 0U);
9766 DevAssert(IngressStreamFilterTableList != NULL_PTR);
9767 #endif
9768
9769 do
9770 {
9771 /* check if the IngressStreamFilterTableList is full or we get all existing entries */
9772 if ((NumOfExistingEntry >= *NumberOfElements) || (status == (uint8)(E_NOT_OK)))
9773 {
9774 break;
9775 }
9776
9777 status = Netc_EthSwt_Ip_SearchAndFillIngressStreamFilterTable(SwitchIdx, &ResumeId, &NumOfExistingEntry, IngressStreamFilterTableList);
9778
9779 } while (ResumeId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID); /* ResumeId == NETC_ETHSWT_IP_BD_NULL_ENTRY_ID means the query operation is completed */
9780
9781 /* return the Number of elements which are currently available in the EthSwitch module or number of elements copied to IngressStreamFilterTableList*/
9782 *NumberOfElements = NumOfExistingEntry;
9783
9784 return status;
9785 }
9786
9787 /*FUNCTION**********************************************************************
9788 *
9789 * Function Name : Netc_EthSwt_Ip_AddOrUpdateStreamGateInstanceTableEntry
9790 * Description : Ethernet Switch Add or Update Stream Gate Instance table entry function.
9791 * implements Netc_EthSwt_Ip_AddOrUpdateStreamGateInstanceTableEntry_Activity
9792 *END**************************************************************************/
9793 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateStreamGateInstanceTableEntry( uint8 SwitchIdx,
9794 Netc_EthSwt_Ip_CommandsType Cmd,
9795 uint32 *MatchedEntries,
9796 const Netc_EthSwt_Ip_StreamGateInstanceEntryDataType * StreamGateInstanceTableEntry
9797 )
9798 {
9799 Netc_EthSwt_Ip_CBDRStatusType status;
9800 uint32 ActionsData;
9801
9802 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9803 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9804 DevAssert(StreamGateInstanceTableEntry != NULL_PTR);
9805 DevAssert(MatchedEntries != NULL_PTR);
9806 #endif
9807
9808 /* clear the variable MatchedEntries first */
9809 *MatchedEntries = 0U;
9810
9811 /* only support Add and Update commands */
9812 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
9813 {
9814 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
9815 }
9816 else
9817 {
9818 /* set table version and update actions*/
9819 ActionsData = NETC_ETHSWT_IP_SGITABLE_REQFMT_ACFGEU(1U) \
9820 | NETC_ETHSWT_IP_SGITABLE_REQFMT_CFGEU(1U) \
9821 | NETC_ETHSWT_IP_SGITABLE_REQFMT_SGISEU(1U) \
9822 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9823
9824 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_26();
9825 /* ------initialize the table request data buffer------ */
9826 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9827 /* fill in KEYE_DATA */
9828 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = StreamGateInstanceTableEntry->SGIEntryId; /* fill in Entry_ID */
9829 /* fill in ACFGE_DATA */
9830 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = StreamGateInstanceTableEntry->AdminSGCLEntryId;
9831 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = (uint32)(StreamGateInstanceTableEntry->AdminBaseTime & 0xFFFFFFFFUL);
9832 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = (uint32)(StreamGateInstanceTableEntry->AdminBaseTime >> NETC_ETHSWT_IP_32BIT_SHIFT);
9833 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA3] = StreamGateInstanceTableEntry->AdminCycleTimeExt;
9834 /* fill in CFGE_DATA and ICFGE_DATA */
9835 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = (NETC_ETHSWT_IP_SGITABLE_CFGE_OEXEN(StreamGateInstanceTableEntry->Cfge_Oexen ? 1U : 0U) \
9836 | NETC_ETHSWT_IP_SGITABLE_CFGE_IRXEN(StreamGateInstanceTableEntry->Cfge_Irxen ? 1U : 0U) \
9837 | NETC_ETHSWT_IP_SGITABLE_CFGE_SDUTYPE(StreamGateInstanceTableEntry->SduType) \
9838 | (NETC_ETHSWT_IP_SGITABLE_ICFGE_IPV(StreamGateInstanceTableEntry->Icfge_Ipv) << NETC_ETHSWT_IP_8BIT_SHIFT) \
9839 | (NETC_ETHSWT_IP_SGITABLE_ICFGE_OIPV(StreamGateInstanceTableEntry->Icfge_Oipv ? 1U : 0U) << NETC_ETHSWT_IP_8BIT_SHIFT) \
9840 | (NETC_ETHSWT_IP_SGITABLE_ICFGE_GST(StreamGateInstanceTableEntry->Icfge_Gst) << NETC_ETHSWT_IP_8BIT_SHIFT) \
9841 | (NETC_ETHSWT_IP_SGITABLE_ICFGE_CTD(StreamGateInstanceTableEntry->Icfge_Ctd ? 1U : 0U) << NETC_ETHSWT_IP_8BIT_SHIFT)) & 0xFFFFU;
9842 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_26();
9843
9844 /* fill in operation data for config field of Request Header*/
9845 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9846 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9847 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_INSTANCE_TABLE_ID;
9848 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
9849 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
9850 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
9851 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_SGITABLE_REQBUFFER_LEN);
9852 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
9853
9854 /* send command */
9855 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9856 #if defined(ERR_IPV_NETC_051243)
9857 #if (STD_ON == ERR_IPV_NETC_051243)
9858 /* Error code 0x8A is not a real error. check it on Errata. */
9859 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9860 {
9861 #endif
9862 #else
9863 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9864 {
9865 #endif
9866 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9867 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9868 }
9869 }
9870
9871 return status;
9872 }
9873
9874 /*FUNCTION**********************************************************************
9875 *
9876 * Function Name : Netc_EthSwt_Ip_QueryStreamGateInstanceTableEntry
9877 * Description : Ethernet Switch query Ingress Stream Filter table entry function.
9878 * implements Netc_EthSwt_Ip_QueryStreamGateInstanceTableEntry_Activity
9879 *END**************************************************************************/
9880 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryStreamGateInstanceTableEntry( uint8 SwitchIdx,
9881 uint32 *MatchedEntries,
9882 uint32 SGIEntryId,
9883 Netc_EthSwt_Ip_StreamGateInstanceEntryRspDataType * SGITableEntryRspData
9884 )
9885 {
9886 Netc_EthSwt_Ip_CBDRStatusType status;
9887 uint32 ActionsData;
9888 uint32 ConfigBits;
9889 uint8 SduType;
9890
9891 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
9892 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
9893 DevAssert(MatchedEntries != NULL_PTR);
9894 DevAssert(SGITableEntryRspData != NULL_PTR);
9895 #endif
9896
9897 /* clear the variable MatchedEntries first */
9898 *MatchedEntries = 0U;
9899
9900 /* always do the full query. 0x0 = Full query. */
9901 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
9902 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
9903
9904 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_27();
9905 /* ------initialize the table request data buffer------ */
9906 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
9907 /* fill in ACCESS_KEY field */
9908 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = SGIEntryId;
9909 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_27();
9910
9911 /* fill in operation data for config field of Request Header*/
9912 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
9913 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
9914 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_INSTANCE_TABLE_ID;
9915 /* for query function, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
9916 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
9917 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
9918 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
9919 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_SGITABLE_RSPBUFFER_LEN); /* set response data buffer length */
9920
9921 /* send command */
9922 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
9923 #if defined(ERR_IPV_NETC_051243)
9924 #if (STD_ON == ERR_IPV_NETC_051243)
9925 /* Error code 0x8A is not a real error. check it on Errata. */
9926 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
9927 {
9928 #endif
9929 #else
9930 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
9931 {
9932 #endif
9933 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
9934 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
9935
9936 /* found a matched entry */
9937 if (1U == *MatchedEntries)
9938 {
9939 /* fill in "Netc_EthSwt_Ip_StreamGateInstanceEntryRspDataType" structure with data in response data buffer */
9940 SGITableEntryRspData->SGIEntryId = TableDataBuffer.TableDataField[0U];
9941 /* fill in SGISE_DATA */
9942 SGITableEntryRspData->OperationalSGCLEntryID = TableDataBuffer.TableDataField[1U];
9943 SGITableEntryRspData->ConfigChangeTime = ((uint64)(TableDataBuffer.TableDataField[3U]) << NETC_ETHSWT_IP_32BIT_SHIFT);
9944 SGITableEntryRspData->ConfigChangeTime |= (uint64)(TableDataBuffer.TableDataField[2U]);
9945 SGITableEntryRspData->OperationalBaseTime = ((uint64)(TableDataBuffer.TableDataField[5U]) << NETC_ETHSWT_IP_32BIT_SHIFT);
9946 SGITableEntryRspData->OperationalBaseTime |= (uint64)(TableDataBuffer.TableDataField[4U]);
9947 SGITableEntryRspData->OperationalCycleTimeExt = TableDataBuffer.TableDataField[6U];
9948 ConfigBits = TableDataBuffer.TableDataField[7U];
9949 SGITableEntryRspData->SGISEOex = (uint8)(ConfigBits & NETC_ETHSWT_IP_SGITABLE_SGISE_OEX_MASK);
9950 SGITableEntryRspData->SGISEIrx = (uint8)((ConfigBits & NETC_ETHSWT_IP_SGITABLE_SGISE_IRX_MASK) >> NETC_ETHSWT_IP_SGITABLE_SGISE_IRX_SHIFT);
9951 SGITableEntryRspData->SGISEState = (uint8)((ConfigBits & NETC_ETHSWT_IP_SGITABLE_SGISE_STATE_MASK) >> NETC_ETHSWT_IP_SGITABLE_SGISE_STATE_SHIFT);
9952
9953 /* fill in CFGE data */
9954 ConfigBits = TableDataBuffer.TableDataField[7U] >> NETC_ETHSWT_IP_8BIT_SHIFT;
9955 SGITableEntryRspData->Cfge_Oexen = ((ConfigBits & NETC_ETHSWT_IP_SGITABLE_CFGE_OEXEN_MASK) == 0U) ? FALSE : TRUE;
9956 SGITableEntryRspData->Cfge_Irxen = ((ConfigBits & NETC_ETHSWT_IP_SGITABLE_CFGE_IRXEN_MASK) == 0U) ? FALSE : TRUE;
9957 SduType = (uint8)((ConfigBits & NETC_ETHSWT_IP_SGITABLE_CFGE_SDUTYPE_MASK) >> NETC_ETHSWT_IP_SGITABLE_CFGE_SDUTYPE_SHIFT);
9958 switch (SduType)
9959 {
9960 case 0U:
9961 SGITableEntryRspData->SduType = NETC_ETHSWT_IP_PPDU;
9962 break;
9963 case 1U:
9964 SGITableEntryRspData->SduType = NETC_ETHSWT_IP_MPDU;
9965 break;
9966 case 2U:
9967 SGITableEntryRspData->SduType = NETC_ETHSWT_IP_MSDU;
9968 break;
9969 default:
9970 SGITableEntryRspData->SduType = NETC_ETHSWT_IP_RSDTYPE;
9971 break;
9972 }
9973
9974 /* fill in ICFGE data */
9975 ConfigBits = TableDataBuffer.TableDataField[7U] >> NETC_ETHSWT_IP_16BIT_SHIFT;
9976 SGITableEntryRspData->Icfge_Ipv = (uint8)(ConfigBits & NETC_ETHSWT_IP_SGITABLE_ICFGE_IPV_MASK);
9977 SGITableEntryRspData->Icfge_Oipv = ((ConfigBits & NETC_ETHSWT_IP_SGITABLE_ICFGE_OIPV_MASK) == 0U) ? FALSE : TRUE;
9978 SGITableEntryRspData->Icfge_Gst = (ConfigBits & NETC_ETHSWT_IP_SGITABLE_ICFGE_GST_MASK) >> NETC_ETHSWT_IP_SGITABLE_ICFGE_GST_SHIFT;
9979 SGITableEntryRspData->Icfge_Ctd = ((ConfigBits & NETC_ETHSWT_IP_SGITABLE_ICFGE_CTD_MASK) >> NETC_ETHSWT_IP_SGITABLE_ICFGE_CTD_SHIFT)!=0U;
9980
9981 /* fill in ACFGE data */
9982 SGITableEntryRspData->AdminSGCLEntryId = TableDataBuffer.TableDataField[8U];
9983 SGITableEntryRspData->AdminBaseTime = (((uint64)(TableDataBuffer.TableDataField[10U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
9984 SGITableEntryRspData->AdminBaseTime |= (uint64)(TableDataBuffer.TableDataField[9U]);
9985 SGITableEntryRspData->AdminCycleTimeExt = TableDataBuffer.TableDataField[11U];
9986 }
9987 }
9988
9989 return status;
9990 }
9991
9992 /*FUNCTION**********************************************************************
9993 *
9994 * Function Name : Netc_EthSwt_Ip_DeleteStreamGateInstanceTableEntry
9995 * Description : Ethernet Switch delete Stream Gate Instance table entry function.
9996 * implements Netc_EthSwt_Ip_DeleteStreamGateInstanceTableEntry_Activity
9997 *END**************************************************************************/
9998 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteStreamGateInstanceTableEntry( uint8 SwitchIdx,
9999 uint32 *MatchedEntries,
10000 uint32 SGIEntryId
10001 )
10002 {
10003 Netc_EthSwt_Ip_CBDRStatusType status;
10004 uint32 ActionsData = 0U;
10005
10006 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10007 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10008 DevAssert(MatchedEntries != NULL_PTR);
10009 #endif
10010
10011 /* clear the variable MatchedEntries first */
10012 *MatchedEntries = 0U;
10013 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_28();
10014 /* ------initialize the table request data buffer------ */
10015 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
10016 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = SGIEntryId; /* fill in Entry_ID field (Access Key) */
10017 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_28();
10018
10019 /* fill in operation data for config field of Request Header*/
10020 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10021 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10022 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_INSTANCE_TABLE_ID;
10023 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
10024 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
10025 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
10026 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN); /* set response data buffer with normal length */
10027
10028 /* send the "Delete" command */
10029 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10030 #if defined(ERR_IPV_NETC_051243)
10031 #if (STD_ON == ERR_IPV_NETC_051243)
10032 /* Error code 0x8A is not a real error. check it on Errata. */
10033 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10034 #else
10035 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10036 #endif
10037 #else
10038 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10039 #endif
10040 {
10041 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10042 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10043 }
10044
10045 return status;
10046 }
10047
10048 /*FUNCTION**********************************************************************
10049 *
10050 * Function Name : Netc_EthSwt_Ip_AddStreamGateControlListTableEntry
10051 * Description : Ethernet Switch Add Stream Gate Control List table entry function.
10052 * implements Netc_EthSwt_Ip_AddStreamGateControlListTableEntry_Activity
10053 *END**************************************************************************/
10054 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddStreamGateControlListTableEntry( uint8 SwitchIdx,
10055 Netc_EthSwt_Ip_CommandsType Cmd,
10056 uint32 *MatchedEntries,
10057 const Netc_EthSwt_Ip_SGCLTableDataType * SGCLTableEntry
10058 )
10059 {
10060 Netc_EthSwt_Ip_CBDRStatusType status;
10061 uint32 ActionsData;
10062
10063 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10064 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10065 DevAssert(SGCLTableEntry != NULL_PTR);
10066 DevAssert(MatchedEntries != NULL_PTR);
10067 if (SGCLTableEntry->Cfge_ListLength > 0U)
10068 {
10069 DevAssert(SGCLTableEntry->ListEntries != NULL_PTR);
10070 }
10071 #endif
10072
10073 /* clear the variable MatchedEntries first */
10074 *MatchedEntries = 0U;
10075
10076 /* only support Add commands */
10077 if (NETC_ETHSWT_ADD_CMD != Cmd)
10078 {
10079 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
10080 }
10081 else
10082 {
10083 /* set table version*/
10084 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
10085
10086 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_29();
10087 /* ------initialize the table request data buffer------ */
10088 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
10089 /* fill in ACCESS_KEY */
10090 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = SGCLTableEntry->SGCLEntryId; /* fill in Entry_ID */
10091 /* fill in CFGE_DATA */
10092 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = SGCLTableEntry->Cfge_CycleTime;
10093 /* 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 */
10094 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = NETC_ETHSWT_IP_SGCLTABLE_CFGE_LISTLEN((uint8)(SGCLTableEntry->Cfge_ListLength - 1U)) \
10095 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTOIPV((SGCLTableEntry->Cfge_ExtOIPV) ? 1U : 0U) \
10096 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTIPV(SGCLTableEntry->Cfge_ExtIpv) \
10097 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTCTD((SGCLTableEntry->Cfge_ExtCtd) ? 1U : 0U) \
10098 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_EXTGTST(SGCLTableEntry->Cfge_ExtGtst);
10099
10100 /* fill in list entries data */
10101 Netc_EthSwt_Ip_AddStreamGateControlListTableEntry_FillListEntriesData(SGCLTableEntry);
10102 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_29();
10103
10104 /* fill in operation data for config field of Request Header*/
10105 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10106 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10107 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_CTRL_LIST_TABLE_ID;
10108 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
10109 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
10110 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
10111 /* the request and response data buffer length are variable based on the length of control list*/
10112 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (uint16)((uint8)(16U + (8U * SGCLTableEntry->Cfge_ListLength)));
10113 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
10114
10115 /* send command */
10116 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10117 #if defined(ERR_IPV_NETC_051243)
10118 #if (STD_ON == ERR_IPV_NETC_051243)
10119 /* Error code 0x8A is not a real error. check it on Errata. */
10120 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10121 {
10122 #endif
10123 #else
10124 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10125 {
10126 #endif
10127 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10128 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10129 }
10130 }
10131
10132 return status;
10133 }
10134
10135 /*FUNCTION**********************************************************************
10136 *
10137 * Function Name : Netc_EthSwt_Ip_QueryStreamGateControlListTableEntry
10138 * Description : Ethernet Switch query Ingress Stream Control List table entry function.
10139 * implements Netc_EthSwt_Ip_QueryStreamGateControlListTableEntry_Activity
10140 *END**************************************************************************/
10141 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryStreamGateControlListTableEntry( uint8 SwitchIdx,
10142 uint32 *MatchedEntries,
10143 uint32 SGCLEntryId,
10144 uint8 ListLen,
10145 Netc_EthSwt_Ip_SGCLTableDataType * SGCLTableEntryRspData
10146 )
10147 {
10148 Netc_EthSwt_Ip_CBDRStatusType status;
10149 uint32 ActionsData;
10150
10151 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10152 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10153 DevAssert(MatchedEntries != NULL_PTR);
10154 DevAssert(SGCLTableEntryRspData != NULL_PTR);
10155 if (ListLen > 0U)
10156 {
10157 DevAssert(SGCLTableEntryRspData->ListEntries != NULL_PTR);
10158 }
10159 #endif
10160
10161 /* clear the variable MatchedEntries first */
10162 *MatchedEntries = 0U;
10163
10164 /* always do the full query. 0x0 = Full query. */
10165 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
10166 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
10167
10168 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_30();
10169 /* ------initialize the table request data buffer------ */
10170 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
10171 /* fill in ACCESS_KEY field */
10172 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = SGCLEntryId;
10173 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_30();
10174
10175 /* fill in operation data for config field of Request Header*/
10176 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10177 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10178 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_CTRL_LIST_TABLE_ID;
10179 /* for query function, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
10180 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
10181 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
10182 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
10183 Netc_EthSwt_Ip_OperationData.RspBuffLength = (uint16)((uint8)(16U + (8U * ListLen))); /* set response data buffer length */
10184
10185 /* send command */
10186 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10187 #if defined(ERR_IPV_NETC_051243)
10188 #if (STD_ON == ERR_IPV_NETC_051243)
10189 /* Error code 0x8A is not a real error. check it on Errata. */
10190 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10191 {
10192 #endif
10193 #else
10194 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10195 {
10196 #endif
10197 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10198 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10199
10200 /* found a matched entry */
10201 if (1U == *MatchedEntries)
10202 {
10203 Netc_EthSwt_Ip_QueryStreamGateControlListTableEntry_FoundAMatchedEntry(SGCLTableEntryRspData);
10204 }
10205 }
10206
10207 return status;
10208 }
10209
10210 /*FUNCTION**********************************************************************
10211 *
10212 * Function Name : Netc_EthSwt_Ip_DeleteStreamGateControlListTableEntry
10213 * Description : Ethernet Switch delete Stream Gate Instance table entry function.
10214 * implements Netc_EthSwt_Ip_DeleteStreamGateControlListTableEntry_Activity
10215 *END**************************************************************************/
10216 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteStreamGateControlListTableEntry( uint8 SwitchIdx,
10217 uint32 *MatchedEntries,
10218 uint32 SGCLEntryId
10219 )
10220 {
10221 Netc_EthSwt_Ip_CBDRStatusType status;
10222 uint32 ActionsData = 0U;
10223
10224 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10225 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10226 DevAssert(MatchedEntries != NULL_PTR);
10227 #endif
10228
10229 /* clear the variable MatchedEntries first */
10230 *MatchedEntries = 0U;
10231 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_31();
10232 /* ------initialize the table request data buffer------ */
10233 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
10234 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = SGCLEntryId; /* fill in Entry_ID field (Access Key) */
10235 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_31();
10236
10237 /* fill in operation data for config field of Request Header*/
10238 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10239 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10240 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_STREAM_GATE_CTRL_LIST_TABLE_ID;
10241 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
10242 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
10243 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
10244 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN); /* set response data buffer with normal length */
10245
10246 /* send the "Delete" command */
10247 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10248 #if defined(ERR_IPV_NETC_051243)
10249 #if (STD_ON == ERR_IPV_NETC_051243)
10250 /* Error code 0x8A is not a real error. check it on Errata. */
10251 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10252 #else
10253 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10254 #endif
10255 #else
10256 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10257 #endif
10258 {
10259 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10260 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10261 }
10262
10263 return status;
10264 }
10265
10266 /*FUNCTION**********************************************************************
10267 *
10268 * Function Name : Netc_EthSwt_Ip_AddOrUpdateIngressSeqGenerationTableEntry
10269 * Description : Ethernet Switch Add or Update Ingress Sequence Generation table entry function.
10270 * implements Netc_EthSwt_Ip_AddOrUpdateIngressSeqGenerationTableEntry_Activity
10271 *END**************************************************************************/
10272 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateIngressSeqGenerationTableEntry( uint8 SwitchIdx,
10273 Netc_EthSwt_Ip_CommandsType Cmd,
10274 uint32 *MatchedEntries,
10275 const Netc_EthSwt_Ip_ISQGTableDataType * ISQGTableEntry
10276 )
10277 {
10278 Netc_EthSwt_Ip_CBDRStatusType status;
10279 uint32 ActionsData;
10280
10281 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10282 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10283 DevAssert(ISQGTableEntry != NULL_PTR);
10284 DevAssert(MatchedEntries != NULL_PTR);
10285 #endif
10286
10287 /* clear the variable MatchedEntries first */
10288 *MatchedEntries = 0U;
10289
10290 /* only support Add and Update commands */
10291 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
10292 {
10293 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
10294 }
10295 else
10296 {
10297 /* set table version and update actions*/
10298 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U) \
10299 | NETC_ETHSWT_IP_ISQGTABLE_REQFMT_ACTIONS_FIELD_SGSEU(1U) \
10300 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
10301
10302 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_32();
10303 /* ------initialize the table request data buffer------ */
10304 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
10305 /* fill in KEYE_DATA */
10306 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = ISQGTableEntry->ISQGEntryId; /* fill in Entry_ID */
10307 /* fill in ACFGE_DATA */
10308 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = ISQGTableEntry->Cfge_SQTagType;
10309 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_32();
10310
10311 /* fill in operation data for config field of Request Header*/
10312 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10313 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10314 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_SEQ_GENERATION_TABLE_ID;
10315 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
10316 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
10317 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
10318 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISQGTABLE_REQBUFFER_LEN);
10319 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
10320
10321 /* send command */
10322 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10323 #if defined(ERR_IPV_NETC_051243)
10324 #if (STD_ON == ERR_IPV_NETC_051243)
10325 /* Error code 0x8A is not a real error. check it on Errata. */
10326 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10327 {
10328 #endif
10329 #else
10330 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10331 {
10332 #endif
10333 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10334 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10335 }
10336 }
10337
10338 return status;
10339 }
10340
10341 /*FUNCTION**********************************************************************
10342 *
10343 * Function Name : Netc_EthSwt_Ip_QueryIngressSeqGenerationTableEntry
10344 * Description : Ethernet Switch query Ingress Sequence Generation table entry function.
10345 * implements Netc_EthSwt_Ip_QueryIngressSeqGenerationTableEntry_Activity
10346 *END**************************************************************************/
10347 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngressSeqGenerationTableEntry( uint8 SwitchIdx,
10348 uint32 *MatchedEntries,
10349 uint32 ISQGEntryId,
10350 Netc_EthSwt_Ip_ISQGTableDataType * ISQGRspData
10351 )
10352 {
10353 Netc_EthSwt_Ip_CBDRStatusType status;
10354 uint32 ActionsData;
10355 uint32 ConfigBits;
10356
10357 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10358 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10359 DevAssert(MatchedEntries != NULL_PTR);
10360 DevAssert(ISQGRspData != NULL_PTR);
10361 #endif
10362
10363 /* clear the variable MatchedEntries first */
10364 *MatchedEntries = 0U;
10365
10366 /* always do the full query. 0x0 = Full query. */
10367 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
10368 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
10369
10370 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_33();
10371 /* ------initialize the table request data buffer------ */
10372 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
10373 /* fill in ACCESS_KEY field */
10374 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = ISQGEntryId;
10375 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_33();
10376
10377 /* fill in operation data for config field of Request Header*/
10378 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10379 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10380 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_SEQ_GENERATION_TABLE_ID;
10381 /* for query function, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
10382 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
10383 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
10384 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
10385 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISQGTABLE_RSPBUFFER_LEN); /* set response data buffer length */
10386
10387 /* send command */
10388 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10389 #if defined(ERR_IPV_NETC_051243)
10390 #if (STD_ON == ERR_IPV_NETC_051243)
10391 /* Error code 0x8A is not a real error. check it on Errata. */
10392 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10393 {
10394 #endif
10395 #else
10396 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10397 {
10398 #endif
10399 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10400 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10401
10402 /* found a matched entry */
10403 if (1U == *MatchedEntries)
10404 {
10405 /* fill in "Netc_EthSwt_Ip_ISQGTableDataType" structure with data in response data buffer */
10406 ISQGRspData->ISQGEntryId = TableDataBuffer.TableDataField[0U];
10407
10408 /* fill in CFGE data */
10409 ConfigBits = TableDataBuffer.TableDataField[1U];
10410 ISQGRspData->Cfge_SQTagType = (ConfigBits & NETC_ETHSWT_IP_ISQGTABLE_CFGE_SQTAG_MASK);
10411 ISQGRspData->Sgse_SQGNum = (uint16)((ConfigBits >> NETC_ETHSWT_IP_16BIT_SHIFT) & 0xFFFFU);
10412 }
10413 }
10414
10415 return status;
10416 }
10417
10418 /*FUNCTION**********************************************************************
10419 *
10420 * Function Name : Netc_EthSwt_Ip_DeleteIngressSeqGenerationTableEntry
10421 * implements Netc_EthSwt_Ip_DeleteIngressSeqGenerationTableEntry_Activity
10422 *END**************************************************************************/
10423 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngressSeqGenerationTableEntry( uint8 SwitchIdx,
10424 uint32 *MatchedEntries,
10425 uint32 ISQGEntryId
10426 )
10427 {
10428 Netc_EthSwt_Ip_CBDRStatusType status;
10429 uint32 ActionsData = 0U;
10430
10431 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10432 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10433 DevAssert(MatchedEntries != NULL_PTR);
10434 #endif
10435
10436 /* clear the variable MatchedEntries first */
10437 *MatchedEntries = 0U;
10438 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_34();
10439 /* ------initialize the table request data buffer------ */
10440 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* Delete command will ignore ActionsData data field */
10441 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = ISQGEntryId; /* fill in Entry_ID field (Access Key) */
10442 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_34();
10443
10444 /* fill in operation data for config field of Request Header*/
10445 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10446 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10447 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_SEQ_GENERATION_TABLE_ID;
10448 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH; /* for delete command, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
10449 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
10450 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_REQBUFFER_8BYTE_LEN); /* set request data buffer length */
10451 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN); /* set response data buffer with normal length */
10452
10453 /* send the "Delete" command */
10454 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10455 #if defined(ERR_IPV_NETC_051243)
10456 #if (STD_ON == ERR_IPV_NETC_051243)
10457 /* Error code 0x8A is not a real error. check it on Errata. */
10458 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10459 #else
10460 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10461 #endif
10462 #else
10463 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10464 #endif
10465 {
10466 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10467 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10468 }
10469
10470 return status;
10471 }
10472
10473 /*FUNCTION**********************************************************************
10474 *
10475 * Function Name : Netc_EthSwt_Ip_UpdateEgressSeqRecoveryTableEntry
10476 * Description : Ethernet Switch Add or Update Ingress Sequence Generation table entry function.
10477 * implements Netc_EthSwt_Ip_UpdateEgressSeqRecoveryTableEntry_Activity
10478 *END**************************************************************************/
10479 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_UpdateEgressSeqRecoveryTableEntry( uint8 SwitchIdx,
10480 uint32 *MatchedEntries,
10481 const Netc_EthSwt_Ip_EgrSeqRecoveryTableDataType * EgrSQRTableEntry
10482 )
10483 {
10484 Netc_EthSwt_Ip_CBDRStatusType status;
10485 uint32 ActionsData;
10486
10487 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10488 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10489 DevAssert(EgrSQRTableEntry != NULL_PTR);
10490 DevAssert(MatchedEntries != NULL_PTR);
10491 #endif
10492
10493 /* clear the variable MatchedEntries first */
10494 *MatchedEntries = 0U;
10495
10496 /* set table version and update actions*/
10497 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U) \
10498 | NETC_ETHSWT_IP_ESQRTABLE_REQFMT_ACTIONS_FIELD_STSEU(1U) \
10499 | NETC_ETHSWT_IP_ESQRTABLE_REQFMT_ACTIONS_FIELD_SRSEU(1U) \
10500 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
10501 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_35();
10502 /* ------initialize the table request data buffer------ */
10503 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
10504 /* fill in ACCESS_KEY */
10505 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EgrSQRTableEntry->EgrSeqRecEntryId; /* fill in Entry_ID */
10506 /* fill in CFGE_DATA */
10507 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQTAG(EgrSQRTableEntry->Cfge_SQTag) \
10508 | NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTNSQ(EgrSQRTableEntry->Cfge_SqrTnsq) \
10509 | NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRALG(EgrSQRTableEntry->Cfge_SqrAlg) \
10510 | NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTYPE(EgrSQRTableEntry->Cfge_SqrType) \
10511 | NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRHL(EgrSQRTableEntry->Cfge_SQRHisLen) \
10512 | NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRFWL(EgrSQRTableEntry->Cfge_SQRFutureWinLen);
10513 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTP(EgrSQRTableEntry->Cfge_SQRTimeOutPeriod);
10514 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_35();
10515
10516 /* fill in operation data for config field of Request Header*/
10517 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10518 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10519 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_EGRESS_SEQ_RECOVERY_TABLE_ID;
10520 /* for Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
10521 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
10522 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_UPDATE_CMD;
10523 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_EGRSQRTABLE_REQBUFFER_LEN);
10524 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
10525
10526 /* send command */
10527 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10528 #if defined(ERR_IPV_NETC_051243)
10529 #if (STD_ON == ERR_IPV_NETC_051243)
10530 /* Error code 0x8A is not a real error. check it on Errata. */
10531 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10532 #else
10533 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10534 #endif
10535 #else
10536 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10537 #endif
10538 {
10539 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10540 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10541 }
10542
10543 return status;
10544 }
10545
10546 /*FUNCTION**********************************************************************
10547 *
10548 * Function Name : Netc_EthSwt_Ip_QueryEgressSeqRecoveryTableEntry
10549 * Description : Ethernet Switch query Ingress Sequence Generation table entry function.
10550 * implements Netc_EthSwt_Ip_QueryEgressSeqRecoveryTableEntry_Activity
10551 *END**************************************************************************/
10552 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryEgressSeqRecoveryTableEntry( uint8 SwitchIdx,
10553 uint32 *MatchedEntries,
10554 uint32 ESQREntryId,
10555 Netc_EthSwt_Ip_EgrSeqRecoveryTableRspDataType * ESQRRspData
10556 )
10557 {
10558 Netc_EthSwt_Ip_CBDRStatusType status;
10559 uint32 ActionsData;
10560 uint32 ConfigBits;
10561 uint8 HisIdx;
10562
10563 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10564 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10565 DevAssert(MatchedEntries != NULL_PTR);
10566 DevAssert(ESQRRspData != NULL_PTR);
10567 #endif
10568
10569 /* clear the variable MatchedEntries first */
10570 *MatchedEntries = 0U;
10571
10572 /* always do the full query. 0x0 = Full query. */
10573 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
10574 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
10575
10576 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_36();
10577 /* ------initialize the table request data buffer------ */
10578 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
10579 /* fill in ACCESS_KEY field */
10580 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = ESQREntryId;
10581 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_36();
10582
10583 /* fill in operation data for config field of Request Header*/
10584 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10585 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10586 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_EGRESS_SEQ_RECOVERY_TABLE_ID;
10587 /* for query function, always uses NETC_ETHSWT_ENTRY_ID_MATCH method */
10588 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
10589 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
10590 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_EGRSQRTABLE_REQBUFFER_LEN); /* set request data buffer length */
10591 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_EGRSQRTABLE_RSPBUFFER_LEN); /* set response data buffer length */
10592
10593 /* send command */
10594 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10595 #if defined(ERR_IPV_NETC_051243)
10596 #if (STD_ON == ERR_IPV_NETC_051243)
10597 /* Error code 0x8A is not a real error. check it on Errata. */
10598 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10599 {
10600 #endif
10601 #else
10602 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10603 {
10604 #endif
10605 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10606 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10607
10608 /* found a matched entry */
10609 if (1U == *MatchedEntries)
10610 {
10611 /* fill in "Netc_EthSwt_Ip_EgrSeqRecoveryTableRspDataType" structure with data in response data buffer */
10612 ESQRRspData->EgrSeqRecEntryId = TableDataBuffer.TableDataField[0U];
10613
10614 /* fill in STSE_DATA */
10615 ESQRRspData->Stse_InOrderPkts = (((uint64)(TableDataBuffer.TableDataField[2U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
10616 ESQRRspData->Stse_InOrderPkts |= (uint64)(TableDataBuffer.TableDataField[1U]);
10617 ESQRRspData->Stse_OutOfOrderPkts = (((uint64)(TableDataBuffer.TableDataField[4U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
10618 ESQRRspData->Stse_OutOfOrderPkts |= (uint64)(TableDataBuffer.TableDataField[3U]);
10619 ESQRRspData->Stse_RoguePkts = (((uint64)(TableDataBuffer.TableDataField[6U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
10620 ESQRRspData->Stse_RoguePkts |= (uint64)(TableDataBuffer.TableDataField[5U]);
10621 ESQRRspData->Stse_DuplicatePkts = (((uint64)(TableDataBuffer.TableDataField[8U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
10622 ESQRRspData->Stse_DuplicatePkts |= (uint64)(TableDataBuffer.TableDataField[7U]);
10623 ESQRRspData->Stse_LostPkts = (((uint64)(TableDataBuffer.TableDataField[10U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
10624 ESQRRspData->Stse_LostPkts |= (uint64)(TableDataBuffer.TableDataField[9U]);
10625 ESQRRspData->Stse_TaglessPkts = (((uint64)(TableDataBuffer.TableDataField[12U])) << NETC_ETHSWT_IP_32BIT_SHIFT);
10626 ESQRRspData->Stse_TaglessPkts |= (uint64)(TableDataBuffer.TableDataField[11U]);
10627 ESQRRspData->Stse_SeqRecResets = TableDataBuffer.TableDataField[13U];
10628
10629 /* fill in CFGE data */
10630 ConfigBits = TableDataBuffer.TableDataField[14U];
10631 ESQRRspData->Cfge_SQTag = (uint8)(ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQTAG_MASK);
10632 ESQRRspData->Cfge_SqrTnsq = (ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTNSQ_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTNSQ_SHIFT;
10633 ESQRRspData->Cfge_SqrAlg = (ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRALG_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRALG_SHIFT;
10634 ESQRRspData->Cfge_SqrType = (ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTYPE_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTYPE_SHIFT;
10635 ESQRRspData->Cfge_SQRHisLen = (uint8)((ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRHL_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRHL_SHIFT);
10636 ESQRRspData->Cfge_SQRFutureWinLen = (uint16)((ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRFWL_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRFWL_SHIFT);
10637 ESQRRspData->Cfge_SQRTimeOutPeriod = (uint16)(TableDataBuffer.TableDataField[15U] & NETC_ETHSWT_IP_EGRSQRTABLE_CFGE_SQRTP_MASK);
10638
10639 /* fill in SRSE data */
10640 ConfigBits = TableDataBuffer.TableDataField[16U];
10641 ESQRRspData->Srse_SqrNum = (uint16)(ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_SQRNUM_MASK);
10642 ESQRRspData->Srse_TakeAny = (uint8)((ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_TAKEANY_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_TAKEANY_SHIFT);
10643 ESQRRspData->Srse_LostCntEnable = ((ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_LCE_MASK) == 0U) ? FALSE : TRUE;
10644 ESQRRspData->Srse_SqrTimeStamp = (uint16)((ConfigBits & NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_SQRTS_MASK) >> NETC_ETHSWT_IP_EGRSQRTABLE_SRSE_SQRTS_SHIFT);
10645
10646 for (HisIdx = 0U; HisIdx < 4U; HisIdx++)
10647 {
10648 ESQRRspData->Srse_SqrHistory[HisIdx] = TableDataBuffer.TableDataField[17U + HisIdx];
10649 }
10650 }
10651 }
10652
10653 return status;
10654 }
10655
10656 /*FUNCTION**********************************************************************
10657 *
10658 * Function Name : Netc_EthSwt_Ip_AddOrUpdateIngrStreamIdentificationTableEntry
10659 * Description : Ethernet Switch Add or Update Ingress Stream Identification table entry function.
10660 * implements Netc_EthSwt_Ip_AddOrUpdateIngrStreamIdentificationTableEntry_Activity
10661 *END**************************************************************************/
10662 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_AddOrUpdateIngrStreamIdentificationTableEntry( uint8 SwitchIdx,
10663 Netc_EthSwt_Ip_CommandsType Cmd,
10664 uint32 *MatchedEntries,
10665 const Netc_EthSwt_Ip_IngrStremIdentificationTableDataType * ISITableEntry
10666 )
10667 {
10668 Netc_EthSwt_Ip_CBDRStatusType status;
10669 uint32 ActionsData;
10670 uint8 FrmKeyIdx;
10671
10672 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10673 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10674 DevAssert(ISITableEntry != NULL_PTR);
10675 DevAssert(MatchedEntries != NULL_PTR);
10676 #endif
10677
10678 /* clear the variable MatchedEntries first */
10679 *MatchedEntries = 0U;
10680
10681 /* only support Add and Update commands */
10682 if ((NETC_ETHSWT_ADD_CMD != Cmd) && (NETC_ETHSWT_UPDATE_CMD != Cmd))
10683 {
10684 status = NETC_ETHSWT_IP_CBDRSTATUS_INVALID_CMD; /* not supported command */
10685 }
10686 else
10687 {
10688 /* set table version and update actions*/
10689 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_CFGEU(1U) \
10690 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
10691
10692 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_37();
10693 /* ------initialize the table request data buffer------ */
10694 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
10695 /* fill in KEYE_DATA */
10696 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = NETC_ETHSWT_IP_ISITABLE_KEYE_KEYTYPE(ISITableEntry->Keye_Keytype) \
10697 | NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID(ISITableEntry->Keye_SrcPortId) \
10698 | NETC_ETHSWT_IP_ISITABLE_KEYE_SPM(ISITableEntry->Keye_Spm);
10699 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_37();
10700
10701 for (FrmKeyIdx = 0U; FrmKeyIdx < 4U; FrmKeyIdx++)
10702 {
10703 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0 + FrmKeyIdx] = ISITableEntry->Keye_FrmKey[FrmKeyIdx]; /* [Ricky]TODO: need to check the data format, big endian */
10704 }
10705 /* fill in CFGE_DATA */
10706 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA4] = ISITableEntry->IngrStreamEntryId; /* IS_EID */
10707
10708 /* fill in operation data for config field of Request Header*/
10709 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10710 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10711 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_IDEN_TABLE_ID;
10712 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH */
10713 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
10714 Netc_EthSwt_Ip_OperationData.Cmd = Cmd;
10715 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISITABLE_ADD_REQBUFFER_LEN);
10716 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN);
10717
10718 /* send command */
10719 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10720 #if defined(ERR_IPV_NETC_051243)
10721 #if (STD_ON == ERR_IPV_NETC_051243)
10722 /* Error code 0x8A is not a real error. check it on Errata. */
10723 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10724 {
10725 #endif
10726 #else
10727 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10728 {
10729 #endif
10730 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10731 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10732 }
10733 }
10734
10735 return status;
10736 }
10737
10738 /*FUNCTION**********************************************************************
10739 *
10740 * Function Name : Netc_EthSwt_Ip_QueryIngrStreamIdentificationTableEntry
10741 * Description : Ethernet Switch query Ingress Stream Identification table entry function.
10742 * implements Netc_EthSwt_Ip_QueryIngrStreamIdentificationTableEntry_Activity
10743 *END**************************************************************************/
10744 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_QueryIngrStreamIdentificationTableEntry( uint8 SwitchIdx,
10745 uint32 *MatchedEntries,
10746 Netc_EthSwt_Ip_IngrStremIdentificationTableDataType * ISITableEntry
10747 )
10748 {
10749 Netc_EthSwt_Ip_CBDRStatusType status;
10750 uint32 ActionsData;
10751 uint32 ConfigBits;
10752 uint8 FrmKeyIdx;
10753
10754 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10755 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10756 DevAssert(MatchedEntries != NULL_PTR);
10757 DevAssert(ISITableEntry != NULL_PTR);
10758 #endif
10759
10760 /* clear the variable MatchedEntries first */
10761 *MatchedEntries = 0U;
10762
10763 /* always do the full query. 0x0 = Full query. */
10764 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
10765 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
10766
10767 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_38();
10768 /* ------initialize the table request data buffer------ */
10769 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
10770 /* fill in KEYE_DATA */
10771 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = NETC_ETHSWT_IP_ISITABLE_KEYE_KEYTYPE(ISITableEntry->Keye_Keytype) \
10772 | NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID(ISITableEntry->Keye_SrcPortId) \
10773 | NETC_ETHSWT_IP_ISITABLE_KEYE_SPM(ISITableEntry->Keye_Spm);
10774 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_38();
10775
10776 for (FrmKeyIdx = 0U; FrmKeyIdx < 4U; FrmKeyIdx++)
10777 {
10778 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0 + FrmKeyIdx] = ISITableEntry->Keye_FrmKey[FrmKeyIdx]; /* [Ricky]TODO: need to check the data format, big endian */
10779 }
10780
10781 /* fill in operation data for config field of Request Header*/
10782 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10783 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10784 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_IDEN_TABLE_ID;
10785 /* for query function, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
10786 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
10787 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
10788 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISITABLE_QUERY_REQBUFFER_LEN); /* set request data buffer length */
10789 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISITABLE_RSQBUFFER_LEN); /* set response data buffer length */
10790
10791 /* send command */
10792 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10793 #if defined(ERR_IPV_NETC_051243)
10794 #if (STD_ON == ERR_IPV_NETC_051243)
10795 /* Error code 0x8A is not a real error. check it on Errata. */
10796 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10797 {
10798 #endif
10799 #else
10800 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10801 {
10802 #endif
10803 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10804 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10805
10806 /* found a matched entry */
10807 if (1U == *MatchedEntries)
10808 {
10809 /* fill in "Netc_EthSwt_Ip_IngrStremIdentificationTableDataType" structure with data in response data buffer */
10810 ISITableEntry->IngrStreamIdenEntryId = TableDataBuffer.TableDataField[1U];
10811
10812 /* fill in KEYE data */
10813 ConfigBits = TableDataBuffer.TableDataField[2U];
10814 ISITableEntry->Keye_Keytype = (ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_KEYTYPE_MASK);
10815 ISITableEntry->Keye_SrcPortId = (uint8)((ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID_MASK) >> NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID_SHIFT);
10816 ISITableEntry->Keye_Spm = (ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_SPM_MASK) >> NETC_ETHSWT_IP_ISITABLE_KEYE_SPM_SHIFT;
10817
10818 for (FrmKeyIdx = 0U; FrmKeyIdx < 4U; FrmKeyIdx++)
10819 {
10820 ISITableEntry->Keye_FrmKey[FrmKeyIdx] = TableDataBuffer.TableDataField[3U + FrmKeyIdx];
10821 }
10822
10823 /* fill in CFGE data */
10824 ISITableEntry->IngrStreamEntryId = TableDataBuffer.TableDataField[7U];
10825 }
10826 }
10827
10828 return status;
10829 }
10830
10831 /*FUNCTION**********************************************************************
10832 *
10833 * Function Name : Netc_EthSwt_Ip_DeleteIngrStreamIdentificationTableEntry
10834 * Description : Ethernet Switch delete Ingress Stream Identification table entry function.
10835 * implements Netc_EthSwt_Ip_DeleteIngrStreamIdentificationTableEntry_Activity
10836 *END**************************************************************************/
10837 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_DeleteIngrStreamIdentificationTableEntry( uint8 SwitchIdx,
10838 uint32 *MatchedEntries,
10839 const Netc_EthSwt_Ip_IngrStremIdentificationTableDataType * ISITableEntry
10840 )
10841 {
10842 Netc_EthSwt_Ip_CBDRStatusType status;
10843 uint32 ActionsData = 0U;
10844 uint8 FrmKeyIdx;
10845
10846 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10847 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10848 DevAssert(MatchedEntries != NULL_PTR);
10849 DevAssert(ISITableEntry != NULL_PTR);
10850 #endif
10851
10852 /* clear the variable MatchedEntries first */
10853 *MatchedEntries = 0U;
10854
10855 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_39();
10856 /* ------initialize the table request data buffer------ */
10857 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
10858 /* fill in KEYE_DATA */
10859 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = NETC_ETHSWT_IP_ISITABLE_KEYE_KEYTYPE(ISITableEntry->Keye_Keytype) \
10860 | NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID(ISITableEntry->Keye_SrcPortId) \
10861 | NETC_ETHSWT_IP_ISITABLE_KEYE_SPM(ISITableEntry->Keye_Spm);
10862 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_39();
10863
10864 for (FrmKeyIdx = 0U; FrmKeyIdx < 4U; FrmKeyIdx++)
10865 {
10866 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0 + FrmKeyIdx] = ISITableEntry->Keye_FrmKey[FrmKeyIdx]; /* [Ricky]TODO: need to check the data format, big endian */
10867 }
10868
10869 /* fill in operation data for config field of Request Header*/
10870 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10871 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10872 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_IDEN_TABLE_ID;
10873 /* for query function, always uses NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH method */
10874 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_EXACT_MATCH_KEY_ELEMENT_MATCH;
10875 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_DELETE_CMD;
10876 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISITABLE_QUERY_REQBUFFER_LEN); /* set request data buffer length */
10877 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_4BYTE_LEN); /* set response data buffer length */
10878
10879 /* send command */
10880 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10881 #if defined(ERR_IPV_NETC_051243)
10882 #if (STD_ON == ERR_IPV_NETC_051243)
10883 /* Error code 0x8A is not a real error. check it on Errata. */
10884 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10885 #else
10886 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10887 #endif
10888 #else
10889 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10890 #endif
10891 {
10892 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10893 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
10894 }
10895
10896 return status;
10897 }
10898
10899 /*FUNCTION**********************************************************************
10900 *
10901 * Function Name : Netc_EthSwt_Ip_SearchAndFillIngrStreamIdentificationTable
10902 * Description : inline function for searching and filling Ingress Stream Filter table entries.
10903 *END**************************************************************************/
10904 static inline Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_SearchAndFillIngrStreamIdentificationTable( uint8 SwitchIdx,
10905 uint32 * ResumeEntryId,
10906 uint16 * NumOfExistingEntry,
10907 Netc_EthSwt_Ip_IngrStremIdentificationTableDataType * ISITableEntry
10908 )
10909 {
10910 Netc_EthSwt_Ip_CBDRStatusType status;
10911 uint32 ActionsData;
10912 uint32 ConfigBits;
10913 uint32 MatchedEntries = 0x0UL;
10914 uint8 FrmKeyIdx;
10915 uint8 TableMemIdx;
10916
10917 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
10918 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
10919 DevAssert(ResumeEntryId != NULL_PTR);
10920 DevAssert(ISITableEntry != NULL_PTR);
10921 #endif
10922
10923 /* always do the full query. 0x0 = Full query. */
10924 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_QUERY_ACTIONS(NETC_ETHSWT_TABLES_FULL_QUERY) \
10925 | NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
10926
10927 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_40();
10928 /* ------initialize the table request data buffer------ */
10929 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
10930 /* fill in KEYE_DATA field */
10931 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = *ResumeEntryId;
10932 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_40();
10933
10934 /* clear the memory for searching, otherwise will get 0x89 error code */
10935 for (TableMemIdx = 0U; TableMemIdx < 6U; TableMemIdx++)
10936 {
10937 TableDataBuffer.TableDataField[(uint8)NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0 + TableMemIdx] = 0U;
10938 }
10939
10940 /* fill in operation data for config field of Request Header*/
10941 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
10942 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
10943 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_INGRESS_STREAM_IDEN_TABLE_ID;
10944 /* query function with NETC_ETHSWT_SEARCH_METHOD method */
10945 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_SEARCH_METHOD;
10946 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_QUERY_CMD;
10947 Netc_EthSwt_Ip_OperationData.ReqBuffLength = (NETC_ETHSWT_IP_ISITABLE_QUERY_REQBUFFER_LEN); /* set request data buffer length */
10948 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_ISITABLE_RSQBUFFER_LEN); /* set response data buffer length */
10949
10950 /* send command */
10951 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
10952 #if defined(ERR_IPV_NETC_051243)
10953 #if (STD_ON == ERR_IPV_NETC_051243)
10954 /* Error code 0x8A is not a real error. check it on Errata. */
10955 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
10956 {
10957 #endif
10958 #else
10959 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
10960 {
10961 #endif
10962 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
10963 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, &MatchedEntries);
10964
10965 /* get the resume_entry_id and be ready for the next query operation */
10966 *ResumeEntryId = TableDataBuffer.TableDataField[0U];
10967
10968 /* ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED */
10969 /* found a matched entry */
10970 if ((1U == MatchedEntries) && (*ResumeEntryId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID))
10971 {
10972 /* fill in "Netc_EthSwt_Ip_IngrStremIdentificationTableDataType" structure with data in response data buffer */
10973 ISITableEntry[*NumOfExistingEntry].IngrStreamIdenEntryId = TableDataBuffer.TableDataField[1U];
10974
10975 /* fill in KEYE data */
10976 ConfigBits = TableDataBuffer.TableDataField[2U];
10977 ISITableEntry[*NumOfExistingEntry].Keye_Keytype = (ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_KEYTYPE_MASK);
10978 ISITableEntry[*NumOfExistingEntry].Keye_SrcPortId = (uint8)((ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID_MASK) >> NETC_ETHSWT_IP_ISITABLE_KEYE_SRCPORTID_SHIFT);
10979 ISITableEntry[*NumOfExistingEntry].Keye_Spm = (ConfigBits & NETC_ETHSWT_IP_ISITABLE_KEYE_SPM_MASK) >> NETC_ETHSWT_IP_ISITABLE_KEYE_SPM_SHIFT;
10980
10981 for (FrmKeyIdx = 0U; FrmKeyIdx < 4U; FrmKeyIdx++)
10982 {
10983 ISITableEntry[*NumOfExistingEntry].Keye_FrmKey[FrmKeyIdx] = TableDataBuffer.TableDataField[3U + FrmKeyIdx];
10984 }
10985
10986 /* fill in CFGE data */
10987 ISITableEntry[*NumOfExistingEntry].IngrStreamEntryId = TableDataBuffer.TableDataField[7U];
10988
10989 /* increase the NumOfExistingEntry */
10990 (*NumOfExistingEntry) += 1U;
10991 }
10992 }
10993
10994 return status;
10995 }
10996
10997 /*FUNCTION**********************************************************************
10998 *
10999 * Function Name : Netc_EthSwt_Ip_GetIngrStreamIdentificationTable
11000 * Description : Ethernet Switch get ingress stream filter table function.
11001 * implements Netc_EthSwt_Ip_GetIngrStreamIdentificationTable_Activity
11002 *END**************************************************************************/
11003 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_GetIngrStreamIdentificationTable( uint8 SwitchIdx,
11004 uint16 * NumberOfElements,
11005 Netc_EthSwt_Ip_IngrStremIdentificationTableDataType * ISITableList
11006 )
11007 {
11008 Netc_EthSwt_Ip_CBDRStatusType status = E_OK;
11009 uint16 NumOfExistingEntry = 0U;
11010 uint32 ResumeId = NETC_ETHSWT_IP_BD_NULL_ENTRY_ID;
11011
11012 /* [notes]: we will have to read entries one by one because of the errata ERR051048.
11013 - ERR051048: NETC: Management command with search action responds with incorrect NUM_MATCHED
11014 - Description: The NUM_MATCHED field in the command NTMP response header may be incorrect when
11015 the search access method is used for the following tables: FDB table 15, L2 IPv4 Multicast
11016 Filter table 16, VLAN Filter table 18, Ingress Stream Identification table 30, or Ingress Stream
11017 Filter table 32.
11018 - Workaround: For the query command, limit the message response buffer size (RESPONSE_LENGTH field in the request header)
11019 so that NETC returns no more than one entry at a time. Under this condition, the NUM_MATCHED field value is correct
11020 */
11021
11022 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
11023 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
11024 DevAssert(NumberOfElements != NULL_PTR);
11025 DevAssert(*NumberOfElements != 0U);
11026 DevAssert(ISITableList != NULL_PTR);
11027 #endif
11028
11029 do
11030 {
11031 /* check if the ISITableList is full or we get all existing entries */
11032 if ((NumOfExistingEntry >= *NumberOfElements) || (status == (uint8)(E_NOT_OK)))
11033 {
11034 break;
11035 }
11036
11037 status = Netc_EthSwt_Ip_SearchAndFillIngrStreamIdentificationTable(SwitchIdx, &ResumeId, &NumOfExistingEntry, ISITableList);
11038
11039 } while (ResumeId != NETC_ETHSWT_IP_BD_NULL_ENTRY_ID); /* ResumeId == NETC_ETHSWT_IP_BD_NULL_ENTRY_ID means the query operation is completed */
11040
11041 /* return the Number of elements which are currently available in the EthSwitch module or number of elements copied to ISITableList*/
11042 *NumberOfElements = NumOfExistingEntry;
11043
11044 return status;
11045 }
11046
11047 /*FUNCTION**********************************************************************
11048 *
11049 * Function Name : Netc_EthSwt_Ip_UpdateEgressSchedulerTableEntry
11050 * Description : Ethernet Switch Update Egress Class Scheduler table entry function.
11051 * implements Netc_EthSwt_Ip_UpdateEgressSchedulerTableEntry_Activity
11052 *END**************************************************************************/
11053 Netc_EthSwt_Ip_CBDRStatusType Netc_EthSwt_Ip_UpdateEgressSchedulerTableEntry( uint8 SwitchIdx,
11054 uint32 EntryId,
11055 uint32 *MatchedEntries,
11056 const Netc_EthSwt_Ip_PortSchedulerType * SchedulerTableEntry
11057 )
11058 {
11059 Netc_EthSwt_Ip_CBDRStatusType status;
11060 uint32 ActionsData;
11061
11062 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
11063 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
11064 DevAssert(SchedulerTableEntry != NULL_PTR);
11065 DevAssert(MatchedEntries != NULL_PTR);
11066 DevAssert((EntryId > 0U) && (EntryId < NETC_ETHSWT_IP_NUMBER_OF_PORTS));
11067 #endif
11068
11069 /* clear the variable MatchedEntries first */
11070 *MatchedEntries = 0U;
11071
11072 /* set table version*/
11073 ActionsData = NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD_TABLE_VERSIONS(0U);
11074 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_41();
11075
11076 /* ------initialize the table request data buffer------ */
11077 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ACTIONS_FIELD] = ActionsData; /* fill in Actions field */
11078
11079 /* fill in Access Key field, only support Entry ID Match method */
11080 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_ENTRYID_FIELD] = EntryId;
11081
11082 /* fill in CFGE_DATA */
11083 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA0] = NETC_ETHSWT_IP_SCHTABLE_CFGE_DATA_CQ_ASSG(SchedulerTableEntry->numberOfWBFSQueues) \
11084 | NETC_ETHSWT_IP_SCHTABLE_CFGE_DATA_OAL(SchedulerTableEntry->overheadAccountingLength);
11085
11086 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA1] = NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_0(SchedulerTableEntry->portEgressSchedulerWeightList[0U]) \
11087 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_1(SchedulerTableEntry->portEgressSchedulerWeightList[1U]) \
11088 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_2(SchedulerTableEntry->portEgressSchedulerWeightList[2U]) \
11089 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_3(SchedulerTableEntry->portEgressSchedulerWeightList[3U]);
11090
11091 TableDataBuffer.TableDataField[NETC_ETHSWT_IP_SWITCHTABLE_REQFMT_CFGEDATA2] = NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_4(SchedulerTableEntry->portEgressSchedulerWeightList[4U]) \
11092 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_5(SchedulerTableEntry->portEgressSchedulerWeightList[5U]) \
11093 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_6(SchedulerTableEntry->portEgressSchedulerWeightList[6U]) \
11094 | NETC_ETHSWT_IP_SGCLTABLE_CFGE_DATA_WBFS_WEIGHT_7(SchedulerTableEntry->portEgressSchedulerWeightList[7U]);
11095 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_41();
11096
11097 /* fill in operation data for config field of Request Header*/
11098 Netc_EthSwt_Ip_OperationData.CmdCompletionInt = 0x0U; /* command completion interrupt disabled */
11099 Netc_EthSwt_Ip_OperationData.Version = NETC_ETHSWT_IP_CMDBD_REQFMT_PROTOCOL_VERSION; /* protocol version = 2 */
11100 Netc_EthSwt_Ip_OperationData.TableId = NETC_ETHSWT_IP_CLASS_SCHEDULER_TABLE_ID;
11101 /* for Add and Update command, the Access Method should only be NETC_ETHSWT_ENTRY_ID_MATCH */
11102 Netc_EthSwt_Ip_OperationData.AccessMethod = NETC_ETHSWT_ENTRY_ID_MATCH;
11103 Netc_EthSwt_Ip_OperationData.Cmd = NETC_ETHSWT_UPDATE_CMD;
11104
11105 /* the request and response data buffer length are variable based on the length of control list*/
11106 Netc_EthSwt_Ip_OperationData.ReqBuffLength = NETC_ETHSWT_IP_EGRSCHTABLE_REQBUFFER_LEN ;
11107 Netc_EthSwt_Ip_OperationData.RspBuffLength = (NETC_ETHSWT_IP_TABLE_COMMON_RSPBUFFER_0BYTE_LEN);
11108
11109 /* send command */
11110 status = Netc_EthSwt_Ip_SendCommand(SwitchIdx, NETC_ETHSWT_IP_CBDR_0, &Netc_EthSwt_Ip_OperationData);
11111 #if defined(ERR_IPV_NETC_051243)
11112 #if (STD_ON == ERR_IPV_NETC_051243)
11113 /* Error code 0x8A is not a real error. check it on Errata. */
11114 if ((status == 0x8AU) || (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS))
11115 #else
11116 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
11117 #endif
11118 #else
11119 if (status == NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS)
11120 #endif
11121 {
11122 status = NETC_ETHSWT_IP_CBDRSTATUS_SUCCESS;
11123 Netc_EthSwt_Ip_GetMatchedEntries(NETC_ETHSWT_IP_CBDR_0, MatchedEntries);
11124 }
11125
11126 return status;
11127 }
11128
11129 /* @implements Netc_EthSwt_Ip_SetSyncState_Activity */
11130 Std_ReturnType Netc_EthSwt_Ip_SetSyncState(uint8 SwitchIdx, boolean SyncState)
11131 {
11132 Std_ReturnType Status = E_OK;
11133
11134 #if (STD_ON == NETC_ETHSWT_IP_DEV_ERROR_DETECT)
11135 DevAssert(SwitchIdx < FEATURE_NETC_ETHSWT_IP_NUMBER_OF_SWTS);
11136 #else
11137 (void)SwitchIdx; /*Cast to void because there might be cases when NETC_ETHSWT_IP_DEV_ERROR_DETECT == STD_OFF and SwitchIdx will be unused */
11138 #endif
11139
11140 SchM_Enter_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_09();
11141 if(TRUE == SyncState)
11142 {
11143 Netc_EthSwt_Ip_TimerBase->TMR_PARAM |= NETC_ETHSWT_TIMER_SYNC_MASK;
11144 }
11145 else
11146 {
11147 Netc_EthSwt_Ip_TimerBase->TMR_PARAM &= ~NETC_ETHSWT_TIMER_SYNC_MASK;
11148 }
11149 SchM_Exit_EthSwt_43_NETC_ETHSWT_EXCLUSIVE_AREA_09();
11150
11151 return Status;
11152 }
11153
11154 #define ETHSWT_43_NETC_STOP_SEC_CODE
11155 #include "EthSwt_43_NETC_MemMap.h"
11156
11157 #ifdef __cplusplus
11158 }
11159 #endif
11160
11161 /** @} */
11162