summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/freescale/fman/inc/Peripherals/fm_ext.h
blob: 00951b1e95cb83754e86af439f581fcdeddfd977 (plain)
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
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
/* Copyright (c) 2008-2012 Freescale Semiconductor, Inc
 * All rights reserved.
 *
 * 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_ext.h

 @Description   FM Application Programming Interface.
*//***************************************************************************/
#ifndef __FM_EXT
#define __FM_EXT

#include "error_ext.h"
#include "std_ext.h"
#include "dpaa_ext.h"
#include "fsl_fman_sp.h"

/**************************************************************************//**
 @Group         FM_grp Frame Manager API

 @Description   FM API functions, definitions and enums.

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

/**************************************************************************//**
 @Group         FM_lib_grp FM library

 @Description   FM API functions, definitions and enums.

                The FM module is the main driver module and is a mandatory module
                for FM driver users. This module must be initialized first prior
                to any other drivers modules.
                The FM is a "singleton" module. It is responsible of the common
                HW modules: FPM, DMA, common QMI and common BMI initializations and
                run-time control routines. This module must be initialized always
                when working with any of the FM modules.
                NOTE - We assume that the FM library will be initialized only by core No. 0!

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

/**************************************************************************//**
 @Description   Enum for defining port types
*//***************************************************************************/
typedef enum e_FmPortType {
    e_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0,  /**< Offline parsing port */
    e_FM_PORT_TYPE_RX,                      /**< 1G Rx port */
    e_FM_PORT_TYPE_RX_10G,                  /**< 10G Rx port */
    e_FM_PORT_TYPE_TX,                      /**< 1G Tx port */
    e_FM_PORT_TYPE_TX_10G,                  /**< 10G Tx port */
    e_FM_PORT_TYPE_DUMMY
} e_FmPortType;

/**************************************************************************//**
 @Collection    General FM defines
*//***************************************************************************/
#define FM_MAX_NUM_OF_PARTITIONS    64      /**< Maximum number of partitions */
#define FM_PHYS_ADDRESS_SIZE        6       /**< FM Physical address size */
/* @} */


#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(push,1)
#endif /* defined(__MWERKS__) && ... */

/**************************************************************************//**
 @Description   FM physical Address
*//***************************************************************************/
typedef _Packed struct t_FmPhysAddr {
    volatile uint8_t    high;         /**< High part of the physical address */
    volatile uint32_t   low;          /**< Low part of the physical address */
} _PackedType t_FmPhysAddr;

/**************************************************************************//**
 @Description   Parse results memory layout
*//***************************************************************************/
typedef _Packed struct t_FmPrsResult {
    volatile uint8_t     lpid;               /**< Logical port id */
    volatile uint8_t     shimr;              /**< Shim header result  */
    volatile uint16_t    l2r;                /**< Layer 2 result */
    volatile uint16_t    l3r;                /**< Layer 3 result */
    volatile uint8_t     l4r;                /**< Layer 4 result */
    volatile uint8_t     cplan;              /**< Classification plan id */
    volatile uint16_t    nxthdr;             /**< Next Header  */
    volatile uint16_t    cksum;              /**< Running-sum */
    volatile uint16_t    flags_frag_off;     /**< Flags & fragment-offset field of the last IP-header */
    volatile uint8_t     route_type;         /**< Routing type field of a IPv6 routing extension header */
    volatile uint8_t     rhp_ip_valid;       /**< Routing Extension Header Present; last bit is IP valid */
    volatile uint8_t     shim_off[2];        /**< Shim offset */
    volatile uint8_t     ip_pid_off;         /**< IP PID (last IP-proto) offset */
    volatile uint8_t     eth_off;            /**< ETH offset */
    volatile uint8_t     llc_snap_off;       /**< LLC_SNAP offset */
    volatile uint8_t     vlan_off[2];        /**< VLAN offset */
    volatile uint8_t     etype_off;          /**< ETYPE offset */
    volatile uint8_t     pppoe_off;          /**< PPP offset */
    volatile uint8_t     mpls_off[2];        /**< MPLS offset */
    volatile uint8_t     ip_off[2];          /**< IP offset */
    volatile uint8_t     gre_off;            /**< GRE offset */
    volatile uint8_t     l4_off;             /**< Layer 4 offset */
    volatile uint8_t     nxthdr_off;         /**< Parser end point */
} _PackedType t_FmPrsResult;

/**************************************************************************//**
 @Collection   FM Parser results
*//***************************************************************************/
#define FM_PR_L2_VLAN_STACK         0x00000100  /**< Parse Result: VLAN stack */
#define FM_PR_L2_ETHERNET           0x00008000  /**< Parse Result: Ethernet*/
#define FM_PR_L2_VLAN               0x00004000  /**< Parse Result: VLAN */
#define FM_PR_L2_LLC_SNAP           0x00002000  /**< Parse Result: LLC_SNAP */
#define FM_PR_L2_MPLS               0x00001000  /**< Parse Result: MPLS */
#define FM_PR_L2_PPPoE              0x00000800  /**< Parse Result: PPPoE */
/* @} */

/**************************************************************************//**
 @Collection   FM Frame descriptor macros
*//***************************************************************************/
#define FM_FD_CMD_FCO                   0x80000000  /**< Frame queue Context Override */
#define FM_FD_CMD_RPD                   0x40000000  /**< Read Prepended Data */
#define FM_FD_CMD_UPD                   0x20000000  /**< Update Prepended Data */
#define FM_FD_CMD_DTC                   0x10000000  /**< Do L4 Checksum */
#define FM_FD_CMD_DCL4C                 0x10000000  /**< Didn't calculate L4 Checksum */
#define FM_FD_CMD_CFQ                   0x00ffffff  /**< Confirmation Frame Queue */

#define FM_FD_ERR_UNSUPPORTED_FORMAT    0x04000000  /**< Not for Rx-Port! Unsupported Format */
#define FM_FD_ERR_LENGTH                0x02000000  /**< Not for Rx-Port! Length Error */
#define FM_FD_ERR_DMA                   0x01000000  /**< DMA Data error */

#define FM_FD_IPR                       0x00000001  /**< IPR frame (not error) */

#define FM_FD_ERR_IPR_NCSP              (0x00100000 | FM_FD_IPR)    /**< IPR non-consistent-sp */
#define FM_FD_ERR_IPR                   (0x00200000 | FM_FD_IPR)    /**< IPR error */
#define FM_FD_ERR_IPR_TO                (0x00300000 | FM_FD_IPR)    /**< IPR timeout */

#ifdef FM_CAPWAP_SUPPORT
#define FM_FD_ERR_CRE                   0x00200000
#define FM_FD_ERR_CHE                   0x00100000
#endif /* FM_CAPWAP_SUPPORT */

#define FM_FD_ERR_PHYSICAL              0x00080000  /**< Rx FIFO overflow, FCS error, code error, running disparity
                                                         error (SGMII and TBI modes), FIFO parity error. PHY
                                                         Sequence error, PHY error control character detected. */
#define FM_FD_ERR_SIZE                  0x00040000  /**< Frame too long OR Frame size exceeds max_length_frame  */
#define FM_FD_ERR_CLS_DISCARD           0x00020000  /**< classification discard */
#define FM_FD_ERR_EXTRACTION            0x00008000  /**< Extract Out of Frame */
#define FM_FD_ERR_NO_SCHEME             0x00004000  /**< No Scheme Selected */
#define FM_FD_ERR_KEYSIZE_OVERFLOW      0x00002000  /**< Keysize Overflow */
#define FM_FD_ERR_COLOR_RED             0x00000800  /**< Frame color is red */
#define FM_FD_ERR_COLOR_YELLOW          0x00000400  /**< Frame color is yellow */
#define FM_FD_ERR_ILL_PLCR              0x00000200  /**< Illegal Policer Profile selected */
#define FM_FD_ERR_PLCR_FRAME_LEN        0x00000100  /**< Policer frame length error */
#define FM_FD_ERR_PRS_TIMEOUT           0x00000080  /**< Parser Time out Exceed */
#define FM_FD_ERR_PRS_ILL_INSTRUCT      0x00000040  /**< Invalid Soft Parser instruction */
#define FM_FD_ERR_PRS_HDR_ERR           0x00000020  /**< Header error was identified during parsing */
#define FM_FD_ERR_BLOCK_LIMIT_EXCEEDED  0x00000008  /**< Frame parsed beyind 256 first bytes */

