Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
/*
 * Copyright 2008-2012 Freescale Semiconductor Inc.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Freescale Semiconductor nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 *
 * ALTERNATIVELY, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") as published by the Free Software
 * Foundation, either version 2 of that License or (at your option) any
 * later version.
 *
 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


/**************************************************************************//**
 @File          fm_mac_ext.h

 @Description   FM MAC ...
*//***************************************************************************/
#ifndef __FM_MAC_EXT_H
#define __FM_MAC_EXT_H

#include "std_ext.h"
#include "enet_ext.h"


/**************************************************************************//**

 @Group         FM_grp Frame Manager API

 @Description   FM API functions, definitions and enums

 @{
*//***************************************************************************/

/**************************************************************************//**
 @Group         FM_mac_grp FM MAC

 @Description   FM MAC API functions, definitions and enums

 @{
*//***************************************************************************/

#define FM_MAC_NO_PFC   0xff


/**************************************************************************//**
 @Description   FM MAC Exceptions
*//***************************************************************************/
typedef enum e_FmMacExceptions {
    e_FM_MAC_EX_10G_MDIO_SCAN_EVENTMDIO = 0                     /**< 10GEC MDIO scan event interrupt */
   ,e_FM_MAC_EX_10G_MDIO_CMD_CMPL                               /**< 10GEC MDIO command completion interrupt */
   ,e_FM_MAC_EX_10G_REM_FAULT                                   /**< 10GEC, mEMAC Remote fault interrupt */
   ,e_FM_MAC_EX_10G_LOC_FAULT                                   /**< 10GEC, mEMAC Local fault interrupt */
   ,e_FM_MAC_EX_10G_1TX_ECC_ER                                  /**< 10GEC, mEMAC Transmit frame ECC error interrupt */
   ,e_FM_MAC_EX_10G_TX_FIFO_UNFL                                /**< 10GEC, mEMAC Transmit FIFO underflow interrupt */
   ,e_FM_MAC_EX_10G_TX_FIFO_OVFL                                /**< 10GEC, mEMAC Transmit FIFO overflow interrupt */
   ,e_FM_MAC_EX_10G_TX_ER                                       /**< 10GEC Transmit frame error interrupt */
   ,e_FM_MAC_EX_10G_RX_FIFO_OVFL                                /**< 10GEC, mEMAC Receive FIFO overflow interrupt */
   ,e_FM_MAC_EX_10G_RX_ECC_ER                                   /**< 10GEC, mEMAC Receive frame ECC error interrupt */
   ,e_FM_MAC_EX_10G_RX_JAB_FRM                                  /**< 10GEC Receive jabber frame interrupt */
   ,e_FM_MAC_EX_10G_RX_OVRSZ_FRM                                /**< 10GEC Receive oversized frame interrupt */
   ,e_FM_MAC_EX_10G_RX_RUNT_FRM                                 /**< 10GEC Receive runt frame interrupt */
   ,e_FM_MAC_EX_10G_RX_FRAG_FRM                                 /**< 10GEC Receive fragment frame interrupt */
   ,e_FM_MAC_EX_10G_RX_LEN_ER                                   /**< 10GEC Receive payload length error interrupt */
   ,e_FM_MAC_EX_10G_RX_CRC_ER                                   /**< 10GEC Receive CRC error interrupt */
   ,e_FM_MAC_EX_10G_RX_ALIGN_ER                                 /**< 10GEC Receive alignment error interrupt */
   ,e_FM_MAC_EX_1G_BAB_RX                                       /**< dTSEC Babbling receive error */
   ,e_FM_MAC_EX_1G_RX_CTL                                       /**< dTSEC Receive control (pause frame) interrupt */
   ,e_FM_MAC_EX_1G_GRATEFUL_TX_STP_COMPLET                      /**< dTSEC Graceful transmit stop complete */
   ,e_FM_MAC_EX_1G_BAB_TX                                       /**< dTSEC Babbling transmit error */
   ,e_FM_MAC_EX_1G_TX_CTL                                       /**< dTSEC Transmit control (pause frame) interrupt */
   ,e_FM_MAC_EX_1G_TX_ERR                                       /**< dTSEC Transmit error */
   ,e_FM_MAC_EX_1G_LATE_COL                                     /**< dTSEC Late collision */
   ,e_FM_MAC_EX_1G_COL_RET_LMT                                  /**< dTSEC Collision retry limit */
   ,e_FM_MAC_EX_1G_TX_FIFO_UNDRN                                /**< dTSEC Transmit FIFO underrun */
   ,e_FM_MAC_EX_1G_MAG_PCKT                                     /**< dTSEC Magic Packet detection */
   ,e_FM_MAC_EX_1G_MII_MNG_RD_COMPLET                           /**< dTSEC MII management read completion */
   ,e_FM_MAC_EX_1G_MII_MNG_WR_COMPLET                           /**< dTSEC MII management write completion */
   ,e_FM_MAC_EX_1G_GRATEFUL_RX_STP_COMPLET                      /**< dTSEC Graceful receive stop complete */
   ,e_FM_MAC_EX_1G_TX_DATA_ERR                                  /**< dTSEC Internal data error on transmit */
   ,e_FM_MAC_EX_1G_RX_DATA_ERR                                  /**< dTSEC Internal data error on receive */
   ,e_FM_MAC_EX_1G_1588_TS_RX_ERR                               /**< dTSEC Time-Stamp Receive Error */
   ,e_FM_MAC_EX_1G_RX_MIB_CNT_OVFL                              /**< dTSEC MIB counter overflow */
   ,e_FM_MAC_EX_TS_FIFO_ECC_ERR                                 /**< mEMAC Time-stamp FIFO ECC error interrupt;
                                                                     not supported on T4240/B4860 rev1 chips */
   ,e_FM_MAC_EX_MAGIC_PACKET_INDICATION = e_FM_MAC_EX_1G_MAG_PCKT
                                                                /**< mEMAC Magic Packet Indication Interrupt */
} e_FmMacExceptions;

