1 /*
2  * Copyright 2021-2023 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef NETC_ETH_IP_H
8 #define NETC_ETH_IP_H
9 
10 /**
11 *   @file Netc_Eth_Ip.h
12 *
13 *   @addtogroup NETC_ETH_DRIVER NETC_ETH Driver
14 *   @{
15 */
16 
17 #ifdef __cplusplus
18 extern "C"{
19 #endif
20 
21 /*==================================================================================================
22 *                                          INCLUDE FILES
23 * 1) system and project includes
24 * 2) needed interfaces from external units
25 * 3) internal and external interfaces from this unit
26 ==================================================================================================*/
27 #include "Netc_Eth_Ip_Types.h"
28 #include "Eth_GeneralTypes.h"
29 
30 /*==================================================================================================
31 *                                 SOURCE FILE VERSION INFORMATION
32 ==================================================================================================*/
33 #define NETC_ETH_IP_VENDOR_ID                    43
34 #define NETC_ETH_IP_AR_RELEASE_MAJOR_VERSION     4
35 #define NETC_ETH_IP_AR_RELEASE_MINOR_VERSION     7
36 #define NETC_ETH_IP_AR_RELEASE_REVISION_VERSION  0
37 #define NETC_ETH_IP_SW_MAJOR_VERSION             1
38 #define NETC_ETH_IP_SW_MINOR_VERSION             0
39 #define NETC_ETH_IP_SW_PATCH_VERSION             0
40 
41 /*==================================================================================================
42 *                                       FILE VERSION CHECKS
43 ==================================================================================================*/
44 /* Checks against Netc_Eth_Ip_Types.h */
45 #if (NETC_ETH_IP_VENDOR_ID != NETC_ETH_IP_TYPES_VENDOR_ID)
46     #error "Netc_Eth_Ip.h and Netc_Eth_Ip_Types.h have different vendor ids"
47 #endif
48 #if ((NETC_ETH_IP_AR_RELEASE_MAJOR_VERSION    != NETC_ETH_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
49      (NETC_ETH_IP_AR_RELEASE_MINOR_VERSION    != NETC_ETH_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
50      (NETC_ETH_IP_AR_RELEASE_REVISION_VERSION != NETC_ETH_IP_TYPES_AR_RELEASE_REVISION_VERSION))
51     #error "AUTOSAR Version Numbers of Netc_Eth_Ip.h and Netc_Eth_Ip_Types.h are different"
52 #endif
53 #if ((NETC_ETH_IP_SW_MAJOR_VERSION != NETC_ETH_IP_TYPES_SW_MAJOR_VERSION) || \
54      (NETC_ETH_IP_SW_MINOR_VERSION != NETC_ETH_IP_TYPES_SW_MINOR_VERSION) || \
55      (NETC_ETH_IP_SW_PATCH_VERSION != NETC_ETH_IP_TYPES_SW_PATCH_VERSION) \
56     )
57     #error "Software Version Numbers of Netc_Eth_Ip.h and Netc_Eth_Ip_Types.h are different"
58 #endif
59 
60 /*==================================================================================================
61 *                                            CONSTANTS
62 ==================================================================================================*/
63 
64 /*==================================================================================================
65 *                                       DEFINES AND MACROS
66 ==================================================================================================*/
67 #define ETH_43_NETC_START_SEC_CONFIG_DATA_UNSPECIFIED
68 #include "Eth_43_NETC_MemMap.h"
69 
70 NETC_ETH_IP_CONFIG_EXT
71 
72 #define ETH_43_NETC_STOP_SEC_CONFIG_DATA_UNSPECIFIED
73 #include "Eth_43_NETC_MemMap.h"
74 
75 #define NETC_ETH_IP_32BIT_SHIFT (32U)    /*!< 32 bits shift */
76 #define NETC_ETH_IP_24BIT_SHIFT (24U)    /*!< 24 bits shift */
77 #define NETC_ETH_IP_16BIT_SHIFT (16U)    /*!< 16 bits shift */
78 #define NETC_ETH_IP_8BIT_SHIFT  (8U)     /*!< 8 bits shift */
79 
80 #define NETC_ETH_IP_0XFF_MASK                           (0xFFU)
81 #define NETC_ETH_IP_0XFFFF_MASK                         (0xFFFFU)
82 #define NETC_ETH_IP_0XFFFF0000_MASK                     (0xFFFF0000UL)
83 
84 /* Macros for NTMP request message header */
85 #define NETC_ETH_IP_CMDBD_REQFMT_PROTOCOL_VERSION       (2U)      /*!< protocol version = 0x2 */
86 #define NETC_ETH_IP_CMDBD_REQFMT_NTMP_PROTOCOL_VERSION  (1U)      /*!< NTMP version is 2.0 */
87 
88 /*==================================================================================================
89 *                                              ENUMS
90 ==================================================================================================*/
91 
92 /*==================================================================================================
93 *                                  STRUCTURES AND OTHER TYPEDEFS
94 ==================================================================================================*/
95 
96 /*==================================================================================================
97 *                                  GLOBAL VARIABLE DECLARATIONS
98 ==================================================================================================*/
99 
100 /*==================================================================================================
101 *                                       FUNCTION PROTOTYPES
102 ==================================================================================================*/
103 #define ETH_43_NETC_START_SEC_CODE
104 #include "Eth_43_NETC_MemMap.h"
105 
106 /*!
107  * @brief Initializes the ENETC station interface
108  *
109  * This function initializes and enables the ENETC station instance, configuring receive and transmit control
110  * settings, the receive and transmit descriptors rings and the MAC physical address.
111  *
112  * @param[in] ctrlIndex Instance number
113  * @param[in] config Pointer to the instance configuration structure
114  *
115  * @retval NETC_ETH_IP_STATUS_SUCCESS The initialization was successful.
116  * @retval NETC_ETH_IP_STATUS_TIMEOUT The initialization returned a timeout.
117  */
118 Netc_Eth_Ip_StatusType Netc_Eth_Ip_Init(uint8 ctrlIndex, const Netc_Eth_Ip_ConfigType *config);
119 
120 /**
121  * @brief            Set the credit based shaper slope
122  * @details          Set the idle slope for the credit based shaper
123  *
124  * Parameters:
125  * -[in]     ctrlIndex           Index of the controller within the context of the Ethernet Driver
126  * -[in]     TrafficClass        The value range is 0 to 7
127  * -[in]     idleSlope           Idleslope is the rate of credits that is accumulated (in bits per second)  when there  is  at  least  one packet waiting for transmission.
128  */
129 Std_ReturnType Netc_Eth_Ip_ConfigureCreditBasedShaper(const uint8 ctrlIndex, const uint8 TrafficClass, const uint64 idleSlope);
130 
131 /**
132  * @brief            Enable/Disable the credit based shaper
133  * @details          The credit based shaper TrafficClass is Enable/Disable
134  *
135  * Parameters:
136  * -[in]     ctrlIndex            Index of the controller within the context of the Ethernet Driver
137  * -[in]     TrafficClass         The value range is 0 to 7
138  * -[in]     Enable               TRUE: enable credit based shaper. FALSE: disable credit based shaper.
139  *
140  */
141 Std_ReturnType Netc_Eth_Ip_EnableCreditBasedShaper(const uint8 ctrlIndex, const uint8 TrafficClass, const boolean Enable);
142 
143 /*!
144  * @brief Gets the current power state of the NETC instance
145  *
146  * @param[in] CtrlIndex Instance number
147  * @return Netc_Eth_Ip_PowerStateType The power state of the controller
148  */
149 Netc_Eth_Ip_PowerStateType Netc_Eth_Ip_GetPowerState(uint8 CtrlIndex);
150 
151 /*!
152  * @brief Enables the specified SI.
153  *
154  * @param[in] ctrlIndex SI number
155  *
156  * @retval NETC_ETH_IP_STATUS_SUCCESS The initialization was successful.
157  */
158 Netc_Eth_Ip_StatusType Netc_Eth_Ip_EnableController(uint8 ctrlIndex);
159 
160 /*!
161  * @brief Disables the controller and resets all the configured transmit and receive buffers
162  *
163  * Warning: This function ignores all pending transmission and reception requests
164  *
165  * @param[in] ctrlIndex SI number
166  *
167  * @retval NETC_ETH_IP_STATUS_SUCCESS The controller was successfully disabled.
168  * @retval NETC_ETH_IP_STATUS_ERROR   The controller cannot be disabled because of consuming pending ring.
169  */
170 Netc_Eth_Ip_StatusType Netc_Eth_Ip_DisableController(uint8 ctrlIndex);
171 
172 /*!
173  * @brief Provides a transmit buffer to be used by the application for transmission.
174  *
175  * This function provides an internal buffer which can further be used by the application
176  * to store the transmit data.
177  *
178  * Note: The buffer will be marked as locked and won't be released until after a call to
179  * Netc_Eth_Ip_GetTransmitStatus for the same buffer returns NETC_ETH_IP_STATUS_SUCCESS.
180  *
181  * Important: The driver does not ensure synchronization between different threads trying
182  * to get a buffer at the same time. This synchronization shall be implemented by the
183  * application.
184  *
185  * @param[in]     ctrlIndex Instance number
186  * @param[in]     ring   Ring number
187  * @param[in,out] buff   In:  Buffer containing the desired length
188  *                       Out: Buffer containing the granted length or available length in case of overflow.
189  * @param[out]    buffId Index of the buffer (descriptor) within the ring.
190  *                       If this information is not needed, this parameter should be NULL_PTR.
191  * @retval NETC_ETH_IP_STATUS_SUCCESS The buffer has been successfully locked.
192  * @retval NETC_ETH_IP_STATUS_TX_BUFF_BUSY All buffers are currently in use for the current ring.
193  * @retval NETC_ETH_IP_STATUS_TX_BUFF_OVERFLOW The requested buffer length cannot be granted.
194  * @retval NETC_ETH_IP_STATUS_INVALID_FRAME_LENGTH The buffer length is smaller than minium of frame length.
195  */
196 Netc_Eth_Ip_StatusType Netc_Eth_Ip_GetTxBuff(uint8 ctrlIndex,
197                                              uint8 ring,
198                                              Netc_Eth_Ip_BufferType *buff,
199                                              uint16 *buffId);
200 
201 /*!
202  * @brief Sends an Ethernet frame
203  *
204  * This function sends an Ethernet frame, contained in the buffer received as parameter.
205  *
206  * Note: Since the transmission of the frame is not complete when this function returns,
207  * the application must not change/alter/re-use the provided buffer until after a call
208  * to Netc_Eth_Ip_GetTransmitStatus for the same buffer returns NETC_ETH_IP_STATUS_SUCCESS.
209  *
210  * Important: The driver does not ensure synchronization between different threads trying
211  * to send a frame at the same time. This synchronization shall be implemented by the
212  * application.
213  *
214  * @param[in] ctrlIndex Instance number
215  * @param[in] ring The ring number
216  * @param[in] buff The buffer containing the frame
217  * @param[in] options Configuration options applicable to this buffer's transmission only.
218  * Can be NULL_PTR, if no special option is required.
219  * @retval NETC_ETH_IP_STATUS_SUCCESS       The frame was successfully enqueued for transmission.
220  * @retval NETC_ETH_IP_STATUS_TX_BUFF_BUSY  All internal TX buffers are currently in use.
221  * @retval NETC_ETH_IP_STATUS_INVALID_FRAME_LENGTH Length of the external buffer is smaller than minium of frame length.
222  * @retval NETC_ETH_IP_STATUS_TX_BUFF_OVERFLOW The requested buffer length cannot be granted.
223  */
224 Netc_Eth_Ip_StatusType Netc_Eth_Ip_SendFrame(uint8 ctrlIndex,
225                                              uint8 ring,
226                                             Netc_Eth_Ip_BufferType * buff,
227                                              const Netc_Eth_Ip_TxOptionsType * options
228                                             );
229 
230 
231 /*!
232  * @brief Sends an Ethernet frame which is scattered in multiple buffers
233  *
234  * This function sends an Ethernet frame, contained in the buffers received as parameter.
235  *
236  * Note: Since the transmission of the frame is not complete when this function returns,
237  * the application must not change/alter/re-use the provided buffer until after a call
238  * to Netc_Eth_Ip_GetTransmitStatus for the same buffer returns NETC_ETH_IP_STATUS_SUCCESS.
239  *
240  * Important: The driver does not ensure synchronization between different threads trying
241  * to send a frame at the same time. This synchronization shall be implemented by the
242  * application.
243  *
244  * @param[in] ctrlIndex Instance number
245  * @param[in] ring The ring number
246  * @param[in] Buffers The list of buffers containing the frame
247  * @param[in] options Configuration options applicable to this buffer's transmission only.
248  *                    Can be NULL_PTR, if no special option is required.
249  * @param[in] NumBuffers Number of buffers available in Buffers
250  * @retval NETC_ETH_IP_STATUS_SUCCESS       The frame was successfully enqueued for transmission.
251  * @retval NETC_ETH_IP_STATUS_TX_BUFF_BUSY  All internal TX buffers are currently in use.
252  * @retval NETC_ETH_IP_STATUS_INVALID_FRAME_LENGTH Length of the external buffer is smaller than minium of frame length.
253  * @retval NETC_ETH_IP_STATUS_TX_BUFF_OVERFLOW The requested buffer length cannot be granted.
254  */
255 Netc_Eth_Ip_StatusType Netc_Eth_Ip_SendMultiBufferFrame(uint8 ctrlIndex,
256                                                         uint8 ring,
257                                                         Netc_Eth_Ip_BufferType Buffers[],
258                                                         const Netc_Eth_Ip_TxOptionsType *options,
259                                                         uint16 NumBuffers);
260 
261 /*!
262  * @brief Provides a transmit buffer to be used by the application for transmission.
263  *
264  * This function will verify if there are enough descriptors free and that each of
265  * the descriptors can hold the parts of the frame to be send using Netc_Eth_Ip_SendMultiBufferFrame.
266  *
267  * Note: This function will only return the first buffer descriptor index starting with which the
268  * multi buffer frame can be sent.
269  *
270  * Important: This function is meant for internal use only and will be called from an upper layer to get
271  * the first buffer descriptor index from a sequence of buffers that will be used for sending a
272  * multi buffer frame.
273  *
274  * @param[in]     ctrlIndex     Instance number
275  * @param[in]     ring          Ring number
276  * @param[in]     NumBuffers    Number of buffers
277  * @param[in]     BufferLength  List with the length of each chunk of the frame
278  * @param[out]    buffId        Index of the buffer (descriptor) within the ring.
279  * @retval NETC_ETH_IP_STATUS_SUCCESS The buffer has been successfully locked.
280  * @retval NETC_ETH_IP_STATUS_TX_BUFF_BUSY All buffers are currently in use for the current ring.
281  * @retval NETC_ETH_IP_STATUS_TX_BUFF_OVERFLOW The requested buffer length cannot be granted.
282  * @retval NETC_ETH_IP_STATUS_INVALID_FRAME_LENGTH The buffer length is smaller than minium of frame length.
283  */
284 Netc_Eth_Ip_StatusType Netc_Eth_Ip_GetTxMultiBuff(uint8 ctrlIndex,
285                                                   uint8 ring,
286                                                   uint16 NumBuffers,
287                                                   const uint16 BufferLength[],
288                                                   uint16 *buffId);
289 
290 /*!
291  * @brief Reads a received Ethernet frame
292  *
293  * This function reads the first received Ethernet frame in the Rx queue. The buffer received
294  * as parameter will be updated by the driver and the .data field will point to a memory area
295  * containing the frame data.
296  *
297  * Note: Once the application finished processing the buffer, it could be reused by the
298  * driver for further receptions by invoking Netc_Eth_Ip_ProvideRxBuff.
299  *
300  * Important: The driver does not ensure synchronization between different threads trying
301  * to read a frame at the same time. This synchronization shall be implemented by the
302  * application.
303  *
304  * @param[in]  ctrlIndex Instance number
305  * @param[in]  ring The ring number
306  * @param[out] buff The buffer containing the frame
307  * @param[out] info Enhanced information related to the data contained by this receive buffer.
308  * If this information is not needed, this parameter should be NULL_PTR.
309  * @retval NETC_ETH_IP_STATUS_SUCCESS        A frame was successfully read.
310  * @retval NETC_ETH_IP_STATUS_RX_QUEUE_EMPTY There is no available frame in the queue.
311  * @retval NETC_ETH_IP_STATUS_ERROR       There is at least an error in reception.
312  */
313 Netc_Eth_Ip_StatusType Netc_Eth_Ip_ReadFrame(uint8 ctrlIndex,
314                                              uint8 ring,
315                                              Netc_Eth_Ip_BufferType *buff,
316                                              Netc_Eth_Ip_RxInfoType *info
317                                             );
318 
319 /*!
320  * @brief Provides a receive buffer to be used by the driver for reception.
321  *
322  * This function provides a buffer which can further be used by the reception mechanism
323  * in order to store the received data.
324  *
325  * Note: The application can either provide a buffer previously obtained in a Netc_Eth_Ip_ReadFrame
326  * call (when it is no longer needed after being fully processed), or allocate a new buffer.
327  * The former approach is recommended as it has a simpler usage model and re-uses the same initial
328  * memory range for the entire driver lifetime operation. The later approach could provide more
329  * flexibility, but since it involves constant memory free/alloc operations it is only recommended
330  * with an efficient pool-based memory allocator.
331  *
332  * Important: The driver does not ensure synchronization between different threads trying
333  * to provide a buffer at the same time. This synchronization shall be implemented by the
334  * application.
335  *
336  * Important: The application is responsible for providing one Rx buffer for every frame it
337  * receives, otherwise the reception ring can fill-up, affecting further reception.
338  *
339  * Usage example:
340  *
341  * stat = Netc_Eth_Ip_ReadFrame(0U, 0U, &rxBuff);
342  *
343  * if (stat == NETC_ETH_IP_STATUS_SUCCESS)
344  * {
345  *     process_buffer(&rxBuff);
346  *     Netc_Eth_Ip_ProvideRxBuff(0U, 0U, &rxBuff);
347  * }
348  *
349  * @param[in] ctrlIndex Instance number
350  * @param[in] ring The ring number
351  * @param[in] buff The buffer to be added to the reception ring
352  */
353 Netc_Eth_Ip_StatusType Netc_Eth_Ip_ProvideRxBuff(uint8 ctrlIndex,
354                                                  uint8 ring,
355                                                  const Netc_Eth_Ip_BufferType *buff);
356 
357 /**
358  * @brief This function will be used when RX should be used at maximum capacity, instead of providing
359  *        one by one buffer for reception, a batch of buffers will be provided
360  *
361  * @param[in] CtrlIndex Instance number.
362  * @param[in] Ring      The ring number.
363  * @param[in] BuffList  This should be NULL_PTR if internal buffers are used, otherwise this should respect
364  *                  the follwing indications:
365  *                   - List of the external buffers used for descriptor restauration;
366  * @param[inout] BuffListSize [IN]  Number of buffers in list. When the internal buffers are in use, this parameter shall
367  *                                  contain the number of BD which need to be restored after a reception of a more than one packet.
368  *                            [OUT] Returns how many Buffer Descriptors have been released.
369  */
370 void Netc_Eth_Ip_ProvideMultipleRxBuff(const uint8 CtrlIndex,
371                                                          const uint8 Ring,
372                                                          uint8* BuffList[],
373                                                          uint16* BuffListSize);
374 
375 /*!
376  * @brief Checks if there are more frames available in the given queue
377  *
378  * This function takes a peek at the given Rx queue to check if there are more Ethernet
379  * frames to be received. Its intended usage is to provide this information without
380  * also extracting the frame as "Netc_Eth_Ip_ReadFrame".
381  *
382  * @param[in]  ctrlIndex Instance number
383  * @param[in]  ring The ring number
384  * @retval TRUE  There is an available frame in the queue.
385  * @retval FALSE There is no available frame in the queue.
386  */
387 boolean Netc_Eth_Ip_IsFrameAvailable(uint8 ctrlIndex,
388                                      uint8 ring
389                                     );
390 /*!
391  * @brief Checks if the transmission of a buffer is complete.
392  *
393  * This function checks if the transmission of the given buffer is complete.
394  *
395  * TODO: Descrition should be improved to indicate that this is not normally
396  * needed in regular transmit workflow since GetTxBuff already exposes HW
397  * consumption of TX entries
398  *
399  * Note: If the buffer is not found in the Tx ring, the function will return NETC_ETH_IP_STATUS_BUFF_NOT_FOUND.
400  *
401  * @param[in]  CtrlIndex Instance number
402  * @param[in]  ring The ring number
403  * @param[in]  buff The transmit buffer for which the status shall be checked
404  * @param[out] info Extended information related to the buffer. If this information is not needed,
405  * this parameter should be NULL_PTR.
406  * @retval NETC_ETH_IP_STATUS_TX_BUFF_BUSY    The frame is still enqueued for transmission.
407  * @retval NETC_ETH_IP_STATUS_BUFF_NOT_FOUND  The buffer was not found in the Tx queue.
408  * @retval NETC_ETH_IP_STATUS_ERROR        There is at least an error in transmission.
409  * @retval NETC_ETH_IP_STATUS_SUCCESS         Otherwise.
410  */
411 Netc_Eth_Ip_StatusType Netc_Eth_Ip_GetTransmitStatus(uint8 ctrlIndex,
412                                                      uint8 ring,
413                                                      const Netc_Eth_Ip_BufferType * buff,
414                                                      Netc_Eth_Ip_TxInfoType * info
415                                                     );
416 
417 /*!
418  * @brief Configures the physical address of the MAC
419  *
420  * @param[in] CtrlIndex Instance number
421  * @param[in] MacAddr The MAC address to be configured
422  *
423  * @retval NETC_ETH_IP_STATUS_SUCCESS Physical address of mac is configured successfully.
424  * @retval NETC_ETH_IP_STATUS_TIMEOUT Changing the physical address was not changed because a timeout has occured.
425  */
426 Netc_Eth_Ip_StatusType Netc_Eth_Ip_SetMacAddr(uint8 CtrlIndex, const uint8 *MacAddr);
427 
428 /**
429  * @brief Gets the physical address of the MAC for a controller.
430  *
431  * @param[in]  CtrlIndex Instance number
432  * @param[out] MacAddr The physical address of the MAC
433  */
434 void Netc_Eth_Ip_GetMacAddr(uint8 CtrlIndex, uint8 *MacAddr);
435 
436 /**
437  * @brief Gets statistics from the specified counter
438  *
439  * @param[in] CtrlIndex Instance number
440  * @param[in] Counter The counter to be read
441  * @return The low 32-bit value of the requested counter
442  */
443 uint32 Netc_Eth_Ip_GetCounter(uint8 CtrlIndex, Netc_Eth_Ip_CounterType Counter);
444 
445 /**
446  * @brief Gets statistics from the specified counter
447  *
448  * @param[in] CtrlIndex Instance number
449  * @param[in] Counter The counter to be read
450  * @return The 64-bit value of the requested counter
451  */
452 uint64 Netc_Eth_Ip_GetCounter64(uint8 CtrlIndex, Netc_Eth_Ip_CounterType Counter);
453 
454 /**
455  * @brief Adds a hardware address to the hash filter. The destination address of
456  * an incoming packet is passed through hash function and then is added as an
457  * entry in the hash table.
458  *
459  * @param[in] CtrlIndex Instance number.
460  * @param[in] MacAddr   Destination MAC address to be added in hash filter.
461  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
462  *                                NETC_ETH_IP_STATUS_ERROR   - unsuccessfully operation
463  *                                NETC_ETH_IP_STATUS_MAC_ADDR_TABLE_FULL - MAC table used for hash filter is full
464  *                                NETC_ETH_IP_STATUS_TIMEOUT - Only for VSIs - the command was not processed in the allotted time
465  */
466 Netc_Eth_Ip_StatusType Netc_Eth_Ip_AddMulticastDstAddrToHashFilter(const uint8 CtrlIndex, const uint8 *MacAddr);
467 
468 /**
469  * @brief Removes a hardware address from the hash filter. The destination address of
470  * an incoming packet is passed through hash function and then is removed from
471  * hash table.
472  *
473  * @param[in] CtrlIndex Instance number.
474  * @param[in] MacAddr   Destination MAC address to be removed from hash filer.
475  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
476  *                                NETC_ETH_IP_STATUS_ERROR   - unsuccessfully operation
477  *                                NETC_ETH_IP_STATUS_MAC_ADDR_NOT_FOUND - the current destination MAC was not
478  *                                found in the hash filter table
479  *                                NETC_ETH_IP_STATUS_TIMEOUT - Only for VSIs - the command was not processed in the allotted time
480  */
481 Netc_Eth_Ip_StatusType Netc_Eth_Ip_RemoveMulticastDstAddrFromHashFilter(const uint8 CtrlIndex, const uint8 *MacAddr);
482 
483 /**
484  * @brief Enables/Disables forwarding of the multicast traffic.
485  *
486  * @param[in]  CtrlIdx Instance number
487  * @param[in]  EnableMulticast  TRUE -> cotroller will receive all the multicast traffic;
488  *                     FALSE-> cotroller will stop receive all the multicast traffic;
489  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
490  *                                NETC_ETH_IP_STATUS_TIMEOUT - Only for VSIs - the command was not processed in the allotted time
491  */
492 Netc_Eth_Ip_StatusType Netc_Eth_Ip_SetMulticastForwardAll(const uint8 CtrlIndex, const boolean EnableMulticast);
493 
494 /**
495  * @brief Disable multicast promiscuous and delete all entries in multicast MAC filter table.
496  *
497  * @param[in] CtrlIdx Instance number.
498  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
499  *                                NETC_ETH_IP_STATUS_TIMEOUT - Only for VSIs - the command was not processed in the allotted time
500  */
501 Netc_Eth_Ip_StatusType Netc_Eth_Ip_CloseMulticastReceiving(const uint8 CtrlIndex);
502 /**
503  * @brief Realease multiple transmission buffers at once.
504  *
505  * @param CtrlIdx Instance number.
506  * @param Ring    Ring number.
507  */
508 void Netc_Eth_Ip_ReleaseTxBuffers(const uint8 CtrlIdx, const uint8 Ring);
509 
510 /**
511  * @brief Set the threshold values for Rx coalescing interrupt.
512  *
513  * @param[in]  CtrlIdx  Controller number
514  * @param[in]  RingIdx  Ring Index on which the settings will be applied.
515  * @param[in]  PacketsThreshold  No of packets after which the ISR will be triggered. Must be different than 0 in order to set the value.
516  * @param[in]  TimerThreshold  No of ticks after which the ISR will be triggered. Must be different than 0 in order to set the value.
517  *
518  *
519  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
520  *                                NETC_ETH_IP_STATUS_ERROR - Either the coalescing interrupt is not enabled or the No of packets passed exceedes the
521  *                                                        size of the ring.
522  */
523 Netc_Eth_Ip_StatusType Netc_Eth_Ip_SetRxCoalescingThresholds(uint8 CtrlIdx, uint8 RingIdx, uint16 PacketsThreshold, uint32 TimerThreshold);
524 
525 /**
526  * @brief Set the threshold values for Tx coalescing interrupt.
527  *
528  * @param[in]  CtrlIdx  Controller number
529  * @param[in]  RingIdx  Ring Index on which the settings will be applied.
530  * @param[in]  PacketsThreshold  No of packets after which the ISR will be triggered. Must be different than 0 in order to set the value.
531  *                               If a value which is not a power of two is passed through this parameter, than the actual number of packets configured
532  *                               will be the greatest power of two which is smaller than the parameter value.
533  * @param[in]  TimerThreshold  No of ticks after which the ISR will be triggered. Must be different than 0 in order to set the value.
534  *
535  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
536  *                                NETC_ETH_IP_STATUS_ERROR - Either the coalescing interrupt is not enabled or the No of packets passed is equal
537  *                                                          to or greater than the size of the ring.
538  */
539 Netc_Eth_Ip_StatusType Netc_Eth_Ip_SetTxCoalescingThresholds(uint8 CtrlIdx, uint8 RingIdx, uint16 PacketsThreshold, uint32 TimerThreshold);
540 
541 /**
542  * @brief Add/Update time gate scheduling table entry.
543  *
544  * @param[in]  CtrlIndex Instance number
545  * @param[in]  TimeGateSchedulingTableEntry  pointer to structure Netc_Eth_Ip_TimeGateSchedulingEntryDataType that contains the data of time gate scheduling entry
546  *
547  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
548  *                                others - error code from command ring
549  */
550 Netc_Eth_Ip_StatusType Netc_Eth_Ip_AddOrUpdateTimeGateSchedulingTableEntry( const uint8 CtrlIndex,
551                                                                             const Netc_Eth_Ip_TimeGateSchedulingEntryDataType *TimeGateSchedulingTableEntry
552                                                                           );
553 
554 /**
555  * @brief Enables/Disables time gate scheduling feature.
556  *
557  * @param[in]  CtrlIndex Instance number
558  * @param[in]  Enable  TRUE -> time gate scheduling will be enabled;
559  *                     FALSE-> time gate scheduling will be disabled;
560  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
561  *                                NETC_ETH_IP_STATUS_ERROR - fail to enable time gating because Operational gate control list is active
562  */
563 Netc_Eth_Ip_StatusType Netc_Eth_Ip_ConfigPortTimeGateScheduling( const uint8 CtrlIndex, const boolean Enable );
564 
565 /**
566  * @brief Add/Update rate policer table entry.
567  *
568  * @param[in]  CtrlIndex Instance number
569  * @param[in]  Cmd              Add and Update commands are supported
570  * @param[out] MatchedEntries   Number of matched entries
571  * @param[in]  RatePolicerTableEntry  pointer to structure Netc_Eth_Ip_RatePolicerEntryDataType that contains the data of rate policer entry
572  *
573  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
574  *                                others - error code from command ring
575  */
576 Netc_Eth_Ip_StatusType Netc_Eth_Ip_AddOrUpdateRatePolicerTableEntry( const uint8 CtrlIndex,
577                                                                      Netc_Eth_Ip_CommandsType Cmd,
578                                                                      uint32 *MatchedEntries,
579                                                                      const Netc_Eth_Ip_RatePolicerEntryDataType * RatePolicerTableEntry
580                                                                    );
581 
582 /**
583  * @brief Query rate policer table entry.
584  *
585  * @param[in]   CtrlIndex Instance number
586  * @param[out]  MatchedEntries   Number of matched entries
587  * @param[in]   RatePolicerEntryId       Rate policer table entry id
588  * @param[out]  RatePolicerTableEntry    pointer to structure Netc_Eth_Ip_RatePolicerEntryRspDataType that contains the data of rate policer entry
589  *
590  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
591  *                                others - error code from command ring
592  */
593 Netc_Eth_Ip_StatusType Netc_Eth_Ip_QueryRatePolicerTableEntry( const uint8 CtrlIndex,
594                                                                uint32 *MatchedEntries,
595                                                                uint32 RatePolicerEntryId,
596                                                                Netc_Eth_Ip_RatePolicerEntryRspDataType * RatePolicerTableEntry
597                                                              );
598 
599 /**
600  * @brief Delete rate policer table entry.
601  *
602  * @param[in]   CtrlIndex Instance number
603  * @param[out]  MatchedEntries   Number of matched entries
604  * @param[in]   RatePolicerEntryId       Rate policer table entry id
605  *
606  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
607  *                                others - error code from command ring
608  */
609 Netc_Eth_Ip_StatusType Netc_Eth_Ip_DeleteRatePolicerTableEntry( const uint8 CtrlIndex,
610                                                                 uint32 *MatchedEntries,
611                                                                 uint32 RatePolicerEntryId
612                                                               );
613 
614 /**
615  * @brief Add VLAN Filter Table entry.
616  *
617  * @param[in]  CtrlIndex Instance number
618  * @param[in]  VLANTableEntry  pointer to structure Netc_Eth_Ip_VLANFilterTableEntryDataType that contains the data of the VLAN Filter Table entry
619  *
620  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
621  *                                others - error code from command ring
622  */
623 Netc_Eth_Ip_StatusType Netc_Eth_Ip_AddVLANFilterTableEntry( const uint8 ctrlIndex, const Netc_Eth_Ip_VLANFilterTableEntryDataType *VLANTableEntry);
624 
625 /**
626  * @brief Query VLAN Filter Table entry. Uses the entry ID for the entry and updates the rest of the fields in the structure if the entry is found.
627  *
628  * @param[in]  CtrlIndex Instance number
629  * @param[in,out]  VLANTableEntry  pointer to structure Netc_Eth_Ip_VLANFilterTableEntryDataType that contains the data of the VLAN Filter Table entry
630  *
631  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
632  *                                others - error code from command ring
633  */
634 Netc_Eth_Ip_StatusType Netc_Eth_Ip_QueryVLANFilterTableEntry(const uint8 ctrlIndex, Netc_Eth_Ip_VLANFilterTableEntryDataType *VLANTableEntry);
635 
636 #if (STD_ON == NETC_ETH_IP_EXTENDED_BUFF)
637 #ifdef NETC_ETH_0_USED
638 /**
639  * @brief Set management information for a frame which will be send using management.
640  *
641  * @param CtrlIdx Instance number
642  * @param BuffIdx Unique buffer index id.
643  * @param SwitchIndex Index number of the switch to be used by the frame
644  * @param PortIndex Index identifier of the switch's port to be used by the frame
645  * @param Enable Enable/Disable management transmission on this frame.
646  */
647 Netc_Eth_Ip_StatusType Netc_Eth_Ip_ManagementFrame(const uint8 CtrlIdx, uint16 BuffIdx, uint8 SwitchIndex, uint8 PortIndex, boolean Enable);
648 
649 /**
650  * @brief Set a management frame to be sent as a timestamping one
651  * @param CtrlIdx Instance number
652  * @param BuffIdx Unique buffer index id.
653  * @param Enable Enable/Disable timestamping for this frame
654  **/
655 Netc_Eth_Ip_StatusType Netc_Eth_Ip_TimestampTxFrame(const uint8 CtrlIdx, const uint16 BuffIdx, const boolean Enable);
656 
657 /**
658  * @brief
659  *
660  * @param CtrlIndex Instance number
661  * @param Ring
662  * @return void
663  * @internal This function is not an API.
664 
665  */
666 void Netc_Eth_Ip_ReleaseUnusedTxBuff(uint8 CtrlIndex, uint8 Ring);
667 
668 /**
669  * @brief Get a pointer to the timestamp information of a particular TX frame.
670  *
671  * @param CtrlIdx Instance number
672  * @param BuffIdx Unique buffer index id.
673  * @param MgmtInfo Pointer to management information for the frame identified by BuffIdx
674  * @param TimestampInfo Pointer to timestamp information for the frame identified by BuffIdx
675  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - succesfully returned a pointer to the latest timestamp information
676  *                                NETC_ETH_IP_STATUS_ERROR - no timestamp information found for the requested frame
677  */
678 Netc_Eth_Ip_StatusType Netc_Eth_Ip_GetTxTimestampInfo(const uint8 CtrlIdx, const uint32 BuffIdx, Netc_Eth_Ip_TxManagementInfoType **MgmtInfo, Netc_Eth_Ip_TxTimestampInfoType **TimestampInfo);
679 
680 #endif /* NETC_ETH_0_USED */
681 
682 /**
683  * @brief Get a pointer to the Ingress timestamp information of a particular RX frame.
684  *
685  * @param[in] CtrlIdx - Index of the SI.
686  * @param[in] DataPtr - Data buffer address of the received frame for which the timestamp information is requested.
687  * @param[out] RxTimestampInfo  Pointer to the timestamp information.
688  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - succesfully returned a pointer to the latest timestamp information
689  *                                NETC_ETH_IP_STATUS_ERROR - no timestamp information found for the requested frame
690  */
691 Netc_Eth_Ip_StatusType Netc_Eth_Ip_GetRxTimestampInfo(const uint8 CtrlIdx, const uint8 *DataPtr, Netc_Eth_Ip_RxTimestampInfoType **RxTimestampInfo);
692 
693 #endif /* STD_ON == NETC_ETH_IP_EXTENDED_BUFF */
694 
695 /**
696  * @brief Function updates the time pointer value with the current sys time
697  *
698  * @param ctrlIndex Index of the Eth controller.
699  * @param TimePtr Current time stamp pointer
700  */
701 void Netc_Eth_Ip_GetSysTime(uint8 ctrlIndex, Netc_Eth_Ip_TimeType *TimePtr);
702 
703 /**
704  * @brief Function de-initialises VSI controller.
705  * PSI de-init not supported since it will also reset all VSIs
706  * VSI-PSI messaging interrupt needs to be configured for the VSI reconfiguration, done by the PSI
707  *
708  * @param ctrlIndex Index of the Eth controller.
709  * @retval NETC_ETH_IP_STATUS_SUCCESS The de-initialization was successful.
710  * @retval NETC_ETH_IP_STATUS_TIMEOUT The de-initialization returned a timeout.
711  */
712 Netc_Eth_Ip_StatusType Netc_Eth_Ip_Deinit(uint8 ctrlIndex);
713 
714 /**
715  * @brief Checks the status of a transmissions and releases the resources
716  * @internal This function is not an API, but an internal function that needs to be used in the upper layer.
717  *
718  *
719  * @param ctrlIndex             Index of the SI.
720  * @param ring                  Ring Number.
721  * @param ConsumerIndex         Consumer read from HW.
722  * @param buff                  Buffer address.
723  * @param timeStampInfo         Parameter where the timestamp can be provided for the transmitted frame
724  * @param txStatus              Parameter where the transmission status can be provided.
725  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
726  *                                NETC_ETH_IP_STATUS_TIMEOUT - Only for VSIs - the command was not processed in time
727  * @internal This function is not an API.
728  */
729 Netc_Eth_Ip_StatusType Netc_Eth_Ip_CheckFrameStatus(uint8 ctrlIndex,
730                                                     uint8 ring,
731                                                     uint32 ConsumerIndex,
732                                                     const uint8 *buff,
733                                                     Netc_Eth_Ip_TimestampType *timeStampInfo,
734                                                     Netc_Eth_Ip_TxStatusType *txStatus);
735 
736 /**
737  * @brief The Pcie Event Collector Interrupt handler
738  * @internal This function is not an API. It must be added in the Interrupt Controller configuration as a handler.
739  *
740  * @param ctrlIndex             Index of the SI.
741  * @return void
742  */
743 void Netc_Eth_Ip_PCIe_AER_Handler(uint8 ctrlIndex);
744 
745 /**
746  * @brief         Enable/Disable the ingress port filter feature on ENETC port
747  *
748  * @param[in]     CtrlIndex            Index of the controller within the context of the Ethernet Driver
749  * @param[in]     Enable               TRUE: enable ingress port filter feature. FALSE: disable ingress port filter feature.
750  *
751  */
752 Std_ReturnType Netc_Eth_Ip_EnableIngressPortFiltering(const uint8 CtrlIndex, boolean Enable );
753 
754 /**
755  * @brief Add ingress port filter table entry.
756  *
757  * @param[in]   CtrlIndex Instance number
758  * @param[out]  MatchedEntries   Number of matched entries
759  * @param[in]   IngressPortFilterTableEntry    pointer to structure Netc_Eth_Ip_IngressPortFilterEntryDataType that contains the data of ingress port filter entry
760  * @param[out]  IngressPortFilterTableEntry    pointer to structure Netc_Eth_Ip_IngressPortFilterEntryDataType that contains the data of ingress port filter entry
761  *
762  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
763  *                                others - error code from command ring
764  */
765 Netc_Eth_Ip_StatusType Netc_Eth_Ip_AddIngressPortFilterTableEntry( uint8 CtrlIndex,
766                                                                    uint32 *MatchedEntries,
767                                                                    Netc_Eth_Ip_IngressPortFilterEntryDataType * IngressPortFilterTableEntry
768                                                                  );
769 
770 /**
771  * @brief Query ingress port filter table entry.
772  *
773  * @param[in]   CtrlIndex Instance number
774  * @param[out]  MatchedEntries   Number of matched entries
775  * @param[in]   IngressPortFilterTableEntry    pointer to structure Netc_Eth_Ip_IngressPortFilterEntryDataType that contains the data of ingress port filter entry
776  * @param[out]  IngressPortFilterTableEntry    pointer to structure Netc_Eth_Ip_IngressPortFilterEntryDataType that contains the data of ingress port filter entry
777  *
778  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
779  *                                others - error code from command ring
780  */
781 Netc_Eth_Ip_StatusType Netc_Eth_Ip_QueryIngressPortFilterTableEntry( const uint8 CtrlIndex,
782                                                                      uint32 *MatchedEntries,
783                                                                      Netc_Eth_Ip_IngressPortFilterEntryDataType * IngressPortFilterTableEntry
784                                                                    );
785 
786 /**
787  * @brief Delete ingress port filter table entry.
788  *
789  * @param[in]   CtrlIndex Instance number
790  * @param[out]  MatchedEntries   Number of matched entries
791  * @param[in]   IngressPortFilterEntryId       Ingress port filter table entry id
792  *
793  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
794  *                                others - error code from command ring
795  */
796 Netc_Eth_Ip_StatusType Netc_Eth_Ip_DeleteIngressPortFilterTableEntry( const uint8 CtrlIndex,
797                                                                       uint32 *MatchedEntries,
798                                                                       uint32 IngressPortFilterEntryId
799                                                                     );
800 
801 
802 /**
803  * @brief This function dumps the Error Capture registers for a specific PCIE device (function).
804 * @param[in]  ctrlIndex                Index of the SI. Input Parameter
805 * @param[in]  function                 The PCIE function for which the error statistics are requested.Input Parameter
806 * @param[out] numberOfRegisters        This is an output parameter. The function returns the number of statistics registers that have been written in the Buffer parameter.
807 * @param[in]  siIndex                  This is an input parameter. Must be used only if he function is VSI or PSI. For PSI it must be set to 0 while for VSI must be set to the index of the SI.
808 *                                      For other functions(ENET, TIMER, SWITCH, EMDIO), this parameter is ignored.
809 * @param[in]  Buffers                  Array of pointers to Netc_Eth_Ip_ErrorCaptureRegisterInformation structures.
810         *                              Application MUST allocate enough space for the maximum number of
811         *                              registers that could have a function for Error detailing.
812         *                              Netc driver offers two macros: NETC_ETH_IP_MAX_UNCORRECTABLE_ERROR_REPORTING_STATISTICS_LENGTH for the maximum number of
813         *                              uncorrectable errors status registers among the PCIE function supported and
814         *                              NETC_ETH_IP_MAX_CORRECTABLE_ERROR_REPORTING_STATISTICS_LENGTH for the maximum number of
815         *                              correctable errors status registers among the PCIE function supported.
816  * @return void
817  */
818 void Netc_Eth_Ip_DumpErrorCapture (     const uint8 ctrlIdx,
819                                         const Netc_Eth_Ip_PcieFunction function,
820                                         uint8 *numberOfRegisters,
821                                         uint8 siIndex,
822                                         Netc_Eth_Ip_ErrorCaptureRegisterInformation* Buffers[]);
823 
824 /**
825  * @brief This function gets Timer Syncronization State function.
826 * @param[in]  CtrlIndex                Index of the SI. Input Parameter
827 * @param[out]  SyncState                 Timer Syncronization State
828 *
829 * @return          Netc_Eth_Ip_StatusType
830 * @retval          NETC_ETH_IP_STATUS_SUCCESS: successful.
831 * @retval          NETC_ETH_IP_STATUS_TIMEOUT: failed
832 */
833 Netc_Eth_Ip_StatusType Netc_Eth_Ip_GetSyncState( const uint8 CtrlIndex,
834                                                 boolean *SyncState);
835 /*
836  * @brief Query statistics Receive Flow Steering table entry.
837  *
838  * @param[in]   ctrlIndex Instance number
839  * @param[in]   RfsTableEntry   Rfs Entry for querying
840  * @param[out]  MatchedFramesNb    Number of matched frames
841  *
842  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
843  *                                others - error code from command ring
844  */
845 Netc_Eth_Ip_StatusType Netc_Eth_Ip_QueryStatisticsRfsTableEntry(const uint8 ctrlIndex,
846                                                                 uint8 RfsEntryIdx,
847                                                                  uint32 * MatchedFramesNb);
848 
849 /**
850  * @brief Query Receive Flow Steering table entry.
851  *
852  * @param[in]   ctrlIndex Instance number
853  * @param[in]   RfsTableEntry   Rfs Entry for querying
854  * @param[out]  RfsTableEntryAddr    Address of matched rfs entry
855  *
856  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
857  *                                others - error code from command ring
858  */
859 Netc_Eth_Ip_StatusType Netc_Eth_Ip_QueryRfsTableEntry(const uint8 ctrlIndex,
860                                                                 uint8 RfsEntryIdx,
861                                                                  uint32 * RfsTableEntryAddr);
862 
863 /**
864  * @brief Add Receive Flow Steering table entry.
865  *
866  * @param[in]   ctrlIndex Instance number
867  * @param[in]   RfsTableEntry   Rfs Entry to add
868  *
869  * @return Netc_Eth_Ip_StatusType NETC_ETH_IP_STATUS_SUCCESS - successfully operation
870  *                                others - error code from command ring
871  */
872 Netc_Eth_Ip_StatusType Netc_Eth_Ip_AddRfsTableEntry(const uint8 ctrlIndex,
873                                                      const Netc_Eth_Ip_RfsEntryType * RfsTableEntry);
874 
875 /**
876  * @brief This function sets SIs MAC address.
877 * @param[in]  CtrlIndex           Index of the current controller. Input Parameter
878 * @param[in]  SiId                Index of the SI which will have the MAC address changed. Input Parameter
879 * @param[in]  MacAddr             MAC address. Input Parameter
880 *
881 * @return          Netc_Eth_Ip_StatusType
882 * @retval          NETC_ETH_IP_STATUS_SUCCESS: successful.
883 * @retval          NETC_ETH_IP_STATUS_UNSUPPORTED: SI identified by ctrlIndex parameter has type different than PSI
884 */
885 Netc_Eth_Ip_StatusType Netc_Eth_Ip_SetSiPhysAddr( const uint8 CtrlIndex,
886                                                     const uint8 SiId,
887                                                     const uint8 *MacAddr);
888 
889 #define ETH_43_NETC_STOP_SEC_CODE
890 #include "Eth_43_NETC_MemMap.h"
891 
892 #ifdef __cplusplus
893 }
894 #endif
895 
896 /** @} */
897 
898 #endif
899