summaryrefslogtreecommitdiffstats
path: root/sys/contrib/ncsw/inc/Peripherals/fm_ext.h
blob: 9b5db04f392f913e3da0d49e8682e20f470d9329 (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
/* Copyright (c) 2008-2011 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"


/**************************************************************************//**
 @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. Before any further module initialization,
                this module must be initialized.
                The FM is a "singletone" module. It is responsible of the common
                HW modules: FPM, DMA, common QMI, common BMI initializations and
                run-time control routines. This module must be initialized always
                when working with any of the FM modules.
                NOTE - We assumes that the FML will be initialize 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 (id's: 0-6, share id's with
                                                 host command, so must have exclusive id) */
    e_FM_PORT_TYPE_OH_HOST_COMMAND,         /**< Host command port (id's: 0-6, share id's with
                                                 offline parsing ports, so must have exclusive id) */
    e_FM_PORT_TYPE_RX,                      /**< 1G Rx port (id's: 0-3) */
    e_FM_PORT_TYPE_RX_10G,                  /**< 10G Rx port (id's: 0) */
    e_FM_PORT_TYPE_TX,                      /**< 1G Tx port (id's: 0-3) */
    e_FM_PORT_TYPE_TX_10G,                  /**< 10G Tx port (id's: 0) */
    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__) && ... */
#define MEM_MAP_START

/**************************************************************************//**
 @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;              /**< Checksum */
    volatile uint32_t    lcv;                /**< LCV */
    volatile uint8_t     shim_off[3];        /**< Shim 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_TX_STATUS_ERR_MASK    0x07000000  /**< TX Error FD bits */
#define FM_FD_RX_STATUS_ERR_MASK    0x070ee3f8  /**< RX Error FD bits */
/* @} */

/**************************************************************************//**
 @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   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)))
/* @} */

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