/**************************************************************************//**
 @Description   TM MAC statistics level
*//***************************************************************************/
typedef enum e_FmMacStatisticsLevel {
    e_FM_MAC_NONE_STATISTICS = 0,       /**< No statistics */
    e_FM_MAC_PARTIAL_STATISTICS,        /**< Only error counters are available; Optimized for performance */
    e_FM_MAC_FULL_STATISTICS            /**< All counters available; Not optimized for performance */
} e_FmMacStatisticsLevel;


#if (DPAA_VERSION >= 11)
/**************************************************************************//**
 @Description   Priority Flow Control Parameters
*//***************************************************************************/
typedef struct t_FmMacPfcParams {
    bool        pfcEnable;                                      /**< Enable/Disable PFC */

    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*/

    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*/


} t_FmMacPfcParams;
#endif /* (DPAA_VERSION >= 11) */

/**************************************************************************//**
 @Function      t_FmMacExceptionCallback

 @Description   Fm Mac Exception Callback from FM MAC to the user

 @Param[in]     h_App             - Handle to the upper layer handler

 @Param[in]     exceptions        - The exception that occurred

 @Return        void.
*//***************************************************************************/
typedef void (t_FmMacExceptionCallback)(t_Handle h_App, e_FmMacExceptions exceptions);