#define FM_FD_TX_STATUS_ERR_MASK        (FM_FD_ERR_UNSUPPORTED_FORMAT   | \
                                         FM_FD_ERR_LENGTH               | \
                                         FM_FD_ERR_DMA) /**< TX Error FD bits */

#define FM_FD_RX_STATUS_ERR_MASK        (FM_FD_ERR_UNSUPPORTED_FORMAT   | \
                                         FM_FD_ERR_LENGTH               | \
                                         FM_FD_ERR_DMA                  | \
                                         FM_FD_ERR_IPR                  | \
                                         FM_FD_ERR_IPR_TO               | \
                                         FM_FD_ERR_IPR_NCSP             | \
                                         FM_FD_ERR_PHYSICAL             | \
                                         FM_FD_ERR_SIZE                 | \
                                         FM_FD_ERR_CLS_DISCARD          | \
                                         FM_FD_ERR_COLOR_RED            | \
                                         FM_FD_ERR_COLOR_YELLOW         | \
                                         FM_FD_ERR_ILL_PLCR             | \
                                         FM_FD_ERR_PLCR_FRAME_LEN       | \
                                         FM_FD_ERR_EXTRACTION           | \
                                         FM_FD_ERR_NO_SCHEME            | \
                                         FM_FD_ERR_KEYSIZE_OVERFLOW     | \
                                         FM_FD_ERR_PRS_TIMEOUT          | \
                                         FM_FD_ERR_PRS_ILL_INSTRUCT     | \
                                         FM_FD_ERR_PRS_HDR_ERR          | \
                                         FM_FD_ERR_BLOCK_LIMIT_EXCEEDED) /**< RX Error FD bits */

#define FM_FD_RX_STATUS_ERR_NON_FM      0x00400000  /**< non Frame-Manager error */
/* @} */

/**************************************************************************//**
 @Description   Context A
*//***************************************************************************/
typedef _Packed struct t_FmContextA {
    volatile uint32_t    command;   /**< ContextA Command */
    volatile uint8_t     res0[4];   /**< ContextA Reserved bits */
} _PackedType t_FmContextA;

/**************************************************************************//**
 @Description   Context B
*//***************************************************************************/
typedef uint32_t t_FmContextB;

/**************************************************************************//**
 @Collection   Special Operation options
*//***************************************************************************/
typedef uint32_t fmSpecialOperations_t;                 /**< typedef for defining Special Operation options */

#define  FM_SP_OP_IPSEC                     0x80000000  /**< activate features that related to IPSec (e.g fix Eth-type) */
#define  FM_SP_OP_IPSEC_UPDATE_UDP_LEN      0x40000000  /**< update the UDP-Len after Encryption */
#define  FM_SP_OP_IPSEC_MANIP               0x20000000  /**< handle the IPSec-manip options */
#define  FM_SP_OP_RPD                       0x10000000  /**< Set the RPD bit */
#define  FM_SP_OP_DCL4C                     0x08000000  /**< Set the DCL4C bit */
#define  FM_SP_OP_CHECK_SEC_ERRORS          0x04000000  /**< Check SEC errors */
#define  FM_SP_OP_CLEAR_RPD                 0x02000000  /**< Clear the RPD bit */
#define  FM_SP_OP_CAPWAP_DTLS_ENC           0x01000000  /**< activate features that related to CAPWAP-DTLS post Encryption */
#define  FM_SP_OP_CAPWAP_DTLS_DEC           0x00800000  /**< activate features that related to CAPWAP-DTLS post Decryption */
/* @} */

/**************************************************************************//**
 @Collection   Context A macros
*//***************************************************************************/
#define FM_CONTEXTA_OVERRIDE_MASK       0x80000000
#define FM_CONTEXTA_ICMD_MASK           0x40000000
#define FM_CONTEXTA_A1_VALID_MASK       0x20000000
#define FM_CONTEXTA_MACCMD_MASK         0x00ff0000
#define FM_CONTEXTA_MACCMD_VALID_MASK   0x00800000
#define FM_CONTEXTA_MACCMD_SECURED_MASK 0x00100000
#define FM_CONTEXTA_MACCMD_SC_MASK      0x000f0000
#define FM_CONTEXTA_A1_MASK             0x0000ffff

#define FM_CONTEXTA_GET_OVERRIDE(contextA)                 ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_OVERRIDE_MASK) >> (31-0))
#define FM_CONTEXTA_GET_ICMD(contextA)                     ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_ICMD_MASK) >> (31-1))
#define FM_CONTEXTA_GET_A1_VALID(contextA)                 ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_A1_VALID_MASK) >> (31-2))
#define FM_CONTEXTA_GET_A1(contextA)                       ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_A1_MASK) >> (31-31))
#define FM_CONTEXTA_GET_MACCMD(contextA)                   ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_MASK) >> (31-15))
#define FM_CONTEXTA_GET_MACCMD_VALID(contextA)             ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_VALID_MASK) >> (31-8))
#define FM_CONTEXTA_GET_MACCMD_SECURED(contextA)           ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_SECURED_MASK) >> (31-11))
#define FM_CONTEXTA_GET_MACCMD_SECURE_CHANNEL(contextA)    ((((t_FmContextA *)contextA)->command & FM_CONTEXTA_MACCMD_SC_MASK) >> (31-15))

#define FM_CONTEXTA_SET_OVERRIDE(contextA,val)              (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_OVERRIDE_MASK) | (((uint32_t)(val) << (31-0)) & FM_CONTEXTA_OVERRIDE_MASK) ))
#define FM_CONTEXTA_SET_ICMD(contextA,val)                  (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_ICMD_MASK) | (((val) << (31-1)) & FM_CONTEXTA_ICMD_MASK) ))
#define FM_CONTEXTA_SET_A1_VALID(contextA,val)              (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_A1_VALID_MASK) | (((val) << (31-2)) & FM_CONTEXTA_A1_VALID_MASK) ))
#define FM_CONTEXTA_SET_A1(contextA,val)                    (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_A1_MASK) | (((val) << (31-31)) & FM_CONTEXTA_A1_MASK) ))
#define FM_CONTEXTA_SET_MACCMD(contextA,val)                (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_MASK) | (((val) << (31-15)) & FM_CONTEXTA_MACCMD_MASK) ))
#define FM_CONTEXTA_SET_MACCMD_VALID(contextA,val)          (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_VALID_MASK) | (((val) << (31-8)) & FM_CONTEXTA_MACCMD_VALID_MASK) ))
#define FM_CONTEXTA_SET_MACCMD_SECURED(contextA,val)        (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_SECURED_MASK) | (((val) << (31-11)) & FM_CONTEXTA_MACCMD_SECURED_MASK) ))
#define FM_CONTEXTA_SET_MACCMD_SECURE_CHANNEL(contextA,val) (((t_FmContextA *)contextA)->command = (uint32_t)((((t_FmContextA *)contextA)->command & ~FM_CONTEXTA_MACCMD_SC_MASK) | (((val) << (31-15)) & FM_CONTEXTA_MACCMD_SC_MASK) ))
/* @} */

/**************************************************************************//**
 @Collection   Context B macros
*//***************************************************************************/
#define FM_CONTEXTB_FQID_MASK               0x00ffffff

#define FM_CONTEXTB_GET_FQID(contextB)      (*((t_FmContextB *)contextB) & FM_CONTEXTB_FQID_MASK)
#define FM_CONTEXTB_SET_FQID(contextB,val)  (*((t_FmContextB *)contextB) = ((*((t_FmContextB *)contextB) & ~FM_CONTEXTB_FQID_MASK) | ((val) & FM_CONTEXTB_FQID_MASK)))
/* @} */