/**************************************************************************//**
 @Description   FM Exceptions
*//***************************************************************************/
typedef enum e_FmExceptions {
    e_FM_EX_DMA_BUS_ERROR,              /**< DMA bus error. */
    e_FM_EX_DMA_READ_ECC,               /**< Read Buffer ECC error */
    e_FM_EX_DMA_SYSTEM_WRITE_ECC,       /**< Write Buffer ECC error on system side */
    e_FM_EX_DMA_FM_WRITE_ECC,           /**< Write Buffer ECC error on FM side */
    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,/**< Dequeu from unknown port id */
    e_FM_EX_BMI_LIST_RAM_ECC,           /**< Linked List RAM ECC error */
    e_FM_EX_BMI_PIPELINE_ECC,           /**< Pipeline Table 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;

/**************************************************************************//**
 @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:
                a.  Calling the configuration routine with basic parameters.
                b.  Calling the advance initialization routines to change driver's defaults.
                c.  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   structure for defining Ucode patch for loading.
*//***************************************************************************/
typedef struct t_FmPcdFirmwareParams {
    uint32_t                size;                   /**< Size of uCode */
    uint32_t                *p_Code;                /**< A pointer to the uCode */
} t_FmPcdFirmwareParams;

/**************************************************************************//**
 @Description   structure representing FM initialization parameters
*//***************************************************************************/
#define FM_SIZE_OF_LIODN_TABLE  64
typedef struct t_FmParams {
    uint8_t                 fmId;                   /**< Index of the FM */

    uint8_t                 guestId;                /**< FM Partition Id */

    uintptr_t               baseAddr;               /**< Relevant when guestId = NCSW_MASSTER_ID only.
                                                         A pointer to base of memory mapped FM registers (virtual);
                                                         NOTE that this should include ALL common regs of the FM including
                                                         the PCD regs area. */
    t_Handle                h_FmMuram;              /**< Relevant when guestId = NCSW_MASSTER_ID only.
                                                         A handle of an initialized MURAM object,
                                                         to be used by the FM */
    uint16_t                fmClkFreq;              /**< Relevant when guestId = NCSW_MASSTER_ID only.
                                                         In Mhz */
#ifdef FM_PARTITION_ARRAY
    uint16_t                liodnBasePerPort[FM_SIZE_OF_LIODN_TABLE];
                                                    /**< Relevant when guestId = NCSW_MASSTER_ID only.
                                                         For each partition, LIODN should be configured here. */
#endif /* FM_PARTITION_ARRAY */
    t_FmExceptionsCallback  *f_Exception;           /**< Relevant when guestId = NCSW_MASSTER_ID only.
                                                         An application callback routine to
                                                         handle exceptions.*/
    t_FmBusErrorCallback    *f_BusError;            /**< Relevant when guestId = NCSW_MASSTER_ID only.
                                                         An application callback routine to
                                                         handle exceptions.*/
    t_Handle                h_App;                  /**< Relevant when guestId = NCSW_MASSTER_ID only.
                                                         A handle to an application layer object; This handle will
                                                         be passed by the driver upon calling the above callbacks */
    int                     irq;                    /**< Relevant when guestId = NCSW_MASSTER_ID only.
                                                         FM interrupt source for normal events */
    int                     errIrq;                 /**< Relevant when guestId = NCSW_MASSTER_ID only.
                                                         FM interrupt source for errors */
    t_FmPcdFirmwareParams   firmware;               /**< Relevant when guestId = NCSW_MASSTER_ID only.
                                                         Ucode */
} t_FmParams;


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

 @Description   Creates descriptor for the FM module.

                The routine returns a handle (descriptor) to the FM object.
                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.

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

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

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

 @Description   Initializes the FM module

 @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   Configuration functions used to change default values;
                Note: Advanced init routines are not available for guest partition.
 @{
*//***************************************************************************/

/**************************************************************************//**
 @Description   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   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   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   FPM Catasrophic error behaviour
*//***************************************************************************/
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 errornous task is stalled */
} e_FmCatastrophicErr;

/**************************************************************************//**
 @Description   FPM DMA error behaviour
*//***************************************************************************/
typedef enum e_FmDmaErr {
    e_FM_DMA_ERR_CATASTROPHIC = 0,          /**< Dma error is treated as a catastrophic error */
    e_FM_DMA_ERR_REPORT                     /**< Dma error is just reported */
} e_FmDmaErr;

/**************************************************************************//**
 @Description   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   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   Tell the driver whether to reset the FM before initialization or
                not. It changes the default configuration [FALSE].

 @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().
*//***************************************************************************/
t_Error FM_ConfigResetOnInit(t_Handle h_Fm, bool enable);

/**************************************************************************//**
 @Function      FM_ConfigTotalNumOfTasks

 @Description   Change the total number of tasks from its default
                configuration [BMI_MAX_NUM_OF_TASKS]

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

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
*//***************************************************************************/
t_Error FM_ConfigTotalNumOfTasks(t_Handle h_Fm, uint8_t totalNumOfTasks);

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

 @Description   Change the total Fifo size from its default
                configuration [BMI_MAX_FIFO_SIZE]

 @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().
*//***************************************************************************/
t_Error FM_ConfigTotalFifoSize(t_Handle h_Fm, uint32_t totalFifoSize);

/**************************************************************************//**
 @Function      FM_ConfigMaxNumOfOpenDmas

 @Description   Change the maximum allowed open DMA's for this FM from its default
                configuration [BMI_MAX_NUM_OF_DMAS]

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

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only following FM_Config() and before FM_Init().
*//***************************************************************************/
t_Error FM_ConfigMaxNumOfOpenDmas(t_Handle h_Fm, uint8_t maxNumOfOpenDmas);

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

 @Description   Calling this routine changes the internal driver data base
                from its default FM threshold configuration:
                                          dispLimit:    [0]
                                          prsDispTh:    [16]
                                          plcrDispTh:   [16]
                                          kgDispTh:     [16]
                                          bmiDispTh:    [16]
                                          qmiEnqDispTh: [16]
                                          qmiDeqDispTh: [16]
                                          fmCtl1DispTh:  [16]
                                          fmCtl2DispTh:  [16]

 @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().
*//***************************************************************************/
t_Error FM_ConfigThresholds(t_Handle h_Fm, t_FmThresholds *p_FmThresholds);

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

 @Description   Calling this routine changes the internal driver data base
                from its default configuration of cache override mode [e_FM_DMA_NO_CACHE_OR]

 @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().
*//***************************************************************************/
t_Error FM_ConfigDmaCacheOverride(t_Handle h_Fm, e_FmDmaCacheOverride cacheOverride);

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

 @Description   Calling this routine changes the internal driver data base
                from its default configuration of aid override mode [TRUE]

 @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().
*//***************************************************************************/
t_Error FM_ConfigDmaAidOverride(t_Handle h_Fm, bool aidOverride);

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

 @Description   Calling this routine changes the internal driver data base
                from its default configuration of aid mode [e_FM_DMA_AID_OUT_TNUM]

 @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().
*//***************************************************************************/
t_Error FM_ConfigDmaAidMode(t_Handle h_Fm, e_FmDmaAidMode aidMode);

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

 @Description   Calling this routine changes the internal driver data base
                from its default configuration of axi debug [1]

 @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().
*//***************************************************************************/
t_Error FM_ConfigDmaAxiDbgNumOfBeats(t_Handle h_Fm, uint8_t axiDbgNumOfBeats);

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

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

 @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().
*//***************************************************************************/
t_Error FM_ConfigDmaCamNumOfEntries(t_Handle h_Fm, uint8_t numOfEntries);

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

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

 @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().
*//***************************************************************************/
t_Error FM_ConfigDmaWatchdog(t_Handle h_Fm, uint32_t watchDogValue);

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

 @Description   Calling this routine changes the internal driver data base
                from its default configuration of DMA write buffer threshold
                assertEmergency: [DMA_THRESH_MAX_BUF]
                clearEmergency:  [DMA_THRESH_MAX_BUF]

 @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().
*//***************************************************************************/
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: [DMA_THRESH_MAX_COMMQ]
                clearEmergency:  [DMA_THRESH_MAX_COMMQ]

 @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().
*//***************************************************************************/
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: [DMA_THRESH_MAX_BUF]
                clearEmergency:  [DMA_THRESH_MAX_BUF]

 @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().
*//***************************************************************************/
t_Error FM_ConfigDmaReadBufThresholds(t_Handle h_Fm, t_FmDmaThresholds *p_FmDmaThresholds);

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

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

 @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().
*//***************************************************************************/
t_Error FM_ConfigDmaSosEmergencyThreshold(t_Handle h_Fm, uint32_t dmaSosEmergency);

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

 @Description   Calling this routine changes the internal driver data base
                from its default counters configuration where counters are disabled.

 @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().
*//***************************************************************************/
t_Error FM_ConfigEnableCounters(t_Handle h_Fm);

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

 @Description   Calling this routine changes the internal driver data base
                from its default DMA debug counters configuration [e_FM_DMA_DBG_NO_CNT]

 @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().
*//***************************************************************************/
t_Error FM_ConfigDmaDbgCounter(t_Handle h_Fm, e_FmDmaDbgCntMode fmDmaDbgCntMode);

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

 @Description   Calling this routine changes the internal driver data base
                from its default selection of bus error behavior [FALSE]


 @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.
*//***************************************************************************/
t_Error FM_ConfigDmaStopOnBusErr(t_Handle h_Fm, bool stop);

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

 @Description   Calling this routine changes the internal driver data base
                from its default selection of DMA emergency 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().
*//***************************************************************************/
t_Error FM_ConfigDmaEmergency(t_Handle h_Fm, t_FmDmaEmergency *p_Emergency);

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

 @Description   sets the minimum amount of DATA beats transferred on the AXI
                READ and WRITE ports before lowering the emergency level.
                By default smother 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().
*//***************************************************************************/
t_Error FM_ConfigDmaEmergencySmoother(t_Handle h_Fm, uint32_t emergencyCnt);

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

 @Description   Calling this routine changes the internal driver data base
                from its default DMA error treatment [e_FM_DMA_ERR_CATASTROPHIC]

 @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().
*//***************************************************************************/
t_Error FM_ConfigDmaErr(t_Handle h_Fm, e_FmDmaErr dmaErr);

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

 @Description   Calling this routine changes the internal driver data base
                from its default behavior on catastrophic error [e_FM_CATASTROPHIC_ERR_STALL_PORT]

 @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().
*//***************************************************************************/
t_Error FM_ConfigCatastrophicErr(t_Handle h_Fm, e_FmCatastrophicErr catastrophicErr);

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

 @Description   Calling this routine changes the internal driver data base
                from its default selection of test mode where it's disabled.

 @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().
*//***************************************************************************/
t_Error FM_ConfigEnableMuramTestMode(t_Handle h_Fm);

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

 @Description   Calling this routine changes the internal driver data base
                from its default selection of test mode where it's disabled.

 @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().
*//***************************************************************************/
t_Error FM_ConfigEnableIramTestMode(t_Handle h_Fm);

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

 @Description   Calling this routine changes the internal driver data base
                from its default selection of FM behaviour on external halt
                activation [FALSE].

 @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().
*//***************************************************************************/
t_Error FM_ConfigHaltOnExternalActivation(t_Handle h_Fm, bool enable);

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

 @Description   Calling this routine changes the internal driver data base
                from its default selection of FM behaviour on unrecoverable
                Ecc error [FALSE].

 @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().
*//***************************************************************************/
t_Error FM_ConfigHaltOnUnrecoverableEccError(t_Handle h_Fm, bool enable);

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

 @Description   Calling this routine changes the internal driver data base
                from its default selection of exceptions enablement.
                By default 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().
*//***************************************************************************/
t_Error FM_ConfigException(t_Handle h_Fm, e_FmExceptions exception, bool enable);

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

 @Description   Calling this routine changes the internal driver data base
                from its default [FALSE].
                When this option is enabled Rams ECC enable is not effected
                by the FPM RCR bit, 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().
*//***************************************************************************/
t_Error FM_ConfigExternalEccRamsEnable(t_Handle h_Fm, bool enable);

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

 @Description   Calling this routine changes the internal driver data base
                from its default configuration for aging of dequeue TNUM's
                in the QMI.[0]
                Note that this functionality is not available in all chips.

 @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().
*//***************************************************************************/
t_Error FM_ConfigTnumAgingPeriod(t_Handle h_Fm, uint16_t tnumAgingPeriod);

/** @} */ /* 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 for each module.
                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)
/* @} */

/**************************************************************************//**
 @Description   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;         /**< num of ports listed 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_FM_COUNTERS_SEMAPHOR_ENTRY_FULL_REJECT,       /**< DMA semaphor reject due to full entry counter */
    e_FM_COUNTERS_SEMAPHOR_QUEUE_FULL_REJECT,       /**< DMA semaphor reject due to full CAM queue counter */
    e_FM_COUNTERS_SEMAPHOR_SYNC_REJECT              /**< DMA semaphor reject due to sync counter */
} e_FmCounters;

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

