1/*
2 * Copyright 2008-2012 Freescale Semiconductor Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *     * Redistributions of source code must retain the above copyright
7 *       notice, this list of conditions and the following disclaimer.
8 *     * Redistributions in binary form must reproduce the above copyright
9 *       notice, this list of conditions and the following disclaimer in the
10 *       documentation and/or other materials provided with the distribution.
11 *     * Neither the name of Freescale Semiconductor nor the
12 *       names of its contributors may be used to endorse or promote products
13 *       derived from this software without specific prior written permission.
14 *
15 *
16 * ALTERNATIVELY, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL") as published by the Free Software
18 * Foundation, either version 2 of that License or (at your option) any
19 * later version.
20 *
21 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33
34/**************************************************************************//**
35 @File          fm_mac_ext.h
36
37 @Description   FM MAC ...
38*//***************************************************************************/
39#ifndef __FM_MAC_EXT_H
40#define __FM_MAC_EXT_H
41
42#include "std_ext.h"
43#include "enet_ext.h"
44
45
46/**************************************************************************//**
47
48 @Group         FM_grp Frame Manager API
49
50 @Description   FM API functions, definitions and enums
51
52 @{
53*//***************************************************************************/
54
55/**************************************************************************//**
56 @Group         FM_mac_grp FM MAC
57
58 @Description   FM MAC API functions, definitions and enums
59
60 @{
61*//***************************************************************************/
62
63#define FM_MAC_NO_PFC   0xff
64
65
66/**************************************************************************//**
67 @Description   FM MAC Exceptions
68*//***************************************************************************/
69typedef enum e_FmMacExceptions {
70    e_FM_MAC_EX_10G_MDIO_SCAN_EVENTMDIO = 0                     /**< 10GEC MDIO scan event interrupt */
71   ,e_FM_MAC_EX_10G_MDIO_CMD_CMPL                               /**< 10GEC MDIO command completion interrupt */
72   ,e_FM_MAC_EX_10G_REM_FAULT                                   /**< 10GEC, mEMAC Remote fault interrupt */
73   ,e_FM_MAC_EX_10G_LOC_FAULT                                   /**< 10GEC, mEMAC Local fault interrupt */
74   ,e_FM_MAC_EX_10G_1TX_ECC_ER                                  /**< 10GEC, mEMAC Transmit frame ECC error interrupt */
75   ,e_FM_MAC_EX_10G_TX_FIFO_UNFL                                /**< 10GEC, mEMAC Transmit FIFO underflow interrupt */
76   ,e_FM_MAC_EX_10G_TX_FIFO_OVFL                                /**< 10GEC, mEMAC Transmit FIFO overflow interrupt */
77   ,e_FM_MAC_EX_10G_TX_ER                                       /**< 10GEC Transmit frame error interrupt */
78   ,e_FM_MAC_EX_10G_RX_FIFO_OVFL                                /**< 10GEC, mEMAC Receive FIFO overflow interrupt */
79   ,e_FM_MAC_EX_10G_RX_ECC_ER                                   /**< 10GEC, mEMAC Receive frame ECC error interrupt */
80   ,e_FM_MAC_EX_10G_RX_JAB_FRM                                  /**< 10GEC Receive jabber frame interrupt */
81   ,e_FM_MAC_EX_10G_RX_OVRSZ_FRM                                /**< 10GEC Receive oversized frame interrupt */
82   ,e_FM_MAC_EX_10G_RX_RUNT_FRM                                 /**< 10GEC Receive runt frame interrupt */
83   ,e_FM_MAC_EX_10G_RX_FRAG_FRM                                 /**< 10GEC Receive fragment frame interrupt */
84   ,e_FM_MAC_EX_10G_RX_LEN_ER                                   /**< 10GEC Receive payload length error interrupt */
85   ,e_FM_MAC_EX_10G_RX_CRC_ER                                   /**< 10GEC Receive CRC error interrupt */
86   ,e_FM_MAC_EX_10G_RX_ALIGN_ER                                 /**< 10GEC Receive alignment error interrupt */
87   ,e_FM_MAC_EX_1G_BAB_RX                                       /**< dTSEC Babbling receive error */
88   ,e_FM_MAC_EX_1G_RX_CTL                                       /**< dTSEC Receive control (pause frame) interrupt */
89   ,e_FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET                      /**< dTSEC Graceful transmit stop complete */
90   ,e_FM_MAC_EX_1G_BAB_TX                                       /**< dTSEC Babbling transmit error */
91   ,e_FM_MAC_EX_1G_TX_CTL                                       /**< dTSEC Transmit control (pause frame) interrupt */
92   ,e_FM_MAC_EX_1G_TX_ERR                                       /**< dTSEC Transmit error */
93   ,e_FM_MAC_EX_1G_LATE_COL                                     /**< dTSEC Late collision */
94   ,e_FM_MAC_EX_1G_COL_RET_LMT                                  /**< dTSEC Collision retry limit */
95   ,e_FM_MAC_EX_1G_TX_FIFO_UNDRN                                /**< dTSEC Transmit FIFO underrun */
96   ,e_FM_MAC_EX_1G_MAG_PCKT                                     /**< dTSEC Magic Packet detection */
97   ,e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET                           /**< dTSEC MII management read completion */
98   ,e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET                           /**< dTSEC MII management write completion */
99   ,e_FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET                      /**< dTSEC Graceful receive stop complete */
100   ,e_FM_MAC_EX_1G_TX_DATA_ERR                                  /**< dTSEC Internal data error on transmit */
101   ,e_FM_MAC_EX_1G_RX_DATA_ERR                                  /**< dTSEC Internal data error on receive */
102   ,e_FM_MAC_EX_1G_1588_TS_RX_ERR                               /**< dTSEC Time-Stamp Receive Error */
103   ,e_FM_MAC_EX_1G_RX_MIB_CNT_OVFL                              /**< dTSEC MIB counter overflow */
104   ,e_FM_MAC_EX_TS_FIFO_ECC_ERR                                 /**< mEMAC Time-stamp FIFO ECC error interrupt;
105                                                                     not supported on T4240/B4860 rev1 chips */
106   ,e_FM_MAC_EX_MAGIC_PACKET_INDICATION = e_FM_MAC_EX_1G_MAG_PCKT
107                                                                /**< mEMAC Magic Packet Indication Interrupt */
108} e_FmMacExceptions;
109
110/**************************************************************************//**
111 @Description   TM MAC statistics level
112*//***************************************************************************/
113typedef enum e_FmMacStatisticsLevel {
114    e_FM_MAC_NONE_STATISTICS = 0,       /**< No statistics */
115    e_FM_MAC_PARTIAL_STATISTICS,        /**< Only error counters are available; Optimized for performance */
116    e_FM_MAC_FULL_STATISTICS            /**< All counters available; Not optimized for performance */
117} e_FmMacStatisticsLevel;
118
119
120#if (DPAA_VERSION >= 11)
121/**************************************************************************//**
122 @Description   Priority Flow Control Parameters
123*//***************************************************************************/
124typedef struct t_FmMacPfcParams {
125    bool        pfcEnable;                                      /**< Enable/Disable PFC */
126
127    uint16_t    pauseQuanta[FM_MAX_NUM_OF_PFC_PRIORITIES];      /**< Pause Quanta per priority to be sent in a pause frame. Each quanta represents a 512 bit-times*/
128
129    uint16_t    pauseThresholdQuanta[FM_MAX_NUM_OF_PFC_PRIORITIES];/**< Pause threshold per priority, when timer passes this threshold time a PFC frames is sent again if the port is still congested or BM pool in depletion*/
130
131
132} t_FmMacPfcParams;
133#endif /* (DPAA_VERSION >= 11) */
134
135/**************************************************************************//**
136 @Function      t_FmMacExceptionCallback
137
138 @Description   Fm Mac Exception Callback from FM MAC to the user
139
140 @Param[in]     h_App             - Handle to the upper layer handler
141
142 @Param[in]     exceptions        - The exception that occurred
143
144 @Return        void.
145*//***************************************************************************/
146typedef void (t_FmMacExceptionCallback)(t_Handle h_App, e_FmMacExceptions exceptions);
147
148
149/**************************************************************************//**
150 @Description   TM MAC statistics rfc3635
151*//***************************************************************************/
152typedef struct t_FmMacStatistics {
153/* RMON */
154    uint64_t  eStatPkts64;             /**< r-10G tr-DT 64 byte frame counter */
155    uint64_t  eStatPkts65to127;        /**< r-10G 65 to 127 byte frame counter */
156    uint64_t  eStatPkts128to255;       /**< r-10G 128 to 255 byte frame counter */
157    uint64_t  eStatPkts256to511;       /**< r-10G 256 to 511 byte frame counter */
158    uint64_t  eStatPkts512to1023;      /**< r-10G 512 to 1023 byte frame counter */
159    uint64_t  eStatPkts1024to1518;     /**< r-10G 1024 to 1518 byte frame counter */
160    uint64_t  eStatPkts1519to1522;     /**< r-10G 1519 to 1522 byte good frame count */
161/* */
162    uint64_t  eStatFragments;          /**< Total number of packets that were less than 64 octets long with a wrong CRC.*/
163    uint64_t  eStatJabbers;            /**< Total number of packets longer than valid maximum length octets */
164    uint64_t  eStatsDropEvents;        /**< number of dropped packets due to internal errors of the MAC Client (during receive). */
165    uint64_t  eStatCRCAlignErrors;     /**< Incremented when frames of correct length but with CRC error are received.*/
166    uint64_t  eStatUndersizePkts;      /**< Incremented for frames under 64 bytes with a valid FCS and otherwise well formed;
167                                            This count does not include range length errors */
168    uint64_t  eStatOversizePkts;       /**< Incremented for frames which exceed 1518 (non VLAN) or 1522 (VLAN) and contains
169                                            a valid FCS and otherwise well formed */
170/* Pause */
171    uint64_t  teStatPause;             /**< Pause MAC Control received */
172    uint64_t  reStatPause;             /**< Pause MAC Control sent */
173/* MIB II */
174    uint64_t  ifInOctets;              /**< Total number of byte received. */
175    uint64_t  ifInPkts;                /**< Total number of packets received.*/
176    uint64_t  ifInUcastPkts;           /**< Total number of unicast frame received;
177                                            NOTE: this counter is not supported on dTSEC MAC */
178    uint64_t  ifInMcastPkts;           /**< Total number of multicast frame received*/
179    uint64_t  ifInBcastPkts;           /**< Total number of broadcast frame received */
180    uint64_t  ifInDiscards;            /**< Frames received, but discarded due to problems within the MAC RX. */
181    uint64_t  ifInErrors;              /**< Number of frames received with error:
182                                               - FIFO Overflow Error
183                                               - CRC Error
184                                               - Frame Too Long Error
185                                               - Alignment Error
186                                               - The dedicated Error Code (0xfe, not a code error) was received */
187    uint64_t  ifOutOctets;             /**< Total number of byte sent. */
188    uint64_t  ifOutPkts;               /**< Total number of packets sent .*/
189    uint64_t  ifOutUcastPkts;          /**< Total number of unicast frame sent;
190                                            NOTE: this counter is not supported on dTSEC MAC */
191    uint64_t  ifOutMcastPkts;          /**< Total number of multicast frame sent */
192    uint64_t  ifOutBcastPkts;          /**< Total number of multicast frame sent */
193    uint64_t  ifOutDiscards;           /**< Frames received, but discarded due to problems within the MAC TX N/A!.*/
194    uint64_t  ifOutErrors;             /**< Number of frames transmitted with error:
195                                               - FIFO Overflow Error
196                                               - FIFO Underflow Error
197                                               - Other */
198} t_FmMacStatistics;
199
200
201/**************************************************************************//**
202 @Group         FM_mac_init_grp FM MAC Initialization Unit
203
204 @Description   FM MAC Initialization Unit
205
206 @{
207*//***************************************************************************/
208
209/**************************************************************************//**
210 @Description   FM MAC config input
211*//***************************************************************************/
212typedef struct t_FmMacParams {
213    uintptr_t                   baseAddr;           /**< Base of memory mapped FM MAC registers */
214    t_EnetAddr                  addr;               /**< MAC address of device; First octet is sent first */
215    uint8_t                     macId;              /**< MAC ID;
216                                                         numbering of dTSEC and 1G-mEMAC:
217                                                            0 - FM_MAX_NUM_OF_1G_MACS;
218                                                         numbering of 10G-MAC (TGEC) and 10G-mEMAC:
219                                                            0 - FM_MAX_NUM_OF_10G_MACS */
220    e_EnetMode                  enetMode;           /**< Ethernet operation mode (MAC-PHY interface and speed);
221                                                         Note that the speed should indicate the maximum rate that
222                                                         this MAC should support rather than the actual speed;
223                                                         i.e. user should use the FM_MAC_AdjustLink() routine to
224                                                         provide accurate speed;
225                                                         In case of mEMAC RGMII mode, the MAC is configured to RGMII
226                                                         automatic mode, where actual speed/duplex mode information
227                                                         is provided by PHY automatically in-band; FM_MAC_AdjustLink()
228                                                         function should be used to switch to manual RGMII speed/duplex mode
229                                                         configuration if RGMII PHY doesn't support in-band status signaling;
230                                                         In addition, in mEMAC, in case where user is using the higher MACs
231                                                         (i.e. the MACs that should support 10G), user should pass here
232                                                         speed=10000 even if the interface is not allowing that (e.g. SGMII). */
233    t_Handle                    h_Fm;               /**< A handle to the FM object this port related to */
234    int                         mdioIrq;            /**< MDIO exceptions interrupt source - not valid for all
235                                                         MACs; MUST be set to 'NO_IRQ' for MACs that don't have
236                                                         mdio-irq, or for polling */
237    t_FmMacExceptionCallback    *f_Event;           /**< MDIO Events Callback Routine         */
238    t_FmMacExceptionCallback    *f_Exception;       /**< Exception Callback Routine         */
239    t_Handle                    h_App;              /**< A handle to an application layer object; This handle will
240                                                         be passed by the driver upon calling the above callbacks */
241} t_FmMacParams;
242
243
244/**************************************************************************//**
245 @Function      FM_MAC_Config
246
247 @Description   Creates descriptor for the FM MAC module.
248
249                The routine returns a handle (descriptor) to the FM MAC object.
250                This descriptor must be passed as first parameter to all other
251                FM MAC function calls.
252
253                No actual initialization or configuration of FM MAC hardware is
254                done by this routine.
255
256 @Param[in]     p_FmMacParam   - Pointer to data structure of parameters
257
258 @Retval        Handle to FM MAC object, or NULL for Failure.
259*//***************************************************************************/
260t_Handle FM_MAC_Config(t_FmMacParams *p_FmMacParam);
261
262/**************************************************************************//**
263 @Function      FM_MAC_Init
264
265 @Description   Initializes the FM MAC module
266
267 @Param[in]     h_FmMac - FM module descriptor
268
269 @Return        E_OK on success; Error code otherwise.
270*//***************************************************************************/
271t_Error  FM_MAC_Init(t_Handle h_FmMac);
272
273/**************************************************************************//**
274 @Function      FM_Free
275
276 @Description   Frees all resources that were assigned to FM MAC module.
277
278                Calling this routine invalidates the descriptor.
279
280 @Param[in]     h_FmMac - FM module descriptor
281
282 @Return        E_OK on success; Error code otherwise.
283*//***************************************************************************/
284t_Error  FM_MAC_Free(t_Handle h_FmMac);
285
286
287/**************************************************************************//**
288 @Group         FM_mac_advanced_init_grp    FM MAC Advanced Configuration Unit
289
290 @Description   Configuration functions used to change default values.
291
292 @{
293*//***************************************************************************/
294
295/**************************************************************************//**
296 @Function      FM_MAC_ConfigResetOnInit
297
298 @Description   Tell the driver whether to reset the FM MAC before initialization or
299                not. It changes the default configuration [DEFAULT_resetOnInit].
300
301 @Param[in]     h_FmMac    A handle to a FM MAC Module.
302 @Param[in]     enable     When TRUE, FM will be reset before any initialization.
303
304 @Return        E_OK on success; Error code otherwise.
305
306 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
307*//***************************************************************************/
308t_Error FM_MAC_ConfigResetOnInit(t_Handle h_FmMac, bool enable);
309
310/**************************************************************************//**
311 @Function      FM_MAC_ConfigLoopback
312
313 @Description   Enable/Disable internal loopback mode
314
315 @Param[in]     h_FmMac    A handle to a FM MAC Module.
316 @Param[in]     enable     TRUE to enable or FALSE to disable.
317
318 @Return        E_OK on success; Error code otherwise.
319
320 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
321*//***************************************************************************/
322t_Error FM_MAC_ConfigLoopback(t_Handle h_FmMac, bool enable);
323
324/**************************************************************************//**
325 @Function      FM_MAC_ConfigMaxFrameLength
326
327 @Description   Setup maximum Rx Frame Length (in 1G MAC, effects also Tx)
328
329 @Param[in]     h_FmMac    A handle to a FM MAC Module.
330 @Param[in]     newVal     MAX Frame length
331
332 @Return        E_OK on success; Error code otherwise.
333
334 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
335*//***************************************************************************/
336t_Error FM_MAC_ConfigMaxFrameLength(t_Handle h_FmMac, uint16_t newVal);
337
338/**************************************************************************//**
339 @Function      FM_MAC_ConfigWan
340
341 @Description   ENABLE WAN mode in 10G-MAC
342
343 @Param[in]     h_FmMac    A handle to a FM MAC Module.
344 @Param[in]     enable     TRUE to enable or FALSE to disable.
345
346 @Return        E_OK on success; Error code otherwise.
347
348 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
349*//***************************************************************************/
350t_Error FM_MAC_ConfigWan(t_Handle h_FmMac, bool enable);
351
352/**************************************************************************//**
353 @Function      FM_MAC_ConfigPadAndCrc
354
355 @Description   Config PAD and CRC mode
356
357 @Param[in]     h_FmMac    A handle to a FM MAC Module.
358 @Param[in]     enable     TRUE to enable or FALSE to disable.
359
360 @Return        E_OK on success; Error code otherwise.
361
362 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
363                Not supported on 10G-MAC (i.e. CRC & PAD are added automatically
364                by HW); on mEMAC, this routine supports only PAD (i.e. CRC is
365                added automatically by HW).
366*//***************************************************************************/
367t_Error FM_MAC_ConfigPadAndCrc(t_Handle h_FmMac, bool enable);
368
369/**************************************************************************//**
370 @Function      FM_MAC_ConfigHalfDuplex
371
372 @Description   Config Half Duplex Mode
373
374 @Param[in]     h_FmMac    A handle to a FM MAC Module.
375 @Param[in]     enable     TRUE to enable or FALSE to disable.
376
377 @Return        E_OK on success; Error code otherwise.
378
379 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
380*//***************************************************************************/
381t_Error FM_MAC_ConfigHalfDuplex(t_Handle h_FmMac, bool enable);
382
383/**************************************************************************//**
384 @Function      FM_MAC_ConfigTbiPhyAddr
385
386 @Description   Configures the address of internal TBI PHY.
387
388 @Param[in]     h_FmMac    A handle to a FM MAC Module.
389 @Param[in]     newVal     TBI PHY address (1-31).
390
391 @Return        E_OK on success; Error code otherwise.
392
393 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
394*//***************************************************************************/
395t_Error FM_MAC_ConfigTbiPhyAddr(t_Handle h_FmMac, uint8_t newVal);
396
397/**************************************************************************//**
398 @Function      FM_MAC_ConfigLengthCheck
399
400 @Description   Configure the frame length checking.
401
402 @Param[in]     h_FmMac    A handle to a FM MAC Module.
403 @Param[in]     enable     TRUE to enable or FALSE to disable.
404
405 @Return        E_OK on success; Error code otherwise.
406
407 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
408*//***************************************************************************/
409t_Error FM_MAC_ConfigLengthCheck(t_Handle h_FmMac, bool enable);
410
411/**************************************************************************//**
412 @Function      FM_MAC_ConfigException
413
414 @Description   Change Exception selection from default
415
416 @Param[in]     h_FmMac         A handle to a FM MAC Module.
417 @Param[in]     ex              Type of the desired exceptions
418 @Param[in]     enable          TRUE to enable the specified exception, FALSE to disable it.
419
420 @Return        E_OK on success; Error code otherwise.
421
422 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
423*//***************************************************************************/
424t_Error FM_MAC_ConfigException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable);
425
426#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
427t_Error FM_MAC_ConfigSkipFman11Workaround (t_Handle h_FmMac);
428#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
429/** @} */ /* end of FM_mac_advanced_init_grp group */
430/** @} */ /* end of FM_mac_init_grp group */
431
432
433/**************************************************************************//**
434 @Group         FM_mac_runtime_control_grp FM MAC Runtime Control Unit
435
436 @Description   FM MAC Runtime control unit API functions, definitions and enums.
437
438 @{
439*//***************************************************************************/
440
441/**************************************************************************//**
442 @Function      FM_MAC_Enable
443
444 @Description   Enable the MAC
445
446 @Param[in]     h_FmMac    A handle to a FM MAC Module.
447 @Param[in]     mode       Mode of operation (RX, TX, Both)
448
449 @Return        E_OK on success; Error code otherwise.
450
451 @Cautions      Allowed only following FM_MAC_Init().
452*//***************************************************************************/
453t_Error FM_MAC_Enable(t_Handle h_FmMac,  e_CommMode mode);
454
455/**************************************************************************//**
456 @Function      FM_MAC_Disable
457
458 @Description   DISABLE the MAC
459
460 @Param[in]     h_FmMac    A handle to a FM MAC Module.
461 @Param[in]     mode       Define what part to Disable (RX,  TX or BOTH)
462
463 @Return        E_OK on success; Error code otherwise.
464
465 @Cautions      Allowed only following FM_MAC_Init().
466*//***************************************************************************/
467t_Error FM_MAC_Disable(t_Handle h_FmMac, e_CommMode mode);
468
469/**************************************************************************//**
470 @Function      FM_MAC_Resume
471
472 @Description   Re-init the MAC after suspend
473
474 @Param[in]     h_FmMac    A handle to a FM MAC Module.
475
476 @Return        E_OK on success; Error code otherwise.
477
478 @Cautions      Allowed only following FM_MAC_Init().
479*//***************************************************************************/
480t_Error FM_MAC_Resume(t_Handle h_FmMac);
481
482/**************************************************************************//**
483 @Function      FM_MAC_Enable1588TimeStamp
484
485 @Description   Enables the TSU operation.
486
487 @Param[in]     h_Fm   - Handle to the PTP as returned from the FM_MAC_PtpConfig.
488
489 @Return        E_OK on success; Error code otherwise.
490
491 @Cautions      Allowed only following FM_MAC_Init().
492*//***************************************************************************/
493t_Error FM_MAC_Enable1588TimeStamp(t_Handle h_Fm);
494
495/**************************************************************************//**
496 @Function      FM_MAC_Disable1588TimeStamp
497
498 @Description   Disables the TSU operation.
499
500 @Param[in]     h_Fm   - Handle to the PTP as returned from the FM_MAC_PtpConfig.
501
502 @Return        E_OK on success; Error code otherwise.
503
504 @Cautions      Allowed only following FM_MAC_Init().
505*//***************************************************************************/
506t_Error FM_MAC_Disable1588TimeStamp(t_Handle h_Fm);
507
508/**************************************************************************//**
509 @Function      FM_MAC_SetTxAutoPauseFrames
510
511 @Description   Enable/Disable transmission of Pause-Frames.
512                The routine changes the default configuration [DEFAULT_TX_PAUSE_TIME].
513
514 @Param[in]     h_FmMac       -  A handle to a FM MAC Module.
515 @Param[in]     pauseTime     -  Pause quanta value used with transmitted pause frames.
516                                 Each quanta represents a 512 bit-times; Note that '0'
517                                 as an input here will be used as disabling the
518                                 transmission of the pause-frames.
519
520 @Return        E_OK on success; Error code otherwise.
521
522 @Cautions      Allowed only following FM_MAC_Init().
523*//***************************************************************************/
524t_Error FM_MAC_SetTxAutoPauseFrames(t_Handle h_FmMac,
525                                    uint16_t pauseTime);
526
527 /**************************************************************************//**
528 @Function      FM_MAC_SetTxPauseFrames
529
530 @Description   Enable/Disable transmission of Pause-Frames.
531                The routine changes the default configuration:
532                pause-time - [DEFAULT_TX_PAUSE_TIME]
533                threshold-time - [0]
534
535 @Param[in]     h_FmMac       -  A handle to a FM MAC Module.
536 @Param[in]     priority      -  the PFC class of service; use 'FM_MAC_NO_PFC'
537                                 to indicate legacy pause support (i.e. no PFC).
538 @Param[in]     pauseTime     -  Pause quanta value used with transmitted pause frames.
539                                 Each quanta represents a 512 bit-times;
540                                 Note that '0' as an input here will be used as disabling the
541                                 transmission of the pause-frames.
542 @Param[in]     threshTime    -  Pause Threshold equanta value used by the MAC to retransmit pause frame.
543                                 if the situation causing a pause frame to be sent didn't finish when the timer
544                                 reached the threshold quanta, the MAC will retransmit the pause frame.
545                                 Each quanta represents a 512 bit-times.
546
547 @Return        E_OK on success; Error code otherwise.
548
549 @Cautions      Allowed only following FM_MAC_Init().
550                In order for PFC to work properly the user must configure
551                TNUM-aging in the tx-port it is recommended that pre-fetch and
552                rate limit in the tx port should be disabled;
553                PFC is supported only on new mEMAC; i.e. in MACs that don't have
554                PFC support (10G-MAC and dTSEC), user should use 'FM_MAC_NO_PFC'
555                in the 'priority' field.
556*//***************************************************************************/
557t_Error FM_MAC_SetTxPauseFrames(t_Handle h_FmMac,
558                                uint8_t  priority,
559                                uint16_t pauseTime,
560                                uint16_t threshTime);
561
562/**************************************************************************//**
563 @Function      FM_MAC_SetRxIgnorePauseFrames
564
565 @Description   Enable/Disable ignoring of Pause-Frames.
566
567 @Param[in]     h_FmMac    - A handle to a FM MAC Module.
568 @Param[in]     en         - boolean indicates whether to ignore the incoming pause
569                             frames or not.
570
571 @Return        E_OK on success; Error code otherwise.
572
573 @Cautions      Allowed only following FM_MAC_Init().
574*//***************************************************************************/
575t_Error FM_MAC_SetRxIgnorePauseFrames(t_Handle h_FmMac, bool en);
576
577/**************************************************************************//**
578 @Function      FM_MAC_SetWakeOnLan
579
580 @Description   Enable/Disable Wake On Lan support
581
582 @Param[in]     h_FmMac    - A handle to a FM MAC Module.
583 @Param[in]     en         - boolean indicates whether to enable Wake On Lan
584                             support or not.
585
586 @Return        E_OK on success; Error code otherwise.
587
588 @Cautions      Allowed only following FM_MAC_Init().
589*//***************************************************************************/
590t_Error FM_MAC_SetWakeOnLan(t_Handle h_FmMac, bool en);
591
592/**************************************************************************//**
593 @Function      FM_MAC_ResetCounters
594
595 @Description   reset all statistics counters
596
597 @Param[in]     h_FmMac    - A handle to a FM MAC Module.
598
599 @Return        E_OK on success; Error code otherwise.
600
601 @Cautions      Allowed only following FM_MAC_Init().
602*//***************************************************************************/
603t_Error FM_MAC_ResetCounters(t_Handle h_FmMac);
604
605/**************************************************************************//**
606 @Function      FM_MAC_SetException
607
608 @Description   Enable/Disable a specific Exception
609
610 @Param[in]     h_FmMac        - A handle to a FM MAC Module.
611 @Param[in]     ex             - Type of the desired exceptions
612 @Param[in]     enable         - TRUE to enable the specified exception, FALSE to disable it.
613
614
615 @Return        E_OK on success; Error code otherwise.
616
617 @Cautions      Allowed only following FM_MAC_Init().
618*//***************************************************************************/
619t_Error FM_MAC_SetException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable);
620
621/**************************************************************************//**
622 @Function      FM_MAC_SetStatistics
623
624 @Description   Define Statistics level.
625                Where applicable, the routine also enables the MIB counters
626                overflow interrupt in order to keep counters accurate
627                and account for overflows.
628                This routine is relevant only for dTSEC.
629
630 @Param[in]     h_FmMac         - A handle to a FM MAC Module.
631 @Param[in]     statisticsLevel - Full statistics level provides all standard counters but may
632                                  reduce performance. Partial statistics provides only special
633                                  event counters (errors etc.). If selected, regular counters (such as
634                                  byte/packet) will be invalid and will return -1.
635
636 @Return        E_OK on success; Error code otherwise.
637
638 @Cautions      Allowed only following FM_MAC_Init().
639*//***************************************************************************/
640t_Error FM_MAC_SetStatistics(t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel);
641
642/**************************************************************************//**
643 @Function      FM_MAC_GetStatistics
644
645 @Description   get all statistics counters
646
647 @Param[in]     h_FmMac       -  A handle to a FM MAC Module.
648 @Param[in]     p_Statistics  -  Structure with statistics
649
650 @Return        E_OK on success; Error code otherwise.
651
652 @Cautions      Allowed only following FM_Init().
653*//***************************************************************************/
654t_Error FM_MAC_GetStatistics(t_Handle h_FmMac, t_FmMacStatistics *p_Statistics);
655
656/**************************************************************************//**
657 @Function      FM_MAC_ModifyMacAddr
658
659 @Description   Replace the main MAC Address
660
661 @Param[in]     h_FmMac     -   A handle to a FM Module.
662 @Param[in]     p_EnetAddr  -   Ethernet Mac address
663
664 @Return        E_OK on success; Error code otherwise.
665
666 @Cautions      Allowed only after FM_MAC_Init().
667*//***************************************************************************/
668t_Error FM_MAC_ModifyMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
669
670/**************************************************************************//**
671 @Function      FM_MAC_AddHashMacAddr
672
673 @Description   Add an Address to the hash table. This is for filter purpose only.
674
675 @Param[in]     h_FmMac     -   A handle to a FM Module.
676 @Param[in]     p_EnetAddr  -   Ethernet Mac address
677
678 @Return        E_OK on success; Error code otherwise.
679
680 @Cautions      Allowed only following FM_MAC_Init(). It is a filter only address.
681 @Cautions      Some address need to be filterd out in upper FM blocks.
682*//***************************************************************************/
683t_Error FM_MAC_AddHashMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
684
685/**************************************************************************//**
686 @Function      FM_MAC_RemoveHashMacAddr
687
688 @Description   Delete an Address to the hash table. This is for filter purpose only.
689
690 @Param[in]     h_FmMac     -   A handle to a FM Module.
691 @Param[in]     p_EnetAddr  -   Ethernet Mac address
692
693 @Return        E_OK on success; Error code otherwise.
694
695 @Cautions      Allowed only following FM_MAC_Init().
696*//***************************************************************************/
697t_Error FM_MAC_RemoveHashMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
698
699/**************************************************************************//**
700 @Function      FM_MAC_AddExactMatchMacAddr
701
702 @Description   Add a unicast or multicast mac address for exact-match filtering
703                (8 on dTSEC, 2 for 10G-MAC)
704
705 @Param[in]     h_FmMac     -   A handle to a FM Module.
706 @Param[in]     p_EnetAddr  -   MAC Address to ADD
707
708 @Return        E_OK on success; Error code otherwise.
709
710 @Cautions      Allowed only after FM_MAC_Init().
711*//***************************************************************************/
712t_Error FM_MAC_AddExactMatchMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
713
714/**************************************************************************//**
715 @Function      FM_MAC_RemovelExactMatchMacAddr
716
717 @Description   Remove a uni cast or multi cast mac address.
718
719 @Param[in]     h_FmMac     -   A handle to a FM Module.
720 @Param[in]     p_EnetAddr  -   MAC Address to remove
721
722 @Return        E_OK on success; Error code otherwise..
723
724 @Cautions      Allowed only after FM_MAC_Init().
725*//***************************************************************************/
726t_Error FM_MAC_RemovelExactMatchMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);
727
728/**************************************************************************//**
729 @Function      FM_MAC_SetPromiscuous
730
731 @Description   Enable/Disable MAC Promiscuous mode for ALL mac addresses.
732
733 @Param[in]     h_FmMac    - A handle to a FM MAC Module.
734 @Param[in]     enable     - TRUE to enable or FALSE to disable.
735
736 @Return        E_OK on success; Error code otherwise.
737
738 @Cautions      Allowed only after FM_MAC_Init().
739*//***************************************************************************/
740t_Error FM_MAC_SetPromiscuous(t_Handle h_FmMac, bool enable);
741
742/**************************************************************************//**
743 @Function      FM_MAC_AdjustLink
744
745 @Description   Adjusts the Ethernet link with new speed/duplex setup.
746                This routine is relevant for dTSEC and mEMAC.
747                In case of mEMAC, this routine is also used for manual
748                re-configuration of RGMII speed and duplex mode for
749                RGMII PHYs not supporting in-band status information
750                to MAC.
751
752 @Param[in]     h_FmMac     - A handle to a FM Module.
753 @Param[in]     speed       - Ethernet speed.
754 @Param[in]     fullDuplex  - TRUE for full-duplex mode;
755                              FALSE for half-duplex mode.
756
757 @Return        E_OK on success; Error code otherwise.
758*//***************************************************************************/
759t_Error FM_MAC_AdjustLink(t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex);
760
761/**************************************************************************//**
762 @Function      FM_MAC_RestartAutoneg
763
764 @Description   Restarts the auto-negotiation process.
765                When auto-negotiation process is invoked under traffic the
766                auto-negotiation process between the internal SGMII PHY and the
767                external PHY does not always complete successfully. Calling this
768                function will restart the auto-negotiation process that will end
769                successfully. It is recommended to call this function after issuing
770                auto-negotiation restart command to the Eth Phy.
771                This routine is relevant only for dTSEC.
772
773 @Param[in]     h_FmMac     - A handle to a FM Module.
774
775 @Return        E_OK on success; Error code otherwise.
776*//***************************************************************************/
777t_Error FM_MAC_RestartAutoneg(t_Handle h_FmMac);
778
779/**************************************************************************//**
780 @Function      FM_MAC_GetId
781
782 @Description   Return the MAC ID
783
784 @Param[in]     h_FmMac     -   A handle to a FM Module.
785 @Param[out]    p_MacId     -   MAC ID of device
786
787 @Return        E_OK on success; Error code otherwise.
788
789 @Cautions      Allowed only after FM_MAC_Init().
790*//***************************************************************************/
791t_Error FM_MAC_GetId(t_Handle h_FmMac, uint32_t *p_MacId);
792
793/**************************************************************************//**
794 @Function      FM_MAC_GetVesrion
795
796 @Description   Return Mac HW chip version
797
798 @Param[in]     h_FmMac      -   A handle to a FM Module.
799 @Param[out]    p_MacVresion -   Mac version as defined by the chip
800
801 @Return        E_OK on success; Error code otherwise.
802
803 @Cautions      Allowed only after FM_MAC_Init().
804*//***************************************************************************/
805t_Error FM_MAC_GetVesrion(t_Handle h_FmMac, uint32_t *p_MacVresion);
806
807/**************************************************************************//**
808 @Function      FM_MAC_MII_WritePhyReg
809
810 @Description   Write data into Phy Register
811
812 @Param[in]     h_FmMac     -   A handle to a FM Module.
813 @Param[in]     phyAddr     -   Phy Address on the MII bus
814 @Param[in]     reg         -   Register Number.
815 @Param[in]     data        -   Data to write.
816
817 @Return        E_OK on success; Error code otherwise.
818
819 @Cautions      Allowed only after FM_MAC_Init().
820*//***************************************************************************/
821t_Error FM_MAC_MII_WritePhyReg(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data);
822
823/**************************************************************************//**
824 @Function      FM_MAC_MII_ReadPhyReg
825
826 @Description   Read data from Phy Register
827
828 @Param[in]     h_FmMac     -   A handle to a FM Module.
829 @Param[in]     phyAddr     -   Phy Address on the MII bus
830 @Param[in]     reg         -   Register Number.
831 @Param[out]    p_Data      -   Data from PHY.
832
833 @Return        E_OK on success; Error code otherwise.
834
835 @Cautions      Allowed only after FM_MAC_Init().
836*//***************************************************************************/
837t_Error FM_MAC_MII_ReadPhyReg(t_Handle h_FmMac,  uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);
838
839#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
840/**************************************************************************//**
841 @Function      FM_MAC_DumpRegs
842
843 @Description   Dump internal registers
844
845 @Param[in]     h_FmMac     -   A handle to a FM Module.
846
847 @Return        E_OK on success; Error code otherwise.
848
849 @Cautions      Allowed only after FM_MAC_Init().
850*//***************************************************************************/
851t_Error FM_MAC_DumpRegs(t_Handle h_FmMac);
852#endif /* (defined(DEBUG_ERRORS) && ... */
853
854/** @} */ /* end of FM_mac_runtime_control_grp group */
855/** @} */ /* end of FM_mac_grp group */
856/** @} */ /* end of FM_grp group */
857
858
859#endif /* __FM_MAC_EXT_H */
860