#if defined(__MWERKS__) && !defined(__GNUC__)
#pragma pack(pop)
#endif /* defined(__MWERKS__) && ... */


/**************************************************************************//**
 @Description   FM Exceptions
*//***************************************************************************/
typedef enum e_FmExceptions {
    e_FM_EX_DMA_BUS_ERROR = 0,          /**< DMA bus error. */
    e_FM_EX_DMA_READ_ECC,               /**< Read Buffer ECC error (Valid for FM rev < 6)*/
    e_FM_EX_DMA_SYSTEM_WRITE_ECC,       /**< Write Buffer ECC error on system side (Valid for FM rev < 6)*/
    e_FM_EX_DMA_FM_WRITE_ECC,           /**< Write Buffer ECC error on FM side (Valid for FM rev < 6)*/
    e_FM_EX_DMA_SINGLE_PORT_ECC,        /**< Single Port ECC error on FM side (Valid for FM rev > 6)*/
    e_FM_EX_FPM_STALL_ON_TASKS,         /**< Stall of tasks on FPM */
    e_FM_EX_FPM_SINGLE_ECC,             /**< Single ECC on FPM. */
    e_FM_EX_FPM_DOUBLE_ECC,             /**< Double ECC error on FPM ram access */
    e_FM_EX_QMI_SINGLE_ECC,             /**< Single ECC on QMI. */
    e_FM_EX_QMI_DOUBLE_ECC,             /**< Double bit ECC occurred on QMI */
    e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/**< Dequeue from unknown port id */
    e_FM_EX_BMI_LIST_RAM_ECC,           /**< Linked List RAM ECC error */
    e_FM_EX_BMI_STORAGE_PROFILE_ECC,    /**< Storage Profile ECC Error */
    e_FM_EX_BMI_STATISTICS_RAM_ECC,     /**< Statistics Count RAM ECC Error Enable */
    e_FM_EX_BMI_DISPATCH_RAM_ECC,       /**< Dispatch RAM ECC Error Enable */
    e_FM_EX_IRAM_ECC,                   /**< Double bit ECC occurred on IRAM*/
    e_FM_EX_MURAM_ECC                   /**< Double bit ECC occurred on MURAM*/
} e_FmExceptions;

/**************************************************************************//**
 @Description   Enum for defining port DMA swap mode
*//***************************************************************************/
typedef enum e_FmDmaSwapOption {
    e_FM_DMA_NO_SWP = FMAN_DMA_NO_SWP,          /**< No swap, transfer data as is.*/
    e_FM_DMA_SWP_PPC_LE = FMAN_DMA_SWP_PPC_LE,  /**< The transferred data should be swapped
                                                in PowerPc Little Endian mode. */
    e_FM_DMA_SWP_BE = FMAN_DMA_SWP_BE           /**< The transferred data should be swapped
                                                in Big Endian mode */
} e_FmDmaSwapOption;

/**************************************************************************//**
 @Description   Enum for defining port DMA cache attributes
*//***************************************************************************/
typedef enum e_FmDmaCacheOption {
    e_FM_DMA_NO_STASH = FMAN_DMA_NO_STASH,      /**< Cacheable, no Allocate (No Stashing) */
    e_FM_DMA_STASH = FMAN_DMA_STASH             /**< Cacheable and Allocate (Stashing on) */
} e_FmDmaCacheOption;


/**************************************************************************//**
 @Group         FM_init_grp FM Initialization Unit

 @Description   FM Initialization Unit

                Initialization Flow
                Initialization of the FM Module will be carried out by the application
                according to the following sequence:
                -  Calling the configuration routine with basic parameters.
                -  Calling the advance initialization routines to change driver's defaults.
                -  Calling the initialization routine.

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

/**************************************************************************//**
 @Function      t_FmExceptionsCallback

 @Description   Exceptions user callback routine, will be called upon an
                exception passing the exception identification.

 @Param[in]     h_App      - User's application descriptor.
 @Param[in]     exception  - The exception.
*//***************************************************************************/
typedef void (t_FmExceptionsCallback)(t_Handle          h_App,
                                      e_FmExceptions    exception);


/**************************************************************************//**
 @Function      t_FmBusErrorCallback

 @Description   Bus error user callback routine, will be called upon a
                bus error, passing parameters describing the errors and the owner.

 @Param[in]     h_App       - User's application descriptor.
 @Param[in]     portType    - Port type (e_FmPortType)
 @Param[in]     portId      - Port id - relative to type.
 @Param[in]     addr        - Address that caused the error
 @Param[in]     tnum        - Owner of error
 @Param[in]     liodn       - Logical IO device number
*//***************************************************************************/
typedef void (t_FmBusErrorCallback) (t_Handle        h_App,
                                     e_FmPortType    portType,
                                     uint8_t         portId,
                                     uint64_t        addr,
                                     uint8_t         tnum,
                                     uint16_t        liodn);

/**************************************************************************//**
 @Description   A structure for defining buffer prefix area content.
*//***************************************************************************/
typedef struct t_FmBufferPrefixContent {
    uint16_t    privDataSize;       /**< Number of bytes to be left at the beginning
                                         of the external buffer; Note that the private-area will
                                         start from the base of the buffer address. */
    bool        passPrsResult;      /**< TRUE to pass the parse result to/from the FM;
                                         User may use FM_PORT_GetBufferPrsResult() in order to
                                         get the parser-result from a buffer. */
    bool        passTimeStamp;      /**< TRUE to pass the timeStamp to/from the FM
                                         User may use FM_PORT_GetBufferTimeStamp() in order to
                                         get the parser-result from a buffer. */
    bool        passHashResult;     /**< TRUE to pass the KG hash result to/from the FM
                                         User may use FM_PORT_GetBufferHashResult() in order to
                                         get the parser-result from a buffer. */
    bool        passAllOtherPCDInfo;/**< Add all other Internal-Context information:
                                         AD, hash-result, key, etc. */
    uint16_t    dataAlign;          /**< 0 to use driver's default alignment [DEFAULT_FM_SP_bufferPrefixContent_dataAlign],
                                         other value for selecting a data alignment (must be a power of 2);
                                         if write optimization is used, must be >= 16. */
    uint8_t     manipExtraSpace;    /**< Maximum extra size needed (insertion-size minus removal-size);
                                         Note that this field impacts the size of the buffer-prefix
                                         (i.e. it pushes the data offset);
                                         This field is irrelevant if DPAA_VERSION==10 */
} t_FmBufferPrefixContent;

/**************************************************************************//**
 @Description   A structure of information about each of the external
                buffer pools used by a port or storage-profile.
*//***************************************************************************/
typedef struct t_FmExtPoolParams {
    uint8_t                 id;     /**< External buffer pool id */
    uint16_t                size;   /**< External buffer pool buffer size */
} t_FmExtPoolParams;

/**************************************************************************//**
 @Description   A structure for informing the driver about the external
                buffer pools allocated in the BM and used by a port or a
                storage-profile.
*//***************************************************************************/
typedef struct t_FmExtPools {
    uint8_t                 numOfPoolsUsed;     /**< Number of pools use by this port */
    t_FmExtPoolParams       extBufPool[FM_PORT_MAX_NUM_OF_EXT_POOLS];
                                                /**< Parameters for each port */
} t_FmExtPools;

/**************************************************************************//**
 @Description   A structure for defining backup BM Pools.
*//***************************************************************************/
typedef struct t_FmBackupBmPools {
    uint8_t     numOfBackupPools;       /**< Number of BM backup pools -
                                             must be smaller than the total number of
                                             pools defined for the specified port.*/
    uint8_t     poolIds[FM_PORT_MAX_NUM_OF_EXT_POOLS];
                                        /**< numOfBackupPools pool id's, specifying which
                                             pools should be used only as backup. Pool
                                             id's specified here must be a subset of the
                                             pools used by the specified port.*/
} t_FmBackupBmPools;