/**************************************************************************//**
 @Description   struct 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 */
    bool    writeBufEccSysError;    /**< Double ECC error on buffer write from system side */
    bool    writeBufEccFmError;     /**< Double ECC error on buffer write from FM side */
} t_FmDmaStatus;


#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 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.
                Note: Not available for guest partition.

 @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().
*//***************************************************************************/
t_Error FM_SetException(t_Handle h_Fm, e_FmExceptions exception, bool enable);

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

 @Description   Sets relative weights between ports when accessing common resources.
                Note: Not available for guest partition.

 @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().
*//***************************************************************************/
t_Error FM_SetPortsBandwidth(t_Handle h_Fm, t_FmPortsBandwidthParams *p_PortsBandwidth);

/**************************************************************************//**
 @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.
                Note: Not available for guest partition.

 @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().
*//***************************************************************************/
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.
                Note: Not available for guest partition.


 @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().
*//***************************************************************************/
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_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.
                Note: Not available for guest partition.

 @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().
*//***************************************************************************/
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.
                Note: Not available for guest partition.

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

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

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

 @Description   Manual emergency set
                Note: Not available for guest partition.

 @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().
*//***************************************************************************/
void FM_SetDmaEmergency(t_Handle h_Fm, e_FmDmaMuramPort muramPort, bool enable);

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

 @Description   Manual emergency set
                Note: Not available for guest partition.

 @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().