/**************************************************************************//**
 @Description   TM MAC statistics rfc3635
*//***************************************************************************/
typedef struct t_FmMacStatistics {
/* RMON */
    uint64_t  eStatPkts64;             /**< r-10G tr-DT 64 byte frame counter */
    uint64_t  eStatPkts65to127;        /**< r-10G 65 to 127 byte frame counter */
    uint64_t  eStatPkts128to255;       /**< r-10G 128 to 255 byte frame counter */
    uint64_t  eStatPkts256to511;       /**< r-10G 256 to 511 byte frame counter */
    uint64_t  eStatPkts512to1023;      /**< r-10G 512 to 1023 byte frame counter */
    uint64_t  eStatPkts1024to1518;     /**< r-10G 1024 to 1518 byte frame counter */
    uint64_t  eStatPkts1519to1522;     /**< r-10G 1519 to 1522 byte good frame count */
/* */
    uint64_t  eStatFragments;          /**< Total number of packets that were less than 64 octets long with a wrong CRC.*/
    uint64_t  eStatJabbers;            /**< Total number of packets longer than valid maximum length octets */
    uint64_t  eStatsDropEvents;        /**< number of dropped packets due to internal errors of the MAC Client (during receive). */
    uint64_t  eStatCRCAlignErrors;     /**< Incremented when frames of correct length but with CRC error are received.*/
    uint64_t  eStatUndersizePkts;      /**< Incremented for frames under 64 bytes with a valid FCS and otherwise well formed;
                                            This count does not include range length errors */
    uint64_t  eStatOversizePkts;       /**< Incremented for frames which exceed 1518 (non VLAN) or 1522 (VLAN) and contains
                                            a valid FCS and otherwise well formed */
/* Pause */
    uint64_t  teStatPause;             /**< Pause MAC Control received */
    uint64_t  reStatPause;             /**< Pause MAC Control sent */
/* MIB II */
    uint64_t  ifInOctets;              /**< Total number of byte received. */
    uint64_t  ifInPkts;                /**< Total number of packets received.*/
    uint64_t  ifInUcastPkts;           /**< Total number of unicast frame received;
                                            NOTE: this counter is not supported on dTSEC MAC */
    uint64_t  ifInMcastPkts;           /**< Total number of multicast frame received*/
    uint64_t  ifInBcastPkts;           /**< Total number of broadcast frame received */
    uint64_t  ifInDiscards;            /**< Frames received, but discarded due to problems within the MAC RX. */
    uint64_t  ifInErrors;              /**< Number of frames received with error:
                                               - FIFO Overflow Error
                                               - CRC Error
                                               - Frame Too Long Error
                                               - Alignment Error
                                               - The dedicated Error Code (0xfe, not a code error) was received */
    uint64_t  ifOutOctets;             /**< Total number of byte sent. */
    uint64_t  ifOutPkts;               /**< Total number of packets sent .*/
    uint64_t  ifOutUcastPkts;          /**< Total number of unicast frame sent;
                                            NOTE: this counter is not supported on dTSEC MAC */
    uint64_t  ifOutMcastPkts;          /**< Total number of multicast frame sent */
    uint64_t  ifOutBcastPkts;          /**< Total number of multicast frame sent */
    uint64_t  ifOutDiscards;           /**< Frames received, but discarded due to problems within the MAC TX N/A!.*/
    uint64_t  ifOutErrors;             /**< Number of frames transmitted with error:
                                               - FIFO Overflow Error
                                               - FIFO Underflow Error
                                               - Other */
} t_FmMacStatistics;


/**************************************************************************//**
 @Group         FM_mac_init_grp FM MAC Initialization Unit

 @Description   FM MAC Initialization Unit

 @{
*//***************************************************************************/

/**************************************************************************//**
 @Description   FM MAC config input
*//***************************************************************************/
typedef struct t_FmMacParams {
    uintptr_t                   baseAddr;           /**< Base of memory mapped FM MAC registers */
    t_EnetAddr                  addr;               /**< MAC address of device; First octet is sent first */
    uint8_t                     macId;              /**< MAC ID;
                                                         numbering of dTSEC and 1G-mEMAC:
                                                            0 - FM_MAX_NUM_OF_1G_MACS;
                                                         numbering of 10G-MAC (TGEC) and 10G-mEMAC:
                                                            0 - FM_MAX_NUM_OF_10G_MACS */
    e_EnetMode                  enetMode;           /**< Ethernet operation mode (MAC-PHY interface and speed);
                                                         Note that the speed should indicate the maximum rate that
                                                         this MAC should support rather than the actual speed;
                                                         i.e. user should use the FM_MAC_AdjustLink() routine to
                                                         provide accurate speed;
                                                         In case of mEMAC RGMII mode, the MAC is configured to RGMII
                                                         automatic mode, where actual speed/duplex mode information
                                                         is provided by PHY automatically in-band; FM_MAC_AdjustLink()
                                                         function should be used to switch to manual RGMII speed/duplex mode
                                                         configuration if RGMII PHY doesn't support in-band status signaling;
                                                         In addition, in mEMAC, in case where user is using the higher MACs
                                                         (i.e. the MACs that should support 10G), user should pass here
                                                         speed=10000 even if the interface is not allowing that (e.g. SGMII). */
    t_Handle                    h_Fm;               /**< A handle to the FM object this port related to */
    int                         mdioIrq;            /**< MDIO exceptions interrupt source - not valid for all
                                                         MACs; MUST be set to 'NO_IRQ' for MACs that don't have
                                                         mdio-irq, or for polling */
    t_FmMacExceptionCallback    *f_Event;           /**< MDIO Events Callback Routine         */
    t_FmMacExceptionCallback    *f_Exception;       /**< Exception Callback Routine         */
    t_Handle                    h_App;              /**< A handle to an application layer object; This handle will
                                                         be passed by the driver upon calling the above callbacks */
} t_FmMacParams;