/**************************************************************************//**
 @Description   A structure for defining BM pool depletion criteria
*//***************************************************************************/
typedef struct t_FmBufPoolDepletion {
    bool        poolsGrpModeEnable;                 /**< select mode in which pause frames will be sent after
                                                         a number of pools (all together!) are depleted */
    uint8_t     numOfPools;                         /**< the number of depleted pools that will invoke
                                                         pause frames transmission. */
    bool        poolsToConsider[BM_MAX_NUM_OF_POOLS];
                                                    /**< For each pool, TRUE if it should be considered for
                                                         depletion (Note - this pool must be used by this port!). */
    bool        singlePoolModeEnable;               /**< select mode in which pause frames will be sent after
                                                         a single-pool is depleted; */
    bool        poolsToConsiderForSingleMode[BM_MAX_NUM_OF_POOLS];
                                                    /**< For each pool, TRUE if it should be considered for
                                                         depletion (Note - this pool must be used by this port!) */
#if (DPAA_VERSION >= 11)
    bool        pfcPrioritiesEn[FM_MAX_NUM_OF_PFC_PRIORITIES];
                                                    /**< This field is used by the MAC as the Priority Enable Vector in the PFC frame which is transmitted */
#endif /* (DPAA_VERSION >= 11) */
} t_FmBufPoolDepletion;

/**************************************************************************//**
 @Description   A Structure for defining Ucode patch for loading.
*//***************************************************************************/
typedef struct t_FmFirmwareParams {
    uint32_t                size;                   /**< Size of uCode */
    uint32_t                *p_Code;                /**< A pointer to the uCode */
} t_FmFirmwareParams;

/**************************************************************************//**
 @Description   A Structure for defining FM initialization parameters
*//***************************************************************************/
typedef struct t_FmParams {
    uint8_t                 fmId;                   /**< Index of the FM */
    uint8_t                 guestId;                /**< FM Partition Id */
    uintptr_t               baseAddr;               /**< A pointer to base of memory mapped FM registers (virtual);
                                                         this field is optional when the FM runs in "guest-mode"
                                                         (i.e. guestId != NCSW_MASTER_ID); in that case, the driver will
                                                         use the memory-map instead of calling the IPC where possible;
                                                         NOTE that this should include ALL common registers of the FM including
                                                         the PCD registers area (i.e. until the VSP pages - 880KB). */
    t_Handle                h_FmMuram;              /**< A handle of an initialized MURAM object,
                                                         to be used by the FM. */
    uint16_t                fmClkFreq;              /**< In Mhz;
                                                         Relevant when FM not runs in "guest-mode". */
    uint16_t                fmMacClkRatio;          /**< FM MAC Clock ratio, for backward comparability:
                                                                     when fmMacClkRatio = 0, ratio is 2:1
                                                                     when fmMacClkRatio = 1, ratio is 1:1  */
    t_FmExceptionsCallback  *f_Exception;           /**< An application callback routine to handle exceptions;
                                                         Relevant when FM not runs in "guest-mode". */
    t_FmBusErrorCallback    *f_BusError;            /**< An application callback routine to handle exceptions;
                                                         Relevant when FM not runs in "guest-mode". */
    t_Handle                h_App;                  /**< A handle to an application layer object; This handle will
                                                         be passed by the driver upon calling the above callbacks;
                                                         Relevant when FM not runs in "guest-mode". */
    int                     irq;                    /**< FM interrupt source for normal events;
                                                         Relevant when FM not runs in "guest-mode". */
    int                     errIrq;                 /**< FM interrupt source for errors;
                                                         Relevant when FM not runs in "guest-mode". */
    t_FmFirmwareParams      firmware;               /**< The firmware parameters structure;
                                                         Relevant when FM not runs in "guest-mode". */

#if (DPAA_VERSION >= 11)
    uintptr_t               vspBaseAddr;            /**< A pointer to base of memory mapped FM VSP registers (virtual);
                                                         i.e. up to 24KB, depending on the specific chip. */
    uint8_t                 partVSPBase;            /**< The first Virtual-Storage-Profile-id dedicated to this partition.
                                                         NOTE: this parameter relevant only when working with multiple partitions. */
    uint8_t                 partNumOfVSPs;          /**< Number of VSPs dedicated to this partition.
                                                         NOTE: this parameter relevant only when working with multiple partitions. */
#endif /* (DPAA_VERSION >= 11) */
} t_FmParams;


/**************************************************************************//**
 @Function      FM_Config

 @Description   Creates the FM module and returns its handle (descriptor).
                This descriptor must be passed as first parameter to all other
                FM function calls.

                No actual initialization or configuration of FM hardware is
                done by this routine. All FM parameters get default values that
                may be changed by calling one or more of the advance config routines.

 @Param[in]     p_FmParams  - A pointer to a data structure of mandatory FM parameters

 @Return        A handle to the FM object, or NULL for Failure.
*//***************************************************************************/
t_Handle FM_Config(t_FmParams *p_FmParams);

/**************************************************************************//**
 @Function      FM_Init

 @Description   Initializes the FM module by defining the software structure
                and configuring the hardware registers.

 @Param[in]     h_Fm - FM module descriptor

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

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

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

                Calling this routine invalidates the descriptor.

 @Param[in]     h_Fm - FM module descriptor

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


/**************************************************************************//**
 @Group         FM_advanced_init_grp    FM Advanced Configuration Unit

 @Description   Advanced configuration routines are optional routines that may
                be called in order to change the default driver settings.

                Note: Advanced configuration routines are not available for guest partition.
 @{
*//***************************************************************************/

/**************************************************************************//**
 @Description   Enum for selecting DMA debug mode
*//***************************************************************************/
typedef enum e_FmDmaDbgCntMode {
    e_FM_DMA_DBG_NO_CNT             = 0,    /**< No counting */
    e_FM_DMA_DBG_CNT_DONE,                  /**< Count DONE commands */
    e_FM_DMA_DBG_CNT_COMM_Q_EM,             /**< count command queue emergency signals */
    e_FM_DMA_DBG_CNT_INT_READ_EM,           /**< Count Internal Read buffer emergency signal */
    e_FM_DMA_DBG_CNT_INT_WRITE_EM,          /**< Count Internal Write buffer emergency signal */
    e_FM_DMA_DBG_CNT_FPM_WAIT,              /**< Count FPM WAIT signal */
    e_FM_DMA_DBG_CNT_SIGLE_BIT_ECC,         /**< Single bit ECC errors. */
    e_FM_DMA_DBG_CNT_RAW_WAR_PROT           /**< Number of times there was a need for RAW & WAR protection. */
} e_FmDmaDbgCntMode;

/**************************************************************************//**
 @Description   Enum for selecting DMA Cache Override
*//***************************************************************************/
typedef enum e_FmDmaCacheOverride {
    e_FM_DMA_NO_CACHE_OR = 0,               /**< No override of the Cache field */
    e_FM_DMA_NO_STASH_DATA,                 /**< Data should not be stashed in system level cache */
    e_FM_DMA_MAY_STASH_DATA,                /**< Data may be stashed in system level cache */
    e_FM_DMA_STASH_DATA                     /**< Data should be stashed in system level cache */
} e_FmDmaCacheOverride;

/**************************************************************************//**
 @Description   Enum for selecting DMA External Bus Priority
*//***************************************************************************/
typedef enum e_FmDmaExtBusPri {
    e_FM_DMA_EXT_BUS_NORMAL = 0,            /**< Normal priority */
    e_FM_DMA_EXT_BUS_EBS,                   /**< AXI extended bus service priority */
    e_FM_DMA_EXT_BUS_SOS,                   /**< AXI sos priority */
    e_FM_DMA_EXT_BUS_EBS_AND_SOS            /**< AXI ebs + sos priority */
} e_FmDmaExtBusPri;

