1 /*******************************************************************************
2  * Copyright 2020 Microchip Corporation.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  *
24  * PolarFire SoC Microcontroller Subsystem 10/100/1000 Mbps Ethernet MAC bare
25  * metal software driver public API.
26  *
27  */
28 
29 /*=========================================================================*//**
30   @mainpage PolarFire SoC MSS Ethernet MAC Bare Metal Driver.
31 
32   @section intro_sec Introduction
33     The PolarFire SoC Microcontroller Subsystem (MSS) includes two Gigabit
34     Ethernet MAC (GEM) hardware peripherals which support communications at
35     10/100/1000 Mbps.
36 
37     This software driver provides a set of functions for controlling the MSS
38     Ethernet MAC as part of a bare metal system where no operating system is
39     available. The drivers can be adapted for use as part of an operating
40     system, but the implementation of the adaptation layer between the driver
41     and the operating system's driver model is outside the scope of the driver.
42 
43     Each GEM consists of two Ethernet MAC devices, the pMAC (pre-emptable MAC)
44     and the eMAC (express MAC) which share a single network port. The MMSL
45     (Media Merge Sub Layer) is responsible for multiplexing the network port
46     between the two MACs. When IEEE 802.3br Frame pre-emption is enabled, the
47     transmission of packets via the pMAC can be interrupted by packets
48     transmitted via the eMAC. This can result in pMAC packets being split into
49     two or more segments. __Note:__ For this feature to work, both link partners
50     must support IEEE 802.3br Frame pre-emption.
51 
52     The GEMs support GMII/MII and SGMII connections to an external Ethernet PHY
53     device and the device driver can configure the devices at run time to select
54     which interface is active.
55 
56     The driver implements a sub-driver interface for configuring and controlling
57     the PHY and example drivers for a number of different PHYs are provided with
58     the driver.
59 
60     In addition to the standard Ethernet features, the GEMs support a number of
61     advanced features including:
62         - IEEE 1588 Time stamping support for PTPv1 and PTPv2.
63         - IEEE 802.1Qci Receive traffic policing.
64         - IEEE 802.1Qbb Priority based flow control.
65         - IEEE 802.1Q VLAN tagging.
66         - IEEE 802.1Qav Credit based traffic shaping.
67         - IEEE 802.1Qaz Bandwidth based transmit queueing.
68         - IEEE 802.1Qbv Time based priority queueing.
69         - IEEE 802.1CB Frame Redundancy and Elimination.
70         - IEEE 802.1AS Time stamping.
71         - IEEE 802.3br Frame pre-emption.
72         - TCP/UDP/IP Checksum offload.
73         - TCP/IP Large Send Offload.
74         - Advanced DMA system to provide high performance operation.
75 
76     The driver provides basic support for some of these features but more
77     advanced use of the features will require application level support and/or
78     modifications to the driver.
79 
80     __Note:__ In terms of the standard Ethernet support, this driver is modeled
81     on the MSS MAC Ethernet device drivers from previous generations of
82     Microchip FPGA SoC devices to facilitate porting of designs to the MPFS
83     platform. However unlike the previous MSS Ethernet MACs, the PolarFire SoC
84     MSS supports up to 4 MACs. Each GEM device has 1 x pMAC and 1 x eMAC, and so
85     most driver functions now have a parameter which identifies the specific GEM
86     device and MAC that the function should act upon. In addition, the pMACs
87     support multiple queues and so some functions require a queue identifier as
88     well.
89 
90   @section hw_dependencies Hardware Flow Dependencies
91     The configuration of all features of the MSS Ethernet MAC is covered by this
92     driver with the exception of the PolarFire SoC IOMUX configuration.
93     PolarFire SoC allows multiple non-concurrent uses of some external pins
94     through IOMUX configuration. This feature allows optimization of external
95     pin usage by assigning external pins for use by either the microprocessor
96     subsystem or the FPGA fabric. The MDIO signals are routed through IOMUXs to
97     the PolarFire SoC device external pins. The MDIO signals may also be routed
98     through IOMUXs to the PolarFire SoC FPGA fabric. The IOMUXs are configured
99     using the PolarFire SoC MSS configurator tool. You must ensure that the MSS
100     Ethernet MAC are enabled and configured in the PolarFire SoC MSS
101     configurator if you wish to use them. For more information on IOMUX, refer
102     to the I/O Configuration section of the PolarFire SoC Microprocessor
103     Subsystem (MSS) User's Guide.
104 
105     The base address, register addresses and interrupt number assignment for the
106     MSS Ethernet MAC are defined as constants in the PolarFire SoC HAL. You must
107     ensure that the latest PolarFire SoC HAL is included in the project settings
108     of the software tool chain used to build your project and that it is
109     generated into your project.
110 
111     The MSS Ethernet MAC supports the following selections for the PHY
112     interface:
113 
114     Table 1 PHY Interface
115 
116     ----------------------------------------------------------------------------
117     |PHY Type   | Value | Explanation                                          |
118     |-----------|-------|------------------------------------------------------|
119     |NULL_PHY   |   1   | There is no PHY device connected. This configuration |
120     |           |       | is used for testing where the GEM devices are cross  |
121     |           |       | connected through the fabric or via direct external  |
122     |           |       | links. This setting also supports local loopback     |
123     |           |       | operation.                                           |
124     |GMII       |   2   | MSS Ethernet MAC operates in GMII mode and interfaces|
125     |           |       | with a GMII PHY directly.                            |
126     |           |       | Maximum network speed is 1Gb.                        |
127     |TBI        |   4   | MSS Ethernet MAC operates in TBI mode using the PCS  |
128     |           |       | interface and the MSS in-built SGMII interface.      |
129     |           |       | Maximum network speed is 1Gb.                        |
130     |GMII_SGMII |   8   | MSS Ethernet MAC operates in GMII mode but the       |
131     |           |       | interface to the PHY is through an SGMII to GMII     |
132     |           |       | converter. This facilitates designs based on the G5  |
133     |           |       | SoC Emulation Platform.                              |
134     ----------------------------------------------------------------------------
135 
136   @section theory_op Theory of Operation
137     The MSS Ethernet MAC driver functions are grouped into the following
138     categories:
139         - __Initialization and configuration__
140         - __Transmit operations__
141         - __Receive operations__
142         - __Reading link status and statistics__
143         - __Feature support__
144 
145     @subsection init Initialization and Configuration
146     The MSS Ethernet MAC driver is initialized and configured by
147     calling the _MSS_MAC_init()_ function. The _MSS_MAC_init()_ function takes
148     as one of its parameters a pointer to a configuration data structure. This
149     data structure contains all the configuration information required to
150     initialize and configure the Ethernet MAC.
151     The MSS Ethernet MAC driver provides the _MSS_MAC_cfg_struct_def_init()_
152     function to initialize the configuration data structure entries to default
153     values. It is recommended to use this function to retrieve the default
154     configuration and then overwrite the defaults with the application specific
155     settings such as PHY address, PHY type, interface type, allowed link speeds,
156     link duplex mode and MAC address etc.
157 
158     The following functions are used as part of the initialization and
159     configuration process:
160         - _MSS_MAC_cfg_struct_def_init()_
161         - _MSS_MAC_init()_
162 
163     @subsection tx_ops Transmit Operations
164     The MSS Ethernet MAC driver transmit operations are interrupt driven. The
165     application must register a transmit call-back function with the driver
166     using the _MSS_MAC_set_tx_callback()_ function. This call-back function will
167     be called by the MSS Ethernet MAC driver every time a packet has been sent.
168     The application must call the _MSS_MAC_send_pkt()_ function every time it
169     wants to transmit a packet. The application must pass a pointer to the
170     buffer containing the packet to send. It is the application's responsibility
171     to manage the memory allocated to store the transmit packets. The MSS
172     Ethernet MAC driver only requires a pointer to the instance structure for
173     the desired MAC, a pointer to the buffer containing the packet, the queue
174     number and the packet size. The MSS Ethernet MAC driver will call the
175     transmit call-back function registered using the _MSS_MAC_set_tx_callback()_
176     function once a packet is sent. The transmit call-back function is supplied
177     by the application and can be used to, for example, release the memory used
178     to store the packet that was sent.
179 
180     The following functions are used as part of the transmit operations:
181         - _MSS_MAC_send_pkt()_
182         - _MSS_MAC_send_pkts()_
183         - _MSS_MAC_set_tx_callback()_
184 
185     @subsection rx_ops Receive Operations
186     The MSS Ethernet MAC driver receive operations are interrupt driven. The
187     application must first register a receive call-back function using the
188     _MSS_MAC_set_rx_callback()_ function. The application can then allocate
189     receive buffers to the MSS Ethernet MAC driver by calling the
190     _MSS_MAC_receive_pkt()_ function. This function can be called multiple times
191     to allocate more than one receive buffer. The MSS Ethernet MAC driver will
192     then call the receive call-back whenever a packet is received into one of
193     the receive buffers. It will hand back the receive buffer to the application
194     for packet processing. This buffer will not be reused by the MSS Ethernet
195     MAC driver unless it is re-allocated to the driver by a call to
196     _MSS_MAC_receive_pkt()_.
197 
198     The following functions are used as part of the receive operations:
199         - _MSS_MAC_receive_pkt()_
200         - _MSS_MAC_set_rx_callback()_
201 
202     @subsection stats Reading Status and Statistics
203     The MSS Ethernet MAC driver provides the following functions to retrieve the
204     current link status and statistics.
205         - _MSS_MAC_get_link_status()_
206         - _MSS_MAC_read_stat()_
207 
208     @subsection features Feature Support
209     The MSS Ethernet MAC driver provides the following functions to support on
210     the fly configuration and control of various features of the MSS
211     Ethernet MAC devices.
212         - _MSS_MAC_read_TSU()_
213         - _MSS_MAC_init_TSU()_
214         - _MSS_MAC_set_TSU_rx_mode()_
215         - _MSS_MAC_set_TSU_tx_mode()_
216         - _MSS_MAC_get_TSU_rx_mode()_
217         - _MSS_MAC_get_TSU_tx_mode()_
218         - _MSS_MAC_set_TSU_oss_mode()_
219         - _MSS_MAC_get_TSU_oss_mode()_
220         - _MSS_MAC_set_TSU_unicast_addr()_
221         - _MSS_MAC_get_TSU_unicast_addr()_
222         - _MSS_MAC_set_VLAN_only_mode()_
223         - _MSS_MAC_get_VLAN_only_mode()_
224         - _MSS_MAC_set_stacked_VLAN()_
225         - _MSS_MAC_get_stacked_VLAN()_
226         - _MSS_MAC_set_hash()_
227         - _MSS_MAC_get_hash()_
228         - _MSS_MAC_set_hash_mode()_
229         - _MSS_MAC_get_hash_mode()_
230         - _MSS_MAC_set_type_filter()_
231         - _MSS_MAC_get_type_filter()_
232         - _MSS_MAC_set_sa_filter()_
233         - _MSS_MAC_get_sa_filter()_
234         - _MSS_MAC_set_type_1_filter()_
235         - _MSS_MAC_get_type_1_filter()_
236         - _MSS_MAC_set_type_2_filter()_
237         - _MSS_MAC_get_type_2_filter()_
238         - _MSS_MAC_set_type_2_ethertype()_
239         - _MSS_MAC_get_type_2_ethertype()_
240         - _MSS_MAC_set_type_2_compare()_
241         - _MSS_MAC_get_type_2_compare()_
242         - _MSS_MAC_set_mmsl_mode()_
243         - _MSS_MAC_get_mmsl_mode()_
244         - _MSS_MAC_start_preemption_verify()_
245         - _MSS_MAC_get_mmsl_status()_
246         - _MSS_MAC_get_mmsl_stats()_
247         - _MSS_MAC_set_tx_cutthru()_
248         - _MSS_MAC_set_rx_cutthru()_
249         - _MSS_MAC_get_tx_cutthru()_
250         - _MSS_MAC_get_rx_cutthru()_
251         - _MSS_MAC_tx_enable()_
252         - _MSS_MAC_set_jumbo_frames_mode()_
253         - _MSS_MAC_get_jumbo_frames_mode()_
254         - _MSS_MAC_set_jumbo_frame_length()_
255         - _MSS_MAC_get_jumbo_frame_length()_
256         - _MSS_MAC_set_pause_frame_copy_to_mem()_
257         - _MSS_MAC_get_pause_frame_copy_to_mem()_
258 
259  *//*=========================================================================*/
260 #ifndef MSS_ETHERNET_MAC_H_
261 #define MSS_ETHERNET_MAC_H_
262 
263 #include <stdbool.h>
264 #include "drivers/mss_ethernet_mac/mss_ethernet_mac_types.h"
265 
266 #ifdef __cplusplus
267 extern "C" {
268 #endif
269 
270 /***************************************************************************//**
271  * Length of a MAC address
272  */
273 #define MSS_MAC_MAC_LEN (6)
274 
275 /***************************************************************************//**
276  *
277  * False/True, Disable/Enable values used in driver
278  */
279 #define MSS_MAC_DISABLE                     (0U)
280 #define MSS_MAC_ENABLE                      (1U)
281 
282 /***************************************************************************//**
283  * Driver API function return value definitions.
284  */
285 #define MSS_MAC_SUCCESS         MSS_MAC_ENABLE  /*!< @brief Simple success value */
286 #define MSS_MAC_FAILED          MSS_MAC_DISABLE /*!< @brief Simple failure value */
287 #define MSS_MAC_ERR_OK          (1)             /*!< @brief Success by another name */
288 #define MSS_MAC_ERR_NOT_DONE    (0)             /*!< @brief Previous packet send not complete yet */
289 #define MSS_MAC_ERR_TX_NOT_OK   (-1)            /*!< @brief Non specific TX failure */
290 #define MSS_MAC_ERR_TX_TIMEOUT  (-2)            /*!< @brief Packet send did not release queue after send */
291 #define MSS_MAC_ERR_TX_FAIL     (-3)            /*!< @brief Packet send failed with errors */
292 
293 /****************************************************************************//**
294   The following definitions are used with function _MSS_MAC_get_link_status()_ to
295   report the link status.
296  */
297 #define MSS_MAC_LINK_DOWN                   (0U)
298 #define MSS_MAC_LINK_UP                     (1U)
299 #define MSS_MAC_HALF_DUPLEX                 (0U)
300 #define MSS_MAC_FULL_DUPLEX                 (1U)
301 
302 /***************************************************************************//**
303  * Standard all 1s broadcast MAC address value
304  */
305 #define MSS_MAC_BROADCAST_MAC_ADDRESS       0xFFU,0xFFU,0xFFU,0xFFU,0xFFU,0xFFU
306 
307 /***************************************************************************//**
308  * Maximum packet size that the hardware supports
309  */
310 #define MSS_MAC_JUMBO_MAX (10240U)
311 
312 /***************************************************************************//**
313  * Maximum MAC frame size (packet size)
314  *
315  * This value should be defined based on the type of packets you intend to
316  * support. For normal packets a value of 1518 is appropriate.
317  *
318  * If the receive_1536_byte_frames bit of the Network Config register is set
319  * then the value 1536 is appropriate. This will be required if VLAN support is
320  * used.
321  *
322  * If Jumbo frame support is enabled by setting the jumbo_frames bit of the
323  * Network Config register, then a value up to 10240 bytes can be set.
324  *
325  * __Note:__ Default has size bumped up to support maximum jumbo packet size of
326  * 10,240 bytes. The value chosen should match that of the jumbo_max_length
327  * register if Jumbo frame support is enabled.
328  *
329  */
330 #if defined(MSS_MAC_USE_DDR)
331 #if MSS_MAC_USE_DDR == MSS_MAC_MEM_DDR
332 #define MSS_MAC_MAX_PACKET_SIZE                 MSS_MAC_JUMBO_MAX /* Smaller for Crypto and FIC tests */
333 #else
334 #define MSS_MAC_MAX_PACKET_SIZE                 (80U)
335 #endif
336 #else
337 #if (MSS_MAC_QUEUE_COUNT >= 2)
338 #define MSS_MAC_MAX_PACKET_SIZE                 MSS_MAC_JUMBO_MAX
339 #else
340 #define MSS_MAC_MAX_PACKET_SIZE                 MSS_MAC_JUMBO_MAX
341 #endif
342 #endif
343 
344 /***************************************************************************//**
345  * Calculate the RX Buffer size field value automatically by rounding
346  * _MSS_MAC_MAX_PACKET_SIZE_ up to nearest 64 bytes and dividing by 64.
347  */
348 #define MSS_MAC_RX_BUF_VALUE ((MSS_MAC_MAX_PACKET_SIZE + 63U) / 64U)
349 
350 /***************************************************************************//**
351   The definition below is provided to specify that the _MSS_MAC_init()_ function
352   should attempt to discover the address of the PHY connected to the MACs
353   management interface. It can be used with _mss_mac_cfg_t_ configuration
354   parameter _phy_addr_.
355 
356   __Note:__ To auto detect the PHY address, this drivers scans the valid MDIO
357   addresses starting from 0 looking for valid data. This should not be done if
358   more than 1 device is connected to the MDIO interface.
359 
360  */
361 #define MSS_MAC_AUTO_DETECT_PHY_ADDRESS     ((uint8_t)255U)
362 
363 /***************************************************************************//**
364  * Transmit and receive packet buffer sizes.
365  *
366  * __Note:__ The odd addition/division/multiplication sequence is to ensure the
367  * size is a multiple of 64 bits so that sequential buffers are 64 bit word
368  * aligned in case we are using time stamp support.
369  *
370  */
371 #define MSS_MAC_MAX_TX_BUF_SIZE       (((MSS_MAC_MAX_PACKET_SIZE + 7U) / 8U) * 8U)
372 #define MSS_MAC_MAX_RX_BUF_SIZE       (((MSS_MAC_MAX_PACKET_SIZE + 7U) / 8U) * 8U)
373 
374 /*******************************************************************************
375  * Defines for configuration parameters
376  */
377 /***************************************************************************//**
378  * Queue enable / disable.
379  *
380  *__Note:__ Queue 0 is always enabled
381  */
382 #define MSS_MAC_QUEUE_ENABLE                        MSS_MAC_ENABLE
383 #define MSS_MAC_QUEUE_DISABLE                       MSS_MAC_DISABLE
384 
385 /***************************************************************************//**
386  * FIFO error detection & correction enable / disable
387  */
388 #define MSS_MAC_ERR_DET_CORR_ENABLE                 MSS_MAC_ENABLE
389 #define MSS_MAC_ERR_DET_CORR_DISABLE                MSS_MAC_DISABLE
390 
391 /***************************************************************************//**
392  * Jumbo frame support enable / disable
393  *
394  * __Note:__ This enables support for the feature but the reception of jumbo
395  * frames still needs to be explicitly enabled via
396  * _MSS_MAC_set_jumbo_frames_mode()_
397  */
398 #define MSS_MAC_JUMBO_FRAME_ENABLE                  MSS_MAC_ENABLE
399 #define MSS_MAC_JUMBO_FRAME_DISABLE                 MSS_MAC_DISABLE
400 
401 /***************************************************************************//**
402  * Length field checking enable / disable
403  */
404 #define MSS_MAC_LENGTH_FIELD_CHECK_ENABLE           MSS_MAC_ENABLE
405 #define MSS_MAC_LENGTH_FIELD_CHECK_DISABLE          MSS_MAC_DISABLE
406 
407 /***************************************************************************//**
408  * Append CRC enable / disable
409  */
410 #define MSS_MAC_CRC_ENABLE                          MSS_MAC_ENABLE
411 #define MSS_MAC_CRC_DISABLE                         MSS_MAC_DISABLE
412 
413 /***************************************************************************//**
414  * Full duplex mode enable / disable
415  */
416 #define MSS_MAC_FULLDUPLEX_ENABLE                   MSS_MAC_ENABLE
417 #define MSS_MAC_FULLDUPLEX_DISABLE                  MSS_MAC_DISABLE
418 
419 /***************************************************************************//**
420  * Loopback mode enable / disable
421  */
422 #define MSS_MAC_LOOPBACK_ENABLE                     MSS_MAC_ENABLE
423 #define MSS_MAC_LOOPBACK_DISABLE                    MSS_MAC_DISABLE
424 
425 /***************************************************************************//**
426  * Receiver flow control enable / disable
427  */
428 #define MSS_MAC_RX_FLOW_CTRL_ENABLE                 MSS_MAC_ENABLE
429 #define MSS_MAC_RX_FLOW_CTRL_DISABLE                MSS_MAC_DISABLE
430 
431 /***************************************************************************//**
432  * Transmission flow control enable / disable
433  */
434 #define MSS_MAC_TX_FLOW_CTRL_ENABLE                 MSS_MAC_ENABLE
435 #define MSS_MAC_TX_FLOW_CTRL_DISABLE                MSS_MAC_DISABLE
436 
437 /***************************************************************************//**
438  * Default IPG/IFG value which results in the standard minimum IPG.
439  */
440 #define MSS_MAC_IPG_DEFVAL                          (0x00U)
441 
442 /***************************************************************************//**
443  * PHY clock divider values.
444  *
445  * __Note:__ The value used should not result in a clock frequency greater than
446  * 2.5MHz.
447  */
448 #define MSS_MAC_BY8_PHY_CLK                         (0U)
449 #define MSS_MAC_BY16_PHY_CLK                        (1U)
450 #define MSS_MAC_BY32_PHY_CLK                        (2U)
451 #define MSS_MAC_BY48_PHY_CLK                        (3U)
452 #define MSS_MAC_BY64_PHY_CLK                        (4U)
453 #define MSS_MAC_BY96_PHY_CLK                        (5U)
454 #define MSS_MAC_BY128_PHY_CLK                       (6U)
455 #define MSS_MAC_BY224_PHY_CLK                       (7U)
456 #if defined(TARGET_ALOE)
457 #define MSS_MAC_DEF_PHY_CLK                         MSS_MAC_BY224_PHY_CLK /*!< @brief For Aloe this is divide by 96, good for up to 560MHz */
458 #else
459 #define MSS_MAC_DEF_PHY_CLK                         MSS_MAC_BY96_PHY_CLK /*!< @brief For MPFS this is divide by 96, good for up to 240MHz */
460 #endif
461 
462 /***************************************************************************//**
463  * PHY addresse and register number limits.
464  */
465 #define MSS_MAC_PHYADDR_MAXVAL                      ( (uint8_t)(0x1FU) )
466 #define MSS_MAC_PHYREGADDR_MAXVAL                   ( (uint8_t)(0x1FU) )
467 
468 /***************************************************************************//**
469  * Maximum frame length default & maximum values.
470  */
471 #define MSS_MAC_MAXFRAMELEN_DEFVAL                  (0x00000600U)
472 #define MSS_MAC_MAXFRAMELEN_MAXVAL                  (0x00002800U)
473 
474 /***************************************************************************//**
475  * Options for link speed and duplex configuration for autonegotiation.
476  *
477  * These may be or'ed together to construct a set of speed/duplex options to
478  * allow. _MSS_MAC_ANEG_ALL_SPEEDS_ is the default and implies full
479  * autonegotiation.
480  */
481 #define MSS_MAC_ANEG_10M_FD             (0x00000001U)
482 #define MSS_MAC_ANEG_10M_HD             (0x00000002U)
483 #define MSS_MAC_ANEG_100M_FD            (0x00000004U)
484 #define MSS_MAC_ANEG_100M_HD            (0x00000008U)
485 #define MSS_MAC_ANEG_1000M_FD           (0x00000010U)
486 #define MSS_MAC_ANEG_1000M_HD           (0x00000020U)
487 #define MSS_MAC_ANEG_ALL_SPEEDS         (MSS_MAC_ANEG_10M_FD | MSS_MAC_ANEG_10M_HD | \
488                                          MSS_MAC_ANEG_100M_FD | MSS_MAC_ANEG_100M_HD | \
489                                          MSS_MAC_ANEG_1000M_FD | MSS_MAC_ANEG_1000M_HD)
490 
491 #if defined(TARGET_G5_SOC)
492 extern mss_mac_instance_t g_mac0;
493 extern mss_mac_instance_t g_mac1;
494 extern mss_mac_instance_t g_emac0;
495 extern mss_mac_instance_t g_emac1;
496 #endif
497 
498 #if defined(TARGET_ALOE)
499 extern mss_mac_instance_t g_mac0;
500 #endif
501 
502 /* Support for testing access to different memory areas */
503 #if defined(MSS_MAC_USE_DDR)
504 extern uint8_t *g_mss_mac_ddr_ptr;
505 #endif
506 
507 /***************************************************************************//**
508  * Specific Address Filter support definitions.
509  *
510  * These may be or'ed together to construct the control value for the
511  * _MSS_MAC_set_sa_filter()_ function. The value _MSS_MAC_SA_FILTER_DISABLE_ is
512  * used to indicate a filter should be disabled.
513  */
514 #define MSS_MAC_SA_FILTER_SOURCE     (0x0001U)
515 #define MSS_MAC_SA_FILTER_BYTE0      (0x0100U)
516 #define MSS_MAC_SA_FILTER_BYTE1      (0x0200U)
517 #define MSS_MAC_SA_FILTER_BYTE2      (0x0400U)
518 #define MSS_MAC_SA_FILTER_BYTE3      (0x0800U)
519 #define MSS_MAC_SA_FILTER_BYTE4      (0x1000U)
520 #define MSS_MAC_SA_FILTER_BYTE5      (0x2000U)
521 #define MSS_MAC_SA_FILTER_DISABLE    (0xFFFFU) /* Use this to signal we should disable filter */
522 
523 /***************************************************************************//**
524  * Type 2 Filter support data offset definitions. These determine the reference
525  * point used to convert the offset value into an absolute location within the
526  * frame.
527  */
528 #define MSS_MAC_T2_OFFSET_FRAME      (0U)
529 #define MSS_MAC_T2_OFFSET_ETHERTYPE  (1U)
530 #define MSS_MAC_T2_OFFSET_IP         (2U)
531 #define MSS_MAC_T2_OFFSET_TCP_UDP    (3U)
532 
533 
534 /**************************************************************************/
535 /* Public Function declarations                                           */
536 /**************************************************************************/
537 
538 /***************************************************************************//**
539   The _MSS_MAC_cfg_struct_def_init()_ function initializes a _mss_mac_cfg_t_
540   configuration data structure to default values. The default configuration uses
541   the NULL_PHY interface connected to a PHY at address 0x00 which is set to
542   auto-negotiate at all available speeds up to 1000Mbps. This default
543   configuration can then be used as parameter to _MSS_MAC_init()_. Typically,
544   the default configuration would be modified to suit the application before
545   being passed to _MSS_MAC_init()_.
546 
547   @param cfg
548     This parameter is a pointer to an _mss_mac_cfg_t_ data structure that will
549     be used as parameter to function _MSS_MAC_init()_.
550 
551   @return
552     This function does not return a value.
553 
554   Example:
555   The example below demonstrates the use of the _MSS_MAC_cfg_struct_def_init()_
556   function. It retrieves the default MAC configuration and modifies it to
557   connect through a VSC8757 SGMII Ethernet PHY at MII management interface
558   address 0x01. This example also demonstrates how to assign the device's MAC
559   address and force a 100Mbps full duplex link.
560   @code
561     mss_mac_cfg_t mac_config;
562 
563     MSS_MAC_cfg_struct_def_init(&mac_config);
564 
565     mac_config.interface_type = TBI;
566     config.phy_type = MSS_MAC_DEV_PHY_VSC8575;
567     config.phy_get_link_status = MSS_MAC_VSC8575_phy_get_link_status;
568     config.phy_init = MSS_MAC_VSC8575_phy_init;
569     config.phy_set_link_speed = MSS_MAC_VSC8575_phy_set_link_speed;
570     config.phy_extended_read = NULL_ti_read_extended_regs;
571     config.phy_extended_write = NULL_ti_write_extended_regs;
572     mac_config.phy_addr = 0x01;
573     mac_config.speed_duplex_select = MSS_MAC_ANEG_100M_FD;
574     mac_config.mac_addr[0] = 0xC0u;
575     mac_config.mac_addr[1] = 0xB1u;
576     mac_config.mac_addr[2] = 0x3Cu;
577     mac_config.mac_addr[3] = 0x88u;
578     mac_config.mac_addr[4] = 0x88u;
579     mac_config.mac_addr[5] = 0x88u;
580 
581     MSS_MAC_init(&g_mac0, &mac_config);
582   @endcode
583  */
584 void
585 MSS_MAC_cfg_struct_def_init
586 (
587     mss_mac_cfg_t * cfg
588 );
589 
590 /***************************************************************************//**
591   The _MSS_MAC_init()_ function initializes the Ethernet MAC hardware and driver
592   internal data structures. In addition to the MAC identifier, the
593   _MSS_MAC_init()_ function takes a pointer to a configuration data structure of
594   type _mss_mac_cfg_t_ as parameter. This configuration data structure contains
595   all the information required to configure the Ethernet MAC. The
596   _MSS_MAC_init()_ function initializes the descriptor rings and their pointers
597   to initial values. The _MSS_MAC_init()_ function enables DMA Rx packet
598   received and Tx packet sent interrupts. The configuration passed to the
599   _MSS_MAC_init()_ function specifies the type of interface used to connect the
600   Ethernet MAC and Ethernet PHY as well as the PHY type and PHY MII management
601   interface address. It also specifies the allowed link speed and duplex mode.
602   It is at this point that the application chooses if the link  speed and duplex
603   mode will be auto-negotiated with the link partner or forced to a specific
604   speed and duplex mode.
605 
606   @param this_mac
607     This parameter is a pointer to one of the global _mss_mac_instance_t_
608     structures which identifies the MAC that the function is to operate on.
609     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
610     and eMAC1.
611 
612   @param cfg
613     This parameter is a pointer to a data structure of type _mss_mac_cfg_t_
614     containing the Ethernet MAC's requested configuration. You must initialize
615     this data structure by first calling the _MSS_MAC_cfg_struct_def_init()_
616     function to fill the configuration data structure with default values. You
617     can then overwrite some of the default settings with the ones specific to
618     your application before passing this data structure as parameter to the call
619     to the _MSS_MAC_init()_ function. You must at a minimum overwrite the
620     mac_addr[6] array of the configuration data structure to contain a unique
621     value used as the device's MAC address.
622 
623   @return
624     This function does not return a value.
625 
626   Example:
627   @code
628     mss_mac_cfg_t cfg;
629 
630     MSS_MAC_cfg_struct_def_init(&cfg);
631 
632     cfg.mac_addr[0] = 0xC0u;
633     cfg.mac_addr[1] = 0xB1u;
634     cfg.mac_addr[2] = 0x3Cu;
635     cfg.mac_addr[3] = 0x88u;
636     cfg.mac_addr[4] = 0x88u;
637     cfg.mac_addr[5] = 0x88u;
638 
639     MSS_MAC_init(&g_mac0, &cfg);
640   @endcode
641  */
642 void
643 MSS_MAC_init
644 (
645     mss_mac_instance_t *this_mac,
646     mss_mac_cfg_t * cfg
647 );
648 
649 /***************************************************************************//**
650   The _MSS_MAC_update_hw_address()_ function updates the MAC address for the
651   Ethernet MAC. In addition to the MAC identifier, the
652   _MSS_MAC_update_hw_address()_ function takes a pointer to a configuration data
653   structure of type _mss_mac_cfg_t_ as a parameter. This configuration data
654   structure contains all the information required to configure the Ethernet MAC
655   including the required MAC address. The _MSS_MAC_update_hw_address()_ function
656   reconfigures the Ethernet MAC using the MAC address contained in the structure
657   pointed to by cfg.
658 
659   This function should only be called after the MSS Ethernet MAC has been
660   initialized as it does not perform any other initialization/configuration.
661 
662   @param this_mac
663     This parameter is a pointer to one of the global _mss_mac_instance_t_
664     structures which identifies the MAC that the function is to operate on.
665     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
666     and eMAC1.
667 
668   @param cfg
669     This parameter is a pointer to a data structure of _type mss_mac_cfg_t_
670     containing the Ethernet MAC's requested configuration.
671     For this function, the only field of importance is the _mac_addr_ array, all
672     other fields are ignored.
673 
674   @return
675     This function does not return a value.
676 
677   Example:
678   @code
679     mss_mac_cfg_t cfg;
680 
681     MSS_MAC_cfg_struct_def_init(&cfg);
682 
683     cfg.mac_addr[0] = 0xC0u;
684     cfg.mac_addr[1] = 0xB1u;
685     cfg.mac_addr[2] = 0x3Cu;
686     cfg.mac_addr[3] = 0x88u;
687     cfg.mac_addr[4] = 0x88u;
688     cfg.mac_addr[5] = 0x88u;
689 
690     MSS_MAC_init(&g_mac_0, &cfg);
691 
692     ....
693 
694     cfg.mac_addr[0] = 0xC0u;
695     cfg.mac_addr[1] = 0xB1u;
696     cfg.mac_addr[2] = 0x3Cu;
697     cfg.mac_addr[3] = 0x88u;
698     cfg.mac_addr[4] = 0x88u;
699     cfg.mac_addr[5] = 0x89u;
700 
701     MSS_MAC_update_hw_address(&g_mac0, &cfg);
702   @endcode
703  */
704 void
705 MSS_MAC_update_hw_address
706 (
707     mss_mac_instance_t *this_mac,
708     const mss_mac_cfg_t * cfg
709 );
710 
711 /***************************************************************************//**
712   The _MSS_MAC_set_tx_callback()_ function registers the function that will be
713   called by the Ethernet MAC driver when a packet has been sent on the specified
714   queue.
715 
716   @param this_mac
717     This parameter is a pointer to one of the global _mss_mac_instance_t_
718     structures which identifies the MAC that the function is to operate on.
719     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
720     and eMAC1.
721 
722   @param queue_no
723     This parameter identifies the queue which this callback function will
724     service. For single queue devices, this should be set to 0 for compatibility
725     purposes.
726 
727   @param tx_complete_handler
728     This parameter is a pointer to the function that will be called when a
729     packet is sent by the Ethernet MAC on the selected queue.
730 
731   @return
732     This function does not return a value.
733 
734  */
735 void MSS_MAC_set_tx_callback
736 (
737     mss_mac_instance_t *this_mac,
738     uint32_t queue_no,
739     mss_mac_transmit_callback_t tx_complete_handler
740 );
741 
742 /***************************************************************************//**
743   The _MSS_MAC_set_rx_callback()_ function registers the function that will be
744   called by the Ethernet MAC driver when a packet is received.
745 
746   @param this_mac
747     This parameter is a pointer to one of the global _mss_mac_instance_t_
748     structures which identifies the MAC that the function is to operate on.
749     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
750     and eMAC1.
751 
752   @param queue_no
753     This parameter identifies the queue which this callback function will
754     service. For single queue devices this should be set to 0 for compatibility
755     purposes.
756 
757   @param rx_callback
758     This parameter is a pointer to the function that will be called when the a
759     packet is received by Ethernet MAC on the selected queue.
760 
761   @return
762     This function does not return a value.
763 
764   Example:
765   The example below demonstrates the use of the _MSS_MAC_set_rx_callback()_
766   function. The _init()_ function calls the _MSS_MAC_set_rx_callback()_ function
767   to register the _rx_callback()_ receive callback function with the Ethernet
768   MAC driver. The _MSS_MAC_receive_pkt()_ function is then called to assign the
769   rx_buffer to an Ethernet MAC descriptor for packet reception. The
770   _rx_callback()_ function will be called by the Ethernet MAC driver once a
771   packet has been received into _rx_buffer_. The _rx_callback()_ function calls
772   the _process_rx_packet()_ application function to process the received packet
773   then calls _MSS_MAC_receive_pkt()_ to reallocate rx_buffer to receive another
774   packet. The _rx_callback()_ function will be called again every time a packet
775   is received to process the received packet and reallocate _rx_buffer_ for
776   packet reception.
777 
778   @code
779     uint8_t rx_buffer[MSS_MAC_MAX_RX_BUF_SIZE];
780 
781     void rx_callback
782     (
783         void *this_mac,
784         uint32_t queue_no,
785         uint8_t * p_rx_packet,
786         uint32_t pckt_length,
787         mss_mac_rx_desc_t *cdesc,
788         void * caller_info
789     )
790     {
791         process_rx_packet(p_rx_packet, pckt_length);
792         MSS_MAC_receive_pkt((mss_mac_instance_t *)this_mac, queue_no,
793                             p_rx_packet, caller_info, MSS_MAC_INT_ENABLE);
794     }
795 
796     void init(void)
797     {
798         MSS_MAC_set_rx_callback(rx_callback);
799         MSS_MAC_receive_pkt(&g_mac0, 0, rx_buffer, (void *)0, MSS_MAC_INT_ARM);
800     }
801   @endcode
802  */
803 void MSS_MAC_set_rx_callback
804 (
805     mss_mac_instance_t *this_mac,
806     uint32_t queue_no,
807     mss_mac_receive_callback_t rx_callback
808 );
809 
810 /***************************************************************************//**
811   The _MSS_MAC_change_speed()_ function sets the speed and duplex mode for the
812   link and if autonegotiation is selected as the speed mode, also sets the speed
813   and duplex options to advertise.
814 
815   @param this_mac
816     This parameter is a pointer to one of the global _mss_mac_instance_t_
817     structures which identifies the MAC that the function is to operate on.
818     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
819     and eMAC1.
820 
821   @param speed_duplex_select
822     This parameter identifies the speed and duplex options to advertise to the
823     link partner if autonegotiation is selected as the speed mode.
824 
825   @param speed_mode
826     This parameter selects between autonegotiation and one of the six speed and
827     duplex options. Valid values are:
828 
829      - _MSS_MAC_SPEED_AN_
830      - _MSS_MAC_10_HDX_
831      - _MSS_MAC_10_FDX_
832      - _MSS_MAC_100_HDX_
833      - _MSS_MAC_100_FDX_
834      - _MSS_MAC_1000_HDX_
835      - _MSS_MAC_1000_FDX_
836 
837     if _MSS_MAC_SPEED_AN_ is selected when previously there was a static speed
838     selection or if the autonegotiation advertisement select is changed then an
839     autonegotiation operation is kicked off via the PHY which may cause
840     temporary link loss.
841 
842     __Note:__ Selecting _MSS_MAC_1000_HDX_ or _MSS_MAC_1000_FDX_ is not
843     recommended, if fixed 1G operation is required, the recommended approach is
844     to use the _MSS_MAC_SPEED_AN_ option as the PHY and/or link partner may not
845     be able to honor the request otherwise.
846  */
847 void MSS_MAC_change_speed
848 (
849     mss_mac_instance_t *this_mac, uint32_t speed_duplex_select, mss_mac_speed_mode_t speed_mode
850 );
851 
852 /***************************************************************************//**
853   The _MSS_MAC_send_pkt()_ function initiates the transmission of a packet. It
854   places the buffer containing the packet to send into one of the Ethernet MAC's
855   transmit descriptors.
856 
857   This function is non-blocking. It will return immediately without waiting for
858   the packet to be sent. The Ethernet MAC driver indicates that the packet is
859   sent by calling the transmit completion handler registered by a call to
860   _MSS_MAC_set_tx_callback()_.
861 
862   This function waits for all active transmission(s) on all queues to complete
863   before initiating a new transmission.
864 
865   Some of the error responses for this function refer to issues with the
866   previous transmission operation and it may be appropriate to retry the current
867   request in that case.
868 
869   @param this_mac
870     This parameter is a pointer to one of the global _mss_mac_instance_t_
871     structures which identifies the MAC that the function is to operate on.
872     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
873     and eMAC1.
874 
875   @param queue_no
876     This parameter identifies the queue to which this transmit operation
877     applies. For single queue devices this should be set to 0 for compatibility
878     purposes.
879 
880   @param tx_buffer
881     This parameter is a pointer to the buffer containing the packet to send.
882 
883   @param tx_length
884     This parameter specifies the length in bytes of the packet to send.
885 
886   @param p_user_data
887     This parameter is a pointer to an optional application defined data
888     structure. Its usage is left to the application. It is intended to help the
889     application manage memory allocated to store packets. The Ethernet MAC
890     driver does not make use of this pointer. The Ethernet MAC driver will pass
891     back this pointer to the application as part of the call to the transmit
892     completion handler registered by the application.
893 
894   @return
895     This function returns the following values:
896 
897      - ___MSS_MAC_ERR_OK___ on successfully launching the packet.
898      - ___MSS_MAC_ERR_NOT_DONE___ if the previous packet has not finished
899           sending.
900      - ___MSS_MAC_ERR_NOT_OK___ for general errors.
901      - ___MSS_MAC_ERR_TX_TIMEOUT___ If the previous packet has not released the
902           queue buffers after the MAC completes the send.
903      - ___MSS_MAC_ERR_TX_FAIL___ If the previous packet has not released the
904           queue buffers after the MAC completes the send and there is an error
905           flagged in the tx descriptor.
906 
907   Example:
908   This example demonstrates the use of the _MSS_MAC_send_pkt()_ function. The
909   application registers the _tx_complete_callback()_ transmit completion
910   callback function with the Ethernet MAC driver by a call to
911   _MSS_MAC_set_tx_callback()_. The application dynamically allocates memory for
912   an application defined _packet_t_ data structure, builds a packet and calls
913   _send_packet()_. The _send_packet()_ function extracts the pointer to the
914   buffer containing the data to transmit and its length from the _tx_packet_
915   data structure and passes these to _MSS_MAC_send_pkt()_. It also passes the
916   pointer to _tx_packet_ as the _p_user_data_ parameter. The Ethernet MAC driver
917   calls _tx_complete_callback()_ once the packet is sent. The
918   _tx_complete_callback()_ function uses _p_user_data_, which points to
919   _tx_packet_, to release memory allocated by the application to store the
920   transmit packet.
921   @code
922 
923     void tx_complete_handler(void *this_mac, uint32_t queue_no,
924                              mss_mac_tx_desc_t *cdesc, void * caller_info);
925 
926     void init(void)
927     {
928         MSS_MAC_set_tx_callback(tx_complete_handler);
929     }
930 
931     void tx_complete_handler(void *this_mac, uint32_t queue_no,
932                              mss_mac_tx_desc_t *cdesc, void * caller_info)
933     {
934         release_packet_memory(caller_info);
935     }
936 
937     void send_packet(app_packet_t * packet)
938     {
939         MSS_MAC_send_pkt(void *this_mac, 0, packet->buffer, packet->length, packet);
940     }
941 
942   @endcode
943  */
944 int32_t
945 MSS_MAC_send_pkt
946 (
947     mss_mac_instance_t *this_mac,
948     uint32_t queue_no,
949     uint8_t const * tx_buffer,
950     uint32_t tx_length,
951     void * p_user_data
952 );
953 
954 
955 /***************************************************************************//**
956   The _MSS_MAC_send_pkts()_ function initiates the transmission of one or more
957   packets on one or more queues. It initialises all the required transmit queues
958   and sets the transmit operation in motion.
959 
960   Due to the requirement to keep an unused descriptor at the end of the
961   per-queue descriptor chains, this function will append at most
962   _MSS_MAC_TX_RING_SIZE_ - 1 packets to any queue. Any packets above this limit
963   will be silently ignored.
964 
965   This function is non-blocking. It will return immediately without waiting for
966   the packets to be sent. The Ethernet MAC driver indicates that each packet is
967   sent by calling the transmit completion handler registered by a call to
968   _MSS_MAC_set_tx_callback()_.
969 
970   This function waits for all active transmissions on all queues to complete
971   before initiating a new transmission.
972 
973   Some of the error responses for this function refer to issues with the
974   previous transmission operation and it may be appropriate to retry the current
975   request in that case.
976 
977   @param this_mac
978     This parameter is a pointer to one of the global _mss_mac_instance_t_
979     structures which identifies the MAC that the function is to operate on.
980     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
981     and eMAC1.
982 
983   @param queue_mask
984     This parameter identifies which queues it is intended to transmit from so
985     that the driver can mask the appropriate queue interrupts. Queue 0 is always
986     assumed to be masked as the transmit operation must write to the queue 0
987     descriptor register even when queue 0 is not being used.
988 
989     queue_mask indicates the queues which may be involved so that we can
990     properly handle ISR vs normal calling.
991 
992     Set the mask to 0x0000000F to indicate all queues if there is any
993     uncertainty.
994 
995     Set the mask to 0xFFFFFFF0 to indicate we are being called from a GEM ISR
996     context.
997 
998     For single queue devices this should be set to 0 for compatibility
999     purposes.
1000 
1001   @param p_packets
1002     This parameter is a pointer to the list of packets to send. The list
1003     consists of a sequence of _mss_mac_tx_pkt_info_t_ structures with the last
1004     entry having a length field of 0.
1005 
1006   @return
1007     This function returns the following values:
1008 
1009      - ___MSS_MAC_ERR_OK___ on successfully launching the packet.
1010      - ___MSS_MAC_ERR_NOT_DONE___ if the previous packet has not finished
1011           sending.
1012      - ___MSS_MAC_ERR_NOT_OK___ for general errors.
1013      - ___MSS_MAC_ERR_TX_TIMEOUT___ If the previous packet has not released the
1014           queue buffers after the MAC completes the send.
1015      - ___MSS_MAC_ERR_TX_FAIL___ If the previous packet has not released the
1016           queue buffers after the MAC completes the send and there is an error
1017           flagged in the tx descriptor.
1018 
1019   Example:
1020   This example demonstrates the use of the _MSS_MAC_send_pkts()_ function. The
1021   application builds a list of 10 arp packets over multiple queues and then
1022   calls _MSS_MAC_send_pkts()_ to transmit them in one go.
1023 
1024   @code
1025 
1026     int32_t send_arps()
1027     {
1028         int32_t tx_status;
1029         mss_mac_tx_pkt_info_t packet_array[11];
1030         int count;
1031 
1032         for(count = 0; count != 10; count++)
1033         {
1034             packet_array[count].tx_buffer   = tx_pak_arp;
1035             packet_array[count].length      = sizeof(tx_pak_arp);
1036             packet_array[count].queue_no    = count % 4;
1037             packet_array[count].p_user_data = (void *)0;
1038         }
1039 
1040         packet_array[count].tx_buffer   = (void *)0; // End of list
1041         packet_array[count].length      = 0;
1042         packet_array[count].queue_no    = 0;
1043         packet_array[count].p_user_data = (void *)0;
1044 
1045         memcpy(&tx_pak_arp[6], g_test_mac->mac_addr, 6);
1046         tx_status = MSS_MAC_send_pkts(g_test_mac, 1, packet_array);
1047     }
1048 
1049   @endcode
1050  */
1051 int32_t
1052 MSS_MAC_send_pkts
1053 (
1054     mss_mac_instance_t    *this_mac,
1055     uint32_t               queue_mask,
1056     mss_mac_tx_pkt_info_t *p_packets
1057 );
1058 
1059 #if defined(MSS_MAC_SPEED_TEST)
1060 /***************************************************************************//**
1061  * Non standard function for network saturation speed tests. Not for normal use.
1062  */
1063 int32_t
1064 MSS_MAC_send_pkts_fast
1065 (
1066     mss_mac_instance_t    *this_mac,
1067     mss_mac_tx_desc_t *descriptors,
1068     uint32_t tx_count
1069 );
1070 #endif
1071 
1072 /***************************************************************************//**
1073   The _MSS_MAC_receive_pkt()_ function assigns a buffer to one of  the Ethernet
1074   MAC's receive descriptors. The receive buffer specified as parameter will be
1075   used to receive one single packet. The receive buffer will be handed back to
1076   the application via a call to the receive callback function assigned through a
1077   call to _MSS_MAC_set_rx_callback()_. The _MSS_MAC_receive_pkt()_ function will
1078   need to be called again pointing to the same buffer if more packets are to be
1079   received into this same buffer after the packet has been processed by the
1080   application.
1081 
1082   The _MSS_MAC_receive_pkt()_ function is non-blocking. It will return
1083   immediately and does not wait for a packet to be received. The application
1084   needs to implement a receive callback function to be notified that a packet
1085   has been received.
1086 
1087   The _p_user_data_ parameter can be optionally used to point to a memory
1088   management data structure managed by the application.
1089 
1090   @param this_mac
1091     This parameter is a pointer to one of the global _mss_mac_instance_t_
1092     structures which identifies the MAC that the function is to operate on.
1093     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1094     and eMAC1.
1095 
1096   @param queue_no
1097     This parameter identifies the queue to which this transmit operation
1098     applies. For single queue devices this should be set to 0 for compatibility
1099     purposes.
1100 
1101   @param rx_pkt_buffer
1102     This parameter is a pointer to a memory buffer. It points to the memory that
1103     will be assigned to one of the Ethernet MAC's receive descriptors. It must
1104     point to a buffer large enough to contain the largest possible packet.
1105 
1106   @param p_user_data
1107     This parameter is intended to help the application manage memory. Its usage
1108     is left to the application. The Ethernet MAC driver does not make use of
1109     this pointer. The Ethernet MAC driver will pass this pointer back to the
1110     application as part of the call to the application's receive callback
1111     function to help the application associate the received packet with the
1112     memory it allocated prior to the call to _MSS_MAC_receive_pkt()_.
1113 
1114   @param enable
1115     This parameter controls the enabling of the Ethernet MAC interrupt. If set
1116     to _MSS_MAC_INT_DISABLE_, the interrupt is left disabled by this function.
1117     If set to _MSS_MAC_INT_ENABLE_, the interrupt is enabled on return from this
1118     function. This allows a series of packet buffers to be assigned without
1119     there being any modifications to the internal packet buffer tables. To
1120     achieve this, enable should be _MSS_MAC_INT_DISABLE_ for all but the last
1121     call to the function. When allocating a chain of buffers, the last call to
1122     _MSS_MAC_send_pkt()_ should use a value of _MSS_MAC_INT_ARM_ to set up the
1123     RX interrupt for the first time.
1124 
1125   @return
1126     This function returns 1 on successfully assigning the buffer to a receive
1127     descriptor. It returns 0 otherwise.
1128 
1129   Example:
1130   The example below demonstrates the use of the _MSS_MAC_receive_pkt()_ function
1131   to handle packet reception using two receive buffers. The _init()_ function
1132   calls the _MSS_MAC_set_rx_callback()_ function to register the _rx_callback()_
1133   receive callback function with the Ethernet MAC driver. The
1134   _MSS_MAC_receive_pkt()_ function is then called twice to assign _rx_buffer_1_
1135   and _rx_buffer_2_ to Ethernet MAC descriptors for packet reception. The
1136   _rx_callback_ function will be called by the Ethernet MAC driver once a packet
1137   has been received into one of the receive buffers. The _rx_callback()_
1138   function calls the _process_rx_packet()_ application function to process the
1139   received packet then calls _MSS_MAC_receive_pkt()_ to reallocate the receive
1140   buffer to receive another packet. The _rx_callback()_ function will be called
1141   again every time a packet is received to process the received packet and
1142   reallocate _rx_buffer_ for packet reception.
1143 
1144   __Note:__ The use of the _p_user_data parameter_ to handle the buffer
1145   reassignment to the Ethernet MAC as part of the _rx_callback()_ function. This
1146   is a simplistic use of _p_user_data_. It is more likely that _p_user_data_
1147   would be useful to keep track of a pointer to a TCP/IP stack packet container
1148   data structure dynamically allocated. In this more complex use case, the first
1149   parameter of _MSS_MAC_receive_pkt()_ would point to the actual receive buffer
1150   and the second parameter would point to a data structure used to free the
1151   receive buffer memory once the packet has been consumed by the TCP/IP stack.
1152 
1153   @code
1154     uint8_t rx_buffer_1[MSS_MAC_MAX_RX_BUF_SIZE];
1155     uint8_t rx_buffer_2[MSS_MAC_MAX_RX_BUF_SIZE];
1156 
1157     void rx_callback
1158     (
1159         void *this_mac,
1160         uint32_t queue_no,
1161         uint8_t * p_rx_packet,
1162         uint32_t pckt_length,
1163         mss_mac_rx_desc_t *cdesc,
1164         void * caller_info
1165     )
1166     {
1167         process_rx_packet(p_rx_packet, pckt_length);
1168         MSS_MAC_receive_pkt((mss_mac_instance_t *)this_mac, queue_no,
1169                             p_rx_packet, caller_info, MSS_MAC_INT_ENABLE);
1170     }
1171 
1172     void init(void)
1173     {
1174         MSS_MAC_set_rx_callback(&g_mac_0, 0, rx_callback);
1175         MSS_MAC_receive_pkt(&g_mac_0, 0, rx_buffer_1, (void *)rx_buffer_1,
1176                             MSS_MAC_INT_DISABLE);
1177         MSS_MAC_receive_pkt(&g_mac_0, 0, rx_buffer_2, (void *)rx_buffer_2,
1178                             MSS_MAC_INT_ARM);
1179     }
1180   @endcode
1181  */
1182 uint8_t
1183 MSS_MAC_receive_pkt
1184 (
1185     mss_mac_instance_t *this_mac,
1186     uint32_t queue_no,
1187     uint8_t * rx_pkt_buffer,
1188     void * p_user_data,
1189     mss_mac_rx_int_ctrl_t enable
1190 );
1191 
1192 
1193 #if defined MSS_MAC_UNH_TEST
1194   /***************************************************************************//**
1195    * Non standard function for network saturation speed tests. Not for normal use.
1196    */
1197 void
1198 MSS_MAC_receive_pkt_isr
1199 (
1200   mss_mac_instance_t *this_mac
1201 );
1202 #endif
1203 
1204 
1205 /***************************************************************************//**
1206   The _MSS_MAC_get_link_status()_ function retrieves the status of the link from
1207   the Ethernet PHY. It returns the current state of the Ethernet link. The speed
1208   and duplex mode of the link is also returned via the two pointers passed as
1209   parameter if the link is up, if the link is not up then these values willl not
1210   be updated.
1211 
1212   This function also adjusts the Ethernet MAC's internal configuration if some
1213   of the link characteristics have changed since the previous call to this
1214   function. Calling this function periodically is important for maintaining the
1215   link operation.
1216 
1217   @param this_mac
1218     This parameter is a pointer to one of the global _mss_mac_instance_t_
1219     structures which identifies the MAC that the function is to operate on.
1220     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1221     and eMAC1.
1222 
1223   @param speed
1224     This parameter is a pointer to variable of type _mss_mac_speed_t_ where the
1225     current link speed will be stored if the link is up. This variable is not
1226     updated if the link is down.
1227 
1228     This parameter can be set to zero if the caller does not need to find out
1229     the link speed.
1230 
1231   @param fullduplex
1232     This parameter is a pointer to an unsigned character where the current link
1233     duplex mode will be stored if the link is up. This variable is not updated
1234     if the link is down.
1235 
1236     This parameter can be set to zero if the caller does not need to find out
1237     the link duplex.
1238 
1239   @return
1240     This function returns 1 if the link is up. It returns 0 if the link is down.
1241 
1242   Example:
1243   @code
1244     uint8_t link_up;
1245     mss_mac_speed_t speed;
1246     uint8_t full_duplex
1247     link_up = MSS_MAC_get_link_status(&gmac_0, &speed, &full_duplex);
1248   @endcode
1249  */
1250 uint8_t MSS_MAC_get_link_status
1251 (
1252     const mss_mac_instance_t *this_mac,
1253     mss_mac_speed_t * speed,
1254     uint8_t * fullduplex
1255 );
1256 
1257 
1258 /***************************************************************************//**
1259   The _MSS_MAC_read_stat()_  function reads the transmit and receive statistics
1260   of the selected Ethernet MAC. This function can be used to read one of 26
1261   receive statistics and 20 transmitter statistics as defined in the
1262   _mss_mac_stat_t_ enumeration.
1263 
1264   Reading a statistics value automatically zeroes the associated statistics
1265   count register. If a statistics counter reaches its maximum value, it will not
1266   roll over to 0 so it is important to collect the statistics regularly if you
1267   wish to keep an accurate account of the statistics.
1268 
1269   @param this_mac
1270     This parameter is a pointer to one of the global _mss_mac_instance_t_
1271     structures which identifies the MAC that the function is to operate on.
1272     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1273     and eMAC1.
1274 
1275   @param stat
1276     This parameter of type _mss_mac_stat_t_ identifies the statistic that will
1277     be read.
1278 
1279   @return
1280     This function returns the value of the requested statistic.
1281 
1282   Example:
1283   @code
1284     uint64_t tx_pkts_cnt = 0;
1285 
1286     ...
1287 
1288     tx_pkts_cnt += MSS_MAC_read_stat(FRAMES_TXED_OK);
1289   @endcode
1290  */
1291 uint32_t
1292 MSS_MAC_read_stat
1293 (
1294     const mss_mac_instance_t *this_mac,
1295     mss_mac_stat_t stat
1296 );
1297 
1298 /***************************************************************************//**
1299   @brief
1300     The _MSS_MAC_clear_statistics()_ function clears all the statistics counter
1301     registers for the selected MAC.
1302 
1303   @param this_mac
1304     This parameter is a pointer to one of the global _mss_mac_instance_t_
1305     structures which identifies the MAC that the function is to operate on.
1306     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1307     and eMAC1.
1308 
1309   @return
1310     This function does not return a value.
1311  */
1312 void MSS_MAC_clear_statistics
1313 (
1314     const mss_mac_instance_t *this_mac
1315 );
1316 
1317 /***************************************************************************//**
1318   The _MSS_MAC_read_phy_reg()_ function reads the Ethernet PHY register
1319   specified as parameter. It uses the MII management interface to communicate
1320   with the Ethernet PHY. This function is used by the Ethernet PHY drivers
1321   provided alongside the Ethernet MAC driver. You normally only need to use this
1322   function if writing your own Ethernet PHY driver.
1323 
1324   This function always accesses the pMAC registers as the same PHY is shared by
1325   both eMAC and pMAC and only has an MDIO connection to the pMAC.
1326 
1327   @param this_mac
1328     This parameter is a pointer to one of the global _mss_mac_instance_t_
1329     structures which identifies the MAC that the function is to operate on.
1330     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1331     and eMAC1.
1332 
1333   @param phyaddr
1334     This parameter is the 5-bit address of the Ethernet PHY on the MII
1335     management interface. This address is typically defined through Ethernet PHY
1336     hardware configuration signals. Please refer to the Ethernet PHY's datasheet
1337     for details of how this address is assigned.
1338 
1339   @param regaddr
1340     This parameter is the address of the Ethernet PHY register to be read. This
1341     address is the offset of the register within the Ethernet PHY's register
1342     map.
1343 
1344   @return
1345     This function returns the 16-bit value of the requested register.
1346 
1347   Example:
1348   @code
1349     #include "phy.h"
1350     uint16_t read_phy_status(uint8_t phy_addr)
1351     {
1352         uint16_t phy_status = MSS_MAC_read_phy_reg(&g_mac0, phy_addr, MII_BMSR);
1353         return phy_status;
1354     }
1355   @endcode
1356  */
1357 uint16_t
1358 MSS_MAC_read_phy_reg
1359 (
1360     const mss_mac_instance_t *this_mac,
1361     uint8_t phyaddr,
1362     uint8_t regaddr
1363 );
1364 
1365 /***************************************************************************//**
1366   The _MSS_MAC_write_phy_reg()_ function writes a 16-bit value to the specified
1367   Ethernet PHY register. It uses the MII management interface to communicate
1368   with the Ethernet PHY. This function is used by the Ethernet PHY drivers
1369   provided alongside the Ethernet MAC driver. You normally only need to use this
1370   function if writing your own Ethernet PHY driver.
1371 
1372   This function always accesses the pMAC registers as the same PHY is shared by
1373   both eMAC and pMAC and only has an MDIO connection to the pMAC.
1374 
1375   @param this_mac
1376     This parameter is a pointer to one of the global _mss_mac_instance_t_
1377     structures which identifies the MAC that the function is to operate on.
1378     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1379     and eMAC1.
1380 
1381   @param phyaddr
1382     This parameter is the 5-bit address of the Ethernet PHY on the MII
1383     management interface. This address is typically defined through Ethernet PHY
1384     hardware configuration signals. Please refer to the Ethernet PHY's datasheet
1385     for details of how this address is assigned.
1386 
1387   @param regaddr
1388     This parameter is the address of the Ethernet register that will be written
1389     to. This address is the offset of the register within the Ethernet PHY's
1390     register map.
1391 
1392   @param regval
1393     The parameter is the 16-bit value that will be written into the specified
1394     PHY register.
1395 
1396   @return
1397     This function does not return a value.
1398 
1399   Example:
1400   @code
1401     #include "mss_ethernet_sgmii_phy.h"
1402     #include "phy.h"
1403 
1404     void reset_sgmii_phy(void)
1405     {
1406         MSS_MAC_write_phy_reg(&g_mac0, SGMII_PHY_ADDR, MII_BMCR, 0x8000);
1407     }
1408   @endcode
1409  */
1410 void
1411 MSS_MAC_write_phy_reg
1412 (
1413     const mss_mac_instance_t *this_mac,
1414     uint8_t phyaddr,
1415     uint8_t regaddr,
1416     uint16_t regval
1417 );
1418 
1419 /***************************************************************************//**
1420   The _MSS_MAC_phy_reset_ function provides a mechanism for resetting the PHY
1421   device attached to a given MSS Ethernet MAC peripheral. Both soft and hard
1422   reset signals can be controlled via this function.
1423 
1424   This function is used by the Ethernet PHY drivers provided alongside the
1425   Ethernet MAC driver. You normally only need to use this function if writing
1426   your own Ethernet PHY driver.
1427 
1428   This function always accesses the pMAC structure data as the same PHY is
1429   shared by both eMAC and pMAC.
1430 
1431   __Note:__ The use of this function introduces a dependency on the MSS_GPIO
1432   driver into the application. If this is not desirable the function can be
1433   disabled by ensuring the _MSS_MAC_PHY_HW_RESET_ and _MSS_MAC_PHY_HW_SRESET_
1434   are undefined.
1435 
1436   @param this_mac
1437     This parameter is a pointer to one of the global _mss_mac_instance_t_
1438     structures which identifies the MAC that the function is to operate on.
1439     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1440     and eMAC1.
1441 
1442   @param reset_type
1443     This parameter selects between hard and soft reset
1444 
1445   @param reset_state
1446     This parameter is the state to set the reset pin to. For active low resets
1447     this should be set to false to reset the PHY and true to release the PHY
1448     from reset and the opposite for active high resets. It is the responsibility
1449     of the PHY driver to select the correct values for the hardware involved.
1450 
1451   @return
1452     This function does not return a value.
1453 
1454   Example:
1455   @code
1456     #include "mss_ethernet_mac.h"
1457 
1458     void reset_phy(void)
1459     {
1460         MSS_MAC_phy_reset(&g_mac0, MSS_MAC_SOFT_RESET, false);
1461         // delay for a bit
1462         MSS_MAC_phy_reset(&g_mac0, MSS_MAC_SOFT_RESET, true);
1463     }
1464   @endcode
1465  */
1466 void
1467 MSS_MAC_phy_reset
1468 (
1469     const mss_mac_instance_t *this_mac,
1470     mss_mac_phy_reset_t reset_type,
1471     bool     reset_state
1472 );
1473 
1474 /***************************************************************************//**
1475   The _MSS_MAC_init_TSU()_ function configures the Time Stamp Unit (TSU) for
1476   operation and sets the initial count value.
1477 
1478   @param this_mac
1479     This parameter is a pointer to one of the global _mss_mac_instance_t_
1480     structures which identifies the MAC that the function is to operate on.
1481     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1482     and eMAC1.
1483 
1484   @param tsu_cfg
1485     this parameter is a pointer to an _mss_mac_tsu_config_t_ structure which the
1486     application uses to set the initial timer value and the nanosecond and
1487     sub-nanosecond increment values to ensure the counter increments at the
1488     desired rate.
1489 
1490   @return
1491     This function does not return a value.
1492 
1493   Example:
1494   This example illustrates configuring the TSU for operation with a 125MHz clock
1495   (8nS increment). It also configures the time stamping operation for the
1496   Ethernet MAC to collect the times tamps for received and transmitted PTP
1497   packets without modifying outgoing PTP packets. The ingress and egress unicast
1498   PTP addresses to recognize are set to 10.1.1.2 and 10.1.1.3 respectively and
1499   at a later stage the current TSU count is retrieved and displayed.
1500   @code
1501     #include "mss_ethernet_mac.h"
1502 
1503     void init_ts(void)
1504     {
1505         mss_mac_tsu_config_t tsu_cfg;
1506 
1507         tsu_cfg.nanoseconds = 0;
1508         tsu_cfg.secs_lsb    = 0;
1509         tsu_cfg.secs_msb    = 0;
1510         tsu_cfg.ns_inc      = 8;
1511         tsu_cfg.sub_ns_inc  = 0;
1512 
1513         MSS_MAC_init_TSU(&g_mac0, &tsu_cfg);
1514         MSS_MAC_set_TSU_rx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1515         MSS_MAC_set_TSU_tx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1516         MSS_MAC_set_TSU_oss_mode(&g_mac0, MSS_MAC_OSS_MODE_DISABLED);
1517         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_RX,
1518                                      0x0A010102);
1519         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_TX,
1520                                      0x0A010103);
1521 
1522         ...
1523 
1524         MSS_MAC_read_TSU(&g_mac0, &tsu_val);
1525         printf("TSU = %u, %u, %u\n\r", tsu_val.secs_msb, tsu_val.secs_lsb,
1526                tsu_val.nanoseconds);
1527     }
1528   @endcode
1529  */
1530 void
1531 MSS_MAC_init_TSU
1532 (
1533     const mss_mac_instance_t *this_mac,
1534     const mss_mac_tsu_config_t *tsu_cfg
1535 );
1536 
1537 /***************************************************************************//**
1538   The _MSS_MAC_MSS_MAC_read_TSU()_ function reads the current timer value from
1539   the TSU. A strict order of reading and a check for nanoseconds overflow is
1540   used to ensure the time is read correctly.
1541 
1542   @param this_mac
1543     This parameter is a pointer to one of the global _mss_mac_instance_t_
1544     structures which identifies the MAC that the function is to operate on.
1545     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1546     and eMAC1.
1547 
1548   @param tsu_time
1549     This parameter is a pointer to an _mss_mac_tsu_time_t_ structure which the
1550     driver populates with the current counter value from the TSU.
1551 
1552   @return
1553     This function does not return a value.
1554 
1555   Example:
1556   This example illustrates configuring the TSU for operation with a 125MHz clock
1557   (8nS increment). It also configures the time stamping operation for the
1558   Ethernet MAC to collect the time stamps for received and transmitted PTP
1559   packets without modifying outgoing PTP packets. The ingress and egress unicast
1560   PTP addresses to recognize are set to 10.1.1.2 and 10.1.1.3 respectively and
1561   at a later stage the current TSU count is retrieved and displayed.
1562   @code
1563     #include "mss_ethernet_mac.h"
1564 
1565     void init_ts(void)
1566     {
1567         mss_mac_tsu_config_t tsu_cfg;
1568 
1569         tsu_cfg.nanoseconds = 0;
1570         tsu_cfg.secs_lsb    = 0;
1571         tsu_cfg.secs_msb    = 0;
1572         tsu_cfg.ns_inc      = 8;
1573         tsu_cfg.sub_ns_inc  = 0;
1574 
1575         MSS_MAC_init_TSU(&g_mac0, &tsu_cfg);
1576         MSS_MAC_set_TSU_rx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1577         MSS_MAC_set_TSU_tx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1578         MSS_MAC_set_TSU_oss_mode(&g_mac0, MSS_MAC_OSS_MODE_DISABLED);
1579         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_RX,
1580                                      0x0A010102);
1581         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_TX,
1582                                      0x0A010103);
1583 
1584         ...
1585 
1586         MSS_MAC_read_TSU(&g_mac0, &tsu_val);
1587         printf("TSU = %u, %u, %u\n\r", tsu_val.secs_msb, tsu_val.secs_lsb,
1588                tsu_val.nanoseconds);
1589     }
1590   @endcode
1591  */
1592 void
1593 MSS_MAC_read_TSU
1594 (
1595     const mss_mac_instance_t *this_mac,
1596     mss_mac_tsu_time_t *tsu_time
1597 );
1598 
1599 /***************************************************************************//**
1600   The _MSS_MAC_set_TSU_rx_mode()_ function configures time stamp recording for
1601   received packets. This allows recording the TSU value for received packets in
1602   the DMA descriptor for different types of packet.
1603 
1604   The receive packet callback function can retrieve the packet time stamp from
1605   the DMA descriptor for processing by the application.
1606 
1607   @param this_mac
1608     This parameter is a pointer to one of the global _mss_mac_instance_t_
1609     structures which identifies the MAC that the function is to operate on.
1610     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1611     and eMAC1.
1612 
1613   @param tsu_mode
1614     This parameter selects which types of packet have their time stamp recorded.
1615     The available options allow for:
1616 
1617     - _MSS_MAC_TSU_MODE_DISABLED_  - none
1618     - _MSS_MAC_TSU_MODE_PTP_EVENT_ - PTP event packets
1619     - _MSS_MAC_TSU_MODE_PTP_ALL_   - all PTP packets
1620     - _MSS_MAC_TSU_MODE_ALL_       - all packets.
1621 
1622   @return
1623     This function does not return a value.
1624 
1625   Example:
1626   This example illustrates configuring the TSU for operation with a 125MHz clock
1627   (8nS increment). It also configures the time stamping operation for the
1628   Ethernet MAC to collect the time stamps for received and transmitted PTP
1629   packets without modifying outgoing PTP packets. The ingress and egress unicast
1630   PTP addresses to recognize are set to 10.1.1.2 and 10.1.1.3 respectively and
1631   at a later stage the current TSU count is retrieved and displayed.
1632   @code
1633     #include "mss_ethernet_mac.h"
1634 
1635     void init_ts(void)
1636     {
1637         mss_mac_tsu_config_t tsu_cfg;
1638 
1639         tsu_cfg.nanoseconds = 0;
1640         tsu_cfg.secs_lsb    = 0;
1641         tsu_cfg.secs_msb    = 0;
1642         tsu_cfg.ns_inc      = 8;
1643         tsu_cfg.sub_ns_inc  = 0;
1644 
1645         MSS_MAC_init_TSU(&g_mac0, &tsu_cfg);
1646         MSS_MAC_set_TSU_rx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1647         MSS_MAC_set_TSU_tx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1648         MSS_MAC_set_TSU_oss_mode(&g_mac0, MSS_MAC_OSS_MODE_DISABLED);
1649         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_RX,
1650                                      0x0A010102);
1651         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_TX,
1652                                      0x0A010103);
1653 
1654         ...
1655 
1656         MSS_MAC_read_TSU(&g_mac0, &tsu_val);
1657         printf("TSU = %u, %u, %u\n\r", tsu_val.secs_msb, tsu_val.secs_lsb,
1658                tsu_val.nanoseconds);
1659     }
1660   @endcode
1661  */
1662 void
1663 MSS_MAC_set_TSU_rx_mode
1664 (
1665     const mss_mac_instance_t *this_mac,
1666     mss_mac_tsu_mode_t tsu_mode
1667 );
1668 
1669 /***************************************************************************//**
1670   The _MSS_MAC_set_TSU_tx_mode()_ function configures time stamp recording for
1671   transmitted packets. This allows recording the TSU value for transmitted
1672   packets in the DMA descriptor for different types of packet.
1673 
1674   The transmit packet callback function can retrieve the packet time stamp from
1675   the DMA descriptor for processing by the application.
1676 
1677   @param this_mac
1678     This parameter is a pointer to one of the global _mss_mac_instance_t_
1679     structures which identifies the MAC that the function is to operate on.
1680     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1681     and eMAC1.
1682 
1683   @param tsu_mode
1684     This parameter selects which types of packet have their time stamp recorded.
1685     The available options allow for:
1686 
1687     - _MSS_MAC_TSU_MODE_DISABLED_  - none
1688     - _MSS_MAC_TSU_MODE_PTP_EVENT_ - PTP event packets
1689     - _MSS_MAC_TSU_MODE_PTP_ALL_   - all PTP packets
1690     - _MSS_MAC_TSU_MODE_ALL_       - all packets.
1691 
1692   @return
1693     This function does not return a value.
1694 
1695   Example:
1696   This example illustrates configuring the TSU for operation with a 125MHz clock
1697   (8nS increment). It also configures the time stamping operation for the
1698   Ethernet MAC to collect the time stamps for received and transmitted PTP
1699   packets without modifying outgoing PTP packets. The ingress and egress unicast
1700   PTP addresses to recognize are set to 10.1.1.2 and 10.1.1.3 respectively and
1701   at a later stage the current TSU count is retrieved and displayed.
1702   @code
1703     #include "mss_ethernet_mac.h"
1704 
1705     void init_ts(void)
1706     {
1707         mss_mac_tsu_config_t tsu_cfg;
1708 
1709         tsu_cfg.nanoseconds = 0;
1710         tsu_cfg.secs_lsb    = 0;
1711         tsu_cfg.secs_msb    = 0;
1712         tsu_cfg.ns_inc      = 8;
1713         tsu_cfg.sub_ns_inc  = 0;
1714 
1715         MSS_MAC_init_TSU(&g_mac0, &tsu_cfg);
1716         MSS_MAC_set_TSU_rx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1717         MSS_MAC_set_TSU_tx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1718         MSS_MAC_set_TSU_oss_mode(&g_mac0, MSS_MAC_OSS_MODE_DISABLED);
1719         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_RX,
1720                                      0x0A010102);
1721         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_TX,
1722                                      0x0A010103);
1723 
1724         ...
1725 
1726         MSS_MAC_read_TSU(&g_mac0, &tsu_val);
1727         printf("TSU = %u, %u, %u\n\r", tsu_val.secs_msb, tsu_val.secs_lsb,
1728                tsu_val.nanoseconds);
1729     }
1730   @endcode
1731  */
1732 void
1733 MSS_MAC_set_TSU_tx_mode
1734 (
1735     const mss_mac_instance_t *this_mac,
1736     mss_mac_tsu_mode_t tsu_mode
1737 );
1738 
1739 /***************************************************************************//**
1740   The _MSS_MAC_get_TSU_rx_mode()_ function allows the application determine the
1741   current TSU receive time stamping mode.
1742 
1743   @param this_mac
1744     This parameter is a pointer to one of the global _mss_mac_instance_t_
1745     structures which identifies the MAC that the function is to operate on.
1746     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1747     and eMAC1.
1748 
1749   @return
1750     This function returns the current TSU receive time stamping mode setting.
1751  */
1752 mss_mac_tsu_mode_t
1753 MSS_MAC_get_TSU_rx_mode
1754 (
1755     const mss_mac_instance_t *this_mac
1756 );
1757 
1758 /***************************************************************************//**
1759   The _MSS_MAC_get_TSU_tx_mode()_ function allows the application determine the
1760   current TSU tranmit time stamping mode.
1761 
1762   @param this_mac
1763     This parameter is a pointer to one of the global _mss_mac_instance_t_
1764     structures which identifies the MAC that the function is to operate on.
1765     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1766     and eMAC1.
1767 
1768   @return
1769     This function returns the current TSU transmit time stamping mode setting.
1770 
1771  */
1772 mss_mac_tsu_mode_t
1773 MSS_MAC_get_TSU_tx_mode
1774 (
1775     const mss_mac_instance_t *this_mac
1776 );
1777 
1778 /***************************************************************************//**
1779   The _MSS_MAC_set_TSU_oss_mode()_ function configures one step sync (OSS)
1780   operation for the Ethernet MAC. The three options allow for disabling OSS,
1781   enabling OSS time stamp replacement mode and enabling OSS correction field
1782   adjustment mode.
1783 
1784   @param this_mac
1785     This parameter is a pointer to one of the global _mss_mac_instance_t_
1786     structures which identifies the MAC that the function is to operate on.
1787     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1788     and eMAC1.
1789 
1790   @param oss_mode
1791     This parameter selects which OSS mode to use. Valid values are:
1792 
1793     - _MSS_MAC_OSS_MODE_DISABLED_
1794     - _MSS_MAC_OSS_MODE_REPLACE_
1795     - _MSS_MAC_OSS_MODE_ADJUST_
1796 
1797   @return
1798     This function does not return a value.
1799 
1800   Example:
1801   @code
1802     #include "mss_ethernet_mac.h"
1803 
1804     void init_ts(void)
1805     {
1806         mss_mac_tsu_config_t tsu_cfg;
1807 
1808         tsu_cfg.nanoseconds = 0;
1809         tsu_cfg.secs_lsb    = 0;
1810         tsu_cfg.secs_msb    = 0;
1811         tsu_cfg.ns_inc      = 8;
1812         tsu_cfg.sub_ns_inc  = 0;
1813 
1814         MSS_MAC_init_TSU(&g_mac0, &tsu_cfg);
1815         MSS_MAC_set_TSU_rx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1816         MSS_MAC_set_TSU_tx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1817         MSS_MAC_set_TSU_oss_mode(&g_mac0, MSS_MAC_OSS_MODE_DISABLED);
1818         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_RX,
1819                                      0x0A010102);
1820         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_TX,
1821                                      0x0A010103);
1822 
1823         ...
1824 
1825         MSS_MAC_read_TSU(&g_mac0, &tsu_val);
1826         printf("TSU = %u, %u, %u\n\r", tsu_val.secs_msb, tsu_val.secs_lsb,
1827                tsu_val.nanoseconds);
1828     }
1829   @endcode
1830  */
1831 void
1832 MSS_MAC_set_TSU_oss_mode
1833 (
1834     const mss_mac_instance_t *this_mac,
1835     mss_mac_oss_mode_t oss_mode
1836 );
1837 
1838 /***************************************************************************//**
1839   The _MSS_MAC_get_TSU_oss_mode()_ function returns the currently configured one
1840   step sync (OSS) mode for the MAC.
1841 
1842   @param this_mac
1843     This parameter is a pointer to one of the global _mss_mac_instance_t_
1844     structures which identifies the MAC that the function is to operate on.
1845     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1846     and eMAC1.
1847 
1848   @return
1849     This function returns an _mss_mac_oss_mode_t_ value which indicates the
1850     current OSS mode in operation.
1851  */
1852 mss_mac_oss_mode_t
1853 MSS_MAC_get_TSU_oss_mode
1854 (
1855     const mss_mac_instance_t *this_mac
1856 );
1857 
1858 
1859 /***************************************************************************//**
1860   The _MSS_MAC_set_TSU_unicast_addr()_ function configures IP addresses that the
1861   MAC will use to identify unicast PTP frames. The receive IPv4 address and
1862   transmit IPv4 address can be set separately.
1863 
1864   @param this_mac
1865     This parameter is a pointer to one of the global _mss_mac_instance_t_
1866     structures which identifies the MAC that the function is to operate on.
1867     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1868     and eMAC1.
1869 
1870   @param select
1871     This parameter of type _mss_mac_tsu_addr_t_, selects whether the RX or TX
1872     address is being set.
1873 
1874   @param ip_address
1875     This unsigned 32 bit int holds the IP address with the 8 msb holding the
1876     leftmost octet i.e. 10.2.2.1 is represented as 0x0A020201.
1877 
1878   @return
1879     This function does not return a value.
1880 
1881   Example:
1882   @code
1883     #include "mss_ethernet_mac.h"
1884 
1885     void init_ts(void)
1886     {
1887         mss_mac_tsu_config_t tsu_cfg;
1888 
1889         tsu_cfg.nanoseconds = 0;
1890         tsu_cfg.secs_lsb    = 0;
1891         tsu_cfg.secs_msb    = 0;
1892         tsu_cfg.ns_inc      = 8;
1893         tsu_cfg.sub_ns_inc  = 0;
1894 
1895         MSS_MAC_init_TSU(&g_mac0, &tsu_cfg);
1896         MSS_MAC_set_TSU_rx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1897         MSS_MAC_set_TSU_tx_mode(&g_mac0, MSS_MAC_TSU_MODE_PTP_EVENT);
1898         MSS_MAC_set_TSU_oss_mode(&g_mac0, MSS_MAC_OSS_MODE_DISABLED);
1899         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_RX,
1900                                      0x0A010102);
1901         MSS_MAC_set_TSU_unicast_addr(&g_mac0, MSS_MAC_TSU_UNICAST_TX,
1902                                      0x0A010103);
1903 
1904         ...
1905 
1906         MSS_MAC_read_TSU(&g_mac0, &tsu_val);
1907         printf("TSU = %u, %u, %u\n\r", tsu_val.secs_msb, tsu_val.secs_lsb,
1908                tsu_val.nanoseconds);
1909     }
1910   @endcode
1911  */
1912 void
1913 MSS_MAC_set_TSU_unicast_addr
1914 (
1915     const mss_mac_instance_t *this_mac,
1916     mss_mac_tsu_addr_t select,
1917     uint32_t ip_address
1918 );
1919 
1920 /***************************************************************************//**
1921   The _MSS_MAC_get_TSU_unicast_addr()_ function retrieves the IP addresses that
1922   the Ethernet MAC uses to identify unicast PTP frames.
1923 
1924   The receive IPv4 address and transmit IPv4 address can be retrieved
1925   separately.
1926 
1927   @param this_mac
1928     This parameter is a pointer to one of the global _mss_mac_instance_t_
1929     structures which identifies the MAC that the function is to operate on.
1930     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1931     and eMAC1.
1932 
1933   @param select
1934     This parameter of type _mss_mac_tsu_addr_t_, selects whether the RX or TX
1935     address is being retrieved.
1936 
1937   @return
1938     This function returns an unsigned 32 bit int which holds the IP address with
1939     the 8 msb holding the leftmost octet i.e. 10.2.2.1 is represented as
1940     0x0A020201.
1941  */
1942 uint32_t
1943 MSS_MAC_get_TSU_unicast_addr
1944 (
1945     const mss_mac_instance_t *this_mac,
1946     mss_mac_tsu_addr_t select
1947 );
1948 
1949 /***************************************************************************//**
1950   The _MSS_MAC_set_VLAN_only_mode()_ function allows the application enable or
1951   disable VLAN only mode. When VALN only mode is enabled, non VLAN tagged
1952   packets will be discarded.
1953 
1954   @param this_mac
1955     This parameter is a pointer to one of the global _mss_mac_instance_t_
1956     structures which identifies the MAC that the function is to operate on.
1957     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1958     and eMAC1.
1959 
1960   @param enable
1961     This parameter of type _bool_, is set to true to enable VLAN only mode and
1962     false to disable it.
1963 
1964   @return
1965     This function does not return a value.
1966  */
1967 void
1968 MSS_MAC_set_VLAN_only_mode
1969 (
1970     const mss_mac_instance_t *this_mac,
1971     bool enable
1972 );
1973 
1974 /***************************************************************************//**
1975   The _MSS_MAC_get_VLAN_only_mode()_ function retrieves the current VLAN only
1976   mode status. When VALN only mode is enabled, non VLAN tagged packets will be
1977   discarded.
1978 
1979   @param this_mac
1980     This parameter is a pointer to one of the global _mss_mac_instance_t_
1981     structures which identifies the MAC that the function is to operate on.
1982     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
1983     and eMAC1.
1984 
1985   @return
1986     This function returns a value of type _bool_, which is true to indicate VLAN
1987     only mode is currently enabled and false otherwise.
1988  */
1989 bool
1990 MSS_MAC_get_VLAN_only_mode
1991 (
1992     const mss_mac_instance_t *this_mac
1993 );
1994 
1995 /***************************************************************************//**
1996   The _MSS_MAC_set_stacked_VLAN()_ function sets the stacked VLAN tag register
1997   in the MAC. This can be used to enable and disable stacked VLAN operation.
1998 
1999   @param this_mac
2000     This parameter is a pointer to one of the global _mss_mac_instance_t_
2001     structures which identifies the MAC that the function is to operate on.
2002     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2003     and eMAC1.
2004 
2005   @param tag
2006     This parameter of type _uint16_t_, holds the stacked VLAN tag to write to
2007     the Ethernet MAC. A value <= _GEM_VLAN_ETHERTYPE_MIN_ disables stacked VLAN
2008     mode and sets the stacked VLAN tag to 0.
2009 
2010   @return
2011     This function does not return a value.
2012  */
2013 void
2014 MSS_MAC_set_stacked_VLAN
2015 (
2016     const mss_mac_instance_t *this_mac,
2017     uint16_t tag
2018 );
2019 
2020 /***************************************************************************//**
2021   The _MSS_MAC_get_stacked_VLAN()_ function retrieves the current stacked VLAN
2022   tag register from the Ethernet MAC.
2023 
2024   @param this_mac
2025     This parameter is a pointer to one of the global _mss_mac_instance_t_
2026     structures which identifies the MAC that the function is to operate on.
2027     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2028     and eMAC1.
2029 
2030   @return
2031     This function returns a value of type _uint16_t_, which is the current
2032     stacked VLAN tag from the Ethernet MAC. A value of 0 indicates stacked VLAN
2033     mode is disabled.
2034  */
2035 uint16_t
2036 MSS_MAC_get_stacked_VLAN
2037 (
2038     const mss_mac_instance_t *this_mac
2039 );
2040 
2041 /***************************************************************************//**
2042   The _MSS_MAC_set_hash()_ function sets the 64 bit addressing hash field in the
2043   Ethernet MAC.
2044 
2045   @param this_mac
2046     This parameter is a pointer to one of the global _mss_mac_instance_t_
2047     structures which identifies the MAC that the function is to operate on.
2048     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2049     and eMAC1.
2050 
2051   @param hash
2052     This parameter of type _uint64_t_, holds the hash bitmap for the MAC which
2053     is used to enable matching against blocks of addresses based on a 6 bit
2054     hashing function.
2055 
2056     As a short cut, setting a value of 0 also disables hash address matching.
2057 
2058   @return
2059     This function does not return a value.
2060 
2061   Example:
2062   This example sets the hash bit for the multicast MAC address 01:80:C2:00:00:0E
2063   and also configures the Ethernet MAC to only use hashing to match multicast
2064   addresses. The _calc_gem_hash_index()_ function calculates the bit index in
2065   the 64 bit hash value associated with a given MAC address.
2066   @code
2067     uint32_t calc_gem_hash_index(uint8_t *p_address)
2068     {
2069         uint64_t address;
2070         uint32_t index;
2071         uint32_t count;
2072 
2073         p_address += 5;
2074         address = 0;
2075         for(count = 0; count != 6; count++)
2076         {
2077             address <<= 8;
2078             address |= (uint64_t)*p_address;
2079             p_address--;
2080         }
2081 
2082         index = (int32_t)address & 0x0000003Fl;
2083         for(count = 0; count != 7; count++)
2084         {
2085             address >>= 6;
2086             index ^= (uint32_t)(address & 0x0000003Fl);
2087         }
2088 
2089         return(index);
2090     }
2091 
2092     void set_gem_hash(void)
2093     {
2094         uint8_t mac_address[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e};
2095         int32_t index;
2096         uint64_t temp_hash;
2097         uint64_t current_hash;
2098 
2099         index = calc_gem_hash_index(mac_address);
2100         temp_hash = (uint64_t)(1ll << index);
2101         current_hash = MSS_MAC_get_hash(g_mac0);
2102         current_hash = current_hash | temp_hash;
2103         MSS_MAC_set_hash_mode(g_mac0, MSS_MAC_HASH_MULTICAST);
2104         MSS_MAC_set_hash(g_mac0, current_hash);
2105     }
2106     @endcode
2107  */
2108 void
2109 MSS_MAC_set_hash
2110 (
2111     const mss_mac_instance_t *this_mac,
2112     uint64_t hash
2113 );
2114 
2115 /***************************************************************************//**
2116   The _MSS_MAC_get_hash()_ function retrieves the current 64 bit addressing hash
2117   field from the Ethernet MAC.
2118 
2119   @param this_mac
2120     This parameter is a pointer to one of the global _mss_mac_instance_t_
2121     structures which identifies the MAC that the function is to operate on.
2122     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2123     and eMAC1.
2124 
2125   @return
2126     This function returns a value of type _uint64_t_, representing the hash
2127     bitmap for the Ethernet MAC.
2128 
2129   Example:
2130   This example sets the hash bit for the multicast MAC address 01:80:C2:00:00:0E
2131   and also configures the Ethernet MAC to only use hashing to match multicast
2132   addresses. The _calc_gem_hash_index()_ function calculates the bit index in
2133   the 64 bit hash value associated with a given MAC address.
2134   @code
2135     uint32_t calc_gem_hash_index(uint8_t *p_address)
2136     {
2137         uint64_t address;
2138         uint32_t index;
2139         uint32_t count;
2140 
2141         p_address += 5;
2142         address = 0;
2143         for(count = 0; count != 6; count++)
2144         {
2145             address <<= 8;
2146             address |= (uint64_t)*p_address;
2147             p_address--;
2148         }
2149 
2150         index = (int32_t)address & 0x0000003Fl;
2151         for(count = 0; count != 7; count++)
2152         {
2153             address >>= 6;
2154             index ^= (uint32_t)(address & 0x0000003Fl);
2155         }
2156 
2157         return(index);
2158     }
2159 
2160     void set_gem_hash(void)
2161     {
2162         uint8_t mac_address[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e};
2163         int32_t index;
2164         uint64_t temp_hash;
2165         uint64_t current_hash;
2166 
2167         index = calc_gem_hash_index(mac_address);
2168         temp_hash = (uint64_t)(1ll << index);
2169         current_hash = MSS_MAC_get_hash(g_mac0);
2170         current_hash = current_hash | temp_hash;
2171         MSS_MAC_set_hash_mode(g_mac0, MSS_MAC_HASH_MULTICAST);
2172         MSS_MAC_set_hash(g_mac0, current_hash);
2173     }
2174     @endcode
2175  */
2176 uint64_t
2177 MSS_MAC_get_hash
2178 (
2179     const mss_mac_instance_t *this_mac
2180 );
2181 
2182 /***************************************************************************//**
2183   The _MSS_MAC_set_hash_mode()_ function sets the operational mode for the hash
2184   based address matching.
2185 
2186   @param this_mac
2187     This parameter is a pointer to one of the global _mss_mac_instance_t_
2188     structures which identifies the MAC that the function is to operate on.
2189     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2190     and eMAC1.
2191 
2192   @param mode
2193     This parameter of type _mss_mac_hash_mode_t_, selects the mode of operation
2194     of the hash based address filter. The options allow for disabling hash based
2195     filtering, matching unicast packets only, matching multicast packets only
2196     and matching both packet types.
2197 
2198   @return
2199     This function does not return a value.
2200 
2201   Example:
2202   This example sets the hash bit for the multicast MAC address 01:80:C2:00:00:0E
2203   and also configures the Ethernet MAC to only use hashing to match multicast
2204   addresses. The _calc_gem_hash_index()_ function calculates the bit index in
2205   the 64 bit hash value associated with a given MAC address.
2206   @code
2207     uint32_t calc_gem_hash_index(uint8_t *p_address)
2208     {
2209         uint64_t address;
2210         uint32_t index;
2211         uint32_t count;
2212 
2213         p_address += 5;
2214         address = 0;
2215         for(count = 0; count != 6; count++)
2216         {
2217             address <<= 8;
2218             address |= (uint64_t)*p_address;
2219             p_address--;
2220         }
2221 
2222         index = (int32_t)address & 0x0000003Fl;
2223         for(count = 0; count != 7; count++)
2224         {
2225             address >>= 6;
2226             index ^= (uint32_t)(address & 0x0000003Fl);
2227         }
2228 
2229         return(index);
2230     }
2231 
2232     void set_gem_hash(void)
2233     {
2234         uint8_t mac_address[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e};
2235         int32_t index;
2236         uint64_t temp_hash;
2237         uint64_t current_hash;
2238 
2239         index = calc_gem_hash_index(mac_address);
2240         temp_hash = (uint64_t)(1ll << index);
2241         current_hash = MSS_MAC_get_hash(g_mac0);
2242         current_hash = current_hash | temp_hash;
2243         MSS_MAC_set_hash_mode(g_mac0, MSS_MAC_HASH_MULTICAST);
2244         MSS_MAC_set_hash(g_mac0, current_hash);
2245     }
2246     @endcode
2247  */
2248 void
2249 MSS_MAC_set_hash_mode
2250 (
2251     const mss_mac_instance_t *this_mac,
2252     mss_mac_hash_mode_t mode
2253 );
2254 
2255 /***************************************************************************//**
2256   The _MSS_MAC_get_hash_mode()_ function retrieves the current operational mode
2257   for the hash based address matching.
2258 
2259   @param this_mac
2260     This parameter is a pointer to one of the global _mss_mac_instance_t_
2261     structures which identifies the MAC that the function is to operate on.
2262     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2263     and eMAC1.
2264 
2265   @return
2266     This function returns a value of type _mss_mac_hash_mode_t_, which indicates
2267     the mode of operation of the hash based address filter.
2268  */
2269 mss_mac_hash_mode_t
2270 MSS_MAC_get_hash_mode
2271 (
2272     const mss_mac_instance_t *this_mac
2273 );
2274 
2275 /***************************************************************************//**
2276   The _MSS_MAC_set_type_filter()_ function is used to configure the specific
2277   type filters in the Ethernet MAC. These filters allow selective reception of
2278   packets based on matching the type ID/length field in the packet.
2279 
2280   @param this_mac
2281     This parameter is a pointer to one of the global _mss_mac_instance_t_
2282     structures which identifies the MAC that the function is to operate on.
2283     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2284     and eMAC1.
2285 
2286   @param filter
2287     This parameter of type _uint16_t_, selects which filter to configure. The
2288     valid range is 1 to 4 to match the numbering in the GEM documentation.
2289 
2290   @param value
2291     This parameter of type _uint16_t_, is the value to match against. Typical
2292     values for matching purposes will be greater than 0x600 (1536) as the field
2293     is used for packet length in some circumstances and as the Ethertype value
2294     in others.
2295 
2296     Setting _value_ to 0 indicates disabling the filter.
2297 
2298   @return
2299     This function does not return a value.
2300 
2301   Example:
2302     This example enables Specific Type filters 1 and 2 for IPv4 and IPv6
2303     packets respectively.
2304 
2305   @code
2306     #include "mss_ethernet_mac.h"
2307 
2308     void init_st_filters(void)
2309     {
2310         MSS_MAC_set_type_filter(&g_mac0, 1, 0x0800);
2311         MSS_MAC_set_type_filter(&g_mac0, 2, 0x86DD);
2312         MSS_MAC_set_type_filter(&g_mac0, 3, 0x0000);
2313         MSS_MAC_set_type_filter(&g_mac0, 4, 0x0000);
2314     }
2315   @endcode
2316  */
2317 void
2318 MSS_MAC_set_type_filter
2319 (
2320     const mss_mac_instance_t *this_mac,
2321     uint32_t filter,
2322     uint16_t value
2323 );
2324 
2325 /***************************************************************************//**
2326   The _MSS_MAC_get_type_filter()_ function is used to retrieve the current
2327   settings of the specific type filters in the Ethernet MAC. These filters allow
2328   selective reception of packets based on matching the type ID/length field in
2329   the packet.
2330 
2331   @param this_mac
2332     This parameter is a pointer to one of the global _mss_mac_instance_t_
2333     structures which identifies the MAC that the function is to operate on.
2334     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2335     and eMAC1.
2336 
2337   @param filter
2338     This parameter of type _uint16_t_, selects which filter to read. The valid
2339     range is 1 to 4 to match the numbering in the GEM documentation.
2340 
2341   @return
2342     This function returns a value of type _uint16_t_, which is the current
2343     filter match value.
2344 
2345     A value of 0 indicates the filter is disabled.
2346  */
2347 uint16_t
2348 MSS_MAC_get_type_filter
2349 (
2350     const mss_mac_instance_t *this_mac,
2351     uint32_t filter
2352 );
2353 
2354 /***************************************************************************//**
2355   The _MSS_MAC_set_sa_filter()_ function is used to configure the specific
2356   address filters in the Ethernet MAC. These filters allow selective reception
2357   of packets based on matching the destination or source MAC address field in
2358   the packet.
2359 
2360   @param this_mac
2361     This parameter is a pointer to one of the global _mss_mac_instance_t_
2362     structures which identifies the MAC that the function is to operate on.
2363     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2364     and eMAC1.
2365 
2366   @param filter
2367     This parameter of type _uint16_t_, selects which filter to configure. The
2368     valid range is 2 to 4 to match the numbering in the GEM documentation.
2369 
2370     __Note:__ Filter 1 is reserved for the MAC address of the device and cannot
2371     be modified using this function.
2372 
2373   @param control
2374     This parameter of type _uint16_t_, is used to select between source and
2375     destination matching and selective masking of individual bytes, see the
2376     _MSS_MAC_SA_FILTER_*_ macros for allowed values. In addition, the
2377     _MSS_MAC_SA_FILTER_DISABLE_ value is used to disable a filter.
2378 
2379   @param mac_addr
2380     This parameter of type pointer to _uint8_t_, points to the 6 byte MAC
2381     address to be used for this filter operation.
2382 
2383   @return
2384     This function does not return a value.
2385 
2386   Example:
2387     This example assumes MAC0 is connected on the same network as MAC1 and
2388     configures source address filters to detect traffic from MAC0 and MAC1 on
2389     the opposing MAC. This uses filter number two on each Ethernet MAC.
2390 
2391   @code
2392     #include "mss_ethernet_mac.h"
2393 
2394     void init_sa_filters(void)
2395     {
2396         MSS_MAC_set_sa_filter(&g_mac0, 2, MSS_MAC_SA_FILTER_SOURCE,
2397                               g_mac1.mac_addr);
2398         MSS_MAC_set_sa_filter(&g_mac1, 2, MSS_MAC_SA_FILTER_SOURCE,
2399                               g_mac0.mac_addr);
2400     }
2401   @endcode
2402  */
2403 void
2404 MSS_MAC_set_sa_filter
2405 (
2406     const mss_mac_instance_t *this_mac,
2407     uint32_t filter,
2408     uint16_t control,
2409     const uint8_t *mac_addr
2410 );
2411 
2412 /***************************************************************************//**
2413   The _MSS_MAC_get_sa_filter()_ function retrieves the current specific address
2414   filter settings from the Ethernet MAC. These filters allow selective reception
2415   of packets based on matching the destination or source MAC address field in
2416   the packet.
2417 
2418   @param this_mac
2419     This parameter is a pointer to one of the global _mss_mac_instance_t_
2420     structures which identifies the MAC that the function is to operate on.
2421     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2422     and eMAC1.
2423 
2424   @param filter
2425     This parameter of type _uint16_t_, selects which filter to retrieve from.
2426     The valid range is 2 to 4 to match the numbering in the GEM documentation.
2427 
2428     __Note:__ Filter 1 is reserved for the MAC address of the device and cannot
2429     be read using this function.
2430 
2431   @param mac_addr
2432     This parameter of type pointer to _uint8_t_, points to a storage location
2433     where the 6 byte MAC address from the filter will be stored.
2434 
2435   @return
2436     This function returns a value of type _uint16_t_, which has the same format
2437     as the control parameter for the _MSS_MAC_set_sa_filter()_ function.
2438 
2439 
2440   Example:
2441     This example reads the filter settings for filter 2 on the pMAC of GEM 0.
2442 
2443   @code
2444     #include "mss_ethernet_mac.h"
2445 
2446     void read_sa_filter_2(void)
2447     {
2448         uint16_t control;
2449         uint8_t  mac_addr[6];
2450 
2451         control = MSS_MAC_get_sa_filter(&g_mac0, 2, mac_addr);
2452     }
2453   @endcode
2454  */
2455 uint16_t
2456 MSS_MAC_get_sa_filter
2457 (
2458     const mss_mac_instance_t *this_mac,
2459     uint32_t filter,
2460     uint8_t *mac_addr
2461 );
2462 
2463 /***************************************************************************//**
2464   The _MSS_MAC_set_type_1_filter()_ function is used to configure the Type 1
2465   filters in the Ethernet MAC. These filters allow selective routing of packets
2466   to specific queues based on combinations of UDP port number and/or
2467   differentiated service/traffic class values. Packets can also be flagged for
2468   dropping based on the same criteria.
2469 
2470   Packets that do not match a Type 1 or Type 2 filter are automatically routed
2471   to queue 0.
2472 
2473   @param this_mac
2474     This parameter is a pointer to one of the global _mss_mac_instance_t_
2475     structures which identifies the MAC that the function is to operate on.
2476     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2477     and eMAC1.
2478 
2479   @param filter_no
2480     This parameter of type _uint32_t_, selects which filter to configure. The
2481     valid range is 0 to 3.
2482 
2483   @param filter
2484     This parameter of type pointer to _mss_mac_type_1_filter_t_, points to the
2485     filter configuration structure which defines the filter setup required.
2486 
2487   @return
2488     This function does not return a value.
2489 
2490   Example:
2491     This example configures 3 type 1 filters which route UDP port 320 packets to
2492     queue 1, packets with a DS or TC value of 15 to queue 2 and drops packets
2493     with a UDP port of 1534. The example also checks to see if filter 3 has
2494     already been configured and only proceeds if it is not configured.
2495 
2496   @code
2497     #include "mss_ethernet_mac.h"
2498 
2499     void init_t1_filters(void)
2500     {
2501         mss_mac_type_1_filter_t filter1;
2502 
2503         MSS_MAC_get_type_1_filter(&g_mac0, 3, &filter1);
2504         if(0 == filter1.udp_port)
2505         {
2506             memset(&filter1, 0, sizeof(filter1));
2507             filter1.udp_port = 320;
2508             filter1.udp_port_enable = 1;
2509             filter1.queue_no = 1;
2510 
2511             MSS_MAC_set_type_1_filter(&g_mac0, 3, &filter1);
2512 
2513             memset(&filter1, 0, sizeof(filter1));
2514             filter1.dstc = 0x0F;
2515             filter1.dstc_enable = 1;
2516             filter1.queue_no = 2;
2517 
2518             MSS_MAC_set_type_1_filter(&g_mac0, 2, &filter1);
2519 
2520             memset(&filter1, 0, sizeof(filter1));
2521             filter1.udp_port = 1534;
2522             filter1.udp_port_enable = 1;
2523             filter1.drop_on_match = 1;
2524             filter1.queue_no = 3;
2525 
2526             MSS_MAC_set_type_1_filter(&g_mac0, 1, &filter1);
2527         }
2528     }
2529   @endcode
2530  */
2531 void
2532 MSS_MAC_set_type_1_filter
2533 (
2534     const mss_mac_instance_t *this_mac,
2535     uint32_t filter_no,
2536     const mss_mac_type_1_filter_t *filter
2537 );
2538 
2539 /***************************************************************************//**
2540   The _MSS_MAC_get_type_1_filter()_ function is used to retrieve the current
2541   Type 1 filter configurations from the Ethernet MAC. These filters allow
2542   selective routing of packets to specific queues based on combinations of UDP
2543   port number and/or differentiated service/traffic class values. Packets can
2544   also be flagged for dropping based on the same criteria.
2545 
2546   Packets that do not match a Type 1 or Type 2 filter are automatically routed
2547   to queue 0.
2548 
2549   @param this_mac
2550     This parameter is a pointer to one of the global _mss_mac_instance_t_
2551     structures which identifies the MAC that the function is to operate on.
2552     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2553     and eMAC1.
2554 
2555   @param filter_no
2556     This parameter of type _uint32_t_, selects which filter to retrieve. The
2557     valid range is 0 to 3.
2558 
2559   @param filter
2560     This parameter of type pointer to _mss_mac_type_1_filter_t_, points to the
2561     filter configuration structure which receives the setup information for
2562     the selected filter.
2563 
2564   @return
2565     This function does not return a value.
2566 
2567   Example:
2568     This example configures 3 type 1 filters which route UDP port 320 packets to
2569     queue 1, packets with a DS or TC value of 15 to queue 2 and drops packets
2570     with a UDP port of 1534. The example also checks to see if filter 3 has
2571     already been configured and only proceeds if it is not configured.
2572 
2573   @code
2574     #include "mss_ethernet_mac.h"
2575 
2576     void init_t1_filters(void)
2577     {
2578         mss_mac_type_1_filter_t filter1;
2579 
2580         MSS_MAC_get_type_1_filter(&g_mac0, 3, &filter1);
2581         if(0 == filter1.udp_port)
2582         {
2583             memset(&filter1, 0, sizeof(filter1));
2584             filter1.udp_port = 320;
2585             filter1.udp_port_enable = 1;
2586             filter1.queue_no = 1;
2587 
2588             MSS_MAC_set_type_1_filter(&g_mac0, 3, &filter1);
2589 
2590             memset(&filter1, 0, sizeof(filter1));
2591             filter1.dstc = 0x0F;
2592             filter1.dstc_enable = 1;
2593             filter1.queue_no = 2;
2594 
2595             MSS_MAC_set_type_1_filter(&g_mac0, 2, &filter1);
2596 
2597             memset(&filter1, 0, sizeof(filter1));
2598             filter1.udp_port = 1534;
2599             filter1.udp_port_enable = 1;
2600             filter1.drop_on_match = 1;
2601             filter1.queue_no = 3;
2602 
2603             MSS_MAC_set_type_1_filter(&g_mac0, 1, &filter1);
2604         }
2605     }
2606   @endcode
2607  */
2608 void
2609 MSS_MAC_get_type_1_filter
2610 (
2611     const mss_mac_instance_t *this_mac,
2612     uint32_t filter_no,
2613     mss_mac_type_1_filter_t *filter
2614 );
2615 
2616 /***************************************************************************//**
2617   The _MSS_MAC_set_type_2_filter()_ function is used to configure the Type 2
2618   filters in the Ethernet MAC. These filters allow selective routing of packets
2619   to specific queues based on combinations of Ethertype field values, general
2620   data patterns and VLAN priority values. Packets can also be flagged for
2621   dropping based on the same criteria.
2622 
2623   For consistent operation, the application should always use the
2624   _MSS_MAC_set_type_2_compare()_ and _MSS_MAC_set_type_2_ethertype()_ functions
2625   to set the filter match values before calling _MSS_MAC_set_type_2_filter()_.
2626 
2627   Packets that do not match a Type 1 or Type 2 filter are automatically routed
2628   to queue 0.
2629 
2630   @param this_mac
2631     This parameter is a pointer to one of the global _mss_mac_instance_t_
2632     structures which identifies the MAC that the function is to operate on.
2633     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2634     and eMAC1.
2635 
2636   @param filter_no
2637     This parameter of type _uint32_t_, selects which filter to configure. The
2638     valid range is 0 to 3 for pMACs and 0 to 1 for eMACs.
2639 
2640   @param filter
2641     This parameter of type pointer to _mss_mac_type_2_filter_t_, points to the
2642     filter configuration structure which defines the filter setup required.
2643 
2644   @return
2645     This function does not return a value.
2646 
2647   Example:
2648     This example configures 2 filters which route IP packets with 0x9E, 0x48,
2649     0x05, 0x0F at offset 0x48 to queue 3 and ARP packets with 12 x 0xFF at
2650     offset 0x30 to queue 2. The example also checks to see if Ethertype block 0
2651     has already been configured and only proceeds if it is not configured.
2652 
2653   @code
2654     #include "mss_ethernet_mac.h"
2655 
2656     void init_t2_filters(void)
2657     {
2658         mss_mac_type_2_filter_t filter;
2659         mss_mac_type_2_compare_t compare;
2660 
2661         if(0 == MSS_MAC_get_type_2_ethertype(&g_mac0, 0))
2662         {
2663             MSS_MAC_set_type_2_ethertype(&g_mac0, 0, 0x0800);
2664 
2665             compare.disable_mask = 1;
2666             compare.data = 0x0F05489EUL;
2667             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
2668             compare.offset_value = 0x48;
2669             MSS_MAC_set_type_2_compare(&g_mac0, 0, &compare);
2670 
2671             memset(&filter, 0, sizeof(filter));
2672             filter.compare_a_enable = 1;
2673             filter.compare_a_index  = 0;
2674             filter.ethertype_enable = 1;
2675             filter.ethertype_index  = 0;
2676             filter.queue_no         = 3;
2677             MSS_MAC_set_type_2_filter(&g_mac0, 0, &filter);
2678 
2679             compare.disable_mask = 1;
2680             compare.data = 0xFFFFFFFFUL;
2681             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
2682             compare.offset_value = 0x30;
2683             MSS_MAC_set_type_2_compare(&g_mac0, 1, &compare);
2684 
2685             compare.offset_value = 0x34;
2686             MSS_MAC_set_type_2_compare(&g_mac0, 2, &compare);
2687 
2688             compare.offset_value = 0x38;
2689             MSS_MAC_set_type_2_compare(&g_mac0, 3, &compare);
2690 
2691             MSS_MAC_set_type_2_ethertype(&g_mac0, 1, 0x0806);
2692 
2693             memset(&filter, 0, sizeof(filter));
2694             filter.compare_a_enable = 1;
2695             filter.compare_a_index  = 1;
2696             filter.compare_b_enable = 1;
2697             filter.compare_b_index  = 2;
2698             filter.compare_c_enable = 1;
2699             filter.compare_c_index  = 3;
2700             filter.ethertype_enable = 1;
2701             filter.ethertype_index  = 1;
2702             filter.queue_no         = 2;
2703             MSS_MAC_set_type_2_filter(&g_mac0, 1, &filter);
2704         }
2705     }
2706   @endcode
2707  */
2708 void
2709 MSS_MAC_set_type_2_filter
2710 (
2711     const mss_mac_instance_t *this_mac,
2712     uint32_t filter_no,
2713     const mss_mac_type_2_filter_t *filter
2714 );
2715 
2716 /***************************************************************************//**
2717   The _MSS_MAC_get_type_2_filter()_ function is used to retrieve the current
2718   Type 2 filter configuration from the Ethernet MAC. These filters allow
2719   selective routing of packets to specific queues based on combinations of
2720   Ethertype field values, general data patterns and VLAN priority values.
2721   Packets can also be flagged for dropping based on the same criteria.
2722 
2723   Packets that do not match a Type 1 or Type 2 filter are automatically routed
2724   to queue 0.
2725 
2726   @param this_mac
2727     This parameter is a pointer to one of the global _mss_mac_instance_t_
2728     structures which identifies the MAC that the function is to operate on.
2729     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2730     and eMAC1.
2731 
2732   @param filter_no
2733     This parameter of type _uint32_t_, selects which filter to retrieve. The
2734     valid range is 0 to 3 for pMACs and 0 to 1 for eMACs.
2735 
2736   @param filter
2737     This parameter of type pointer to _mss_mac_type_2_filter_t_, points to the
2738     filter configuration structure which will receive a copy of the current
2739     filter setup.
2740 
2741   @return
2742     This function does not return a value.
2743 
2744   Example:
2745     This example configures 2 filters which route IP packets with 0x9E, 0x48,
2746     0x05, 0x0F at offset 0x48 to queue 3 and ARP packets with 12 x 0xFF at
2747     offset 0x30 to queue 2. The example also checks to see if Ethertype block 0
2748     has already been configured and only proceeds if it is not configured.
2749 
2750   @code
2751     #include "mss_ethernet_mac.h"
2752 
2753     void init_t2_filters(void)
2754     {
2755         mss_mac_type_2_filter_t filter;
2756         mss_mac_type_2_compare_t compare;
2757 
2758         if(0 == MSS_MAC_get_type_2_ethertype(&g_mac0, 0))
2759         {
2760             MSS_MAC_set_type_2_ethertype(&g_mac0, 0, 0x0800);
2761 
2762             compare.disable_mask = 1;
2763             compare.data = 0x0F05489EUL;
2764             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
2765             compare.offset_value = 0x48;
2766             MSS_MAC_set_type_2_compare(&g_mac0, 0, &compare);
2767 
2768             memset(&filter, 0, sizeof(filter));
2769             filter.compare_a_enable = 1;
2770             filter.compare_a_index  = 0;
2771             filter.ethertype_enable = 1;
2772             filter.ethertype_index  = 0;
2773             filter.queue_no         = 3;
2774             MSS_MAC_set_type_2_filter(&g_mac0, 0, &filter);
2775 
2776             compare.disable_mask = 1;
2777             compare.data = 0xFFFFFFFFUL;
2778             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
2779             compare.offset_value = 0x30;
2780             MSS_MAC_set_type_2_compare(&g_mac0, 1, &compare);
2781 
2782             compare.offset_value = 0x34;
2783             MSS_MAC_set_type_2_compare(&g_mac0, 2, &compare);
2784 
2785             compare.offset_value = 0x38;
2786             MSS_MAC_set_type_2_compare(&g_mac0, 3, &compare);
2787 
2788             MSS_MAC_set_type_2_ethertype(&g_mac0, 1, 0x0806);
2789 
2790             memset(&filter, 0, sizeof(filter));
2791             filter.compare_a_enable = 1;
2792             filter.compare_a_index  = 1;
2793             filter.compare_b_enable = 1;
2794             filter.compare_b_index  = 2;
2795             filter.compare_c_enable = 1;
2796             filter.compare_c_index  = 3;
2797             filter.ethertype_enable = 1;
2798             filter.ethertype_index  = 1;
2799             filter.queue_no         = 2;
2800             MSS_MAC_set_type_2_filter(&g_mac0, 1, &filter);
2801         }
2802     }
2803   @endcode
2804  */
2805 void
2806 MSS_MAC_get_type_2_filter
2807 (
2808     const mss_mac_instance_t *this_mac,
2809     uint32_t filter_no,
2810     mss_mac_type_2_filter_t *filter
2811  );
2812 
2813 /***************************************************************************//**
2814   The _MSS_MAC_set_type_2_ethertype()_ function is used to configure the Type 2
2815   Ethertype matching blocks in the Ethernet MAC. These are used by Type 2
2816   filters to allow selection of packet types.
2817 
2818   For consistent operation, the application should always use the
2819   _MSS_MAC_set_type_2_compare()_ and _MSS_MAC_set_type_2_ethertype()_ functions
2820   to set the filter match values before calling _MSS_MAC_set_type_2_filter()_.
2821 
2822   @param this_mac
2823     This parameter is a pointer to one of the global _mss_mac_instance_t_
2824     structures which identifies the MAC that the function is to operate on.
2825     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2826     and eMAC1.
2827 
2828   @param ethertype_no
2829     This parameter of type _uint32_t_, selects which Ethertype block to
2830     configure. The valid range is 0 to 3 for pMACs, eMACs do not support
2831     Ethertype filters.
2832 
2833   @param ethertype
2834     This parameter of type _uint16_t_, is the Ethertype value to match against.
2835     A value of 0 indicates the Ethertype matching block is not configured.
2836 
2837   @return
2838     This function does not return a value.
2839 
2840   Example:
2841     This example configures 2 filters which route IP packets with 0x9E, 0x48,
2842     0x05, 0x0F at offset 0x48 to queue 3 and ARP packets with 12 x 0xFF at
2843     offset 0x30 to queue 2. The example also checks to see if Ethertype block 0
2844     has already been configured and only proceeds if it is not configured.
2845 
2846   @code
2847     #include "mss_ethernet_mac.h"
2848 
2849     void init_t2_filters(void)
2850     {
2851         mss_mac_type_2_filter_t filter;
2852         mss_mac_type_2_compare_t compare;
2853 
2854         if(0 == MSS_MAC_get_type_2_ethertype(&g_mac0, 0))
2855         {
2856             MSS_MAC_set_type_2_ethertype(&g_mac0, 0, 0x0800);
2857 
2858             compare.disable_mask = 1;
2859             compare.data = 0x0F05489EUL;
2860             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
2861             compare.offset_value = 0x48;
2862             MSS_MAC_set_type_2_compare(&g_mac0, 0, &compare);
2863 
2864             memset(&filter, 0, sizeof(filter));
2865             filter.compare_a_enable = 1;
2866             filter.compare_a_index  = 0;
2867             filter.ethertype_enable = 1;
2868             filter.ethertype_index  = 0;
2869             filter.queue_no         = 3;
2870             MSS_MAC_set_type_2_filter(&g_mac0, 0, &filter);
2871 
2872             compare.disable_mask = 1;
2873             compare.data = 0xFFFFFFFFUL;
2874             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
2875             compare.offset_value = 0x30;
2876             MSS_MAC_set_type_2_compare(&g_mac0, 1, &compare);
2877 
2878             compare.offset_value = 0x34;
2879             MSS_MAC_set_type_2_compare(&g_mac0, 2, &compare);
2880 
2881             compare.offset_value = 0x38;
2882             MSS_MAC_set_type_2_compare(&g_mac0, 3, &compare);
2883 
2884             MSS_MAC_set_type_2_ethertype(&g_mac0, 1, 0x0806);
2885 
2886             memset(&filter, 0, sizeof(filter));
2887             filter.compare_a_enable = 1;
2888             filter.compare_a_index  = 1;
2889             filter.compare_b_enable = 1;
2890             filter.compare_b_index  = 2;
2891             filter.compare_c_enable = 1;
2892             filter.compare_c_index  = 3;
2893             filter.ethertype_enable = 1;
2894             filter.ethertype_index  = 1;
2895             filter.queue_no         = 2;
2896             MSS_MAC_set_type_2_filter(&g_mac0, 1, &filter);
2897         }
2898     }
2899   @endcode
2900  */
2901 void
2902 MSS_MAC_set_type_2_ethertype
2903 (
2904     const mss_mac_instance_t *this_mac,
2905     uint32_t ethertype_no,
2906     uint16_t ethertype
2907 );
2908 
2909 /***************************************************************************//**
2910   The _MSS_MAC_get_type_2_ethertype()_ function is used to retrieve the current
2911   settings for Type 2 Ethertype matching blocks in the Ethernet MAC.
2912 
2913   @param this_mac
2914     This parameter is a pointer to one of the global _mss_mac_instance_t_
2915     structures which identifies the MAC that the function is to operate on.
2916     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
2917     and eMAC1.
2918 
2919   @param ethertype_no
2920     This parameter of type _uint32_t_, selects the Ethertype block to retrieve.
2921     The valid range is 0 to 3 for pMACs, eMACs do not support Ethertype filters.
2922 
2923   @return
2924     This function returns a value of type _uint16_t_ which is the Ethertype
2925     value to match against. A value of 0 indicates the Ethertype matching block
2926     is not configured.
2927 
2928   Example:
2929     This example configures 2 filters which route IP packets with 0x9E, 0x48,
2930     0x05, 0x0F at offset 0x48 to queue 3 and ARP packets with 12 x 0xFF at
2931     offset 0x30 to queue 2. The example also checks to see if Ethertype block 0
2932     has already been configured and only proceeds if it is not configured.
2933 
2934   @code
2935     #include "mss_ethernet_mac.h"
2936 
2937     void init_t2_filters(void)
2938     {
2939         mss_mac_type_2_filter_t filter;
2940         mss_mac_type_2_compare_t compare;
2941 
2942         if(0 == MSS_MAC_get_type_2_ethertype(&g_mac0, 0))
2943         {
2944             MSS_MAC_set_type_2_ethertype(&g_mac0, 0, 0x0800);
2945 
2946             compare.disable_mask = 1;
2947             compare.data = 0x0F05489EUL;
2948             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
2949             compare.offset_value = 0x48;
2950             MSS_MAC_set_type_2_compare(&g_mac0, 0, &compare);
2951 
2952             memset(&filter, 0, sizeof(filter));
2953             filter.compare_a_enable = 1;
2954             filter.compare_a_index  = 0;
2955             filter.ethertype_enable = 1;
2956             filter.ethertype_index  = 0;
2957             filter.queue_no         = 3;
2958             MSS_MAC_set_type_2_filter(&g_mac0, 0, &filter);
2959 
2960             compare.disable_mask = 1;
2961             compare.data = 0xFFFFFFFFUL;
2962             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
2963             compare.offset_value = 0x30;
2964             MSS_MAC_set_type_2_compare(&g_mac0, 1, &compare);
2965 
2966             compare.offset_value = 0x34;
2967             MSS_MAC_set_type_2_compare(&g_mac0, 2, &compare);
2968 
2969             compare.offset_value = 0x38;
2970             MSS_MAC_set_type_2_compare(&g_mac0, 3, &compare);
2971 
2972             MSS_MAC_set_type_2_ethertype(&g_mac0, 1, 0x0806);
2973 
2974             memset(&filter, 0, sizeof(filter));
2975             filter.compare_a_enable = 1;
2976             filter.compare_a_index  = 1;
2977             filter.compare_b_enable = 1;
2978             filter.compare_b_index  = 2;
2979             filter.compare_c_enable = 1;
2980             filter.compare_c_index  = 3;
2981             filter.ethertype_enable = 1;
2982             filter.ethertype_index  = 1;
2983             filter.queue_no         = 2;
2984             MSS_MAC_set_type_2_filter(&g_mac0, 1, &filter);
2985         }
2986     }
2987   @endcode
2988  */
2989 uint16_t
2990 MSS_MAC_get_type_2_ethertype
2991 (
2992     const mss_mac_instance_t *this_mac,
2993     uint32_t ethertype_no
2994 );
2995 
2996 /***************************************************************************//**
2997   The _MSS_MAC_set_type_2_compare()_ function is used to configure the Type 2
2998   data matching blocks in the Ethernet MAC. These are used by Type 2 filters to
2999   allow comparing up to 4 bytes of data at different locations in the packet.
3000   They also allow for matching against VLAN IDs. The data matching can be
3001   performed against 4 consecutive bytes or against up to 2 consecutive bytes
3002   with an associated bit mask.
3003 
3004   For consistent operation, the application should always use the
3005   _MSS_MAC_set_type_2_compare()_ and _MSS_MAC_set_type_2_ethertype()_ functions
3006   to set the filter match values before calling _MSS_MAC_set_type_2_filter()_.
3007 
3008   @param this_mac
3009     This parameter is a pointer to one of the global _mss_mac_instance_t_
3010     structures which identifies the MAC that the function is to operate on.
3011     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3012     and eMAC1.
3013 
3014   @param comparer_no_in
3015     This parameter of type _uint32_t_, selects which compare block to configure.
3016     The valid range is 0 to 11 for pMACs and 0 to 5 for eMACs.
3017 
3018   @param comparer
3019     This parameter of type pointer to _mss_mac_type_2_compare_t_, is the address
3020     of the compare block structure to use for the configuration.
3021 
3022   @return
3023     This function does not return a value.
3024 
3025   Example:
3026     This example configures 2 filters which route IP packets with 0x9E, 0x48,
3027     0x05, 0x0F at offset 0x48 to queue 3 and ARP packets with 12 x 0xFF at
3028     offset 0x30 to queue 2. The example also checks to see if Ethertype block 0
3029     has already been configured and only proceeds if it is not configured.
3030 
3031   @code
3032     #include "mss_ethernet_mac.h"
3033 
3034     void init_t2_filters(void)
3035     {
3036         mss_mac_type_2_filter_t filter;
3037         mss_mac_type_2_compare_t compare;
3038 
3039         if(0 == MSS_MAC_get_type_2_ethertype(&g_mac0, 0))
3040         {
3041             MSS_MAC_set_type_2_ethertype(&g_mac0, 0, 0x0800);
3042 
3043             compare.disable_mask = 1;
3044             compare.data = 0x0F05489EUL;
3045             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
3046             compare.offset_value = 0x48;
3047             MSS_MAC_set_type_2_compare(&g_mac0, 0, &compare);
3048 
3049             memset(&filter, 0, sizeof(filter));
3050             filter.compare_a_enable = 1;
3051             filter.compare_a_index  = 0;
3052             filter.ethertype_enable = 1;
3053             filter.ethertype_index  = 0;
3054             filter.queue_no         = 3;
3055             MSS_MAC_set_type_2_filter(&g_mac0, 0, &filter);
3056 
3057             compare.disable_mask = 1;
3058             compare.data = 0xFFFFFFFFUL;
3059             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
3060             compare.offset_value = 0x30;
3061             MSS_MAC_set_type_2_compare(&g_mac0, 1, &compare);
3062 
3063             compare.offset_value = 0x34;
3064             MSS_MAC_set_type_2_compare(&g_mac0, 2, &compare);
3065 
3066             compare.offset_value = 0x38;
3067             MSS_MAC_set_type_2_compare(&g_mac0, 3, &compare);
3068 
3069             MSS_MAC_set_type_2_ethertype(&g_mac0, 1, 0x0806);
3070 
3071             memset(&filter, 0, sizeof(filter));
3072             filter.compare_a_enable = 1;
3073             filter.compare_a_index  = 1;
3074             filter.compare_b_enable = 1;
3075             filter.compare_b_index  = 2;
3076             filter.compare_c_enable = 1;
3077             filter.compare_c_index  = 3;
3078             filter.ethertype_enable = 1;
3079             filter.ethertype_index  = 1;
3080             filter.queue_no         = 2;
3081             MSS_MAC_set_type_2_filter(&g_mac0, 1, &filter);
3082         }
3083     }
3084   @endcode
3085  */
3086 void
3087 MSS_MAC_set_type_2_compare
3088 (
3089     const mss_mac_instance_t *this_mac,
3090     uint32_t comparer_no_in,
3091     const mss_mac_type_2_compare_t *comparer
3092 );
3093 
3094 
3095 /***************************************************************************//**
3096   The _MSS_MAC_get_type_2_compare()_ function is used to retrieve the current
3097   Type 2 data matching blocks configuration from the Ethernet MAC.
3098 
3099   @param this_mac
3100     This parameter is a pointer to one of the global _mss_mac_instance_t_
3101     structures which identifies the MAC that the function is to operate on.
3102     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3103     and eMAC1.
3104 
3105   @param comparer_no_in
3106     This parameter of type _uint32_t_, selects which compare block to retrieve.
3107     The valid range is 0 to 11 for pMACs and 0 to 5 for eMACs.
3108 
3109   @param comparer
3110     This parameter of type pointer to _mss_mac_type_2_compare_t_, is the address
3111     of the configuration structure which will receive a copy of the current
3112     comparer block setup.
3113 
3114   @return
3115     This function does not return a value.
3116 
3117   Example:
3118     This example configures 2 filters which route IP packets with 0x9E, 0x48,
3119     0x05, 0x0F at offset 0x48 to queue 3 and ARP packets with 12 x 0xFF at
3120     offset 0x30 to queue 2. The example also checks to see if Ethertype block 0
3121     has already been configured and only proceeds if it is not configured.
3122 
3123   @code
3124     #include "mss_ethernet_mac.h"
3125 
3126     void init_t2_filters(void)
3127     {
3128         mss_mac_type_2_filter_t filter;
3129         mss_mac_type_2_compare_t compare;
3130 
3131         if(0 == MSS_MAC_get_type_2_ethertype(&g_mac0, 0))
3132         {
3133             MSS_MAC_set_type_2_ethertype(&g_mac0, 0, 0x0800);
3134 
3135             compare.disable_mask = 1;
3136             compare.data = 0x0F05489EUL;
3137             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
3138             compare.offset_value = 0x48;
3139             MSS_MAC_set_type_2_compare(&g_mac0, 0, &compare);
3140 
3141             memset(&filter, 0, sizeof(filter));
3142             filter.compare_a_enable = 1;
3143             filter.compare_a_index  = 0;
3144             filter.ethertype_enable = 1;
3145             filter.ethertype_index  = 0;
3146             filter.queue_no         = 3;
3147             MSS_MAC_set_type_2_filter(&g_mac0, 0, &filter);
3148 
3149             compare.disable_mask = 1;
3150             compare.data = 0xFFFFFFFFUL;
3151             compare.compare_offset = MSS_MAC_T2_OFFSET_FRAME;
3152             compare.offset_value = 0x30;
3153             MSS_MAC_set_type_2_compare(&g_mac0, 1, &compare);
3154 
3155             compare.offset_value = 0x34;
3156             MSS_MAC_set_type_2_compare(&g_mac0, 2, &compare);
3157 
3158             compare.offset_value = 0x38;
3159             MSS_MAC_set_type_2_compare(&g_mac0, 3, &compare);
3160 
3161             MSS_MAC_set_type_2_ethertype(&g_mac0, 1, 0x0806);
3162 
3163             memset(&filter, 0, sizeof(filter));
3164             filter.compare_a_enable = 1;
3165             filter.compare_a_index  = 1;
3166             filter.compare_b_enable = 1;
3167             filter.compare_b_index  = 2;
3168             filter.compare_c_enable = 1;
3169             filter.compare_c_index  = 3;
3170             filter.ethertype_enable = 1;
3171             filter.ethertype_index  = 1;
3172             filter.queue_no         = 2;
3173             MSS_MAC_set_type_2_filter(&g_mac0, 1, &filter);
3174         }
3175     }
3176   @endcode
3177  */
3178 void
3179 MSS_MAC_get_type_2_compare
3180 (
3181     const mss_mac_instance_t *this_mac,
3182     uint32_t comparer_no_in,
3183     mss_mac_type_2_compare_t *comparer
3184 );
3185 
3186 /***************************************************************************//**
3187   The _MSS_MAC_set_mmsl_mode()_ function is used to configure the operation of
3188   the MAC Merge Sublayer component of the GEM. This function is used to enable
3189   and disable preemption and to determine which MAC (eMAC or pMAC) is used for
3190   reception in non preemption modes. The function also allows control of the
3191   preemption verification functionality.
3192 
3193   The function only operates on the pMAC.
3194 
3195   @param this_mac
3196     This parameter is a pointer to one of the global _mss_mac_instance_t_
3197     structures which identifies the MAC that the function is to operate on.
3198     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3199     and eMAC1.
3200 
3201   @param mmsl_cfg
3202     This parameter of type pointer to _mss_mac_mmsl_config_t_, points to the
3203     configuration structure used to set the MMSL operation mode.
3204 
3205   @return
3206     This function does not return a value.
3207  */
3208 void
3209 MSS_MAC_set_mmsl_mode
3210 (
3211     const mss_mac_instance_t *this_mac,
3212     const mss_mac_mmsl_config_t *mmsl_cfg
3213 );
3214 
3215 /***************************************************************************//**
3216   The _MSS_MAC_get_mmsl_mode()_ function is used to retrieve the current
3217   configuration of the MAC Merge Sublayer component of the GEM.
3218 
3219   The function only operates on the pMAC.
3220 
3221   @param this_mac
3222     This parameter is a pointer to one of the global _mss_mac_instance_t_
3223     structures which identifies the MAC that the function is to operate on.
3224     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3225     and eMAC1.
3226 
3227   @param mmsl_cfg
3228     This parameter of type pointer to _mss_mac_mmsl_config_t_, points to the
3229     configuration structure which will receive a copy of the current MMSL
3230     configuration.
3231 
3232   @return
3233     This function does not return a value.
3234  */
3235 void
3236 MSS_MAC_get_mmsl_mode
3237 (
3238     const mss_mac_instance_t *this_mac,
3239     mss_mac_mmsl_config_t *mmsl_cfg
3240 );
3241 
3242 /***************************************************************************//**
3243   The _MSS_MAC_start_preemption_verify()_ function is used to initiate a link
3244   preemption verification operation by the MAC Merge Sublayer component of the
3245   GEM. The progress and completion status of the operation can be monitored by
3246   calling the _MSS_MAC_get_mmsl_status()_ function until the operation
3247   completes.
3248 
3249   The function only operates on the pMAC.
3250 
3251   @param this_mac
3252     This parameter is a pointer to one of the global _mss_mac_instance_t_
3253     structures which identifies the MAC that the function is to operate on.
3254     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3255     and eMAC1.
3256 
3257   @return
3258     This function does not return a value.
3259  */
3260 void
3261 MSS_MAC_start_preemption_verify
3262 (
3263     const mss_mac_instance_t *this_mac
3264 );
3265 
3266 /***************************************************************************//**
3267   The _MSS_MAC_get_mmsl_status()_ function is used to monitor the current state
3268   of the MAC Merge Sublayer component of the GEM. The function returns the raw
3269   32 bit value from the MMSL Status register and the definitions in
3270   _mss_ethernet_mac_regs.h_ can be used to examine the status.
3271 
3272   The function only operates on the pMAC.
3273 
3274   @param this_mac
3275     This parameter is a pointer to one of the global _mss_mac_instance_t_
3276     structures which identifies the MAC that the function is to operate on.
3277     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3278     and eMAC1.
3279 
3280   @return
3281     This function returns a 32 bit value which is a copy of the MMSL Status
3282     register. The register bit defines for the MMSL Status register can be used
3283     to examine the return value including the _GEM_VERIFY_*_ defines which
3284     enumerate the verification state machine.
3285  */
3286 uint32_t
3287 MSS_MAC_get_mmsl_status
3288 (
3289     const mss_mac_instance_t *this_mac
3290 );
3291 
3292 /***************************************************************************//**
3293   The _MSS_MAC_get_mmsl_stats()_ function is used to retrieve the statistics
3294   counts from the MAC Merge Sublayer component of the GEM.
3295 
3296   The function only operates on the pMAC.
3297 
3298   @param this_mac
3299     This parameter is a pointer to one of the global _mss_mac_instance_t_
3300     structures which identifies the MAC that the function is to operate on.
3301     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3302     and eMAC1.
3303 
3304   @param stats
3305     This parameter is a pointer to an _mss_mac_mmsl_stats_t_ structure which
3306     will be populated with the current MMSL statistics counts.
3307 
3308   @return
3309     This function does not return a value.
3310  */
3311 void
3312 MSS_MAC_get_mmsl_stats
3313 (
3314     const mss_mac_instance_t *this_mac,
3315     mss_mac_mmsl_stats_t *stats
3316 );
3317 
3318 /***************************************************************************//**
3319   The _MSS_MAC_set_tx_cutthru()_ function is used to set the transmit cutthru
3320   level for the GEM DMA engine. The useful ranges are different for the eMAC and
3321   pMAC and will also differ based on the allocation of DMA buffer space to
3322   active queues.
3323 
3324   This setting should be used with caution and the correct values
3325   will depend on the overall bus speed amongst other things.
3326 
3327   __Note:__ This value may need to be configured to allow sending Jumbo frames
3328   of more than approximately 3,880 bytes depending on system configuration.
3329 
3330   @param this_mac
3331     This parameter is a pointer to one of the global _mss_mac_instance_t_
3332     structures which identifies the MAC that the function is to operate on.
3333     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3334     and eMAC1.
3335 
3336   @param level
3337     This 32 bit parameter indicates the minimum data to be read into the DMA
3338     buffer before cutthru operation begins.
3339 
3340   @return
3341     This function does not return a value.
3342  */
3343 void
3344 MSS_MAC_set_tx_cutthru
3345 (
3346     const mss_mac_instance_t *this_mac, uint32_t level
3347 );
3348 
3349 /***************************************************************************//**
3350   The _MSS_MAC_set_rx_cutthru()_ function is used to set the receive cutthru
3351   level for the GEM DMA engine. The useful ranges are different for the eMAC
3352   and pMAC.
3353 
3354   This setting should be used with caution and the correct values will depend on
3355   the overall bus speed amongst other things.
3356 
3357   __Note:__ This value may need to be configured to allow receiving Jumbo frames
3358   of more than approximately 3,880 bytes depending on system configuration.
3359 
3360   @param this_mac
3361     This parameter is a pointer to one of the global _mss_mac_instance_t_
3362     structures which identifies the MAC that the function is to operate on.
3363     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3364     and eMAC1.
3365 
3366   @param level
3367     This 32 bit parameter indicates the minimum data to be written from the FIFO
3368     into the DMA buffer before cutthru operation begins.
3369 
3370   @return
3371     This function does not return a value.
3372  */
3373 void
3374 MSS_MAC_set_rx_cutthru
3375 (
3376     const mss_mac_instance_t *this_mac,
3377     uint32_t level
3378 );
3379 
3380 /***************************************************************************//**
3381   The _MSS_MAC_get_tx_cutthru()_ function is used to retrieve the current
3382   transmit cutthru level for the GEM DMA engine.
3383 
3384   @param this_mac
3385     This parameter is a pointer to one of the global _mss_mac_instance_t_
3386     structures which identifies the MAC that the function is to operate on.
3387     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3388     and eMAC1.
3389 
3390   @return
3391     This function returns an unsigned 32 bit value representing the current
3392     minimum amount of data to be read into the DMA buffer before cutthru
3393     operation begins.
3394  */
3395 uint32_t
3396 MSS_MAC_get_tx_cutthru
3397 (
3398     const mss_mac_instance_t *this_mac
3399 );
3400 
3401 /***************************************************************************//**
3402   The _MSS_MAC_get_rx_cutthru()_ function is used to retrieve the current
3403   receive cutthru level for the GEM DMA engine.
3404 
3405   @param this_mac
3406     This parameter is a pointer to one of the global _mss_mac_instance_t_
3407     structures which identifies the MAC that the function is to operate on.
3408     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3409     and eMAC1.
3410 
3411   @return
3412     This function returns an unsigned 32 bit value representing the current
3413     minimum amount of data to be read to be written from the FIFO into the DMA
3414     buffer before cutthru operation begins.
3415  */
3416 uint32_t
3417 MSS_MAC_get_rx_cutthru
3418 (
3419     const mss_mac_instance_t *this_mac
3420 );
3421 
3422 /***************************************************************************//**
3423   The _MSS_MAC_tx_enable()_ function is used to start or restart transmit
3424   operations. It can be used as part of recovery from errors which may have
3425   resulted in transmission being stopped.
3426 
3427   @param this_mac
3428     This parameter is a pointer to one of the global _mss_mac_instance_t_
3429     structures which identifies the MAC that the function is to operate on.
3430     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3431     and eMAC1.
3432 
3433   @return
3434     This function does not return a value.
3435  */
3436 void
3437 MSS_MAC_tx_enable
3438 (
3439     const mss_mac_instance_t *this_mac
3440 );
3441 
3442 /***************************************************************************//**
3443   The _MSS_MAC_set_jumbo_frames_mode()_ function is used to enable and disable
3444   reception of Jumbo frames. For this function to work correctly, the
3445   _jumbo_frame_enable_ value in the _mss_mac_cfg_t_ structure used to configure
3446   the Ethernet MAC will have to have been set to true.
3447 
3448   @param this_mac
3449     This parameter is a pointer to one of the global _mss_mac_instance_t_
3450     structures which identifies the MAC that the function is to operate on.
3451     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3452     and eMAC1.
3453 
3454 @param state
3455     This boolean parameter is set to true to enable Jumbo frame support and
3456     false to disable Jumbo frame support.
3457 
3458   @return
3459     This function does not return a value.
3460  */
3461 void
3462 MSS_MAC_set_jumbo_frames_mode
3463 (
3464     const mss_mac_instance_t *this_mac,
3465     bool state
3466 );
3467 
3468 /***************************************************************************//**
3469   The _MSS_MAC_get_jumbo_frames_mode()_ function is used to determine if Jumbo
3470   frame support is enabled or not.
3471 
3472   @param this_mac
3473     This parameter is a pointer to one of the global _mss_mac_instance_t_
3474     structures which identifies the MAC that the function is to operate on.
3475     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3476     and eMAC1.
3477 
3478   @return
3479     This function returns a boolean value which is true if Jumbo frame support
3480     is enabled and false otherwise.
3481  */
3482 bool
3483 MSS_MAC_get_jumbo_frames_mode
3484 (
3485     const mss_mac_instance_t *this_mac
3486 );
3487 
3488 /***************************************************************************//**
3489   The _MSS_MAC_set_jumbo_frame_length()_ function is used to set the maximum
3490   length of Jumbo frames that can be received. The maximum allowed is
3491   _MSS_MAC_JUMBO_MAX_. For this function to work correctly, the
3492   _jumbo_frame_enable_ value in the _mss_mac_cfg_t_ structure used to configure
3493   the Ethernet MAC will have to have been set to true.
3494 
3495   @param this_mac
3496     This parameter is a pointer to one of the global _mss_mac_instance_t_
3497     structures which identifies the MAC that the function is to operate on.
3498     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3499     and eMAC1.
3500 
3501   @param length
3502     This unsigned 32 bit int parameter sets the maximum Jumbo frame length that
3503     the MAC will accept. The upper limit is defined as _MSS_MAC_JUMBO_MAX_.
3504 
3505   @return
3506     This function does not return a value.
3507  */
3508 void
3509 MSS_MAC_set_jumbo_frame_length
3510 (
3511     const mss_mac_instance_t *this_mac,
3512     uint32_t length
3513 );
3514 
3515 /***************************************************************************//**
3516   The _MSS_MAC_get_jumbo_frame_length()_ function is used to retrieve the
3517   current maximum length of Jumbo frames that can be received. For this function
3518   to work correctly, the _jumbo_frame_enable_ value in _the mss_mac_cfg_t_
3519   structure used to configure the Ethernet MAC will have to have been set to
3520   true.
3521 
3522   @param this_mac
3523     This parameter is a pointer to one of the global _mss_mac_instance_t_
3524     structures which identifies the MAC that the function is to operate on.
3525     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3526     and eMAC1.
3527 
3528   @return
3529     This function returns an unsigned 32 bit int indicating the current maximum
3530     Jumbo frame length that the MAC will accept.
3531  */
3532 uint32_t
3533 MSS_MAC_get_jumbo_frame_length
3534 (
3535     const mss_mac_instance_t *this_mac
3536 );
3537 
3538 /***************************************************************************//**
3539   The _MSS_MAC_set_pause_frame_copy_to_mem()_ function is used to control the
3540   writing of pause frames into memory.
3541 
3542   The default operation is not to copy pause frames into memory.
3543 
3544   @param this_mac
3545     This parameter is a pointer to one of the global _mss_mac_instance_t_
3546     structures which identifies the MAC that the function is to operate on.
3547     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3548     and eMAC1.
3549 
3550   @param state
3551     This boolean value is true to enable copying of pause frames to memory and
3552     false to disable.
3553 
3554   @return
3555     This function does not return a value.
3556  */
3557 void
3558 MSS_MAC_set_pause_frame_copy_to_mem
3559 (
3560     const mss_mac_instance_t *this_mac,
3561     bool state
3562 );
3563 
3564 /***************************************************************************//**
3565   The _MSS_MAC_get_pause_frame_copy_to_mem()_ function is used to determine
3566   whether the GEM is currently configured to copy pause frames to memory.
3567 
3568   @param this_mac
3569     This parameter is a pointer to one of the global _mss_mac_instance_t_
3570     structures which identifies the MAC that the function is to operate on.
3571     There are between 1 and 4 such structures identifying pMAC0, eMAC0, pMAC1
3572     and eMAC1.
3573 
3574   @return
3575     This function returns a boolean value which is true if copying of pause
3576     frames to memory is enabled and false otherwise.
3577 
3578  */
3579 bool
3580 MSS_MAC_get_pause_frame_copy_to_mem
3581 (
3582     const mss_mac_instance_t *this_mac
3583 );
3584 
3585 
3586 #ifdef __cplusplus
3587 }
3588 #endif
3589 
3590 #endif /* MSS_ETHERNET_MAC_H_ */
3591