/**************************************************************************//**
 @Function      FM_MAC_Config

 @Description   Creates descriptor for the FM MAC module.

                The routine returns a handle (descriptor) to the FM MAC object.
                This descriptor must be passed as first parameter to all other
                FM MAC function calls.

                No actual initialization or configuration of FM MAC hardware is
                done by this routine.

 @Param[in]     p_FmMacParam   - Pointer to data structure of parameters

 @Retval        Handle to FM MAC object, or NULL for Failure.
*//***************************************************************************/
t_Handle FM_MAC_Config(t_FmMacParams *p_FmMacParam);

/**************************************************************************//**
 @Function      FM_MAC_Init

 @Description   Initializes the FM MAC module

 @Param[in]     h_FmMac - FM module descriptor

 @Return        E_OK on success; Error code otherwise.
*//***************************************************************************/
t_Error  FM_MAC_Init(t_Handle h_FmMac);

/**************************************************************************//**
 @Function      FM_Free

 @Description   Frees all resources that were assigned to FM MAC module.

                Calling this routine invalidates the descriptor.

 @Param[in]     h_FmMac - FM module descriptor

 @Return        E_OK on success; Error code otherwise.
*//***************************************************************************/
t_Error  FM_MAC_Free(t_Handle h_FmMac);


/**************************************************************************//**
 @Group         FM_mac_advanced_init_grp    FM MAC Advanced Configuration Unit

 @Description   Configuration functions used to change default values.

 @{
*//***************************************************************************/

/**************************************************************************//**
 @Function      FM_MAC_ConfigResetOnInit

 @Description   Tell the driver whether to reset the FM MAC before initialization or
                not. It changes the default configuration [DEFAULT_resetOnInit].

 @Param[in]     h_FmMac    A handle to a FM MAC Module.
 @Param[in]     enable     When TRUE, FM will be reset before any initialization.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_ConfigResetOnInit(t_Handle h_FmMac, bool enable);

/**************************************************************************//**
 @Function      FM_MAC_ConfigLoopback

 @Description   Enable/Disable internal loopback mode

 @Param[in]     h_FmMac    A handle to a FM MAC Module.
 @Param[in]     enable     TRUE to enable or FALSE to disable.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_ConfigLoopback(t_Handle h_FmMac, bool enable);

/**************************************************************************//**
 @Function      FM_MAC_ConfigMaxFrameLength

 @Description   Setup maximum Rx Frame Length (in 1G MAC, effects also Tx)

 @Param[in]     h_FmMac    A handle to a FM MAC Module.
 @Param[in]     newVal     MAX Frame length

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_ConfigMaxFrameLength(t_Handle h_FmMac, uint16_t newVal);

/**************************************************************************//**
 @Function      FM_MAC_ConfigWan

 @Description   ENABLE WAN mode in 10G-MAC

 @Param[in]     h_FmMac    A handle to a FM MAC Module.
 @Param[in]     enable     TRUE to enable or FALSE to disable.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_ConfigWan(t_Handle h_FmMac, bool enable);

/**************************************************************************//**
 @Function      FM_MAC_ConfigPadAndCrc

 @Description   Config PAD and CRC mode

 @Param[in]     h_FmMac    A handle to a FM MAC Module.
 @Param[in]     enable     TRUE to enable or FALSE to disable.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
                Not supported on 10G-MAC (i.e. CRC & PAD are added automatically
                by HW); on mEMAC, this routine supports only PAD (i.e. CRC is
                added automatically by HW).
*//***************************************************************************/
t_Error FM_MAC_ConfigPadAndCrc(t_Handle h_FmMac, bool enable);