/**************************************************************************//**
 @Description   Enum for choosing the field that will be output on AID
*//***************************************************************************/
typedef enum e_FmDmaAidMode {
    e_FM_DMA_AID_OUT_PORT_ID = 0,           /**< 4 LSB of PORT_ID */
    e_FM_DMA_AID_OUT_TNUM                   /**< 4 LSB of TNUM */
} e_FmDmaAidMode;

/**************************************************************************//**
 @Description   Enum for selecting FPM Catastrophic error behavior
*//***************************************************************************/
typedef enum e_FmCatastrophicErr {
    e_FM_CATASTROPHIC_ERR_STALL_PORT = 0,   /**< Port_ID is stalled (only reset can release it) */
    e_FM_CATASTROPHIC_ERR_STALL_TASK        /**< Only erroneous task is stalled */
} e_FmCatastrophicErr;

/**************************************************************************//**
 @Description   Enum for selecting FPM DMA Error behavior
*//***************************************************************************/
typedef enum e_FmDmaErr {
    e_FM_DMA_ERR_CATASTROPHIC = 0,          /**< Dma error is treated as a catastrophic
                                                 error (e_FmCatastrophicErr)*/
    e_FM_DMA_ERR_REPORT                     /**< Dma error is just reported */
} e_FmDmaErr;

/**************************************************************************//**
 @Description   Enum for selecting DMA Emergency level by BMI emergency signal
*//***************************************************************************/
typedef enum e_FmDmaEmergencyLevel {
    e_FM_DMA_EM_EBS = 0,                    /**< EBS emergency */
    e_FM_DMA_EM_SOS                         /**< SOS emergency */
} e_FmDmaEmergencyLevel;

/**************************************************************************//**
 @Collection   Enum for selecting DMA Emergency options
*//***************************************************************************/
typedef uint32_t fmEmergencyBus_t;          /**< DMA emergency options */

#define  FM_DMA_MURAM_READ_EMERGENCY        0x00800000    /**< Enable emergency for MURAM1 */
#define  FM_DMA_MURAM_WRITE_EMERGENCY       0x00400000    /**< Enable emergency for MURAM2 */
#define  FM_DMA_EXT_BUS_EMERGENCY           0x00100000    /**< Enable emergency for external bus */
/* @} */

/**************************************************************************//**
 @Description   A structure for defining DMA emergency level
*//***************************************************************************/
typedef struct t_FmDmaEmergency {
    fmEmergencyBus_t        emergencyBusSelect;             /**< An OR of the busses where emergency
                                                                 should be enabled */
    e_FmDmaEmergencyLevel   emergencyLevel;                 /**< EBS/SOS */
} t_FmDmaEmergency;

/**************************************************************************//*
 @Description   structure for defining FM threshold
*//***************************************************************************/
typedef struct t_FmThresholds {
    uint8_t                 dispLimit;                      /**< The number of times a frames may
                                                                 be passed in the FM before assumed to
                                                                 be looping. */
    uint8_t                 prsDispTh;                      /**< This is the number pf packets that may be
                                                                 queued in the parser dispatch queue*/
    uint8_t                 plcrDispTh;                     /**< This is the number pf packets that may be
                                                                 queued in the policer dispatch queue*/
    uint8_t                 kgDispTh;                       /**< This is the number pf packets that may be
                                                                 queued in the keygen dispatch queue*/
    uint8_t                 bmiDispTh;                      /**< This is the number pf packets that may be
                                                                 queued in the BMI dispatch queue*/
    uint8_t                 qmiEnqDispTh;                   /**< This is the number pf packets that may be
                                                                 queued in the QMI enqueue dispatch queue*/
    uint8_t                 qmiDeqDispTh;                   /**< This is the number pf packets that may be
                                                                 queued in the QMI dequeue dispatch queue*/
    uint8_t                 fmCtl1DispTh;                   /**< This is the number pf packets that may be
                                                                 queued in fmCtl1 dispatch queue*/
    uint8_t                 fmCtl2DispTh;                   /**< This is the number pf packets that may be
                                                                 queued in fmCtl2 dispatch queue*/
} t_FmThresholds;

/**************************************************************************//*
 @Description   structure for defining DMA thresholds
*//***************************************************************************/
typedef struct t_FmDmaThresholds {
    uint8_t                     assertEmergency;            /**< When this value is reached,
                                                                 assert emergency (Threshold)*/
    uint8_t                     clearEmergency;             /**< After emergency is asserted, it is held
                                                                 until this value is reached (Hystheresis) */
} t_FmDmaThresholds;