*//***************************************************************************/
void FM_SetDmaExtBusPri(t_Handle h_Fm, e_FmDmaExtBusPri pri);

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

 @Description   Causes an interrupt event on the requested source.
                Note: Not available for guest partition.

 @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().
*//***************************************************************************/
t_Error FM_ForceIntr (t_Handle h_Fm, e_FmExceptions exception);

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

 @Return        None

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

/**************************************************************************//**
 @Function      FM_GetPcdHandle

 @Description   Used by FMC in order to get PCD handle

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

 @Return        A handle to the PCD module, NULL if uninitialized.

 @Cautions      Allowed only following FM_Init().
*//***************************************************************************/
t_Handle FM_GetPcdHandle(t_Handle h_Fm);

/**************************************************************************//**
 @Function      FM_ErrorIsr
                Note: Not available for guest partition.

 @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
                Note: Not available for guest partition.

 @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);

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

 @Description   Dumps FM port registers which are part of FM common registers

 @Param[in]     h_Fm            A handle to an FM Module.
 @Param[in]     hardwarePortId    HW port id.

 @Return        E_OK on success; Error code otherwise.

 @Cautions      Allowed only FM_Init().
*//***************************************************************************/
t_Error FmDumpPortRegs(t_Handle h_Fm,uint8_t hardwarePortId);
#endif /* (defined(DEBUG_ERRORS) && ... */


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

#endif /* __FM_EXT */
OpenPOWER on IntegriCloud