/**************************************************************************//**
 @Function      FM_MAC_ConfigHalfDuplex

 @Description   Config Half Duplex Mode

 @Param[in]     h_FmMac    A handle to a FM MAC Module.
 @Param[in]     enable     TRUE to enable or FALSE to disable.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_ConfigHalfDuplex(t_Handle h_FmMac, bool enable);

/**************************************************************************//**
 @Function      FM_MAC_ConfigTbiPhyAddr

 @Description   Configures the address of internal TBI PHY.

 @Param[in]     h_FmMac    A handle to a FM MAC Module.
 @Param[in]     newVal     TBI PHY address (1-31).

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_ConfigTbiPhyAddr(t_Handle h_FmMac, uint8_t newVal);

/**************************************************************************//**
 @Function      FM_MAC_ConfigLengthCheck

 @Description   Configure the frame length checking.

 @Param[in]     h_FmMac    A handle to a FM MAC Module.
 @Param[in]     enable     TRUE to enable or FALSE to disable.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_ConfigLengthCheck(t_Handle h_FmMac, bool enable);

/**************************************************************************//**
 @Function      FM_MAC_ConfigException

 @Description   Change Exception selection from default

 @Param[in]     h_FmMac         A handle to a FM MAC Module.
 @Param[in]     ex              Type of the desired exceptions
 @Param[in]     enable          TRUE to enable the specified exception, FALSE to disable it.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Config() and before FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_ConfigException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable);

#ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
t_Error FM_MAC_ConfigSkipFman11Workaround (t_Handle h_FmMac);
#endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
/** @} */ /* end of FM_mac_advanced_init_grp group */
/** @} */ /* end of FM_mac_init_grp group */


/**************************************************************************//**
 @Group         FM_mac_runtime_control_grp FM MAC Runtime Control Unit

 @Description   FM MAC Runtime control unit API functions, definitions and enums.

 @{
*//***************************************************************************/

/**************************************************************************//**
 @Function      FM_MAC_Enable

 @Description   Enable the MAC

 @Param[in]     h_FmMac    A handle to a FM MAC Module.
 @Param[in]     mode       Mode of operation (RX, TX, Both)

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_Enable(t_Handle h_FmMac,  e_CommMode mode);

/**************************************************************************//**
 @Function      FM_MAC_Disable

 @Description   DISABLE the MAC

 @Param[in]     h_FmMac    A handle to a FM MAC Module.
 @Param[in]     mode       Define what part to Disable (RX,  TX or BOTH)

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_Disable(t_Handle h_FmMac, e_CommMode mode);

/**************************************************************************//**
 @Function      FM_MAC_Resume

 @Description   Re-init the MAC after suspend

 @Param[in]     h_FmMac    A handle to a FM MAC Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_Resume(t_Handle h_FmMac);

/**************************************************************************//**
 @Function      FM_MAC_Enable1588TimeStamp

 @Description   Enables the TSU operation.

 @Param[in]     h_Fm   - Handle to the PTP as returned from the FM_MAC_PtpConfig.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_Enable1588TimeStamp(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_MAC_Disable1588TimeStamp

 @Description   Disables the TSU operation.

 @Param[in]     h_Fm   - Handle to the PTP as returned from the FM_MAC_PtpConfig.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_Disable1588TimeStamp(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_MAC_SetTxAutoPauseFrames

 @Description   Enable/Disable transmission of Pause-Frames.
                The routine changes the default configuration [DEFAULT_TX_PAUSE_TIME].

 @Param[in]     h_FmMac       -  A handle to a FM MAC Module.
 @Param[in]     pauseTime     -  Pause quanta value used with transmitted pause frames.
                                 Each quanta represents a 512 bit-times; Note that '0'
                                 as an input here will be used as disabling the
                                 transmission of the pause-frames.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_SetTxAutoPauseFrames(t_Handle h_FmMac,
                                    uint16_t pauseTime);

 /**************************************************************************//**
 @Function      FM_MAC_SetTxPauseFrames

 @Description   Enable/Disable transmission of Pause-Frames.
                The routine changes the default configuration:
                pause-time - [DEFAULT_TX_PAUSE_TIME]
                threshold-time - [0]

 @Param[in]     h_FmMac       -  A handle to a FM MAC Module.
 @Param[in]     priority      -  the PFC class of service; use 'FM_MAC_NO_PFC'
                                 to indicate legacy pause support (i.e. no PFC).
 @Param[in]     pauseTime     -  Pause quanta value used with transmitted pause frames.
                                 Each quanta represents a 512 bit-times;
                                 Note that '0' as an input here will be used as disabling the
                                 transmission of the pause-frames.
 @Param[in]     threshTime    -  Pause Threshold equanta value used by the MAC to retransmit pause frame.
                                 if the situation causing a pause frame to be sent didn't finish when the timer
                                 reached the threshold quanta, the MAC will retransmit the pause frame.
                                 Each quanta represents a 512 bit-times.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
                In order for PFC to work properly the user must configure
                TNUM-aging in the tx-port it is recommended that pre-fetch and
                rate limit in the tx port should be disabled;
                PFC is supported only on new mEMAC; i.e. in MACs that don't have
                PFC support (10G-MAC and dTSEC), user should use 'FM_MAC_NO_PFC'
                in the 'priority' field.
*//***************************************************************************/
t_Error FM_MAC_SetTxPauseFrames(t_Handle h_FmMac,
                                uint8_t  priority,
                                uint16_t pauseTime,
                                uint16_t threshTime);