/**************************************************************************//**
 @Function      FM_ConfigResetOnInit

 @Description   Define whether to reset the FM before initialization.
                Change the default configuration [DEFAULT_resetOnInit].

 @Param[in]     h_Fm                A handle to an FM 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_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigResetOnInit(t_Handle h_Fm, bool enable);

/**************************************************************************//**
 @Function      FM_ConfigTotalFifoSize

 @Description   Define Total FIFO size for the whole FM.
                Calling this routine changes the total Fifo size in the internal driver
                data base from its default configuration [DEFAULT_totalFifoSize]

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[in]     totalFifoSize       The selected new value.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigTotalFifoSize(t_Handle h_Fm, uint32_t totalFifoSize);

 /**************************************************************************//**
 @Function      FM_ConfigDmaCacheOverride

 @Description   Define cache override mode.
                Calling this routine changes the cache override mode
                in the internal driver data base from its default configuration [DEFAULT_cacheOverride]

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     cacheOverride   The selected new value.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaCacheOverride(t_Handle h_Fm, e_FmDmaCacheOverride cacheOverride);

/**************************************************************************//**
 @Function      FM_ConfigDmaAidOverride

 @Description   Define DMA AID override mode.
                Calling this routine changes the AID override mode
                in the internal driver data base from its default configuration  [DEFAULT_aidOverride]

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     aidOverride     The selected new value.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaAidOverride(t_Handle h_Fm, bool aidOverride);

/**************************************************************************//**
 @Function      FM_ConfigDmaAidMode

 @Description   Define DMA AID  mode.
                Calling this routine changes the AID  mode in the internal
                driver data base from its default configuration [DEFAULT_aidMode]

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     aidMode         The selected new value.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaAidMode(t_Handle h_Fm, e_FmDmaAidMode aidMode);

/**************************************************************************//**
 @Function      FM_ConfigDmaAxiDbgNumOfBeats

 @Description   Define DMA AXI number of beats.
                Calling this routine changes the AXI number of beats in the internal
                driver data base from its default configuration [DEFAULT_axiDbgNumOfBeats]

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[in]     axiDbgNumOfBeats    The selected new value.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaAxiDbgNumOfBeats(t_Handle h_Fm, uint8_t axiDbgNumOfBeats);

/**************************************************************************//**
 @Function      FM_ConfigDmaCamNumOfEntries

 @Description   Define number of CAM entries.
                Calling this routine changes the number of CAM entries in the internal
                driver data base from its default configuration [DEFAULT_dmaCamNumOfEntries].

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     numOfEntries    The selected new value.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaCamNumOfEntries(t_Handle h_Fm, uint8_t numOfEntries);

/**************************************************************************//**
 @Function      FM_ConfigEnableCounters

 @Description   Obsolete, always return E_OK.

 @Param[in]     h_Fm    A handle to an FM Module.

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

/**************************************************************************//**
 @Function      FM_ConfigDmaDbgCounter

 @Description   Define DMA debug counter.
                Calling this routine changes the number of the DMA debug counter in the internal
                driver data base from its default configuration [DEFAULT_dmaDbgCntMode].

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[in]     fmDmaDbgCntMode     An enum selecting the debug counter mode.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaDbgCounter(t_Handle h_Fm, e_FmDmaDbgCntMode fmDmaDbgCntMode);

/**************************************************************************//**
 @Function      FM_ConfigDmaStopOnBusErr

 @Description   Define bus error behavior.
                Calling this routine changes the bus error behavior definition
                in the internal driver data base from its default
                configuration [DEFAULT_dmaStopOnBusError].

 @Param[in]     h_Fm    A handle to an FM Module.
 @Param[in]     stop    TRUE to stop on bus error, FALSE to continue.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                Only if bus error is enabled.
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaStopOnBusErr(t_Handle h_Fm, bool stop);

/**************************************************************************//**
 @Function      FM_ConfigDmaEmergency

 @Description   Define DMA emergency.
                Calling this routine changes the DMA emergency definition
                in the internal driver data base from its default
                configuration where's it's disabled.

 @Param[in]     h_Fm        A handle to an FM Module.
 @Param[in]     p_Emergency An OR mask of all required options.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaEmergency(t_Handle h_Fm, t_FmDmaEmergency *p_Emergency);

/**************************************************************************//**
 @Function      FM_ConfigDmaErr

 @Description   DMA error treatment.
                Calling this routine changes the DMA error treatment
                in the internal driver data base from its default
                configuration [DEFAULT_dmaErr].

 @Param[in]     h_Fm    A handle to an FM Module.
 @Param[in]     dmaErr  The selected new choice.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaErr(t_Handle h_Fm, e_FmDmaErr dmaErr);

/**************************************************************************//**
 @Function      FM_ConfigCatastrophicErr

 @Description   Define FM behavior on catastrophic error.
                Calling this routine changes the FM behavior on catastrophic
                error in the internal driver data base from its default
                [DEFAULT_catastrophicErr].

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[in]     catastrophicErr     The selected new choice.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigCatastrophicErr(t_Handle h_Fm, e_FmCatastrophicErr catastrophicErr);

/**************************************************************************//**
 @Function      FM_ConfigEnableMuramTestMode

 @Description   Enable MURAM test mode.
                Calling this routine changes the internal driver data base
                from its default selection of test mode where it's disabled.
                This routine is only avaiable on old FM revisions (FMan v2).

 @Param[in]     h_Fm    A handle to an FM Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigEnableMuramTestMode(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_ConfigEnableIramTestMode

 @Description   Enable IRAM test mode.
                Calling this routine changes the internal driver data base
                from its default selection of test mode where it's disabled.
                This routine is only avaiable on old FM revisions (FMan v2).

 @Param[in]     h_Fm    A handle to an FM Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigEnableIramTestMode(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_ConfigHaltOnExternalActivation

 @Description   Define FM behavior on external halt activation.
                Calling this routine changes the FM behavior on external halt
                activation in the internal driver data base from its default
                [DEFAULT_haltOnExternalActivation].

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     enable          TRUE to enable halt on external halt
                                activation.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigHaltOnExternalActivation(t_Handle h_Fm, bool enable);

/**************************************************************************//**
 @Function      FM_ConfigHaltOnUnrecoverableEccError

 @Description   Define FM behavior on external halt activation.
                Calling this routine changes the FM behavior on unrecoverable
                ECC error in the internal driver data base from its default
                [DEFAULT_haltOnUnrecoverableEccError].
                This routine is only avaiable on old FM revisions (FMan v2).

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     enable          TRUE to enable halt on unrecoverable Ecc error

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigHaltOnUnrecoverableEccError(t_Handle h_Fm, bool enable);

/**************************************************************************//**
 @Function      FM_ConfigException

 @Description   Define FM exceptions.
                Calling this routine changes the exceptions defaults in the
                internal driver data base where all exceptions are enabled.

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     exception       The exception to be selected.
 @Param[in]     enable          TRUE to enable interrupt, FALSE to mask it.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigException(t_Handle h_Fm, e_FmExceptions exception, bool enable);

/**************************************************************************//**
 @Function      FM_ConfigExternalEccRamsEnable

 @Description   Select external ECC enabling.
                Calling this routine changes the ECC enabling control in the internal
                driver data base from its default [DEFAULT_externalEccRamsEnable].
                When this option is enabled Rams ECC enabling is not effected
                by FM_EnableRamsEcc/FM_DisableRamsEcc, but by a JTAG.

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     enable          TRUE to enable this option.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigExternalEccRamsEnable(t_Handle h_Fm, bool enable);

/**************************************************************************//**
 @Function      FM_ConfigTnumAgingPeriod

 @Description   Define Tnum aging period.
                Calling this routine changes the Tnum aging of dequeue TNUMs
                in the QMI in the internal driver data base from its default
                [DEFAULT_tnumAgingPeriod].

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[in]     tnumAgingPeriod     Tnum Aging Period in microseconds.
                                    Note that period is recalculated in units of
                                    64 FM clocks. Driver will pick the closest
                                    possible period.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
                NOTE that if some MAC is configured for PFC, '0' value is NOT
                allowed.
*//***************************************************************************/
t_Error FM_ConfigTnumAgingPeriod(t_Handle h_Fm, uint16_t tnumAgingPeriod);

/**************************************************************************//*
 @Function      FM_ConfigDmaEmergencySmoother

 @Description   Define DMA emergency smoother.
                Calling this routine changes the definition of the minimum
                amount of DATA beats transferred on the AXI READ and WRITE
                ports before lowering the emergency level.
                By default smoother is disabled.

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     emergencyCnt    emergency switching counter.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaEmergencySmoother(t_Handle h_Fm, uint32_t emergencyCnt);

/**************************************************************************//*
 @Function      FM_ConfigThresholds

 @Description   Calling this routine changes the internal driver data base
                from its default FM threshold configuration:
                    dispLimit:    [DEFAULT_dispLimit]
                    prsDispTh:    [DEFAULT_prsDispTh]
                    plcrDispTh:   [DEFAULT_plcrDispTh]
                    kgDispTh:     [DEFAULT_kgDispTh]
                    bmiDispTh:    [DEFAULT_bmiDispTh]
                    qmiEnqDispTh: [DEFAULT_qmiEnqDispTh]
                    qmiDeqDispTh: [DEFAULT_qmiDeqDispTh]
                    fmCtl1DispTh: [DEFAULT_fmCtl1DispTh]
                    fmCtl2DispTh: [DEFAULT_fmCtl2DispTh]


 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     p_FmThresholds  A structure of threshold parameters.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigThresholds(t_Handle h_Fm, t_FmThresholds *p_FmThresholds);

/**************************************************************************//*
 @Function      FM_ConfigDmaSosEmergencyThreshold

 @Description   Calling this routine changes the internal driver data base
                from its default dma SOS emergency configuration [DEFAULT_dmaSosEmergency]

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[in]     dmaSosEmergency     The selected new value.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaSosEmergencyThreshold(t_Handle h_Fm, uint32_t dmaSosEmergency);

/**************************************************************************//*
 @Function      FM_ConfigDmaWriteBufThresholds

 @Description   Calling this routine changes the internal driver data base
                from its default configuration of DMA write buffer threshold
                assertEmergency: [DEFAULT_dmaWriteIntBufLow]
                clearEmergency:  [DEFAULT_dmaWriteIntBufHigh]
                This routine is only avaiable on old FM revisions (FMan v2).

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[in]     p_FmDmaThresholds   A structure of thresholds to define emergency behavior -
                                    When 'assertEmergency' value is reached, emergency is asserted,
                                    then it is held until 'clearEmergency' value is reached.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaWriteBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);

 /**************************************************************************//*
 @Function      FM_ConfigDmaCommQThresholds

 @Description   Calling this routine changes the internal driver data base
                from its default configuration of DMA command queue threshold
                assertEmergency: [DEFAULT_dmaCommQLow]
                clearEmergency:  [DEFAULT_dmaCommQHigh]

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[in]     p_FmDmaThresholds   A structure of thresholds to define emergency behavior -
                                    When 'assertEmergency' value is reached, emergency is asserted,
                                    then it is held until 'clearEmergency' value is reached..

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaCommQThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);

/**************************************************************************//*
 @Function      FM_ConfigDmaReadBufThresholds

 @Description   Calling this routine changes the internal driver data base
                from its default configuration of DMA read buffer threshold
                assertEmergency: [DEFAULT_dmaReadIntBufLow]
                clearEmergency:  [DEFAULT_dmaReadIntBufHigh]
                This routine is only avaiable on old FM revisions (FMan v2).

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[in]     p_FmDmaThresholds   A structure of thresholds to define emergency behavior -
                                    When 'assertEmergency' value is reached, emergency is asserted,
                                    then it is held until 'clearEmergency' value is reached..

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaReadBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);

/**************************************************************************//*
 @Function      FM_ConfigDmaWatchdog

 @Description   Calling this routine changes the internal driver data base
                from its default watchdog configuration, which is disabled
                [DEFAULT_dmaWatchdog].

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     watchDogValue   The selected new value - in microseconds.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ConfigDmaWatchdog(t_Handle h_Fm, uint32_t watchDogValue);

/** @} */ /* end of FM_advanced_init_grp group */
/** @} */ /* end of FM_init_grp group */


/**************************************************************************//**
 @Group         FM_runtime_control_grp FM Runtime Control Unit

 @Description   FM Runtime control unit API functions, definitions and enums.
                The FM driver provides a set of control routines.
                These routines may only be called after the module was fully
                initialized (both configuration and initialization routines were
                called). They are typically used to get information from hardware
                (status, counters/statistics, revision etc.), to modify a current
                state or to force/enable a required action. Run-time control may
                be called whenever necessary and as many times as needed.
 @{
*//***************************************************************************/

/**************************************************************************//**
 @Collection   General FM defines.
*//***************************************************************************/
#define FM_MAX_NUM_OF_VALID_PORTS   (FM_MAX_NUM_OF_OH_PORTS +       \
                                     FM_MAX_NUM_OF_1G_RX_PORTS +    \
                                     FM_MAX_NUM_OF_10G_RX_PORTS +   \
                                     FM_MAX_NUM_OF_1G_TX_PORTS +    \
                                     FM_MAX_NUM_OF_10G_TX_PORTS)      /**< Number of available FM ports */
/* @} */

/**************************************************************************//*
 @Description   A Structure for Port bandwidth requirement. Port is identified
                by type and relative id.
*//***************************************************************************/
typedef struct t_FmPortBandwidth {
    e_FmPortType        type;           /**< FM port type */
    uint8_t             relativePortId; /**< Type relative port id */
    uint8_t             bandwidth;      /**< bandwidth - (in term of percents) */
} t_FmPortBandwidth;

/**************************************************************************//*
 @Description   A Structure containing an array of Port bandwidth requirements.
                The user should state the ports requiring bandwidth in terms of
                percentage - i.e. all port's bandwidths in the array must add
                up to 100.
*//***************************************************************************/
typedef struct t_FmPortsBandwidthParams {
    uint8_t             numOfPorts;         /**< The number of relevant ports, which is the
                                                 number of valid entries in the array below */
    t_FmPortBandwidth   portsBandwidths[FM_MAX_NUM_OF_VALID_PORTS];
                                            /**< for each port, it's bandwidth (all port's
                                                 bandwidths must add up to 100.*/
} t_FmPortsBandwidthParams;

/**************************************************************************//**
 @Description   DMA Emergency control on MURAM
*//***************************************************************************/
typedef enum e_FmDmaMuramPort {
    e_FM_DMA_MURAM_PORT_WRITE,              /**< MURAM write port */
    e_FM_DMA_MURAM_PORT_READ                /**< MURAM read port */
} e_FmDmaMuramPort;

/**************************************************************************//**
 @Description   Enum for defining FM counters
*//***************************************************************************/
typedef enum e_FmCounters {
    e_FM_COUNTERS_ENQ_TOTAL_FRAME = 0,              /**< QMI total enqueued frames counter */
    e_FM_COUNTERS_DEQ_TOTAL_FRAME,                  /**< QMI total dequeued frames counter */
    e_FM_COUNTERS_DEQ_0,                            /**< QMI 0 frames from QMan counter */
    e_FM_COUNTERS_DEQ_1,                            /**< QMI 1 frames from QMan counter */
    e_FM_COUNTERS_DEQ_2,                            /**< QMI 2 frames from QMan counter */
    e_FM_COUNTERS_DEQ_3,                            /**< QMI 3 frames from QMan counter */
    e_FM_COUNTERS_DEQ_FROM_DEFAULT,                 /**< QMI dequeue from default queue counter */
    e_FM_COUNTERS_DEQ_FROM_CONTEXT,                 /**< QMI dequeue from FQ context counter */
    e_FM_COUNTERS_DEQ_FROM_FD,                      /**< QMI dequeue from FD command field counter */
    e_FM_COUNTERS_DEQ_CONFIRM                       /**< QMI dequeue confirm counter */
} e_FmCounters;

/**************************************************************************//**
 @Description   A Structure for returning FM revision information
*//***************************************************************************/
typedef struct t_FmRevisionInfo {
    uint8_t         majorRev;               /**< Major revision */
    uint8_t         minorRev;               /**< Minor revision */
} t_FmRevisionInfo;

/**************************************************************************//**
 @Description   A Structure for returning FM ctrl code revision information
*//***************************************************************************/
typedef struct t_FmCtrlCodeRevisionInfo {
    uint16_t        packageRev;             /**< Package revision */
    uint8_t         majorRev;               /**< Major revision */
    uint8_t         minorRev;               /**< Minor revision */
} t_FmCtrlCodeRevisionInfo;

/**************************************************************************//**
 @Description   A Structure for defining DMA status
*//***************************************************************************/
typedef struct t_FmDmaStatus {
    bool    cmqNotEmpty;            /**< Command queue is not empty */
    bool    busError;               /**< Bus error occurred */
    bool    readBufEccError;        /**< Double ECC error on buffer Read (Valid for FM rev < 6)*/
    bool    writeBufEccSysError;    /**< Double ECC error on buffer write from system side (Valid for FM rev < 6)*/
    bool    writeBufEccFmError;     /**< Double ECC error on buffer write from FM side (Valid for FM rev < 6) */
    bool    singlePortEccError;     /**< Single Port ECC error from FM side (Valid for FM rev >= 6)*/
} t_FmDmaStatus;

/**************************************************************************//**
 @Description   A Structure for obtaining FM controller monitor values
*//***************************************************************************/
typedef struct t_FmCtrlMon {
    uint8_t percentCnt[2];          /**< Percentage value */
} t_FmCtrlMon;


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

 @Description   Dumps all FM registers

 @Param[in]     h_Fm      A handle to an FM Module.

 @Return        E_OK on success;

 @Cautions      Allowed only following FM_Init().
*//***************************************************************************/
t_Error FM_DumpRegs(t_Handle h_Fm);
#endif /* (defined(DEBUG_ERRORS) && ... */

/**************************************************************************//**
 @Function      FM_SetException

 @Description   Calling this routine enables/disables the specified exception.

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     exception       The exception to be selected.
 @Param[in]     enable          TRUE to enable interrupt, FALSE to mask it.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_SetException(t_Handle h_Fm, e_FmExceptions exception, bool enable);

/**************************************************************************//**
 @Function      FM_EnableRamsEcc

 @Description   Enables ECC mechanism for all the different FM RAM's; E.g. IRAM,
                MURAM, Parser, Keygen, Policer, etc.
                Note:
                If FM_ConfigExternalEccRamsEnable was called to enable external
                setting of ECC, this routine effects IRAM ECC only.
                This routine is also called by the driver if an ECC exception is
                enabled.

 @Param[in]     h_Fm            A handle to an FM Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_EnableRamsEcc(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_DisableRamsEcc

 @Description   Disables ECC mechanism for all the different FM RAM's; E.g. IRAM,
                MURAM, Parser, Keygen, Policer, etc.
                Note:
                If FM_ConfigExternalEccRamsEnable was called to enable external
                setting of ECC, this routine effects IRAM ECC only.
                In opposed to FM_EnableRamsEcc, this routine must be called
                explicitly to disable all Rams ECC.

 @Param[in]     h_Fm            A handle to an FM Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_DisableRamsEcc(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_GetRevision

 @Description   Returns the FM revision

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[out]    p_FmRevisionInfo    A structure of revision information parameters.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Init().
*//***************************************************************************/
t_Error  FM_GetRevision(t_Handle h_Fm, t_FmRevisionInfo *p_FmRevisionInfo);