/**************************************************************************//**
 @Function      FM_MAC_SetRxIgnorePauseFrames

 @Description   Enable/Disable ignoring of Pause-Frames.

 @Param[in]     h_FmMac    - A handle to a FM MAC Module.
 @Param[in]     en         - boolean indicates whether to ignore the incoming pause
                             frames or not.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_SetRxIgnorePauseFrames(t_Handle h_FmMac, bool en);

/**************************************************************************//**
 @Function      FM_MAC_SetWakeOnLan

 @Description   Enable/Disable Wake On Lan support

 @Param[in]     h_FmMac    - A handle to a FM MAC Module.
 @Param[in]     en         - boolean indicates whether to enable Wake On Lan
                             support or not.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_SetWakeOnLan(t_Handle h_FmMac, bool en);

/**************************************************************************//**
 @Function      FM_MAC_ResetCounters

 @Description   reset all statistics counters

 @Param[in]     h_FmMac    - A handle to a FM MAC Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_ResetCounters(t_Handle h_FmMac);

/**************************************************************************//**
 @Function      FM_MAC_SetException

 @Description   Enable/Disable a specific Exception

 @Param[in]     h_FmMac        - A handle to a FM MAC Module.
 @Param[in]     ex             - Type of the desired exceptions
 @Param[in]     enable         - TRUE to enable the specified exception, FALSE to disable it.


 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_SetException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable);

/**************************************************************************//**
 @Function      FM_MAC_SetStatistics

 @Description   Define Statistics level.
                Where applicable, the routine also enables the MIB counters
                overflow interrupt in order to keep counters accurate
                and account for overflows.
                This routine is relevant only for dTSEC.

 @Param[in]     h_FmMac         - A handle to a FM MAC Module.
 @Param[in]     statisticsLevel - Full statistics level provides all standard counters but may
                                  reduce performance. Partial statistics provides only special
                                  event counters (errors etc.). If selected, regular counters (such as
                                  byte/packet) will be invalid and will return -1.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_SetStatistics(t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel);

/**************************************************************************//**
 @Function      FM_MAC_GetStatistics

 @Description   get all statistics counters

 @Param[in]     h_FmMac       -  A handle to a FM MAC Module.
 @Param[in]     p_Statistics  -  Structure with statistics

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Init().
*//***************************************************************************/
t_Error FM_MAC_GetStatistics(t_Handle h_FmMac, t_FmMacStatistics *p_Statistics);

/**************************************************************************//**
 @Function      FM_MAC_ModifyMacAddr

 @Description   Replace the main MAC Address

 @Param[in]     h_FmMac     -   A handle to a FM Module.
 @Param[in]     p_EnetAddr  -   Ethernet Mac address

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only after FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_ModifyMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);

/**************************************************************************//**
 @Function      FM_MAC_AddHashMacAddr

 @Description   Add an Address to the hash table. This is for filter purpose only.

 @Param[in]     h_FmMac     -   A handle to a FM Module.
 @Param[in]     p_EnetAddr  -   Ethernet Mac address

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init(). It is a filter only address.
 @Cautions      Some address need to be filterd out in upper FM blocks.
*//***************************************************************************/
t_Error FM_MAC_AddHashMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);