/**************************************************************************//**
 @Function      FM_GetFmanCtrlCodeRevision

 @Description   Returns the Fman controller code revision

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[out]    p_RevisionInfo      A structure of revision information parameters.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Init().
*//***************************************************************************/
t_Error FM_GetFmanCtrlCodeRevision(t_Handle h_Fm, t_FmCtrlCodeRevisionInfo *p_RevisionInfo);

/**************************************************************************//**
 @Function      FM_GetCounter

 @Description   Reads one of the FM counters.

 @Param[in]     h_Fm        A handle to an FM Module.
 @Param[in]     counter     The requested counter.

 @Return        Counter's current value.

 @Cautions      Allowed only following FM_Init().
                Note that it is user's responsibility to call this routine only
                for enabled counters, and there will be no indication if a
                disabled counter is accessed.
*//***************************************************************************/
uint32_t  FM_GetCounter(t_Handle h_Fm, e_FmCounters counter);

/**************************************************************************//**
 @Function      FM_ModifyCounter

 @Description   Sets a value to an enabled counter. Use "0" to reset the counter.

 @Param[in]     h_Fm        A handle to an FM Module.
 @Param[in]     counter     The requested counter.
 @Param[in]     val         The requested value to be written into the counter.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error  FM_ModifyCounter(t_Handle h_Fm, e_FmCounters counter, uint32_t val);

/**************************************************************************//**
 @Function      FM_Resume

 @Description   Release FM after halt FM command or after unrecoverable ECC error.

 @Param[in]     h_Fm        A handle to an FM Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
void FM_Resume(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_SetDmaEmergency

 @Description   Manual emergency set

 @Param[in]     h_Fm        A handle to an FM Module.
 @Param[in]     muramPort   MURAM direction select.
 @Param[in]     enable      TRUE to manually enable emergency, FALSE to disable.

 @Return        None.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
void FM_SetDmaEmergency(t_Handle h_Fm, e_FmDmaMuramPort muramPort, bool enable);

/**************************************************************************//**
 @Function      FM_SetDmaExtBusPri

 @Description   Set the DMA external bus priority

 @Param[in]     h_Fm    A handle to an FM Module.
 @Param[in]     pri     External bus priority select

 @Return        None.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
void FM_SetDmaExtBusPri(t_Handle h_Fm, e_FmDmaExtBusPri pri);

/**************************************************************************//**
 @Function      FM_GetDmaStatus

 @Description   Reads the DMA current status

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[out]    p_FmDmaStatus   A structure of DMA status parameters.

 @Cautions      Allowed only following FM_Init().
*//***************************************************************************/
void FM_GetDmaStatus(t_Handle h_Fm, t_FmDmaStatus *p_FmDmaStatus);

/**************************************************************************//**
 @Function      FM_ErrorIsr

 @Description   FM interrupt-service-routine for errors.

 @Param[in]     h_Fm            A handle to an FM Module.

 @Return        E_OK on success; E_EMPTY if no errors found in register, other
                error code otherwise.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ErrorIsr(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_EventIsr

 @Description   FM interrupt-service-routine for normal events.

 @Param[in]     h_Fm            A handle to an FM Module.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
void FM_EventIsr(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_GetSpecialOperationCoding

 @Description   Return a specific coding according to the input mask.

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     spOper          special operation mask.
 @Param[out]    p_SpOperCoding  special operation code.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Init().
*//***************************************************************************/
t_Error FM_GetSpecialOperationCoding(t_Handle               h_Fm,
                                     fmSpecialOperations_t  spOper,
                                     uint8_t                *p_SpOperCoding);

/**************************************************************************//**
 @Function      FM_CtrlMonStart

 @Description   Start monitoring utilization of all available FM controllers.

                In order to obtain FM controllers utilization the following sequence
                should be used:
                -# FM_CtrlMonStart()
                -# FM_CtrlMonStop()
                -# FM_CtrlMonGetCounters() - issued for each FM controller

 @Param[in]     h_Fm            A handle to an FM Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID).
*//***************************************************************************/
t_Error FM_CtrlMonStart(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_CtrlMonStop

 @Description   Stop monitoring utilization of all available FM controllers.

                In order to obtain FM controllers utilization the following sequence
                should be used:
                -# FM_CtrlMonStart()
                -# FM_CtrlMonStop()
                -# FM_CtrlMonGetCounters() - issued for each FM controller

 @Param[in]     h_Fm            A handle to an FM Module.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID).
*//***************************************************************************/
t_Error FM_CtrlMonStop(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_CtrlMonGetCounters

 @Description   Obtain FM controller utilization parameters.

                In order to obtain FM controllers utilization the following sequence
                should be used:
                -# FM_CtrlMonStart()
                -# FM_CtrlMonStop()
                -# FM_CtrlMonGetCounters() - issued for each FM controller

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     fmCtrlIndex     FM Controller index for that utilization results
                                are requested.
 @Param[in]     p_Mon           Pointer to utilization results structure.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID).
*//***************************************************************************/
t_Error FM_CtrlMonGetCounters(t_Handle h_Fm, uint8_t fmCtrlIndex, t_FmCtrlMon *p_Mon);


/**************************************************************************//*
 @Function      FM_ForceIntr

 @Description   Causes an interrupt event on the requested source.

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     exception       An exception to be forced.

 @Return        E_OK on success; Error code if the exception is not enabled,
                or is not able to create interrupt.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_ForceIntr (t_Handle h_Fm, e_FmExceptions exception);

/**************************************************************************//*
 @Function      FM_SetPortsBandwidth

 @Description   Sets relative weights between ports when accessing common resources.

 @Param[in]     h_Fm                A handle to an FM Module.
 @Param[in]     p_PortsBandwidth    A structure of ports bandwidths in percentage, i.e.
                                    total must equal 100.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Init().
                This routine should NOT be called from guest-partition
                (i.e. guestId != NCSW_MASTER_ID)
*//***************************************************************************/
t_Error FM_SetPortsBandwidth(t_Handle h_Fm, t_FmPortsBandwidthParams *p_PortsBandwidth);

/** @} */ /* end of FM_runtime_control_grp group */
/** @} */ /* end of FM_lib_grp group */
/** @} */ /* end of FM_grp group */


#ifdef NCSW_BACKWARD_COMPATIBLE_API
typedef t_FmFirmwareParams          t_FmPcdFirmwareParams;
typedef t_FmBufferPrefixContent     t_FmPortBufferPrefixContent;
typedef t_FmExtPoolParams           t_FmPortExtPoolParams;
typedef t_FmExtPools                t_FmPortExtPools;
typedef t_FmBackupBmPools           t_FmPortBackupBmPools;
typedef t_FmBufPoolDepletion        t_FmPortBufPoolDepletion;
typedef e_FmDmaSwapOption           e_FmPortDmaSwapOption;
typedef e_FmDmaCacheOption          e_FmPortDmaCacheOption;

#define FM_CONTEXTA_GET_OVVERIDE    FM_CONTEXTA_GET_OVERRIDE
#define FM_CONTEXTA_SET_OVVERIDE    FM_CONTEXTA_SET_OVERRIDE

#define e_FM_EX_BMI_PIPELINE_ECC    e_FM_EX_BMI_STORAGE_PROFILE_ECC
#define e_FM_PORT_DMA_NO_SWP        e_FM_DMA_NO_SWP
#define e_FM_PORT_DMA_SWP_PPC_LE    e_FM_DMA_SWP_PPC_LE
#define e_FM_PORT_DMA_SWP_BE        e_FM_DMA_SWP_BE
#define e_FM_PORT_DMA_NO_STASH      e_FM_DMA_NO_STASH
#define e_FM_PORT_DMA_STASH         e_FM_DMA_STASH
#endif /* NCSW_BACKWARD_COMPATIBLE_API */


#endif /* __FM_EXT */