/**************************************************************************//**
 @Function      FM_MAC_RemoveHashMacAddr

 @Description   Delete an Address to the hash table. This is for filter purpose only.

 @Param[in]     h_FmMac     -   A handle to a FM Module.
 @Param[in]     p_EnetAddr  -   Ethernet Mac address

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_RemoveHashMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);

/**************************************************************************//**
 @Function      FM_MAC_AddExactMatchMacAddr

 @Description   Add a unicast or multicast mac address for exact-match filtering
                (8 on dTSEC, 2 for 10G-MAC)

 @Param[in]     h_FmMac     -   A handle to a FM Module.
 @Param[in]     p_EnetAddr  -   MAC Address to ADD

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only after FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_AddExactMatchMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);

/**************************************************************************//**
 @Function      FM_MAC_RemovelExactMatchMacAddr

 @Description   Remove a uni cast or multi cast mac address.

 @Param[in]     h_FmMac     -   A handle to a FM Module.
 @Param[in]     p_EnetAddr  -   MAC Address to remove

 @Return        E_OK on success; Error code otherwise..

 @Cautions      Allowed only after FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_RemovelExactMatchMacAddr(t_Handle h_FmMac, t_EnetAddr *p_EnetAddr);

/**************************************************************************//**
 @Function      FM_MAC_SetPromiscuous

 @Description   Enable/Disable MAC Promiscuous mode for ALL mac addresses.

 @Param[in]     h_FmMac    - A handle to a FM MAC Module.
 @Param[in]     enable     - TRUE to enable or FALSE to disable.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only after FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_SetPromiscuous(t_Handle h_FmMac, bool enable);

/**************************************************************************//**
 @Function      FM_MAC_AdjustLink

 @Description   Adjusts the Ethernet link with new speed/duplex setup.
                This routine is relevant for dTSEC and mEMAC.
                In case of mEMAC, this routine is also used for manual
                re-configuration of RGMII speed and duplex mode for
                RGMII PHYs not supporting in-band status information
                to MAC.

 @Param[in]     h_FmMac     - A handle to a FM Module.
 @Param[in]     speed       - Ethernet speed.
 @Param[in]     fullDuplex  - TRUE for full-duplex mode;
                              FALSE for half-duplex mode.

 @Return        E_OK on success; Error code otherwise.
*//***************************************************************************/
t_Error FM_MAC_AdjustLink(t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex);

/**************************************************************************//**
 @Function      FM_MAC_RestartAutoneg

 @Description   Restarts the auto-negotiation process.
                When auto-negotiation process is invoked under traffic the
                auto-negotiation process between the internal SGMII PHY and the
                external PHY does not always complete successfully. Calling this
                function will restart the auto-negotiation process that will end
                successfully. It is recommended to call this function after issuing
                auto-negotiation restart command to the Eth Phy.
                This routine is relevant only for dTSEC.

 @Param[in]     h_FmMac     - A handle to a FM Module.

 @Return        E_OK on success; Error code otherwise.
*//***************************************************************************/
t_Error FM_MAC_RestartAutoneg(t_Handle h_FmMac);

/**************************************************************************//**
 @Function      FM_MAC_GetId

 @Description   Return the MAC ID

 @Param[in]     h_FmMac     -   A handle to a FM Module.
 @Param[out]    p_MacId     -   MAC ID of device

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only after FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_GetId(t_Handle h_FmMac, uint32_t *p_MacId);

/**************************************************************************//**
 @Function      FM_MAC_GetVesrion

 @Description   Return Mac HW chip version

 @Param[in]     h_FmMac      -   A handle to a FM Module.
 @Param[out]    p_MacVresion -   Mac version as defined by the chip

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only after FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_GetVesrion(t_Handle h_FmMac, uint32_t *p_MacVresion);

/**************************************************************************//**
 @Function      FM_MAC_MII_WritePhyReg

 @Description   Write data into Phy Register

 @Param[in]     h_FmMac     -   A handle to a FM Module.
 @Param[in]     phyAddr     -   Phy Address on the MII bus
 @Param[in]     reg         -   Register Number.
 @Param[in]     data        -   Data to write.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only after FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_MII_WritePhyReg(t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data);

/**************************************************************************//**
 @Function      FM_MAC_MII_ReadPhyReg

 @Description   Read data from Phy Register

 @Param[in]     h_FmMac     -   A handle to a FM Module.
 @Param[in]     phyAddr     -   Phy Address on the MII bus
 @Param[in]     reg         -   Register Number.
 @Param[out]    p_Data      -   Data from PHY.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only after FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_MII_ReadPhyReg(t_Handle h_FmMac,  uint8_t phyAddr, uint8_t reg, uint16_t *p_Data);

#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
/**************************************************************************//**
 @Function      FM_MAC_DumpRegs

 @Description   Dump internal registers

 @Param[in]     h_FmMac     -   A handle to a FM Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only after FM_MAC_Init().
*//***************************************************************************/
t_Error FM_MAC_DumpRegs(t_Handle h_FmMac);
#endif /* (defined(DEBUG_ERRORS) && ... */

/** @} */ /* end of FM_mac_runtime_control_grp group */
/** @} */ /* end of FM_mac_grp group */
/** @} */ /* end of FM_grp group */


#endif /* __FM_MAC_EXT_H */